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