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