@vkontakte/videoplayer-interactive 1.0.33-dev.2a01fae8.0 → 1.0.33-dev.2d205106.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 (31) hide show
  1. package/es2015.cjs.js +15 -105
  2. package/es2015.esm.js +15 -105
  3. package/es2018.cjs.js +15 -105
  4. package/es2018.esm.js +15 -105
  5. package/esnext.cjs.js +15 -105
  6. package/esnext.esm.js +15 -105
  7. package/evergreen.esm.js +15 -105
  8. package/package.json +5 -5
  9. package/types/modules/Interactives/Interactives.d.ts +2 -6
  10. package/types/modules/Interactives/containers/ChoiceContainer.d.ts +0 -4
  11. package/types/modules/Interactives/containers/Container.d.ts +1 -1
  12. package/types/modules/Interactives/containers/types.d.ts +1 -1
  13. package/types/modules/Interactives/controls/AreaControl.d.ts +0 -7
  14. package/types/modules/Interactives/controls/ButtonControl.d.ts +0 -7
  15. package/types/modules/Interactives/controls/Control.d.ts +2 -7
  16. package/types/modules/Interactives/controls/TextControl.d.ts +1 -5
  17. package/types/modules/Interactives/controls/types.d.ts +1 -1
  18. package/types/modules/Interactives/controls/utils.d.ts +0 -4
  19. package/types/modules/Interactives/index.d.ts +6 -20
  20. package/types/modules/Interactives/types.d.ts +2 -5
  21. package/types/modules/Interactives/utils/GameController.d.ts +0 -3
  22. package/types/modules/Interactives/utils/SelectBranches.types.d.ts +1 -0
  23. package/types/modules/Interactives/utils/gameUtils.d.ts +2 -13
  24. package/types/modules/Interactives/utils/renderingUtils.d.ts +1 -15
  25. package/types/utils/getVideoContentSize.d.ts +1 -1
  26. package/types/utils/typeCheck.d.ts +2 -2
  27. package/types/modules/Interactives/utils/blinkAnimationReference.d.ts +0 -8
  28. package/types/modules/Interactives/utils/functionUtils.d.ts +0 -5
  29. package/types/utils/FrameAverageColor/FrameAverageColor.d.ts +0 -19
  30. package/types/utils/FrameAverageColor/helpers.d.ts +0 -17
  31. package/types/utils/FrameAverageColor/index.d.ts +0 -2
package/es2015.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.33-dev.2a01fae8.0
3
- * Mon, 03 Mar 2025 14:31:46 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.33-dev.2d205106.0
3
+ * Wed, 05 Mar 2025 07:04:22 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-33/doc/
5
5
  */
