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