@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.esm.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
|
-
var no=Object.create;var Dr=Object.defineProperty;var so=Object.getOwnPropertyDescriptor;var ao=Object.getOwnPropertyNames;var oo=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty;var p=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var lo=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ao(e))!co.call(t,n)&&n!==r&&Dr(t,n,{get:()=>e[n],enumerable:!(i=so(e,n))||i.enumerable});return t};var K=(t,e,r)=>(r=t!=null?no(oo(t)):{},lo(e||!t||!t.__esModule?Dr(r,"default",{value:t,enumerable:!0}):r,t));var U=p((Ft,Qr)=>{"use strict";var fe=function(t){return t&&t.Math===Math&&t};Qr.exports=fe(typeof globalThis=="object"&&globalThis)||fe(typeof window=="object"&&window)||fe(typeof self=="object"&&self)||fe(typeof global=="object"&&global)||fe(typeof Ft=="object"&&Ft)||function(){return this}()||Function("return this")()});var _=p((yh,Yr)=>{"use strict";Yr.exports=function(t){try{return!!t()}catch{return!0}}});var me=p((bh,Xr)=>{"use strict";var po=_();Xr.exports=!po(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var ri=p((gh,ti)=>{"use strict";var ho=me(),ei=Function.prototype,Zr=ei.apply,Jr=ei.call;ti.exports=typeof Reflect=="object"&&Reflect.apply||(ho?Jr.bind(Zr):function(){return Jr.apply(Zr,arguments)})});var q=p((Ch,si)=>{"use strict";var ii=me(),ni=Function.prototype,qt=ni.call,fo=ii&&ni.bind.bind(qt,qt);si.exports=ii?fo:function(t){return function(){return qt.apply(t,arguments)}}});var ve=p((Eh,oi)=>{"use strict";var ai=q(),mo=ai({}.toString),vo=ai("".slice);oi.exports=function(t){return vo(mo(t),8,-1)}});var Bt=p((Ih,ci)=>{"use strict";var yo=ve(),bo=q();ci.exports=function(t){if(yo(t)==="Function")return bo(t)}});var F=p((Th,li)=>{"use strict";var Dt=typeof document=="object"&&document.all;li.exports=typeof Dt>"u"&&Dt!==void 0?function(t){return typeof t=="function"||t===Dt}:function(t){return typeof t=="function"}});var Z=p((xh,ui)=>{"use strict";var go=_();ui.exports=!go(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Xe=p((Sh,pi)=>{"use strict";var Co=me(),Ye=Function.prototype.call;pi.exports=Co?Ye.bind(Ye):function(){return Ye.apply(Ye,arguments)}});var Ht=p(fi=>{"use strict";var hi={}.propertyIsEnumerable,di=Object.getOwnPropertyDescriptor,Eo=di&&!hi.call({1:2},1);fi.f=Eo?function(e){var r=di(this,e);return!!r&&r.enumerable}:hi});var Ut=p((Ah,mi)=>{"use strict";mi.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var yi=p((Rh,vi)=>{"use strict";var Io=q(),To=_(),xo=ve(),Gt=Object,So=Io("".split);vi.exports=To(function(){return!Gt("z").propertyIsEnumerable(0)})?function(t){return xo(t)==="String"?So(t,""):Gt(t)}:Gt});var zt=p((Oh,bi)=>{"use strict";bi.exports=function(t){return t==null}});var Wt=p((Ph,gi)=>{"use strict";var wo=zt(),Ao=TypeError;gi.exports=function(t){if(wo(t))throw new Ao("Can't call method on "+t);return t}});var ye=p((kh,Ci)=>{"use strict";var Ro=yi(),Oo=Wt();Ci.exports=function(t){return Ro(Oo(t))}});var se=p((Mh,Ei)=>{"use strict";var Po=F();Ei.exports=function(t){return typeof t=="object"?t!==null:Po(t)}});var Ze=p((Vh,Ii)=>{"use strict";Ii.exports={}});var Je=p((jh,xi)=>{"use strict";var Kt=Ze(),Qt=U(),ko=F(),Ti=function(t){return ko(t)?t:void 0};xi.exports=function(t,e){return arguments.length<2?Ti(Kt[t])||Ti(Qt[t]):Kt[t]&&Kt[t][e]||Qt[t]&&Qt[t][e]}});var wi=p((Lh,Si)=>{"use strict";var Mo=q();Si.exports=Mo({}.isPrototypeOf)});var Pi=p(($h,Oi)=>{"use strict";var Vo=U(),Ai=Vo.navigator,Ri=Ai&&Ai.userAgent;Oi.exports=Ri?String(Ri):""});var Ni=p((Nh,$i)=>{"use strict";var Li=U(),Yt=Pi(),ki=Li.process,Mi=Li.Deno,Vi=ki&&ki.versions||Mi&&Mi.version,ji=Vi&&Vi.v8,B,et;ji&&(B=ji.split("."),et=B[0]>0&&B[0]<4?1:+(B[0]+B[1]));!et&&Yt&&(B=Yt.match(/Edge\/(\d+)/),(!B||B[1]>=74)&&(B=Yt.match(/Chrome\/(\d+)/),B&&(et=+B[1])));$i.exports=et});var Xt=p((_h,Fi)=>{"use strict";var _i=Ni(),jo=_(),Lo=U(),$o=Lo.String;Fi.exports=!!Object.getOwnPropertySymbols&&!jo(function(){var t=Symbol("symbol detection");return!$o(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&_i&&_i<41})});var Zt=p((Fh,qi)=>{"use strict";var No=Xt();qi.exports=No&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Jt=p((qh,Bi)=>{"use strict";var _o=Je(),Fo=F(),qo=wi(),Bo=Zt(),Do=Object;Bi.exports=Bo?function(t){return typeof t=="symbol"}:function(t){var e=_o("Symbol");return Fo(e)&&qo(e.prototype,Do(t))}});var Hi=p((Bh,Di)=>{"use strict";var Ho=String;Di.exports=function(t){try{return Ho(t)}catch{return"Object"}}});var er=p((Dh,Ui)=>{"use strict";var Uo=F(),Go=Hi(),zo=TypeError;Ui.exports=function(t){if(Uo(t))return t;throw new zo(Go(t)+" is not a function")}});var zi=p((Hh,Gi)=>{"use strict";var Wo=er(),Ko=zt();Gi.exports=function(t,e){var r=t[e];return Ko(r)?void 0:Wo(r)}});var Ki=p((Uh,Wi)=>{"use strict";var tr=Xe(),rr=F(),ir=se(),Qo=TypeError;Wi.exports=function(t,e){var r,i;if(e==="string"&&rr(r=t.toString)&&!ir(i=tr(r,t))||rr(r=t.valueOf)&&!ir(i=tr(r,t))||e!=="string"&&rr(r=t.toString)&&!ir(i=tr(r,t)))return i;throw new Qo("Can't convert object to primitive value")}});var Yi=p((Gh,Qi)=>{"use strict";Qi.exports=!0});var Ji=p((zh,Zi)=>{"use strict";var Xi=U(),Yo=Object.defineProperty;Zi.exports=function(t,e){try{Yo(Xi,t,{value:e,configurable:!0,writable:!0})}catch{Xi[t]=e}return e}});var tt=p((Wh,rn)=>{"use strict";var Xo=Yi(),Zo=U(),Jo=Ji(),en="__core-js_shared__",tn=rn.exports=Zo[en]||Jo(en,{});(tn.versions||(tn.versions=[])).push({version:"3.38.0",mode:Xo?"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 nr=p((Kh,sn)=>{"use strict";var nn=tt();sn.exports=function(t,e){return nn[t]||(nn[t]=e||{})}});var be=p((Qh,an)=>{"use strict";var ec=Wt(),tc=Object;an.exports=function(t){return tc(ec(t))}});var ae=p((Yh,on)=>{"use strict";var rc=q(),ic=be(),nc=rc({}.hasOwnProperty);on.exports=Object.hasOwn||function(e,r){return nc(ic(e),r)}});var sr=p((Xh,cn)=>{"use strict";var sc=q(),ac=0,oc=Math.random(),cc=sc(1 .toString);cn.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+cc(++ac+oc,36)}});var ge=p((Zh,un)=>{"use strict";var lc=U(),uc=nr(),ln=ae(),pc=sr(),hc=Xt(),dc=Zt(),oe=lc.Symbol,ar=uc("wks"),fc=dc?oe.for||oe:oe&&oe.withoutSetter||pc;un.exports=function(t){return ln(ar,t)||(ar[t]=hc&&ln(oe,t)?oe[t]:fc("Symbol."+t)),ar[t]}});var fn=p((Jh,dn)=>{"use strict";var mc=Xe(),pn=se(),hn=Jt(),vc=zi(),yc=Ki(),bc=ge(),gc=TypeError,Cc=bc("toPrimitive");dn.exports=function(t,e){if(!pn(t)||hn(t))return t;var r=vc(t,Cc),i;if(r){if(e===void 0&&(e="default"),i=mc(r,t,e),!pn(i)||hn(i))return i;throw new gc("Can't convert object to primitive value")}return e===void 0&&(e="number"),yc(t,e)}});var or=p((ed,mn)=>{"use strict";var Ec=fn(),Ic=Jt();mn.exports=function(t){var e=Ec(t,"string");return Ic(e)?e:e+""}});var bn=p((td,yn)=>{"use strict";var Tc=U(),vn=se(),cr=Tc.document,xc=vn(cr)&&vn(cr.createElement);yn.exports=function(t){return xc?cr.createElement(t):{}}});var lr=p((rd,gn)=>{"use strict";var Sc=Z(),wc=_(),Ac=bn();gn.exports=!Sc&&!wc(function(){return Object.defineProperty(Ac("div"),"a",{get:function(){return 7}}).a!==7})});var In=p(En=>{"use strict";var Rc=Z(),Oc=Xe(),Pc=Ht(),kc=Ut(),Mc=ye(),Vc=or(),jc=ae(),Lc=lr(),Cn=Object.getOwnPropertyDescriptor;En.f=Rc?Cn:function(e,r){if(e=Mc(e),r=Vc(r),Lc)try{return Cn(e,r)}catch{}if(jc(e,r))return kc(!Oc(Pc.f,e,r),e[r])}});var xn=p((nd,Tn)=>{"use strict";var $c=_(),Nc=F(),_c=/#|\.prototype\./,Ce=function(t,e){var r=qc[Fc(t)];return r===Dc?!0:r===Bc?!1:Nc(e)?$c(e):!!e},Fc=Ce.normalize=function(t){return String(t).replace(_c,".").toLowerCase()},qc=Ce.data={},Bc=Ce.NATIVE="N",Dc=Ce.POLYFILL="P";Tn.exports=Ce});var ur=p((sd,wn)=>{"use strict";var Sn=Bt(),Hc=er(),Uc=me(),Gc=Sn(Sn.bind);wn.exports=function(t,e){return Hc(t),e===void 0?t:Uc?Gc(t,e):function(){return t.apply(e,arguments)}}});var Rn=p((ad,An)=>{"use strict";var zc=Z(),Wc=_();An.exports=zc&&Wc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Pn=p((od,On)=>{"use strict";var Kc=se(),Qc=String,Yc=TypeError;On.exports=function(t){if(Kc(t))return t;throw new Yc(Qc(t)+" is not an object")}});var Vn=p(Mn=>{"use strict";var Xc=Z(),Zc=lr(),Jc=Rn(),rt=Pn(),kn=or(),el=TypeError,pr=Object.defineProperty,tl=Object.getOwnPropertyDescriptor,hr="enumerable",dr="configurable",fr="writable";Mn.f=Xc?Jc?function(e,r,i){if(rt(e),r=kn(r),rt(i),typeof e=="function"&&r==="prototype"&&"value"in i&&fr in i&&!i[fr]){var n=tl(e,r);n&&n[fr]&&(e[r]=i.value,i={configurable:dr in i?i[dr]:n[dr],enumerable:hr in i?i[hr]:n[hr],writable:!1})}return pr(e,r,i)}:pr:function(e,r,i){if(rt(e),r=kn(r),rt(i),Zc)try{return pr(e,r,i)}catch{}if("get"in i||"set"in i)throw new el("Accessors not supported");return"value"in i&&(e[r]=i.value),e}});var Ln=p((ld,jn)=>{"use strict";var rl=Z(),il=Vn(),nl=Ut();jn.exports=rl?function(t,e,r){return il.f(t,e,nl(1,r))}:function(t,e,r){return t[e]=r,t}});var Ie=p((ud,Nn)=>{"use strict";var Ee=U(),sl=ri(),al=Bt(),ol=F(),cl=In().f,ll=xn(),ce=Ze(),ul=ur(),le=Ln(),$n=ae();tt();var pl=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 sl(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?Ee:n?Ee[r]:Ee[r]&&Ee[r].prototype,o=i?ce:ce[r]||le(ce,r,{})[r],a=o.prototype,l,f,m,d,v,R,O,b,w;for(d in e)l=ll(i?d:r+(n?".":"#")+d,t.forced),f=!l&&c&&$n(c,d),R=o[d],f&&(t.dontCallGetSet?(w=cl(c,d),O=w&&w.value):O=c[d]),v=f&&O?O:e[d],!(!l&&!s&&typeof R==typeof v)&&(t.bind&&f?b=ul(v,Ee):t.wrap&&f?b=pl(v):s&&ol(v)?b=al(v):b=v,(t.sham||v&&v.sham||R&&R.sham)&&le(b,"sham",!0),le(o,d,b),s&&(m=r+"Prototype",$n(ce,m)||le(ce,m,{}),le(ce[m],d,v),t.real&&a&&(l||!a[d])&&le(a,d,v)))}});var Fn=p((pd,_n)=>{"use strict";var hl=Math.ceil,dl=Math.floor;_n.exports=Math.trunc||function(e){var r=+e;return(r>0?dl:hl)(r)}});var Te=p((hd,qn)=>{"use strict";var fl=Fn();qn.exports=function(t){var e=+t;return e!==e||e===0?0:fl(e)}});var Dn=p((dd,Bn)=>{"use strict";var ml=Te(),vl=Math.min;Bn.exports=function(t){var e=ml(t);return e>0?vl(e,9007199254740991):0}});var xe=p((fd,Hn)=>{"use strict";var yl=Dn();Hn.exports=function(t){return yl(t.length)}});var it=p((md,Un)=>{"use strict";Un.exports=function(){}});var Gn=p(()=>{"use strict";var bl=Ie(),gl=be(),Cl=xe(),El=Te(),Il=it();bl({target:"Array",proto:!0},{at:function(e){var r=gl(this),i=Cl(r),n=El(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:r[s]}});Il("at")});var nt=p((bd,zn)=>{"use strict";var Tl=Je();zn.exports=Tl});var Kn=p((gd,Wn)=>{"use strict";Gn();var xl=nt();Wn.exports=xl("Array","at")});var Yn=p((Cd,Qn)=>{"use strict";var Sl=Kn();Qn.exports=Sl});var mr=p((Ed,Xn)=>{"use strict";var wl=Yn();Xn.exports=wl});var ds=p((Vf,hs)=>{"use strict";var $l=nr(),Nl=sr(),ps=$l("keys");hs.exports=function(t){return ps[t]||(ps[t]=Nl(t))}});var ms=p((jf,fs)=>{"use strict";var _l=_();fs.exports=!_l(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var bs=p((Lf,ys)=>{"use strict";var Fl=ae(),ql=F(),Bl=be(),Dl=ds(),Hl=ms(),vs=Dl("IE_PROTO"),Sr=Object,Ul=Sr.prototype;ys.exports=Hl?Sr.getPrototypeOf:function(t){var e=Bl(t);if(Fl(e,vs))return e[vs];var r=e.constructor;return ql(r)&&e instanceof r?r.prototype:e instanceof Sr?Ul:null}});var Cs=p(($f,gs)=>{"use strict";var Gl=Te(),zl=Math.max,Wl=Math.min;gs.exports=function(t,e){var r=Gl(t);return r<0?zl(r+e,0):Wl(r,e)}});var wr=p((Nf,Is)=>{"use strict";var Kl=ye(),Ql=Cs(),Yl=xe(),Es=function(t){return function(e,r,i){var n=Kl(e),s=Yl(n);if(s===0)return!t&&-1;var c=Ql(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}};Is.exports={includes:Es(!0),indexOf:Es(!1)}});var xs=p((_f,Ts)=>{"use strict";Ts.exports={}});var As=p((Ff,ws)=>{"use strict";var Xl=q(),Ar=ae(),Zl=ye(),Jl=wr().indexOf,eu=xs(),Ss=Xl([].push);ws.exports=function(t,e){var r=Zl(t),i=0,n=[],s;for(s in r)!Ar(eu,s)&&Ar(r,s)&&Ss(n,s);for(;e.length>i;)Ar(r,s=e[i++])&&(~Jl(n,s)||Ss(n,s));return n}});var Os=p((qf,Rs)=>{"use strict";Rs.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ks=p((Bf,Ps)=>{"use strict";var tu=As(),ru=Os();Ps.exports=Object.keys||function(e){return tu(e,ru)}});var Ns=p((Df,$s)=>{"use strict";var Vs=Z(),iu=_(),js=q(),nu=bs(),su=ks(),au=ye(),ou=Ht().f,Ls=js(ou),cu=js([].push),lu=Vs&&iu(function(){var t=Object.create(null);return t[2]=2,!Ls(t,2)}),Ms=function(t){return function(e){for(var r=au(e),i=su(r),n=lu&&nu(r)===null,s=i.length,c=0,o=[],a;s>c;)a=i[c++],(!Vs||(n?a in r:Ls(r,a)))&&cu(o,t?[a,r[a]]:r[a]);return o}};$s.exports={entries:Ms(!0),values:Ms(!1)}});var _s=p(()=>{"use strict";var uu=Ie(),pu=Ns().values;uu({target:"Object",stat:!0},{values:function(e){return pu(e)}})});var qs=p((Gf,Fs)=>{"use strict";_s();var hu=Ze();Fs.exports=hu.Object.values});var Ds=p((zf,Bs)=>{"use strict";var du=qs();Bs.exports=du});var Ct=p((Wf,Hs)=>{"use strict";var fu=Ds();Hs.exports=fu});var zs=p(()=>{"use strict";var mu=Ie(),vu=wr().includes,yu=_(),bu=it(),gu=yu(function(){return!Array(1).includes()});mu({target:"Array",proto:!0,forced:gu},{includes:function(e){return vu(this,e,arguments.length>1?arguments[1]:void 0)}});bu("includes")});var Ks=p((Zf,Ws)=>{"use strict";zs();var Cu=nt();Ws.exports=Cu("Array","includes")});var Ys=p((Jf,Qs)=>{"use strict";var Eu=Ks();Qs.exports=Eu});var Et=p((em,Xs)=>{"use strict";var Iu=Ys();Xs.exports=Iu});var Mr=p((bm,ra)=>{"use strict";var Ru=ve();ra.exports=Array.isArray||function(e){return Ru(e)==="Array"}});var na=p((gm,ia)=>{"use strict";var Ou=TypeError,Pu=9007199254740991;ia.exports=function(t){if(t>Pu)throw Ou("Maximum allowed index exceeded");return t}});var oa=p((Cm,aa)=>{"use strict";var ku=Mr(),Mu=xe(),Vu=na(),ju=ur(),sa=function(t,e,r,i,n,s,c,o){for(var a=n,l=0,f=c?ju(c,o):!1,m,d;l<i;)l in r&&(m=f?f(r[l],l,e):r[l],s>0&&ku(m)?(d=Mu(m),a=sa(t,e,m,d,a,s-1)-1):(Vu(a+1),t[a]=m),a++),l++;return a};aa.exports=sa});var ua=p((Em,la)=>{"use strict";var Lu=ge(),$u=Lu("toStringTag"),ca={};ca[$u]="z";la.exports=String(ca)==="[object z]"});var ha=p((Im,pa)=>{"use strict";var Nu=ua(),_u=F(),Tt=ve(),Fu=ge(),qu=Fu("toStringTag"),Bu=Object,Du=Tt(function(){return arguments}())==="Arguments",Hu=function(t,e){try{return t[e]}catch{}};pa.exports=Nu?Tt:function(t){var e,r,i;return t===void 0?"Undefined":t===null?"Null":typeof(r=Hu(e=Bu(t),qu))=="string"?r:Du?Tt(e):(i=Tt(e))==="Object"&&_u(e.callee)?"Arguments":i}});var fa=p((Tm,da)=>{"use strict";var Uu=q(),Gu=F(),Vr=tt(),zu=Uu(Function.toString);Gu(Vr.inspectSource)||(Vr.inspectSource=function(t){return zu(t)});da.exports=Vr.inspectSource});var Ca=p((xm,ga)=>{"use strict";var Wu=q(),Ku=_(),ma=F(),Qu=ha(),Yu=Je(),Xu=fa(),va=function(){},ya=Yu("Reflect","construct"),jr=/^\s*(?:class|function)\b/,Zu=Wu(jr.exec),Ju=!jr.test(va),Le=function(e){if(!ma(e))return!1;try{return ya(va,[],e),!0}catch{return!1}},ba=function(e){if(!ma(e))return!1;switch(Qu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ju||!!Zu(jr,Xu(e))}catch{return!0}};ba.sham=!0;ga.exports=!ya||Ku(function(){var t;return Le(Le.call)||!Le(Object)||!Le(function(){t=!0})||t})?ba:Le});var xa=p((Sm,Ta)=>{"use strict";var Ea=Mr(),ep=Ca(),tp=se(),rp=ge(),ip=rp("species"),Ia=Array;Ta.exports=function(t){var e;return Ea(t)&&(e=t.constructor,ep(e)&&(e===Ia||Ea(e.prototype))?e=void 0:tp(e)&&(e=e[ip],e===null&&(e=void 0))),e===void 0?Ia:e}});var wa=p((wm,Sa)=>{"use strict";var np=xa();Sa.exports=function(t,e){return new(np(t))(e===0?0:e)}});var Aa=p(()=>{"use strict";var sp=Ie(),ap=oa(),op=be(),cp=xe(),lp=Te(),up=wa();sp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,r=op(this),i=cp(r),n=up(r,0);return n.length=ap(n,r,r,i,0,e===void 0?1:lp(e)),n}})});var Ra=p(()=>{"use strict";var pp=it();pp("flat")});var Pa=p((km,Oa)=>{"use strict";Aa();Ra();var hp=nt();Oa.exports=hp("Array","flat")});var Ma=p((Mm,ka)=>{"use strict";var dp=Pa();ka.exports=dp});var ja=p((Vm,Va)=>{"use strict";var fp=Ma();Va.exports=fp});var Hr="1.0.30-dev.a221ed50.0";function Mt(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 L="interactive",uo="interactive-controls-container",qe=()=>document.querySelector(`.${uo}`),Ur=.4,V={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||{}),Be=({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"},De=({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},He=({target:t,props:e,fallback:r})=>{t.style.backgroundColor=Mt(e?.background?.color??r.backgroundColor,e?.background?.alpha??r.backgroundAlpha)},Ue=({target:t,props:e,fallback:r,dependsOn:i})=>{t.style.border=`calc(${i.height} * ${e?.shape?.border?.width??r.borderWidth}) solid ${Mt(e?.shape?.border?.color??r.borderColor,e?.shape?.border?.alpha??r.borderAlpha)}`,t.style.borderRadius=`calc(${i.height} * ${e?.shape?.roundCorners??r.roundCorners})`},ie=({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(`${L}-control-container-${this.control.id}`),e(r,this.control.layoutParams);let i=(this.control.layoutParams.innerSizesDependOn??V.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 Vt="int",X=(i=>(i.AREA=`${Vt}_area`,i.TEXT=`${Vt}_text`,i.BUTTON=`${Vt}_bttn`,i))(X||{});var Ge=t=>{if(t.type.trim().toLowerCase()==="area")return new jt(t)},jt=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(`${L}-${this.control.id}`),i.setAttribute("data-testid",X.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",He({target:i,props:this.control.props,fallback:{...V,backgroundColor:"transparent"}}),Ue({target:i,props:this.control.props,fallback:{...V,borderAlpha:0},dependsOn:this.container.dimensions}),ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),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 ze=()=>{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 We=t=>{if(t.type.trim().toLowerCase()==="button")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(`${L}-${this.control.id}`),i.setAttribute("data-testid",X.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),He({target:i,props:this.control.props,fallback:V}),Ue({target:i,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),Be({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=ze();De({target:n,props:this.control.props,fallback:V,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 $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("div");i.classList.add(`${L}-${this.control.id}`),i.setAttribute("data-testid",X.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),Be({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=ze();De({target:n,props:this.control.props,fallback:V,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 Nt=class{constructor(e){this.layout=e}},Ke=class extends Nt{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 ne=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 Qe=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new _t(t,e)},_t=class extends ne{constructor(e,r){super(e),this.rootElement=r??qe(),this.layout=new Ke(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",We),this.addControlFactory("text",Kr),this.addControlFactory("area",Ge)}createView(e){let r=document.createElement("div");return r.classList.add(`${L}-${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(`.${L}-${this.container.id}`)}};var io=K(mr(),1);import{clientChecker as Sp,combine as wp,InterfaceLanguage as Ap,Observable as to,once as Rp,Subject as $,Subscription as qr,ValueSubject as N}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as Fe}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as Al}from"@vkontakte/videoplayer-shared";function Se(t,e){let r;return(...i)=>{clearTimeout(r),r=setTimeout(()=>t(...i),e)}}var J=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,we=t=>J(t,"Object"),st=t=>J(t,"String"),at=t=>J(t,"Array"),ot=t=>J(t,"Number"),Zn=t=>J(t,"Function");var vr=t=>ot(t)&&!isNaN(t);var ee=t=>we(t)&&Object.keys(t).length===0,yr=t=>at(t)&&!t.length;var Ae=(t,e)=>st(t)&&(e?t.trim():t).length;var Jn="video_interactive",es="videoint";var ts=250,Re=class{constructor(e){this.handleZoomChange=Se(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,!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(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=Rl(e),this.resizeObserver=new ResizeObserver(Se(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 Al(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 Rl(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 Oe=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}}};import{isSupportedManifest as lt,ContainerTypes as zd,ControlTypes as ut,EventActionTypes as S,EventTypes as Wd,migrateManifestToLatestVersion as ss,compareVersions as Kd}from"@interactiveplatform/movika-manifest";var rs={metadata:"Object",chapters:"Array"},is=t=>{if(!we(t))return!1;for(let e in rs)if(!t[e]||!J(t[e],rs[e]))return!1;return lt(t.metadata.version)},ct=t=>t.type===ut.Text,_d=t=>t.type===ut.Button,Fd=t=>t.type===ut.Area,qd={Choice:"Choice",TextInput:"TextInput"},Bd={Button:"Button",Area:"Area",Text:"Text"},Dd={onClick:"onClick",onSuspense:"onSuspense"},ns={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var M=class{constructor(e,r,...i){this.severity=e;this.category=r;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var pt=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 ht=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=[]}};import{ValueSubject as Ll}from"@vkontakte/videoplayer-shared";var dt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,r){return Ol(...this.loaders[e])(r)}};function Ol(...t){return async function(r){let i=[...t];for(;i.length>0;)r=await i.shift()(r);return r}}function Pe(t,e,r){return t?{...t,[e]:t[e]?[r,...t[e]]:[r]}:{[e]:[r]}}function ft({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:Pe(e,ft.name,"Could not find media"),actions:t}}}return{...i,errors:Pe(e,ft.name,"Could not find chapter"),actions:t}}var mt=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}},ue=class extends mt{constructor(){super(),this.listeners||mt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},ke=class{constructor(){Object.defineProperty(this,"signal",{value:new ue,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&&(ke.prototype[Symbol.toStringTag]="AbortController",ue.prototype[Symbol.toStringTag]="AbortSignal");function vt(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 br(t){typeof t=="function"&&(t={fetch:t});let{fetch:e,Request:r=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=t;if(!vt({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,R)=>{f.addEventListener("abort",()=>R(m),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([d,c(a,l)])}return c(a,l)},Request:s}}var Me=vt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),as=Me?br({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,gr=Me?as.fetch:window.fetch,df=Me?as.Request:window.Request,ff=Me?ke:window.AbortController,mf=Me?ue:window.AbortSignal;var Cr=(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 Pl=async t=>{try{let e={},r;if(st(t)){r=new URL(t).href;let n=await gr(r);if(!n.ok)return{};e=await n.json()}else if(we(t))e=t;else return{};if(!is(e))return{};let i=e.metadata.media;if(st(i)&&!("media"in e))try{let n;r?n=new URL(i,r).href:(n=new URL(i).href,r=n);let s=await gr(n);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch{return Vl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch{return{}}};async function os(t){let{manifest:e,manifestURL:r}=await Pl(t);if(!e)throw new Error("Failed on fetch");let i=ss(e);return i.media=kl(i.media,r),delete i.metadata.media,i}function yt(t,e){if(e)return t.find(r=>r.id===e)}function Er(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 Ir(t,e){return t.videos.find(r=>r.id===e)}function kl(t,e){return{...t,videos:t.videos.map(r=>({...r,variants:r.variants.map(i=>{let n="url"in i?i.url:"",s=Ml(n,e);return{...i,url:s||n}})}))}}function Ml(t="",e){try{return new URL(t,e).href}catch{return""}}function Vl(t){return Cr(t,"3.2.0")>=0}var bt=t=>at(t)&&!yr(t),G=t=>t.order==="end",gt=t=>at(t.containers)&&!yr(t.containers)&&G(t),cs=(t,e)=>{let r=t*1e3;return bt(e.controls)&&r<(e.startTime??0)},Tr=(t,e)=>{let r=t*1e3;return bt(e.controls)&&r>=(e.startTime??0)&&r<=(e.endTime??1/0)};var te=(t=[])=>t.some(e=>e.action.type==="expect"),xr=(t=[])=>t.find(e=>e.action.type==="expect"),jl=t=>t?.length===1,pe=t=>jl(t)&&ct(t[0]);function ls(t,...e){return r=>typeof e[0]=="object"&&typeof r=="object"?t({...e[0],...r}):t(...e,...r)}var us=(t,e)=>{let r=d=>e.find(({container:R})=>R.container.id===d)?.container.isRemoved,i=te(t.events)&&!r(t.id),n=(d,v=!1,R=!1)=>{let O=R?"every":"some";return d.controls[O](b=>{let w=v?d.endTime===t.endTime:!0;return b.events?.[O](k=>k.action?.type===ns.openURI)&&w})},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&&te(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 he=class extends dt{constructor(r,i){super(r);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Ll(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:Pe},result:null,errors:null,source:r});return i.errors&&this.errorHandler(i.errors),this.manifest=await os(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",ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Er,getChapter:yt,getMedia:Ir,getByBranches:this.getByBranches.bind(this),addErrorMessage:Pe},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=yt(this.manifest.chapters,r);if(i){let n=Ir(this.manifest.media,i.videoId),s=Er(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=yt(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?G(this.chapter):!1}};var Zs=K(Ct(),1);import{Player as Tu}from"@vkontakte/videoplayer-core";import{Subscription as Pr,Tracer as xu,ValueSubject as Su}from"@vkontakte/videoplayer-shared";var Us=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 Gs=K(Ct(),1);function Rr(){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,Gs.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 de=K(Et(),1);function Or(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,de.default)(e,"mp4"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"mpeg":(n||(0,de.default)(e,"mpeg"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"hls":(n||(0,de.default)(e,"hls"))&&(r={...r,HLS:{type:"url",url:s.url}});break;case"dash":(n||(0,de.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 Ve=(t,e)=>{let r=t.info.currentQuality$.getValue(),i=t.info.availableQualities$.getValue();r!==e&&(0,de.default)(i,e)&&(t.setQuality(e),t.setAutoQuality(!1))};var wu=2;function kr(t){let e=Rr(),r=new Pr,i={},n=null,s=!1,c,o=new Su(null);t&&a(t);function a(b){n=b}function l(b,w,k){if(!n)throw Error("need to set interactive controller");if(!n.options)return;let h=(e.map.get(b)??{})[w];if(h){i={chapterId:k,listId:b,itemId:w,...h};let y=i.player;i.subscription.add(y.info.currentQuality$.subscribe(g=>{let C=y.info.position$.getValue(),P=y.info.isAutoQualityEnabled$.getValue();if(!(!g||!C||P))for(let x of e.map)(0,Zs.default)(x[1]).forEach(({player:I})=>{Ve(I,g)})})).add(y.events.started$.subscribe(()=>{f(w)})),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(b){if(!n)throw Error("need to set interactive controller");if(ee(i)||b!==i.itemId)return;let w=n.getChapterBranches(),k=new Set;for(let u of w)k.has(u.media.id)||(await d({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),k.add(u.media.id))}async function m({chapter:{id:b},manifestVideo:w}){if(ee(i)||!n)return;let k=i.player.info.muted$.getValue(),u=i.player.info.currentQuality$.getValue(),h=i.player.info.isAutoQualityEnabled$.getValue(),y=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),C=!h,P=!1;for(let x of e.map)if(x[0]===w.id&&!n.state.isReplay$.getValue()){let I=Object.keys(x[1]);for(let T of I)T===i.itemId?(I.length<wu||(P=!0),e.removePlayer(x[0],T)):(P=!0,l(x[0],T,b),C?Ve(i.player,u):i.player.setAutoQuality(!0),i.player.setVolume(y),i.player.setMuted(k),i.player.setPlaybackRate(g))}else e.removePlayer(x[0]);P||(await d({media:w,chapterId:b,setAsActive:!0,playbackRate:g}),C?Ve(i.player,u):i.player.setAutoQuality(!0),i.player.setVolume(y),i.player.setMuted(k))}async function d({media:b,chapterId:w,prefetch:k=!0,setAsActive:u=!0,autoplay:h=!1,preferredExt:y,title:g,playbackRate:C}){let P=Math.random().toString(),x=document.createElement("div");c.append(x);let I;if(n?.options?.vkVideoLoader){let re=Us(b);re.length&&(I=await n.options.vkVideoLoader(...re))}let T=n?.options?.coreConfig||void 0,z={...T,configName:[...T?.configName??[],"interactive"]},W={container:x,...I?.videos?.[0]||{sources:Or(b,y).sources},title:g,failoverHosts:I?.failoverHosts||[]},j=new Tu(z,xu.createRootTracer());j.initVideo(W);let D=null;if(I?.videos&&n?.options.createOneStat){let re=I.videos[0],kt=n.options.createOneStat(re),Br=new Pr;kt&&(Br.add(kt.attachTo(j)),D={oneStat:kt,statSubscription:Br})}let Y=new Pr,Pt=i?.player?.info.isAutoQualityEnabled$.getValue();Y.add(j.events.canplay$.subscribe(function(){Pt||Ve(j,i.player.info.currentQuality$.getValue()),C&&j.setPlaybackRate(C)}));let H=e.createPlayer({listId:b.id,itemId:P,player:j,container:x,sources:Or(b,y).sources,config:W,subscription:Y,statistics:D});return u&&l(b.id,H.itemId,w),h&&H.player.play(),k&&!h&&H.player.prepare(),{player:H.player,config:H.config,statistics:H.statistics}}function v(){R(),n=null,c.remove()}function R(){r.unsubscribe(),e.removeAll(),i={},s=!1}async function O(){if(!n)throw Error("need to set interactive controller");R(),c=document.createElement("div");let{media:b,chapter:w}=n.getCurrentChapter();b&&w?(r.add(n.events.chapterChanged$.subscribe(m)),await d({media:b,chapterId:w.id,title:w.label})):console.error("not found")}return{...e,init:O,setInteractiveController:a,createPlayer:d,removeAll:v,getActivePlayer:function(){return i},activePlayerChanged:o}}var E={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},je={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},A={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",containerFakeRemoved:"container-fake-removed",rangeEnded:"range-ended"};var ea=K(Et(),1);import{Subscription as Au}from"@vkontakte/videoplayer-shared";var It=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&&(te(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=ls(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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.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=((R,O,b,w)=>!R&&!O&&b||R&&!O&&b&&!w||R&&!O&&b&&w)(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(cs(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Tr(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=Tr(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(E.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=r,this.branches=i,this.selectBranches=n,this.subscription=new Au,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&pe(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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.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:te(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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.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 ta=(t=[])=>t.reduce((e,r,i)=>{let n=(r?.controls??[]).filter(s=>!ct(s));if(bt(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 $a=K(Et(),1),Lr=K(Ct(),1),Na=K(ja(),1);function La(){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(vr(o)){let f=t[o]??null;if(f&&a&&Ae(a,!0)){let m={},d=f[a];return d&&(m={...m,...d}),m=ee(m)?null:m,m&&Ae(l,!0)?m[l]??null:m}return f}return null}function s({timestamp:o,priority:a,initiator:l}){if(vr(o))if(t[o]){if(a&&Ae(a,!0))if(t[o][a]){if(l&&Ae(l,!0))if(t[o][a][l]){if(delete t[o][a][l],!ee(t[o][a]))return!0}else return!1;if(delete t[o][a],!ee(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 mp=[S.expect,S.setNextBranch],vp=1/0;function _a(t,e){let r=t,i,n=yp(e),s=La(),c,o=()=>{v(),k()},a=u=>{s.add.call(void 0,u),O()},l=(u=[])=>{for(let h of u)if(h.action(),(0,$a.default)(mp,h.actionType))break},f=(u=1/0)=>{let h=xt(s.get({timestamp:u,priority:"control"})??{}),y=xt(s.get({timestamp:u,priority:"container"})??{}),g=xt(s.get({timestamp:u,priority:"chapter"})??{});return[...h,...y,...g]},m=u=>{n.isReady(u)&&l(f(u))},d=()=>{l([...xt(s.get({timestamp:1/0,priority:"chapter"})??{})])},v=()=>{i&&(c?.unsubscribe(),i=void 0)},R=u=>{},O=()=>{i||(i=()=>setTimeout(()=>{m(1/0)}),c=r.events.ended$.subscribe(i))},b=u=>{v(),r=u},w=u=>{u.priority==="container"&&n.resetCalled(u.timestamp),s.remove(u)},k=()=>{n.release(),s.removeAll()};return{setPlayer:b,add:a,remove:w,exec:m,execEndOfVideo:d,listen:O,unlisten:v,release:o,containersEventsCallState:n,getPreparedToExecActions:f}}function yp(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??vp,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,Lr.default)(a);return t?l.some(m=>m):!l.some(m=>!m)},release:()=>e.clear()}}function xt(t){return(0,Na.default)((0,Lr.default)(t)).sort(e=>e.actionType===S.expect?-1:1)}var Fa={videoContentHeight:0,videoContentWidth:0},qa=(t,e)=>{let{height:r,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(r&&i))return Fa;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Fa;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 bp=250;function Ba(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}=qa(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=Se(o=>{let{fns:a=[]}=t();i(o);for(let l of a)l()},bp);function c(){e=void 0,r.disconnect(),n()}return{resizeObserver:r,calc:()=>{e?.()},release:c}}var $e=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 gp=t=>Math.floor(Math.random()*t),Ha=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},Ua=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 Ga=t=>{let e=t.length,r=gp(e);return t[r]},Da=1,za=t=>{let e=0;for(let i=0;i<t.length;++i)e+=t[i].weight??Da;let r=Math.random()*e;e=0;for(let i=0;i<t.length-1;++i)if(e+=t[i].weight??Da,e>=r)return t[i];return t[t.length-1]};var Wa={shouldOpenNow:!0,isDetachContainer:!0},Ka="after-expect";var $r=(t,e=!1)=>({...t,args:e?{...t.args,...Wa}:{...Wa,...t.args}}),Xa=({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:g,branches:C=[],onEvent:P,isEOV:x=()=>!1,isDisabled:I=()=>!1})=>{let T=$r(u,x()),z={timestamp:1/0,priority:"control",initiator:y,actionType:T.type},W=I(),j=t.emit.bind(t,E.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:W?A.actionChoiceCanceled:A.actionChoice,actionType:u.type,payload:{containerId:g,...T.args}}),D=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:W?"action-choice-canceled":"action-choice",actionType:u.type,payload:{containerId:g,...T.args}})};if(W){j(),D();return}switch(T.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{let H=C.find(re=>re.id===T.args.branchId);if(!H)return;P(T.args.isDetachContainer,R.bind(null,{subjectId:y,subjectName:"control"})),j(),D(),T.args.shouldOpenNow?b({subjectId:y,subjectName:"control",subjectType:h,action:T,payload:{chapterId:H.chapterId,autoSelect:!1}}):(i.add({...z,action:b.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:T,payload:{chapterId:H.chapterId,autoSelect:!1}})}),n?.());return}case S.continuePlayback.trim().toLowerCase():{P(T.args.isDetachContainer,R.bind(null,{subjectId:y,subjectName:"control"})),j(),D(),T.args.shouldOpenNow?O({subjectId:y,subjectName:"control",subjectType:h,action:u}):i.add({...z,action:O.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:u})});return}case S.openURI.trim().toLowerCase():{P(T.args.isDetachContainer,R.bind(null,{subjectId:y,subjectName:"control"})),j(),D(),T.args.shouldOpenNow?k({subjectId:y,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}}):(i.add({...z,action:k.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}})}),n?.());return}default:let Y="Unexpected control event",Pt=new M(1,1,{message:Y});m(Pt,Y);return}},a=({action:u,container:{id:h,endTime:y},branches:g=[],isEOV:C=!1,autoSelected:P=!1})=>{let x=$r(u,C),I={timestamp:!x.args.shouldOpenNow||C?1/0:y??1/0,priority:"container",initiator:h,actionType:x.type},T=t.emit.bind(t,E.interactives,{subjectId:h,subjectName:"container",type:A.actionChoice,actionType:x.type,payload:x.args}),z=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:x.type,payload:x.args})};switch(x.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{let D=g.find(Y=>Y.id===x.args.branchId);if(!D)return;T(),z(),i.add({...I,action:b.bind(null,{subjectId:h,subjectName:"container",action:x,payload:{chapterId:D.chapterId,autoSelect:P}})}),n?.();return}case S.setMaxWeightBranch.trim().toLowerCase():return;case S.setMinWeightBranch.trim().toLowerCase():return;case S.setRandomBranch.trim().toLowerCase():return;case S.setWeightlessRandomBranch.trim().toLowerCase():return;case S.continuePlayback.trim().toLowerCase():{T(),z(),i.add({...I,action:O.bind(null,{subjectId:h,subjectName:"container",action:x})});return}case S.openURI.trim().toLowerCase():{T(),z(),i.add({...I,action:k.bind(null,{subjectId:h,subjectName:"container",action:x,payload:{URI:u.args.uri}})}),n?.();return}default:let W="Unexpected container event",j=new M(1,1,{message:W});m(j,W);return}};function l({container:u,branches:h,isEOV:y=!1}){let g=xr(u.events);if(g){let C=$r(g.action,y);t.emit(E.interactives,{subjectId:u.id,subjectName:"container",type:A.actionChoice,actionType:C.type,payload:C.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:C.type,payload:C.args}),i.add({timestamp:y?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:S.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),s.isExpect=!0}else for(let C of u.events??[])a({action:C.action,container:u,branches:h,isEOV:y})}let f=({chapterId:u,action:h,branches:y=[]})=>{let g=t.emit.bind(t,E.interactives,{subjectId:u,subjectName:"chapter",type:A.actionChoice,actionType:h.type,payload:h.args}),C=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{let I=y.find(T=>T.id===h.args.branchId);return I?.chapterId?(g(),C(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case S.setWeightlessRandomBranch.trim().toLowerCase():{let I=Ga(y);return I?.chapterId?(g(),C(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case S.setRandomBranch.trim().toLowerCase():{let I=za(y);return I?.chapterId?(g(),C(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case S.setMaxWeightBranch.trim().toLowerCase():{let I=Ua(y);return I?.chapterId?(g(),C(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case S.setMinWeightBranch.trim().toLowerCase():{let I=Ha(y);return I?.chapterId?(g(),C(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case S.continuePlayback.trim().toLowerCase():return g(),C(),O.bind(null,{subjectId:u,subjectName:"chapter",action:h});case S.openURI.trim().toLowerCase():return g(),C(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:let P="Unexpected chapter event",x=new M(1,1,{message:P});m(x,P);return}};function m(u,h){console.error(h),e.error$.next(u),t.emit(E.errors,u)}function d(u){let h=xr(u.events);if(h){if(G(u))return;t.emit(E.interactives,{subjectId:u.id,subjectName:"chapter",type:A.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:S.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(y=>{let g=f({chapterId:u.id,action:y.action,branches:u.branches});g&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:y.action.type,action:g})})}let v=({subjectId:u,subjectName:h})=>{r.pause(),t.emit(E.interactives,{subjectId:u,subjectName:h,type:A.actionExecution,actionType:S.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:S.expect})},R=({subjectId:u,subjectName:h})=>{r.info.isEnded$.getValue()?i.execEndOfVideo():r.play(),t.emit(E.interactives,{subjectId:u,subjectName:h,type:A.actionExecution,actionType:Ka}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:Ka})},O=({subjectId:u,subjectName:h,subjectType:y,action:g})=>{t.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:y,type:A.actionExecution,actionType:g.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:g.type})},b=({subjectId:u,subjectName:h,subjectType:y,action:g,payload:C})=>{C.behaviour="change-chapter",t.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:y,type:A.actionExecution,actionType:g.type,payload:C}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:g.type,payload:C})},w=({subjectId:u,subjectName:h,subjectType:y,action:g,payload:C})=>{C.behaviour="change-manifest",t.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:y,type:A.actionExecution,actionType:g.type,payload:C}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:g.type,payload:C})},k=({subjectId:u,subjectName:h,subjectType:y,action:g,payload:C})=>{if(!C.URI)return;let P=window.open(C.URI,"_blank","noopener,noreferrer");P&&(P.opener=null),t.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:y,type:A.actionExecution,actionType:g.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:g.type})};return{onControlEvent:o,onContainerEvent:a,onChapterEvent:f,onExpectEvent:v,expectEventHandler:R,setManifestChapterEvents:d,setManifestContainerEvents:l,stopExpect:c,state:s}};var Fr=K(mr(),1);import{Subscription as xp,Subject as _r,ValueSubject as Ne}from"@vkontakte/videoplayer-shared";var Nr=(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]=Za(s)}return r[i]}).filter(Boolean)},Ep=t=>{for(let e of t.variants)if(Ip(e)&&e.payload)return e.payload.id},Ip=t=>!!(t.type==="custom"&&t.payload&&t.payload.type==="vk"),Za=t=>{let e=Ep(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},Tp=(t,e)=>{for(let r of t.media.videos)if(e===Za(r)){for(let i of t.chapters)if(i.videoId===r.id)return i.id;return}},Ja=(t,e)=>t.reduce((r,i)=>{let n=Tp(e,i);return n?[...r,n]:r},[]);var _e=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new Ne([]),hasPrevChapter$:new Ne(!1),prevChapter$:new Ne(null),isInitialChapter$:new Ne(!1),isGoBackLimited$:new Ne(!1)};this.#r=null;this.#a=!1;this.#e=null;this.#u=null;this.events={inited$:new _r,destroyed$:new _r,error$:new _r};this.#i=null;this.#n=null;this.#t=null;this.#o=new xp;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,Fr.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=Nr(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 M(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(E.errors,a)}}async goBack(){if(!this.state||!this.#n){let i=new M(1,5,"Unable to save interactive history");return this.events.error$.next(i),this.#t?.emit(E.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 M(1,5,"Error while trying to fetch data");this.events.error$.next(s),this.#t?.emit(E.errors,s)}let i=Ja(r,e);this.state.history$.next(i)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,Fr.default)(e,-1)||this.#s.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return Nr([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(E.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var St=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 wt=class{constructor(){this.bindingMap=new $e}release(){this.removeAll(),this.bindingMap=null}listen(e,r,i,n){if(!this.bindingMap)return;let s=new St(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 At=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 Rt=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
|
+
var ys=Object.create;var zr=Object.defineProperty;var bs=Object.getOwnPropertyDescriptor;var gs=Object.getOwnPropertyNames;var Cs=Object.getPrototypeOf,Es=Object.prototype.hasOwnProperty;var c=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Ts=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gs(e))!Es.call(r,n)&&n!==t&&zr(r,n,{get:()=>e[n],enumerable:!(i=bs(e,n))||i.enumerable});return r};var W=(r,e,t)=>(t=r!=null?ys(Cs(r)):{},Ts(e||!r||!r.__esModule?zr(t,"default",{value:r,enumerable:!0}):t,r));var G=c((Dt,ni)=>{"use strict";var Ce=function(r){return r&&r.Math===Math&&r};ni.exports=Ce(typeof globalThis=="object"&&globalThis)||Ce(typeof window=="object"&&window)||Ce(typeof self=="object"&&self)||Ce(typeof global=="object"&&global)||Ce(typeof Dt=="object"&&Dt)||function(){return this}()||Function("return this")()});var j=c((cd,oi)=>{"use strict";oi.exports=function(r){try{return!!r()}catch{return!0}}});var Ee=c((ud,ai)=>{"use strict";var ws=j();ai.exports=!ws(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var pi=c((pd,ui)=>{"use strict";var As=Ee(),ci=Function.prototype,si=ci.apply,li=ci.call;ui.exports=typeof Reflect=="object"&&Reflect.apply||(As?li.bind(si):function(){return li.apply(si,arguments)})});var D=c((hd,mi)=>{"use strict";var hi=Ee(),di=Function.prototype,Ht=di.call,Ss=hi&&di.bind.bind(Ht,Ht);mi.exports=hi?Ss:function(r){return function(){return Ht.apply(r,arguments)}}});var Te=c((dd,vi)=>{"use strict";var fi=D(),Rs=fi({}.toString),Ps=fi("".slice);vi.exports=function(r){return Ps(Rs(r),8,-1)}});var Gt=c((md,yi)=>{"use strict";var Os=Te(),ks=D();yi.exports=function(r){if(Os(r)==="Function")return ks(r)}});var N=c((fd,bi)=>{"use strict";var zt=typeof document=="object"&&document.all;bi.exports=typeof zt>"u"&&zt!==void 0?function(r){return typeof r=="function"||r===zt}:function(r){return typeof r=="function"}});var ee=c((vd,gi)=>{"use strict";var Ls=j();gi.exports=!Ls(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var st=c((yd,Ci)=>{"use strict";var Ms=Ee(),at=Function.prototype.call;Ci.exports=Ms?at.bind(at):function(){return at.apply(at,arguments)}});var Ut=c(Ii=>{"use strict";var Ei={}.propertyIsEnumerable,Ti=Object.getOwnPropertyDescriptor,Vs=Ti&&!Ei.call({1:2},1);Ii.f=Vs?function(e){var t=Ti(this,e);return!!t&&t.enumerable}:Ei});var Wt=c((gd,xi)=>{"use strict";xi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ai=c((Cd,wi)=>{"use strict";var Fs=D(),$s=j(),js=Te(),Kt=Object,Ns=Fs("".split);wi.exports=$s(function(){return!Kt("z").propertyIsEnumerable(0)})?function(r){return js(r)==="String"?Ns(r,""):Kt(r)}:Kt});var Qt=c((Ed,Si)=>{"use strict";Si.exports=function(r){return r==null}});var Xt=c((Td,Ri)=>{"use strict";var _s=Qt(),qs=TypeError;Ri.exports=function(r){if(_s(r))throw new qs("Can't call method on "+r);return r}});var Ie=c((Id,Pi)=>{"use strict";var Bs=Ai(),Ds=Xt();Pi.exports=function(r){return Bs(Ds(r))}});var ae=c((xd,Oi)=>{"use strict";var Hs=N();Oi.exports=function(r){return typeof r=="object"?r!==null:Hs(r)}});var lt=c((wd,ki)=>{"use strict";ki.exports={}});var ct=c((Ad,Mi)=>{"use strict";var Yt=lt(),Zt=G(),Gs=N(),Li=function(r){return Gs(r)?r:void 0};Mi.exports=function(r,e){return arguments.length<2?Li(Yt[r])||Li(Zt[r]):Yt[r]&&Yt[r][e]||Zt[r]&&Zt[r][e]}});var Fi=c((Sd,Vi)=>{"use strict";var zs=D();Vi.exports=zs({}.isPrototypeOf)});var _i=c((Rd,Ni)=>{"use strict";var Us=G(),$i=Us.navigator,ji=$i&&$i.userAgent;Ni.exports=ji?String(ji):""});var Ui=c((Pd,zi)=>{"use strict";var Gi=G(),Jt=_i(),qi=Gi.process,Bi=Gi.Deno,Di=qi&&qi.versions||Bi&&Bi.version,Hi=Di&&Di.v8,H,ut;Hi&&(H=Hi.split("."),ut=H[0]>0&&H[0]<4?1:+(H[0]+H[1]));!ut&&Jt&&(H=Jt.match(/Edge\/(\d+)/),(!H||H[1]>=74)&&(H=Jt.match(/Chrome\/(\d+)/),H&&(ut=+H[1])));zi.exports=ut});var er=c((Od,Ki)=>{"use strict";var Wi=Ui(),Ws=j(),Ks=G(),Qs=Ks.String;Ki.exports=!!Object.getOwnPropertySymbols&&!Ws(function(){var r=Symbol("symbol detection");return!Qs(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Wi&&Wi<41})});var tr=c((kd,Qi)=>{"use strict";var Xs=er();Qi.exports=Xs&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var rr=c((Ld,Xi)=>{"use strict";var Ys=ct(),Zs=N(),Js=Fi(),el=tr(),tl=Object;Xi.exports=el?function(r){return typeof r=="symbol"}:function(r){var e=Ys("Symbol");return Zs(e)&&Js(e.prototype,tl(r))}});var Zi=c((Md,Yi)=>{"use strict";var rl=String;Yi.exports=function(r){try{return rl(r)}catch{return"Object"}}});var ir=c((Vd,Ji)=>{"use strict";var il=N(),nl=Zi(),ol=TypeError;Ji.exports=function(r){if(il(r))return r;throw new ol(nl(r)+" is not a function")}});var tn=c((Fd,en)=>{"use strict";var al=ir(),sl=Qt();en.exports=function(r,e){var t=r[e];return sl(t)?void 0:al(t)}});var nn=c(($d,rn)=>{"use strict";var nr=st(),or=N(),ar=ae(),ll=TypeError;rn.exports=function(r,e){var t,i;if(e==="string"&&or(t=r.toString)&&!ar(i=nr(t,r))||or(t=r.valueOf)&&!ar(i=nr(t,r))||e!=="string"&&or(t=r.toString)&&!ar(i=nr(t,r)))return i;throw new ll("Can't convert object to primitive value")}});var an=c((jd,on)=>{"use strict";on.exports=!0});var cn=c((Nd,ln)=>{"use strict";var sn=G(),cl=Object.defineProperty;ln.exports=function(r,e){try{cl(sn,r,{value:e,configurable:!0,writable:!0})}catch{sn[r]=e}return e}});var pt=c((_d,hn)=>{"use strict";var ul=an(),pl=G(),hl=cn(),un="__core-js_shared__",pn=hn.exports=pl[un]||hl(un,{});(pn.versions||(pn.versions=[])).push({version:"3.38.0",mode:ul?"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=c((qd,mn)=>{"use strict";var dn=pt();mn.exports=function(r,e){return dn[r]||(dn[r]=e||{})}});var xe=c((Bd,fn)=>{"use strict";var dl=Xt(),ml=Object;fn.exports=function(r){return ml(dl(r))}});var se=c((Dd,vn)=>{"use strict";var fl=D(),vl=xe(),yl=fl({}.hasOwnProperty);vn.exports=Object.hasOwn||function(e,t){return yl(vl(e),t)}});var lr=c((Hd,yn)=>{"use strict";var bl=D(),gl=0,Cl=Math.random(),El=bl(1 .toString);yn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+El(++gl+Cl,36)}});var we=c((Gd,gn)=>{"use strict";var Tl=G(),Il=sr(),bn=se(),xl=lr(),wl=er(),Al=tr(),le=Tl.Symbol,cr=Il("wks"),Sl=Al?le.for||le:le&&le.withoutSetter||xl;gn.exports=function(r){return bn(cr,r)||(cr[r]=wl&&bn(le,r)?le[r]:Sl("Symbol."+r)),cr[r]}});var In=c((zd,Tn)=>{"use strict";var Rl=st(),Cn=ae(),En=rr(),Pl=tn(),Ol=nn(),kl=we(),Ll=TypeError,Ml=kl("toPrimitive");Tn.exports=function(r,e){if(!Cn(r)||En(r))return r;var t=Pl(r,Ml),i;if(t){if(e===void 0&&(e="default"),i=Rl(t,r,e),!Cn(i)||En(i))return i;throw new Ll("Can't convert object to primitive value")}return e===void 0&&(e="number"),Ol(r,e)}});var ur=c((Ud,xn)=>{"use strict";var Vl=In(),Fl=rr();xn.exports=function(r){var e=Vl(r,"string");return Fl(e)?e:e+""}});var Sn=c((Wd,An)=>{"use strict";var $l=G(),wn=ae(),pr=$l.document,jl=wn(pr)&&wn(pr.createElement);An.exports=function(r){return jl?pr.createElement(r):{}}});var hr=c((Kd,Rn)=>{"use strict";var Nl=ee(),_l=j(),ql=Sn();Rn.exports=!Nl&&!_l(function(){return Object.defineProperty(ql("div"),"a",{get:function(){return 7}}).a!==7})});var kn=c(On=>{"use strict";var Bl=ee(),Dl=st(),Hl=Ut(),Gl=Wt(),zl=Ie(),Ul=ur(),Wl=se(),Kl=hr(),Pn=Object.getOwnPropertyDescriptor;On.f=Bl?Pn:function(e,t){if(e=zl(e),t=Ul(t),Kl)try{return Pn(e,t)}catch{}if(Wl(e,t))return Gl(!Dl(Hl.f,e,t),e[t])}});var Mn=c((Xd,Ln)=>{"use strict";var Ql=j(),Xl=N(),Yl=/#|\.prototype\./,Ae=function(r,e){var t=Jl[Zl(r)];return t===tc?!0:t===ec?!1:Xl(e)?Ql(e):!!e},Zl=Ae.normalize=function(r){return String(r).replace(Yl,".").toLowerCase()},Jl=Ae.data={},ec=Ae.NATIVE="N",tc=Ae.POLYFILL="P";Ln.exports=Ae});var dr=c((Yd,Fn)=>{"use strict";var Vn=Gt(),rc=ir(),ic=Ee(),nc=Vn(Vn.bind);Fn.exports=function(r,e){return rc(r),e===void 0?r:ic?nc(r,e):function(){return r.apply(e,arguments)}}});var jn=c((Zd,$n)=>{"use strict";var oc=ee(),ac=j();$n.exports=oc&&ac(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var _n=c((Jd,Nn)=>{"use strict";var sc=ae(),lc=String,cc=TypeError;Nn.exports=function(r){if(sc(r))return r;throw new cc(lc(r)+" is not an object")}});var Dn=c(Bn=>{"use strict";var uc=ee(),pc=hr(),hc=jn(),ht=_n(),qn=ur(),dc=TypeError,mr=Object.defineProperty,mc=Object.getOwnPropertyDescriptor,fr="enumerable",vr="configurable",yr="writable";Bn.f=uc?hc?function(e,t,i){if(ht(e),t=qn(t),ht(i),typeof e=="function"&&t==="prototype"&&"value"in i&&yr in i&&!i[yr]){var n=mc(e,t);n&&n[yr]&&(e[t]=i.value,i={configurable:vr in i?i[vr]:n[vr],enumerable:fr in i?i[fr]:n[fr],writable:!1})}return mr(e,t,i)}:mr:function(e,t,i){if(ht(e),t=qn(t),ht(i),pc)try{return mr(e,t,i)}catch{}if("get"in i||"set"in i)throw new dc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Gn=c((tm,Hn)=>{"use strict";var fc=ee(),vc=Dn(),yc=Wt();Hn.exports=fc?function(r,e,t){return vc.f(r,e,yc(1,t))}:function(r,e,t){return r[e]=t,r}});var Re=c((rm,Un)=>{"use strict";var Se=G(),bc=pi(),gc=Gt(),Cc=N(),Ec=kn().f,Tc=Mn(),ce=lt(),Ic=dr(),ue=Gn(),zn=se();pt();var xc=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 bc(r,this,arguments)};return e.prototype=r.prototype,e};Un.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,s=i?Se:n?Se[t]:Se[t]&&Se[t].prototype,a=i?ce:ce[t]||ue(ce,t,{})[t],l=a.prototype,p,d,f,m,y,S,L,I,A;for(m in e)p=Tc(i?m:t+(n?".":"#")+m,r.forced),d=!p&&s&&zn(s,m),S=a[m],d&&(r.dontCallGetSet?(A=Ec(s,m),L=A&&A.value):L=s[m]),y=d&&L?L:e[m],!(!p&&!o&&typeof S==typeof y)&&(r.bind&&d?I=Ic(y,Se):r.wrap&&d?I=xc(y):o&&Cc(y)?I=gc(y):I=y,(r.sham||y&&y.sham||S&&S.sham)&&ue(I,"sham",!0),ue(a,m,I),o&&(f=t+"Prototype",zn(ce,f)||ue(ce,f,{}),ue(ce[f],m,y),r.real&&l&&(p||!l[m])&&ue(l,m,y)))}});var Kn=c((im,Wn)=>{"use strict";var wc=Math.ceil,Ac=Math.floor;Wn.exports=Math.trunc||function(e){var t=+e;return(t>0?Ac:wc)(t)}});var Pe=c((nm,Qn)=>{"use strict";var Sc=Kn();Qn.exports=function(r){var e=+r;return e!==e||e===0?0:Sc(e)}});var Yn=c((om,Xn)=>{"use strict";var Rc=Pe(),Pc=Math.max,Oc=Math.min;Xn.exports=function(r,e){var t=Rc(r);return t<0?Pc(t+e,0):Oc(t,e)}});var Jn=c((am,Zn)=>{"use strict";var kc=Pe(),Lc=Math.min;Zn.exports=function(r){var e=kc(r);return e>0?Lc(e,9007199254740991):0}});var Oe=c((sm,eo)=>{"use strict";var Mc=Jn();eo.exports=function(r){return Mc(r.length)}});var br=c((lm,ro)=>{"use strict";var Vc=Ie(),Fc=Yn(),$c=Oe(),to=function(r){return function(e,t,i){var n=Vc(e),o=$c(n);if(o===0)return!r&&-1;var s=Fc(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}};ro.exports={includes:to(!0),indexOf:to(!1)}});var dt=c((cm,io)=>{"use strict";io.exports=function(){}});var no=c(()=>{"use strict";var jc=Re(),Nc=br().includes,_c=j(),qc=dt(),Bc=_c(function(){return!Array(1).includes()});jc({target:"Array",proto:!0,forced:Bc},{includes:function(e){return Nc(this,e,arguments.length>1?arguments[1]:void 0)}});qc("includes")});var mt=c((hm,oo)=>{"use strict";var Dc=ct();oo.exports=Dc});var so=c((dm,ao)=>{"use strict";no();var Hc=mt();ao.exports=Hc("Array","includes")});var co=c((mm,lo)=>{"use strict";var Gc=so();lo.exports=Gc});var ft=c((fm,uo)=>{"use strict";var zc=co();uo.exports=zc});var po=c(()=>{"use strict";var Uc=Re(),Wc=xe(),Kc=Oe(),Qc=Pe(),Xc=dt();Uc({target:"Array",proto:!0},{at:function(e){var t=Wc(this),i=Kc(t),n=Qc(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Xc("at")});var mo=c((bm,ho)=>{"use strict";po();var Yc=mt();ho.exports=Yc("Array","at")});var vo=c((gm,fo)=>{"use strict";var Zc=mo();fo.exports=Zc});var gr=c((Cm,yo)=>{"use strict";var Jc=vo();yo.exports=Jc});var Ro=c((vf,So)=>{"use strict";var cu=sr(),uu=lr(),Ao=cu("keys");So.exports=function(r){return Ao[r]||(Ao[r]=uu(r))}});var Oo=c((yf,Po)=>{"use strict";var pu=j();Po.exports=!pu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Mo=c((bf,Lo)=>{"use strict";var hu=se(),du=N(),mu=xe(),fu=Ro(),vu=Oo(),ko=fu("IE_PROTO"),Sr=Object,yu=Sr.prototype;Lo.exports=vu?Sr.getPrototypeOf:function(r){var e=mu(r);if(hu(e,ko))return e[ko];var t=e.constructor;return du(t)&&e instanceof t?t.prototype:e instanceof Sr?yu:null}});var Fo=c((gf,Vo)=>{"use strict";Vo.exports={}});var No=c((Cf,jo)=>{"use strict";var bu=D(),Rr=se(),gu=Ie(),Cu=br().indexOf,Eu=Fo(),$o=bu([].push);jo.exports=function(r,e){var t=gu(r),i=0,n=[],o;for(o in t)!Rr(Eu,o)&&Rr(t,o)&&$o(n,o);for(;e.length>i;)Rr(t,o=e[i++])&&(~Cu(n,o)||$o(n,o));return n}});var qo=c((Ef,_o)=>{"use strict";_o.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Do=c((Tf,Bo)=>{"use strict";var Tu=No(),Iu=qo();Bo.exports=Object.keys||function(e){return Tu(e,Iu)}});var Ko=c((If,Wo)=>{"use strict";var Go=ee(),xu=j(),zo=D(),wu=Mo(),Au=Do(),Su=Ie(),Ru=Ut().f,Uo=zo(Ru),Pu=zo([].push),Ou=Go&&xu(function(){var r=Object.create(null);return r[2]=2,!Uo(r,2)}),Ho=function(r){return function(e){for(var t=Su(e),i=Au(t),n=Ou&&wu(t)===null,o=i.length,s=0,a=[],l;o>s;)l=i[s++],(!Go||(n?l in t:Uo(t,l)))&&Pu(a,r?[l,t[l]]:t[l]);return a}};Wo.exports={entries:Ho(!0),values:Ho(!1)}});var Qo=c(()=>{"use strict";var ku=Re(),Lu=Ko().values;ku({target:"Object",stat:!0},{values:function(e){return Lu(e)}})});var Yo=c((Af,Xo)=>{"use strict";Qo();var Mu=lt();Xo.exports=Mu.Object.values});var Jo=c((Sf,Zo)=>{"use strict";var Vu=Yo();Zo.exports=Vu});var wt=c((Rf,ea)=>{"use strict";var Fu=Jo();ea.exports=Fu});var Mr=c((Kf,aa)=>{"use strict";var Bu=Te();aa.exports=Array.isArray||function(e){return Bu(e)==="Array"}});var la=c((Qf,sa)=>{"use strict";var Du=TypeError,Hu=9007199254740991;sa.exports=function(r){if(r>Hu)throw Du("Maximum allowed index exceeded");return r}});var pa=c((Xf,ua)=>{"use strict";var Gu=Mr(),zu=Oe(),Uu=la(),Wu=dr(),ca=function(r,e,t,i,n,o,s,a){for(var l=n,p=0,d=s?Wu(s,a):!1,f,m;p<i;)p in t&&(f=d?d(t[p],p,e):t[p],o>0&&Gu(f)?(m=zu(f),l=ca(r,e,f,m,l,o-1)-1):(Uu(l+1),r[l]=f),l++),p++;return l};ua.exports=ca});var ma=c((Yf,da)=>{"use strict";var Ku=we(),Qu=Ku("toStringTag"),ha={};ha[Qu]="z";da.exports=String(ha)==="[object z]"});var va=c((Zf,fa)=>{"use strict";var Xu=ma(),Yu=N(),St=Te(),Zu=we(),Ju=Zu("toStringTag"),ep=Object,tp=St(function(){return arguments}())==="Arguments",rp=function(r,e){try{return r[e]}catch{}};fa.exports=Xu?St:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=rp(e=ep(r),Ju))=="string"?t:tp?St(e):(i=St(e))==="Object"&&Yu(e.callee)?"Arguments":i}});var ba=c((Jf,ya)=>{"use strict";var ip=D(),np=N(),Vr=pt(),op=ip(Function.toString);np(Vr.inspectSource)||(Vr.inspectSource=function(r){return op(r)});ya.exports=Vr.inspectSource});var xa=c((ev,Ia)=>{"use strict";var ap=D(),sp=j(),ga=N(),lp=va(),cp=ct(),up=ba(),Ca=function(){},Ea=cp("Reflect","construct"),Fr=/^\s*(?:class|function)\b/,pp=ap(Fr.exec),hp=!Fr.test(Ca),_e=function(e){if(!ga(e))return!1;try{return Ea(Ca,[],e),!0}catch{return!1}},Ta=function(e){if(!ga(e))return!1;switch(lp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return hp||!!pp(Fr,up(e))}catch{return!0}};Ta.sham=!0;Ia.exports=!Ea||sp(function(){var r;return _e(_e.call)||!_e(Object)||!_e(function(){r=!0})||r})?Ta:_e});var Ra=c((tv,Sa)=>{"use strict";var wa=Mr(),dp=xa(),mp=ae(),fp=we(),vp=fp("species"),Aa=Array;Sa.exports=function(r){var e;return wa(r)&&(e=r.constructor,dp(e)&&(e===Aa||wa(e.prototype))?e=void 0:mp(e)&&(e=e[vp],e===null&&(e=void 0))),e===void 0?Aa:e}});var Oa=c((rv,Pa)=>{"use strict";var yp=Ra();Pa.exports=function(r,e){return new(yp(r))(e===0?0:e)}});var ka=c(()=>{"use strict";var bp=Re(),gp=pa(),Cp=xe(),Ep=Oe(),Tp=Pe(),Ip=Oa();bp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Cp(this),i=Ep(t),n=Ip(t,0);return n.length=gp(n,t,t,i,0,e===void 0?1:Tp(e)),n}})});var La=c(()=>{"use strict";var xp=dt();xp("flat")});var Va=c((sv,Ma)=>{"use strict";ka();La();var wp=mt();Ma.exports=wp("Array","flat")});var $a=c((lv,Fa)=>{"use strict";var Ap=Va();Fa.exports=Ap});var Na=c((cv,ja)=>{"use strict";var Sp=$a();ja.exports=Sp});var Ur="1.0.30-dev.b736679d.0";function fe(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 ve(r){for(;r>Math.PI;)r-=2*Math.PI;for(;r<=-Math.PI;)r+=2*Math.PI;return r}function Is(r){return r*180/Math.PI}var ze=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=ve(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,f=!!(o%Math.PI/2)&&!d,m=f?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:Is(o),rotateAngleRaw:e.rotateAngle,fromRight:s,fromTop:a,fromBottom:l,fromLeft:p}),this.useSkew=f,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 O="interactive";var P={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},Wr=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Wr||{}),Kr=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Kr||{}),Qr=(i=>(i.start="left",i.end="right",i.center="center",i))(Qr||{}),Ue=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&Wr[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&Kr[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&Qr[e.alignment])??"left"},We=({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},Ke=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=fe(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},ye=({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=fe(n?t.borderColor:e?.shape?.border?.color??t.borderColor,n?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=s},Xr=({target:r,frameToneIsDark:e,baseDimension:t,fallback:i})=>{let s=fe(i.shadowColorLight,i.shadowColorAlpha),a=fe(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,p=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${p} ${e?s:a}`;r.style.boxShadow=d},ie=({target:r,layoutParams:e,fallback:t})=>{let i=ve(e.angle??t.angle);i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var Vt="int",X=(i=>(i.AREA=`${Vt}_area`,i.TEXT=`${Vt}_text`,i.BUTTON=`${Vt}_bttn`,i))(X||{});function Qe(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(`${O}-control-container-${this.control.id}`),e.setControlLayout(t,this.control.layoutParams);let i=(this.control.layoutParams.innerSizesDependOn??P.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&&Qe(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 Yr=!1,Zr=60,ne=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:Yr?t.offsetWidth:Zr,height:Yr?t.offsetHeight:Zr},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=xs(l,p,ve(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 xs(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var Xe=(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(`${O}-${this.control.id}`,`${O}-control`,`${O}-control-area`),n.setAttribute("data-testid",X.AREA),this.controlElement=n,Ke({target:n,props:this.control.props,fallback:{...P,backgroundColor:"transparent"}}),this.updateShadowStyles(),ie({target:n,layoutParams:this.control.layoutParams,fallback:P}),this.featureIsEnabled("tapPlaceShow")){let o=this.control.layoutParams.angle??P.angle;this.tapElement=new ne(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";Xr({target:this.controlElement,props:this.control.props,fallback:P,frameToneIsDark:s,baseDimension:o}),ye({target:this.controlElement,props:this.control.props,fallback:{...P,borderColor:s?"#fff":"#000",borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??P.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else ye({target:this.controlElement,props:this.control.props,fallback:{...P,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 Ye=()=>{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 Ze=(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(`${O}-${this.control.id}`,`${O}-control`,`${O}-control-button`),n.setAttribute("data-testid",X.BUTTON),ie({target:n,layoutParams:this.control.layoutParams,fallback:P}),Ke({target:n,props:this.control.props,fallback:P}),ye({target:n,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),Ue({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let o=Ye();if(We({target:o,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("buttonControlInteractiveTimeTimer")&&(this.fillAnimation=new ze({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??P.angle,borderRadius:n.style.borderRadius})),this.featureIsEnabled("tapPlaceShow")){let s=this.control.layoutParams.angle??P.angle;this.tapElement=new ne(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 Jr=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(`${O}-${this.control.id}`,`${O}-control`,`${O}-control-text`),n.setAttribute("data-testid",X.TEXT),ie({target:n,layoutParams:this.control.layoutParams,fallback:P}),Ue({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let o=Ye();We({target:o,props:this.control.props,fallback:P,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}},Je=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 oe=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&&Qe(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]},[])||[]}};import{isSupportedManifest as nt,ContainerTypes as Wh,ControlTypes as J,EventActionTypes as x,EventTypes as Kh,migrateManifestToLatestVersion as ii,compareVersions as Qh}from"@interactiveplatform/movika-manifest";var Y=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,be=r=>Y(r,"Object"),et=r=>Y(r,"String"),tt=r=>Y(r,"Array"),rt=r=>Y(r,"Number"),ei=r=>Y(r,"Function");var _t=r=>rt(r)&&!isNaN(r);var Z=r=>be(r)&&Object.keys(r).length===0,qt=r=>tt(r)&&!r.length;var ge=(r,e)=>et(r)&&(e?r.trim():r).length;var ti={metadata:"Object",chapters:"Array"},ri=r=>{if(!be(r))return!1;for(let e in ti)if(!r[e]||!Y(r[e],ti[e]))return!1;return nt(r.metadata.version)},it=r=>r.type===J.Text,Nh=r=>r.type===J.Button,_h=r=>r.type===J.Area,qh={Choice:"Choice",TextInput:"TextInput"},Bh={Button:"Button",Area:"Area",Text:"Text"},Dh={onClick:"onClick",onSuspense:"onSuspense"},Hh={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var ot=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Bt(r,e,t)},Bt=class extends oe{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 Je(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.willRemoved=!1,this.addControlFactory("button",Ze),this.addControlFactory("text",Jr),this.addControlFactory("area",Xe)}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(`${O}-${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===J.Button||s===J.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(`.${O}-${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=W(ft(),1),fs=W(gr(),1);import{clientChecker as Hp,combine as Gp,InterfaceLanguage as zp,Observable as ps,once as Up,Subject as F,Subscription as kt,ValueSubject as $,fromEvent as hs}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as He}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as eu}from"@vkontakte/videoplayer-shared";function ke(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var bo="video_interactive",go="videoint";var Co=250,Le=class{constructor(e){this.handleZoomChange=ke(e=>{this.lastZoomInfo=e},Co);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,!rt(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=tu(e),this.resizeObserver=new ResizeObserver(ke(this.onResize,Co)),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 eu(this.lang,bo,go)}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 tu(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 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(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 vt=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 yt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{ei(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as lu}from"@vkontakte/videoplayer-shared";var bt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return ru(...this.loaders[e])(t)}};function ru(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Ve(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function gt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let 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:Ve(e,gt.name,"Could not find media"),actions:r}}}}return{...i,errors:Ve(e,gt.name,"Could not find chapter"),actions:r}}var Ct=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}},pe=class extends Ct{constructor(){super(),this.listeners||Ct.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)}},Fe=class{constructor(){Object.defineProperty(this,"signal",{value:new pe,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&&(Fe.prototype[Symbol.toStringTag]="AbortController",pe.prototype[Symbol.toStringTag]="AbortSignal");function Et(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 Cr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Et({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 f;d&&d.signal&&(f=d.signal,delete d.signal);let m=new t(p,d);return f&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),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 f;try{f=new DOMException("Aborted","AbortError")}catch{f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let m=new Promise((y,S)=>{d.addEventListener("abort",()=>S(f),{once:!0})});return p&&p.signal&&delete p.signal,Promise.race([m,s(l,p)])}return s(l,p)},Request:o}}var $e=Et({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Eo=$e?Cr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Er=$e?Eo.fetch:window.fetch,Qm=$e?Eo.Request:window.Request,Xm=$e?Fe:window.AbortController,Ym=$e?pe:window.AbortSignal;var Tr=(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 iu=async r=>{try{let e={},t;if(et(r)){t=new URL(r).href;let n=await Er(t);if(!n.ok)return{};e=await n.json()}else if(be(r))e=r;else return{};if(!ri(e))return{};let i=e.metadata.media;if(et(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await Er(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return au(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function To(r){let{manifest:e,manifestURL:t}=await iu(r);if(!e)throw new Error("Failed on fetch");let i=ii(e);return i.media=nu(i.media,t),delete i.metadata.media,i}function Tt(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 nu(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=ou(n,e);return{...i,url:o||n}})}))}}function ou(r="",e){try{return new URL(r,e).href}catch{return""}}function au(r){return Tr(r,"3.2.0")>=0}var It=r=>tt(r)&&!qt(r),z=r=>r.order==="end",xt=r=>tt(r.containers)&&!qt(r.containers)&&z(r),Io=(r,e)=>{let t=r*1e3;return It(e.controls)&&t<(e.startTime??0)},wr=(r,e)=>{let t=r*1e3;return It(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"),su=r=>r?.length===1,he=r=>su(r)&&it(r[0]);function xo(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r({...e[0],...t}):r(...e,...t)}var wo=(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 de=class extends bt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new lu(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:Ve},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await To(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",gt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Ir,getChapter:Tt,getMedia:xr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ve},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=Tt(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=Tt(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?z(this.chapter):!1}};var ia=W(wt(),1);import{Player as $u}from"@vkontakte/videoplayer-core";import{Subscription as kr,Tracer as ju,ValueSubject as Nu}from"@vkontakte/videoplayer-shared";var ta=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 ra=W(wt(),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,ra.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=W(ft(),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 je=(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 _u=2;function Lr(r){let e=Pr(),t=new kr,i={},n=null,o=!1,s,a=new Nu(null);r&&l(r);function l(I){n=I}function p(I,A,u){if(!n)throw Error("need to set interactive controller");if(!n.options)return;let v=(e.map.get(I)??{})[A];if(v){i={chapterId:u,listId:I,itemId:A,...v};let b=i.player;i.subscription.add(b.info.currentQuality$.subscribe(g=>{let C=b.info.position$.getValue(),w=b.info.isAutoQualityEnabled$.getValue();if(!(!g||!C||w))for(let k of e.map)(0,ia.default)(k[1]).forEach(({player:T})=>{je(T,g)})})).add(b.events.started$.subscribe(()=>{d(A)})),v.container.remove(),n.setPlayer(v.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(I){if(!n)throw Error("need to set interactive controller");if(Z(i)||I!==i.itemId)return;let A=n.getChapterBranches(),u=new Set;for(let h of A)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 f({chapter:{id:I},manifestVideo:A}){if(Z(i)||!n)return;let u=i.player.info.muted$.getValue(),h=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),b=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),C=!v,w=!1;for(let k of e.map)if(k[0]===A.id&&!n.state.isReplay$.getValue()){let T=Object.keys(k[1]);for(let M of T)M===i.itemId?(T.length<_u||(w=!0),e.removePlayer(k[0],M)):(w=!0,p(k[0],M,I),C?je(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(b),i.player.setMuted(u),i.player.setPlaybackRate(g))}else e.removePlayer(k[0]);w||(await m({media:A,chapterId:I,setAsActive:!0,playbackRate:g}),C?je(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(b),i.player.setMuted(u))}async function m({media:I,chapterId:A,prefetch:u=!0,setAsActive:h=!0,autoplay:v=!1,preferredExt:b,title:g,playbackRate:C}){let w=Math.random().toString(),k=document.createElement("div");s.append(k);let T;if(n?.options?.vkVideoLoader){let Ge=ta(I);Ge.length&&(T=await n.options.vkVideoLoader(...Ge))}let M=n?.options?.coreConfig||void 0,_={...M,configName:[...M?.configName??[],"interactive"]},q={container:k,...T?.videos?.[0]||{sources:Or(I,b).sources},title:g,failoverHosts:T?.failoverHosts||[]},B=new $u(_,ju.createRootTracer());B.initVideo(q);let U=null;if(T?.videos&&n?.options.createOneStat){let Ge=T.videos[0],Mt=n.options.createOneStat(Ge),Gr=new kr;Mt&&(Gr.add(Mt.attachTo(B)),U={oneStat:Mt,statSubscription:Gr})}let te=new kr,vs=i?.player?.info.isAutoQualityEnabled$.getValue();te.add(B.events.canplay$.subscribe(function(){vs||je(B,i.player.info.currentQuality$.getValue()),C&&B.setPlaybackRate(C)}));let re=e.createPlayer({listId:I.id,itemId:w,player:B,container:k,sources:Or(I,b).sources,config:q,subscription:te,statistics:U});return h&&p(I.id,re.itemId,A),v&&re.player.play(),u&&!v&&re.player.prepare(),{player:re.player,config:re.config,statistics:re.statistics}}function y(){S(),n=null,s.remove()}function S(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function L(){if(!n)throw Error("need to set interactive controller");S(),s=document.createElement("div");let{media:I,chapter:A}=n.getCurrentChapter();I&&A?(t.add(n.events.chapterChanged$.subscribe(f)),await m({media:I,chapterId:A.id,title:A.label})):console.error("not found")}return{...e,init:L,setInteractiveController:l,createPlayer:m,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:a}}var E={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ne={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},R={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as qu}from"@vkontakte/videoplayer-shared";var At=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:s,globalEventEmitter:a,ignoreContainerEvent:l,permanentTextControls:p,disabledControls$:d,onRemove:f,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=xo(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(Io(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(E.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 qu,this.player=e,this.interactiveEvents=o,this.ignoreContainerEvent=l,this.isPermanentText=p&&he(t.container.controls),this.disabledControls$=d,this.onRemove=f,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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.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(E.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){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(E.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?.()}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 oa=(r=[])=>r.reduce((e,t,i)=>{let n=(t?.controls??[]).filter(o=>!it(o));if(It(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=[],f=[];for(let m=0;m<e.length;m++){let y=e[m];if(f.push(...y.subjects),y.range[0]<p&&(p=y.range[0]),y.range[1]>l&&(l=y.range[1]),o[0]>=y.range[0]&&o[1]<=y.range[1])return e[m].subjects.push(s),e;o[0]<y.range[0]&&o[1]>y.range[0]&&(a.push(m),d=d.concat(y.subjects)),o[0]>=y.range[0]&&o[0]<=y.range[1]&&(a.push(m),d=d.concat(y.subjects),o[0]=y.range[0]),o[1]>=y.range[0]&&o[1]<=y.range[1]&&(a.push(m),d=d.concat(y.subjects),o[1]=y.range[1])}if(f.push(s),o[0]<=p&&o[1]>=l)return[{subjects:f,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 qa=W(ft(),1),$r=W(wt(),1),Ba=W(Na(),1);function _a(){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&&ge(l,!0)){let f={},m=d[l];return m&&(f={...f,...m}),f=Z(f)?null:f,f&&ge(p,!0)?f[p]??null:f}return d}return null}function o({timestamp:a,priority:l,initiator:p}){if(_t(a))if(r[a]){if(l&&ge(l,!0))if(r[a][l]){if(p&&ge(p,!0))if(r[a][l][p]){if(delete r[a][l][p],!Z(r[a][l]))return!0}else return!1;if(delete r[a][l],!Z(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 Rp=[x.expect,x.setNextBranch],Pp=1/0;function Da(r){let e=r,t,i=Op(),n=_a(),o,s=()=>{m(),A()},a=u=>{n.add.call(void 0,u),S()},l=(u=[])=>{for(let h of u)if(h.action(),(0,qa.default)(Rp,h.actionType))break},p=(u=1/0)=>{let h=Rt(n.get({timestamp:u,priority:"control"})??{}),v=Rt(n.get({timestamp:u,priority:"container"})??{}),b=Rt(n.get({timestamp:u,priority:"chapter"})??{});return[...h,...v,...b]},d=u=>{i.isReady(u)&&l(p(u))},f=()=>{l([...Rt(n.get({timestamp:1/0,priority:"chapter"})??{})])},m=()=>{t&&(o?.unsubscribe(),t=void 0)},y=u=>{},S=()=>{t||(t=()=>setTimeout(()=>{d(1/0)}),o=e.events.ended$.subscribe(t))},L=u=>{m(),e=u},I=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},A=()=>{i.release(),n.removeAll()};return{setPlayer:L,add:a,remove:I,exec:d,execEndOfVideo:f,listen:S,unlisten:m,release:s,containersEventsCallState:i,getPreparedToExecActions:p}}function Op(){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??Pp,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,$r.default)(a).some(l=>!l):!0},release:()=>r.clear()}}function Rt(r){return(0,Ba.default)((0,$r.default)(r)).sort(e=>e.actionType===x.expect?-1:1)}var Ha={videoContentHeight:0,videoContentWidth:0},Ga=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ha;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ha;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 kp=250;function za(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:f}=Ga(p);l.style.setProperty("--interactive-content-width",`${Math.ceil(d)}px`),l.style.setProperty("--interactive-content-height",`${Math.ceil(f)}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=ke(a=>{let{fns:l=[]}=r();i(a);for(let p of l)p()},kp);function s(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e?.()},release:s}}var Lp=r=>Math.floor(Math.random()*r),Wa=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},Ka=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 Qa=r=>{let e=r.length,t=Lp(e);return r[t]},Ua=1,Xa=r=>{let e=0;for(let i=0;i<r.length;++i)e+=r[i].weight??Ua;let t=Math.random()*e;e=0;for(let i=0;i<r.length-1;++i)if(e+=r[i].weight??Ua,e>=t)return r[i];return r[r.length-1]};var Ya={shouldOpenNow:!0,isDetachContainer:!0},Za="after-expect";var jr=(r,e=!1)=>({...r,args:e?{...r.args,...Ya}:{...Ya,...r.args}}),ts=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},s=({action:u,controlType:h,controlId:v,containerId:b,branches:g=[],onEvent:C,isEOV:w=()=>!1,isDisabled:k=()=>!1})=>{let T=jr(u,w()),M={timestamp:1/0,priority:"control",initiator:v,actionType:T.type},_=k(),q=r.emit.bind(r,E.interactives,{subjectId:v,subjectType:h,subjectName:"control",type:_?R.actionChoiceCanceled:R.actionChoice,actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:b,...T.args}}),B=()=>{e.interactiveActionChoice$.next({subjectId:v,subjectType:h,subjectName:"control",type:_?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:b,...T.args}})};if(_){q(),B();return}switch(T.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let U=g.find(te=>te.id===T.args.branchId);if(!U)return;C(T.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),q(),B(),T.args.shouldOpenNow?L({subjectId:v,subjectName:"control",subjectType:h,action:T,payload:{chapterId:U.chapterId,autoSelect:!1}}):i.add({...M,action:L.bind(null,{subjectId:v,subjectName:"control",subjectType:h,action:T,payload:{chapterId:U.chapterId,autoSelect:!1}})});return}case x.continuePlayback.trim().toLowerCase():{C(T.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),q(),B(),T.args.shouldOpenNow?S({subjectId:v,subjectName:"control",subjectType:h,action:u}):i.add({...M,action:S.bind(null,{subjectId:v,subjectName:"control",subjectType:h,action:u})});return}case x.openURI.trim().toLowerCase():{C(T.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),q(),B(),T.args.shouldOpenNow?A({subjectId:v,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}}):i.add({...M,action:A.bind(null,{subjectId:v,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}})});return}default:{let U="Unexpected control event",te=new V(1,1,{message:U});d(te,U);return}}},a=({action:u,container:{id:h,endTime:v},branches:b=[],isEOV:g=!1,autoSelected:C=!1})=>{let w=jr(u,g),k={timestamp:!w.args.shouldOpenNow||g?1/0:v??1/0,priority:"container",initiator:h,actionType:w.type},T=r.emit.bind(r,E.interactives,{subjectId:h,subjectName:"container",type:R.actionChoice,actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}})};switch(w.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let _=b.find(q=>q.id===w.args.branchId);if(!_)return;T(),M(),i.add({...k,action:L.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{chapterId:_.chapterId,autoSelect:C}})});return}case x.setMaxWeightBranch.trim().toLowerCase():return;case x.setMinWeightBranch.trim().toLowerCase():return;case x.setRandomBranch.trim().toLowerCase():return;case x.setWeightlessRandomBranch.trim().toLowerCase():return;case x.continuePlayback.trim().toLowerCase():{T(),M(),i.add({...k,action:S.bind(null,{subjectId:h,subjectName:"container",action:w})});return}case x.openURI.trim().toLowerCase():{T(),M(),i.add({...k,action:A.bind(null,{subjectId:h,subjectName:"container",action:w,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:v=!1}){let b=Ar(u.events);if(b){let g=jr(b.action,v);r.emit(E.interactives,{subjectId:u.id,subjectName:"container",type:R.actionChoice,actionType:g.type,payload:{invokeImmediately:g.args.shouldOpenNow,...g.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:g.type,payload:{invokeImmediately:g.args.shouldOpenNow,...g.args}}),i.add({timestamp:v?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:x.expect,action:m.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let g of u.events??[])a({action:g.action,container:u,branches:h,isEOV:v})}let p=({chapterId:u,action:h,branches:v=[]})=>{let b=r.emit.bind(r,E.interactives,{subjectId:u,subjectName:"chapter",type:R.actionChoice,actionType:h.type,payload:h.args}),g=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let C=v.find(w=>w.id===h.args.branchId);return C?.chapterId?(b(),g(),L.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.setWeightlessRandomBranch.trim().toLowerCase():{let C=Qa(v);return C?.chapterId?(b(),g(),L.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.setRandomBranch.trim().toLowerCase():{let C=Xa(v);return C?.chapterId?(b(),g(),L.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.setMaxWeightBranch.trim().toLowerCase():{let C=Ka(v);return C?.chapterId?(b(),g(),L.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.setMinWeightBranch.trim().toLowerCase():{let C=Wa(v);return C?.chapterId?(b(),g(),L.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case x.continuePlayback.trim().toLowerCase():return b(),g(),S.bind(null,{subjectId:u,subjectName:"chapter",action:h});case x.openURI.trim().toLowerCase():return b(),g(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let C="Unexpected chapter event",w=new V(1,1,{message:C});d(w,C);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(E.errors,u)}function f(u){let h=Ar(u.events);if(h){if(z(u))return;r.emit(E.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:x.expect,action:m.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(v=>{let b=p({chapterId:u.id,action:v.action,branches:u.branches});b&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:v.action.type,action:b})})}let m=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(E.interactives,{subjectId:u,subjectName:h,type:R.actionExecution,actionType:x.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:x.expect})},y=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(E.interactives,{subjectId:u,subjectName:h,type:R.actionExecution,actionType:Za}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:Za})},S=({subjectId:u,subjectName:h,subjectType:v,action:b})=>{r.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:v,type:R.actionExecution,actionType:b.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:b.type})},L=({subjectId:u,subjectName:h,subjectType:v,action:b,payload:g})=>{g.behaviour="change-chapter",r.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:v,type:R.actionExecution,actionType:b.type,payload:g}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:b.type,payload:g})},I=({subjectId:u,subjectName:h,subjectType:v,action:b,payload:g})=>{g.behaviour="change-manifest",r.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:v,type:R.actionExecution,actionType:b.type,payload:g}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:b.type,payload:g})},A=({subjectId:u,subjectName:h,subjectType:v,action:b,payload:g})=>{if(!g.URI)return;let C=window.open(g.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(E.interactives,{subjectId:u,subjectName:h,subjectType:v,type:R.actionExecution,actionType:b.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:b.type})};return{onControlEvent:s,onContainerEvent:a,onChapterEvent:p,onExpectEvent:m,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:o,state:n}};var qr=W(gr(),1);import{Subscription as jp,Subject as _r,ValueSubject as qe}from"@vkontakte/videoplayer-shared";var Nr=(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]=rs(o)}return t[i]}).filter(Boolean)},Vp=r=>{for(let e of r.variants)if(Fp(e)&&e.payload)return e.payload.id},Fp=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),rs=r=>{let e=Vp(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},$p=(r,e)=>{for(let t of r.media.videos)if(e===rs(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},is=(r,e)=>r.reduce((t,i)=>{let n=$p(e,i);return n?[...t,n]:t},[]);var Be=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new qe([]),hasPrevChapter$:new qe(!1),prevChapter$:new qe(null),isInitialChapter$:new qe(!1),isGoBackLimited$:new qe(!1)};this.#r=null;this.#a=!1;this.#e=null;this.#u=null;this.events={inited$:new _r,destroyed$:new _r,error$:new _r};this.#i=null;this.#n=null;this.#t=null;this.#s=new jp;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,qr.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=Nr(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(E.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(E.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(E.errors,o)}let i=is(t,e);this.state.history$.next(i)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,qr.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return Nr([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(E.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var Pt=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 Ot=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 @@ var no=Object.create;var Dr=Object.defineProperty;var so=Object.getOwnPropertyDe
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new Pt,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 ns(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Np=`
|
|
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
|
+
`,_p=`
|
|
88
|
+
${Np}
|
|
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 Ot=class{constructor(e){this.subscription=new qr;this.globalEventEmitter=new pt;this.eventsSubs=new qr;this.animation=new ht;this.eventManager=new wt;this.seekToInteractiveController=new Oe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Op();this.factories=new Map([["choice",Qe]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new qr;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new N(null),isInitialChapter$:new N(!1),isFirstChapter$:new N(!0),isEndChapter$:new N(!1),isInteractiveExpectation$:new N(!1),isReplay$:new N(!1),calledByInteractive$:new N(!1),lastChapterChangeWasInitiatedByInteractive$:new N(!1),disabledControls$:new N(!1),interactiveRanges$:new N([]),isInteractiveTime$:new N(!1),statistics$:new N(null),isSeekable$:new N(!1)};this.events={noInteraction$:new $,graphVisibilityChanged$:new $,watchAgainIsClicked$:new $,chapterChanged$:new $,playerChanged$:new $,error$:new $,eachTick$:new $,manifestChanged$:new $,interactiveRangeEnded$:new $,interactiveContainerRemoved$:new $,interactiveActionExecution$:new $,interactiveActionChoice$:new $,interactiveVisibilityChanged$:new $};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(E.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),r=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&G(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(E.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={...ro,...e,config:{...ro.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new _e({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 Rt({parentElement:this._options.parentElement,onError:r=>{let i=new M(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 he(this._options.loaders,r=>{let i=new M(1,3,r);this.emitErrorEvent(i)}),this.resizeManager=Ba(()=>({player:this.player,parentElement:this._options?.parentElement,fns:this._options?.lastFrame?[()=>{this.lastFrame?.updateCanvasDimensions(!0)}]:[]})),this._options.graph&&(this.graph=new Re({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:r=>{this.setChapter({chapterId:r}),this.globalEventEmitter.emit(E.graph,{type:je.watchAgainClicked,chapterId:r}),this.events.watchAgainIsClicked$.next(r)},onError:r=>{let i=new M(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(E.interactives,async e=>{e.type===A.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=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 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(E.interactives,{type:A.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(Rp()).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(wp({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=>!pe(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 It({player:this.player,container:c,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>us(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&&G(i)&>(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,io.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(E.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=_a(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Xa({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()),Sp.isSafari&&await eo(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(E.chapterChanged,{chapter:s,media:c,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new to(e=>{this.eventsSubs.add(this.events.graphVisibilityChanged$.subscribe(r=>{e.next(r?Fe.GRAPH_SHOW:Fe.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Fe.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:r,subjectName:i,subjectType:n})=>{r!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Fe.NEXT_BUTTON),n==="Area"&&e.next(Fe.NEXT_AREA))}))}),nextMovie$:new to(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(E.graph,{type:je.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===S.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&&te(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&<(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 ta(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 Pp={Container:ne,createChoiceContainer:Qe,createAreaControl:Ge,createButtonControl:We,getRootEl:qe,classnamesPrefix:L};var Gv={version:Hr};export{zd as ContainerTypes,ut as ControlTypes,M as CustomError,E as EVENT_NAMES,S as EventActionTypes,Wd as EventTypes,Ot as Interactives,he as ManifestController,Gv as SDKInfo,Nr as chapterIdsToVKVideoIds,Cr as compareVersions,qd as containerTypes,Bd as controlTypes,ns as eventActionTypes,Dd as eventTypes,Tp as getChapterIdByVkVideoId,Za as getVKVideoIdByMedia,Ep as getVideoRawIdByMedia,je as graphEventTypes,gt as hasEndTemplate,A as interactivesEventTypes,Fd as isAreaControl,_d as isButtonControl,G as isLastChapter,pe as isOneTextCtrlContainer,lt as isSupportedManifest,ct as isTextControl,Ip as isVKVariantItem,is as isValidManifest,ss as migrateManifestToLatestVersion,Pp as utils,Ja as vkVideoIdsToChapterIds};
|
|
245
|
+
pointer-events: none;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.interactive-blink-reference-disable-animation {
|
|
249
|
+
animation: none;
|
|
250
|
+
}
|
|
251
|
+
`,os=r=>{let e=document.createElement("style");e.textContent=_p,r.prepend(e)};var qp=typeof window>"u",Bp=typeof OffscreenCanvas<"u";function as(){return qp?Bp?new OffscreenCanvas(1,1):null:document.createElement("canvas")}function ss(r){return(r[0]*299+r[1]*587+r[2]*114)/1e3<128}var Br=[0,0,0,0],ls=1,Dp="AverageColor: ";function Dr(r){return Error(Dp+r)}function Hr(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 De=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||ls,defaultColor:t.defaultColor??Br,debug:t.debug??!1};if(!this.canvas&&(this.canvas=as(),!this.canvas))return this.prepareResult(i.defaultColor,Dr("Failed to create canvas"));if(!this.ctx){if(this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),!this.ctx)return this.prepareResult(i.defaultColor,Dr("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 Br;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 f=e[d],m=e[d+1],y=e[d+2],S=e[d+3];n+=f*f*S,o+=m*m*S,s+=y*y*S,a+=S,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=ss(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 cs=()=>{let r=document.createElement("div");return r.classList.add("interactive-blink-reference-animation","interactive-control-cta-button"),r},us=r=>{r.classList.add("interactive-blink-reference-disable-animation"),requestAnimationFrame(()=>{r.classList.remove("interactive-blink-reference-disable-animation")})};var ds=Object.freeze({lang:zp.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 Wp(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Lt=class{constructor(e){this.playerSubscriptions=new kt;this.subscriptions=new kt;this.globalEventEmitter=new vt;this.eventsSubs=new kt;this.animation=new yt;this.seekToInteractiveController=new Me;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Wp();this.factories=new Map([["choice",ot]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new kt;this.graph=null;this.lastFrame=null;this.frameAverageColor=null;this.appState=0;this.state={prevChapter$:new $(null),isInitialChapter$:new $(!1),isFirstChapter$:new $(!0),isEndChapter$:new $(!1),isInteractiveExpectation$:new $(!1),isReplay$:new $(!1),calledByInteractive$:new $(!1),lastChapterChangeWasInitiatedByInteractive$:new $(!1),disabledControls$:new $(!1),interactiveRanges$:new $([]),isInteractiveTime$:new $(!1),statistics$:new $(null),isSeekable$:new $(!1)};this.events={noInteraction$:new F,graphVisibilityChanged$:new F,watchAgainIsClicked$:new F,chapterChanged$:new F,playerChanged$:new F,error$:new F,eachTick$:new F,manifestChanged$:new F,interactiveRangeEnded$:new F,interactiveContainerRemoved$:new F,interactiveActionExecution$:new F,interactiveActionChoice$:new F,interactiveVisibilityChanged$:new F};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(E.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&z(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(E.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(cs()),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 Ot({parentElement:this._options.parentElement,onError:i=>{let n=new V(1,6,i);this.emitErrorEvent(n)}})),os(this._options.parentElement),this.subscriptions.add(hs(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(hs(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new de(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=za(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Le({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(E.graph,{type:Ne.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 De),this.initSubscriptions()}async getVideoFrameAverageColorInfo(){if(!this.frameAverageColor||!this.player)return;let e=this.player.experimental.element$.getValue();if(!e||!e.readyState)return;let t=Hr(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&&us(i)}this.execForAllExpectContainers({...e,execFnName:"toggleControlsCTAAnimation"})}}async initSeamless(){this.seamlessController=Lr(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(E.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.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(Up()).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(Gp({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,f],subjects:m})=>d<l&&l<f&&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=>!he(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 At({player:this.player,container:s,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>wo(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&&z(i)&&xt(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(E.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=Da(this.player),this.selectBranches=ts({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&&Hp.isSafari&&await ns(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(E.chapterChanged,{chapter:o,media:s,graph:a}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new ps(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?He.GRAPH_SHOW:He.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(He.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(He.NEXT_BUTTON),n==="Area"&&e.next(He.NEXT_AREA))}))}),nextMovie$:new ps(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(E.graph,{type:Ne.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===x.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&&nt(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 oa(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 Kp={Container:oe,createChoiceContainer:ot,createAreaControl:Xe,createButtonControl:Ze,classnamesPrefix:O};var Ry={version:Ur};export{Wh as ContainerTypes,J as ControlTypes,V as CustomError,E as EVENT_NAMES,x as EventActionTypes,Kh as EventTypes,Lt as Interactives,de as ManifestController,Ry as SDKInfo,Nr as chapterIdsToVKVideoIds,Tr as compareVersions,qh as containerTypes,Bh as controlTypes,Hh as eventActionTypes,Dh as eventTypes,$p as getChapterIdByVkVideoId,rs as getVKVideoIdByMedia,Vp as getVideoRawIdByMedia,Ne as graphEventTypes,xt as hasEndTemplate,R as interactivesEventTypes,_h as isAreaControl,Nh as isButtonControl,z as isLastChapter,he as isOneTextCtrlContainer,nt as isSupportedManifest,it as isTextControl,Fp as isVKVariantItem,ri as isValidManifest,ii as migrateManifestToLatestVersion,Kp as utils,is as vkVideoIdsToChapterIds};
|