@vkontakte/videoplayer-interactive 1.0.36-dev.5119b35a.0 → 1.0.36-dev.62c89fb9.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.
Files changed (32) hide show
  1. package/es2015.cjs.js +12 -148
  2. package/es2015.esm.js +12 -148
  3. package/es2018.cjs.js +12 -148
  4. package/es2018.esm.js +12 -148
  5. package/es2024.cjs.js +12 -148
  6. package/es2024.esm.js +12 -148
  7. package/esnext.cjs.js +12 -148
  8. package/esnext.esm.js +12 -148
  9. package/evergreen.esm.js +12 -148
  10. package/package.json +4 -4
  11. package/types/modules/Interactives/Interactives.d.ts +4 -8
  12. package/types/modules/Interactives/containers/ChoiceContainer.d.ts +6 -9
  13. package/types/modules/Interactives/containers/Container.d.ts +0 -4
  14. package/types/modules/Interactives/containers/types.d.ts +1 -3
  15. package/types/modules/Interactives/controls/AreaControl.d.ts +2 -3
  16. package/types/modules/Interactives/controls/ButtonControl.d.ts +3 -8
  17. package/types/modules/Interactives/controls/Control.d.ts +4 -15
  18. package/types/modules/Interactives/controls/TextControl.d.ts +1 -2
  19. package/types/modules/Interactives/controls/types.d.ts +1 -3
  20. package/types/modules/Interactives/controls/utils.d.ts +0 -1
  21. package/types/modules/Interactives/index.d.ts +5 -30
  22. package/types/modules/Interactives/types.d.ts +0 -4
  23. package/types/modules/Interactives/utils/GameController.d.ts +4 -9
  24. package/types/modules/Interactives/utils/gameUtils.d.ts +0 -1
  25. package/types/modules/Interactives/utils/ControlFillAnimation/ControlFillAnimation.d.ts +0 -34
  26. package/types/modules/Interactives/utils/ControlFillAnimation/index.d.ts +0 -1
  27. package/types/modules/Interactives/utils/ControlFillAnimation/utils.d.ts +0 -12
  28. package/types/modules/Interactives/utils/ControlTap/ControlTap.d.ts +0 -17
  29. package/types/modules/Interactives/utils/ControlTap/index.d.ts +0 -1
  30. package/types/modules/Interactives/utils/ControlTap/utils.d.ts +0 -6
  31. package/types/modules/Interactives/utils/angleUtils.d.ts +0 -2
  32. package/types/modules/Interactives/utils/emitOnError.d.ts +0 -13
package/es2018.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.36-dev.5119b35a.0
3
- * Tue, 29 Apr 2025 12:25:21 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.36-dev.62c89fb9.0
3
+ * Wed, 07 May 2025 06:34:17 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-36/doc/
5
5
  */
