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