6
- "use strict";var sl=Object.create;var _e=Object.defineProperty,al=Object.defineProperties,ll=Object.getOwnPropertyDescriptor,cl=Object.getOwnPropertyDescriptors,ul=Object.getOwnPropertyNames,vt=Object.getOwnPropertySymbols,pl=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var wn=r=>{throw TypeError(r)};var Sn=(r,e,t)=>e in r?_e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))ir.call(e,t)&&Sn(r,t,e[t]);if(vt)for(var t of vt(e))An.call(e,t)&&Sn(r,t,e[t]);return r},T=(r,e)=>al(r,cl(e));var te=(r,e)=>{var t={};for(var n in r)ir.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&vt)for(var n of vt(r))e.indexOf(n)<0&&An.call(r,n)&&(t[n]=r[n]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),hl=(r,e)=>{for(var t in e)_e(r,t,{get:e[t],enumerable:!0})},Rn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ul(e))!ir.call(r,i)&&i!==t&&_e(r,i,{get:()=>e[i],enumerable:!(n=ll(e,i))||n.enumerable});return r};var X=(r,e,t)=>(t=r!=null?sl(pl(r)):{},Rn(e||!r||!r.__esModule?_e(t,"default",{value:r,enumerable:!0}):t,r)),dl=r=>Rn(_e({},"__esModule",{value:!0}),r);var On=(r,e,t)=>e.has(r)||wn("Cannot "+t);var k=(r,e,t)=>(On(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?wn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),B=(r,e,t,n)=>(On(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var kn=(r,e,t,n)=>({set _(i){B(r,e,i,t)},get _(){return k(r,e,n)}});var V=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{a(t.next(s))}catch(c){i(c)}},l=s=>{try{a(t.throw(s))}catch(c){i(c)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,l);a((t=t.apply(r,e)).next())});var ne=p((fr,Un)=>{"use strict";var He=function(r){return r&&r.Math===Math&&r};Un.exports=He(typeof globalThis=="object"&&globalThis)||He(typeof window=="object"&&window)||He(typeof self=="object"&&self)||He(typeof global=="object"&&global)||He(typeof fr=="object"&&fr)||function(){return this}()||Function("return this")()});var z=p((_d,Gn)=>{"use strict";Gn.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ue=p((Bd,zn)=>{"use strict";var ml=z();zn.exports=!ml(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Yn=p((qd,Xn)=>{"use strict";var fl=Ue(),Qn=Function.prototype,Wn=Qn.apply,Kn=Qn.call;Xn.exports=typeof Reflect=="object"&&Reflect.apply||(fl?Kn.bind(Wn):function(){return Kn.apply(Wn,arguments)})});var Y=p((Dd,ei)=>{"use strict";var Zn=Ue(),Jn=Function.prototype,vr=Jn.call,vl=Zn&&Jn.bind.bind(vr,vr);ei.exports=Zn?vl:function(r){return function(){return vr.apply(r,arguments)}}});var Ge=p((Hd,ri)=>{"use strict";var ti=Y(),yl=ti({}.toString),bl=ti("".slice);ri.exports=function(r){return bl(yl(r),8,-1)}});var yr=p((Ud,ni)=>{"use strict";var Cl=Ge(),gl=Y();ni.exports=function(r){if(Cl(r)==="Function")return gl(r)}});var W=p((Gd,ii)=>{"use strict";var br=typeof document=="object"&&document.all;ii.exports=typeof br=="undefined"&&br!==void 0?function(r){return typeof r=="function"||r===br}:function(r){return typeof r=="function"}});var ye=p((zd,oi)=>{"use strict";var El=z();oi.exports=!El(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var kt=p((Wd,si)=>{"use strict";var xl=Ue(),Ot=Function.prototype.call;si.exports=xl?Ot.bind(Ot):function(){return Ot.apply(Ot,arguments)}});var Cr=p(ci=>{"use strict";var ai={}.propertyIsEnumerable,li=Object.getOwnPropertyDescriptor,Il=li&&!ai.call({1:2},1);ci.f=Il?function(e){var t=li(this,e);return!!t&&t.enumerable}:ai});var gr=p((Qd,ui)=>{"use strict";ui.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var hi=p((Xd,pi)=>{"use strict";var Tl=Y(),Sl=z(),Al=Ge(),Er=Object,wl=Tl("".split);pi.exports=Sl(function(){return!Er("z").propertyIsEnumerable(0)})?function(r){return Al(r)==="String"?wl(r,""):Er(r)}:Er});var xr=p((Yd,di)=>{"use strict";di.exports=function(r){return r==null}});var Ir=p((Zd,mi)=>{"use strict";var Rl=xr(),Ol=TypeError;mi.exports=function(r){if(Rl(r))throw new Ol("Can't call method on "+r);return r}});var ze=p((Jd,fi)=>{"use strict";var kl=hi(),Pl=Ir();fi.exports=function(r){return kl(Pl(r))}});var Re=p((em,vi)=>{"use strict";var Vl=W();vi.exports=function(r){return typeof r=="object"?r!==null:Vl(r)}});var Pt=p((tm,yi)=>{"use strict";yi.exports={}});var Vt=p((rm,Ci)=>{"use strict";var Tr=Pt(),Sr=ne(),$l=W(),bi=function(r){return $l(r)?r:void 0};Ci.exports=function(r,e){return arguments.length<2?bi(Tr[r])||bi(Sr[r]):Tr[r]&&Tr[r][e]||Sr[r]&&Sr[r][e]}});var Ei=p((nm,gi)=>{"use strict";var Ml=Y();gi.exports=Ml({}.isPrototypeOf)});var Si=p((im,Ti)=>{"use strict";var Ll=ne(),xi=Ll.navigator,Ii=xi&&xi.userAgent;Ti.exports=Ii?String(Ii):""});var Vi=p((om,Pi)=>{"use strict";var ki=ne(),Ar=Si(),Ai=ki.process,wi=ki.Deno,Ri=Ai&&Ai.versions||wi&&wi.version,Oi=Ri&&Ri.v8,Z,$t;Oi&&(Z=Oi.split("."),$t=Z[0]>0&&Z[0]<4?1:+(Z[0]+Z[1]));!$t&&Ar&&(Z=Ar.match(/Edge\/(\d+)/),(!Z||Z[1]>=74)&&(Z=Ar.match(/Chrome\/(\d+)/),Z&&($t=+Z[1])));Pi.exports=$t});var wr=p((sm,Mi)=>{"use strict";var $i=Vi(),Nl=z(),Fl=ne(),jl=Fl.String;Mi.exports=!!Object.getOwnPropertySymbols&&!Nl(function(){var r=Symbol("symbol detection");return!jl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&$i&&$i<41})});var Rr=p((am,Li)=>{"use strict";var _l=wr();Li.exports=_l&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Or=p((lm,Ni)=>{"use strict";var Bl=Vt(),ql=W(),Dl=Ei(),Hl=Rr(),Ul=Object;Ni.exports=Hl?function(r){return typeof r=="symbol"}:function(r){var e=Bl("Symbol");return ql(e)&&Dl(e.prototype,Ul(r))}});var ji=p((cm,Fi)=>{"use strict";var Gl=String;Fi.exports=function(r){try{return Gl(r)}catch(e){return"Object"}}});var kr=p((um,_i)=>{"use strict";var zl=W(),Wl=ji(),Kl=TypeError;_i.exports=function(r){if(zl(r))return r;throw new Kl(Wl(r)+" is not a function")}});var qi=p((pm,Bi)=>{"use strict";var Ql=kr(),Xl=xr();Bi.exports=function(r,e){var t=r[e];return Xl(t)?void 0:Ql(t)}});var Hi=p((hm,Di)=>{"use strict";var Pr=kt(),Vr=W(),$r=Re(),Yl=TypeError;Di.exports=function(r,e){var t,n;if(e==="string"&&Vr(t=r.toString)&&!$r(n=Pr(t,r))||Vr(t=r.valueOf)&&!$r(n=Pr(t,r))||e!=="string"&&Vr(t=r.toString)&&!$r(n=Pr(t,r)))return n;throw new Yl("Can't convert object to primitive value")}});var Gi=p((dm,Ui)=>{"use strict";Ui.exports=!0});var Ki=p((mm,Wi)=>{"use strict";var zi=ne(),Zl=Object.defineProperty;Wi.exports=function(r,e){try{Zl(zi,r,{value:e,configurable:!0,writable:!0})}catch(t){zi[r]=e}return e}});var Mt=p((fm,Yi)=>{"use strict";var Jl=Gi(),ec=ne(),tc=Ki(),Qi="__core-js_shared__",Xi=Yi.exports=ec[Qi]||tc(Qi,{});(Xi.versions||(Xi.versions=[])).push({version:"3.38.0",mode:Jl?"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=p((vm,Ji)=>{"use strict";var Zi=Mt();Ji.exports=function(r,e){return Zi[r]||(Zi[r]=e||{})}});var We=p((ym,eo)=>{"use strict";var rc=Ir(),nc=Object;eo.exports=function(r){return nc(rc(r))}});var Oe=p((bm,to)=>{"use strict";var ic=Y(),oc=We(),sc=ic({}.hasOwnProperty);to.exports=Object.hasOwn||function(e,t){return sc(oc(e),t)}});var Lr=p((Cm,ro)=>{"use strict";var ac=Y(),lc=0,cc=Math.random(),uc=ac(1 .toString);ro.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+uc(++lc+cc,36)}});var Ke=p((gm,io)=>{"use strict";var pc=ne(),hc=Mr(),no=Oe(),dc=Lr(),mc=wr(),fc=Rr(),ke=pc.Symbol,Nr=hc("wks"),vc=fc?ke.for||ke:ke&&ke.withoutSetter||dc;io.exports=function(r){return no(Nr,r)||(Nr[r]=mc&&no(ke,r)?ke[r]:vc("Symbol."+r)),Nr[r]}});var lo=p((Em,ao)=>{"use strict";var yc=kt(),oo=Re(),so=Or(),bc=qi(),Cc=Hi(),gc=Ke(),Ec=TypeError,xc=gc("toPrimitive");ao.exports=function(r,e){if(!oo(r)||so(r))return r;var t=bc(r,xc),n;if(t){if(e===void 0&&(e="default"),n=yc(t,r,e),!oo(n)||so(n))return n;throw new Ec("Can't convert object to primitive value")}return e===void 0&&(e="number"),Cc(r,e)}});var Fr=p((xm,co)=>{"use strict";var Ic=lo(),Tc=Or();co.exports=function(r){var e=Ic(r,"string");return Tc(e)?e:e+""}});var ho=p((Im,po)=>{"use strict";var Sc=ne(),uo=Re(),jr=Sc.document,Ac=uo(jr)&&uo(jr.createElement);po.exports=function(r){return Ac?jr.createElement(r):{}}});var _r=p((Tm,mo)=>{"use strict";var wc=ye(),Rc=z(),Oc=ho();mo.exports=!wc&&!Rc(function(){return Object.defineProperty(Oc("div"),"a",{get:function(){return 7}}).a!==7})});var yo=p(vo=>{"use strict";var kc=ye(),Pc=kt(),Vc=Cr(),$c=gr(),Mc=ze(),Lc=Fr(),Nc=Oe(),Fc=_r(),fo=Object.getOwnPropertyDescriptor;vo.f=kc?fo:function(e,t){if(e=Mc(e),t=Lc(t),Fc)try{return fo(e,t)}catch(n){}if(Nc(e,t))return $c(!Pc(Vc.f,e,t),e[t])}});var Co=p((Am,bo)=>{"use strict";var jc=z(),_c=W(),Bc=/#|\.prototype\./,Qe=function(r,e){var t=Dc[qc(r)];return t===Uc?!0:t===Hc?!1:_c(e)?jc(e):!!e},qc=Qe.normalize=function(r){return String(r).replace(Bc,".").toLowerCase()},Dc=Qe.data={},Hc=Qe.NATIVE="N",Uc=Qe.POLYFILL="P";bo.exports=Qe});var Br=p((wm,Eo)=>{"use strict";var go=yr(),Gc=kr(),zc=Ue(),Wc=go(go.bind);Eo.exports=function(r,e){return Gc(r),e===void 0?r:zc?Wc(r,e):function(){return r.apply(e,arguments)}}});var Io=p((Rm,xo)=>{"use strict";var Kc=ye(),Qc=z();xo.exports=Kc&&Qc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var So=p((Om,To)=>{"use strict";var Xc=Re(),Yc=String,Zc=TypeError;To.exports=function(r){if(Xc(r))return r;throw new Zc(Yc(r)+" is not an object")}});var Ro=p(wo=>{"use strict";var Jc=ye(),eu=_r(),tu=Io(),Lt=So(),Ao=Fr(),ru=TypeError,qr=Object.defineProperty,nu=Object.getOwnPropertyDescriptor,Dr="enumerable",Hr="configurable",Ur="writable";wo.f=Jc?tu?function(e,t,n){if(Lt(e),t=Ao(t),Lt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Ur in n&&!n[Ur]){var i=nu(e,t);i&&i[Ur]&&(e[t]=n.value,n={configurable:Hr in n?n[Hr]:i[Hr],enumerable:Dr in n?n[Dr]:i[Dr],writable:!1})}return qr(e,t,n)}:qr:function(e,t,n){if(Lt(e),t=Ao(t),Lt(n),eu)try{return qr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new ru("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var ko=p((Pm,Oo)=>{"use strict";var iu=ye(),ou=Ro(),su=gr();Oo.exports=iu?function(r,e,t){return ou.f(r,e,su(1,t))}:function(r,e,t){return r[e]=t,r}});var Ye=p((Vm,Vo)=>{"use strict";var Xe=ne(),au=Yn(),lu=yr(),cu=W(),uu=yo().f,pu=Co(),Pe=Pt(),hu=Br(),Ve=ko(),Po=Oe();Mt();var du=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 au(r,this,arguments)};return e.prototype=r.prototype,e};Vo.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,l=n?Xe:i?Xe[t]:Xe[t]&&Xe[t].prototype,a=n?Pe:Pe[t]||Ve(Pe,t,{})[t],s=a.prototype,c,m,v,b,g,R,I,f,O;for(b in e)c=pu(n?b:t+(i?".":"#")+b,r.forced),m=!c&&l&&Po(l,b),R=a[b],m&&(r.dontCallGetSet?(O=uu(l,b),I=O&&O.value):I=l[b]),g=m&&I?I:e[b],!(!c&&!o&&typeof R==typeof g)&&(r.bind&&m?f=hu(g,Xe):r.wrap&&m?f=du(g):o&&cu(g)?f=lu(g):f=g,(r.sham||g&&g.sham||R&&R.sham)&&Ve(f,"sham",!0),Ve(a,b,f),o&&(v=t+"Prototype",Po(Pe,v)||Ve(Pe,v,{}),Ve(Pe[v],b,g),r.real&&s&&(c||!s[b])&&Ve(s,b,g)))}});var Mo=p(($m,$o)=>{"use strict";var mu=Math.ceil,fu=Math.floor;$o.exports=Math.trunc||function(e){var t=+e;return(t>0?fu:mu)(t)}});var Ze=p((Mm,Lo)=>{"use strict";var vu=Mo();Lo.exports=function(r){var e=+r;return e!==e||e===0?0:vu(e)}});var Fo=p((Lm,No)=>{"use strict";var yu=Ze(),bu=Math.min;No.exports=function(r){var e=yu(r);return e>0?bu(e,9007199254740991):0}});var Je=p((Nm,jo)=>{"use strict";var Cu=Fo();jo.exports=function(r){return Cu(r.length)}});var Nt=p((Fm,_o)=>{"use strict";_o.exports=function(){}});var Bo=p(()=>{"use strict";var gu=Ye(),Eu=We(),xu=Je(),Iu=Ze(),Tu=Nt();gu({target:"Array",proto:!0},{at:function(e){var t=Eu(this),n=xu(t),i=Iu(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Tu("at")});var Ft=p((Bm,qo)=>{"use strict";var Su=Vt();qo.exports=Su});var Ho=p((qm,Do)=>{"use strict";Bo();var Au=Ft();Do.exports=Au("Array","at")});var Go=p((Dm,Uo)=>{"use strict";var wu=Ho();Uo.exports=wu});var Gr=p((Hm,zo)=>{"use strict";var Ru=Go();zo.exports=Ru});var ts=p((Ff,es)=>{"use strict";var Bu=Ze(),qu=Math.max,Du=Math.min;es.exports=function(r,e){var t=Bu(r);return t<0?qu(t+e,0):Du(t,e)}});var Zr=p((jf,ns)=>{"use strict";var Hu=ze(),Uu=ts(),Gu=Je(),rs=function(r){return function(e,t,n){var i=Hu(e),o=Gu(i);if(o===0)return!r&&-1;var l=Uu(n,o),a;if(r&&t!==t){for(;o>l;)if(a=i[l++],a!==a)return!0}else for(;o>l;l++)if((r||l in i)&&i[l]===t)return r||l||0;return!r&&-1}};ns.exports={includes:rs(!0),indexOf:rs(!1)}});var is=p(()=>{"use strict";var zu=Ye(),Wu=Zr().includes,Ku=z(),Qu=Nt(),Xu=Ku(function(){return!Array(1).includes()});zu({target:"Array",proto:!0,forced:Xu},{includes:function(e){return Wu(this,e,arguments.length>1?arguments[1]:void 0)}});Qu("includes")});var ss=p((qf,os)=>{"use strict";is();var Yu=Ft();os.exports=Yu("Array","includes")});var ls=p((Df,as)=>{"use strict";var Zu=ss();as.exports=Zu});var at=p((Hf,cs)=>{"use strict";var Ju=ls();cs.exports=Ju});var ys=p((ev,vs)=>{"use strict";var tp=Mr(),rp=Lr(),fs=tp("keys");vs.exports=function(r){return fs[r]||(fs[r]=rp(r))}});var Cs=p((tv,bs)=>{"use strict";var np=z();bs.exports=!np(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var xs=p((rv,Es)=>{"use strict";var ip=Oe(),op=W(),sp=We(),ap=ys(),lp=Cs(),gs=ap("IE_PROTO"),tn=Object,cp=tn.prototype;Es.exports=lp?tn.getPrototypeOf:function(r){var e=sp(r);if(ip(e,gs))return e[gs];var t=e.constructor;return op(t)&&e instanceof t?t.prototype:e instanceof tn?cp:null}});var Ts=p((nv,Is)=>{"use strict";Is.exports={}});var ws=p((iv,As)=>{"use strict";var up=Y(),rn=Oe(),pp=ze(),hp=Zr().indexOf,dp=Ts(),Ss=up([].push);As.exports=function(r,e){var t=pp(r),n=0,i=[],o;for(o in t)!rn(dp,o)&&rn(t,o)&&Ss(i,o);for(;e.length>n;)rn(t,o=e[n++])&&(~hp(i,o)||Ss(i,o));return i}});var Os=p((ov,Rs)=>{"use strict";Rs.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ps=p((sv,ks)=>{"use strict";var mp=ws(),fp=Os();ks.exports=Object.keys||function(e){return mp(e,fp)}});var Fs=p((av,Ns)=>{"use strict";var $s=ye(),vp=z(),Ms=Y(),yp=xs(),bp=Ps(),Cp=ze(),gp=Cr().f,Ls=Ms(gp),Ep=Ms([].push),xp=$s&&vp(function(){var r=Object.create(null);return r[2]=2,!Ls(r,2)}),Vs=function(r){return function(e){for(var t=Cp(e),n=bp(t),i=xp&&yp(t)===null,o=n.length,l=0,a=[],s;o>l;)s=n[l++],(!$s||(i?s in t:Ls(t,s)))&&Ep(a,r?[s,t[s]]:t[s]);return a}};Ns.exports={entries:Vs(!0),values:Vs(!1)}});var js=p(()=>{"use strict";var Ip=Ye(),Tp=Fs().values;Ip({target:"Object",stat:!0},{values:function(e){return Tp(e)}})});var Bs=p((uv,_s)=>{"use strict";js();var Sp=Pt();_s.exports=Sp.Object.values});var Ds=p((pv,qs)=>{"use strict";var Ap=Bs();qs.exports=Ap});var Kt=p((hv,Hs)=>{"use strict";var wp=Ds();Hs.exports=wp});var ln=p((Nv,Zs)=>{"use strict";var Op=Ge();Zs.exports=Array.isArray||function(e){return Op(e)==="Array"}});var ea=p((Fv,Js)=>{"use strict";var kp=TypeError,Pp=9007199254740991;Js.exports=function(r){if(r>Pp)throw kp("Maximum allowed index exceeded");return r}});var na=p((jv,ra)=>{"use strict";var Vp=ln(),$p=Je(),Mp=ea(),Lp=Br(),ta=function(r,e,t,n,i,o,l,a){for(var s=i,c=0,m=l?Lp(l,a):!1,v,b;c<n;)c in t&&(v=m?m(t[c],c,e):t[c],o>0&&Vp(v)?(b=$p(v),s=ta(r,e,v,b,s,o-1)-1):(Mp(s+1),r[s]=v),s++),c++;return s};ra.exports=ta});var sa=p((_v,oa)=>{"use strict";var Np=Ke(),Fp=Np("toStringTag"),ia={};ia[Fp]="z";oa.exports=String(ia)==="[object z]"});var la=p((Bv,aa)=>{"use strict";var jp=sa(),_p=W(),Xt=Ge(),Bp=Ke(),qp=Bp("toStringTag"),Dp=Object,Hp=Xt(function(){return arguments}())==="Arguments",Up=function(r,e){try{return r[e]}catch(t){}};aa.exports=jp?Xt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Up(e=Dp(r),qp))=="string"?t:Hp?Xt(e):(n=Xt(e))==="Object"&&_p(e.callee)?"Arguments":n}});var ua=p((qv,ca)=>{"use strict";var Gp=Y(),zp=W(),cn=Mt(),Wp=Gp(Function.toString);zp(cn.inspectSource)||(cn.inspectSource=function(r){return Wp(r)});ca.exports=cn.inspectSource});var va=p((Dv,fa)=>{"use strict";var Kp=Y(),Qp=z(),pa=W(),Xp=la(),Yp=Vt(),Zp=ua(),ha=function(){},da=Yp("Reflect","construct"),un=/^\s*(?:class|function)\b/,Jp=Kp(un.exec),eh=!un.test(ha),pt=function(e){if(!pa(e))return!1;try{return da(ha,[],e),!0}catch(t){return!1}},ma=function(e){if(!pa(e))return!1;switch(Xp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return eh||!!Jp(un,Zp(e))}catch(t){return!0}};ma.sham=!0;fa.exports=!da||Qp(function(){var r;return pt(pt.call)||!pt(Object)||!pt(function(){r=!0})||r})?ma:pt});var ga=p((Hv,Ca)=>{"use strict";var ya=ln(),th=va(),rh=Re(),nh=Ke(),ih=nh("species"),ba=Array;Ca.exports=function(r){var e;return ya(r)&&(e=r.constructor,th(e)&&(e===ba||ya(e.prototype))?e=void 0:rh(e)&&(e=e[ih],e===null&&(e=void 0))),e===void 0?ba:e}});var xa=p((Uv,Ea)=>{"use strict";var oh=ga();Ea.exports=function(r,e){return new(oh(r))(e===0?0:e)}});var Ia=p(()=>{"use strict";var sh=Ye(),ah=na(),lh=We(),ch=Je(),uh=Ze(),ph=xa();sh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=lh(this),n=ch(t),i=ph(t,0);return i.length=ah(i,t,t,n,0,e===void 0?1:uh(e)),i}})});var Ta=p(()=>{"use strict";var hh=Nt();hh("flat")});var Aa=p((Qv,Sa)=>{"use strict";Ia();Ta();var dh=Ft();Sa.exports=dh("Array","flat")});var Ra=p((Xv,wa)=>{"use strict";var mh=Aa();wa.exports=mh});var ka=p((Yv,Oa)=>{"use strict";var fh=Ra();Oa.exports=fh});var Ph={};hl(Ph,{ContainerTypes:()=>x.ContainerTypes,ControlTypes:()=>x.ControlTypes,CustomError:()=>D,EVENT_NAMES:()=>M,EventActionTypes:()=>x.EventActionTypes,EventTypes:()=>x.EventTypes,Interactives:()=>mt,ManifestController:()=>ge,SDKInfo:()=>kh,chapterIdsToVKVideoIds:()=>Zt,compareVersions:()=>Ut,containerTypes:()=>Vu,controlTypes:()=>$u,eventActionTypes:()=>Wr,eventTypes:()=>Mu,getChapterIdByVkVideoId:()=>Xa,getVKVideoIdByMedia:()=>dn,getVideoRawIdByMedia:()=>Ka,graphEventTypes:()=>Le,hasEndTemplate:()=>lt,interactivesEventTypes:()=>F,isAreaControl:()=>Pu,isButtonControl:()=>ku,isLastChapter:()=>J,isOneTextCtrlContainer:()=>Ce,isSupportedManifest:()=>x.isSupportedManifest,isTextControl:()=>nt,isVKVariantItem:()=>Qa,isValidManifest:()=>zr,migrateManifestToLatestVersion:()=>x.migrateManifestToLatestVersion,utils:()=>il,vkVideoIdsToChapterIds:()=>mn});module.exports=dl(Ph);var Pn="1.0.33-dev.2a01fae8.0";var or=class{constructor(e){this.layout=e}},yt=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))`}};function Vn(r){return"features"in r}var Ae=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Vn(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 l=o(n,this.options);if(l)return[...t,l]}return[...t]},[]))||[]}};var fe=require("@vkontakte/videoplayer-shared/es2015");function Be(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 $n="interactive",q={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},Mn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Mn||{}),Ln=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Ln||{}),Nn=(n=>(n.start="left",n.end="right",n.center="center",n))(Nn||{}),bt=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Mn[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&Ln[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&Nn[e.alignment])!=null?i:"center"},Ct=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,o,l,a,s,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} * ${(a=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?a:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},gt=({target:r,props:e,fallback:t})=>{var n,i,o,l;r.style.backgroundColor=Be((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(l=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?l:t.backgroundAlpha)},qe=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{var a,s,c,m,v,b,g,R,I,f,O;let o=i?t.borderWidthRawValue:`calc(${n.height} * ${(c=(s=(a=e==null?void 0:e.shape)==null?void 0:a.border)==null?void 0:s.width)!=null?c:t.borderWidth})`,l=i?t.roundCornersRawValue:`calc(${n.height} * ${(v=(m=e==null?void 0:e.shape)==null?void 0:m.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Be(i?t.borderColor:(R=(g=(b=e==null?void 0:e.shape)==null?void 0:b.border)==null?void 0:g.color)!=null?R:t.borderColor,i?t.borderAlpha:(O=(f=(I=e==null?void 0:e.shape)==null?void 0:I.border)==null?void 0:f.alpha)!=null?O:t.borderAlpha),r.style.borderRadius=l},Fn=({target:r,frameToneIsDark:e,baseDimension:t,fallback:n})=>{let l=Be(n.shadowColorLight,n.shadowColorAlpha),a=Be(n.shadowColorDark,n.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,m=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=m},we=({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 Et=require("@vkontakte/videoplayer-shared/es2015");var sr="int",de=(n=>(n.AREA=`${sr}_area`,n.TEXT=`${sr}_text`,n.BUTTON=`${sr}_bttn`,n))(de||{});function jn(r){return"features"in r}var re="interactive-control",E={common:re,selected:`${re}-selected`,wrapper:`${re}-wrapper`,disabled:`${re}-disabled`,button:`${re}-button`,area:`${re}-area`,text:`${re}-text`,blinkAnim:`${re}-blink-anim`,blinkAnimButton:`${re}-blink-anim-button`,blinkAnimArea:`${re}-blink-anim-area`};var le=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Et.Subscription}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(E.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:q.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&jn(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,Et.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type}))));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var ce=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ue=r=>ce(r,"Object"),xt=r=>ce(r,"String"),It=r=>ce(r,"Array"),Tt=r=>ce(r,"Number"),_n=r=>ce(r,"Function"),Bn=r=>ce(r,"Boolean"),ar=r=>Tt(r)&&!isNaN(r);var me=r=>ue(r)&&Object.keys(r).length===0,lr=r=>It(r)&&!r.length;var De=(r,e)=>xt(r)&&(e?r.trim():r).length;var cr="interactive-blink-anim-reference",j={common:cr,animation:`${cr}-animation`,disabled:`${cr}-disabled`},qn=()=>{let r=document.createElement("div");return r.classList.add(j.common,j.animation),r},Dn=r=>{r.classList.add(j.disabled),requestAnimationFrame(()=>{r.classList.remove(j.disabled)})};var ur="interactive-container",L={common:ur,hidden:`${ur}-hidden`,disabled:`${ur}-disabled`};var St=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new pr(r,e)},pr=class extends le{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(E.common,E.area),n.setAttribute("data-testid",de.AREA),gt({target:n,props:this.control.props,fallback:T(d({},q),{backgroundColor:"transparent"})}),we({target:n,layoutParams:this.control.layoutParams,fallback:q}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){var e;if(this.featureIsEnabled("controlsExpectTimeBlinkAnimation")){let t=(e=this.container)==null?void 0:e.element.parentElement;if(!t||!this.controlElement)return;this.subscriptions.add((0,fe.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(t.classList.contains(L.disabled))return;let n=t.parentElement;if(n){let i=n.querySelector(`.${j.common}`);i&&this.syncBlinkAnimation(i)}})),this.subscriptions.add((0,fe.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{t.classList.contains(L.disabled)||this.onBlinkHovering()})).add((0,fe.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")}))}}disable(){this.controlElement&&this.controlElement.classList.add(E.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(E.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,n,i;if(!(!this.container||!this.controlElement))if(Bn(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Fn({target:this.controlElement,props:this.control.props,fallback:q,frameToneIsDark:e,baseDimension:o}),qe({target:this.controlElement,props:this.control.props,fallback:T(d({},q),{borderColor:e?"#fff":"#000",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:q.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else qe({target:this.controlElement,props:this.control.props,fallback:T(d({},q),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(E.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(E.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${E.blinkAnimArea}`)||this.controlElement.classList.contains(E.selected)||this.controlElement.classList.contains(j.disabled)||(this.controlElement.classList.add(j.disabled),this.subscriptions.add((0,fe.fromEvent)(e,"animationiteration").pipe((0,fe.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(j.disabled)}))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${E.blinkAnimArea}`)||this.controlElement.classList.contains(E.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)})}onProgress(){}onResize(){}};var ve=require("@vkontakte/videoplayer-shared/es2015");var At=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 wt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new hr(r,e)},hr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(E.common,E.button),n.setAttribute("data-testid",de.BUTTON),we({target:n,layoutParams:this.control.layoutParams,fallback:q}),gt({target:n,props:this.control.props,fallback:q}),qe({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),bt({target:n,props:T(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=At(this.control.type.trim().toLowerCase()),o=(l=i.firstElementChild)!=null?l:i;Ct({target:o,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){var e;if(this.featureIsEnabled("controlsExpectTimeBlinkAnimation")){let t=(e=this.container)==null?void 0:e.element.parentElement;if(!t||!this.controlElement)return;this.subscriptions.add((0,ve.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(t.classList.contains(L.disabled))return;let n=t.parentElement;if(n){let i=n.querySelector(`.${j.common}`);i&&this.syncBlinkAnimation(i)}})),this.subscriptions.add((0,ve.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{t.classList.contains(L.disabled)||this.onBlinkHovering()})).add((0,ve.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")}))}}disable(){this.controlElement&&this.controlElement.classList.add(E.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(E.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(E.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(E.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${E.blinkAnimButton}`)||this.controlElement.classList.contains(E.selected)||this.controlElement.classList.contains(j.disabled)||(this.controlElement.classList.add(j.disabled),this.subscriptions.add((0,ve.fromEvent)(e,"animationiteration").pipe((0,ve.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(j.disabled)}))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${E.blinkAnimButton}`)||this.controlElement.classList.contains(E.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)})}onProgress(){}onResize(){}updateShadowStyles(){}};var Hn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new dr(r,e)},dr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(E.common,E.text),n.setAttribute("data-testid",de.TEXT),we({target:n,layoutParams:this.control.layoutParams,fallback:q}),bt({target:n,props:T(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=At(this.control.type.trim().toLowerCase()),o=(l=i.firstElementChild)!=null?l:i;Ct({target:o,props:this.control.props,fallback:q,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(){}};var Rt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new mr(r,e,t)},mr=class extends Ae{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new yt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",wt),this.addControlFactory("text",Hn),this.addControlFactory("area",St)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(L.common,L.disabled),requestAnimationFrame(()=>{n.classList.remove(L.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(L.hidden)}show(){let t=this.getElement();t&&t.classList.remove(L.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(L.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(L.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(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 nl=X(Gr(),1),w=require("@vkontakte/videoplayer-shared/es2015"),je=require("@vkontakte/videoplayer-statistics/es2015");var Xo=require("@vkontakte/videoplayer-shared/es2015");function et(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var Wo="video_interactive",Ko="videoint";var Qo=250,tt=class{constructor(e){this.handleZoomChange=et(e=>{this.lastZoomInfo=e},Qo);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)),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,!Tt(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=Ou(e),this.resizeObserver=new ResizeObserver(et(this.onResize,Qo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return V(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return V(this,null,function*(){var n;if(!this.manifest)return;let e;try{e=yield(0,Xo.loadVKLangPack)(this.lang,Wo,Ko)}catch(i){(n=this.onError)==null||n.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",l=>{var a=l,{name:i}=a,o=te(a,["name"]);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 Ou(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var rt=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 l=o.startTime-e;if(l<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<l&&(t=t===-1?l:Math.min(t,l))}return!n&&t!==-1?t:null}}};var x=require("@interactiveplatform/movika-manifest");var Yo={metadata:"Object",chapters:"Array"},zr=r=>{if(!ue(r))return!1;for(let e in Yo)if(!r[e]||!ce(r[e],Yo[e]))return!1;return(0,x.isSupportedManifest)(r.metadata.version)},nt=r=>r.type===x.ControlTypes.Text,ku=r=>r.type===x.ControlTypes.Button,Pu=r=>r.type===x.ControlTypes.Area,Vu={Choice:"Choice",TextInput:"TextInput"},$u={Button:"Button",Area:"Area",Text:"Text"},Mu={onClick:"onClick",onSuspense:"onSuspense"},Wr={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var D=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var jt=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 _t=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{_n(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 ms=require("@vkontakte/videoplayer-shared/es2015");var Bt=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:[]}}exec(e,t){return V(this,null,function*(){return Lu(...this.loaders[e])(t)})}};function Lu(...r){return function(t){return V(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function it(r,e,t){return r?T(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function qt(i){var o=i,{actions:r,errors:e,chapterId:t}=o,n=te(o,["actions","errors","chapterId"]);if(t){let l=r.getManifest();if(l){let a=r.getChapter(l.chapters,t);if(a){let s=r.getMedia(l.media,a.videoId),c=r.getGraph(l.graph,a.id);return s?T(d({},n),{actions:r,errors:e,result:{chapter:a,media:s,graph:c}}):T(d({},n),{errors:it(e,qt.name,"Could not find media"),actions:r})}}}return T(d({},n),{errors:it(e,qt.name,"Could not find chapter"),actions:r})}var Dt=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 l=n[i];try{l.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},$e=class extends Dt{constructor(){super(),this.listeners||Dt.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 $e,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&&(ot.prototype[Symbol.toStringTag]="AbortController",$e.prototype[Symbol.toStringTag]="AbortSignal");function Ht(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 Kr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Ht({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 v;m&&m.signal&&(v=m.signal,delete m.signal);let b=new t(c,m);return v&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),b},o.prototype=t.prototype);let l=e;return{fetch:(s,c)=>{let m=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(m){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(m.aborted)return Promise.reject(v);let b=new Promise((g,R)=>{m.addEventListener("abort",()=>R(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,l(s,c)])}return l(s,c)},Request:o}}var st=Ht({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Zo=st?Kr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Qr=st?Zo.fetch:window.fetch,Af=st?Zo.Request:window.Request,wf=st?ot:window.AbortController,Rf=st?$e:window.AbortSignal;var Ut=(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 Nu=r=>V(void 0,null,function*(){try{let e={},t;if(xt(r)){t=new URL(r).href;let i=yield Qr(t);if(!i.ok)return{};e=yield i.json()}else if(ue(r))e=r;else return{};if(!zr(e))return{};let n=e.metadata.media;if(xt(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=yield Qr(i);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(i){return _u(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Jo(r){return V(this,null,function*(){let{manifest:e,manifestURL:t}=yield Nu(r);if(!e)throw new Error("Failed on fetch");let n=(0,x.migrateManifestToLatestVersion)(e);return n.media=Fu(n.media,t),delete n.metadata.media,n})}function Gt(r,e){if(e)return r.find(t=>t.id===e)}function Xr(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 Yr(r,e){return r.videos.find(t=>t.id===e)}function Fu(r,e){return T(d({},r),{videos:r.videos.map(t=>T(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=ju(i,e);return T(d({},n),{url:o||i})})}))})}function ju(r="",e){try{return new URL(r,e).href}catch(t){return""}}function _u(r){return Ut(r,"3.2.0")>=0}var us=X(at(),1);var zt=r=>It(r)&&!lr(r),J=r=>r.order==="end",lt=r=>It(r.containers)&&!lr(r.containers)&&J(r),ps=(r,e)=>{var n;let t=r*1e3;return zt(e.controls)&&t<((n=e.startTime)!=null?n:0)},Jr=(r,e)=>{var n,i;let t=r*1e3;return zt(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var be=(r=[])=>r.some(e=>e.action.type==="expect"),en=(r=[])=>r.find(e=>e.action.type==="expect"),ep=r=>(r==null?void 0:r.length)===1,Ce=r=>ep(r)&&nt(r[0]);function hs(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,us.default)(t,n.container.id)&&be(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Wt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),hs(r,i.container.container.endTime,[i.container.container.id]).forEach(l=>{n(l)});break}}var ds=(r,e)=>{let t=I=>{let f=e.find(({container:O})=>O.container.id===I);return f==null?void 0:f.container.isRemoved},n=be(r.events)&&!t(r.id),i=(I,f=!1,O=!1)=>{let h=O?"every":"some";return I.controls[h](u=>{var S;let y=f?I.endTime===r.endTime:!0;return((S=u.events)==null?void 0:S[h](A=>{var C;return((C=A.action)==null?void 0:C.type)===Wr.openURI}))&&y})},o=I=>I.some(({container:f})=>i(f.container,!0,!1)&&!f.isRemoved),l=I=>I.every(({container:f})=>f.isRemoved?!0:i(f.container,!0,!0)),a=hs(e,r.endTime,[r.id]).length,s=I=>I.controls.some(f=>{var O;return(O=f.events)==null?void 0:O.some(h=>{var u,y;return(y=(u=h.action)==null?void 0:u.args)==null?void 0:y.shouldOpenNow})}),c=n||a>0,m=o(e),v=i(r),b=l(e),g=n?!1:a>0,R=s(r);return{isExpectTime:c,hasOtherExpect:a>0,hasOpenURIEvent:m,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:R}};var ge=class extends Bt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ms.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}setManifest(t){return V(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:it},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield Jo((i=n.result)!=null?i:t),this})}setInitial(){return V(this,null,function*(){return this.setNext()})}setNext(){return V(this,arguments,function*(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=yield this.exec("chapterLoaders",qt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Xr,getChapter:Gt,getMedia:Yr,getByBranches:this.getByBranches.bind(this),addErrorMessage:it},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=Gt(this.manifest.chapters,t);if(i){let o=Yr(this.manifest.media,i.videoId),l=Xr(this.manifest.graph,i.id);if(o)return{chapter:i,media:o,graph:l}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,o,l;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let a=Gt(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(a==null?void 0:a.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?J(this.chapter):!1}};var zs=X(Kt(),1),Ws=require("@vkontakte/videoplayer-core/es2015"),pe=require("@vkontakte/videoplayer-shared/es2015");var Us=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 Gs=X(Kt(),1);function nn(){let r=new Map;function e(s){var c=s,{listId:o=Math.random().toString(),itemId:l=Math.random().toString()}=c,a=te(c,["listId","itemId"]);let m=r.get(o),v=d({},a);return m?m[l]=v:r.set(o,{[l]:v}),d({listId:o,itemId:l},a)}function t(o){var l,a;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(l=o.statistics)==null||l.oneStat.destroy(),(a=o.statistics)==null||a.statSubscription.unsubscribe()}function n(o,l){let a=r.get(o);if(!a)throw Error("Can't remove. Not find.");if(l){let s=a[l];s&&t(s),delete a[l],Object.keys(a).length||r.delete(o)}else{for(let s of(0,Gs.default)(a))t(s);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var Me=X(at(),1);function on(r,e=[]){var o,l,a;let t={},n,i=!e.length;for(let s of r.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(i||(0,Me.default)(e,"mp4"))&&(t.MPEG=T(d({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"mpeg":(i||(0,Me.default)(e,"mpeg"))&&(t.MPEG=T(d({},t.MPEG),{[(l=s.standard)!=null?l:"Invariant quality"]:s.url}));break;case"hls":(i||(0,Me.default)(e,"hls"))&&(t=T(d({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(i||(0,Me.default)(e,"dash"))&&(t=T(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(a=r.title)!=null?a:""}}var ct=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Me.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Rp=2;function sn(r){let e=nn(),t=new pe.Subscription,n={},i=null,o=!1,l,a=new pe.ValueSubject(null);r&&s(r);function s(f){i=f}function c(f,O,h){var S;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let y=((S=e.map.get(f))!=null?S:{})[O];if(y){n=d({chapterId:h,listId:f,itemId:O},y);let A=n.player;n.subscription.add(A.info.currentQuality$.subscribe(C=>{let P=A.info.position$.getValue(),H=A.info.isAutoQualityEnabled$.getValue();if(!(!C||!P||H))for(let $ of e.map)(0,zs.default)($[1]).forEach(({player:N})=>{ct(N,C)})})).add(A.events.started$.subscribe(()=>{m(O)})),y.container.remove(),i.setPlayer(y.player),o||(i.init(),o=!0),a.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function m(f){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(me(n)||f!==n.itemId)return;let O=i.getChapterBranches(),h=new Set;for(let u of O)h.has(u.media.id)||(yield b({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),h.add(u.media.id))})}function v(h){return V(this,arguments,function*({chapter:{id:f},manifestVideo:O}){if(me(n)||!i)return;let u=n.player.info.muted$.getValue(),y=n.player.info.currentQuality$.getValue(),S=n.player.info.isAutoQualityEnabled$.getValue(),A=n.player.info.volume$.getValue(),C=n.player.info.currentPlaybackRate$.getValue(),P=!S,H=!1;for(let $ of e.map)if($[0]===O.id&&!i.state.isReplay$.getValue()){let N=Object.keys($[1]);for(let _ of N)_===n.itemId?(N.length<Rp||(H=!0),e.removePlayer($[0],_)):(H=!0,c($[0],_,f),P?ct(n.player,y):n.player.setAutoQuality(!0),n.player.setVolume(A),n.player.setMuted(u),n.player.setPlaybackRate(C))}else e.removePlayer($[0]);H||(yield b({media:O,chapterId:f,setAsActive:!0,playbackRate:C}),P?ct(n.player,y):n.player.setAutoQuality(!0),n.player.setVolume(A),n.player.setMuted(u))})}function b(P){return V(this,arguments,function*({media:f,chapterId:O,prefetch:h=!0,setAsActive:u=!0,autoplay:y=!1,preferredExt:S,title:A,playbackRate:C}){var Cn,gn,En,xn,In;let H=Math.random().toString(),$=document.createElement("div");l.append($);let N;if((Cn=i==null?void 0:i.options)!=null&&Cn.vkVideoLoader){let ft=Us(f);ft.length&&(N=yield i.options.vkVideoLoader(...ft))}let _=((gn=i==null?void 0:i.options)==null?void 0:gn.coreConfig)||void 0,ee=T(d({},_),{configName:[...(En=_==null?void 0:_.configName)!=null?En:[],"interactive"]}),he=T(d({container:$},((xn=N==null?void 0:N.videos)==null?void 0:xn[0])||{sources:on(f,S).sources}),{title:A,failoverHosts:(N==null?void 0:N.failoverHosts)||[]}),U=new Ws.Player(ee,pe.Tracer.createRootTracer());U.initVideo(he);let Te=null;if(N!=null&&N.videos&&(i!=null&&i.options.createOneStat)){let ft=N.videos[0],nr=i.options.createOneStat(ft),Tn=new pe.Subscription;nr&&(Tn.add(nr.attachTo(U)),Te={oneStat:nr,statSubscription:Tn})}let bn=new pe.Subscription,ol=(In=n==null?void 0:n.player)==null?void 0:In.info.isAutoQualityEnabled$.getValue();bn.add(U.events.canplay$.subscribe(function(){ol||ct(U,n.player.info.currentQuality$.getValue()),C&&U.setPlaybackRate(C)}));let Se=e.createPlayer({listId:f.id,itemId:H,player:U,container:$,sources:on(f,S).sources,config:he,subscription:bn,statistics:Te});return u&&c(f.id,Se.itemId,O),y&&Se.player.play(),h&&!y&&Se.player.prepare(),{player:Se.player,config:Se.config,statistics:Se.statistics}})}function g(){R(),i=null,l.remove()}function R(){t.unsubscribe(),e.removeAll(),n={},o=!1}function I(){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");R(),l=document.createElement("div");let{media:f,chapter:O}=i.getCurrentChapter();f&&O?(t.add(i.events.chapterChanged$.subscribe(v)),yield b({media:f,chapterId:O.id,title:O.label})):console.error("not found")})}return T(d({},e),{init:I,setInteractiveController:s,createPlayer:b,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:a})}var M={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Le={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},F={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Qs=X(at(),1),Xs=require("@vkontakte/videoplayer-shared/es2015");function an(r){return function(...t){return r(...t.reverse())}}function ut(r,...e){return(...t)=>ue(e[0])&&ue(t[0])?r(d(d({},e[0]),t[0])):r(...e,...t)}var Qt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:l,globalEventEmitter:a,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:m,disabledControls$:v,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(be(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,n,i,o;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&l)return;this.emitContainerVisibilityEvent(!0,!1)}else{let l={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(s,c)=>{let{isExpectTime:m,hasOtherExpect:v,hasOpenURIEvent:b,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:R,hasShouldOpenNowEvent:I}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!g,O=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),s!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){if(this.interactiveTimeOpenUri){let h=!v&&!R&&g;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&b&&this.gameState!==5){if(O){let u=((y,S,A,C)=>!y&&!S&&A||y&&!S&&A&&!C||y&&!S&&A&&C)(m,v,R,this.isSelectedContainerEvent);this.fakeRemoveView(u)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!m||!v||!I)&&(this.selectBranches.stopExpect(),c())}},isEOV:()=>this.gameState===4},a=ut(this.selectBranches.onControlEvent,l);this.container.createView({eventCallback:a}),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,v;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Qs.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(ps(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Jr(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,R=this.interactiveTimeOpenUri&&b;if(R&&!g){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&&!R&&this.removeView()}let l=Jr(o,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(v=this.container.container.endTime)!=null?v:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:o,isInteractiveTime:l};this.container.onProgress(o*1e3,l),this.globalEventEmitter.emit(M.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Xs.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s,this.isPermanentText=c&&Ce(t.container.controls),this.interactiveTimeOpenUri=m,this.disabledControls$=v,this.onRemove=b,this.globalEventEmitter=a,this.gameState=0,this.globalEvents=l,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(M.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(M.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,n,i,o;e?(n=(t=this.container).disable)==null||n.call(t):(o=(i=this.container).enable)==null||o.call(i)}))}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:be(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(M.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Ys=(r=[])=>r.reduce((e,t,n)=>{var o,l,a;let i=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!nt(s));if(zt(i)){let s=[(l=t.startTime)!=null?l:0,(a=t.endTime)!=null?a:1/0],c={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:s});else{let m=[],v=-1/0,b=1/0,g=[],R=[];for(let I=0;I<e.length;I++){let f=e[I];if(R.push(...f.subjects),f.range[0]<b&&(b=f.range[0]),f.range[1]>v&&(v=f.range[1]),s[0]>=f.range[0]&&s[1]<=f.range[1])return e[I].subjects.push(c),e;s[0]<f.range[0]&&s[1]>f.range[0]&&(m.push(I),g=g.concat(f.subjects)),s[0]>=f.range[0]&&s[0]<=f.range[1]&&(m.push(I),g=g.concat(f.subjects),s[0]=f.range[0]),s[1]>=f.range[0]&&s[1]<=f.range[1]&&(m.push(I),g=g.concat(f.subjects),s[1]=f.range[1])}if(R.push(c),s[0]<=b&&s[1]>=v)return[{subjects:R,range:s}];m.length&&m.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:g.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Va=X(at(),1),pn=X(Kt(),1),$a=X(ka(),1);function Pa(){let r={};function e(){for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&delete r[a]}function t(a){let s={};for(let c in r)+c<=a&&(s[c]=r[c]);return s}function n(a){let s={};for(let c in r)+c>=a&&(s[c]=r[c]);return s}function i({timestamp:a,priority:s,initiator:c}){var m;if(ar(a)){let v=(m=r[a])!=null?m:null;if(v&&s&&De(s,!0)){let b={},g=v[s];if(g&&(b=d(d({},b),g)),b=me(b)?null:b,b&&De(c,!0)){let R=b[c];return R!=null?R:null}return b}return v}return null}function o({timestamp:a,priority:s,initiator:c}){if(ar(a))if(r[a]){if(s&&De(s,!0))if(r[a][s]){if(c&&De(c,!0))if(r[a][s][c]){if(delete r[a][s][c],!me(r[a][s]))return!0}else return!1;if(delete r[a][s],!me(r[a]))return!0}else return!1;return delete r[a]}else return!1;return!1}function l(v){var b=v,{timestamp:a,priority:s,initiator:c}=b,m=te(b,["timestamp","priority","initiator"]);var g,R,I;(R=(g=r[a])==null?void 0:g[s])!=null&&R[c]?r[a][s][c].push(d({},m)):(I=r[a])!=null&&I[s]?r[a][s]=T(d({},r[a][s]),{[c]:[d({},m)]}):r[a]?r[a]=T(d({},r[a]),{[s]:{[c]:[d({},m)]}}):r[a]={[s]:{[c]:[d({},m)]}}}return{map:r,remove:o,add:l,removeAll:e,get:i,getLte:t,getGte:n}}var vh=[x.EventActionTypes.expect,x.EventActionTypes.setNextBranch],yh=1/0;function Ma(r,e){let t=r,n,i=bh(e),o=Pa(),l,a=()=>{g(),h()},s=u=>{o.add.call(void 0,u),I()},c=(u=[])=>{for(let y of u)if(y.action(),(0,Va.default)(vh,y.actionType))break},m=(u=1/0)=>{var C,P,H;let y=Yt((C=o.get({timestamp:u,priority:"control"}))!=null?C:{}),S=Yt((P=o.get({timestamp:u,priority:"container"}))!=null?P:{}),A=Yt((H=o.get({timestamp:u,priority:"chapter"}))!=null?H:{});return[...y,...S,...A]},v=u=>{i.isReady(u)&&c(m(u))},b=()=>{var u;c([...Yt((u=o.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},g=()=>{n&&(l==null||l.unsubscribe(),n=void 0)},R=u=>{},I=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),l=t.events.ended$.subscribe(n))},f=u=>{g(),t=u},O=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),o.remove(u)},h=()=>{i.release(),o.removeAll()};return{setPlayer:f,add:s,remove:O,exec:v,execEndOfVideo:b,listen:I,unlisten:g,release:a,containersEventsCallState:i,getPreparedToExecActions:m}}function bh(r){let e=new Map;return{setCalled:({timestamp:a,id:s})=>{let c=e.get(a);c&&c[s]!==void 0&&(c[s]=!0)},setData:(a=[])=>{var s;for(let c of a){let m=(s=c.endTime)!=null?s:yh,v=e.get(m);e.set(m,T(d({},v),{[c.id]:!1}))}},resetCalled:a=>{let s=e.get(a);if(s)for(let c in s)s[c]=!1},isReady:a=>{let s=e.get(a);if(!s)return!0;let c=(0,pn.default)(s);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function Yt(r){return(0,$a.default)((0,pn.default)(r)).sort(e=>e.actionType===x.EventActionTypes.expect?-1:1)}var La={videoContentHeight:0,videoContentWidth:0},Na=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return La;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return La;let o=e/t,l=n/i,a,s;return l>o?(s=i,a=i*o):l<o?(s=n/o,a=n):(s=i,a=n),{videoContentWidth:s,videoContentHeight:a}};var Ch=250;function Fa(r){let e,t=new ResizeObserver(a=>{o(a),e=o.bind(null,a)});function n(a){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:m,videoContentHeight:v}=Na(c);s.style.setProperty("--interactive-content-width",`${m}px`),s.style.setProperty("--interactive-content-height",`${v}px`),s.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function i(){let{parentElement:a}=r();a.removeAttribute("style")}let o=et(a=>{let{fns:s=[]}=r();n(a);for(let c of s)c()},Ch);function l(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var gh=r=>Math.floor(Math.random()*r),_a=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let o=r[e],l=(i=o.weight)!=null?i:1;l<t&&(t=l,n=o)}return n},Ba=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let o=r[e],l=(i=o.weight)!=null?i:0;l>t&&(t=l,n=o)}return n};var qa=r=>{let e=r.length,t=gh(e);return r[t]},ja=1,Da=r=>{var n,i;let e=0;for(let o=0;o<r.length;++o)e+=(n=r[o].weight)!=null?n:ja;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(i=r[o].weight)!=null?i:ja,e>=t)return r[o];return r[r.length-1]};var Ha={shouldOpenNow:!0,isDetachContainer:!0},Ua="after-expect";var hn=(r,e=!1)=>T(d({},r),{args:e?d(d({},r.args),Ha):d(d({},Ha),r.args)}),Wa=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},l=({action:h,controlType:u,controlId:y,containerId:S,branches:A=[],onEvent:C,isEOV:P=()=>!1,isDisabled:H=()=>!1})=>{let $=hn(h,P()),N={timestamp:1/0,priority:"control",initiator:y,actionType:$.type},_=H(),ee=r.emit.bind(r,M.interactives,{subjectId:y,subjectType:u,subjectName:"control",type:_?F.actionChoiceCanceled:F.actionChoice,actionType:h.type,payload:d({invokeImmediately:$.args.shouldOpenNow,containerId:S},$.args)}),he=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:u,subjectName:"control",type:_?"action-choice-canceled":"action-choice",actionType:h.type,payload:d({invokeImmediately:$.args.shouldOpenNow,containerId:S},$.args)})};if(_){ee(),he();return}switch($.type.trim().toLowerCase()){case x.EventActionTypes.setNextBranch.trim().toLowerCase():{let U=A.find(Te=>Te.id===$.args.branchId);if(!U)return;C($.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),ee(),he(),$.args.shouldOpenNow?I({subjectId:y,subjectName:"control",subjectType:u,action:$,payload:{chapterId:U.chapterId,autoSelect:!1}}):n.add(T(d({},N),{action:I.bind(null,{subjectId:y,subjectName:"control",subjectType:u,action:$,payload:{chapterId:U.chapterId,autoSelect:!1}})}));return}case x.EventActionTypes.continuePlayback.trim().toLowerCase():{C($.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),ee(),he(),$.args.shouldOpenNow?R({subjectId:y,subjectName:"control",subjectType:u,action:h}):n.add(T(d({},N),{action:R.bind(null,{subjectId:y,subjectName:"control",subjectType:u,action:h})}));return}case x.EventActionTypes.openURI.trim().toLowerCase():{C($.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),ee(),he(),$.args.shouldOpenNow?O({subjectId:y,subjectName:"control",subjectType:u,action:$,payload:{URI:h.args.uri}}):n.add(T(d({},N),{action:O.bind(null,{subjectId:y,subjectName:"control",subjectType:u,action:$,payload:{URI:h.args.uri}})}));return}default:{let U="Unexpected control event",Te=new D(1,1,{message:U});m(Te,U);return}}},a=({action:h,container:{id:u,endTime:y},branches:S=[],isEOV:A=!1,autoSelected:C=!1})=>{let P=hn(h,A),H={timestamp:!P.args.shouldOpenNow||A?1/0:y!=null?y:1/0,priority:"container",initiator:u,actionType:P.type},$=r.emit.bind(r,M.interactives,{subjectId:u,subjectName:"container",type:F.actionChoice,actionType:P.type,payload:d({invokeImmediately:P.args.shouldOpenNow},P.args)}),N=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:P.type,payload:d({invokeImmediately:P.args.shouldOpenNow},P.args)})};switch(P.type.trim().toLowerCase()){case x.EventActionTypes.setNextBranch.trim().toLowerCase():{let _=S.find(ee=>ee.id===P.args.branchId);if(!_)return;$(),N(),n.add(T(d({},H),{action:I.bind(null,{subjectId:u,subjectName:"container",action:P,payload:{chapterId:_.chapterId,autoSelect:C}})}));return}case x.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case x.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case x.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case x.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case x.EventActionTypes.continuePlayback.trim().toLowerCase():{$(),N(),n.add(T(d({},H),{action:R.bind(null,{subjectId:u,subjectName:"container",action:P})}));return}case x.EventActionTypes.openURI.trim().toLowerCase():{$(),N(),n.add(T(d({},H),{action:O.bind(null,{subjectId:u,subjectName:"container",action:P,payload:{URI:h.args.uri}})}));return}default:{let _="Unexpected container event",ee=new D(1,1,{message:_});m(ee,_);return}}};function s({container:h,branches:u,isEOV:y=!1}){var A,C;let S=en(h.events);if(S){let P=hn(S.action,y);r.emit(M.interactives,{subjectId:h.id,subjectName:"container",type:F.actionChoice,actionType:P.type,payload:d({invokeImmediately:P.args.shouldOpenNow},P.args)}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:P.type,payload:d({invokeImmediately:P.args.shouldOpenNow},P.args)}),n.add({timestamp:y?1/0:(A=h.endTime)!=null?A:1/0,priority:"container",initiator:h.id,actionType:x.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let P of(C=h.events)!=null?C:[])a({action:P.action,container:h,branches:u,isEOV:y})}let c=({chapterId:h,action:u,branches:y=[]})=>{let S=r.emit.bind(r,M.interactives,{subjectId:h,subjectName:"chapter",type:F.actionChoice,actionType:u.type,payload:u.args}),A=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case x.EventActionTypes.setNextBranch.trim().toLowerCase():{let C=y.find(P=>P.id===u.args.branchId);return C!=null&&C.chapterId?(S(),A(),I.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let C=qa(y);return C!=null&&C.chapterId?(S(),A(),I.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.EventActionTypes.setRandomBranch.trim().toLowerCase():{let C=Da(y);return C!=null&&C.chapterId?(S(),A(),I.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let C=Ba(y);return C!=null&&C.chapterId?(S(),A(),I.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let C=_a(y);return C!=null&&C.chapterId?(S(),A(),I.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.EventActionTypes.continuePlayback.trim().toLowerCase():return S(),A(),R.bind(null,{subjectId:h,subjectName:"chapter",action:u});case x.EventActionTypes.openURI.trim().toLowerCase():return S(),A(),O.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let C="Unexpected chapter event",P=new D(1,1,{message:C});m(P,C);return}}};function m(h,u){console.error(u),e.error$.next(h),r.emit(M.errors,h)}function v(h){var y;let u=en(h.events);if(u){if(J(h))return;r.emit(M.interactives,{subjectId:h.id,subjectName:"chapter",type:F.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:x.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(y=h.events)==null||y.forEach(S=>{let A=c({chapterId:h.id,action:S.action,branches:h.branches});A&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:S.action.type,action:A})})}let b=({subjectId:h,subjectName:u})=>{t.pause(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:F.actionExecution,actionType:x.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:x.EventActionTypes.expect})},g=({subjectId:h,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:F.actionExecution,actionType:Ua}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:Ua})},R=({subjectId:h,subjectName:u,subjectType:y,action:S})=>{r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:y,type:F.actionExecution,actionType:S.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:y,type:"action-execution",actionType:S.type})},I=({subjectId:h,subjectName:u,subjectType:y,action:S,payload:A})=>{A.behaviour="change-chapter",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:y,type:F.actionExecution,actionType:S.type,payload:A}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:y,type:"action-execution",actionType:S.type,payload:A})},f=({subjectId:h,subjectName:u,subjectType:y,action:S,payload:A})=>{A.behaviour="change-manifest",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:y,type:F.actionExecution,actionType:S.type,payload:A}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:y,type:"action-execution",actionType:S.type,payload:A})},O=({subjectId:h,subjectName:u,subjectType:y,action:S,payload:A})=>{if(!A.URI)return;let C=window.open(A.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:y,type:F.actionExecution,actionType:S.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:y,type:"action-execution",actionType:S.type})};return{onControlEvent:l,onContainerEvent:a,onChapterEvent:c,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:s,stopExpect:o,state:i}};var fn=X(Gr(),1),Q=require("@vkontakte/videoplayer-shared/es2015");var Zt=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(l=>l.id===n);if(!i)return null;let o=e.media.videos.find(l=>i.videoId===l.id);if(!o)return null;t[n]=dn(o)}return t[n]}).filter(Boolean)},Ka=r=>{for(let e of r.variants)if(Qa(e)&&e.payload)return e.payload.id},Qa=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),dn=r=>{let e=Ka(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Xa=(r,e)=>{for(let t of r.media.videos)if(e===dn(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},mn=(r,e)=>r.reduce((t,n)=>{let i=Xa(e,n);return i?[...t,i]:t},[]);var oe,Ee,xe,K,Jt,se,ae,ie,Ie,Ne,Fe,ht=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new Q.ValueSubject([]),hasPrevChapter$:new Q.ValueSubject(!1),prevChapter$:new Q.ValueSubject(null),isInitialChapter$:new Q.ValueSubject(!1),isGoBackLimited$:new Q.ValueSubject(!1)};G(this,oe,null);G(this,Ee);G(this,xe,!1);G(this,K,null);G(this,Jt,null);this.events={inited$:new Q.Subject,destroyed$:new Q.Subject,error$:new Q.Subject};G(this,se,null);G(this,ae,null);G(this,ie,null);G(this,Ie,new Q.Subscription);G(this,Ne,!1);G(this,Fe,0);var l;B(this,se,t),B(this,ie,e),B(this,ae,n),B(this,oe,i),B(this,Ee,o),this.state.history$&&k(this,Ie)&&((l=k(this,Ie))==null||l.add(this.state.history$.subscribe(a=>{var s,c;this.state.prevChapter$.next((0,fn.default)(a,-2)||null),this.state.hasPrevChapter$.next(a.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=k(this,K))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(k(this,Fe)===k(this,Ee).maxLength-1)})))}setManifest(e){return V(this,null,function*(){if(!k(this,ae)||!k(this,ie))return;B(this,K,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield k(this,ae).setChapter({chapterId:t,pushToHistory:!1}),k(this,xe)||(B(this,xe,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return k(this,xe)}updateHistory(e,t=!0){return V(this,null,function*(){var a;if(!k(this,K))return;k(this,Ne)?(B(this,Ne,!1),kn(this,Fe)._++):B(this,Fe,0);let n=k(this,K),i=e.length-k(this,Ee).maxLength,o=i>0?e.slice(i):e,l=Zt(o,n);if(B(this,Jt,l),this.state.history$.next(o),!(!t||!k(this,oe)||!k(this,se)))try{yield k(this,oe).save(k(this,se),l)}catch(s){let c=new D(1,5,"Unable to save interactive history");this.events.error$.next(c),(a=k(this,ie))==null||a.emit(M.errors,c)}})}goBack(){return V(this,null,function*(){var n;if(!this.state||!k(this,ae)){let i=new D(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=k(this,ie))==null?void 0:n.emit(M.errors,i)}B(this,Ne,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield k(this,ae).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return V(this,null,function*(){var i;if(!k(this,K)||!k(this,se))return;let e=k(this,K),t=[this.getInitialVideoId()];if(k(this,oe))try{let o=yield k(this,oe).get(k(this,se));o.length&&(t=o)}catch(o){let l=new D(1,5,"Error while trying to fetch data");this.events.error$.next(l),(i=k(this,ie))==null||i.emit(M.errors,l)}let n=mn(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,fn.default)(e,-1)||k(this,Ee).initChapterId||((t=k(this,K))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(k(this,K)){let e=this.getInitialChapterId();return Zt([e],k(this,K)).pop()}return null}destroy(){var e,t;B(this,se,null),B(this,oe,null),B(this,ae,null),(e=k(this,Ie))==null||e.unsubscribe(),B(this,Ie,null),B(this,xe,!1),(t=k(this,ie))==null||t.emit(M.historyDestroyed),this.events.destroyed$.next(),B(this,ie,null)}};oe=new WeakMap,Ee=new WeakMap,xe=new WeakMap,K=new WeakMap,Jt=new WeakMap,se=new WeakMap,ae=new WeakMap,ie=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,Fe=new WeakMap;var er=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))}updateCanvasDimensions(e,t=!1){return V(this,null,function*(){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n})}save(){return V(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var tr=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=`
6
+ "use strict";var Bo=Object.create;var Le=Object.defineProperty,Do=Object.defineProperties,Ho=Object.getOwnPropertyDescriptor,Uo=Object.getOwnPropertyDescriptors,Go=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,zo=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var fn=r=>{throw TypeError(r)};var dn=(r,e,t)=>e in r?Le(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&dn(r,t,e[t]);if(ct)for(var t of ct(e))mn.call(e,t)&&dn(r,t,e[t]);return r},w=(r,e)=>Do(r,Uo(e));var J=(r,e)=>{var t={};for(var n in r)Qt.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&ct)for(var n of ct(r))e.indexOf(n)<0&&mn.call(r,n)&&(t[n]=r[n]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Wo=(r,e)=>{for(var t in e)Le(r,t,{get:e[t],enumerable:!0})},vn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Go(e))!Qt.call(r,i)&&i!==t&&Le(r,i,{get:()=>e[i],enumerable:!(n=Ho(e,i))||n.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?Bo(zo(r)):{},vn(e||!r||!r.__esModule?Le(t,"default",{value:r,enumerable:!0}):t,r)),Ko=r=>vn(Le({},"__esModule",{value:!0}),r);var yn=(r,e,t)=>e.has(r)||fn("Cannot "+t);var O=(r,e,t)=>(yn(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?fn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,n)=>(yn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var bn=(r,e,t,n)=>({set _(i){_(r,e,i,t)},get _(){return O(r,e,n)}});var V=(r,e,t)=>new Promise((n,i)=>{var s=a=>{try{c(t.next(a))}catch(l){i(l)}},o=a=>{try{c(t.throw(a))}catch(l){i(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,o);c((t=t.apply(r,e)).next())});var te=p((ir,An)=>{"use strict";var je=function(r){return r&&r.Math===Math&&r};An.exports=je(typeof globalThis=="object"&&globalThis)||je(typeof window=="object"&&window)||je(typeof self=="object"&&self)||je(typeof global=="object"&&global)||je(typeof ir=="object"&&ir)||function(){return this}()||Function("return this")()});var G=p((cd,On)=>{"use strict";On.exports=function(r){try{return!!r()}catch(e){return!0}}});var $e=p((ld,Rn)=>{"use strict";var Qo=G();Rn.exports=!Qo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Nn=p((ud,Mn)=>{"use strict";var Xo=$e(),Vn=Function.prototype,kn=Vn.apply,Pn=Vn.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(Xo?Pn.bind(kn):function(){return Pn.apply(kn,arguments)})});var Q=p((pd,$n)=>{"use strict";var Ln=$e(),jn=Function.prototype,sr=jn.call,Yo=Ln&&jn.bind.bind(sr,sr);$n.exports=Ln?Yo:function(r){return function(){return sr.apply(r,arguments)}}});var _e=p((hd,Fn)=>{"use strict";var _n=Q(),Zo=_n({}.toString),Jo=_n("".slice);Fn.exports=function(r){return Jo(Zo(r),8,-1)}});var ar=p((dd,qn)=>{"use strict";var ec=_e(),tc=Q();qn.exports=function(r){if(ec(r)==="Function")return tc(r)}});var z=p((md,Bn)=>{"use strict";var or=typeof document=="object"&&document.all;Bn.exports=typeof or=="undefined"&&or!==void 0?function(r){return typeof r=="function"||r===or}:function(r){return typeof r=="function"}});var ue=p((fd,Dn)=>{"use strict";var rc=G();Dn.exports=!rc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ct=p((vd,Hn)=>{"use strict";var nc=$e(),bt=Function.prototype.call;Hn.exports=nc?bt.bind(bt):function(){return bt.apply(bt,arguments)}});var cr=p(zn=>{"use strict";var Un={}.propertyIsEnumerable,Gn=Object.getOwnPropertyDescriptor,ic=Gn&&!Un.call({1:2},1);zn.f=ic?function(e){var t=Gn(this,e);return!!t&&t.enumerable}:Un});var lr=p((bd,Wn)=>{"use strict";Wn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qn=p((Cd,Kn)=>{"use strict";var sc=Q(),ac=G(),oc=_e(),ur=Object,cc=sc("".split);Kn.exports=ac(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return oc(r)==="String"?cc(r,""):ur(r)}:ur});var pr=p((gd,Xn)=>{"use strict";Xn.exports=function(r){return r==null}});var hr=p((Ed,Yn)=>{"use strict";var lc=pr(),uc=TypeError;Yn.exports=function(r){if(lc(r))throw new uc("Can't call method on "+r);return r}});var Fe=p((Id,Zn)=>{"use strict";var pc=Qn(),hc=hr();Zn.exports=function(r){return pc(hc(r))}});var Te=p((xd,Jn)=>{"use strict";var dc=z();Jn.exports=function(r){return typeof r=="object"?r!==null:dc(r)}});var gt=p((Td,ei)=>{"use strict";ei.exports={}});var Et=p((Sd,ri)=>{"use strict";var dr=gt(),mr=te(),mc=z(),ti=function(r){return mc(r)?r:void 0};ri.exports=function(r,e){return arguments.length<2?ti(dr[r])||ti(mr[r]):dr[r]&&dr[r][e]||mr[r]&&mr[r][e]}});var ii=p((wd,ni)=>{"use strict";var fc=Q();ni.exports=fc({}.isPrototypeOf)});var ci=p((Ad,oi)=>{"use strict";var vc=te(),si=vc.navigator,ai=si&&si.userAgent;oi.exports=ai?String(ai):""});var fi=p((Od,mi)=>{"use strict";var di=te(),fr=ci(),li=di.process,ui=di.Deno,pi=li&&li.versions||ui&&ui.version,hi=pi&&pi.v8,X,It;hi&&(X=hi.split("."),It=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!It&&fr&&(X=fr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=fr.match(/Chrome\/(\d+)/),X&&(It=+X[1])));mi.exports=It});var vr=p((Rd,yi)=>{"use strict";var vi=fi(),yc=G(),bc=te(),Cc=bc.String;yi.exports=!!Object.getOwnPropertySymbols&&!yc(function(){var r=Symbol("symbol detection");return!Cc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&vi&&vi<41})});var yr=p((kd,bi)=>{"use strict";var gc=vr();bi.exports=gc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=p((Pd,Ci)=>{"use strict";var Ec=Et(),Ic=z(),xc=ii(),Tc=yr(),Sc=Object;Ci.exports=Tc?function(r){return typeof r=="symbol"}:function(r){var e=Ec("Symbol");return Ic(e)&&xc(e.prototype,Sc(r))}});var Ei=p((Vd,gi)=>{"use strict";var wc=String;gi.exports=function(r){try{return wc(r)}catch(e){return"Object"}}});var Cr=p((Md,Ii)=>{"use strict";var Ac=z(),Oc=Ei(),Rc=TypeError;Ii.exports=function(r){if(Ac(r))return r;throw new Rc(Oc(r)+" is not a function")}});var Ti=p((Nd,xi)=>{"use strict";var kc=Cr(),Pc=pr();xi.exports=function(r,e){var t=r[e];return Pc(t)?void 0:kc(t)}});var wi=p((Ld,Si)=>{"use strict";var gr=Ct(),Er=z(),Ir=Te(),Vc=TypeError;Si.exports=function(r,e){var t,n;if(e==="string"&&Er(t=r.toString)&&!Ir(n=gr(t,r))||Er(t=r.valueOf)&&!Ir(n=gr(t,r))||e!=="string"&&Er(t=r.toString)&&!Ir(n=gr(t,r)))return n;throw new Vc("Can't convert object to primitive value")}});var Oi=p((jd,Ai)=>{"use strict";Ai.exports=!0});var Pi=p(($d,ki)=>{"use strict";var Ri=te(),Mc=Object.defineProperty;ki.exports=function(r,e){try{Mc(Ri,r,{value:e,configurable:!0,writable:!0})}catch(t){Ri[r]=e}return e}});var xt=p((_d,Ni)=>{"use strict";var Nc=Oi(),Lc=te(),jc=Pi(),Vi="__core-js_shared__",Mi=Ni.exports=Lc[Vi]||jc(Vi,{});(Mi.versions||(Mi.versions=[])).push({version:"3.38.0",mode:Nc?"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 xr=p((Fd,ji)=>{"use strict";var Li=xt();ji.exports=function(r,e){return Li[r]||(Li[r]=e||{})}});var qe=p((qd,$i)=>{"use strict";var $c=hr(),_c=Object;$i.exports=function(r){return _c($c(r))}});var Se=p((Bd,_i)=>{"use strict";var Fc=Q(),qc=qe(),Bc=Fc({}.hasOwnProperty);_i.exports=Object.hasOwn||function(e,t){return Bc(qc(e),t)}});var Tr=p((Dd,Fi)=>{"use strict";var Dc=Q(),Hc=0,Uc=Math.random(),Gc=Dc(1 .toString);Fi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Gc(++Hc+Uc,36)}});var Be=p((Hd,Bi)=>{"use strict";var zc=te(),Wc=xr(),qi=Se(),Kc=Tr(),Qc=vr(),Xc=yr(),we=zc.Symbol,Sr=Wc("wks"),Yc=Xc?we.for||we:we&&we.withoutSetter||Kc;Bi.exports=function(r){return qi(Sr,r)||(Sr[r]=Qc&&qi(we,r)?we[r]:Yc("Symbol."+r)),Sr[r]}});var Gi=p((Ud,Ui)=>{"use strict";var Zc=Ct(),Di=Te(),Hi=br(),Jc=Ti(),el=wi(),tl=Be(),rl=TypeError,nl=tl("toPrimitive");Ui.exports=function(r,e){if(!Di(r)||Hi(r))return r;var t=Jc(r,nl),n;if(t){if(e===void 0&&(e="default"),n=Zc(t,r,e),!Di(n)||Hi(n))return n;throw new rl("Can't convert object to primitive value")}return e===void 0&&(e="number"),el(r,e)}});var wr=p((Gd,zi)=>{"use strict";var il=Gi(),sl=br();zi.exports=function(r){var e=il(r,"string");return sl(e)?e:e+""}});var Qi=p((zd,Ki)=>{"use strict";var al=te(),Wi=Te(),Ar=al.document,ol=Wi(Ar)&&Wi(Ar.createElement);Ki.exports=function(r){return ol?Ar.createElement(r):{}}});var Or=p((Wd,Xi)=>{"use strict";var cl=ue(),ll=G(),ul=Qi();Xi.exports=!cl&&!ll(function(){return Object.defineProperty(ul("div"),"a",{get:function(){return 7}}).a!==7})});var Ji=p(Zi=>{"use strict";var pl=ue(),hl=Ct(),dl=cr(),ml=lr(),fl=Fe(),vl=wr(),yl=Se(),bl=Or(),Yi=Object.getOwnPropertyDescriptor;Zi.f=pl?Yi:function(e,t){if(e=fl(e),t=vl(t),bl)try{return Yi(e,t)}catch(n){}if(yl(e,t))return ml(!hl(dl.f,e,t),e[t])}});var ts=p((Qd,es)=>{"use strict";var Cl=G(),gl=z(),El=/#|\.prototype\./,De=function(r,e){var t=xl[Il(r)];return t===Sl?!0:t===Tl?!1:gl(e)?Cl(e):!!e},Il=De.normalize=function(r){return String(r).replace(El,".").toLowerCase()},xl=De.data={},Tl=De.NATIVE="N",Sl=De.POLYFILL="P";es.exports=De});var Rr=p((Xd,ns)=>{"use strict";var rs=ar(),wl=Cr(),Al=$e(),Ol=rs(rs.bind);ns.exports=function(r,e){return wl(r),e===void 0?r:Al?Ol(r,e):function(){return r.apply(e,arguments)}}});var ss=p((Yd,is)=>{"use strict";var Rl=ue(),kl=G();is.exports=Rl&&kl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var os=p((Zd,as)=>{"use strict";var Pl=Te(),Vl=String,Ml=TypeError;as.exports=function(r){if(Pl(r))return r;throw new Ml(Vl(r)+" is not an object")}});var us=p(ls=>{"use strict";var Nl=ue(),Ll=Or(),jl=ss(),Tt=os(),cs=wr(),$l=TypeError,kr=Object.defineProperty,_l=Object.getOwnPropertyDescriptor,Pr="enumerable",Vr="configurable",Mr="writable";ls.f=Nl?jl?function(e,t,n){if(Tt(e),t=cs(t),Tt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Mr in n&&!n[Mr]){var i=_l(e,t);i&&i[Mr]&&(e[t]=n.value,n={configurable:Vr in n?n[Vr]:i[Vr],enumerable:Pr in n?n[Pr]:i[Pr],writable:!1})}return kr(e,t,n)}:kr:function(e,t,n){if(Tt(e),t=cs(t),Tt(n),Ll)try{return kr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new $l("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var hs=p((em,ps)=>{"use strict";var Fl=ue(),ql=us(),Bl=lr();ps.exports=Fl?function(r,e,t){return ql.f(r,e,Bl(1,t))}:function(r,e,t){return r[e]=t,r}});var Ue=p((tm,ms)=>{"use strict";var He=te(),Dl=Nn(),Hl=ar(),Ul=z(),Gl=Ji().f,zl=ts(),Ae=gt(),Wl=Rr(),Oe=hs(),ds=Se();xt();var Kl=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 Dl(r,this,arguments)};return e.prototype=r.prototype,e};ms.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,s=r.proto,o=n?He:i?He[t]:He[t]&&He[t].prototype,c=n?Ae:Ae[t]||Oe(Ae,t,{})[t],a=c.prototype,l,f,y,b,g,A,E,v,k;for(b in e)l=zl(n?b:t+(i?".":"#")+b,r.forced),f=!l&&o&&ds(o,b),A=c[b],f&&(r.dontCallGetSet?(k=Gl(o,b),E=k&&k.value):E=o[b]),g=f&&E?E:e[b],!(!l&&!s&&typeof A==typeof g)&&(r.bind&&f?v=Wl(g,He):r.wrap&&f?v=Kl(g):s&&Ul(g)?v=Hl(g):v=g,(r.sham||g&&g.sham||A&&A.sham)&&Oe(v,"sham",!0),Oe(c,b,v),s&&(y=t+"Prototype",ds(Ae,y)||Oe(Ae,y,{}),Oe(Ae[y],b,g),r.real&&a&&(l||!a[b])&&Oe(a,b,g)))}});var vs=p((rm,fs)=>{"use strict";var Ql=Math.ceil,Xl=Math.floor;fs.exports=Math.trunc||function(e){var t=+e;return(t>0?Xl:Ql)(t)}});var Ge=p((nm,ys)=>{"use strict";var Yl=vs();ys.exports=function(r){var e=+r;return e!==e||e===0?0:Yl(e)}});var Cs=p((im,bs)=>{"use strict";var Zl=Ge(),Jl=Math.min;bs.exports=function(r){var e=Zl(r);return e>0?Jl(e,9007199254740991):0}});var ze=p((sm,gs)=>{"use strict";var eu=Cs();gs.exports=function(r){return eu(r.length)}});var St=p((am,Es)=>{"use strict";Es.exports=function(){}});var Is=p(()=>{"use strict";var tu=Ue(),ru=qe(),nu=ze(),iu=Ge(),su=St();tu({target:"Array",proto:!0},{at:function(e){var t=ru(this),n=nu(t),i=iu(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:t[s]}});su("at")});var wt=p((lm,xs)=>{"use strict";var au=Et();xs.exports=au});var Ss=p((um,Ts)=>{"use strict";Is();var ou=wt();Ts.exports=ou("Array","at")});var As=p((pm,ws)=>{"use strict";var cu=Ss();ws.exports=cu});var Nr=p((hm,Os)=>{"use strict";var lu=As();Os.exports=lu});var Hs=p((bf,Ds)=>{"use strict";var Iu=xr(),xu=Tr(),Bs=Iu("keys");Ds.exports=function(r){return Bs[r]||(Bs[r]=xu(r))}});var Gs=p((Cf,Us)=>{"use strict";var Tu=G();Us.exports=!Tu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ks=p((gf,Ws)=>{"use strict";var Su=Se(),wu=z(),Au=qe(),Ou=Hs(),Ru=Gs(),zs=Ou("IE_PROTO"),Gr=Object,ku=Gr.prototype;Ws.exports=Ru?Gr.getPrototypeOf:function(r){var e=Au(r);if(Su(e,zs))return e[zs];var t=e.constructor;return wu(t)&&e instanceof t?t.prototype:e instanceof Gr?ku:null}});var Xs=p((Ef,Qs)=>{"use strict";var Pu=Ge(),Vu=Math.max,Mu=Math.min;Qs.exports=function(r,e){var t=Pu(r);return t<0?Vu(t+e,0):Mu(t,e)}});var zr=p((If,Zs)=>{"use strict";var Nu=Fe(),Lu=Xs(),ju=ze(),Ys=function(r){return function(e,t,n){var i=Nu(e),s=ju(i);if(s===0)return!r&&-1;var o=Lu(n,s),c;if(r&&t!==t){for(;s>o;)if(c=i[o++],c!==c)return!0}else for(;s>o;o++)if((r||o in i)&&i[o]===t)return r||o||0;return!r&&-1}};Zs.exports={includes:Ys(!0),indexOf:Ys(!1)}});var ea=p((xf,Js)=>{"use strict";Js.exports={}});var na=p((Tf,ra)=>{"use strict";var $u=Q(),Wr=Se(),_u=Fe(),Fu=zr().indexOf,qu=ea(),ta=$u([].push);ra.exports=function(r,e){var t=_u(r),n=0,i=[],s;for(s in t)!Wr(qu,s)&&Wr(t,s)&&ta(i,s);for(;e.length>n;)Wr(t,s=e[n++])&&(~Fu(i,s)||ta(i,s));return i}});var sa=p((Sf,ia)=>{"use strict";ia.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var oa=p((wf,aa)=>{"use strict";var Bu=na(),Du=sa();aa.exports=Object.keys||function(e){return Bu(e,Du)}});var da=p((Af,ha)=>{"use strict";var la=ue(),Hu=G(),ua=Q(),Uu=Ks(),Gu=oa(),zu=Fe(),Wu=cr().f,pa=ua(Wu),Ku=ua([].push),Qu=la&&Hu(function(){var r=Object.create(null);return r[2]=2,!pa(r,2)}),ca=function(r){return function(e){for(var t=zu(e),n=Gu(t),i=Qu&&Uu(t)===null,s=n.length,o=0,c=[],a;s>o;)a=n[o++],(!la||(i?a in t:pa(t,a)))&&Ku(c,r?[a,t[a]]:t[a]);return c}};ha.exports={entries:ca(!0),values:ca(!1)}});var ma=p(()=>{"use strict";var Xu=Ue(),Yu=da().values;Xu({target:"Object",stat:!0},{values:function(e){return Yu(e)}})});var va=p((kf,fa)=>{"use strict";ma();var Zu=gt();fa.exports=Zu.Object.values});var ba=p((Pf,ya)=>{"use strict";var Ju=va();ya.exports=Ju});var Ft=p((Vf,Ca)=>{"use strict";var ep=ba();Ca.exports=ep});var Ia=p(()=>{"use strict";var tp=Ue(),rp=zr().includes,np=G(),ip=St(),sp=np(function(){return!Array(1).includes()});tp({target:"Array",proto:!0,forced:sp},{includes:function(e){return rp(this,e,arguments.length>1?arguments[1]:void 0)}});ip("includes")});var Ta=p((_f,xa)=>{"use strict";Ia();var ap=wt();xa.exports=ap("Array","includes")});var wa=p((Ff,Sa)=>{"use strict";var op=Ta();Sa.exports=op});var qt=p((qf,Aa)=>{"use strict";var cp=wa();Aa.exports=cp});var Yr=p((nv,Na)=>{"use strict";var up=_e();Na.exports=Array.isArray||function(e){return up(e)==="Array"}});var ja=p((iv,La)=>{"use strict";var pp=TypeError,hp=9007199254740991;La.exports=function(r){if(r>hp)throw pp("Maximum allowed index exceeded");return r}});var Fa=p((sv,_a)=>{"use strict";var dp=Yr(),mp=ze(),fp=ja(),vp=Rr(),$a=function(r,e,t,n,i,s,o,c){for(var a=i,l=0,f=o?vp(o,c):!1,y,b;l<n;)l in t&&(y=f?f(t[l],l,e):t[l],s>0&&dp(y)?(b=mp(y),a=$a(r,e,y,b,a,s-1)-1):(fp(a+1),r[a]=y),a++),l++;return a};_a.exports=$a});var Da=p((av,Ba)=>{"use strict";var yp=Be(),bp=yp("toStringTag"),qa={};qa[bp]="z";Ba.exports=String(qa)==="[object z]"});var Ua=p((ov,Ha)=>{"use strict";var Cp=Da(),gp=z(),Dt=_e(),Ep=Be(),Ip=Ep("toStringTag"),xp=Object,Tp=Dt(function(){return arguments}())==="Arguments",Sp=function(r,e){try{return r[e]}catch(t){}};Ha.exports=Cp?Dt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Sp(e=xp(r),Ip))=="string"?t:Tp?Dt(e):(n=Dt(e))==="Object"&&gp(e.callee)?"Arguments":n}});var za=p((cv,Ga)=>{"use strict";var wp=Q(),Ap=z(),Zr=xt(),Op=wp(Function.toString);Ap(Zr.inspectSource)||(Zr.inspectSource=function(r){return Op(r)});Ga.exports=Zr.inspectSource});var Za=p((lv,Ya)=>{"use strict";var Rp=Q(),kp=G(),Wa=z(),Pp=Ua(),Vp=Et(),Mp=za(),Ka=function(){},Qa=Vp("Reflect","construct"),Jr=/^\s*(?:class|function)\b/,Np=Rp(Jr.exec),Lp=!Jr.test(Ka),it=function(e){if(!Wa(e))return!1;try{return Qa(Ka,[],e),!0}catch(t){return!1}},Xa=function(e){if(!Wa(e))return!1;switch(Pp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Lp||!!Np(Jr,Mp(e))}catch(t){return!0}};Xa.sham=!0;Ya.exports=!Qa||kp(function(){var r;return it(it.call)||!it(Object)||!it(function(){r=!0})||r})?Xa:it});var ro=p((uv,to)=>{"use strict";var Ja=Yr(),jp=Za(),$p=Te(),_p=Be(),Fp=_p("species"),eo=Array;to.exports=function(r){var e;return Ja(r)&&(e=r.constructor,jp(e)&&(e===eo||Ja(e.prototype))?e=void 0:$p(e)&&(e=e[Fp],e===null&&(e=void 0))),e===void 0?eo:e}});var io=p((pv,no)=>{"use strict";var qp=ro();no.exports=function(r,e){return new(qp(r))(e===0?0:e)}});var so=p(()=>{"use strict";var Bp=Ue(),Dp=Fa(),Hp=qe(),Up=ze(),Gp=Ge(),zp=io();Bp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Hp(this),n=Up(t),i=zp(t,0);return i.length=Dp(i,t,t,n,0,e===void 0?1:Gp(e)),i}})});var ao=p(()=>{"use strict";var Wp=St();Wp("flat")});var co=p((vv,oo)=>{"use strict";so();ao();var Kp=wt();oo.exports=Kp("Array","flat")});var uo=p((yv,lo)=>{"use strict";var Qp=co();lo.exports=Qp});var ho=p((bv,po)=>{"use strict";var Xp=uo();po.exports=Xp});var oh={};Wo(oh,{ContainerTypes:()=>I.ContainerTypes,ControlTypes:()=>I.ControlTypes,CustomError:()=>q,EVENT_NAMES:()=>M,EventActionTypes:()=>I.EventActionTypes,EventTypes:()=>I.EventTypes,Interactives:()=>at,ManifestController:()=>fe,SDKInfo:()=>ah,chapterIdsToVKVideoIds:()=>Ut,compareVersions:()=>jt,containerTypes:()=>du,controlTypes:()=>mu,eventActionTypes:()=>_r,eventTypes:()=>fu,getChapterIdByVkVideoId:()=>Mo,getVKVideoIdByMedia:()=>rn,getVideoRawIdByMedia:()=>Po,graphEventTypes:()=>Pe,hasEndTemplate:()=>rt,interactivesEventTypes:()=>L,isAreaControl:()=>hu,isButtonControl:()=>pu,isLastChapter:()=>Y,isOneTextCtrlContainer:()=>me,isSupportedManifest:()=>I.isSupportedManifest,isTextControl:()=>Ze,isVKVariantItem:()=>Vo,isValidManifest:()=>$r,migrateManifestToLatestVersion:()=>I.migrateManifestToLatestVersion,utils:()=>Fo,vkVideoIdsToChapterIds:()=>nn});module.exports=Ko(oh);var Cn="1.0.33-dev.2d205106.0";var Xt=class{constructor(e){this.layout=e}},lt=class extends Xt{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 gn(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&&gn(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(),s=this.factories.get(i);if(s){let o=s(n,this.options);if(o)return[...t,o]}return[...t]},[]))||[]}};function Yt(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 En="interactive",B={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},In=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(In||{}),xn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(xn||{}),Tn=(n=>(n.start="left",n.end="right",n.center="center",n))(Tn||{}),ut=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&In[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&xn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&Tn[e.alignment])!=null?i:"center"},pt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l;r.style.color=(s=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?s:t.textColor,r.style.fontSize=`calc(${n.height} * ${(c=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?c:t.textSize})`,r.textContent=(l=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?l:t.textContent},ht=({target:r,props:e,fallback:t})=>{var n,i,s,o;r.style.backgroundColor=Yt((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(o=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?o:t.backgroundAlpha)},dt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l,f,y,b,g,A;r.style.border=`calc(${n.height} * ${(o=(s=(i=e==null?void 0:e.shape)==null?void 0:i.border)==null?void 0:s.width)!=null?o:t.borderWidth}) solid ${Yt((l=(a=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:a.color)!=null?l:t.borderColor,(b=(y=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:y.alpha)!=null?b:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(A=(g=e==null?void 0:e.shape)==null?void 0:g.roundCorners)!=null?A:t.roundCorners})`},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 Zt="int",le=(n=>(n.AREA=`${Zt}_area`,n.TEXT=`${Zt}_text`,n.BUTTON=`${Zt}_bttn`,n))(le||{});function Sn(r){return"features"in r}var xe="interactive-control",j={common:xe,wrapper:`${xe}-wrapper`,disabled:`${xe}-disabled`,button:`${xe}-button`,area:`${xe}-area`,text:`${xe}-text`};var ae=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(j.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:B.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&&Sn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var i;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(i=this.container)==null||i.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var mt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Jt(r,e)},Jt=class extends ae{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(j.common,j.area),n.setAttribute("data-testid",le.AREA),ht({target:n,props:this.control.props,fallback:w(d({},B),{backgroundColor:"transparent"})}),dt({target:n,props:this.control.props,fallback:w(d({},B),{borderAlpha:0}),dependsOn:this.container.dimensions}),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(j.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(j.disabled)}getElement(){return this.controlElement}};var ft=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 vt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new er(r,e)},er=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(j.common,j.button),n.setAttribute("data-testid",le.BUTTON),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),ht({target:n,props:this.control.props,fallback:B}),dt({target:n,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),ut({target:n,props:w(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=ft(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;pt({target:s,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(j.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(j.disabled)}getElement(){return this.controlElement}};var wn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new tr(r,e)},tr=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(j.common,j.text),n.setAttribute("data-testid",le.TEXT),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),ut({target:n,props:w(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=ft(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;pt({target:s,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){}enable(){}getElement(){return this.controlElement}};var rr="interactive-container",U={common:rr,hidden:`${rr}-hidden`,disabled:`${rr}-disabled`};var yt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e,t)},nr=class extends Ee{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new lt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",vt),this.addControlFactory("text",wn),this.addControlFactory("area",mt)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(U.common,U.disabled),requestAnimationFrame(()=>{n.classList.remove(U.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(U.hidden)}show(){let t=this.getElement();t&&t.classList.remove(U.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(U.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(U.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}};var $o=ee(Nr(),1),S=require("@vkontakte/videoplayer-shared/es2015"),Ne=require("@vkontakte/videoplayer-statistics/es2015");var Ms=require("@vkontakte/videoplayer-shared/es2015");function We(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var pe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Ke=r=>pe(r,"Object"),At=r=>pe(r,"String"),Ot=r=>pe(r,"Array"),Rt=r=>pe(r,"Number"),Rs=r=>pe(r,"Function");var Lr=r=>Rt(r)&&!isNaN(r);var he=r=>Ke(r)&&Object.keys(r).length===0,jr=r=>Ot(r)&&!r.length;var Qe=(r,e)=>At(r)&&(e?r.trim():r).length;var ks="video_interactive",Ps="videoint";var Vs=250,Xe=class{constructor(e){this.handleZoomChange=We(e=>{this.lastZoomInfo=e},Vs);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)),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,!Rt(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:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),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=uu(e),this.resizeObserver=new ResizeObserver(We(this.onResize,Vs)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return V(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return V(this,null,function*(){var n;if(!this.manifest)return;let e;try{e=yield(0,Ms.loadVKLangPack)(this.lang,ks,Ps)}catch(i){(n=this.onError)==null||n.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",o=>{var c=o,{name:i}=c,s=J(c,["name"]);var a;i==="openPreview"&&"chapterId"in s&&((a=this.onOpenPreviewClick)==null||a.call(this,s.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 uu(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 Ye=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 s of this._containers){let o=s.startTime-e;if(o<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<o&&(t=t===-1?o:Math.min(t,o))}return!n&&t!==-1?t:null}}};var I=require("@interactiveplatform/movika-manifest");var Ns={metadata:"Object",chapters:"Array"},$r=r=>{if(!Ke(r))return!1;for(let e in Ns)if(!r[e]||!pe(r[e],Ns[e]))return!1;return(0,I.isSupportedManifest)(r.metadata.version)},Ze=r=>r.type===I.ControlTypes.Text,pu=r=>r.type===I.ControlTypes.Button,hu=r=>r.type===I.ControlTypes.Area,du={Choice:"Choice",TextInput:"TextInput"},mu={Button:"Button",Area:"Area",Text:"Text"},fu={onClick:"onClick",onSuspense:"onSuspense"},_r={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var q=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var kt=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 Pt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Rs(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 qs=require("@vkontakte/videoplayer-shared/es2015");var Vt=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:[]}}exec(e,t){return V(this,null,function*(){return vu(...this.loaders[e])(t)})}};function vu(...r){return function(t){return V(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Je(r,e,t){return r?w(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Mt(i){var s=i,{actions:r,errors:e,chapterId:t}=s,n=J(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest();if(o){let c=r.getChapter(o.chapters,t);if(c){let a=r.getMedia(o.media,c.videoId),l=r.getGraph(o.graph,c.id);return a?w(d({},n),{actions:r,errors:e,result:{chapter:c,media:a,graph:l}}):w(d({},n),{errors:Je(e,Mt.name,"Could not find media"),actions:r})}}}return w(d({},n),{errors:Je(e,Mt.name,"Could not find chapter"),actions:r})}var Nt=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,s=n.length;i<s;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,s=n.length;i<s;i++){let o=n[i];try{o.callback.call(this,e)}catch(c){Promise.resolve().then(()=>{throw c})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Re=class extends Nt{constructor(){super(),this.listeners||Nt.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)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Re,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&&(et.prototype[Symbol.toStringTag]="AbortController",Re.prototype[Symbol.toStringTag]="AbortSignal");function Lt(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 Fr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Lt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(l,f){let y;f&&f.signal&&(y=f.signal,delete f.signal);let b=new t(l,f);return y&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),b},s.prototype=t.prototype);let o=e;return{fetch:(a,l)=>{let f=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(f){let y;try{y=new DOMException("Aborted","AbortError")}catch(g){y=new Error("Aborted"),y.name="AbortError"}if(f.aborted)return Promise.reject(y);let b=new Promise((g,A)=>{f.addEventListener("abort",()=>A(y),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([b,o(a,l)])}return o(a,l)},Request:s}}var tt=Lt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ls=tt?Fr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qr=tt?Ls.fetch:window.fetch,Qm=tt?Ls.Request:window.Request,Xm=tt?et:window.AbortController,Ym=tt?Re:window.AbortSignal;var jt=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(t.length,n.length)&&!i;s++)t[s]>n[s]?i=1:t[s]<n[s]?i=-1:i=0;return i};var yu=r=>V(void 0,null,function*(){try{let e={},t;if(At(r)){t=new URL(r).href;let i=yield qr(t);if(!i.ok)return{};e=yield i.json()}else if(Ke(r))e=r;else return{};if(!$r(e))return{};let n=e.metadata.media;if(At(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let s=yield qr(i);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(i){return gu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function js(r){return V(this,null,function*(){let{manifest:e,manifestURL:t}=yield yu(r);if(!e)throw new Error("Failed on fetch");let n=(0,I.migrateManifestToLatestVersion)(e);return n.media=bu(n.media,t),delete n.metadata.media,n})}function $t(r,e){if(e)return r.find(t=>t.id===e)}function Br(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 Dr(r,e){return r.videos.find(t=>t.id===e)}function bu(r,e){return w(d({},r),{videos:r.videos.map(t=>w(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",s=Cu(i,e);return w(d({},n),{url:s||i})})}))})}function Cu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function gu(r){return jt(r,"3.2.0")>=0}var _t=r=>Ot(r)&&!jr(r),Y=r=>r.order==="end",rt=r=>Ot(r.containers)&&!jr(r.containers)&&Y(r),$s=(r,e)=>{var n;let t=r*1e3;return _t(e.controls)&&t<((n=e.startTime)!=null?n:0)},Hr=(r,e)=>{var n,i;let t=r*1e3;return _t(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"),Ur=(r=[])=>r.find(e=>e.action.type==="expect"),Eu=r=>(r==null?void 0:r.length)===1,me=r=>Eu(r)&&Ze(r[0]);function _s(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var Fs=(r,e)=>{let t=E=>{let v=e.find(({container:k})=>k.container.id===E);return v==null?void 0:v.container.isRemoved},n=de(r.events)&&!t(r.id),i=(E,v=!1,k=!1)=>{let h=k?"every":"some";return E.controls[h](u=>{var x;let m=v?E.endTime===r.endTime:!0;return((x=u.events)==null?void 0:x[h](T=>{var C;return((C=T.action)==null?void 0:C.type)===_r.openURI}))&&m})},s=E=>E.some(({container:v})=>i(v.container,!0,!1)&&!v.isRemoved),o=E=>E.every(({container:v})=>v.isRemoved?!0:i(v.container,!0,!0)),c=e.filter(({container:E})=>E.container.id!==r.id&&de(E.container.events)&&E.container.endTime===r.endTime&&!E.isRemoved).length,a=E=>E.controls.some(v=>{var k;return(k=v.events)==null?void 0:k.some(h=>{var u,m;return(m=(u=h.action)==null?void 0:u.args)==null?void 0:m.shouldOpenNow})}),l=n||c>0,f=s(e),y=i(r),b=o(e),g=n?!1:c>0,A=a(r);return{isExpectTime:l,hasOtherExpect:c>0,hasOpenURIEvent:f,hasOpenURIEventInCurrentContainer:y,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:A}};var fe=class extends Vt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new qs.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}setManifest(t){return V(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Je},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield js((i=n.result)!=null?i:t),this})}setInitial(){return V(this,null,function*(){return this.setNext()})}setNext(){return V(this,arguments,function*(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=yield this.exec("chapterLoaders",Mt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Br,getChapter:$t,getMedia:Dr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},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=$t(this.manifest.chapters,t);if(i){let s=Dr(this.manifest.media,i.videoId),o=Br(this.manifest.graph,i.id);if(s)return{chapter:i,media:s,graph:o}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,s,o;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let c=$t(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(c==null?void 0:c.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),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?Y(this.chapter):!1}};var Oa=ee(Ft(),1),Ra=require("@vkontakte/videoplayer-core/es2015"),oe=require("@vkontakte/videoplayer-shared/es2015");var ga=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 Ea=ee(Ft(),1);function Kr(){let r=new Map;function e(a){var l=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=l,c=J(l,["listId","itemId"]);let f=r.get(s),y=d({},c);return f?f[o]=y:r.set(s,{[o]:y}),d({listId:s,itemId:o},c)}function t(s){var o,c;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(c=s.statistics)==null||c.statSubscription.unsubscribe()}function n(s,o){let c=r.get(s);if(!c)throw Error("Can't remove. Not find.");if(o){let a=c[o];a&&t(a),delete c[o],Object.keys(c).length||r.delete(s)}else{for(let a of(0,Ea.default)(c))t(a);r.delete(s)}}function i(){for(let s of r)n(s[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var ke=ee(qt(),1);function Qr(r,e=[]){var s,o,c;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,ke.default)(e,"mp4"))&&(t.MPEG=w(d({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,ke.default)(e,"mpeg"))&&(t.MPEG=w(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(i||(0,ke.default)(e,"hls"))&&(t=w(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,ke.default)(e,"dash"))&&(t=w(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(c=r.title)!=null?c:""}}var nt=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,ke.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var lp=2;function Xr(r){let e=Kr(),t=new oe.Subscription,n={},i=null,s=!1,o,c=new oe.ValueSubject(null);r&&a(r);function a(v){i=v}function l(v,k,h){var x;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let m=((x=e.map.get(v))!=null?x:{})[k];if(m){n=d({chapterId:h,listId:v,itemId:k},m);let T=n.player;n.subscription.add(T.info.currentQuality$.subscribe(C=>{let R=T.info.position$.getValue(),F=T.info.isAutoQualityEnabled$.getValue();if(!(!C||!R||F))for(let P of e.map)(0,Oa.default)(P[1]).forEach(({player:N})=>{nt(N,C)})})).add(T.events.started$.subscribe(()=>{f(k)})),m.container.remove(),i.setPlayer(m.player),s||(i.init(),s=!0),c.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function f(v){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(he(n)||v!==n.itemId)return;let k=i.getChapterBranches(),h=new Set;for(let u of k)h.has(u.media.id)||(yield b({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),h.add(u.media.id))})}function y(h){return V(this,arguments,function*({chapter:{id:v},manifestVideo:k}){if(he(n)||!i)return;let u=n.player.info.muted$.getValue(),m=n.player.info.currentQuality$.getValue(),x=n.player.info.isAutoQualityEnabled$.getValue(),T=n.player.info.volume$.getValue(),C=n.player.info.currentPlaybackRate$.getValue(),R=!x,F=!1;for(let P of e.map)if(P[0]===k.id&&!i.state.isReplay$.getValue()){let N=Object.keys(P[1]);for(let $ of N)$===n.itemId?(N.length<lp||(F=!0),e.removePlayer(P[0],$)):(F=!0,l(P[0],$,v),R?nt(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u),n.player.setPlaybackRate(C))}else e.removePlayer(P[0]);F||(yield b({media:k,chapterId:v,setAsActive:!0,playbackRate:C}),R?nt(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u))})}function b(R){return V(this,arguments,function*({media:v,chapterId:k,prefetch:h=!0,setAsActive:u=!0,autoplay:m=!1,preferredExt:x,title:T,playbackRate:C}){var on,cn,ln,un,pn;let F=Math.random().toString(),P=document.createElement("div");o.append(P);let N;if((on=i==null?void 0:i.options)!=null&&on.vkVideoLoader){let ot=ga(v);ot.length&&(N=yield i.options.vkVideoLoader(...ot))}let $=((cn=i==null?void 0:i.options)==null?void 0:cn.coreConfig)||void 0,Z=w(d({},$),{configName:[...(ln=$==null?void 0:$.configName)!=null?ln:[],"interactive"]}),ce=w(d({container:P},((un=N==null?void 0:N.videos)==null?void 0:un[0])||{sources:Qr(v,x).sources}),{title:T,failoverHosts:(N==null?void 0:N.failoverHosts)||[]}),D=new Ra.Player(Z,oe.Tracer.createRootTracer());D.initVideo(ce);let Ce=null;if(N!=null&&N.videos&&(i!=null&&i.options.createOneStat)){let ot=N.videos[0],Kt=i.options.createOneStat(ot),hn=new oe.Subscription;Kt&&(hn.add(Kt.attachTo(D)),Ce={oneStat:Kt,statSubscription:hn})}let an=new oe.Subscription,qo=(pn=n==null?void 0:n.player)==null?void 0:pn.info.isAutoQualityEnabled$.getValue();an.add(D.events.canplay$.subscribe(function(){qo||nt(D,n.player.info.currentQuality$.getValue()),C&&D.setPlaybackRate(C)}));let ge=e.createPlayer({listId:v.id,itemId:F,player:D,container:P,sources:Qr(v,x).sources,config:ce,subscription:an,statistics:Ce});return u&&l(v.id,ge.itemId,k),m&&ge.player.play(),h&&!m&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}})}function g(){A(),i=null,o.remove()}function A(){t.unsubscribe(),e.removeAll(),n={},s=!1}function E(){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");A(),o=document.createElement("div");let{media:v,chapter:k}=i.getCurrentChapter();v&&k?(t.add(i.events.chapterChanged$.subscribe(y)),yield b({media:v,chapterId:k.id,title:k.label})):console.error("not found")})}return w(d({},e),{init:E,setInteractiveController:a,createPlayer:b,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:c})}var M={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"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Pa=ee(qt(),1),Va=require("@vkontakte/videoplayer-shared/es2015");var Bt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:o,globalEventEmitter:c,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:f,disabledControls$:y,onRemove:b}){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,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:o}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&o)return;this.emitContainerVisibilityEvent(!0,!1)}else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(a,l)=>{let{isExpectTime:f,hasOtherExpect:y,hasOpenURIEvent:b,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:A,hasShouldOpenNowEvent:E}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!g,k=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let h=!y&&!A&&g;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&b&&this.gameState!==5){if(k){let u=((m,x,T,C)=>!m&&!x&&T||m&&!x&&T&&!C||m&&!x&&T&&C)(f,y,A,this.isSelectedContainerEvent);this.fakeRemoveView(u)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!f||!y||!E)&&(this.selectBranches.stopExpect(),l())}},isEOV:()=>this.gameState===4},c=_s(this.selectBranches.onControlEvent,o);this.container.createView({eventCallback:c}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(i=this.container).disable)==null||s.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,f,y;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Pa.default)(i,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if($s(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Hr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,A=this.interactiveTimeOpenUri&&b;if(A&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((f=(l=this.container).hide)==null||f.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!A&&this.removeView()}let o=Hr(s,this.container.container),c=this.container.container.startTime?[this.container.container.startTime,(y=this.container.container.endTime)!=null?y:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:c,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(M.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Va.Subscription,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&me(t.container.controls),this.interactiveTimeOpenUri=f,this.disabledControls$=y,this.onRemove=b,this.globalEventEmitter=c,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(M.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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(M.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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,s;e?(n=(t=this.container).disable)==null||n.call(t):(s=(i=this.container).enable)==null||s.call(i)}))}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)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(M.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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()}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 Ma=(r=[])=>r.reduce((e,t,n)=>{var s,o,c;let i=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!Ze(a));if(_t(i)){let a=[(o=t.startTime)!=null?o:0,(c=t.endTime)!=null?c:1/0],l={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:a});else{let f=[],y=-1/0,b=1/0,g=[],A=[];for(let E=0;E<e.length;E++){let v=e[E];if(A.push(...v.subjects),v.range[0]<b&&(b=v.range[0]),v.range[1]>y&&(y=v.range[1]),a[0]>=v.range[0]&&a[1]<=v.range[1])return e[E].subjects.push(l),e;a[0]<v.range[0]&&a[1]>v.range[0]&&(f.push(E),g=g.concat(v.subjects)),a[0]>=v.range[0]&&a[0]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[0]=v.range[0]),a[1]>=v.range[0]&&a[1]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[1]=v.range[1])}if(A.push(l),a[0]<=b&&a[1]>=y)return[{subjects:A,range:a}];f.length&&f.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([l]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var fo=ee(qt(),1),en=ee(Ft(),1),vo=ee(ho(),1);function mo(){let r={};function e(){for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&delete r[c]}function t(c){let a={};for(let l in r)+l<=c&&(a[l]=r[l]);return a}function n(c){let a={};for(let l in r)+l>=c&&(a[l]=r[l]);return a}function i({timestamp:c,priority:a,initiator:l}){var f;if(Lr(c)){let y=(f=r[c])!=null?f:null;if(y&&a&&Qe(a,!0)){let b={},g=y[a];if(g&&(b=d(d({},b),g)),b=he(b)?null:b,b&&Qe(l,!0)){let A=b[l];return A!=null?A:null}return b}return y}return null}function s({timestamp:c,priority:a,initiator:l}){if(Lr(c))if(r[c]){if(a&&Qe(a,!0))if(r[c][a]){if(l&&Qe(l,!0))if(r[c][a][l]){if(delete r[c][a][l],!he(r[c][a]))return!0}else return!1;if(delete r[c][a],!he(r[c]))return!0}else return!1;return delete r[c]}else return!1;return!1}function o(y){var b=y,{timestamp:c,priority:a,initiator:l}=b,f=J(b,["timestamp","priority","initiator"]);var g,A,E;(A=(g=r[c])==null?void 0:g[a])!=null&&A[l]?r[c][a][l].push(d({},f)):(E=r[c])!=null&&E[a]?r[c][a]=w(d({},r[c][a]),{[l]:[d({},f)]}):r[c]?r[c]=w(d({},r[c]),{[a]:{[l]:[d({},f)]}}):r[c]={[a]:{[l]:[d({},f)]}}}return{map:r,remove:s,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var Yp=[I.EventActionTypes.expect,I.EventActionTypes.setNextBranch],Zp=1/0;function yo(r,e){let t=r,n,i=Jp(e),s=mo(),o,c=()=>{g(),h()},a=u=>{s.add.call(void 0,u),E()},l=(u=[])=>{for(let m of u)if(m.action(),(0,fo.default)(Yp,m.actionType))break},f=(u=1/0)=>{var C,R,F;let m=Ht((C=s.get({timestamp:u,priority:"control"}))!=null?C:{}),x=Ht((R=s.get({timestamp:u,priority:"container"}))!=null?R:{}),T=Ht((F=s.get({timestamp:u,priority:"chapter"}))!=null?F:{});return[...m,...x,...T]},y=u=>{i.isReady(u)&&l(f(u))},b=()=>{var u;l([...Ht((u=s.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},g=()=>{n&&(o==null||o.unsubscribe(),n=void 0)},A=u=>{},E=()=>{n||(n=()=>setTimeout(()=>{y(1/0)}),o=t.events.ended$.subscribe(n))},v=u=>{g(),t=u},k=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),s.remove(u)},h=()=>{i.release(),s.removeAll()};return{setPlayer:v,add:a,remove:k,exec:y,execEndOfVideo:b,listen:E,unlisten:g,release:c,containersEventsCallState:i,getPreparedToExecActions:f}}function Jp(r){let e=new Map;return{setCalled:({timestamp:c,id:a})=>{let l=e.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a;for(let l of c){let f=(a=l.endTime)!=null?a:Zp,y=e.get(f);e.set(f,w(d({},y),{[l.id]:!1}))}},resetCalled:c=>{let a=e.get(c);if(a)for(let l in a)a[l]=!1},isReady:c=>{let a=e.get(c);if(!a)return!0;let l=(0,en.default)(a);return r?l.some(y=>y):!l.some(y=>!y)},release:()=>e.clear()}}function Ht(r){return(0,vo.default)((0,en.default)(r)).sort(e=>e.actionType===I.EventActionTypes.expect?-1:1)}var bo={videoContentHeight:0,videoContentWidth:0},Co=(r,e)=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return bo;let{clientHeight:i,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(i&&s))return bo;let o=t/n,c=i/s,a,l;return c>o?(l=s,a=s*o):c<o?(l=i/o,a=i):(l=s,a=i),{videoContentWidth:l,videoContentHeight:a}};var eh=250;function go(r){let e=()=>{},t=new ResizeObserver(c=>{s(c),e=s.bind(null,c)});function n(c){let{parentElement:a,player:l}=r();if(a&&l){let{videoContentWidth:f,videoContentHeight:y}=Co(a,l);a.style.setProperty("--interactive-content-width",`${f}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${c[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${c[0].contentRect.height}px`)}}function i(){let{parentElement:c}=r();c.removeAttribute("style")}let s=We(c=>{let{fns:a=[]}=r();n(c);for(let l of a)l()},eh);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var th=r=>Math.floor(Math.random()*r),Io=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:1;o<t&&(t=o,n=s)}return n},xo=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:0;o>t&&(t=o,n=s)}return n};var To=r=>{let e=r.length,t=th(e);return r[t]},Eo=1,So=r=>{var n,i;let e=0;for(let s=0;s<r.length;++s)e+=(n=r[s].weight)!=null?n:Eo;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(i=r[s].weight)!=null?i:Eo,e>=t)return r[s];return r[r.length-1]};var wo={shouldOpenNow:!0,isDetachContainer:!0},Ao="after-expect";var tn=(r,e=!1)=>w(d({},r),{args:e?d(d({},r.args),wo):d(d({},wo),r.args)}),ko=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:h,controlType:u,controlId:m,containerId:x,branches:T=[],onEvent:C,isEOV:R=()=>!1,isDisabled:F=()=>!1})=>{let P=tn(h,R()),N={timestamp:1/0,priority:"control",initiator:m,actionType:P.type},$=F(),Z=r.emit.bind(r,M.interactives,{subjectId:m,subjectType:u,subjectName:"control",type:$?L.actionChoiceCanceled:L.actionChoice,actionType:h.type,payload:d({invokeImmediately:P.args.shouldOpenNow,containerId:x},P.args)}),ce=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:u,subjectName:"control",type:$?"action-choice-canceled":"action-choice",actionType:h.type,payload:d({invokeImmediately:P.args.shouldOpenNow,containerId:x},P.args)})};if($){Z(),ce();return}switch(P.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let D=T.find(Ce=>Ce.id===P.args.branchId);if(!D)return;C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?E({subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{chapterId:D.chapterId,autoSelect:!1}}):n.add(w(d({},N),{action:E.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{chapterId:D.chapterId,autoSelect:!1}})}));return}case I.EventActionTypes.continuePlayback.trim().toLowerCase():{C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?A({subjectId:m,subjectName:"control",subjectType:u,action:h}):n.add(w(d({},N),{action:A.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:h})}));return}case I.EventActionTypes.openURI.trim().toLowerCase():{C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?k({subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{URI:h.args.uri}}):n.add(w(d({},N),{action:k.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{URI:h.args.uri}})}));return}default:{let D="Unexpected control event",Ce=new q(1,1,{message:D});f(Ce,D);return}}},c=({action:h,container:{id:u,endTime:m},branches:x=[],isEOV:T=!1,autoSelected:C=!1})=>{let R=tn(h,T),F={timestamp:!R.args.shouldOpenNow||T?1/0:m!=null?m:1/0,priority:"container",initiator:u,actionType:R.type},P=r.emit.bind(r,M.interactives,{subjectId:u,subjectName:"container",type:L.actionChoice,actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),N=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)})};switch(R.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let $=x.find(Z=>Z.id===R.args.branchId);if(!$)return;P(),N(),n.add(w(d({},F),{action:E.bind(null,{subjectId:u,subjectName:"container",action:R,payload:{chapterId:$.chapterId,autoSelect:C}})}));return}case I.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case I.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case I.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case I.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case I.EventActionTypes.continuePlayback.trim().toLowerCase():{P(),N(),n.add(w(d({},F),{action:A.bind(null,{subjectId:u,subjectName:"container",action:R})}));return}case I.EventActionTypes.openURI.trim().toLowerCase():{P(),N(),n.add(w(d({},F),{action:k.bind(null,{subjectId:u,subjectName:"container",action:R,payload:{URI:h.args.uri}})}));return}default:{let $="Unexpected container event",Z=new q(1,1,{message:$});f(Z,$);return}}};function a({container:h,branches:u,isEOV:m=!1}){var T,C;let x=Ur(h.events);if(x){let R=tn(x.action,m);r.emit(M.interactives,{subjectId:h.id,subjectName:"container",type:L.actionChoice,actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),n.add({timestamp:m?1/0:(T=h.endTime)!=null?T:1/0,priority:"container",initiator:h.id,actionType:I.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let R of(C=h.events)!=null?C:[])c({action:R.action,container:h,branches:u,isEOV:m})}let l=({chapterId:h,action:u,branches:m=[]})=>{let x=r.emit.bind(r,M.interactives,{subjectId:h,subjectName:"chapter",type:L.actionChoice,actionType:u.type,payload:u.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let C=m.find(R=>R.id===u.args.branchId);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let C=To(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setRandomBranch.trim().toLowerCase():{let C=So(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let C=xo(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let C=Io(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.continuePlayback.trim().toLowerCase():return x(),T(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u});case I.EventActionTypes.openURI.trim().toLowerCase():return x(),T(),k.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let C="Unexpected chapter event",R=new q(1,1,{message:C});f(R,C);return}}};function f(h,u){console.error(u),e.error$.next(h),r.emit(M.errors,h)}function y(h){var m;let u=Ur(h.events);if(u){if(Y(h))return;r.emit(M.interactives,{subjectId:h.id,subjectName:"chapter",type:L.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:I.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(m=h.events)==null||m.forEach(x=>{let T=l({chapterId:h.id,action:x.action,branches:h.branches});T&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:x.action.type,action:T})})}let b=({subjectId:h,subjectName:u})=>{t.pause(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:L.actionExecution,actionType:I.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:I.EventActionTypes.expect})},g=({subjectId:h,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:L.actionExecution,actionType:Ao}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:Ao})},A=({subjectId:h,subjectName:u,subjectType:m,action:x})=>{r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type})},E=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{T.behaviour="change-chapter",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type,payload:T})},v=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{T.behaviour="change-manifest",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type,payload:T})},k=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{if(!T.URI)return;let C=window.open(T.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type})};return{onControlEvent:o,onContainerEvent:c,onChapterEvent:l,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:y,setManifestContainerEvents:a,stopExpect:s,state:i}};var sn=ee(Nr(),1),K=require("@vkontakte/videoplayer-shared/es2015");var Ut=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(o=>o.id===n);if(!i)return null;let s=e.media.videos.find(o=>i.videoId===o.id);if(!s)return null;t[n]=rn(s)}return t[n]}).filter(Boolean)},Po=r=>{for(let e of r.variants)if(Vo(e)&&e.payload)return e.payload.id},Vo=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),rn=r=>{let e=Po(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Mo=(r,e)=>{for(let t of r.media.videos)if(e===rn(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},nn=(r,e)=>r.reduce((t,n)=>{let i=Mo(e,n);return i?[...t,i]:t},[]);var ne,ve,ye,W,Gt,ie,se,re,be,Ve,Me,st=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new K.ValueSubject([]),hasPrevChapter$:new K.ValueSubject(!1),prevChapter$:new K.ValueSubject(null),isInitialChapter$:new K.ValueSubject(!1),isGoBackLimited$:new K.ValueSubject(!1)};H(this,ne,null);H(this,ve);H(this,ye,!1);H(this,W,null);H(this,Gt,null);this.events={inited$:new K.Subject,destroyed$:new K.Subject,error$:new K.Subject};H(this,ie,null);H(this,se,null);H(this,re,null);H(this,be,new K.Subscription);H(this,Ve,!1);H(this,Me,0);var o;_(this,ie,t),_(this,re,e),_(this,se,n),_(this,ne,i),_(this,ve,s),this.state.history$&&O(this,be)&&((o=O(this,be))==null||o.add(this.state.history$.subscribe(c=>{var a,l;this.state.prevChapter$.next((0,sn.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((l=(a=O(this,W))==null?void 0:a.metadata)==null?void 0:l.initChapterId)),this.state.isGoBackLimited$.next(O(this,Me)===O(this,ve).maxLength-1)})))}setManifest(e){return V(this,null,function*(){if(!O(this,se)||!O(this,re))return;_(this,W,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield O(this,se).setChapter({chapterId:t,pushToHistory:!1}),O(this,ye)||(_(this,ye,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return O(this,ye)}updateHistory(e,t=!0){return V(this,null,function*(){var c;if(!O(this,W))return;O(this,Ve)?(_(this,Ve,!1),bn(this,Me)._++):_(this,Me,0);let n=O(this,W),i=e.length-O(this,ve).maxLength,s=i>0?e.slice(i):e,o=Ut(s,n);if(_(this,Gt,o),this.state.history$.next(s),!(!t||!O(this,ne)||!O(this,ie)))try{yield O(this,ne).save(O(this,ie),o)}catch(a){let l=new q(1,5,"Unable to save interactive history");this.events.error$.next(l),(c=O(this,re))==null||c.emit(M.errors,l)}})}goBack(){return V(this,null,function*(){var n;if(!this.state||!O(this,se)){let i=new q(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=O(this,re))==null?void 0:n.emit(M.errors,i)}_(this,Ve,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield O(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return V(this,null,function*(){var i;if(!O(this,W)||!O(this,ie))return;let e=O(this,W),t=[this.getInitialVideoId()];if(O(this,ne))try{let s=yield O(this,ne).get(O(this,ie));s.length&&(t=s)}catch(s){let o=new q(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=O(this,re))==null||i.emit(M.errors,o)}let n=nn(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,sn.default)(e,-1)||O(this,ve).initChapterId||((t=O(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(O(this,W)){let e=this.getInitialChapterId();return Ut([e],O(this,W)).pop()}return null}destroy(){var e,t;_(this,ie,null),_(this,ne,null),_(this,se,null),(e=O(this,be))==null||e.unsubscribe(),_(this,be,null),_(this,ye,!1),(t=O(this,re))==null||t.emit(M.historyDestroyed),this.events.destroyed$.next(),_(this,re,null)}};ne=new WeakMap,ve=new WeakMap,ye=new WeakMap,W=new WeakMap,Gt=new WeakMap,ie=new WeakMap,se=new WeakMap,re=new WeakMap,be=new WeakMap,Ve=new WeakMap,Me=new WeakMap;var zt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var 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 s=3;s<n;s+=40)if(t[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return V(this,null,function*(){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n})}save(){return V(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Wt=class{constructor({parentElement:e,endOffsetMs:t=250,onError: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,78 +11,26 @@
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new er,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new zt,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"}updateCanvasDimensions(e=!1){return V(this,null,function*(){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 Ya(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var xh=`
20
- .${L.common} {
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"}updateCanvasDimensions(e=!1){return V(this,null,function*(){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,s;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((s=t.endTime)!=null?s: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 No(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var nh=`
20
+ .${U.common} {
21
21
  opacity: 1;
22
22
  visibility: visible;
23
23
  transition: opacity var(--interactive-transition-1);
24
24
  }
25
25
 
26
- .${L.disabled} {
26
+ .${U.disabled} {
27
27
  opacity: 0.5;
28
28
  }
29
29
 
30
- .${L.hidden} {
30
+ .${U.hidden} {
31
31
  visibility: hidden;
32
32
  }
33
- `,Ih=`
34
- .${E.blinkAnim} {
35
- animation-duration: 2001ms;
36
- animation-iteration-count: infinite;
37
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
38
- }
39
-
40
- .${E.blinkAnimButton} {
41
- animation-name: blinking-button;
42
- }
43
-
44
- .${E.blinkAnimArea} {
45
- animation-name: blinking-area;
46
- }
47
-
48
- @keyframes blinking-area {
49
- 0%, 100% {
50
- opacity: 1;
51
- }
52
- 50% {
53
- opacity: var(--interactive-area-hover-opacity);
54
- }
55
- }
56
-
57
- @keyframes blinking-button {
58
- 0%, 100% {
59
- opacity: 1;
60
- }
61
- 50% {
62
- opacity: var(--interactive-button-hover-opacity);
63
- }
64
- }
65
- `,Th=`
66
- .${j.common} {
67
- position: absolute;
68
- height: 0;
69
- width: 0;
70
- top: 0;
71
- left: 0;
72
- pointer-events: none;
73
- }
74
-
75
- .${j.animation} {
76
- animation-duration: 2001ms;
77
- animation-iteration-count: infinite;
78
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
79
- animation-name: blinking-button;
80
- }
81
-
82
- .${j.disabled} {
83
- animation: none;
84
- }
85
- `,Sh=`
33
+ `,ih=`
86
34
  .interactive-chapter {
87
35
  position: absolute;
88
36
  top: 0;
@@ -90,61 +38,23 @@
90
38
  font-family: inherit;
91
39
 
92
40
  --interactive-transition-1: 100ms ease-in-out;
93
- --interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
94
- --interactive-button-hover-opacity: 0.8;
95
- --interactive-area-hover-opacity: 0;
96
41
  }
97
42
 
98
- ${xh}
43
+ ${nh}
99
44
 
100
- .${E.common} {
45
+ .${j.common} {
101
46
  display: flex;
102
47
  width: 100%;
103
48
  height: 100%;
104
49
  font-family: inherit;
105
-
106
- position: relative;
107
- isolation: isolate;
108
- opacity: 1;
109
-
110
- box-shadow: none;
111
- border: none;
112
50
  }
113
51
 
114
- .${E.disabled} {
52
+ .${j.disabled} {
115
53
  cursor: default;
116
54
  }
117
55
 
118
- .${E.button},
119
- .${E.area} {
56
+ .${j.button},
57
+ .${j.area} {
120
58
  cursor: pointer;
121
59
  }
122
-
123
- .${E.button} {
124
- transition: opacity var(--interactive-transition-2);
125
- }
126
-
127
- .${E.area} {
128
- transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
129
- }
130
-
131
- .${L.common}.${L.disabled} .${E.button},
132
- .${L.common}.${L.disabled} .${E.area} {
133
- animation: none;
134
- }
135
-
136
- .${L.common}:not(.${L.disabled}) .${E.button}:not(.${E.selected}):not(.${E.blinkAnim}):hover,
137
- .${L.common}:not(.${L.disabled}) .${E.button}:not(.${E.selected}):not(.${E.blinkAnim}):focus-visible {
138
- opacity: var(--interactive-button-hover-opacity);
139
- animation: none;
140
- }
141
-
142
- .${L.common}:not(.${L.disabled}) .${E.area}:not(.${E.selected}):not(.${E.blinkAnim}):hover,
143
- .${L.common}:not(.${L.disabled}) .${E.area}:not(.${E.selected}):not(.${E.blinkAnim}):focus-visible {
144
- opacity: var(--interactive-area-hover-opacity);
145
- animation: none;
146
- }
147
-
148
- ${Ih}
149
- ${Th}
150
- `,Za=r=>{let e=document.createElement("style");e.textContent=Sh,r.prepend(e)};var Ah=typeof window=="undefined",wh=typeof OffscreenCanvas!="undefined";function Ja(){return Ah?wh?new OffscreenCanvas(1,1):null:document.createElement("canvas")}function el(r){return(r[0]*299+r[1]*587+r[2]*114)/1e3<128}var vn=[0,0,0,0],tl=1,Rh="AverageColor: ";function rr(r){return Error(Rh+r)}function yn(r){let e=window.getComputedStyle(r),t=parseFloat(e.getPropertyValue("--interactive-content-width"))||0,n=parseFloat(e.getPropertyValue("--interactive-content-height"))||0;return{width:t,height:n}}var dt=class{constructor(){this.canvas=null;this.ctx=null}getColorAsync(e,t){let n=this.getColor(e,t);return n.error?Promise.reject(n.error):Promise.resolve(n)}getColor(e,t){var i,o;let n=T(d({},t),{step:t.step||tl,defaultColor:(i=t.defaultColor)!=null?i:vn,debug:(o=t.debug)!=null?o:!1});if(!this.canvas&&(this.canvas=Ja(),!this.canvas))return this.prepareResult(n.defaultColor,rr("Failed to create canvas"));if(!this.ctx){if(this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),!this.ctx)return this.prepareResult(n.defaultColor,rr("Failed to create context of the canvas"));this.ctx.imageSmoothingEnabled=!1}this.canvas.width=n.width,this.canvas.height=n.height;try{this.ctx.clearRect(0,0,n.width,n.height),this.ctx.drawImage(e,0,0,n.width,n.height);let l=this.ctx.getImageData(0,0,n.width,n.height).data,a=this.getColorFromArray(l,n);return this.prepareResult(a)}catch(l){return n.debug&&console.error(l),this.prepareResult(n.defaultColor,rr("Failed on getting average color"))}}getColorFromArray(e,t){let i=e.length;if(i<4)return vn;let o=i-i%4,l=t.step*4;return this.sqrtAlgorithm(e,o,{defaultColor:t.defaultColor,step:l})}sqrtAlgorithm(e,t,n){let i=0,o=0,l=0,a=0,s=0,c=n.step;for(let m=0;m<t;m+=c){let v=e[m],b=e[m+1],g=e[m+2],R=e[m+3];i+=v*v*R,o+=b*b*R,l+=g*g*R,a+=R,s++}return a?[Math.round(Math.sqrt(i/a)),Math.round(Math.sqrt(o/a)),Math.round(Math.sqrt(l/a)),Math.round(a/s)]:n.defaultColor}prepareResult(e,t){let n=`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]/255})`,i=el(e);return{rgba:n,isDark:i,error:t}}destroy(){this.canvas&&(this.canvas.width=1,this.canvas.height=1,this.canvas=null),this.ctx=null}};var rl=Object.freeze({lang:w.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlFrameBasedShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function Oh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var mt=class{constructor(e){this.playerSubscriptions=new w.Subscription;this.subscriptions=new w.Subscription;this.globalEventEmitter=new jt;this.animation=new _t;this.seekToInteractiveController=new rt;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Oh();this.factories=new Map([["choice",Rt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new w.Subscription;this.graph=null;this.lastFrame=null;this.frameAverageColor=null;this.appState=0;this.state={prevChapter$:new w.ValueSubject(null),isInitialChapter$:new w.ValueSubject(!1),isFirstChapter$:new w.ValueSubject(!0),isEndChapter$:new w.ValueSubject(!1),isInteractiveExpectation$:new w.ValueSubject(!1),isReplay$:new w.ValueSubject(!1),calledByInteractive$:new w.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new w.ValueSubject(!1),disabledControls$:new w.ValueSubject(!1),interactiveRanges$:new w.ValueSubject([]),isInteractiveTime$:new w.ValueSubject(!1),statistics$:new w.ValueSubject(null),isSeekable$:new w.ValueSubject(!1)};this.events={noInteraction$:new w.Subject,graphVisibilityChanged$:new w.Subject,watchAgainIsClicked$:new w.Subject,chapterChanged$:new w.Subject,playerChanged$:new w.Subject,error$:new w.Subject,eachTick$:new w.Subject,manifestChanged$:new w.Subject,interactiveRangeEnded$:new w.Subject,interactiveContainerRemoved$:new w.Subject,interactiveContainerFakeRemoved$:new w.Subject,interactiveActionExecution$:new w.Subject,interactiveActionChoice$:new w.Subject,interactiveVisibilityChanged$:new w.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(M.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&&J(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=te(i,["statistics"]);if(t){let{statSubscription:o,oneStat:l}=t;o.add(l.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(M.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=>T(d({},o),{subjects:o.subjects.filter(l=>l.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var i,o,l;this._options=T(d(d({},rl),e),{config:d(d({},rl.config),e.config)}),((i=this._options.animationsFeatureToggles)==null?void 0:i.controlsExpectTimeBlinkAnimation)&&this.rootElement.append(qn()),this._options.parentElement.append(this.rootElement),this.historyController=new ht({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 tr({parentElement:this._options.parentElement,onError:a=>{let s=new D(1,6,a);this.emitErrorEvent(s)}})),Za(this._options.parentElement),this.subscriptions.add((0,w.fromEvent)(this.rootElement,"mousedown").subscribe(a=>a.stopPropagation())).add((0,w.fromEvent)(this.rootElement,"mouseup").subscribe(a=>a.stopPropagation())),this.manifestController=new ge(this._options.loaders,a=>{let s=new D(1,3,a);this.emitErrorEvent(s)});let n=[];this._options.lastFrame&&n.push(()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}),n.push(()=>{let a=this.state.isInteractiveTime$.getValue();for(let s of this.gameControllers)s.onResize(a)}),this.resizeManager=Fa(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new tt({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:a=>{this.setChapter({chapterId:a}),this.globalEventEmitter.emit(M.graph,{type:Le.watchAgainClicked,chapterId:a}),this.events.watchAgainIsClicked$.next(a)},onError:a=>{let s=new D(1,2,{message:a});this.emitErrorEvent(s)}})),(l=this._options.animationsFeatureToggles)!=null&&l.areaControlFrameBasedShadow&&(this.frameAverageColor=new dt),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>V(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield 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)}))}initSeamless(){return V(this,null,function*(){this.seamlessController=sn(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield 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(M.interactives,{type:F.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,w.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,w.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var s;let i;if(n)i=!0;else{let c=e*1e3;i=!!t.find(({range:[v,b],subjects:g})=>v<c&&c<b&&g.some(R=>!R.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let o=!!this.noInteractionTimeout,a=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||n;i&&!o&&a?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!a&&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=>!Ce(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 a,s;let i=n.type.trim().toLowerCase(),o=this.factories.get(i),l=o==null?void 0:o(n,this.rootElement,{features:{areaControlFrameBasedShadow:(a=this._options.animationsFeatureToggles)==null?void 0:a.areaControlFrameBasedShadow,controlsExpectTimeBlinkAnimation:(s=this._options.animationsFeatureToggles)==null?void 0:s.controlsExpectTimeBlinkAnimation}});if(l&&this.selectBranches&&this.interactiveEvents&&this.player){let c=new Qt({player:this.player,container:l,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ds(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(c.whilePlaying,!0),t.push(c)}}),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 a,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(a=n&&J(n)&&lt(n))!=null?a:!1,o=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,nl.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(l=>{let a=l.subjects.some(c=>c.id===e),s=l.subjects.map(c=>t&&a||c.id===e?T(d({},c),{isRemoved:!0}):c);return T(d({},l),{subjects:s})});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 i;if(!((i=this._options.animationsFeatureToggles)==null?void 0:i.controlsExpectTimeBlinkAnimation))return;let n=(o,l)=>{o.toggleBlinkAnimation(l)};if(Wt(T(d({},e),{gameControllers:this.gameControllers,execFn:ut(an(n),e.isExpect)})),e.isExpect){let o=this.rootElement.querySelector(`.${j.common}`);o&&Dn(o)}}updateControlsShadowStyles(e){var n;if(!((n=this._options.animationsFeatureToggles)!=null&&n.areaControlFrameBasedShadow))return;let t=(i,o)=>{i.updateControlsShadowStyles(o)};e.isExpect?this.getVideoFrameAverageColorInfo().then(i=>{if(i&&("isDark"in i&&Wt(T(d({},e),{gameControllers:this.gameControllers,execFn:ut(an(t),i.isDark)})),i.error)){let o=new D(1,1,i.error);this.emitErrorEvent(o)}}):Wt(T(d({},e),{gameControllers:this.gameControllers,execFn:t}))}getVideoFrameAverageColorInfo(){return V(this,null,function*(){if(!this.frameAverageColor||!this.player)return;let e=this.player.experimental.element$.getValue();if(!e||!e.readyState)return;let t=yn(this.rootElement);if(!(!t.width||!t.height))try{return yield this.frameAverageColor.getColorAsync(e,{width:t.width,height:t.height})}catch(n){return{error:n}}})}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())}setManifest(e){return V(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),yield this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(M.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=Ma(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Wa({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return V(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&w.clientChecker.isSafari&&(yield Ya(35));let i=!n&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:o,media:l,graph:a}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!l)&&(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:l}),this.globalEventEmitter.emit(M.chapterChanged,{chapter:o,media:l,graph:a}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new w.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?je.InteractiveInterfaceClick.GRAPH_SHOW:je.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(je.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(je.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(je.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new w.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){return V(this,null,function*(){this.graph&&(e?(yield this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(M.graph,{type:Le.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===x.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&&be(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,x.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 Ys((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,l;this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],(e=this.frameAverageColor)==null||e.destroy(),(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(),(l=this.lastFrame)==null||l.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var il={Container:Ae,createChoiceContainer:Rt,createAreaControl:St,createButtonControl:wt,classnamesPrefix:$n};var kh={version:Pn};
60
+ `,Lo=r=>{let e=document.createElement("style");e.textContent=ih,r.prepend(e)};var _o=require("@vkontakte/videoplayer-core/es2015");var jo=Object.freeze({lang:S.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function sh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var at=class{constructor(e){this.playerSubscriptions=new S.Subscription;this.subscriptions=new S.Subscription;this.globalEventEmitter=new kt;this.animation=new Pt;this.seekToInteractiveController=new Ye;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=sh();this.factories=new Map([["choice",yt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new S.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new S.ValueSubject(null),isInitialChapter$:new S.ValueSubject(!1),isFirstChapter$:new S.ValueSubject(!0),isEndChapter$:new S.ValueSubject(!1),isInteractiveExpectation$:new S.ValueSubject(!1),isReplay$:new S.ValueSubject(!1),calledByInteractive$:new S.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new S.ValueSubject(!1),disabledControls$:new S.ValueSubject(!1),interactiveRanges$:new S.ValueSubject([]),isInteractiveTime$:new S.ValueSubject(!1),statistics$:new S.ValueSubject(null),isSeekable$:new S.ValueSubject(!1)};this.events={noInteraction$:new S.Subject,graphVisibilityChanged$:new S.Subject,watchAgainIsClicked$:new S.Subject,chapterChanged$:new S.Subject,playerChanged$:new S.Subject,error$:new S.Subject,eachTick$:new S.Subject,manifestChanged$:new S.Subject,interactiveRangeEnded$:new S.Subject,interactiveContainerRemoved$:new S.Subject,interactiveContainerFakeRemoved$:new S.Subject,interactiveActionExecution$:new S.Subject,interactiveActionChoice$:new S.Subject,interactiveVisibilityChanged$:new S.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(M.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&&Y(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=J(i,["statistics"]);if(t){let{statSubscription:s,oneStat:o}=t;s.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(M.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(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(s=>w(d({},s),{subjects:s.subjects.filter(o=>o.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n;this._options=w(d(d({},jo),e),{config:d(d({},jo.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new st({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(n=this._options.projectInfo)==null?void 0:n.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Wt({parentElement:this._options.parentElement,onError:i=>{let s=new q(1,6,i);this.emitErrorEvent(s)}})),Lo(this._options.parentElement),this.subscriptions.add((0,S.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,S.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new fe(this._options.loaders,i=>{let s=new q(1,3,i);this.emitErrorEvent(s)});let t=[];this._options.lastFrame&&t.push(()=>{var i;(i=this.lastFrame)==null||i.updateCanvasDimensions(!0)}),this.resizeManager=go(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Xe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(M.graph,{type:Pe.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let s=new q(1,2,{message:i});this.emitErrorEvent(s)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>V(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield 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):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!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.removeControllers(!1)}))}initSeamless(){return V(this,null,function*(){this.seamlessController=Xr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(M.interactives,{type:L.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,S.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,S.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 l=e*1e3;i=!!t.find(({range:[y,b],subjects:g})=>y<l&&l<b&&g.some(A=>!A.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,c=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!s&&c?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!c&&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.filterGameControllers(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)}filterGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i),o=s==null?void 0:s(n,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let c=new Bt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Fs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(c.whilePlaying,!0),t.push(c)}}),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 c,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(c=n&&Y(n)&&rt(n))!=null?c:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(s||i&&t){this.historyController.updateHistory([e]);return}(0,$o.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,s=n.getValue().map(o=>{let c=o.subjects.some(l=>l.id===e),a=o.subjects.map(l=>t&&c||l.id===e?w(d({},l),{isRemoved:!0}):l);return w(d({},o),{subjects:a})});n.next(s)}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}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())}setManifest(e){return V(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),yield this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(M.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=yo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ko({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return V(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,l;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&_o.clientChecker.browser.isSafari&&(yield No(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:s,media:o,graph:c}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&this.state.isFirstChapter$.next(!0),!(!s||!o)&&(t&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),(l=this.lastFrame)==null||l.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:o}),this.globalEventEmitter.emit(M.chapterChanged,{chapter:s,media:o,graph:c}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new S.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 S.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){return V(this,null,function*(){this.graph&&(e?(yield this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(M.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===I.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,I.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 Ma((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,s;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(i=this.interactiveEvents)==null||i.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 Fo={Container:Ee,createChoiceContainer:yt,createAreaControl:mt,createButtonControl:vt,classnamesPrefix:En};var ah={version:Cn};