6
- "use strict";var rl=Object.create;var dt=Object.defineProperty;var il=Object.getOwnPropertyDescriptor;var nl=Object.getOwnPropertyNames;var ol=Object.getPrototypeOf,al=Object.prototype.hasOwnProperty;var Ai=r=>{throw TypeError(r)};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),sl=(r,e)=>{for(var t in e)dt(r,t,{get:e[t],enumerable:!0})},wi=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nl(e))!al.call(r,n)&&n!==t&&dt(r,n,{get:()=>e[n],enumerable:!(i=il(e,n))||i.enumerable});return r};var Y=(r,e,t)=>(t=r!=null?rl(ol(r)):{},wi(e||!r||!r.__esModule?dt(t,"default",{value:r,enumerable:!0}):t,r)),ll=r=>wi(dt({},"__esModule",{value:!0}),r);var Si=(r,e,t)=>e.has(r)||Ai("Cannot "+t);var R=(r,e,t)=>(Si(r,e,"read from private field"),t?t.call(r):e.get(r)),D=(r,e,t)=>e.has(r)?Ai("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,i)=>(Si(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Ri=(r,e,t,i)=>({set _(n){N(r,e,n,t)},get _(){return R(r,e,i)}});var J=h((dr,qi)=>{"use strict";var qe=function(r){return r&&r.Math===Math&&r};qi.exports=qe(typeof globalThis=="object"&&globalThis)||qe(typeof window=="object"&&window)||qe(typeof self=="object"&&self)||qe(typeof global=="object"&&global)||qe(typeof dr=="object"&&dr)||function(){return this}()||Function("return this")()});var H=h((Zh,Di)=>{"use strict";Di.exports=function(r){try{return!!r()}catch(e){return!0}}});var De=h((Jh,Hi)=>{"use strict";var pl=H();Hi.exports=!pl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Ki=h((ed,Wi)=>{"use strict";var hl=De(),zi=Function.prototype,Ui=zi.apply,Gi=zi.call;Wi.exports=typeof Reflect=="object"&&Reflect.apply||(hl?Gi.bind(Ui):function(){return Gi.apply(Ui,arguments)})});var W=h((td,Yi)=>{"use strict";var Xi=De(),Qi=Function.prototype,mr=Qi.call,dl=Xi&&Qi.bind.bind(mr,mr);Yi.exports=Xi?dl:function(r){return function(){return mr.apply(r,arguments)}}});var He=h((rd,Ji)=>{"use strict";var Zi=W(),ml=Zi({}.toString),fl=Zi("".slice);Ji.exports=function(r){return fl(ml(r),8,-1)}});var fr=h((id,en)=>{"use strict";var vl=He(),bl=W();en.exports=function(r){if(vl(r)==="Function")return bl(r)}});var U=h((nd,tn)=>{"use strict";var vr=typeof document=="object"&&document.all;tn.exports=typeof vr=="undefined"&&vr!==void 0?function(r){return typeof r=="function"||r===vr}:function(r){return typeof r=="function"}});var fe=h((od,rn)=>{"use strict";var yl=H();rn.exports=!yl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var At=h((ad,nn)=>{"use strict";var gl=De(),xt=Function.prototype.call;nn.exports=gl?xt.bind(xt):function(){return xt.apply(xt,arguments)}});var br=h(sn=>{"use strict";var on={}.propertyIsEnumerable,an=Object.getOwnPropertyDescriptor,Cl=an&&!on.call({1:2},1);sn.f=Cl?function(e){var t=an(this,e);return!!t&&t.enumerable}:on});var yr=h((ld,ln)=>{"use strict";ln.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var un=h((cd,cn)=>{"use strict";var El=W(),Tl=H(),Il=He(),gr=Object,xl=El("".split);cn.exports=Tl(function(){return!gr("z").propertyIsEnumerable(0)})?function(r){return Il(r)==="String"?xl(r,""):gr(r)}:gr});var Cr=h((ud,pn)=>{"use strict";pn.exports=function(r){return r==null}});var Er=h((pd,hn)=>{"use strict";var Al=Cr(),wl=TypeError;hn.exports=function(r){if(Al(r))throw new wl("Can't call method on "+r);return r}});var Ue=h((hd,dn)=>{"use strict";var Sl=un(),Rl=Er();dn.exports=function(r){return Sl(Rl(r))}});var Se=h((dd,mn)=>{"use strict";var kl=U();mn.exports=function(r){return typeof r=="object"?r!==null:kl(r)}});var wt=h((md,fn)=>{"use strict";fn.exports={}});var St=h((fd,bn)=>{"use strict";var Tr=wt(),Ir=J(),Ol=U(),vn=function(r){return Ol(r)?r:void 0};bn.exports=function(r,e){return arguments.length<2?vn(Tr[r])||vn(Ir[r]):Tr[r]&&Tr[r][e]||Ir[r]&&Ir[r][e]}});var gn=h((vd,yn)=>{"use strict";var Pl=W();yn.exports=Pl({}.isPrototypeOf)});var In=h((bd,Tn)=>{"use strict";var Ml=J(),Cn=Ml.navigator,En=Cn&&Cn.userAgent;Tn.exports=En?String(En):""});var On=h((yd,kn)=>{"use strict";var Rn=J(),xr=In(),xn=Rn.process,An=Rn.Deno,wn=xn&&xn.versions||An&&An.version,Sn=wn&&wn.v8,K,Rt;Sn&&(K=Sn.split("."),Rt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!Rt&&xr&&(K=xr.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=xr.match(/Chrome\/(\d+)/),K&&(Rt=+K[1])));kn.exports=Rt});var Ar=h((gd,Mn)=>{"use strict";var Pn=On(),Ll=H(),Fl=J(),Vl=Fl.String;Mn.exports=!!Object.getOwnPropertySymbols&&!Ll(function(){var r=Symbol("symbol detection");return!Vl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Pn&&Pn<41})});var wr=h((Cd,Ln)=>{"use strict";var Nl=Ar();Ln.exports=Nl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Sr=h((Ed,Fn)=>{"use strict";var $l=St(),jl=U(),_l=gn(),Bl=wr(),ql=Object;Fn.exports=Bl?function(r){return typeof r=="symbol"}:function(r){var e=$l("Symbol");return jl(e)&&_l(e.prototype,ql(r))}});var Nn=h((Td,Vn)=>{"use strict";var Dl=String;Vn.exports=function(r){try{return Dl(r)}catch(e){return"Object"}}});var Rr=h((Id,$n)=>{"use strict";var Hl=U(),Ul=Nn(),Gl=TypeError;$n.exports=function(r){if(Hl(r))return r;throw new Gl(Ul(r)+" is not a function")}});var _n=h((xd,jn)=>{"use strict";var zl=Rr(),Wl=Cr();jn.exports=function(r,e){var t=r[e];return Wl(t)?void 0:zl(t)}});var qn=h((Ad,Bn)=>{"use strict";var kr=At(),Or=U(),Pr=Se(),Kl=TypeError;Bn.exports=function(r,e){var t,i;if(e==="string"&&Or(t=r.toString)&&!Pr(i=kr(t,r))||Or(t=r.valueOf)&&!Pr(i=kr(t,r))||e!=="string"&&Or(t=r.toString)&&!Pr(i=kr(t,r)))return i;throw new Kl("Can't convert object to primitive value")}});var Hn=h((wd,Dn)=>{"use strict";Dn.exports=!0});var zn=h((Sd,Gn)=>{"use strict";var Un=J(),Xl=Object.defineProperty;Gn.exports=function(r,e){try{Xl(Un,r,{value:e,configurable:!0,writable:!0})}catch(t){Un[r]=e}return e}});var kt=h((Rd,Xn)=>{"use strict";var Ql=Hn(),Yl=J(),Zl=zn(),Wn="__core-js_shared__",Kn=Xn.exports=Yl[Wn]||Zl(Wn,{});(Kn.versions||(Kn.versions=[])).push({version:"3.38.0",mode:Ql?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Mr=h((kd,Yn)=>{"use strict";var Qn=kt();Yn.exports=function(r,e){return Qn[r]||(Qn[r]=e||{})}});var Ge=h((Od,Zn)=>{"use strict";var Jl=Er(),ec=Object;Zn.exports=function(r){return ec(Jl(r))}});var Re=h((Pd,Jn)=>{"use strict";var tc=W(),rc=Ge(),ic=tc({}.hasOwnProperty);Jn.exports=Object.hasOwn||function(e,t){return ic(rc(e),t)}});var Lr=h((Md,eo)=>{"use strict";var nc=W(),oc=0,ac=Math.random(),sc=nc(1 .toString);eo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+sc(++oc+ac,36)}});var ze=h((Ld,ro)=>{"use strict";var lc=J(),cc=Mr(),to=Re(),uc=Lr(),pc=Ar(),hc=wr(),ke=lc.Symbol,Fr=cc("wks"),dc=hc?ke.for||ke:ke&&ke.withoutSetter||uc;ro.exports=function(r){return to(Fr,r)||(Fr[r]=pc&&to(ke,r)?ke[r]:dc("Symbol."+r)),Fr[r]}});var ao=h((Fd,oo)=>{"use strict";var mc=At(),io=Se(),no=Sr(),fc=_n(),vc=qn(),bc=ze(),yc=TypeError,gc=bc("toPrimitive");oo.exports=function(r,e){if(!io(r)||no(r))return r;var t=fc(r,gc),i;if(t){if(e===void 0&&(e="default"),i=mc(t,r,e),!io(i)||no(i))return i;throw new yc("Can't convert object to primitive value")}return e===void 0&&(e="number"),vc(r,e)}});var Vr=h((Vd,so)=>{"use strict";var Cc=ao(),Ec=Sr();so.exports=function(r){var e=Cc(r,"string");return Ec(e)?e:e+""}});var uo=h((Nd,co)=>{"use strict";var Tc=J(),lo=Se(),Nr=Tc.document,Ic=lo(Nr)&&lo(Nr.createElement);co.exports=function(r){return Ic?Nr.createElement(r):{}}});var $r=h(($d,po)=>{"use strict";var xc=fe(),Ac=H(),wc=uo();po.exports=!xc&&!Ac(function(){return Object.defineProperty(wc("div"),"a",{get:function(){return 7}}).a!==7})});var fo=h(mo=>{"use strict";var Sc=fe(),Rc=At(),kc=br(),Oc=yr(),Pc=Ue(),Mc=Vr(),Lc=Re(),Fc=$r(),ho=Object.getOwnPropertyDescriptor;mo.f=Sc?ho:function(e,t){if(e=Pc(e),t=Mc(t),Fc)try{return ho(e,t)}catch(i){}if(Lc(e,t))return Oc(!Rc(kc.f,e,t),e[t])}});var bo=h((_d,vo)=>{"use strict";var Vc=H(),Nc=U(),$c=/#|\.prototype\./,We=function(r,e){var t=_c[jc(r)];return t===qc?!0:t===Bc?!1:Nc(e)?Vc(e):!!e},jc=We.normalize=function(r){return String(r).replace($c,".").toLowerCase()},_c=We.data={},Bc=We.NATIVE="N",qc=We.POLYFILL="P";vo.exports=We});var jr=h((Bd,go)=>{"use strict";var yo=fr(),Dc=Rr(),Hc=De(),Uc=yo(yo.bind);go.exports=function(r,e){return Dc(r),e===void 0?r:Hc?Uc(r,e):function(){return r.apply(e,arguments)}}});var Eo=h((qd,Co)=>{"use strict";var Gc=fe(),zc=H();Co.exports=Gc&&zc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Io=h((Dd,To)=>{"use strict";var Wc=Se(),Kc=String,Xc=TypeError;To.exports=function(r){if(Wc(r))return r;throw new Xc(Kc(r)+" is not an object")}});var wo=h(Ao=>{"use strict";var Qc=fe(),Yc=$r(),Zc=Eo(),Ot=Io(),xo=Vr(),Jc=TypeError,_r=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,Br="enumerable",qr="configurable",Dr="writable";Ao.f=Qc?Zc?function(e,t,i){if(Ot(e),t=xo(t),Ot(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Dr in i&&!i[Dr]){var n=eu(e,t);n&&n[Dr]&&(e[t]=i.value,i={configurable:qr in i?i[qr]:n[qr],enumerable:Br in i?i[Br]:n[Br],writable:!1})}return _r(e,t,i)}:_r:function(e,t,i){if(Ot(e),t=xo(t),Ot(i),Yc)try{return _r(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Jc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Ro=h((Ud,So)=>{"use strict";var tu=fe(),ru=wo(),iu=yr();So.exports=tu?function(r,e,t){return ru.f(r,e,iu(1,t))}:function(r,e,t){return r[e]=t,r}});var Xe=h((Gd,Oo)=>{"use strict";var Ke=J(),nu=Ki(),ou=fr(),au=U(),su=fo().f,lu=bo(),Oe=wt(),cu=jr(),Pe=Ro(),ko=Re();kt();var uu=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 nu(r,this,arguments)};return e.prototype=r.prototype,e};Oo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?Ke:n?Ke[t]:Ke[t]&&Ke[t].prototype,l=i?Oe:Oe[t]||Pe(Oe,t,{})[t],s=l.prototype,c,d,f,v,y,w,x,m,u;for(v in e)c=lu(i?v:t+(n?".":"#")+v,r.forced),d=!c&&a&&ko(a,v),w=l[v],d&&(r.dontCallGetSet?(u=su(a,v),x=u&&u.value):x=a[v]),y=d&&x?x:e[v],!(!c&&!o&&typeof w==typeof y)&&(r.bind&&d?m=cu(y,Ke):r.wrap&&d?m=uu(y):o&&au(y)?m=ou(y):m=y,(r.sham||y&&y.sham||w&&w.sham)&&Pe(m,"sham",!0),Pe(l,v,m),o&&(f=t+"Prototype",ko(Oe,f)||Pe(Oe,f,{}),Pe(Oe[f],v,y),r.real&&s&&(c||!s[v])&&Pe(s,v,y)))}});var Mo=h((zd,Po)=>{"use strict";var pu=Math.ceil,hu=Math.floor;Po.exports=Math.trunc||function(e){var t=+e;return(t>0?hu:pu)(t)}});var Qe=h((Wd,Lo)=>{"use strict";var du=Mo();Lo.exports=function(r){var e=+r;return e!==e||e===0?0:du(e)}});var Vo=h((Kd,Fo)=>{"use strict";var mu=Qe(),fu=Math.max,vu=Math.min;Fo.exports=function(r,e){var t=mu(r);return t<0?fu(t+e,0):vu(t,e)}});var $o=h((Xd,No)=>{"use strict";var bu=Qe(),yu=Math.min;No.exports=function(r){var e=bu(r);return e>0?yu(e,9007199254740991):0}});var Ye=h((Qd,jo)=>{"use strict";var gu=$o();jo.exports=function(r){return gu(r.length)}});var Hr=h((Yd,Bo)=>{"use strict";var Cu=Ue(),Eu=Vo(),Tu=Ye(),_o=function(r){return function(e,t,i){var n=Cu(e),o=Tu(n);if(o===0)return!r&&-1;var a=Eu(i,o),l;if(r&&t!==t){for(;o>a;)if(l=n[a++],l!==l)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};Bo.exports={includes:_o(!0),indexOf:_o(!1)}});var Pt=h((Zd,qo)=>{"use strict";qo.exports=function(){}});var Do=h(()=>{"use strict";var Iu=Xe(),xu=Hr().includes,Au=H(),wu=Pt(),Su=Au(function(){return!Array(1).includes()});Iu({target:"Array",proto:!0,forced:Su},{includes:function(e){return xu(this,e,arguments.length>1?arguments[1]:void 0)}});wu("includes")});var Mt=h((tm,Ho)=>{"use strict";var Ru=St();Ho.exports=Ru});var Go=h((rm,Uo)=>{"use strict";Do();var ku=Mt();Uo.exports=ku("Array","includes")});var Wo=h((im,zo)=>{"use strict";var Ou=Go();zo.exports=Ou});var Lt=h((nm,Ko)=>{"use strict";var Pu=Wo();Ko.exports=Pu});var ra=h(()=>{"use strict";var _u=Xe(),Bu=Ge(),qu=Ye(),Du=Qe(),Hu=Pt();_u({target:"Array",proto:!0},{at:function(e){var t=Bu(this),i=qu(t),n=Du(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Hu("at")});var na=h((Cf,ia)=>{"use strict";ra();var Uu=Mt();ia.exports=Uu("Array","at")});var aa=h((Ef,oa)=>{"use strict";var Gu=na();oa.exports=Gu});var Jr=h((Tf,sa)=>{"use strict";var zu=aa();sa.exports=zu});var ba=h((lv,va)=>{"use strict";var Ju=Mr(),ep=Lr(),fa=Ju("keys");va.exports=function(r){return fa[r]||(fa[r]=ep(r))}});var ga=h((cv,ya)=>{"use strict";var tp=H();ya.exports=!tp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ta=h((uv,Ea)=>{"use strict";var rp=Re(),ip=U(),np=Ge(),op=ba(),ap=ga(),Ca=op("IE_PROTO"),ni=Object,sp=ni.prototype;Ea.exports=ap?ni.getPrototypeOf:function(r){var e=np(r);if(rp(e,Ca))return e[Ca];var t=e.constructor;return ip(t)&&e instanceof t?t.prototype:e instanceof ni?sp:null}});var xa=h((pv,Ia)=>{"use strict";Ia.exports={}});var Sa=h((hv,wa)=>{"use strict";var lp=W(),oi=Re(),cp=Ue(),up=Hr().indexOf,pp=xa(),Aa=lp([].push);wa.exports=function(r,e){var t=cp(r),i=0,n=[],o;for(o in t)!oi(pp,o)&&oi(t,o)&&Aa(n,o);for(;e.length>i;)oi(t,o=e[i++])&&(~up(n,o)||Aa(n,o));return n}});var ka=h((dv,Ra)=>{"use strict";Ra.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Pa=h((mv,Oa)=>{"use strict";var hp=Sa(),dp=ka();Oa.exports=Object.keys||function(e){return hp(e,dp)}});var $a=h((fv,Na)=>{"use strict";var La=fe(),mp=H(),Fa=W(),fp=Ta(),vp=Pa(),bp=Ue(),yp=br().f,Va=Fa(yp),gp=Fa([].push),Cp=La&&mp(function(){var r=Object.create(null);return r[2]=2,!Va(r,2)}),Ma=function(r){return function(e){for(var t=bp(e),i=vp(t),n=Cp&&fp(t)===null,o=i.length,a=0,l=[],s;o>a;)s=i[a++],(!La||(n?s in t:Va(t,s)))&&gp(l,r?[s,t[s]]:t[s]);return l}};Na.exports={entries:Ma(!0),values:Ma(!1)}});var ja=h(()=>{"use strict";var Ep=Xe(),Tp=$a().values;Ep({target:"Object",stat:!0},{values:function(e){return Tp(e)}})});var Ba=h((yv,_a)=>{"use strict";ja();var Ip=wt();_a.exports=Ip.Object.values});var Da=h((gv,qa)=>{"use strict";var xp=Ba();qa.exports=xp});var Qt=h((Cv,Ha)=>{"use strict";var Ap=Da();Ha.exports=Ap});var ui=h((qv,Ya)=>{"use strict";var Sp=He();Ya.exports=Array.isArray||function(e){return Sp(e)==="Array"}});var Ja=h((Dv,Za)=>{"use strict";var Rp=TypeError,kp=9007199254740991;Za.exports=function(r){if(r>kp)throw Rp("Maximum allowed index exceeded");return r}});var rs=h((Hv,ts)=>{"use strict";var Op=ui(),Pp=Ye(),Mp=Ja(),Lp=jr(),es=function(r,e,t,i,n,o,a,l){for(var s=n,c=0,d=a?Lp(a,l):!1,f,v;c<i;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&Op(f)?(v=Pp(f),s=es(r,e,f,v,s,o-1)-1):(Mp(s+1),r[s]=f),s++),c++;return s};ts.exports=es});var os=h((Uv,ns)=>{"use strict";var Fp=ze(),Vp=Fp("toStringTag"),is={};is[Vp]="z";ns.exports=String(is)==="[object z]"});var ss=h((Gv,as)=>{"use strict";var Np=os(),$p=U(),Zt=He(),jp=ze(),_p=jp("toStringTag"),Bp=Object,qp=Zt(function(){return arguments}())==="Arguments",Dp=function(r,e){try{return r[e]}catch(t){}};as.exports=Np?Zt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Dp(e=Bp(r),_p))=="string"?t:qp?Zt(e):(i=Zt(e))==="Object"&&$p(e.callee)?"Arguments":i}});var cs=h((zv,ls)=>{"use strict";var Hp=W(),Up=U(),pi=kt(),Gp=Hp(Function.toString);Up(pi.inspectSource)||(pi.inspectSource=function(r){return Gp(r)});ls.exports=pi.inspectSource});var fs=h((Wv,ms)=>{"use strict";var zp=W(),Wp=H(),us=U(),Kp=ss(),Xp=St(),Qp=cs(),ps=function(){},hs=Xp("Reflect","construct"),hi=/^\s*(?:class|function)\b/,Yp=zp(hi.exec),Zp=!hi.test(ps),ct=function(e){if(!us(e))return!1;try{return hs(ps,[],e),!0}catch(t){return!1}},ds=function(e){if(!us(e))return!1;switch(Kp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Zp||!!Yp(hi,Qp(e))}catch(t){return!0}};ds.sham=!0;ms.exports=!hs||Wp(function(){var r;return ct(ct.call)||!ct(Object)||!ct(function(){r=!0})||r})?ds:ct});var gs=h((Kv,ys)=>{"use strict";var vs=ui(),Jp=fs(),eh=Se(),th=ze(),rh=th("species"),bs=Array;ys.exports=function(r){var e;return vs(r)&&(e=r.constructor,Jp(e)&&(e===bs||vs(e.prototype))?e=void 0:eh(e)&&(e=e[rh],e===null&&(e=void 0))),e===void 0?bs:e}});var Es=h((Xv,Cs)=>{"use strict";var ih=gs();Cs.exports=function(r,e){return new(ih(r))(e===0?0:e)}});var Ts=h(()=>{"use strict";var nh=Xe(),oh=rs(),ah=Ge(),sh=Ye(),lh=Qe(),ch=Es();nh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=ah(this),i=sh(t),n=ch(t,0);return n.length=oh(n,t,t,i,0,e===void 0?1:lh(e)),n}})});var Is=h(()=>{"use strict";var uh=Pt();uh("flat")});var As=h((eb,xs)=>{"use strict";Ts();Is();var ph=Mt();xs.exports=ph("Array","flat")});var Ss=h((tb,ws)=>{"use strict";var hh=As();ws.exports=hh});var ks=h((rb,Rs)=>{"use strict";var dh=Ss();Rs.exports=dh});var Ih={};sl(Ih,{ContainerTypes:()=>C.ContainerTypes,ControlTypes:()=>C.ControlTypes,CustomError:()=>$,EVENT_NAMES:()=>k,EventActionTypes:()=>C.EventActionTypes,EventTypes:()=>C.EventTypes,Interactives:()=>pt,ManifestController:()=>ye,SDKInfo:()=>Th,chapterIdsToVKVideoIds:()=>er,compareVersions:()=>Kt,containerTypes:()=>Fu,controlTypes:()=>Vu,eventActionTypes:()=>$u,eventTypes:()=>Nu,getChapterIdByVkVideoId:()=>Ws,getVKVideoIdByMedia:()=>fi,getVideoRawIdByMedia:()=>Gs,graphEventTypes:()=>Fe,hasEndTemplate:()=>Je,interactivesEventTypes:()=>F,isAreaControl:()=>Lu,isButtonControl:()=>Mu,isLastChapter:()=>X,isOneTextCtrlContainer:()=>be,isSupportedManifest:()=>C.isSupportedManifest,isTextControl:()=>Ze,isVKVariantItem:()=>zs,isValidManifest:()=>Ur,migrateManifestToLatestVersion:()=>C.migrateManifestToLatestVersion,utils:()=>el,vkVideoIdsToChapterIds:()=>vi});module.exports=ll(Ih);var ki="1.0.36-dev.5119b35a.0";var et=require("@vkontakte/videoplayer-shared/es2018");var or=class{constructor(e){this.layout=e}},mt=class extends or{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 Pi=require("@vkontakte/videoplayer-shared/es2018");function Oi(r){return"features"in r}var $=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function ft({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let a=new $(n,o,{message:i,error:e,details:{id:t}});r.next(a)}var xe=class{constructor(e,t){this.error$=new Pi.Subject;this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Oi(this.options)&&this.options.features[e]}onError(e="",t){ft({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};var re=require("@vkontakte/videoplayer-shared/es2018");var le=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ce=r=>le(r,"Object"),vt=r=>le(r,"String"),bt=r=>le(r,"Array"),yt=r=>le(r,"Number"),Mi=r=>le(r,"Function"),Li=r=>le(r,"Boolean"),lr=r=>yt(r)&&!isNaN(r);var de=r=>ce(r)&&Object.keys(r).length===0,cr=r=>bt(r)&&!r.length;var je=(r,e)=>vt(r)&&(e?r.trim():r).length;function _e(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var Fi="interactive",L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Vi=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Vi||{}),Ni=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Ni||{}),$i=(i=>(i.start="left",i.end="right",i.center="center",i))($i||{}),gt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Vi[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&Ni[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&$i[e.alignment])!=null?n:"center"},Ct=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,l,s,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},Et=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=_e((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},Be=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var l,s,c,d,f,v,y,w,x,m,u;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(f=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=_e(n?t.borderColor:(w=(y=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:y.color)!=null?w:t.borderColor,n?t.borderAlpha:(u=(m=(x=e==null?void 0:e.shape)==null?void 0:x.border)==null?void 0:m.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=a},ji=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=_e(i.shadowColorLight,i.shadowColorAlpha),l=_e(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=d},Ae=({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 ee=require("@vkontakte/videoplayer-shared/es2018");function Tt(r){for(;r>Math.PI;)r-=2*Math.PI;for(;r<=-Math.PI;)r+=2*Math.PI;return r}function _i(r){return r*180/Math.PI}var ur="interactive-control-tap",we={common:ur,animation:`${ur}-animation`,visible:`${ur}-visible`};var cl=60,It=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=cl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||e.target!==e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,l=i.top+i.height/2,s=e.clientX-a,c=e.clientY-l,d=ul(s,c,Tt(this.controlRotateAngleRad));this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(we.visible,we.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(we.visible,we.animation)};let o=document.createElement("div");o.classList.add(we.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function ul(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var pr="int",me=(i=>(i.AREA=`${pr}_area`,i.TEXT=`${pr}_text`,i.BUTTON=`${pr}_bttn`,i))(me||{});function hr(r){return"features"in r}var Z="interactive-control",P={common:Z,selected:`${Z}-selected`,wrapper:`${Z}-wrapper`,disabled:`${Z}-disabled`,button:`${Z}-button`,area:`${Z}-area`,text:`${Z}-text`,blinkAnim:`${Z}-blink-anim`,blinkAnimButton:`${Z}-blink-anim-button`,blinkAnimArea:`${Z}-blink-anim-area`},Bi=40;var Qo=Y(Lt(),1);var C=require("@interactiveplatform/movika-manifest");var Xo={metadata:"Object",chapters:"Array"},Ur=r=>{if(!ce(r))return!1;for(let e in Xo)if(!r[e]||!le(r[e],Xo[e]))return!1;return(0,C.isSupportedManifest)(r.metadata.version)},Ze=r=>r.type===C.ControlTypes.Text,Mu=r=>r.type===C.ControlTypes.Button,Lu=r=>r.type===C.ControlTypes.Area,Fu={Choice:"Choice",TextInput:"TextInput"},Vu={Button:"Button",Area:"Area",Text:"Text"},Nu={onClick:"onClick",onSuspense:"onSuspense"},$u={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ft=r=>bt(r)&&!cr(r),X=r=>r.order==="end",Je=r=>bt(r.containers)&&!cr(r.containers)&&X(r),Yo=(r,e)=>{var i;let t=r*1e3;return Ft(e.controls)&&t<((i=e.startTime)!=null?i:0)},Gr=(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 ve=(r=[])=>r.some(e=>e.action.type==="expect"),zr=(r=[])=>r.find(e=>e.action.type==="expect"),ju=r=>(r==null?void 0:r.length)===1,be=r=>ju(r)&&Ze(r[0]);function Zo(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,Qo.default)(t,i.container.id)&&ve(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Vt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Zo(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}function Jo(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ea=(r,e)=>{let t=x=>{let m=e.find(({container:u})=>u.container.id===x);return m==null?void 0:m.container.isRemoved},i=ve(r.events)&&!t(r.id),n=(x,m=!1,u=!1)=>{let p=u?"every":"some";return x.controls[p](b=>{var A;let T=m?x.endTime===r.endTime:!0;return((A=b.events)==null?void 0:A[p](g=>{var E;return((E=g.action)==null?void 0:E.type)===C.EventActionTypes.openURI}))&&T})},o=x=>x.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),a=x=>x.every(({container:m})=>m.isRemoved||m.willRemoved?!0:n(m.container,!0,!0)),l=Zo(e,r.endTime,[r.id]).length,s=x=>x.controls.some(m=>{var u;return(u=m.events)==null?void 0:u.some(p=>{var b,T;return(T=(b=p.action)==null?void 0:b.args)==null?void 0:T.shouldOpenNow})}),c=i||l>0,d=o(e),f=n(r),v=a(e),y=i?!1:l>0,w=s(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:w}};var ue=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new ee.Subscription;this.error$=new ee.Subject;this.isInteracted=!1;this.isRemoved=!1;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||Jo(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add((0,ee.fromEvent)(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add((0,ee.fromEvent)(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){ft({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:L.angle;this.controlTap=new It({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Bi:void 0}),this.subscriptions.add((0,ee.fromEvent)(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add((0,ee.fromEvent)(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(P.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>{var a,l;return(l=(a=e.isContainerDisabled)==null?void 0:a.call(e))!=null?l:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&hr(this.options)&&this.options.features[e]}isTouch(){return this.options&&hr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,ee.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Wr="interactive-blink-anim-reference",j={common:Wr,animation:`${Wr}-animation`,disabled:`${Wr}-disabled`},Nt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(j.common,j.animation),this._element=e}restart(){this._element&&(this._element.classList.add(j.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(j.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Kr="interactive-container",_={common:Kr,hidden:`${Kr}-hidden`,disabled:`${Kr}-disabled`};var $t=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Xr(r,e)},Xr=class extends ue{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(P.common,P.area),i.setAttribute("data-testid",me.AREA),Et({target:i,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),this.addControlTap(i),this.subscriptions.add((0,re.fromEvent)(this.container.element,"click").pipe((0,re.once)()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${j.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Li(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";ji({target:this.controlElement,props:this.control.props,fallback:L,isDark:e,baseDimension:o}),Be({target:this.controlElement,props:this.control.props,fallback:{...L,borderColor:e?L.shadowColorDark:L.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:L.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Be({target:this.controlElement,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(P.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(P.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${P.blinkAnimArea}`)||this.controlElement.classList.contains(P.selected)||this.controlElement.classList.contains(j.disabled)||(this.controlElement.classList.add(j.disabled),this.subscriptions.add((0,re.fromEvent)(e,"animationiteration").pipe((0,re.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(j.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${P.blinkAnimArea}`)||this.controlElement.classList.contains(P.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};var ne=require("@vkontakte/videoplayer-shared/es2018");var jt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var ie="interactive-control-fill-animation",B={common:ie,fillerWrapper:`${ie}-filler-wrapper`,filler:`${ie}-filler`,fillHeight:`${ie}-fill-height`,fillWidth:`${ie}-fill-width`,fromTop:`${ie}-from-top`,fromBottom:`${ie}-from-bottom`,fromLeft:`${ie}-from-left`,fromRight:`${ie}-from-right`};var _t=class r{constructor(e){this.widthExpansionCoef=0;var y;let t=document.createElement("div");t.classList.add(B.common);let i=document.createElement("div");i.classList.add(B.fillerWrapper);let n=document.createElement("div");n.classList.add(B.filler),i.append(n),t.append(i);let o=Tt(e.rotateAngle),a=o>Math.PI/2&&o<=Math.PI||o<0&&o<-Math.PI/2,l=o===Math.PI/2,s=o===-Math.PI/2,c=!a&&!l&&!s,d=l||s,f=!!(o%Math.PI/2)&&!d,v=f?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${v*-1}rad)`,d?(n.classList.add(B.fillHeight,l?B.fromTop:B.fromBottom),i.classList.add(B.fillHeight,l?B.fromTop:B.fromBottom)):(n.classList.add(B.fillWidth,c?B.fromLeft:B.fromRight),i.classList.add(B.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:d,rotateAngleRad:o,rotateAngelDeg:_i(o),rotateAngleRaw:e.rotateAngle,fromRight:a,fromTop:l,fromBottom:s,fromLeft:c}),this.useSkew=f,this.fromLeft=c,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=d,this.isDebug=(y=e.debug)!=null?y:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Bt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Qr(r,e)},Qr=class extends ue{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,l,s,c,d,f;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(P.common,P.button),i.setAttribute("data-testid",me.BUTTON),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),Et({target:i,props:this.control.props,fallback:L}),Be({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),gt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=jt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;Ct({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new _t({startTime:this.startTime,endTime:this.endTime,rotateAngle:(l=this.control.layoutParams.angle)!=null?l:L.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add((0,ne.fromEvent)(i,"click").pipe((0,ne.once)()).subscribe(this.onControlSelect,v=>this.onError("Control click handler error",v))),i.append(n,(c=(s=this.controlFillAnimation)==null?void 0:s.fillAnimationElement)!=null?c:""),this.container.element.append((f=(d=this.controlTap)==null?void 0:d.element)!=null?f:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${j.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(P.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(P.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${P.blinkAnimButton}`)||this.controlElement.classList.contains(P.selected)||this.controlElement.classList.contains(j.disabled)||(this.controlElement.classList.add(j.disabled),this.subscriptions.add((0,ne.fromEvent)(e,"animationiteration").pipe((0,ne.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(j.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${P.blinkAnimButton}`)||this.controlElement.classList.contains(P.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var ta=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Yr(r,e)},Yr=class extends ue{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(P.common,P.text),i.setAttribute("data-testid",me.TEXT),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),gt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=jt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;Ct({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var qt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Zr(r,e,t)},Zr=class r extends xe{constructor(t,i,n){super(t,n);this.containerElement=null;this.subscriptions=new et.Subscription;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new mt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Bt),this.addControlFactory("text",ta),this.addControlFactory("area",$t)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(_.common,_.disabled),requestAnimationFrame(()=>{n.classList.remove(_.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(_.hidden)}show(){let t=this.getElement();t&&t.classList.remove(_.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(_.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(_.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add((0,et.fromEvent)(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add((0,et.fromEvent)(n,"transitioncancel").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var Zs=Y(Jr(),1),I=require("@vkontakte/videoplayer-shared/es2018"),$e=require("@vkontakte/videoplayer-statistics/es2018");var pa=require("@vkontakte/videoplayer-shared/es2018");function tt(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var la="video_interactive",ca="videoint";var ua=250,rt=class{constructor(e){this.handleZoomChange=tt(e=>{this.lastZoomInfo=e},ua);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!yt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Wu(e),this.resizeObserver=new ResizeObserver(tt(this.onResize,ua)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var i;if(!this.manifest)return;let e;try{e=await(0,pa.loadVKLangPack)(this.lang,la,ca)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...o})=>{var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Wu(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 it=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};var Dt=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 Ht=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Mi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ma=require("@vkontakte/videoplayer-shared/es2018");var Ut=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}async exec(e,t){return Ku(...this.loaders[e])(t)}};function Ku(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function nt(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Gt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let a=r.getMedia(n.media,o.videoId),l=r.getGraph(n.graph,o.id);return a?{...i,actions:r,errors:e,result:{chapter:o,media:a,graph:l}}:{...i,errors:nt(e,Gt.name,"Could not find media"),actions:r}}}}return{...i,errors:nt(e,Gt.name,"Could not find chapter"),actions:r}}var zt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Me=class extends zt{constructor(){super(),this.listeners||zt.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)}},ot=class{constructor(){Object.defineProperty(this,"signal",{value:new Me,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&&(ot.prototype[Symbol.toStringTag]="AbortController",Me.prototype[Symbol.toStringTag]="AbortSignal");function Wt(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 ei(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Wt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let f;d&&d.signal&&(f=d.signal,delete d.signal);let v=new t(c,d);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let a=e;return{fetch:(s,c)=>{let d=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(d){let f;try{f=new DOMException("Aborted","AbortError")}catch(y){f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let v=new Promise((y,w)=>{d.addEventListener("abort",()=>w(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,a(s,c)])}return a(s,c)},Request:o}}var at=Wt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ha=at?ei({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ti=at?ha.fetch:window.fetch,zf=at?ha.Request:window.Request,Wf=at?ot:window.AbortController,Kf=at?Me:window.AbortSignal;var Kt=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Xu=async r=>{try{let e={},t;if(vt(r)){t=new URL(r).href;let n=await ti(t);if(!n.ok)return{};e=await n.json()}else if(ce(r))e=r;else return{};if(!Ur(e))return{};let i=e.metadata.media;if(vt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await ti(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(n){return Zu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function da(r){let{manifest:e,manifestURL:t}=await Xu(r);if(!e)throw new Error("Failed on fetch");let i=(0,C.migrateManifestToLatestVersion)(e);return i.media=Qu(i.media,t),delete i.metadata.media,i}function Xt(r,e){if(e)return r.find(t=>t.id===e)}function ri(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 ii(r,e){return r.videos.find(t=>t.id===e)}function Qu(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=Yu(n,e);return{...i,url:o||n}})}))}}function Yu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zu(r){return Kt(r,"3.2.0")>=0}var ye=class extends Ut{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ma.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:nt},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await da((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",Gt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ri,getChapter:Xt,getMedia:ii,getByBranches:this.getByBranches.bind(this),addErrorMessage:nt},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=Xt(this.manifest.chapters,t);if(n){let o=ii(this.manifest.media,n.videoId),a=ri(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Xt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?X(this.chapter):!1}};var za=Y(Qt(),1),Wa=require("@vkontakte/videoplayer-core/es2018"),pe=require("@vkontakte/videoplayer-shared/es2018");var Ua=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Ga=Y(Qt(),1);function ai(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...l}){let s=r.get(o),c={...l};return s?s[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...l}}function t(o){var a,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function i(o,a){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(a){let s=l[a];s&&t(s),delete l[a],Object.keys(l).length||r.delete(o)}else{for(let s of(0,Ga.default)(l))t(s);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Le=Y(Lt(),1);function si(r,e=[]){var o,a,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,Le.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=s.standard)!=null?o:"Invariant quality"]:s.url});break;case"mpeg":(n||(0,Le.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(a=s.standard)!=null?a:"Invariant quality"]:s.url});break;case"hls":(n||(0,Le.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(n||(0,Le.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var st=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Le.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var wp=2;function li(r){let e=ai(),t=new pe.Subscription,i={},n=null,o=!1,a,l=new pe.ValueSubject(null);r&&s(r);function s(m){n=m}function c(m,u,p){var A;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((A=e.map.get(m))!=null?A:{})[u];if(T){i={chapterId:p,listId:m,itemId:u,...T};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(E=>{let V=g.info.position$.getValue(),S=g.info.isAutoQualityEnabled$.getValue();if(!(!E||!V||S))for(let O of e.map)(0,za.default)(O[1]).forEach(({player:M})=>{st(M,E)})})).add(g.events.started$.subscribe(()=>{d(u)})),T.container.remove(),n.setPlayer(T.player),o||(n.init(),o=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function d(m){if(!n)throw Error("need to set interactive controller");if(de(i)||m!==i.itemId)return;let u=n.getChapterBranches(),p=new Set;for(let b of u)p.has(b.media.id)||(await v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),p.add(b.media.id))}async function f({chapter:{id:m},manifestVideo:u}){if(de(i)||!n)return;let p=i.player.info.muted$.getValue(),b=i.player.info.currentQuality$.getValue(),T=i.player.info.isAutoQualityEnabled$.getValue(),A=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),E=!T,V=!1;for(let S of e.map)if(S[0]===u.id&&!n.state.isReplay$.getValue()){let O=Object.keys(S[1]);for(let M of O)M===i.itemId?(O.length<wp||(V=!0),e.removePlayer(S[0],M)):(V=!0,c(S[0],M,m),E?st(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(A),i.player.setMuted(p),i.player.setPlaybackRate(g))}else e.removePlayer(S[0]);V||(await v({media:u,chapterId:m,setAsActive:!0,playbackRate:g}),E?st(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(A),i.player.setMuted(p))}async function v({media:m,chapterId:u,prefetch:p=!0,setAsActive:b=!0,autoplay:T=!1,preferredExt:A,title:g,playbackRate:E}){var gi,Ci,Ei,Ti,Ii;let V=Math.random().toString(),S=document.createElement("div");a.append(S);let O;if((gi=n==null?void 0:n.options)!=null&&gi.vkVideoLoader){let ht=Ua(m);ht.length&&(O=await n.options.vkVideoLoader(...ht))}let M=((Ci=n==null?void 0:n.options)==null?void 0:Ci.coreConfig)||void 0,Q={...M,configName:[...(Ei=M==null?void 0:M.configName)!=null?Ei:[],"interactive"]},he={container:S,...((Ti=O==null?void 0:O.videos)==null?void 0:Ti[0])||{sources:si(m,A).sources},title:g,failoverHosts:(O==null?void 0:O.failoverHosts)||[]},q=new Wa.Player(Q,pe.Tracer.createRootTracer());q.initVideo(he);let Te=null;if(O!=null&&O.videos&&(n!=null&&n.options.createOneStat)){let ht=O.videos[0],nr=n.options.createOneStat(ht),xi=new pe.Subscription;nr&&(xi.add(nr.attachTo(q)),Te={oneStat:nr,statSubscription:xi})}let yi=new pe.Subscription,tl=(Ii=i==null?void 0:i.player)==null?void 0:Ii.info.isAutoQualityEnabled$.getValue();yi.add(q.events.canplay$.subscribe(function(){tl||st(q,i.player.info.currentQuality$.getValue()),E&&q.setPlaybackRate(E)}));let Ie=e.createPlayer({listId:m.id,itemId:V,player:q,container:S,sources:si(m,A).sources,config:he,subscription:yi,statistics:Te});return b&&c(m.id,Ie.itemId,u),T&&Ie.player.play(),p&&!T&&Ie.player.prepare(),{player:Ie.player,config:Ie.config,statistics:Ie.statistics}}function y(){w(),n=null,a.remove()}function w(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function x(){if(!n)throw Error("need to set interactive controller");w(),a=document.createElement("div");let{media:m,chapter:u}=n.getCurrentChapter();m&&u?(t.add(n.events.chapterChanged$.subscribe(f)),await v({media:m,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:x,setInteractiveController:s,createPlayer:v,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:l}}var k={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Fe={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},F={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Xa=require("@vkontakte/videoplayer-shared/es2018");function ci(r){return function(...t){return r(...t.reverse())}}function lt(r,...e){return(...t)=>ce(e[0])&&ce(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Yt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:l,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:f,onRemove:v,onError:y,features:w}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ve(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,l;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&s)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(f,v)=>{let{isExpectTime:y,hasOtherExpect:w,hasOpenURIEvent:x,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:u,hasShouldOpenNowEvent:p}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!m,T=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),f!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let A=!w&&!u&&m;A&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:A})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&x&&this.gameState!==5){if(T){let g=((E,V,S,O)=>!E&&!V&&S||E&&!V&&S&&!O||E&&!V&&S&&O)(y,w,u,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!w||!p)&&(this.selectBranches.stopExpect(),v())}},isEOV:()=>this.gameState===4},c=lt(this.selectBranches.onControlEvent,s),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((l=(a=this.container).disable)==null||l.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var s,c,d;let e=this.player.experimental.element$.getValue();if(!(e instanceof HTMLVideoElement?e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(Yo(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Gr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:f}=this.getContainerEventState(),v=this.selectBranches.state.isExpect,y=this.interactiveTimeOpenUri&&f;if(y&&!v){let w=this.container.getElement();w&&(w.style.visibility!=="hidden"&&((c=(s=this.container).hide)==null||c.call(s)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!y&&this.removeView()}let o=Gr(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!=null?d:1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(k.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Xa.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s,this.isPermanentText=c&&be(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=a,this.onError=y,this.features=w,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:ve(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(t=this.onRemove)==null||t.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var Qa=(r=[])=>r.reduce((e,t,i)=>{var o,a,l;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!Ze(s));if(Ft(n)){let s=[(a=t.startTime)!=null?a:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:s});else{let d=[],f=-1/0,v=1/0,y=[],w=[];for(let x=0;x<e.length;x++){let m=e[x];if(w.push(...m.subjects),m.range[0]<v&&(v=m.range[0]),m.range[1]>f&&(f=m.range[1]),s[0]>=m.range[0]&&s[1]<=m.range[1])return e[x].subjects.push(c),e;s[0]<m.range[0]&&s[1]>m.range[0]&&(d.push(x),y=y.concat(m.subjects)),s[0]>=m.range[0]&&s[0]<=m.range[1]&&(d.push(x),y=y.concat(m.subjects),s[0]=m.range[0]),s[1]>=m.range[0]&&s[1]<=m.range[1]&&(d.push(x),y=y.concat(m.subjects),s[1]=m.range[1])}if(w.push(c),s[0]<=v&&s[1]>=f)return[{subjects:w,range:s}];d.length&&d.reverse().forEach(x=>{e.splice(x,1)}),e.push({subjects:y.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Ps=Y(Lt(),1),di=Y(Qt(),1),Ms=Y(ks(),1);function Os(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var d;if(lr(l)){let f=(d=r[l])!=null?d:null;if(f&&s&&je(s,!0)){let v={},y=f[s];if(y&&(v={...v,...y}),v=de(v)?null:v,v&&je(c,!0)){let w=v[c];return w!=null?w:null}return v}return f}return null}function o({timestamp:l,priority:s,initiator:c}){if(lr(l))if(r[l]){if(s&&je(s,!0))if(r[l][s]){if(c&&je(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!de(r[l][s]))return!0}else return!1;if(delete r[l][s],!de(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function a({timestamp:l,priority:s,initiator:c,...d}){var f,v,y;(v=(f=r[l])==null?void 0:f[s])!=null&&v[c]?r[l][s][c].push({...d}):(y=r[l])!=null&&y[s]?r[l][s]={...r[l][s],[c]:[{...d}]}:r[l]?r[l]={...r[l],[s]:{[c]:[{...d}]}}:r[l]={[s]:{[c]:[{...d}]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var mh=[C.EventActionTypes.expect,C.EventActionTypes.setNextBranch],fh=1/0;function Ls(r,e){let t=r,i,n=vh(e),o=Os(),a,l=()=>{y(),u()},s=p=>{o.add.call(void 0,p),w()},c=(p=[])=>{for(let b of p)if(b.action(),(0,Ps.default)(mh,b.actionType))break},d=(p=1/0)=>{var g,E,V;let b=Jt((g=o.get({timestamp:p,priority:"control"}))!=null?g:{}),T=Jt((E=o.get({timestamp:p,priority:"container"}))!=null?E:{}),A=Jt((V=o.get({timestamp:p,priority:"chapter"}))!=null?V:{});return[...b,...T,...A]},f=p=>{n.isReady(p)&&c(d(p))},v=()=>{var p;c([...Jt((p=o.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},y=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},w=()=>{i||(i=()=>setTimeout(()=>{f(1/0)}),a=t.events.ended$.subscribe(i))},x=p=>{y(),t=p},m=p=>{p.priority==="container"&&n.resetCalled(p.timestamp),o.remove(p)},u=()=>{n.release(),o.removeAll()};return{setPlayer:x,add:s,remove:m,exec:f,execEndOfVideo:v,listen:w,unlisten:y,release:l,containersEventsCallState:n,getPreparedToExecActions:d}}function vh(r){let e=new Map;return{setCalled:({timestamp:l,id:s})=>{let c=e.get(l);c&&c[s]!==void 0&&(c[s]=!0)},setData:(l=[])=>{var s;for(let c of l){let d=(s=c.endTime)!=null?s:fh,f=e.get(d);e.set(d,{...f,[c.id]:!1})}},resetCalled:l=>{let s=e.get(l);if(s)for(let c in s)s[c]=!1},isReady:l=>{let s=e.get(l);if(!s)return!0;let c=(0,di.default)(s);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Jt(r){return(0,Ms.default)((0,di.default)(r)).sort(e=>e.actionType===C.EventActionTypes.expect?-1:1)}var Fs={videoContentHeight:0,videoContentWidth:0},Vs=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Fs;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Fs;let o=e/t,a=i/n,l,s;return a>o?(s=n,l=n*o):a<o?(s=i/o,l=i):(s=n,l=i),{videoContentWidth:s,videoContentHeight:l}};var bh=250;function Ns(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:d,videoContentHeight:f}=Vs(c);s.style.setProperty("--interactive-content-width",`${d}px`),s.style.setProperty("--interactive-content-height",`${f}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let o=tt(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},bh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var yh=r=>Math.floor(Math.random()*r),js=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},_s=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var Bs=r=>{let e=r.length,t=yh(e);return r[t]},$s=1,qs=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:$s;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:$s,e>=t)return r[o];return r[r.length-1]};var Ds={shouldOpenNow:!0,isDetachContainer:!0},Hs="after-expect",mi=(r,e=!1)=>({...r,args:e?{...r.args,...Ds}:{...Ds,...r.args}}),Us=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:u,controlType:p,controlId:b,containerId:T,branches:A=[],onEvent:g,isEOV:E=()=>!1,isDisabled:V=()=>!1})=>{let S=mi(u,E()),O={timestamp:1/0,priority:"control",initiator:b,actionType:S.type},M=V(),Q=r.emit.bind(r,k.interactives,{subjectId:b,subjectType:p,subjectName:"control",type:M?F.actionChoiceCanceled:F.actionChoice,actionType:u.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:T,...S.args}}),he=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:p,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:T,...S.args}})};if(M){Q(),he();return}switch(S.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let q=A.find(Te=>Te.id===S.args.branchId);if(!q)return;g(S.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),he(),S.args.shouldOpenNow?x({subjectId:b,subjectName:"control",subjectType:p,action:S,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...O,action:x.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:S,payload:{chapterId:q.chapterId,autoSelect:!1}})});return}case C.EventActionTypes.continuePlayback.trim().toLowerCase():{g(S.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),he(),S.args.shouldOpenNow?w({subjectId:b,subjectName:"control",subjectType:p,action:u}):i.add({...O,action:w.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:u})});return}case C.EventActionTypes.openURI.trim().toLowerCase():{g(S.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),he(),S.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:p,action:S,payload:{URI:u.args.uri}}):i.add({...O,action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:S,payload:{URI:u.args.uri}})});return}default:{let q="Unexpected control event",Te=new $(1,1,{message:q});d(Te,q);return}}},l=({action:u,container:{id:p,endTime:b},branches:T=[],isEOV:A=!1,autoSelected:g=!1})=>{let E=mi(u,A),V={timestamp:!E.args.shouldOpenNow||A?1/0:b!=null?b:1/0,priority:"container",initiator:p,actionType:E.type},S=r.emit.bind(r,k.interactives,{subjectId:p,subjectName:"container",type:F.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),O=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}})};switch(E.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let M=T.find(Q=>Q.id===E.args.branchId);if(!M)return;S(),O(),i.add({...V,action:x.bind(null,{subjectId:p,subjectName:"container",action:E,payload:{chapterId:M.chapterId,autoSelect:g}})});return}case C.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case C.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case C.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case C.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case C.EventActionTypes.continuePlayback.trim().toLowerCase():{S(),O(),i.add({...V,action:w.bind(null,{subjectId:p,subjectName:"container",action:E})});return}case C.EventActionTypes.openURI.trim().toLowerCase():{S(),O(),i.add({...V,action:m.bind(null,{subjectId:p,subjectName:"container",action:E,payload:{URI:u.args.uri}})});return}default:{let M="Unexpected container event",Q=new $(1,1,{message:M});d(Q,M);return}}};function s({container:u,branches:p,isEOV:b=!1}){var A,g;let T=zr(u.events);if(T){let E=mi(T.action,b);r.emit(k.interactives,{subjectId:u.id,subjectName:"container",type:F.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),i.add({timestamp:b?1/0:(A=u.endTime)!=null?A:1/0,priority:"container",initiator:u.id,actionType:C.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let E of(g=u.events)!=null?g:[])l({action:E.action,container:u,branches:p,isEOV:b})}let c=({chapterId:u,action:p,branches:b=[]})=>{let T=r.emit.bind(r,k.interactives,{subjectId:u,subjectName:"chapter",type:F.actionChoice,actionType:p.type,payload:p.args}),A=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let g=b.find(E=>E.id===p.args.branchId);return g!=null&&g.chapterId?(T(),A(),x.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let g=Bs(b);return g!=null&&g.chapterId?(T(),A(),x.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setRandomBranch.trim().toLowerCase():{let g=qs(b);return g!=null&&g.chapterId?(T(),A(),x.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let g=_s(b);return g!=null&&g.chapterId?(T(),A(),x.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let g=js(b);return g!=null&&g.chapterId?(T(),A(),x.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.continuePlayback.trim().toLowerCase():return T(),A(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p});case C.EventActionTypes.openURI.trim().toLowerCase():return T(),A(),m.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let g="Unexpected chapter event",E=new $(1,1,{message:g});d(E,g);return}}};function d(u,p){console.error(p),e.error$.next(u),r.emit(k.errors,u)}function f(u){var b;let p=zr(u.events);if(p){if(X(u))return;r.emit(k.interactives,{subjectId:u.id,subjectName:"chapter",type:F.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:C.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(b=u.events)==null||b.forEach(T=>{let A=c({chapterId:u.id,action:T.action,branches:u.branches});A&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:T.action.type,action:A})})}let v=({subjectId:u,subjectName:p})=>{t.pause(),r.emit(k.interactives,{subjectId:u,subjectName:p,type:F.actionExecution,actionType:C.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:C.EventActionTypes.expect})},y=({subjectId:u,subjectName:p})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:u,subjectName:p,type:F.actionExecution,actionType:Hs}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:Hs})},w=({subjectId:u,subjectName:p,subjectType:b,action:T})=>{r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:F.actionExecution,actionType:T.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:T.type})},x=({subjectId:u,subjectName:p,subjectType:b,action:T,payload:A})=>{A.behaviour="change-chapter",r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:F.actionExecution,actionType:T.type,payload:A}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:T.type,payload:A})},m=({subjectId:u,subjectName:p,subjectType:b,action:T,payload:A})=>{if(!A.URI)return;let g=window.open(A.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:F.actionExecution,actionType:T.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:T.type})};return{onControlEvent:a,onContainerEvent:l,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:s,stopExpect:o,state:n}};var bi=Y(Jr(),1),z=require("@vkontakte/videoplayer-shared/es2018");var er=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=fi(o)}return t[i]}).filter(Boolean)},Gs=r=>{for(let e of r.variants)if(zs(e)&&e.payload)return e.payload.id},zs=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),fi=r=>{let e=Gs(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ws=(r,e)=>{for(let t of r.media.videos)if(e===fi(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},vi=(r,e)=>r.reduce((t,i)=>{let n=Ws(e,i);return n?[...t,n]:t},[]);var oe,ge,Ce,G,tr,ae,se,te,Ee,Ve,Ne,ut=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new z.ValueSubject([]),hasPrevChapter$:new z.ValueSubject(!1),prevChapter$:new z.ValueSubject(null),isInitialChapter$:new z.ValueSubject(!1),isGoBackLimited$:new z.ValueSubject(!1)};D(this,oe,null);D(this,ge);D(this,Ce,!1);D(this,G,null);D(this,tr,null);this.events={inited$:new z.Subject,destroyed$:new z.Subject,error$:new z.Subject};D(this,ae,null);D(this,se,null);D(this,te,null);D(this,Ee,new z.Subscription);D(this,Ve,!1);D(this,Ne,0);var a;N(this,ae,t),N(this,te,e),N(this,se,i),N(this,oe,n),N(this,ge,o),this.state.history$&&R(this,Ee)&&((a=R(this,Ee))==null||a.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,bi.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=R(this,G))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(R(this,Ne)===R(this,ge).maxLength-1)})))}async setManifest(e){if(!R(this,se)||!R(this,te))return;N(this,G,e),await this.getProjectHistory();let t=this.getInitialChapterId();await R(this,se).setChapter({chapterId:t,pushToHistory:!1}),R(this,Ce)||(N(this,Ce,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return R(this,Ce)}async updateHistory(e,t=!0){var l;if(!R(this,G))return;R(this,Ve)?(N(this,Ve,!1),Ri(this,Ne)._++):N(this,Ne,0);let i=R(this,G),n=e.length-R(this,ge).maxLength,o=n>0?e.slice(n):e,a=er(o,i);if(N(this,tr,a),this.state.history$.next(o),!(!t||!R(this,oe)||!R(this,ae)))try{await R(this,oe).save(R(this,ae),a)}catch(s){let c=new $(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=R(this,te))==null||l.emit(k.errors,c)}}async goBack(){var i;if(!this.state||!R(this,se)){let n=new $(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=R(this,te))==null?void 0:i.emit(k.errors,n)}N(this,Ve,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await R(this,se).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!R(this,G)||!R(this,ae))return;let e=R(this,G),t=[this.getInitialVideoId()];if(R(this,oe))try{let o=await R(this,oe).get(R(this,ae));o.length&&(t=o)}catch(o){let a=new $(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=R(this,te))==null||n.emit(k.errors,a)}let i=vi(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,bi.default)(e,-1)||R(this,ge).initChapterId||((t=R(this,G))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(R(this,G)){let e=this.getInitialChapterId();return er([e],R(this,G)).pop()}return null}destroy(){var e,t;N(this,ae,null),N(this,oe,null),N(this,se,null),(e=R(this,Ee))==null||e.unsubscribe(),N(this,Ee,null),N(this,Ce,!1),(t=R(this,te))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),N(this,te,null)}};oe=new WeakMap,ge=new WeakMap,Ce=new WeakMap,G=new WeakMap,tr=new WeakMap,ae=new WeakMap,se=new WeakMap,te=new WeakMap,Ee=new WeakMap,Ve=new WeakMap,Ne=new WeakMap;var rr=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var ir=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
6
+ "use strict";var za=Object.create;var ht=Object.defineProperty;var Wa=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var Qa=Object.getPrototypeOf,Xa=Object.prototype.hasOwnProperty;var bn=r=>{throw TypeError(r)};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ya=(r,e)=>{for(var t in e)ht(r,t,{get:e[t],enumerable:!0})},Cn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ka(e))!Xa.call(r,i)&&i!==t&&ht(r,i,{get:()=>e[i],enumerable:!(n=Wa(e,i))||n.enumerable});return r};var z=(r,e,t)=>(t=r!=null?za(Qa(r)):{},Cn(e||!r||!r.__esModule?ht(t,"default",{value:r,enumerable:!0}):t,r)),Za=r=>Cn(ht({},"__esModule",{value:!0}),r);var gn=(r,e,t)=>e.has(r)||bn("Cannot "+t);var A=(r,e,t)=>(gn(r,e,"read from private field"),t?t.call(r):e.get(r)),q=(r,e,t)=>e.has(r)?bn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),L=(r,e,t,n)=>(gn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var En=(r,e,t,n)=>({set _(i){L(r,e,i,t)},get _(){return A(r,e,n)}});var Z=h((ur,Mn)=>{"use strict";var Be=function(r){return r&&r.Math===Math&&r};Mn.exports=Be(typeof globalThis=="object"&&globalThis)||Be(typeof window=="object"&&window)||Be(typeof self=="object"&&self)||Be(typeof global=="object"&&global)||Be(typeof ur=="object"&&ur)||function(){return this}()||Function("return this")()});var D=h((Ad,Nn)=>{"use strict";Nn.exports=function(r){try{return!!r()}catch(e){return!0}}});var qe=h((Rd,Ln)=>{"use strict";var Ja=D();Ln.exports=!Ja(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Bn=h((kd,_n)=>{"use strict";var el=qe(),Fn=Function.prototype,jn=Fn.apply,$n=Fn.call;_n.exports=typeof Reflect=="object"&&Reflect.apply||(el?$n.bind(jn):function(){return $n.apply(jn,arguments)})});var W=h((Od,Hn)=>{"use strict";var qn=qe(),Dn=Function.prototype,pr=Dn.call,tl=qn&&Dn.bind.bind(pr,pr);Hn.exports=qn?tl:function(r){return function(){return pr.apply(r,arguments)}}});var De=h((Pd,Gn)=>{"use strict";var Un=W(),rl=Un({}.toString),nl=Un("".slice);Gn.exports=function(r){return nl(rl(r),8,-1)}});var hr=h((Vd,zn)=>{"use strict";var il=De(),ol=W();zn.exports=function(r){if(il(r)==="Function")return ol(r)}});var H=h((Md,Wn)=>{"use strict";var dr=typeof document=="object"&&document.all;Wn.exports=typeof dr=="undefined"&&dr!==void 0?function(r){return typeof r=="function"||r===dr}:function(r){return typeof r=="function"}});var he=h((Nd,Kn)=>{"use strict";var sl=D();Kn.exports=!sl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var At=h((Ld,Qn)=>{"use strict";var al=qe(),wt=Function.prototype.call;Qn.exports=al?wt.bind(wt):function(){return wt.apply(wt,arguments)}});var mr=h(Zn=>{"use strict";var Xn={}.propertyIsEnumerable,Yn=Object.getOwnPropertyDescriptor,ll=Yn&&!Xn.call({1:2},1);Zn.f=ll?function(e){var t=Yn(this,e);return!!t&&t.enumerable}:Xn});var fr=h(($d,Jn)=>{"use strict";Jn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var ti=h((Fd,ei)=>{"use strict";var cl=W(),ul=D(),pl=De(),vr=Object,hl=cl("".split);ei.exports=ul(function(){return!vr("z").propertyIsEnumerable(0)})?function(r){return pl(r)==="String"?hl(r,""):vr(r)}:vr});var yr=h((_d,ri)=>{"use strict";ri.exports=function(r){return r==null}});var br=h((Bd,ni)=>{"use strict";var dl=yr(),ml=TypeError;ni.exports=function(r){if(dl(r))throw new ml("Can't call method on "+r);return r}});var He=h((qd,ii)=>{"use strict";var fl=ti(),vl=br();ii.exports=function(r){return fl(vl(r))}});var Te=h((Dd,oi)=>{"use strict";var yl=H();oi.exports=function(r){return typeof r=="object"?r!==null:yl(r)}});var Rt=h((Hd,si)=>{"use strict";si.exports={}});var kt=h((Ud,li)=>{"use strict";var Cr=Rt(),gr=Z(),bl=H(),ai=function(r){return bl(r)?r:void 0};li.exports=function(r,e){return arguments.length<2?ai(Cr[r])||ai(gr[r]):Cr[r]&&Cr[r][e]||gr[r]&&gr[r][e]}});var ui=h((Gd,ci)=>{"use strict";var Cl=W();ci.exports=Cl({}.isPrototypeOf)});var mi=h((zd,di)=>{"use strict";var gl=Z(),pi=gl.navigator,hi=pi&&pi.userAgent;di.exports=hi?String(hi):""});var Ei=h((Wd,gi)=>{"use strict";var Ci=Z(),Er=mi(),fi=Ci.process,vi=Ci.Deno,yi=fi&&fi.versions||vi&&vi.version,bi=yi&&yi.v8,K,Ot;bi&&(K=bi.split("."),Ot=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!Ot&&Er&&(K=Er.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=Er.match(/Chrome\/(\d+)/),K&&(Ot=+K[1])));gi.exports=Ot});var Ir=h((Kd,xi)=>{"use strict";var Ii=Ei(),El=D(),Il=Z(),xl=Il.String;xi.exports=!!Object.getOwnPropertySymbols&&!El(function(){var r=Symbol("symbol detection");return!xl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ii&&Ii<41})});var xr=h((Qd,Ti)=>{"use strict";var Tl=Ir();Ti.exports=Tl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Tr=h((Xd,Si)=>{"use strict";var Sl=kt(),wl=H(),Al=ui(),Rl=xr(),kl=Object;Si.exports=Rl?function(r){return typeof r=="symbol"}:function(r){var e=Sl("Symbol");return wl(e)&&Al(e.prototype,kl(r))}});var Ai=h((Yd,wi)=>{"use strict";var Ol=String;wi.exports=function(r){try{return Ol(r)}catch(e){return"Object"}}});var Sr=h((Zd,Ri)=>{"use strict";var Pl=H(),Vl=Ai(),Ml=TypeError;Ri.exports=function(r){if(Pl(r))return r;throw new Ml(Vl(r)+" is not a function")}});var Oi=h((Jd,ki)=>{"use strict";var Nl=Sr(),Ll=yr();ki.exports=function(r,e){var t=r[e];return Ll(t)?void 0:Nl(t)}});var Vi=h((em,Pi)=>{"use strict";var wr=At(),Ar=H(),Rr=Te(),jl=TypeError;Pi.exports=function(r,e){var t,n;if(e==="string"&&Ar(t=r.toString)&&!Rr(n=wr(t,r))||Ar(t=r.valueOf)&&!Rr(n=wr(t,r))||e!=="string"&&Ar(t=r.toString)&&!Rr(n=wr(t,r)))return n;throw new jl("Can't convert object to primitive value")}});var Ni=h((tm,Mi)=>{"use strict";Mi.exports=!0});var $i=h((rm,ji)=>{"use strict";var Li=Z(),$l=Object.defineProperty;ji.exports=function(r,e){try{$l(Li,r,{value:e,configurable:!0,writable:!0})}catch(t){Li[r]=e}return e}});var Pt=h((nm,Bi)=>{"use strict";var Fl=Ni(),_l=Z(),Bl=$i(),Fi="__core-js_shared__",_i=Bi.exports=_l[Fi]||Bl(Fi,{});(_i.versions||(_i.versions=[])).push({version:"3.38.0",mode:Fl?"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 kr=h((im,Di)=>{"use strict";var qi=Pt();Di.exports=function(r,e){return qi[r]||(qi[r]=e||{})}});var Ue=h((om,Hi)=>{"use strict";var ql=br(),Dl=Object;Hi.exports=function(r){return Dl(ql(r))}});var Se=h((sm,Ui)=>{"use strict";var Hl=W(),Ul=Ue(),Gl=Hl({}.hasOwnProperty);Ui.exports=Object.hasOwn||function(e,t){return Gl(Ul(e),t)}});var Or=h((am,Gi)=>{"use strict";var zl=W(),Wl=0,Kl=Math.random(),Ql=zl(1 .toString);Gi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Ql(++Wl+Kl,36)}});var Ge=h((lm,Wi)=>{"use strict";var Xl=Z(),Yl=kr(),zi=Se(),Zl=Or(),Jl=Ir(),ec=xr(),we=Xl.Symbol,Pr=Yl("wks"),tc=ec?we.for||we:we&&we.withoutSetter||Zl;Wi.exports=function(r){return zi(Pr,r)||(Pr[r]=Jl&&zi(we,r)?we[r]:tc("Symbol."+r)),Pr[r]}});var Yi=h((cm,Xi)=>{"use strict";var rc=At(),Ki=Te(),Qi=Tr(),nc=Oi(),ic=Vi(),oc=Ge(),sc=TypeError,ac=oc("toPrimitive");Xi.exports=function(r,e){if(!Ki(r)||Qi(r))return r;var t=nc(r,ac),n;if(t){if(e===void 0&&(e="default"),n=rc(t,r,e),!Ki(n)||Qi(n))return n;throw new sc("Can't convert object to primitive value")}return e===void 0&&(e="number"),ic(r,e)}});var Vr=h((um,Zi)=>{"use strict";var lc=Yi(),cc=Tr();Zi.exports=function(r){var e=lc(r,"string");return cc(e)?e:e+""}});var to=h((pm,eo)=>{"use strict";var uc=Z(),Ji=Te(),Mr=uc.document,pc=Ji(Mr)&&Ji(Mr.createElement);eo.exports=function(r){return pc?Mr.createElement(r):{}}});var Nr=h((hm,ro)=>{"use strict";var hc=he(),dc=D(),mc=to();ro.exports=!hc&&!dc(function(){return Object.defineProperty(mc("div"),"a",{get:function(){return 7}}).a!==7})});var oo=h(io=>{"use strict";var fc=he(),vc=At(),yc=mr(),bc=fr(),Cc=He(),gc=Vr(),Ec=Se(),Ic=Nr(),no=Object.getOwnPropertyDescriptor;io.f=fc?no:function(e,t){if(e=Cc(e),t=gc(t),Ic)try{return no(e,t)}catch(n){}if(Ec(e,t))return bc(!vc(yc.f,e,t),e[t])}});var ao=h((mm,so)=>{"use strict";var xc=D(),Tc=H(),Sc=/#|\.prototype\./,ze=function(r,e){var t=Ac[wc(r)];return t===kc?!0:t===Rc?!1:Tc(e)?xc(e):!!e},wc=ze.normalize=function(r){return String(r).replace(Sc,".").toLowerCase()},Ac=ze.data={},Rc=ze.NATIVE="N",kc=ze.POLYFILL="P";so.exports=ze});var Lr=h((fm,co)=>{"use strict";var lo=hr(),Oc=Sr(),Pc=qe(),Vc=lo(lo.bind);co.exports=function(r,e){return Oc(r),e===void 0?r:Pc?Vc(r,e):function(){return r.apply(e,arguments)}}});var po=h((vm,uo)=>{"use strict";var Mc=he(),Nc=D();uo.exports=Mc&&Nc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var mo=h((ym,ho)=>{"use strict";var Lc=Te(),jc=String,$c=TypeError;ho.exports=function(r){if(Lc(r))return r;throw new $c(jc(r)+" is not an object")}});var yo=h(vo=>{"use strict";var Fc=he(),_c=Nr(),Bc=po(),Vt=mo(),fo=Vr(),qc=TypeError,jr=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,$r="enumerable",Fr="configurable",_r="writable";vo.f=Fc?Bc?function(e,t,n){if(Vt(e),t=fo(t),Vt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&_r in n&&!n[_r]){var i=Dc(e,t);i&&i[_r]&&(e[t]=n.value,n={configurable:Fr in n?n[Fr]:i[Fr],enumerable:$r in n?n[$r]:i[$r],writable:!1})}return jr(e,t,n)}:jr:function(e,t,n){if(Vt(e),t=fo(t),Vt(n),_c)try{return jr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new qc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Co=h((Cm,bo)=>{"use strict";var Hc=he(),Uc=yo(),Gc=fr();bo.exports=Hc?function(r,e,t){return Uc.f(r,e,Gc(1,t))}:function(r,e,t){return r[e]=t,r}});var Ke=h((gm,Eo)=>{"use strict";var We=Z(),zc=Bn(),Wc=hr(),Kc=H(),Qc=oo().f,Xc=ao(),Ae=Rt(),Yc=Lr(),Re=Co(),go=Se();Pt();var Zc=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return zc(r,this,arguments)};return e.prototype=r.prototype,e};Eo.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,s=n?We:i?We[t]:We[t]&&We[t].prototype,l=n?Ae:Ae[t]||Re(Ae,t,{})[t],a=l.prototype,c,m,f,v,C,w,I,d,p;for(v in e)c=Xc(n?v:t+(i?".":"#")+v,r.forced),m=!c&&s&&go(s,v),w=l[v],m&&(r.dontCallGetSet?(p=Qc(s,v),I=p&&p.value):I=s[v]),C=m&&I?I:e[v],!(!c&&!o&&typeof w==typeof C)&&(r.bind&&m?d=Yc(C,We):r.wrap&&m?d=Zc(C):o&&Kc(C)?d=Wc(C):d=C,(r.sham||C&&C.sham||w&&w.sham)&&Re(d,"sham",!0),Re(l,v,d),o&&(f=t+"Prototype",go(Ae,f)||Re(Ae,f,{}),Re(Ae[f],v,C),r.real&&a&&(c||!a[v])&&Re(a,v,C)))}});var xo=h((Em,Io)=>{"use strict";var Jc=Math.ceil,eu=Math.floor;Io.exports=Math.trunc||function(e){var t=+e;return(t>0?eu:Jc)(t)}});var Qe=h((Im,To)=>{"use strict";var tu=xo();To.exports=function(r){var e=+r;return e!==e||e===0?0:tu(e)}});var wo=h((xm,So)=>{"use strict";var ru=Qe(),nu=Math.min;So.exports=function(r){var e=ru(r);return e>0?nu(e,9007199254740991):0}});var Xe=h((Tm,Ao)=>{"use strict";var iu=wo();Ao.exports=function(r){return iu(r.length)}});var Mt=h((Sm,Ro)=>{"use strict";Ro.exports=function(){}});var ko=h(()=>{"use strict";var ou=Ke(),su=Ue(),au=Xe(),lu=Qe(),cu=Mt();ou({target:"Array",proto:!0},{at:function(e){var t=su(this),n=au(t),i=lu(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});cu("at")});var Nt=h((Rm,Oo)=>{"use strict";var uu=kt();Oo.exports=uu});var Vo=h((km,Po)=>{"use strict";ko();var pu=Nt();Po.exports=pu("Array","at")});var No=h((Om,Mo)=>{"use strict";var hu=Vo();Mo.exports=hu});var Br=h((Pm,Lo)=>{"use strict";var du=No();Lo.exports=du});var Uo=h((bf,Ho)=>{"use strict";var wu=Qe(),Au=Math.max,Ru=Math.min;Ho.exports=function(r,e){var t=wu(r);return t<0?Au(t+e,0):Ru(t,e)}});var Wr=h((Cf,zo)=>{"use strict";var ku=He(),Ou=Uo(),Pu=Xe(),Go=function(r){return function(e,t,n){var i=ku(e),o=Pu(i);if(o===0)return!r&&-1;var s=Ou(n,o),l;if(r&&t!==t){for(;o>s;)if(l=i[s++],l!==l)return!0}else for(;o>s;s++)if((r||s in i)&&i[s]===t)return r||s||0;return!r&&-1}};zo.exports={includes:Go(!0),indexOf:Go(!1)}});var Wo=h(()=>{"use strict";var Vu=Ke(),Mu=Wr().includes,Nu=D(),Lu=Mt(),ju=Nu(function(){return!Array(1).includes()});Vu({target:"Array",proto:!0,forced:ju},{includes:function(e){return Mu(this,e,arguments.length>1?arguments[1]:void 0)}});Lu("includes")});var Qo=h((If,Ko)=>{"use strict";Wo();var $u=Nt();Ko.exports=$u("Array","includes")});var Yo=h((xf,Xo)=>{"use strict";var Fu=Qo();Xo.exports=Fu});var it=h((Tf,Zo)=>{"use strict";var _u=Yo();Zo.exports=_u});var ss=h((Nf,os)=>{"use strict";var qu=kr(),Du=Or(),is=qu("keys");os.exports=function(r){return is[r]||(is[r]=Du(r))}});var ls=h((Lf,as)=>{"use strict";var Hu=D();as.exports=!Hu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var ps=h((jf,us)=>{"use strict";var Uu=Se(),Gu=H(),zu=Ue(),Wu=ss(),Ku=ls(),cs=Wu("IE_PROTO"),Xr=Object,Qu=Xr.prototype;us.exports=Ku?Xr.getPrototypeOf:function(r){var e=zu(r);if(Uu(e,cs))return e[cs];var t=e.constructor;return Gu(t)&&e instanceof t?t.prototype:e instanceof Xr?Qu:null}});var ds=h(($f,hs)=>{"use strict";hs.exports={}});var vs=h((Ff,fs)=>{"use strict";var Xu=W(),Yr=Se(),Yu=He(),Zu=Wr().indexOf,Ju=ds(),ms=Xu([].push);fs.exports=function(r,e){var t=Yu(r),n=0,i=[],o;for(o in t)!Yr(Ju,o)&&Yr(t,o)&&ms(i,o);for(;e.length>n;)Yr(t,o=e[n++])&&(~Zu(i,o)||ms(i,o));return i}});var bs=h((_f,ys)=>{"use strict";ys.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var gs=h((Bf,Cs)=>{"use strict";var ep=vs(),tp=bs();Cs.exports=Object.keys||function(e){return ep(e,tp)}});var ws=h((qf,Ss)=>{"use strict";var Is=he(),rp=D(),xs=W(),np=ps(),ip=gs(),op=He(),sp=mr().f,Ts=xs(sp),ap=xs([].push),lp=Is&&rp(function(){var r=Object.create(null);return r[2]=2,!Ts(r,2)}),Es=function(r){return function(e){for(var t=op(e),n=ip(t),i=lp&&np(t)===null,o=n.length,s=0,l=[],a;o>s;)a=n[s++],(!Is||(i?a in t:Ts(t,a)))&&ap(l,r?[a,t[a]]:t[a]);return l}};Ss.exports={entries:Es(!0),values:Es(!1)}});var As=h(()=>{"use strict";var cp=Ke(),up=ws().values;cp({target:"Object",stat:!0},{values:function(e){return up(e)}})});var ks=h((Uf,Rs)=>{"use strict";As();var pp=Rt();Rs.exports=pp.Object.values});var Ps=h((Gf,Os)=>{"use strict";var hp=ks();Os.exports=hp});var Gt=h((zf,Vs)=>{"use strict";var dp=Ps();Vs.exports=dp});var rn=h((dv,qs)=>{"use strict";var fp=De();qs.exports=Array.isArray||function(e){return fp(e)==="Array"}});var Hs=h((mv,Ds)=>{"use strict";var vp=TypeError,yp=9007199254740991;Ds.exports=function(r){if(r>yp)throw vp("Maximum allowed index exceeded");return r}});var zs=h((fv,Gs)=>{"use strict";var bp=rn(),Cp=Xe(),gp=Hs(),Ep=Lr(),Us=function(r,e,t,n,i,o,s,l){for(var a=i,c=0,m=s?Ep(s,l):!1,f,v;c<n;)c in t&&(f=m?m(t[c],c,e):t[c],o>0&&bp(f)?(v=Cp(f),a=Us(r,e,f,v,a,o-1)-1):(gp(a+1),r[a]=f),a++),c++;return a};Gs.exports=Us});var Qs=h((vv,Ks)=>{"use strict";var Ip=Ge(),xp=Ip("toStringTag"),Ws={};Ws[xp]="z";Ks.exports=String(Ws)==="[object z]"});var Ys=h((yv,Xs)=>{"use strict";var Tp=Qs(),Sp=H(),Wt=De(),wp=Ge(),Ap=wp("toStringTag"),Rp=Object,kp=Wt(function(){return arguments}())==="Arguments",Op=function(r,e){try{return r[e]}catch(t){}};Xs.exports=Tp?Wt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Op(e=Rp(r),Ap))=="string"?t:kp?Wt(e):(n=Wt(e))==="Object"&&Sp(e.callee)?"Arguments":n}});var Js=h((bv,Zs)=>{"use strict";var Pp=W(),Vp=H(),nn=Pt(),Mp=Pp(Function.toString);Vp(nn.inspectSource)||(nn.inspectSource=function(r){return Mp(r)});Zs.exports=nn.inspectSource});var oa=h((Cv,ia)=>{"use strict";var Np=W(),Lp=D(),ea=H(),jp=Ys(),$p=kt(),Fp=Js(),ta=function(){},ra=$p("Reflect","construct"),on=/^\s*(?:class|function)\b/,_p=Np(on.exec),Bp=!on.test(ta),lt=function(e){if(!ea(e))return!1;try{return ra(ta,[],e),!0}catch(t){return!1}},na=function(e){if(!ea(e))return!1;switch(jp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Bp||!!_p(on,Fp(e))}catch(t){return!0}};na.sham=!0;ia.exports=!ra||Lp(function(){var r;return lt(lt.call)||!lt(Object)||!lt(function(){r=!0})||r})?na:lt});var ca=h((gv,la)=>{"use strict";var sa=rn(),qp=oa(),Dp=Te(),Hp=Ge(),Up=Hp("species"),aa=Array;la.exports=function(r){var e;return sa(r)&&(e=r.constructor,qp(e)&&(e===aa||sa(e.prototype))?e=void 0:Dp(e)&&(e=e[Up],e===null&&(e=void 0))),e===void 0?aa:e}});var pa=h((Ev,ua)=>{"use strict";var Gp=ca();ua.exports=function(r,e){return new(Gp(r))(e===0?0:e)}});var ha=h(()=>{"use strict";var zp=Ke(),Wp=zs(),Kp=Ue(),Qp=Xe(),Xp=Qe(),Yp=pa();zp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Kp(this),n=Qp(t),i=Yp(t,0);return i.length=Wp(i,t,t,n,0,e===void 0?1:Xp(e)),i}})});var da=h(()=>{"use strict";var Zp=Mt();Zp("flat")});var fa=h((wv,ma)=>{"use strict";ha();da();var Jp=Nt();ma.exports=Jp("Array","flat")});var ya=h((Av,va)=>{"use strict";var eh=fa();va.exports=eh});var Ca=h((Rv,ba)=>{"use strict";var th=ya();ba.exports=th});var ph={};Ya(ph,{ContainerTypes:()=>g.ContainerTypes,ControlTypes:()=>g.ControlTypes,CustomError:()=>V,EVENT_NAMES:()=>k,EventActionTypes:()=>g.EventActionTypes,EventTypes:()=>g.EventTypes,Interactives:()=>ut,ManifestController:()=>fe,SDKInfo:()=>uh,chapterIdsToVKVideoIds:()=>Qt,compareVersions:()=>qt,containerTypes:()=>yu,controlTypes:()=>bu,eventActionTypes:()=>Dr,eventTypes:()=>Cu,getChapterIdByVkVideoId:()=>$a,getVKVideoIdByMedia:()=>ln,getVideoRawIdByMedia:()=>La,graphEventTypes:()=>Pe,hasEndTemplate:()=>ot,interactivesEventTypes:()=>N,isAreaControl:()=>vu,isButtonControl:()=>fu,isLastChapter:()=>Q,isOneTextCtrlContainer:()=>me,isSupportedManifest:()=>g.isSupportedManifest,isTextControl:()=>et,isVKVariantItem:()=>ja,isValidManifest:()=>qr,migrateManifestToLatestVersion:()=>g.migrateManifestToLatestVersion,utils:()=>Ua,vkVideoIdsToChapterIds:()=>cn});module.exports=Za(ph);var In="1.0.36-dev.62c89fb9.0";var Tt=require("@vkontakte/videoplayer-shared/es2018");var er=class{constructor(e){this.layout=e}},dt=class extends er{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))`}};function xn(r){return"features"in r}var Ee=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&xn(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,n)=>{let i=n.type.trim().toLowerCase(),o=this.factories.get(i);if(o){let s=o(n,this.options);if(s)return[...t,s]}return[...t]},[]))||[]}};var ue=require("@vkontakte/videoplayer-shared/es2018");function Le(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var Tn="interactive",j={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Sn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Sn||{}),wn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(wn||{}),An=(n=>(n.start="left",n.end="right",n.center="center",n))(An||{}),mt=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Sn[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&wn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&An[e.alignment])!=null?i:"center"},ft=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,o,s,l,a,c;r.style.color=(o=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?o:t.textColor,r.style.fontSize=`calc(${n.height} * ${(l=(s=e==null?void 0:e.text)==null?void 0:s.size)!=null?l:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},vt=({target:r,props:e,fallback:t})=>{var n,i,o,s;r.style.backgroundColor=Le((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(s=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?s:t.backgroundAlpha)},je=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{var l,a,c,m,f,v,C,w,I,d,p;let o=i?t.borderWidthRawValue:`calc(${n.height} * ${(c=(a=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:a.width)!=null?c:t.borderWidth})`,s=i?t.roundCornersRawValue:`calc(${n.height} * ${(f=(m=e==null?void 0:e.shape)==null?void 0:m.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Le(i?t.borderColor:(w=(C=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:C.color)!=null?w:t.borderColor,i?t.borderAlpha:(p=(d=(I=e==null?void 0:e.shape)==null?void 0:I.border)==null?void 0:d.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=s},Rn=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let s=Le(n.shadowColorLight,n.shadowColorAlpha),l=Le(n.shadowColorDark,n.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,m=`0px 0px ${a} ${c} ${e?l:s}`;r.style.boxShadow=m},Ie=({target:r,layoutParams:e,fallback:t})=>{var i;let n=(i=e.angle)!=null?i:t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var xe=require("@vkontakte/videoplayer-shared/es2018");var tr="int",le=(n=>(n.AREA=`${tr}_area`,n.TEXT=`${tr}_text`,n.BUTTON=`${tr}_bttn`,n))(le||{});function kn(r){return"features"in r}var Y="interactive-control",O={common:Y,selected:`${Y}-selected`,wrapper:`${Y}-wrapper`,disabled:`${Y}-disabled`,button:`${Y}-button`,area:`${Y}-area`,text:`${Y}-text`,blinkAnim:`${Y}-blink-anim`,blinkAnimButton:`${Y}-blink-anim-button`,blinkAnimArea:`${Y}-blink-anim-area`};var V=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ne=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new xe.Subscription;this.error$=new xe.Subject}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(O.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:j.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:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&kn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,xe.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>{let o=new V(1,1,{message:"Error happened on control interaction",error:i});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var ie=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,oe=r=>ie(r,"Object"),yt=r=>ie(r,"String"),bt=r=>ie(r,"Array"),Ct=r=>ie(r,"Number"),On=r=>ie(r,"Function"),Pn=r=>ie(r,"Boolean"),rr=r=>Ct(r)&&!isNaN(r);var ce=r=>oe(r)&&Object.keys(r).length===0,nr=r=>bt(r)&&!r.length;var _e=(r,e)=>yt(r)&&(e?r.trim():r).length;var ir="interactive-blink-anim-reference",F={common:ir,animation:`${ir}-animation`,disabled:`${ir}-disabled`},gt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(F.common,F.animation),this._element=e}restart(){this._element&&(this._element.classList.add(F.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(F.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var or="interactive-container",_={common:or,hidden:`${or}-hidden`,disabled:`${or}-disabled`};var Et=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new sr(r,e)},sr=class extends ne{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(O.common,O.area),n.setAttribute("data-testid",le.AREA),vt({target:n,props:this.control.props,fallback:{...j,backgroundColor:"transparent"}}),Ie({target:n,layoutParams:this.control.layoutParams,fallback:j}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ue.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let n=e.parentElement;if(n){let i=n.querySelector(`.${F.common}`);i&&this.syncBlinkAnimation(i)}},n=>this.onError("Error happened in mouseleave callback",n))),this.subscriptions.add((0,ue.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},n=>this.onError("Error happened in mouseenter callback",n))).add((0,ue.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},n=>this.onError("Error happened in mouseleave callback",n))))}disable(){this.controlElement&&this.controlElement.classList.add(O.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(O.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,n,i;if(!(!this.container||!this.controlElement))if(Pn(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Rn({target:this.controlElement,props:this.control.props,fallback:j,isDark:e,baseDimension:o}),je({target:this.controlElement,props:this.control.props,fallback:{...j,borderColor:e?j.shadowColorDark:j.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(i=(n=(t=this.control.props)==null?void 0:t.shape)==null?void 0:n.roundCorners)!=null?i:j.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else je({target:this.controlElement,props:this.control.props,fallback:{...j,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(O.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(O.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${O.blinkAnimArea}`)||this.controlElement.classList.contains(O.selected)||this.controlElement.classList.contains(F.disabled)||(this.controlElement.classList.add(F.disabled),this.subscriptions.add((0,ue.fromEvent)(e,"animationiteration").pipe((0,ue.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(F.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${O.blinkAnimArea}`)||this.controlElement.classList.contains(O.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new V(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};var pe=require("@vkontakte/videoplayer-shared/es2018");var It=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var xt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new ar(r,e)},ar=class extends ne{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var s;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(O.common,O.button),n.setAttribute("data-testid",le.BUTTON),Ie({target:n,layoutParams:this.control.layoutParams,fallback:j}),vt({target:n,props:this.control.props,fallback:j}),je({target:n,props:this.control.props,fallback:j,dependsOn:this.container.dimensions}),mt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=It(this.control.type.trim().toLowerCase()),o=(s=i.firstElementChild)!=null?s:i;ft({target:o,props:this.control.props,fallback:j,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,pe.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let n=e.parentElement;if(n){let i=n.querySelector(`.${F.common}`);i&&this.syncBlinkAnimation(i)}},n=>this.onError("Error happened in mouseleave callback",n))),this.subscriptions.add((0,pe.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},n=>this.onError("Error happened in mouseenter callback",n))).add((0,pe.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},n=>this.onError("Error happened in mouseleave callback",n))))}disable(){this.controlElement&&this.controlElement.classList.add(O.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(O.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(O.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(O.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${O.blinkAnimButton}`)||this.controlElement.classList.contains(O.selected)||this.controlElement.classList.contains(F.disabled)||(this.controlElement.classList.add(F.disabled),this.subscriptions.add((0,pe.fromEvent)(e,"animationiteration").pipe((0,pe.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(F.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${O.blinkAnimButton}`)||this.controlElement.classList.contains(O.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new V(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var Vn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new lr(r,e)},lr=class extends ne{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var s;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(O.common,O.text),n.setAttribute("data-testid",le.TEXT),Ie({target:n,layoutParams:this.control.layoutParams,fallback:j}),mt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=It(this.control.type.trim().toLowerCase()),o=(s=i.firstElementChild)!=null?s:i;ft({target:o,props:this.control.props,fallback:j,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}onError(){}};var St=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new cr(r,e,t)},cr=class extends Ee{constructor(t,n,i){super(t,i);this.containerElement=null;this.controlSubscriptions=new Tt.Subscription;this.error$=new Tt.Subject;this.rootElement=n,this.layout=new dt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",xt),this.addControlFactory("text",Vn),this.addControlFactory("area",Et)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(_.common,_.disabled),requestAnimationFrame(()=>{n.classList.remove(_.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t),this.controlSubscriptions.add(i.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(_.hidden)}show(){let t=this.getElement();t&&t.classList.remove(_.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(_.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(_.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};var Da=z(Br(),1),T=require("@vkontakte/videoplayer-shared/es2018"),Ne=require("@vkontakte/videoplayer-statistics/es2018");var _o=require("@vkontakte/videoplayer-shared/es2018");function Ye(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var jo="video_interactive",$o="videoint";var Fo=250,Ze=class{constructor(e){this.handleZoomChange=Ye(e=>{this.lastZoomInfo=e},Fo);this.onResize=e=>{var n;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((n=this.ngEditor)==null||n.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,n,i;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(n=this.ngEditor)==null||n.selectChapter(e.id),(i=this.ngEditor)==null||i.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var n;if(this.isReady=!1,!Ct(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:i,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=n,this.lang=i!=null?i:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=mu(e),this.resizeObserver=new ResizeObserver(Ye(this.onResize,Fo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var n;if(!this.manifest)return;let e;try{e=await(0,_o.loadVKLangPack)(this.lang,jo,$o)}catch(i){(n=this.onError)==null||n.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:i,...o})=>{var s;i==="openPreview"&&"chapterId"in o&&((s=this.onOpenPreviewClick)==null||s.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function mu(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 Je=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let s=o.startTime-e;if(s<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<s&&(t=t===-1?s:Math.min(t,s))}return!n&&t!==-1?t:null}}};var g=require("@interactiveplatform/movika-manifest");var Bo={metadata:"Object",chapters:"Array"},qr=r=>{if(!oe(r))return!1;for(let e in Bo)if(!r[e]||!ie(r[e],Bo[e]))return!1;return(0,g.isSupportedManifest)(r.metadata.version)},et=r=>r.type===g.ControlTypes.Text,fu=r=>r.type===g.ControlTypes.Button,vu=r=>r.type===g.ControlTypes.Area,yu={Choice:"Choice",TextInput:"TextInput"},bu={Button:"Button",Area:"Area",Text:"Text"},Cu={onClick:"onClick",onSuspense:"onSuspense"},Dr={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Lt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var jt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{On(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ns=require("@vkontakte/videoplayer-shared/es2018");var $t=class{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!=null?n:[]}}async exec(e,t){return gu(...this.loaders[e])(t)}};function gu(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function tt(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Ft({actions:r,errors:e,chapterId:t,...n}){if(t){let i=r.getManifest();if(i){let o=r.getChapter(i.chapters,t);if(o){let s=r.getMedia(i.media,o.videoId),l=r.getGraph(i.graph,o.id);return s?{...n,actions:r,errors:e,result:{chapter:o,media:s,graph:l}}:{...n,errors:tt(e,Ft.name,"Could not find media"),actions:r}}}}return{...n,errors:tt(e,Ft.name,"Could not find chapter"),actions:r}}var _t=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,o=n.length;i<o;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,o=n.length;i<o;i++){let s=n[i];try{s.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}},ke=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)}},rt=class{constructor(){Object.defineProperty(this,"signal",{value:new ke,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(i){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(i){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(rt.prototype[Symbol.toStringTag]="AbortController",ke.prototype[Symbol.toStringTag]="AbortSignal");function Bt(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function Hr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Bt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||i)&&(o=function(c,m){let f;m&&m.signal&&(f=m.signal,delete m.signal);let v=new t(c,m);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let s=e;return{fetch:(a,c)=>{let m=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let f;try{f=new DOMException("Aborted","AbortError")}catch(C){f=new Error("Aborted"),f.name="AbortError"}if(m.aborted)return Promise.reject(f);let v=new Promise((C,w)=>{m.addEventListener("abort",()=>w(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,s(a,c)])}return s(a,c)},Request:o}}var Eu=()=>"fetch"in window,nt=Eu()&&Bt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),qo=nt?Hr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ur=nt?qo.fetch:window.fetch,lf=nt?qo.Request:window.Request,cf=nt?rt:window.AbortController,uf=nt?ke:window.AbortSignal;var qt=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let o=0;o<Math.max(t.length,n.length)&&!i;o++)t[o]>n[o]?i=1:t[o]<n[o]?i=-1:i=0;return i};var Iu=async r=>{try{let e={},t;if(yt(r)){t=new URL(r).href;let i=await Ur(t);if(!i.ok)return{};e=await i.json()}else if(oe(r))e=r;else return{};if(!qr(e))return{};let n=e.metadata.media;if(yt(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=await Ur(i);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(i){return Su(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function Do(r){let{manifest:e,manifestURL:t}=await Iu(r);if(!e)throw new Error("Failed on fetch");let n=(0,g.migrateManifestToLatestVersion)(e);return n.media=xu(n.media,t),delete n.metadata.media,n}function Dt(r,e){if(e)return r.find(t=>t.id===e)}function Gr(r,e){var t,n;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(i=>i.id===e):(n=r.view)!=null&&n.chapters?r.view.chapters.find(i=>i.id===e):void 0}function zr(r,e){return r.videos.find(t=>t.id===e)}function xu(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=Tu(i,e);return{...n,url:o||i}})}))}}function Tu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Su(r){return qt(r,"3.2.0")>=0}var Jo=z(it(),1);var Ht=r=>bt(r)&&!nr(r),Q=r=>r.order==="end",ot=r=>bt(r.containers)&&!nr(r.containers)&&Q(r),es=(r,e)=>{var n;let t=r*1e3;return Ht(e.controls)&&t<((n=e.startTime)!=null?n:0)},Kr=(r,e)=>{var n,i;let t=r*1e3;return Ht(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var de=(r=[])=>r.some(e=>e.action.type==="expect"),Qr=(r=[])=>r.find(e=>e.action.type==="expect"),Bu=r=>(r==null?void 0:r.length)===1,me=r=>Bu(r)&&et(r[0]);function ts(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,Jo.default)(t,n.container.id)&&de(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Ut({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),ts(r,i.container.container.endTime,[i.container.container.id]).forEach(s=>{n(s)});break}}var rs=(r,e)=>{let t=I=>{let d=e.find(({container:p})=>p.container.id===I);return d==null?void 0:d.container.isRemoved},n=de(r.events)&&!t(r.id),i=(I,d=!1,p=!1)=>{let u=p?"every":"some";return I.controls[u](y=>{var S;let E=d?I.endTime===r.endTime:!0;return((S=y.events)==null?void 0:S[u](b=>{var x;return((x=b.action)==null?void 0:x.type)===Dr.openURI}))&&E})},o=I=>I.some(({container:d})=>i(d.container,!0,!1)&&!d.isRemoved),s=I=>I.every(({container:d})=>d.isRemoved?!0:i(d.container,!0,!0)),l=ts(e,r.endTime,[r.id]).length,a=I=>I.controls.some(d=>{var p;return(p=d.events)==null?void 0:p.some(u=>{var y,E;return(E=(y=u.action)==null?void 0:y.args)==null?void 0:E.shouldOpenNow})}),c=n||l>0,m=o(e),f=i(r),v=s(e),C=n?!1:l>0,w=a(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:m,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:C,hasShouldOpenNowEvent:w}};var fe=class extends $t{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ns.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var i;this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:tt},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await Do((i=n.result)!=null?i:t),this}async setInitial(){return this.setNext()}async setNext(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=await this.exec("chapterLoaders",Ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Gr,getChapter:Dt,getMedia:zr,getByBranches:this.getByBranches.bind(this),addErrorMessage:tt},result:null,errors:null,chapterId:t}));return i.errors&&this.errorHandler(i.errors),i.result&&(this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.result.graph),this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var n;return this.getByChapterId((n=this.manifest)==null?void 0:n.metadata.initChapterId)||null}getByChapterId(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t||!this.manifest)return null;let i=Dt(this.manifest.chapters,t);if(i){let o=zr(this.manifest.media,i.videoId),s=Gr(this.manifest.graph,i.id);if(o)return{chapter:i,media:o,graph:s}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,o,s;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Dt(((s=this.manifest)==null?void 0:s.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let o=this.getByChapterId(i.chapterId);return o&&n.push(o),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,n;return((t=this.chapter)==null?void 0:t.id)===((n=this.manifest)==null?void 0:n.metadata.initChapterId)}isEndChapter(){return this.chapter?Q(this.chapter):!1}};var Ls=z(Gt(),1),js=require("@vkontakte/videoplayer-core/es2018"),se=require("@vkontakte/videoplayer-shared/es2018");var Ms=r=>{let e=r.variants.find(t=>{var n;return((n=t.payload)==null?void 0:n.type)==="vk"});if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var Ns=z(Gt(),1);function Zr(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:s=Math.random().toString(),...l}){let a=r.get(o),c={...l};return a?a[s]=c:r.set(o,{[s]:c}),{listId:o,itemId:s,...l}}function t(o){var s,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(s=o.statistics)==null||s.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function n(o,s){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(s){let a=l[s];a&&t(a),delete l[s],Object.keys(l).length||r.delete(o)}else{for(let a of(0,Ns.default)(l))t(a);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var Oe=z(it(),1);function Jr(r,e=[]){var o,s,l;let t={},n,i=!e.length;for(let a of r.variants)if(!n&&"cover"in a&&(n=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(i||(0,Oe.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=a.standard)!=null?o:"Invariant quality"]:a.url});break;case"mpeg":(i||(0,Oe.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(s=a.standard)!=null?s:"Invariant quality"]:a.url});break;case"hls":(i||(0,Oe.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:a.url}});break;case"dash":(i||(0,Oe.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}});break;default:break}return{sources:t,thumbUrl:n,title:(l=r.title)!=null?l:""}}var st=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Oe.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var mp=2;function en(r){let e=Zr(),t=new se.Subscription,n={},i=null,o=!1,s,l=new se.ValueSubject(null);r&&a(r);function a(d){i=d}function c(d,p,u){var S;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let E=((S=e.map.get(d))!=null?S:{})[p];if(E){n={chapterId:u,listId:d,itemId:p,...E};let b=n.player;n.subscription.add(b.info.currentQuality$.subscribe(x=>{let $=b.info.position$.getValue(),R=b.info.isAutoQualityEnabled$.getValue();if(!(!x||!$||R))for(let P of e.map)(0,Ls.default)(P[1]).forEach(({player:M})=>{st(M,x)})})).add(b.events.started$.subscribe(()=>{m(p)})),E.container.remove(),i.setPlayer(E.player),o||(i.init(),o=!0),l.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function m(d){if(!i)throw Error("need to set interactive controller");if(ce(n)||d!==n.itemId)return;let p=i.getChapterBranches(),u=new Set;for(let y of p)u.has(y.media.id)||(await v({media:y.media,chapterId:y.chapter.id,setAsActive:!1,title:y.chapter.label}),u.add(y.media.id))}async function f({chapter:{id:d},manifestVideo:p}){if(ce(n)||!i)return;let u=n.player.info.muted$.getValue(),y=n.player.info.currentQuality$.getValue(),E=n.player.info.isAutoQualityEnabled$.getValue(),S=n.player.info.volume$.getValue(),b=n.player.info.currentPlaybackRate$.getValue(),x=!E,$=!1;for(let R of e.map)if(R[0]===p.id&&!i.state.isReplay$.getValue()){let P=Object.keys(R[1]);for(let M of P)M===n.itemId?(P.length<mp||($=!0),e.removePlayer(R[0],M)):($=!0,c(R[0],M,d),x?st(n.player,y):n.player.setAutoQuality(!0),n.player.setVolume(S),n.player.setMuted(u),n.player.setPlaybackRate(b))}else e.removePlayer(R[0]);$||(await v({media:p,chapterId:d,setAsActive:!0,playbackRate:b}),x?st(n.player,y):n.player.setAutoQuality(!0),n.player.setVolume(S),n.player.setMuted(u))}async function v({media:d,chapterId:p,prefetch:u=!0,setAsActive:y=!0,autoplay:E=!1,preferredExt:S,title:b,playbackRate:x}){var hn,dn,mn,fn,vn;let $=Math.random().toString(),R=document.createElement("div");s.append(R);let P;if((hn=i==null?void 0:i.options)!=null&&hn.vkVideoLoader){let pt=Ms(d);pt.length&&(P=await i.options.vkVideoLoader(...pt))}let M=((dn=i==null?void 0:i.options)==null?void 0:dn.coreConfig)||void 0,X={...M,configName:[...(mn=M==null?void 0:M.configName)!=null?mn:[],"interactive"]},ae={container:R,...((fn=P==null?void 0:P.videos)==null?void 0:fn[0])||{sources:Jr(d,S).sources},title:b,failoverHosts:(P==null?void 0:P.failoverHosts)||[]},B=new js.Player(X,se.Tracer.createRootTracer());B.initVideo(ae);let Ce=null;if(P!=null&&P.videos&&(i!=null&&i.options.createOneStat)){let pt=P.videos[0],Jt=i.options.createOneStat(pt),yn=new se.Subscription;Jt&&(yn.add(Jt.attachTo(B)),Ce={oneStat:Jt,statSubscription:yn})}let pn=new se.Subscription,Ga=(vn=n==null?void 0:n.player)==null?void 0:vn.info.isAutoQualityEnabled$.getValue();pn.add(B.events.canplay$.subscribe(function(){Ga||st(B,n.player.info.currentQuality$.getValue()),x&&B.setPlaybackRate(x)}));let ge=e.createPlayer({listId:d.id,itemId:$,player:B,container:R,sources:Jr(d,S).sources,config:ae,subscription:pn,statistics:Ce});return y&&c(d.id,ge.itemId,p),E&&ge.player.play(),u&&!E&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}}function C(){w(),i=null,s.remove()}function w(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function I(){if(!i)throw Error("need to set interactive controller");w(),s=document.createElement("div");let{media:d,chapter:p}=i.getCurrentChapter();d&&p?(t.add(i.events.chapterChanged$.subscribe(f)),await v({media:d,chapterId:p.id,title:p.label})):console.error("not found")}return{...e,init:I,setInteractiveController:a,createPlayer:v,removeAll:C,getActivePlayer:function(){return n},activePlayerChanged:l}}var k={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Pe={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},N={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Fs=z(it(),1),_s=require("@vkontakte/videoplayer-shared/es2018");function tn(r){return function(...t){return r(...t.reverse())}}function at(r,...e){return(...t)=>oe(e[0])&&oe(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var zt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:s,globalEventEmitter:l,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:m,disabledControls$:f,onRemove:v,onError:C}){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 t,n,i,o;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&s)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(a,c)=>{let{isExpectTime:m,hasOtherExpect:f,hasOpenURIEvent:v,hasOpenURIEventInCurrentContainer:C,isAllOpenURIEventsValid:w,hasShouldOpenNowEvent:I}=this.getContainerEventState(),d=this.interactiveTimeOpenUri&&!C,p=this.interactiveTimeOpenUri&&C;if((!this.interactiveTimeOpenUri||d)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||d)){if(this.interactiveTimeOpenUri){let u=!f&&!w&&C;u&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:u})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&v&&this.gameState!==5){if(p){let y=((E,S,b,x)=>!E&&!S&&b||E&&!S&&b&&!x||E&&!S&&b&&x)(m,f,w,this.isSelectedContainerEvent);this.fakeRemoveView(y)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!m||!f||!I)&&(this.selectBranches.stopExpect(),c())}},isEOV:()=>this.gameState===4},l=at(this.selectBranches.onControlEvent,s);this.container.createView({eventCallback:l}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((o=(i=this.container).disable)==null||o.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c,m,f;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Fs.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(es(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Kr(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let v=this.gameState;this.gameState=3,v===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:v}=this.getContainerEventState(),C=this.selectBranches.state.isExpect,w=this.interactiveTimeOpenUri&&v;if(w&&!C){let I=this.container.getElement();I&&(I.style.visibility!=="hidden"&&((m=(c=this.container).hide)==null||m.call(c)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!w&&this.removeView()}let s=Kr(o,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(f=this.container.container.endTime)!=null?f:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:o,isInteractiveTime:s};this.container.onProgress(o*1e3,s),this.globalEventEmitter.emit(k.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new _s.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a,this.isPermanentText=c&&me(t.container.controls),this.interactiveTimeOpenUri=m,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=s,this.onError=C,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.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(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,n,i,o;e?(n=(t=this.container).disable)==null||n.call(t):(o=(i=this.container).enable)==null||o.call(i)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var n,i;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(n=this.container.container.endTime)!=null?n:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:de(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Bs=(r=[])=>r.reduce((e,t,n)=>{var o,s,l;let i=((o=t==null?void 0:t.controls)!=null?o:[]).filter(a=>!et(a));if(Ht(i)){let a=[(s=t.startTime)!=null?s:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:a});else{let m=[],f=-1/0,v=1/0,C=[],w=[];for(let I=0;I<e.length;I++){let d=e[I];if(w.push(...d.subjects),d.range[0]<v&&(v=d.range[0]),d.range[1]>f&&(f=d.range[1]),a[0]>=d.range[0]&&a[1]<=d.range[1])return e[I].subjects.push(c),e;a[0]<d.range[0]&&a[1]>d.range[0]&&(m.push(I),C=C.concat(d.subjects)),a[0]>=d.range[0]&&a[0]<=d.range[1]&&(m.push(I),C=C.concat(d.subjects),a[0]=d.range[0]),a[1]>=d.range[0]&&a[1]<=d.range[1]&&(m.push(I),C=C.concat(d.subjects),a[1]=d.range[1])}if(w.push(c),a[0]<=v&&a[1]>=f)return[{subjects:w,range:a}];m.length&&m.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:C.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Ea=z(it(),1),sn=z(Gt(),1),Ia=z(Ca(),1);function ga(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let a={};for(let c in r)+c<=l&&(a[c]=r[c]);return a}function n(l){let a={};for(let c in r)+c>=l&&(a[c]=r[c]);return a}function i({timestamp:l,priority:a,initiator:c}){var m;if(rr(l)){let f=(m=r[l])!=null?m:null;if(f&&a&&_e(a,!0)){let v={},C=f[a];if(C&&(v={...v,...C}),v=ce(v)?null:v,v&&_e(c,!0)){let w=v[c];return w!=null?w:null}return v}return f}return null}function o({timestamp:l,priority:a,initiator:c}){if(rr(l))if(r[l]){if(a&&_e(a,!0))if(r[l][a]){if(c&&_e(c,!0))if(r[l][a][c]){if(delete r[l][a][c],!ce(r[l][a]))return!0}else return!1;if(delete r[l][a],!ce(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function s({timestamp:l,priority:a,initiator:c,...m}){var f,v,C;(v=(f=r[l])==null?void 0:f[a])!=null&&v[c]?r[l][a][c].push({...m}):(C=r[l])!=null&&C[a]?r[l][a]={...r[l][a],[c]:[{...m}]}:r[l]?r[l]={...r[l],[a]:{[c]:[{...m}]}}:r[l]={[a]:{[c]:[{...m}]}}}return{map:r,remove:o,add:s,removeAll:e,get:i,getLte:t,getGte:n}}var rh=[g.EventActionTypes.expect,g.EventActionTypes.setNextBranch],nh=1/0;function xa(r,e){let t=r,n,i=ih(e),o=ga(),s,l=()=>{C(),p()},a=u=>{o.add.call(void 0,u),w()},c=(u=[])=>{for(let y of u)if(y.action(),(0,Ea.default)(rh,y.actionType))break},m=(u=1/0)=>{var b,x,$;let y=Kt((b=o.get({timestamp:u,priority:"control"}))!=null?b:{}),E=Kt((x=o.get({timestamp:u,priority:"container"}))!=null?x:{}),S=Kt(($=o.get({timestamp:u,priority:"chapter"}))!=null?$:{});return[...y,...E,...S]},f=u=>{i.isReady(u)&&c(m(u))},v=()=>{var u;c([...Kt((u=o.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},C=()=>{n&&(s==null||s.unsubscribe(),n=void 0)},w=()=>{n||(n=()=>setTimeout(()=>{f(1/0)}),s=t.events.ended$.subscribe(n))},I=u=>{C(),t=u},d=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),o.remove(u)},p=()=>{i.release(),o.removeAll()};return{setPlayer:I,add:a,remove:d,exec:f,execEndOfVideo:v,listen:w,unlisten:C,release:l,containersEventsCallState:i,getPreparedToExecActions:m}}function ih(r){let e=new Map;return{setCalled:({timestamp:l,id:a})=>{let c=e.get(l);c&&c[a]!==void 0&&(c[a]=!0)},setData:(l=[])=>{var a;for(let c of l){let m=(a=c.endTime)!=null?a:nh,f=e.get(m);e.set(m,{...f,[c.id]:!1})}},resetCalled:l=>{let a=e.get(l);if(a)for(let c in a)a[c]=!1},isReady:l=>{let a=e.get(l);if(!a)return!0;let c=(0,sn.default)(a);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Kt(r){return(0,Ia.default)((0,sn.default)(r)).sort(e=>e.actionType===g.EventActionTypes.expect?-1:1)}var Ta={videoContentHeight:0,videoContentWidth:0},Sa=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ta;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return Ta;let o=e/t,s=n/i,l,a;return s>o?(a=i,l=i*o):s<o?(a=n/o,l=n):(a=i,l=n),{videoContentWidth:a,videoContentHeight:l}};var oh=250;function wa(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function n(l){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:f}=Sa(c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${f}px`),a.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function i(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Ye(l=>{let{fns:a=[]}=r();n(l);for(let c of a)c()},oh);function s(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:s}}var sh=r=>Math.floor(Math.random()*r),Ra=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let o=r[e],s=(i=o.weight)!=null?i:1;s<t&&(t=s,n=o)}return n},ka=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let o=r[e],s=(i=o.weight)!=null?i:0;s>t&&(t=s,n=o)}return n};var Oa=r=>{let e=r.length,t=sh(e);return r[t]},Aa=1,Pa=r=>{var n,i;let e=0;for(let o=0;o<r.length;++o)e+=(n=r[o].weight)!=null?n:Aa;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(i=r[o].weight)!=null?i:Aa,e>=t)return r[o];return r[r.length-1]};var Va={shouldOpenNow:!0,isDetachContainer:!0},Ma="after-expect",an=(r,e=!1)=>({...r,args:e?{...r.args,...Va}:{...Va,...r.args}}),Na=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},s=({action:p,controlType:u,controlId:y,containerId:E,branches:S=[],onEvent:b,isEOV:x=()=>!1,isDisabled:$=()=>!1})=>{let R=an(p,x()),P={timestamp:1/0,priority:"control",initiator:y,actionType:R.type},M=$(),X=r.emit.bind(r,k.interactives,{subjectId:y,subjectType:u,subjectName:"control",type:M?N.actionChoiceCanceled:N.actionChoice,actionType:p.type,payload:{invokeImmediately:R.args.shouldOpenNow,containerId:E,...R.args}}),ae=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:u,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:p.type,payload:{invokeImmediately:R.args.shouldOpenNow,containerId:E,...R.args}})};if(M){X(),ae();return}switch(R.type.trim().toLowerCase()){case g.EventActionTypes.setNextBranch.trim().toLowerCase():{let B=S.find(Ce=>Ce.id===R.args.branchId);if(!B)return;b(R.args.isDetachContainer,C.bind(null,{subjectId:y,subjectName:"control"})),X(),ae(),R.args.shouldOpenNow?I({subjectId:y,subjectName:"control",subjectType:u,action:R,payload:{chapterId:B.chapterId,autoSelect:!1}}):n.add({...P,action:I.bind(null,{subjectId:y,subjectName:"control",subjectType:u,action:R,payload:{chapterId:B.chapterId,autoSelect:!1}})});return}case g.EventActionTypes.continuePlayback.trim().toLowerCase():{b(R.args.isDetachContainer,C.bind(null,{subjectId:y,subjectName:"control"})),X(),ae(),R.args.shouldOpenNow?w({subjectId:y,subjectName:"control",subjectType:u,action:p}):n.add({...P,action:w.bind(null,{subjectId:y,subjectName:"control",subjectType:u,action:p})});return}case g.EventActionTypes.openURI.trim().toLowerCase():{b(R.args.isDetachContainer,C.bind(null,{subjectId:y,subjectName:"control"})),X(),ae(),R.args.shouldOpenNow?d({subjectId:y,subjectName:"control",subjectType:u,action:R,payload:{URI:p.args.uri}}):n.add({...P,action:d.bind(null,{subjectId:y,subjectName:"control",subjectType:u,action:R,payload:{URI:p.args.uri}})});return}default:{let B="Unexpected control event",Ce=new V(1,1,{message:B});m(Ce,B);return}}},l=({action:p,container:{id:u,endTime:y},branches:E=[],isEOV:S=!1,autoSelected:b=!1})=>{let x=an(p,S),$={timestamp:!x.args.shouldOpenNow||S?1/0:y!=null?y:1/0,priority:"container",initiator:u,actionType:x.type},R=r.emit.bind(r,k.interactives,{subjectId:u,subjectName:"container",type:N.actionChoice,actionType:x.type,payload:{invokeImmediately:x.args.shouldOpenNow,...x.args}}),P=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:x.type,payload:{invokeImmediately:x.args.shouldOpenNow,...x.args}})};switch(x.type.trim().toLowerCase()){case g.EventActionTypes.setNextBranch.trim().toLowerCase():{let M=E.find(X=>X.id===x.args.branchId);if(!M)return;R(),P(),n.add({...$,action:I.bind(null,{subjectId:u,subjectName:"container",action:x,payload:{chapterId:M.chapterId,autoSelect:b}})});return}case g.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case g.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case g.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case g.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case g.EventActionTypes.continuePlayback.trim().toLowerCase():{R(),P(),n.add({...$,action:w.bind(null,{subjectId:u,subjectName:"container",action:x})});return}case g.EventActionTypes.openURI.trim().toLowerCase():{R(),P(),n.add({...$,action:d.bind(null,{subjectId:u,subjectName:"container",action:x,payload:{URI:p.args.uri}})});return}default:{let M="Unexpected container event",X=new V(1,1,{message:M});m(X,M);return}}};function a({container:p,branches:u,isEOV:y=!1}){var S,b;let E=Qr(p.events);if(E){let x=an(E.action,y);r.emit(k.interactives,{subjectId:p.id,subjectName:"container",type:N.actionChoice,actionType:x.type,payload:{invokeImmediately:x.args.shouldOpenNow,...x.args}}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:x.type,payload:{invokeImmediately:x.args.shouldOpenNow,...x.args}}),n.add({timestamp:y?1/0:(S=p.endTime)!=null?S:1/0,priority:"container",initiator:p.id,actionType:g.EventActionTypes.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),i.isExpect=!0}else for(let x of(b=p.events)!=null?b:[])l({action:x.action,container:p,branches:u,isEOV:y})}let c=({chapterId:p,action:u,branches:y=[]})=>{let E=r.emit.bind(r,k.interactives,{subjectId:p,subjectName:"chapter",type:N.actionChoice,actionType:u.type,payload:u.args}),S=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case g.EventActionTypes.setNextBranch.trim().toLowerCase():{let b=y.find(x=>x.id===u.args.branchId);return b!=null&&b.chapterId?(E(),S(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case g.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let b=Oa(y);return b!=null&&b.chapterId?(E(),S(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case g.EventActionTypes.setRandomBranch.trim().toLowerCase():{let b=Pa(y);return b!=null&&b.chapterId?(E(),S(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case g.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let b=ka(y);return b!=null&&b.chapterId?(E(),S(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case g.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let b=Ra(y);return b!=null&&b.chapterId?(E(),S(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case g.EventActionTypes.continuePlayback.trim().toLowerCase():return E(),S(),w.bind(null,{subjectId:p,subjectName:"chapter",action:u});case g.EventActionTypes.openURI.trim().toLowerCase():return E(),S(),d.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let b="Unexpected chapter event",x=new V(1,1,{message:b});m(x,b);return}}};function m(p,u){console.error(u),e.error$.next(p),r.emit(k.errors,p)}function f(p){var y;let u=Qr(p.events);if(u){if(Q(p))return;r.emit(k.interactives,{subjectId:p.id,subjectName:"chapter",type:N.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:g.EventActionTypes.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(y=p.events)==null||y.forEach(E=>{let S=c({chapterId:p.id,action:E.action,branches:p.branches});S&&n.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:E.action.type,action:S})})}let v=({subjectId:p,subjectName:u})=>{t.pause(),r.emit(k.interactives,{subjectId:p,subjectName:u,type:N.actionExecution,actionType:g.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:u,type:"action-execution",actionType:g.EventActionTypes.expect})},C=({subjectId:p,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:p,subjectName:u,type:N.actionExecution,actionType:Ma}),e.interactiveActionExecution$.next({subjectId:p,subjectName:u,type:"action-execution",actionType:Ma})},w=({subjectId:p,subjectName:u,subjectType:y,action:E})=>{r.emit(k.interactives,{subjectId:p,subjectName:u,subjectType:y,type:N.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:u,subjectType:y,type:"action-execution",actionType:E.type})},I=({subjectId:p,subjectName:u,subjectType:y,action:E,payload:S})=>{S.behaviour="change-chapter",r.emit(k.interactives,{subjectId:p,subjectName:u,subjectType:y,type:N.actionExecution,actionType:E.type,payload:S}),e.interactiveActionExecution$.next({subjectId:p,subjectName:u,subjectType:y,type:"action-execution",actionType:E.type,payload:S})},d=({subjectId:p,subjectName:u,subjectType:y,action:E,payload:S})=>{if(!S.URI)return;let b=window.open(S.URI,"_blank","noopener,noreferrer");b&&(b.opener=null),r.emit(k.interactives,{subjectId:p,subjectName:u,subjectType:y,type:N.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:u,subjectType:y,type:"action-execution",actionType:E.type})};return{onControlEvent:s,onContainerEvent:l,onChapterEvent:c,onExpectEvent:v,expectEventHandler:C,setManifestChapterEvents:f,setManifestContainerEvents:a,stopExpect:o,state:i}};var un=z(Br(),1),G=require("@vkontakte/videoplayer-shared/es2018");var Qt=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(s=>s.id===n);if(!i)return null;let o=e.media.videos.find(s=>i.videoId===s.id);if(!o)return null;t[n]=ln(o)}return t[n]}).filter(Boolean)},La=r=>{for(let e of r.variants)if(ja(e)&&e.payload)return e.payload.id},ja=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ln=r=>{let e=La(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},$a=(r,e)=>{for(let t of r.media.videos)if(e===ln(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},cn=(r,e)=>r.reduce((t,n)=>{let i=$a(e,n);return i?[...t,i]:t},[]);var ee,ve,ye,U,Xt,te,re,J,be,Ve,Me,ct=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new G.ValueSubject([]),hasPrevChapter$:new G.ValueSubject(!1),prevChapter$:new G.ValueSubject(null),isInitialChapter$:new G.ValueSubject(!1),isGoBackLimited$:new G.ValueSubject(!1)};q(this,ee,null);q(this,ve);q(this,ye,!1);q(this,U,null);q(this,Xt,null);this.events={inited$:new G.Subject,destroyed$:new G.Subject,error$:new G.Subject};q(this,te,null);q(this,re,null);q(this,J,null);q(this,be,new G.Subscription);q(this,Ve,!1);q(this,Me,0);var s;L(this,te,t),L(this,J,e),L(this,re,n),L(this,ee,i),L(this,ve,o),this.state.history$&&A(this,be)&&((s=A(this,be))==null||s.add(this.state.history$.subscribe(l=>{var a,c;this.state.prevChapter$.next((0,un.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=A(this,U))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(A(this,Me)===A(this,ve).maxLength-1)})))}async setManifest(e){if(!A(this,re)||!A(this,J))return;L(this,U,e),await this.getProjectHistory();let t=this.getInitialChapterId();await A(this,re).setChapter({chapterId:t,pushToHistory:!1}),A(this,ye)||(L(this,ye,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return A(this,ye)}async updateHistory(e,t=!0){var l;if(!A(this,U))return;A(this,Ve)?(L(this,Ve,!1),En(this,Me)._++):L(this,Me,0);let n=A(this,U),i=e.length-A(this,ve).maxLength,o=i>0?e.slice(i):e,s=Qt(o,n);if(L(this,Xt,s),this.state.history$.next(o),!(!t||!A(this,ee)||!A(this,te)))try{await A(this,ee).save(A(this,te),s)}catch(a){let c=new V(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=A(this,J))==null||l.emit(k.errors,c)}}async goBack(){var n;if(!this.state||!A(this,re)){let i=new V(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=A(this,J))==null?void 0:n.emit(k.errors,i)}L(this,Ve,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await A(this,re).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var i;if(!A(this,U)||!A(this,te))return;let e=A(this,U),t=[this.getInitialVideoId()];if(A(this,ee))try{let o=await A(this,ee).get(A(this,te));o.length&&(t=o)}catch(o){let s=new V(1,5,"Error while trying to fetch data");this.events.error$.next(s),(i=A(this,J))==null||i.emit(k.errors,s)}let n=cn(t,e);this.state.history$.next(n)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,un.default)(e,-1)||A(this,ve).initChapterId||((t=A(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(A(this,U)){let e=this.getInitialChapterId();return Qt([e],A(this,U)).pop()}return null}destroy(){var e,t;L(this,te,null),L(this,ee,null),L(this,re,null),(e=A(this,be))==null||e.unsubscribe(),L(this,be,null),L(this,ye,!1),(t=A(this,J))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),L(this,J,null)}};ee=new WeakMap,ve=new WeakMap,ye=new WeakMap,U=new WeakMap,Xt=new WeakMap,te=new WeakMap,re=new WeakMap,J=new WeakMap,be=new WeakMap,Ve=new WeakMap,Me=new WeakMap;var Yt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var i;let e=(i=this.rootElement.getContext("2d"))==null?void 0:i.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let o=3;o<n;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Zt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
7
7
  position: absolute;
8
8
  top: 0;
9
9
  left: 0;
@@ -11,12 +11,12 @@
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new rr,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new Yt,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
15
15
  position: absolute;
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,o;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function Ks(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Xs=`/* interactive-container */
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var n,i,o;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)==null?void 0:t.onError)==null||n.call(t,e)}};function Fa(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var _a=`/* interactive-container */
20
20
  .interactive-container {
21
21
  opacity: 1;
22
22
  visibility: visible;
@@ -31,16 +31,6 @@
31
31
  visibility: hidden;
32
32
  }
33
33
 
34
- .interactive-container.interactive-container-before-remove.interactive-container-before-remove-delay {
35
- transition-delay: var(--interactive-remove-delay);
36
- }
37
-
38
- .interactive-container.interactive-container-before-remove {
39
- transition: opacity var(--interactive-transition-1);
40
- opacity: 0;
41
- pointer-events: none;
42
- }
43
-
44
34
  /* blink-anim */
45
35
  .interactive-control-blink-anim {
46
36
  animation-duration: 2001ms;
@@ -95,39 +85,6 @@
95
85
  animation: none;
96
86
  }
97
87
 
98
- /* control tap */
99
- .interactive-control-tap {
100
- position: absolute;
101
- aspect-ratio: 1;
102
- background-color: var(--interactive-bg-color-1);
103
- border: 1px solid var(--interactive-color-1);
104
- border-radius: 50%;
105
- transition: opacity var(--interactive-transition-1);
106
- opacity: 0;
107
- pointer-events: none;
108
- z-index: 1;
109
- }
110
-
111
- .interactive-control-tap-animation {
112
- animation-duration: 300ms;
113
- animation-iteration-count: 1;
114
- animation-timing-function: ease;
115
- animation-name: interactive-control-tap-bounce;
116
- }
117
-
118
- @keyframes interactive-control-tap-bounce {
119
- 0%, 100% {
120
- transform: scale(1);
121
- }
122
- 50% {
123
- transform: scale(0.3);
124
- }
125
- }
126
-
127
- .interactive-container:not(.interactive-container-disabled) .interactive-control-tap-visible {
128
- opacity: 1;
129
- }
130
-
131
88
  /* interactive-chapter */
132
89
  .interactive-chapter {
133
90
  position: absolute;
@@ -137,18 +94,11 @@
137
94
 
138
95
  --interactive-transition-1: 100ms ease-in-out;
139
96
  --interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
140
- --interactive-color-1: #fff;
141
- --interactive-bg-color-1: rgba(255, 255, 255, 0.08);
142
97
  --interactive-button-hover-opacity: 0.8;
143
98
  --interactive-area-hover-opacity: 0;
144
- --interactive-remove-delay: 300ms;
145
99
  }
146
100
 
147
101
  /* interactive-control */
148
- .interactive-control-wrapper-selected {
149
- pointer-events: none;
150
- }
151
-
152
102
  .interactive-control {
153
103
  display: flex;
154
104
  width: 100%;
@@ -163,11 +113,11 @@
163
113
  border: none;
164
114
  }
165
115
 
166
- .interactive-control.interactive-control-disabled {
116
+ .interactive-control-disabled {
167
117
  cursor: default;
168
118
  }
169
119
 
170
- .interactive-control-button,
120
+ .interactive-control-button
171
121
  .interactive-control-area {
172
122
  cursor: pointer;
173
123
  }
@@ -180,106 +130,20 @@
180
130
  transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
181
131
  }
182
132
 
183
- .interactive-control-wrapper-selected > .interactive-control-button {
184
- transition: opacity var(--interactive-transition-1);
185
- opacity: 0.5;
186
- }
187
-
188
- .interactive-control-wrapper-selected > .interactive-control-area {
189
- transition: opacity var(--interactive-transition-1);
190
- opacity: 0;
191
- }
192
-
193
-
194
- .interactive-control.interactive-control-before-remove {
195
- transition: opacity var(--interactive-transition-1);
196
- opacity: 0;
197
- pointer-events: none;
198
- }
199
-
200
133
  .interactive-container.interactive-container-disabled .interactive-control-button,
201
134
  .interactive-container.interactive-container-disabled .interactive-control-area {
202
135
  animation: none;
203
136
  }
204
137
 
205
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):hover,
206
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):focus-visible {
138
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-button:not(.interactive-control-selected):not(.interactive-control-blink-anim):hover,
139
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-button:not(.interactive-control-selected):not(.interactive-control-blink-anim):focus-visible {
207
140
  opacity: var(--interactive-button-hover-opacity);
208
141
  animation: none;
209
142
  }
210
143
 
211
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):hover,
212
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):focus-visible {
144
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-area:not(.interactive-control-selected):not(.interactive-control-blink-anim):hover,
145
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-area:not(.interactive-control-selected):not(.interactive-control-blink-anim):focus-visible {
213
146
  opacity: var(--interactive-area-hover-opacity);
214
147
  animation: none;
215
148
  }
216
-
217
- /* fill animation */
218
- .interactive-control-fill-animation {
219
- position: absolute;
220
- overflow: hidden;
221
- z-index: -1;
222
- pointer-events: none;
223
- }
224
-
225
- .interactive-control-fill-animation-filler-wrapper {
226
- position: absolute;
227
- width: 100%;
228
- height: 100%;
229
- transform-origin: center;
230
- }
231
-
232
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-width {
233
- top: 0;
234
- }
235
-
236
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-height {
237
- left: 0;
238
- }
239
-
240
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-right {
241
- right: 0;
242
- }
243
-
244
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-left {
245
- left: 0;
246
- }
247
-
248
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-top {
249
- top: 0;
250
- }
251
-
252
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-bottom {
253
- bottom: 0;
254
- }
255
-
256
- .interactive-control-fill-animation-filler {
257
- width: 100%;
258
- height: 100%;
259
- background-color: rgba(173, 211, 255, 0.32);
260
- }
261
-
262
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-width {
263
- transform: scaleX(0);
264
- }
265
-
266
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-height {
267
- transform: scaleY(0);
268
- }
269
-
270
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-right {
271
- transform-origin: right;
272
- }
273
-
274
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-left {
275
- transform-origin: left;
276
- }
277
-
278
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-top {
279
- transform-origin: top;
280
- }
281
-
282
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
283
- transform-origin: bottom;
284
- }
285
- `;var Qs=r=>{let e=document.createElement("style");e.textContent=Xs,r.prepend(e)};var Js=require("@vkontakte/videoplayer-core/es2018");var Ys=Object.freeze({lang:I.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1}});function Eh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var pt=class{constructor(e){this.playerSubscriptions=new I.Subscription;this.subscriptions=new I.Subscription;this.globalEventEmitter=new Dt;this.animation=new Ht;this.seekToInteractiveController=new it;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Eh();this.factories=new Map([["choice",qt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new I.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new I.ValueSubject(null),isInitialChapter$:new I.ValueSubject(!1),isFirstChapter$:new I.ValueSubject(!0),isEndChapter$:new I.ValueSubject(!1),isInteractiveExpectation$:new I.ValueSubject(!1),isReplay$:new I.ValueSubject(!1),calledByInteractive$:new I.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new I.ValueSubject(!1),disabledControls$:new I.ValueSubject(!1),interactiveRanges$:new I.ValueSubject([]),isInteractiveTime$:new I.ValueSubject(!1),statistics$:new I.ValueSubject(null),isSeekable$:new I.ValueSubject(!1)};this.events={noInteraction$:new I.Subject,graphVisibilityChanged$:new I.Subject,watchAgainIsClicked$:new I.Subject,chapterChanged$:new I.Subject,playerChanged$:new I.Subject,error$:new I.Subject,eachTick$:new I.Subject,manifestChanged$:new I.Subject,interactiveRangeEnded$:new I.Subject,interactiveContainerRemoved$:new I.Subject,interactiveContainerFakeRemoved$:new I.Subject,interactiveActionExecution$:new I.Subject,interactiveActionChoice$:new I.Subject,interactiveVisibilityChanged$:new I.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(k.errors,e)};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&X(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:o}=t;n.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(k.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let i of this.gameControllers)!e&&i.isPermanentText||(this.animation.removeFn(i.whilePlaying),i.destroy(t))};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n,o;if(this._options={...Ys,...e,config:{...Ys.config,...e.config}},(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Nt,this.blinkAnimationRef.create();let a=this.blinkAnimationRef.element;a&&this.rootElement.append(a)}this._options.parentElement.append(this.rootElement),this.historyController=new ut({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new ir({parentElement:this._options.parentElement,onError:a=>{let l=new $(1,6,a);this.emitErrorEvent(l)}})),Qs(this._options.parentElement),this.subscriptions.add((0,I.fromEvent)(this.rootElement,"mousedown").subscribe(a=>a.stopPropagation())).add((0,I.fromEvent)(this.rootElement,"mouseup").subscribe(a=>a.stopPropagation())),this.manifestController=new ye(this._options.loaders,a=>{let l=new $(1,3,a);this.emitErrorEvent(l)});let i=[];this._options.lastFrame&&i.push(()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}),i.push(()=>{let a=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(a)}),this.resizeManager=Ns(()=>({player:this.player,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new rt({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:a=>{this.setChapter({chapterId:a}),this.globalEventEmitter.emit(k.graph,{type:Fe.watchAgainClicked,chapterId:a}),this.events.watchAgainIsClicked$.next(a)},onError:a=>{let l=new $(1,2,{message:a});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{var n;e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=li(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(k.interactives,{type:F.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,I.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,I.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var s;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[f,v],subjects:y})=>f<c&&c<v&&y.some(w=>!w.isRemoved)&&y.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,l=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||i;n&&!o&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!be(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(i=>{var l,s,c,d,f,v;let n=i.type.trim().toLowerCase(),o=this.factories.get(n),a=o==null?void 0:o(i,this.rootElement,{isTouch:(s=(l=this._options)==null?void 0:l.isTouch)!=null?s:!1,features:{controlsExpectTimeBlinkAnimation:(c=this._options.animationsFeatureToggles)==null?void 0:c.controlsExpectTimeBlinkAnimation,controlsTapPlace:(d=this._options.animationsFeatureToggles)==null?void 0:d.controlsTapPlace,controlsFillAnimation:(f=this._options.animationsFeatureToggles)==null?void 0:f.controlsFillAnimation}});if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let y=new Yt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ea(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},onError:this.emitErrorEvent,features:{controlsHideAnimation:(v=this._options.animationsFeatureToggles)==null?void 0:v.controlsHideAnimation}});this.animation.addFn(y.whilePlaying,!0),t.push(y)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(l=i&&X(i)&&Je(i))!=null?l:!1,o=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,a=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,Zs.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:i}=this.state,o=i.getValue().map(a=>{let l=a.subjects.some(c=>c.id===e),s=a.subjects.map(c=>t&&l||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:s}});i.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var i,n;if(!((i=this._options.animationsFeatureToggles)!=null&&i.controlsExpectTimeBlinkAnimation))return;let t=(o,a)=>{o.toggleBlinkAnimation(a)};Vt({...e,gameControllers:this.gameControllers,execFn:lt(ci(t),e.isExpect)}),e.isExpect&&((n=this.blinkAnimationRef)==null||n.restart())}updateControlsShadowStyles(e){var i;if(!((i=this._options.animationsFeatureToggles)!=null&&i.areaControlShadow))return;let t=(n,o)=>{n.updateControlsShadowStyles(o)};e.isExpect?Vt({...e,gameControllers:this.gameControllers,execFn:lt(ci(t),!1)}):Vt({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(k.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=Ls(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Us({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Js.clientChecker.browser.isSafari&&await Ks(35);let n=!i&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:o,media:a,graph:l}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:a}),this.globalEventEmitter.emit(k.chapterChanged,{chapter:o,media:a,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new I.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?$e.InteractiveInterfaceClick.GRAPH_SHOW:$e.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next($e.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next($e.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next($e.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new I.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(k.graph,{type:Fe.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===C.EventActionTypes.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(i=>{var o;let n=e&&((o=this._options.animationsFeatureToggles)!=null&&o.controlsHideAnimation)?i.container.willRemoved:!0;return!i.container.isRemoved||!n})}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&!i.container.willRemoved&&n.endTime===null&&ve(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,C.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return Qa((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,o,a;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(i=this.seamlessController)==null||i.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var el={Container:xe,createChoiceContainer:qt,createAreaControl:$t,createButtonControl:Bt,classnamesPrefix:Fi};var Th={version:ki};
149
+ `;var Ba=r=>{let e=document.createElement("style");e.textContent=_a,r.prepend(e)};var Ha=require("@vkontakte/videoplayer-core/es2018");var qa=Object.freeze({lang:T.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function ch(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var ut=class{constructor(e){this.playerSubscriptions=new T.Subscription;this.subscriptions=new T.Subscription;this.globalEventEmitter=new Lt;this.animation=new jt;this.seekToInteractiveController=new Je;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ch();this.factories=new Map([["choice",St]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new T.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new T.ValueSubject(null),isInitialChapter$:new T.ValueSubject(!1),isFirstChapter$:new T.ValueSubject(!0),isEndChapter$:new T.ValueSubject(!1),isInteractiveExpectation$:new T.ValueSubject(!1),isReplay$:new T.ValueSubject(!1),calledByInteractive$:new T.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new T.ValueSubject(!1),disabledControls$:new T.ValueSubject(!1),interactiveRanges$:new T.ValueSubject([]),isInteractiveTime$:new T.ValueSubject(!1),statistics$:new T.ValueSubject(null),isSeekable$:new T.ValueSubject(!1)};this.events={noInteraction$:new T.Subject,graphVisibilityChanged$:new T.Subject,watchAgainIsClicked$:new T.Subject,chapterChanged$:new T.Subject,playerChanged$:new T.Subject,error$:new T.Subject,eachTick$:new T.Subject,manifestChanged$:new T.Subject,interactiveRangeEnded$:new T.Subject,interactiveContainerRemoved$:new T.Subject,interactiveContainerFakeRemoved$:new T.Subject,interactiveActionExecution$:new T.Subject,interactiveActionChoice$:new T.Subject,interactiveVisibilityChanged$:new T.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(k.errors,e)};this.clearHistoryIfEnded=()=>{var i;let e=(i=this.player)==null?void 0:i.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&Q(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:i,oneStat:o}=t;i.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(k.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(o=>({...o,subjects:o.subjects.filter(s=>s.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var i,o;if(this._options={...qa,...e,config:{...qa.config,...e.config}},(i=this._options.animationsFeatureToggles)==null?void 0:i.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new gt,this.blinkAnimationRef.create();let s=this.blinkAnimationRef.element;s&&this.rootElement.append(s)}this._options.parentElement.append(this.rootElement),this.historyController=new ct({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Zt({parentElement:this._options.parentElement,onError:s=>{let l=new V(1,6,s);this.emitErrorEvent(l)}})),Ba(this._options.parentElement),this.subscriptions.add((0,T.fromEvent)(this.rootElement,"mousedown").subscribe(s=>s.stopPropagation())).add((0,T.fromEvent)(this.rootElement,"mouseup").subscribe(s=>s.stopPropagation())),this.manifestController=new fe(this._options.loaders,s=>{let l=new V(1,3,s);this.emitErrorEvent(l)});let n=[];this._options.lastFrame&&n.push(()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}),n.push(()=>{let s=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(s)}),this.resizeManager=wa(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Ze({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(k.graph,{type:Pe.watchAgainClicked,chapterId:s}),this.events.watchAgainIsClicked$.next(s)},onError:s=>{let l=new V(1,2,{message:s});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,n;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:i}=e.payload;this.setChapter({chapterId:i}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((n=e.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:i}=e.payload;i&&this.setManifest(i)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=en(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(i){let o=i.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(k.interactives,{type:N.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,T.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,T.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var a;let i;if(n)i=!0;else{let c=e*1e3;i=!!t.find(({range:[f,v],subjects:C})=>f<c&&c<v&&C.some(w=>!w.isRemoved)&&C.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let o=!!this.noInteractionTimeout,l=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!o&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,n;(t=this.lastFrame)==null||t.hide(),(n=this.lastFrame)==null||n.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,n;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),(n=this.interactiveEvents)==null||n.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(i=>i.container.container).filter(i=>!me(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{var l;let i=n.type.trim().toLowerCase(),o=this.factories.get(i),s=o==null?void 0:o(n,this.rootElement,{features:{controlsExpectTimeBlinkAnimation:(l=this._options.animationsFeatureToggles)==null?void 0:l.controlsExpectTimeBlinkAnimation}});if(s&&this.selectBranches&&this.interactiveEvents&&this.player){let a=new zt({player:this.player,container:s,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>rs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent});this.animation.addFn(a.whilePlaying,!0),t.push(a)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(l=n&&Q(n)&&ot(n))!=null?l:!1,o=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,s=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,Da.default)(s,-1)!==e&&this.historyController.updateHistory([...s,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(s=>{let l=s.subjects.some(c=>c.id===e),a=s.subjects.map(c=>t&&l||c.id===e?{...c,isRemoved:!0}:c);return{...s,subjects:a}});n.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var n,i;if(!((n=this._options.animationsFeatureToggles)!=null&&n.controlsExpectTimeBlinkAnimation))return;let t=(o,s)=>{o.toggleBlinkAnimation(s)};Ut({...e,gameControllers:this.gameControllers,execFn:at(tn(t),e.isExpect)}),e.isExpect&&((i=this.blinkAnimationRef)==null||i.restart())}updateControlsShadowStyles(e){var n;if(!((n=this._options.animationsFeatureToggles)!=null&&n.areaControlShadow))return;let t=(i,o)=>{i.updateControlsShadowStyles(o)};e.isExpect?Ut({...e,gameControllers:this.gameControllers,execFn:at(tn(t),!1)}):Ut({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(k.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=xa(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Na({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Ha.clientChecker.browser.isSafari&&await Fa(35);let i=!n&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:o,media:s,graph:l}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!s)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:s}),this.globalEventEmitter.emit(k.chapterChanged,{chapter:o,media:s,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new T.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ne.InteractiveInterfaceClick.GRAPH_SHOW:Ne.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ne.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ne.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ne.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new T.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(k.graph,{type:Pe.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===g.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&de(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,g.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return Bs((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,n,i,o,s;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(n=this.seamlessController)==null||n.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Ua={Container:Ee,createChoiceContainer:St,createAreaControl:Et,createButtonControl:xt,classnamesPrefix:Tn};var uh={version:In};