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