@vkontakte/videoplayer-interactive 1.0.35-dev.8f111489.0 → 1.0.35-dev.b58c8174.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 +125 -36
- package/es2015.esm.js +125 -36
- package/es2018.cjs.js +125 -36
- package/es2018.esm.js +125 -36
- package/es2024.cjs.js +149 -0
- package/es2024.esm.js +149 -0
- package/esnext.cjs.js +125 -36
- package/esnext.esm.js +125 -36
- package/evergreen.esm.js +125 -36
- package/package.json +19 -14
- package/types/modules/Graph/Graph.d.ts +1 -1
- package/types/modules/Interactives/Interactives.d.ts +4 -1
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +7 -0
- package/types/modules/Interactives/containers/Container.d.ts +1 -1
- package/types/modules/Interactives/containers/types.d.ts +1 -1
- package/types/modules/Interactives/controls/AreaControl.d.ts +7 -1
- package/types/modules/Interactives/controls/ButtonControl.d.ts +7 -1
- package/types/modules/Interactives/controls/Control.d.ts +9 -2
- package/types/modules/Interactives/controls/TextControl.d.ts +4 -1
- package/types/modules/Interactives/controls/types.d.ts +1 -1
- package/types/modules/Interactives/controls/utils.d.ts +4 -0
- package/types/modules/Interactives/index.d.ts +26 -12
- package/types/modules/Interactives/styles/index.d.ts +1 -0
- package/types/modules/Interactives/types.d.ts +5 -2
- package/types/modules/Interactives/utils/BlinkAnimationRef.d.ts +15 -0
- package/types/modules/Interactives/utils/GameController.d.ts +6 -1
- package/types/modules/Interactives/utils/ResizeManager.d.ts +1 -0
- package/types/modules/Interactives/utils/SelectBranches.types.d.ts +1 -0
- package/types/modules/Interactives/utils/fallbackStrategies.d.ts +2 -2
- package/types/modules/Interactives/utils/functionUtils.d.ts +5 -0
- package/types/modules/Interactives/utils/gameUtils.d.ts +13 -2
- package/types/modules/Interactives/utils/renderingUtils.d.ts +15 -1
- package/types/modules/ManifestController/ManifestController.d.ts +1 -1
- package/types/modules/SeamlessController/SeamlessController.d.ts +1 -1
- package/types/utils/typeCheck.d.ts +2 -2
- /package/types/modules/Interactives/{styles.d.ts → styles/utils.d.ts} +0 -0
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.35-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.35-dev.b58c8174.0
|
|
3
|
+
* Wed, 02 Apr 2025 11:47:09 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-35/doc/
|
|
5
5
|
*/
|
|
6
|
-
var Fo=Object.create;var Kt=Object.defineProperty,qo=Object.defineProperties,Bo=Object.getOwnPropertyDescriptor,Do=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertyNames,it=Object.getOwnPropertySymbols,Uo=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable;var vn=r=>{throw TypeError(r)};var mn=(r,e,t)=>e in r?Kt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&mn(r,t,e[t]);if(it)for(var t of it(e))fn.call(e,t)&&mn(r,t,e[t]);return r},x=(r,e)=>qo(r,Do(e));var Z=(r,e)=>{var t={};for(var n in r)Qt.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&it)for(var n of it(r))e.indexOf(n)<0&&fn.call(r,n)&&(t[n]=r[n]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Go=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ho(e))!Qt.call(r,i)&&i!==t&&Kt(r,i,{get:()=>e[i],enumerable:!(n=Bo(e,i))||n.enumerable});return r};var re=(r,e,t)=>(t=r!=null?Fo(Uo(r)):{},Go(e||!r||!r.__esModule?Kt(t,"default",{value:r,enumerable:!0}):t,r));var yn=(r,e,t)=>e.has(r)||vn("Cannot "+t);var w=(r,e,t)=>(yn(r,e,"read from private field"),t?t.call(r):e.get(r)),U=(r,e,t)=>e.has(r)?vn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$=(r,e,t,n)=>(yn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var bn=(r,e,t,n)=>({set _(i){$(r,e,i,t)},get _(){return w(r,e,n)}});var P=(r,e,t)=>new Promise((n,i)=>{var s=a=>{try{c(t.next(a))}catch(l){i(l)}},o=a=>{try{c(t.throw(a))}catch(l){i(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,o);c((t=t.apply(r,e)).next())});var J=p((ir,An)=>{"use strict";var Ve=function(r){return r&&r.Math===Math&&r};An.exports=Ve(typeof globalThis=="object"&&globalThis)||Ve(typeof window=="object"&&window)||Ve(typeof self=="object"&&self)||Ve(typeof global=="object"&&global)||Ve(typeof ir=="object"&&ir)||function(){return this}()||Function("return this")()});var z=p((dd,Rn)=>{"use strict";Rn.exports=function(r){try{return!!r()}catch(e){return!0}}});var Me=p((md,On)=>{"use strict";var zo=z();On.exports=!zo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Nn=p((fd,Mn)=>{"use strict";var Wo=Me(),Vn=Function.prototype,Pn=Vn.apply,kn=Vn.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(Wo?kn.bind(Pn):function(){return kn.apply(Pn,arguments)})});var Q=p((vd,$n)=>{"use strict";var Ln=Me(),jn=Function.prototype,sr=jn.call,Ko=Ln&&jn.bind.bind(sr,sr);$n.exports=Ln?Ko:function(r){return function(){return sr.apply(r,arguments)}}});var Ne=p((yd,Fn)=>{"use strict";var _n=Q(),Qo=_n({}.toString),Xo=_n("".slice);Fn.exports=function(r){return Xo(Qo(r),8,-1)}});var ar=p((bd,qn)=>{"use strict";var Yo=Ne(),Zo=Q();qn.exports=function(r){if(Yo(r)==="Function")return Zo(r)}});var W=p((Cd,Bn)=>{"use strict";var or=typeof document=="object"&&document.all;Bn.exports=typeof or=="undefined"&&or!==void 0?function(r){return typeof r=="function"||r===or}:function(r){return typeof r=="function"}});var le=p((gd,Dn)=>{"use strict";var Jo=z();Dn.exports=!Jo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ft=p((Ed,Hn)=>{"use strict";var ec=Me(),mt=Function.prototype.call;Hn.exports=ec?mt.bind(mt):function(){return mt.apply(mt,arguments)}});var cr=p(zn=>{"use strict";var Un={}.propertyIsEnumerable,Gn=Object.getOwnPropertyDescriptor,tc=Gn&&!Un.call({1:2},1);zn.f=tc?function(e){var t=Gn(this,e);return!!t&&t.enumerable}:Un});var lr=p((Td,Wn)=>{"use strict";Wn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qn=p((xd,Kn)=>{"use strict";var rc=Q(),nc=z(),ic=Ne(),ur=Object,sc=rc("".split);Kn.exports=nc(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return ic(r)==="String"?sc(r,""):ur(r)}:ur});var pr=p((Sd,Xn)=>{"use strict";Xn.exports=function(r){return r==null}});var hr=p((wd,Yn)=>{"use strict";var ac=pr(),oc=TypeError;Yn.exports=function(r){if(ac(r))throw new oc("Can't call method on "+r);return r}});var Le=p((Ad,Zn)=>{"use strict";var cc=Qn(),lc=hr();Zn.exports=function(r){return cc(lc(r))}});var Ee=p((Rd,Jn)=>{"use strict";var uc=W();Jn.exports=function(r){return typeof r=="object"?r!==null:uc(r)}});var vt=p((Od,ei)=>{"use strict";ei.exports={}});var yt=p((Pd,ri)=>{"use strict";var dr=vt(),mr=J(),pc=W(),ti=function(r){return pc(r)?r:void 0};ri.exports=function(r,e){return arguments.length<2?ti(dr[r])||ti(mr[r]):dr[r]&&dr[r][e]||mr[r]&&mr[r][e]}});var ii=p((kd,ni)=>{"use strict";var hc=Q();ni.exports=hc({}.isPrototypeOf)});var ci=p((Vd,oi)=>{"use strict";var dc=J(),si=dc.navigator,ai=si&&si.userAgent;oi.exports=ai?String(ai):""});var fi=p((Md,mi)=>{"use strict";var di=J(),fr=ci(),li=di.process,ui=di.Deno,pi=li&&li.versions||ui&&ui.version,hi=pi&&pi.v8,X,bt;hi&&(X=hi.split("."),bt=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!bt&&fr&&(X=fr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=fr.match(/Chrome\/(\d+)/),X&&(bt=+X[1])));mi.exports=bt});var vr=p((Nd,yi)=>{"use strict";var vi=fi(),mc=z(),fc=J(),vc=fc.String;yi.exports=!!Object.getOwnPropertySymbols&&!mc(function(){var r=Symbol("symbol detection");return!vc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&vi&&vi<41})});var yr=p((Ld,bi)=>{"use strict";var yc=vr();bi.exports=yc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=p((jd,Ci)=>{"use strict";var bc=yt(),Cc=W(),gc=ii(),Ec=yr(),Ic=Object;Ci.exports=Ec?function(r){return typeof r=="symbol"}:function(r){var e=bc("Symbol");return Cc(e)&&gc(e.prototype,Ic(r))}});var Ei=p(($d,gi)=>{"use strict";var Tc=String;gi.exports=function(r){try{return Tc(r)}catch(e){return"Object"}}});var Cr=p((_d,Ii)=>{"use strict";var xc=W(),Sc=Ei(),wc=TypeError;Ii.exports=function(r){if(xc(r))return r;throw new wc(Sc(r)+" is not a function")}});var xi=p((Fd,Ti)=>{"use strict";var Ac=Cr(),Rc=pr();Ti.exports=function(r,e){var t=r[e];return Rc(t)?void 0:Ac(t)}});var wi=p((qd,Si)=>{"use strict";var gr=ft(),Er=W(),Ir=Ee(),Oc=TypeError;Si.exports=function(r,e){var t,n;if(e==="string"&&Er(t=r.toString)&&!Ir(n=gr(t,r))||Er(t=r.valueOf)&&!Ir(n=gr(t,r))||e!=="string"&&Er(t=r.toString)&&!Ir(n=gr(t,r)))return n;throw new Oc("Can't convert object to primitive value")}});var Ri=p((Bd,Ai)=>{"use strict";Ai.exports=!0});var ki=p((Dd,Pi)=>{"use strict";var Oi=J(),Pc=Object.defineProperty;Pi.exports=function(r,e){try{Pc(Oi,r,{value:e,configurable:!0,writable:!0})}catch(t){Oi[r]=e}return e}});var Ct=p((Hd,Ni)=>{"use strict";var kc=Ri(),Vc=J(),Mc=ki(),Vi="__core-js_shared__",Mi=Ni.exports=Vc[Vi]||Mc(Vi,{});(Mi.versions||(Mi.versions=[])).push({version:"3.38.0",mode:kc?"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=p((Ud,ji)=>{"use strict";var Li=Ct();ji.exports=function(r,e){return Li[r]||(Li[r]=e||{})}});var je=p((Gd,$i)=>{"use strict";var Nc=hr(),Lc=Object;$i.exports=function(r){return Lc(Nc(r))}});var Ie=p((zd,_i)=>{"use strict";var jc=Q(),$c=je(),_c=jc({}.hasOwnProperty);_i.exports=Object.hasOwn||function(e,t){return _c($c(e),t)}});var xr=p((Wd,Fi)=>{"use strict";var Fc=Q(),qc=0,Bc=Math.random(),Dc=Fc(1 .toString);Fi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Dc(++qc+Bc,36)}});var $e=p((Kd,Bi)=>{"use strict";var Hc=J(),Uc=Tr(),qi=Ie(),Gc=xr(),zc=vr(),Wc=yr(),Te=Hc.Symbol,Sr=Uc("wks"),Kc=Wc?Te.for||Te:Te&&Te.withoutSetter||Gc;Bi.exports=function(r){return qi(Sr,r)||(Sr[r]=zc&&qi(Te,r)?Te[r]:Kc("Symbol."+r)),Sr[r]}});var Gi=p((Qd,Ui)=>{"use strict";var Qc=ft(),Di=Ee(),Hi=br(),Xc=xi(),Yc=wi(),Zc=$e(),Jc=TypeError,el=Zc("toPrimitive");Ui.exports=function(r,e){if(!Di(r)||Hi(r))return r;var t=Xc(r,el),n;if(t){if(e===void 0&&(e="default"),n=Qc(t,r,e),!Di(n)||Hi(n))return n;throw new Jc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Yc(r,e)}});var wr=p((Xd,zi)=>{"use strict";var tl=Gi(),rl=br();zi.exports=function(r){var e=tl(r,"string");return rl(e)?e:e+""}});var Qi=p((Yd,Ki)=>{"use strict";var nl=J(),Wi=Ee(),Ar=nl.document,il=Wi(Ar)&&Wi(Ar.createElement);Ki.exports=function(r){return il?Ar.createElement(r):{}}});var Rr=p((Zd,Xi)=>{"use strict";var sl=le(),al=z(),ol=Qi();Xi.exports=!sl&&!al(function(){return Object.defineProperty(ol("div"),"a",{get:function(){return 7}}).a!==7})});var Ji=p(Zi=>{"use strict";var cl=le(),ll=ft(),ul=cr(),pl=lr(),hl=Le(),dl=wr(),ml=Ie(),fl=Rr(),Yi=Object.getOwnPropertyDescriptor;Zi.f=cl?Yi:function(e,t){if(e=hl(e),t=dl(t),fl)try{return Yi(e,t)}catch(n){}if(ml(e,t))return pl(!ll(ul.f,e,t),e[t])}});var ts=p((em,es)=>{"use strict";var vl=z(),yl=W(),bl=/#|\.prototype\./,_e=function(r,e){var t=gl[Cl(r)];return t===Il?!0:t===El?!1:yl(e)?vl(e):!!e},Cl=_e.normalize=function(r){return String(r).replace(bl,".").toLowerCase()},gl=_e.data={},El=_e.NATIVE="N",Il=_e.POLYFILL="P";es.exports=_e});var Or=p((tm,ns)=>{"use strict";var rs=ar(),Tl=Cr(),xl=Me(),Sl=rs(rs.bind);ns.exports=function(r,e){return Tl(r),e===void 0?r:xl?Sl(r,e):function(){return r.apply(e,arguments)}}});var ss=p((rm,is)=>{"use strict";var wl=le(),Al=z();is.exports=wl&&Al(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var os=p((nm,as)=>{"use strict";var Rl=Ee(),Ol=String,Pl=TypeError;as.exports=function(r){if(Rl(r))return r;throw new Pl(Ol(r)+" is not an object")}});var us=p(ls=>{"use strict";var kl=le(),Vl=Rr(),Ml=ss(),gt=os(),cs=wr(),Nl=TypeError,Pr=Object.defineProperty,Ll=Object.getOwnPropertyDescriptor,kr="enumerable",Vr="configurable",Mr="writable";ls.f=kl?Ml?function(e,t,n){if(gt(e),t=cs(t),gt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Mr in n&&!n[Mr]){var i=Ll(e,t);i&&i[Mr]&&(e[t]=n.value,n={configurable:Vr in n?n[Vr]:i[Vr],enumerable:kr in n?n[kr]:i[kr],writable:!1})}return Pr(e,t,n)}:Pr:function(e,t,n){if(gt(e),t=cs(t),gt(n),Vl)try{return Pr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new Nl("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var hs=p((sm,ps)=>{"use strict";var jl=le(),$l=us(),_l=lr();ps.exports=jl?function(r,e,t){return $l.f(r,e,_l(1,t))}:function(r,e,t){return r[e]=t,r}});var qe=p((am,ms)=>{"use strict";var Fe=J(),Fl=Nn(),ql=ar(),Bl=W(),Dl=Ji().f,Hl=ts(),xe=vt(),Ul=Or(),Se=hs(),ds=Ie();Ct();var Gl=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return Fl(r,this,arguments)};return e.prototype=r.prototype,e};ms.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,s=r.proto,o=n?Fe:i?Fe[t]:Fe[t]&&Fe[t].prototype,c=n?xe:xe[t]||Se(xe,t,{})[t],a=c.prototype,l,f,y,b,g,S,E,v,R;for(b in e)l=Hl(n?b:t+(i?".":"#")+b,r.forced),f=!l&&o&&ds(o,b),S=c[b],f&&(r.dontCallGetSet?(R=Dl(o,b),E=R&&R.value):E=o[b]),g=f&&E?E:e[b],!(!l&&!s&&typeof S==typeof g)&&(r.bind&&f?v=Ul(g,Fe):r.wrap&&f?v=Gl(g):s&&Bl(g)?v=ql(g):v=g,(r.sham||g&&g.sham||S&&S.sham)&&Se(v,"sham",!0),Se(c,b,v),s&&(y=t+"Prototype",ds(xe,y)||Se(xe,y,{}),Se(xe[y],b,g),r.real&&a&&(l||!a[b])&&Se(a,b,g)))}});var vs=p((om,fs)=>{"use strict";var zl=Math.ceil,Wl=Math.floor;fs.exports=Math.trunc||function(e){var t=+e;return(t>0?Wl:zl)(t)}});var Be=p((cm,ys)=>{"use strict";var Kl=vs();ys.exports=function(r){var e=+r;return e!==e||e===0?0:Kl(e)}});var Cs=p((lm,bs)=>{"use strict";var Ql=Be(),Xl=Math.min;bs.exports=function(r){var e=Ql(r);return e>0?Xl(e,9007199254740991):0}});var De=p((um,gs)=>{"use strict";var Yl=Cs();gs.exports=function(r){return Yl(r.length)}});var Et=p((pm,Es)=>{"use strict";Es.exports=function(){}});var Is=p(()=>{"use strict";var Zl=qe(),Jl=je(),eu=De(),tu=Be(),ru=Et();Zl({target:"Array",proto:!0},{at:function(e){var t=Jl(this),n=eu(t),i=tu(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:t[s]}});ru("at")});var It=p((mm,Ts)=>{"use strict";var nu=yt();Ts.exports=nu});var Ss=p((fm,xs)=>{"use strict";Is();var iu=It();xs.exports=iu("Array","at")});var As=p((vm,ws)=>{"use strict";var su=Ss();ws.exports=su});var Nr=p((ym,Rs)=>{"use strict";var au=As();Rs.exports=au});var Us=p((Nf,Hs)=>{"use strict";var vu=Tr(),yu=xr(),Ds=vu("keys");Hs.exports=function(r){return Ds[r]||(Ds[r]=yu(r))}});var zs=p((Lf,Gs)=>{"use strict";var bu=z();Gs.exports=!bu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Qs=p((jf,Ks)=>{"use strict";var Cu=Ie(),gu=W(),Eu=je(),Iu=Us(),Tu=zs(),Ws=Iu("IE_PROTO"),Ur=Object,xu=Ur.prototype;Ks.exports=Tu?Ur.getPrototypeOf:function(r){var e=Eu(r);if(Cu(e,Ws))return e[Ws];var t=e.constructor;return gu(t)&&e instanceof t?t.prototype:e instanceof Ur?xu:null}});var Ys=p(($f,Xs)=>{"use strict";var Su=Be(),wu=Math.max,Au=Math.min;Xs.exports=function(r,e){var t=Su(r);return t<0?wu(t+e,0):Au(t,e)}});var Gr=p((_f,Js)=>{"use strict";var Ru=Le(),Ou=Ys(),Pu=De(),Zs=function(r){return function(e,t,n){var i=Ru(e),s=Pu(i);if(s===0)return!r&&-1;var o=Ou(n,s),c;if(r&&t!==t){for(;s>o;)if(c=i[o++],c!==c)return!0}else for(;s>o;o++)if((r||o in i)&&i[o]===t)return r||o||0;return!r&&-1}};Js.exports={includes:Zs(!0),indexOf:Zs(!1)}});var ta=p((Ff,ea)=>{"use strict";ea.exports={}});var ia=p((qf,na)=>{"use strict";var ku=Q(),zr=Ie(),Vu=Le(),Mu=Gr().indexOf,Nu=ta(),ra=ku([].push);na.exports=function(r,e){var t=Vu(r),n=0,i=[],s;for(s in t)!zr(Nu,s)&&zr(t,s)&&ra(i,s);for(;e.length>n;)zr(t,s=e[n++])&&(~Mu(i,s)||ra(i,s));return i}});var aa=p((Bf,sa)=>{"use strict";sa.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ca=p((Df,oa)=>{"use strict";var Lu=ia(),ju=aa();oa.exports=Object.keys||function(e){return Lu(e,ju)}});var ma=p((Hf,da)=>{"use strict";var ua=le(),$u=z(),pa=Q(),_u=Qs(),Fu=ca(),qu=Le(),Bu=cr().f,ha=pa(Bu),Du=pa([].push),Hu=ua&&$u(function(){var r=Object.create(null);return r[2]=2,!ha(r,2)}),la=function(r){return function(e){for(var t=qu(e),n=Fu(t),i=Hu&&_u(t)===null,s=n.length,o=0,c=[],a;s>o;)a=n[o++],(!ua||(i?a in t:ha(t,a)))&&Du(c,r?[a,t[a]]:t[a]);return c}};da.exports={entries:la(!0),values:la(!1)}});var fa=p(()=>{"use strict";var Uu=qe(),Gu=ma().values;Uu({target:"Object",stat:!0},{values:function(e){return Gu(e)}})});var ya=p((zf,va)=>{"use strict";fa();var zu=vt();va.exports=zu.Object.values});var Ca=p((Wf,ba)=>{"use strict";var Wu=ya();ba.exports=Wu});var _t=p((Kf,ga)=>{"use strict";var Ku=Ca();ga.exports=Ku});var Ta=p(()=>{"use strict";var Qu=qe(),Xu=Gr().includes,Yu=z(),Zu=Et(),Ju=Yu(function(){return!Array(1).includes()});Qu({target:"Array",proto:!0,forced:Ju},{includes:function(e){return Xu(this,e,arguments.length>1?arguments[1]:void 0)}});Zu("includes")});var Sa=p((ev,xa)=>{"use strict";Ta();var ep=It();xa.exports=ep("Array","includes")});var Aa=p((tv,wa)=>{"use strict";var tp=Sa();wa.exports=tp});var Ft=p((rv,Ra)=>{"use strict";var rp=Aa();Ra.exports=rp});var Yr=p((Iv,Ma)=>{"use strict";var cp=Ne();Ma.exports=Array.isArray||function(e){return cp(e)==="Array"}});var La=p((Tv,Na)=>{"use strict";var lp=TypeError,up=9007199254740991;Na.exports=function(r){if(r>up)throw lp("Maximum allowed index exceeded");return r}});var _a=p((xv,$a)=>{"use strict";var pp=Yr(),hp=De(),dp=La(),mp=Or(),ja=function(r,e,t,n,i,s,o,c){for(var a=i,l=0,f=o?mp(o,c):!1,y,b;l<n;)l in t&&(y=f?f(t[l],l,e):t[l],s>0&&pp(y)?(b=hp(y),a=ja(r,e,y,b,a,s-1)-1):(dp(a+1),r[a]=y),a++),l++;return a};$a.exports=ja});var Ba=p((Sv,qa)=>{"use strict";var fp=$e(),vp=fp("toStringTag"),Fa={};Fa[vp]="z";qa.exports=String(Fa)==="[object z]"});var Ha=p((wv,Da)=>{"use strict";var yp=Ba(),bp=W(),Bt=Ne(),Cp=$e(),gp=Cp("toStringTag"),Ep=Object,Ip=Bt(function(){return arguments}())==="Arguments",Tp=function(r,e){try{return r[e]}catch(t){}};Da.exports=yp?Bt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Tp(e=Ep(r),gp))=="string"?t:Ip?Bt(e):(n=Bt(e))==="Object"&&bp(e.callee)?"Arguments":n}});var Ga=p((Av,Ua)=>{"use strict";var xp=Q(),Sp=W(),Zr=Ct(),wp=xp(Function.toString);Sp(Zr.inspectSource)||(Zr.inspectSource=function(r){return wp(r)});Ua.exports=Zr.inspectSource});var Ya=p((Rv,Xa)=>{"use strict";var Ap=Q(),Rp=z(),za=W(),Op=Ha(),Pp=yt(),kp=Ga(),Wa=function(){},Ka=Pp("Reflect","construct"),Jr=/^\s*(?:class|function)\b/,Vp=Ap(Jr.exec),Mp=!Jr.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(Op(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Mp||!!Vp(Jr,kp(e))}catch(t){return!0}};Qa.sham=!0;Xa.exports=!Ka||Rp(function(){var r;return Je(Je.call)||!Je(Object)||!Je(function(){r=!0})||r})?Qa:Je});var to=p((Ov,eo)=>{"use strict";var Za=Yr(),Np=Ya(),Lp=Ee(),jp=$e(),$p=jp("species"),Ja=Array;eo.exports=function(r){var e;return Za(r)&&(e=r.constructor,Np(e)&&(e===Ja||Za(e.prototype))?e=void 0:Lp(e)&&(e=e[$p],e===null&&(e=void 0))),e===void 0?Ja:e}});var no=p((Pv,ro)=>{"use strict";var _p=to();ro.exports=function(r,e){return new(_p(r))(e===0?0:e)}});var io=p(()=>{"use strict";var Fp=qe(),qp=_a(),Bp=je(),Dp=De(),Hp=Be(),Up=no();Fp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Bp(this),n=Dp(t),i=Up(t,0);return i.length=qp(i,t,t,n,0,e===void 0?1:Hp(e)),i}})});var so=p(()=>{"use strict";var Gp=Et();Gp("flat")});var oo=p((Lv,ao)=>{"use strict";io();so();var zp=It();ao.exports=zp("Array","flat")});var lo=p((jv,co)=>{"use strict";var Wp=oo();co.exports=Wp});var po=p(($v,uo)=>{"use strict";var Kp=lo();uo.exports=Kp});var Cn="1.0.35-dev.8f111489.0";var Xt=class{constructor(e){this.layout=e}},st=class extends Xt{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))`}};function gn(r){return"features"in r}var be=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&gn(this.options)&&this.options.features[e]}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,n)=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i);if(s){let o=s(n,this.options);if(o)return[...t,o]}return[...t]},[]))||[]}};function Yt(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var En="interactive",q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},In=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(In||{}),Tn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Tn||{}),xn=(n=>(n.start="left",n.end="right",n.center="center",n))(xn||{}),at=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&In[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&Tn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&xn[e.alignment])!=null?i:"center"},ot=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l;r.style.color=(s=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?s:t.textColor,r.style.fontSize=`calc(${n.height} * ${(c=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?c:t.textSize})`,r.textContent=(l=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?l:t.textContent},ct=({target:r,props:e,fallback:t})=>{var n,i,s,o;r.style.backgroundColor=Yt((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i: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:n})=>{var i,s,o,c,a,l,f,y,b,g,S;r.style.border=`calc(${n.height} * ${(o=(s=(i=e==null?void 0:e.shape)==null?void 0:i.border)==null?void 0:s.width)!=null?o:t.borderWidth}) solid ${Yt((l=(a=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:a.color)!=null?l:t.borderColor,(b=(y=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:y.alpha)!=null?b:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(S=(g=e==null?void 0:e.shape)==null?void 0:g.roundCorners)!=null?S:t.roundCorners})`},Ce=({target:r,layoutParams:e,fallback:t})=>{var i;let n=(i=e.angle)!=null?i:t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var Zt="int",ce=(n=>(n.AREA=`${Zt}_area`,n.TEXT=`${Zt}_text`,n.BUTTON=`${Zt}_bttn`,n))(ce||{});function Sn(r){return"features"in r}var ge="interactive-control",L={common:ge,wrapper:`${ge}-wrapper`,disabled:`${ge}-disabled`,button:`${ge}-button`,area:`${ge}-area`,text:`${ge}-text`};var ae=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(L.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i: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:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&Sn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var i;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(i=this.container)==null||i.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 ut=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Jt(r,e)},Jt=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(L.common,L.area),n.setAttribute("data-testid",ce.AREA),ct({target:n,props:this.control.props,fallback:x(d({},q),{backgroundColor:"transparent"})}),lt({target:n,props:this.control.props,fallback:x(d({},q),{borderAlpha:0}),dependsOn:this.container.dimensions}),Ce({target:n,layoutParams:this.control.layoutParams,fallback:q}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var pt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var ht=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new er(r,e)},er=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(L.common,L.button),n.setAttribute("data-testid",ce.BUTTON),Ce({target:n,layoutParams:this.control.layoutParams,fallback:q}),ct({target:n,props:this.control.props,fallback:q}),lt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),at({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=pt(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;ot({target:s,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var wn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new tr(r,e)},tr=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(L.common,L.text),n.setAttribute("data-testid",ce.TEXT),Ce({target:n,layoutParams:this.control.layoutParams,fallback:q}),at({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=pt(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;ot({target:s,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}};var rr="interactive-container",G={common:rr,hidden:`${rr}-hidden`,disabled:`${rr}-disabled`};var dt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e,t)},nr=class extends be{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new st(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ht),this.addControlFactory("text",wn),this.addControlFactory("area",ut)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(G.common,G.disabled),requestAnimationFrame(()=>{n.classList.remove(G.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(G.hidden)}show(){let t=this.getElement();t&&t.classList.remove(G.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(G.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(G.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}};var $o=re(Nr(),1);import{combine as oh,InterfaceLanguage as ch,Observable as No,once as lh,Subject as B,Subscription as an,ValueSubject as H,fromEvent as Lo}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as rt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as ou}from"@vkontakte/videoplayer-shared/es2015";function He(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var ue=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Ue=r=>ue(r,"Object"),Tt=r=>ue(r,"String"),xt=r=>ue(r,"Array"),St=r=>ue(r,"Number"),Os=r=>ue(r,"Function");var Lr=r=>St(r)&&!isNaN(r);var pe=r=>Ue(r)&&Object.keys(r).length===0,jr=r=>xt(r)&&!r.length;var Ge=(r,e)=>Tt(r)&&(e?r.trim():r).length;var Ps="video_interactive",ks="videoint";var Vs=250,ze=class{constructor(e){this.handleZoomChange=He(e=>{this.lastZoomInfo=e},Vs);this.onResize=e=>{var n;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((n=this.ngEditor)==null||n.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,n,i;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(n=this.ngEditor)==null||n.selectChapter(e.id),(i=this.ngEditor)==null||i.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var n;if(this.isReady=!1,!St(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"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:n,lang:i,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=n,this.lang=i!=null?i:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=cu(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 P(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 P(this,null,function*(){var n;if(!this.manifest)return;let e;try{e=yield ou(this.lang,Ps,ks)}catch(i){(n=this.onError)==null||n.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",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",o=>{var c=o,{name:i}=c,s=Z(c,["name"]);var a;i==="openPreview"&&"chapterId"in s&&((a=this.onOpenPreviewClick)==null||a.call(this,s.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 cu(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,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let o=s.startTime-e;if(o<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<o&&(t=t===-1?o:Math.min(t,o))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as At,ContainerTypes as Hm,ControlTypes as Rt,EventActionTypes as V,EventTypes as Um,migrateManifestToLatestVersion as js,compareVersions as Gm}from"@interactiveplatform/movika-manifest";var Ms={metadata:"Object",chapters:"Array"},Ns=r=>{if(!Ue(r))return!1;for(let e in Ms)if(!r[e]||!ue(r[e],Ms[e]))return!1;return At(r.metadata.version)},wt=r=>r.type===Rt.Text,Lm=r=>r.type===Rt.Button,jm=r=>r.type===Rt.Area,$m={Choice:"Choice",TextInput:"TextInput"},_m={Button:"Button",Area:"Area",Text:"Text"},Fm={onClick:"onClick",onSuspense:"onSuspense"},Ls={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var F=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}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 n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...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)=>{Os(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==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 fu}from"@vkontakte/videoplayer-shared/es2015";var kt=class{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!=null?n:[]}}exec(e,t){return P(this,null,function*(){return lu(...this.loaders[e])(t)})}};function lu(...r){return function(t){return P(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Ke(r,e,t){return r?x(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Vt(i){var s=i,{actions:r,errors:e,chapterId:t}=s,n=Z(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest();if(o){let c=r.getChapter(o.chapters,t);if(c){let a=r.getMedia(o.media,c.videoId),l=r.getGraph(o.graph,c.id);return a?x(d({},n),{actions:r,errors:e,result:{chapter:c,media:a,graph:l}}):x(d({},n),{errors:Ke(e,Vt.name,"Could not find media"),actions:r})}}}return x(d({},n),{errors:Ke(e,Vt.name,"Could not find chapter"),actions:r})}var Mt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,s=n.length;i<s;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,s=n.length;i<s;i++){let o=n[i];try{o.callback.call(this,e)}catch(c){Promise.resolve().then(()=>{throw c})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},we=class extends Mt{constructor(){super(),this.listeners||Mt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},Qe=class{constructor(){Object.defineProperty(this,"signal",{value:new we,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(i){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 n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(i){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Qe.prototype[Symbol.toStringTag]="AbortController",we.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 $r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Nt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(l,f){let y;f&&f.signal&&(y=f.signal,delete f.signal);let b=new t(l,f);return y&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),b},s.prototype=t.prototype);let o=e;return{fetch:(a,l)=>{let f=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(f){let y;try{y=new DOMException("Aborted","AbortError")}catch(g){y=new Error("Aborted"),y.name="AbortError"}if(f.aborted)return Promise.reject(y);let b=new Promise((g,S)=>{f.addEventListener("abort",()=>S(y),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([b,o(a,l)])}return o(a,l)},Request:s}}var Xe=Nt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),$s=Xe?$r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_r=Xe?$s.fetch:window.fetch,pf=Xe?$s.Request:window.Request,hf=Xe?Qe:window.AbortController,df=Xe?we:window.AbortSignal;var Fr=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(t.length,n.length)&&!i;s++)t[s]>n[s]?i=1:t[s]<n[s]?i=-1:i=0;return i};var uu=r=>P(void 0,null,function*(){try{let e={},t;if(Tt(r)){t=new URL(r).href;let i=yield _r(t);if(!i.ok)return{};e=yield i.json()}else if(Ue(r))e=r;else return{};if(!Ns(e))return{};let n=e.metadata.media;if(Tt(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let s=yield _r(i);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(i){return du(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function _s(r){return P(this,null,function*(){let{manifest:e,manifestURL:t}=yield uu(r);if(!e)throw new Error("Failed on fetch");let n=js(e);return n.media=pu(n.media,t),delete n.metadata.media,n})}function Lt(r,e){if(e)return r.find(t=>t.id===e)}function qr(r,e){var t,n;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(i=>i.id===e):(n=r.view)!=null&&n.chapters?r.view.chapters.find(i=>i.id===e):void 0}function Br(r,e){return r.videos.find(t=>t.id===e)}function pu(r,e){return x(d({},r),{videos:r.videos.map(t=>x(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",s=hu(i,e);return x(d({},n),{url:s||i})})}))})}function hu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function du(r){return Fr(r,"3.2.0")>=0}var jt=r=>xt(r)&&!jr(r),ee=r=>r.order==="end",$t=r=>xt(r.containers)&&!jr(r.containers)&&ee(r),Fs=(r,e)=>{var n;let t=r*1e3;return jt(e.controls)&&t<((n=e.startTime)!=null?n:0)},Dr=(r,e)=>{var n,i;let t=r*1e3;return jt(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var he=(r=[])=>r.some(e=>e.action.type==="expect"),Hr=(r=[])=>r.find(e=>e.action.type==="expect"),mu=r=>(r==null?void 0:r.length)===1,Ae=r=>mu(r)&&wt(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)=>{let t=E=>{let v=e.find(({container:R})=>R.container.id===E);return v==null?void 0:v.container.isRemoved},n=he(r.events)&&!t(r.id),i=(E,v=!1,R=!1)=>{let h=R?"every":"some";return E.controls[h](u=>{var I;let m=v?E.endTime===r.endTime:!0;return((I=u.events)==null?void 0:I[h](T=>{var C;return((C=T.action)==null?void 0:C.type)===Ls.openURI}))&&m})},s=E=>E.some(({container:v})=>i(v.container,!0,!1)&&!v.isRemoved),o=E=>E.every(({container:v})=>v.isRemoved?!0:i(v.container,!0,!0)),c=e.filter(({container:E})=>E.container.id!==r.id&&he(E.container.events)&&E.container.endTime===r.endTime&&!E.isRemoved).length,a=E=>E.controls.some(v=>{var R;return(R=v.events)==null?void 0:R.some(h=>{var u,m;return(m=(u=h.action)==null?void 0:u.args)==null?void 0:m.shouldOpenNow})}),l=n||c>0,f=s(e),y=i(r),b=o(e),g=n?!1:c>0,S=a(r);return{isExpectTime:l,hasOtherExpect:c>0,hasOpenURIEvent:f,hasOpenURIEventInCurrentContainer:y,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:S}};var Re=class extends kt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new fu(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return P(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ke},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield _s((i=n.result)!=null?i:t),this})}setInitial(){return P(this,null,function*(){return this.setNext()})}setNext(){return P(this,arguments,function*(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=yield this.exec("chapterLoaders",Vt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:qr,getChapter:Lt,getMedia:Br,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ke},result:null,errors:null,chapterId:t}));return i.errors&&this.errorHandler(i.errors),i.result&&(this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var n;return this.getByChapterId((n=this.manifest)==null?void 0:n.metadata.initChapterId)||null}getByChapterId(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t||!this.manifest)return null;let i=Lt(this.manifest.chapters,t);if(i){let s=Br(this.manifest.media,i.videoId),o=qr(this.manifest.graph,i.id);if(s)return{chapter:i,media:s,graph:o}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,s,o;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let c=Lt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(c==null?void 0:c.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,n;return((t=this.chapter)==null?void 0:t.id)===((n=this.manifest)==null?void 0:n.metadata.initChapterId)}isEndChapter(){return this.chapter?ee(this.chapter):!1}};var Oa=re(_t(),1);import{Player as np}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Qr,Tracer as ip,ValueSubject as sp}from"@vkontakte/videoplayer-shared/es2015";var Ea=r=>{let e=r.variants.find(t=>{var n;return((n=t.payload)==null?void 0:n.type)==="vk"});if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var Ia=re(_t(),1);function Wr(){let r=new Map;function e(a){var l=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=l,c=Z(l,["listId","itemId"]);let f=r.get(s),y=d({},c);return f?f[o]=y:r.set(s,{[o]:y}),d({listId:s,itemId:o},c)}function t(s){var o,c;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(c=s.statistics)==null||c.statSubscription.unsubscribe()}function n(s,o){let c=r.get(s);if(!c)throw Error("Can't remove. Not find.");if(o){let a=c[o];a&&t(a),delete c[o],Object.keys(c).length||r.delete(s)}else{for(let a of(0,Ia.default)(c))t(a);r.delete(s)}}function i(){for(let s of r)n(s[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var Oe=re(Ft(),1);function Kr(r,e=[]){var s,o,c;let t={},n,i=!e.length;for(let a of r.variants)if(!n&&"cover"in a&&(n=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(i||(0,Oe.default)(e,"mp4"))&&(t.MPEG=x(d({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,Oe.default)(e,"mpeg"))&&(t.MPEG=x(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(i||(0,Oe.default)(e,"hls"))&&(t=x(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,Oe.default)(e,"dash"))&&(t=x(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(c=r.title)!=null?c:""}}var Ye=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Oe.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var ap=2;function Xr(r){let e=Wr(),t=new Qr,n={},i=null,s=!1,o,c=new sp(null);r&&a(r);function a(v){i=v}function l(v,R,h){var I;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let m=((I=e.map.get(v))!=null?I:{})[R];if(m){n=d({chapterId:h,listId:v,itemId:R},m);let T=n.player;n.subscription.add(T.info.currentQuality$.subscribe(C=>{let A=T.info.position$.getValue(),_=T.info.isAutoQualityEnabled$.getValue();if(!(!C||!A||_))for(let O of e.map)(0,Oa.default)(O[1]).forEach(({player:M})=>{Ye(M,C)})})).add(T.events.started$.subscribe(()=>{f(R)})),m.container.remove(),i.setPlayer(m.player),s||(i.init(),s=!0),c.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function f(v){return P(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(pe(n)||v!==n.itemId)return;let R=i.getChapterBranches(),h=new Set;for(let u of R)h.has(u.media.id)||(yield b({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),h.add(u.media.id))})}function y(h){return P(this,arguments,function*({chapter:{id:v},manifestVideo:R}){if(pe(n)||!i)return;let u=n.player.info.muted$.getValue(),m=n.player.info.currentQuality$.getValue(),I=n.player.info.isAutoQualityEnabled$.getValue(),T=n.player.info.volume$.getValue(),C=n.player.info.currentPlaybackRate$.getValue(),A=!I,_=!1;for(let O of e.map)if(O[0]===R.id&&!i.state.isReplay$.getValue()){let M=Object.keys(O[1]);for(let j of M)j===n.itemId?(M.length<ap||(_=!0),e.removePlayer(O[0],j)):(_=!0,l(O[0],j,v),A?Ye(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u),n.player.setPlaybackRate(C))}else e.removePlayer(O[0]);_||(yield b({media:R,chapterId:v,setAsActive:!0,playbackRate:C}),A?Ye(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u))})}function b(A){return P(this,arguments,function*({media:v,chapterId:R,prefetch:h=!0,setAsActive:u=!0,autoplay:m=!1,preferredExt:I,title:T,playbackRate:C}){var cn,ln,un,pn,hn;let _=Math.random().toString(),O=document.createElement("div");o.append(O);let M;if((cn=i==null?void 0:i.options)!=null&&cn.vkVideoLoader){let nt=Ea(v);nt.length&&(M=yield i.options.vkVideoLoader(...nt))}let j=((ln=i==null?void 0:i.options)==null?void 0:ln.coreConfig)||void 0,Y=x(d({},j),{configName:[...(un=j==null?void 0:j.configName)!=null?un:[],"interactive"]}),oe=x(d({container:O},((pn=M==null?void 0:M.videos)==null?void 0:pn[0])||{sources:Kr(v,I).sources}),{title:T,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),D=new np(Y,ip.createRootTracer());D.initVideo(oe);let ve=null;if(M!=null&&M.videos&&(i!=null&&i.options.createOneStat)){let nt=M.videos[0],Wt=i.options.createOneStat(nt),dn=new Qr;Wt&&(dn.add(Wt.attachTo(D)),ve={oneStat:Wt,statSubscription:dn})}let on=new Qr,_o=(hn=n==null?void 0:n.player)==null?void 0:hn.info.isAutoQualityEnabled$.getValue();on.add(D.events.canplay$.subscribe(function(){_o||Ye(D,n.player.info.currentQuality$.getValue()),C&&D.setPlaybackRate(C)}));let ye=e.createPlayer({listId:v.id,itemId:_,player:D,container:O,sources:Kr(v,I).sources,config:oe,subscription:on,statistics:ve});return u&&l(v.id,ye.itemId,R),m&&ye.player.play(),h&&!m&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}})}function g(){S(),i=null,o.remove()}function S(){t.unsubscribe(),e.removeAll(),n={},s=!1}function E(){return P(this,null,function*(){if(!i)throw Error("need to set interactive controller");S(),o=document.createElement("div");let{media:v,chapter:R}=i.getCurrentChapter();v&&R?(t.add(i.events.chapterChanged$.subscribe(y)),yield b({media:v,chapterId:R.id,title:R.label})):console.error("not found")})}return x(d({},e),{init:E,setInteractiveController:a,createPlayer:b,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:c})}var k={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"},N={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ka=re(Ft(),1);import{Subscription as op}from"@vkontakte/videoplayer-shared/es2015";var qt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:o,globalEventEmitter:c,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:f,disabledControls$:y,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(he(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,n,i,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:o}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&o)return;this.emitContainerVisibilityEvent(!0,!1)}else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(a,l)=>{let{isExpectTime:f,hasOtherExpect:y,hasOpenURIEvent:b,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:S,hasShouldOpenNowEvent:E}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!g,R=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let h=!y&&!S&&g;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&b&&this.gameState!==5){if(R){let u=((m,I,T,C)=>!m&&!I&&T||m&&!I&&T&&!C||m&&!I&&T&&C)(f,y,S,this.isSelectedContainerEvent);this.fakeRemoveView(u)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!f||!y||!E)&&(this.selectBranches.stopExpect(),l())}},isEOV:()=>this.gameState===4},c=qs(this.selectBranches.onControlEvent,o);this.container.createView({eventCallback:c}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(i=this.container).disable)==null||s.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,f,y;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,ka.default)(i,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(Dr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,S=this.interactiveTimeOpenUri&&b;if(S&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((f=(l=this.container).hide)==null||f.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!S&&this.removeView()}let o=Dr(s,this.container.container),c=this.container.container.startTime?[this.container.container.startTime,(y=this.container.container.endTime)!=null?y:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:c,currentTime:s,isInteractiveTime:o};this.container.onProgress(s*1e3,o),this.globalEventEmitter.emit(k.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new op,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&Ae(t.container.controls),this.interactiveTimeOpenUri=f,this.disabledControls$=y,this.onRemove=b,this.globalEventEmitter=c,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.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(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.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,n,i,s;e?(n=(t=this.container).disable)==null||n.call(t):(s=(i=this.container).enable)==null||s.call(i)}))}selectContainerEvent(e=!1){var n,i;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(n=this.container.container.endTime)!=null?n:1/0,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(),n=this.interactiveTimeOpenUri?e||t:he(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.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)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}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 Va=(r=[])=>r.reduce((e,t,n)=>{var s,o,c;let i=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!wt(a));if(jt(i)){let a=[(o=t.startTime)!=null?o:0,(c=t.endTime)!=null?c:1/0],l={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:a});else{let f=[],y=-1/0,b=1/0,g=[],S=[];for(let E=0;E<e.length;E++){let v=e[E];if(S.push(...v.subjects),v.range[0]<b&&(b=v.range[0]),v.range[1]>y&&(y=v.range[1]),a[0]>=v.range[0]&&a[1]<=v.range[1])return e[E].subjects.push(l),e;a[0]<v.range[0]&&a[1]>v.range[0]&&(f.push(E),g=g.concat(v.subjects)),a[0]>=v.range[0]&&a[0]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[0]=v.range[0]),a[1]>=v.range[0]&&a[1]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[1]=v.range[1])}if(S.push(l),a[0]<=b&&a[1]>=y)return[{subjects:S,range:a}];f.length&&f.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([l]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var mo=re(Ft(),1),en=re(_t(),1),fo=re(po(),1);function ho(){let r={};function e(){for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&delete r[c]}function t(c){let a={};for(let l in r)+l<=c&&(a[l]=r[l]);return a}function n(c){let a={};for(let l in r)+l>=c&&(a[l]=r[l]);return a}function i({timestamp:c,priority:a,initiator:l}){var f;if(Lr(c)){let y=(f=r[c])!=null?f:null;if(y&&a&&Ge(a,!0)){let b={},g=y[a];if(g&&(b=d(d({},b),g)),b=pe(b)?null:b,b&&Ge(l,!0)){let S=b[l];return S!=null?S:null}return b}return y}return null}function s({timestamp:c,priority:a,initiator:l}){if(Lr(c))if(r[c]){if(a&&Ge(a,!0))if(r[c][a]){if(l&&Ge(l,!0))if(r[c][a][l]){if(delete r[c][a][l],!pe(r[c][a]))return!0}else return!1;if(delete r[c][a],!pe(r[c]))return!0}else return!1;return delete r[c]}else return!1;return!1}function o(y){var b=y,{timestamp:c,priority:a,initiator:l}=b,f=Z(b,["timestamp","priority","initiator"]);var g,S,E;(S=(g=r[c])==null?void 0:g[a])!=null&&S[l]?r[c][a][l].push(d({},f)):(E=r[c])!=null&&E[a]?r[c][a]=x(d({},r[c][a]),{[l]:[d({},f)]}):r[c]?r[c]=x(d({},r[c]),{[a]:{[l]:[d({},f)]}}):r[c]={[a]:{[l]:[d({},f)]}}}return{map:r,remove:s,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var Qp=[V.expect,V.setNextBranch],Xp=1/0;function vo(r,e){let t=r,n,i=Yp(e),s=ho(),o,c=()=>{g(),h()},a=u=>{s.add.call(void 0,u),E()},l=(u=[])=>{for(let m of u)if(m.action(),(0,mo.default)(Qp,m.actionType))break},f=(u=1/0)=>{var C,A,_;let m=Dt((C=s.get({timestamp:u,priority:"control"}))!=null?C:{}),I=Dt((A=s.get({timestamp:u,priority:"container"}))!=null?A:{}),T=Dt((_=s.get({timestamp:u,priority:"chapter"}))!=null?_:{});return[...m,...I,...T]},y=u=>{i.isReady(u)&&l(f(u))},b=()=>{var u;l([...Dt((u=s.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},g=()=>{n&&(o==null||o.unsubscribe(),n=void 0)},S=u=>{},E=()=>{n||(n=()=>setTimeout(()=>{y(1/0)}),o=t.events.ended$.subscribe(n))},v=u=>{g(),t=u},R=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),s.remove(u)},h=()=>{i.release(),s.removeAll()};return{setPlayer:v,add:a,remove:R,exec:y,execEndOfVideo:b,listen:E,unlisten:g,release:c,containersEventsCallState:i,getPreparedToExecActions:f}}function Yp(r){let e=new Map;return{setCalled:({timestamp:c,id:a})=>{let l=e.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a;for(let l of c){let f=(a=l.endTime)!=null?a:Xp,y=e.get(f);e.set(f,x(d({},y),{[l.id]:!1}))}},resetCalled:c=>{let a=e.get(c);if(a)for(let l in a)a[l]=!1},isReady:c=>{let a=e.get(c);if(!a)return!0;let l=(0,en.default)(a);return r?l.some(y=>y):!l.some(y=>!y)},release:()=>e.clear()}}function Dt(r){return(0,fo.default)((0,en.default)(r)).sort(e=>e.actionType===V.expect?-1:1)}var yo={videoContentHeight:0,videoContentWidth:0},bo=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return yo;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return yo;let s=e/t,o=n/i,c,a;return o>s?(a=i,c=i*s):o<s?(a=n/s,c=n):(a=i,c=n),{videoContentWidth:a,videoContentHeight:c}};var Zp=250;function Co(r){let e,t=new ResizeObserver(c=>{s(c),e=s.bind(null,c)});function n(c){let{parentElement:a,player:l}=r();if(a&&l){let{videoContentWidth:f,videoContentHeight:y}=bo(l);a.style.setProperty("--interactive-content-width",`${f}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${c[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${c[0].contentRect.height}px`)}}function i(){let{parentElement:c}=r();c.removeAttribute("style")}let s=He(c=>{let{fns:a=[]}=r();n(c);for(let l of a)l()},Zp);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var Jp=r=>Math.floor(Math.random()*r),Eo=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:1;o<t&&(t=o,n=s)}return n},Io=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:0;o>t&&(t=o,n=s)}return n};var To=r=>{let e=r.length,t=Jp(e);return r[t]},go=1,xo=r=>{var n,i;let e=0;for(let s=0;s<r.length;++s)e+=(n=r[s].weight)!=null?n:go;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(i=r[s].weight)!=null?i:go,e>=t)return r[s];return r[r.length-1]};var So={shouldOpenNow:!0,isDetachContainer:!0},wo="after-expect";var tn=(r,e=!1)=>x(d({},r),{args:e?d(d({},r.args),So):d(d({},So),r.args)}),Oo=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:h,controlType:u,controlId:m,containerId:I,branches:T=[],onEvent:C,isEOV:A=()=>!1,isDisabled:_=()=>!1})=>{let O=tn(h,A()),M={timestamp:1/0,priority:"control",initiator:m,actionType:O.type},j=_(),Y=r.emit.bind(r,k.interactives,{subjectId:m,subjectType:u,subjectName:"control",type:j?N.actionChoiceCanceled:N.actionChoice,actionType:h.type,payload:d({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)}),oe=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:u,subjectName:"control",type:j?"action-choice-canceled":"action-choice",actionType:h.type,payload:d({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)})};if(j){Y(),oe();return}switch(O.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let D=T.find(ve=>ve.id===O.args.branchId);if(!D)return;C(O.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Y(),oe(),O.args.shouldOpenNow?E({subjectId:m,subjectName:"control",subjectType:u,action:O,payload:{chapterId:D.chapterId,autoSelect:!1}}):n.add(x(d({},M),{action:E.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:O,payload:{chapterId:D.chapterId,autoSelect:!1}})}));return}case V.continuePlayback.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Y(),oe(),O.args.shouldOpenNow?S({subjectId:m,subjectName:"control",subjectType:u,action:h}):n.add(x(d({},M),{action:S.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:h})}));return}case V.openURI.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Y(),oe(),O.args.shouldOpenNow?R({subjectId:m,subjectName:"control",subjectType:u,action:O,payload:{URI:h.args.uri}}):n.add(x(d({},M),{action:R.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:O,payload:{URI:h.args.uri}})}));return}default:{let D="Unexpected control event",ve=new F(1,1,{message:D});f(ve,D);return}}},c=({action:h,container:{id:u,endTime:m},branches:I=[],isEOV:T=!1,autoSelected:C=!1})=>{let A=tn(h,T),_={timestamp:!A.args.shouldOpenNow||T?1/0:m!=null?m:1/0,priority:"container",initiator:u,actionType:A.type},O=r.emit.bind(r,k.interactives,{subjectId:u,subjectName:"container",type:N.actionChoice,actionType:A.type,payload:d({invokeImmediately:A.args.shouldOpenNow},A.args)}),M=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:A.type,payload:d({invokeImmediately:A.args.shouldOpenNow},A.args)})};switch(A.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let j=I.find(Y=>Y.id===A.args.branchId);if(!j)return;O(),M(),n.add(x(d({},_),{action:E.bind(null,{subjectId:u,subjectName:"container",action:A,payload:{chapterId:j.chapterId,autoSelect:C}})}));return}case V.setMaxWeightBranch.trim().toLowerCase():return;case V.setMinWeightBranch.trim().toLowerCase():return;case V.setRandomBranch.trim().toLowerCase():return;case V.setWeightlessRandomBranch.trim().toLowerCase():return;case V.continuePlayback.trim().toLowerCase():{O(),M(),n.add(x(d({},_),{action:S.bind(null,{subjectId:u,subjectName:"container",action:A})}));return}case V.openURI.trim().toLowerCase():{O(),M(),n.add(x(d({},_),{action:R.bind(null,{subjectId:u,subjectName:"container",action:A,payload:{URI:h.args.uri}})}));return}default:{let j="Unexpected container event",Y=new F(1,1,{message:j});f(Y,j);return}}};function a({container:h,branches:u,isEOV:m=!1}){var T,C;let I=Hr(h.events);if(I){let A=tn(I.action,m);r.emit(k.interactives,{subjectId:h.id,subjectName:"container",type:N.actionChoice,actionType:A.type,payload:d({invokeImmediately:A.args.shouldOpenNow},A.args)}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:A.type,payload:d({invokeImmediately:A.args.shouldOpenNow},A.args)}),n.add({timestamp:m?1/0:(T=h.endTime)!=null?T:1/0,priority:"container",initiator:h.id,actionType:V.expect,action:b.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let A of(C=h.events)!=null?C:[])c({action:A.action,container:h,branches:u,isEOV:m})}let l=({chapterId:h,action:u,branches:m=[]})=>{let I=r.emit.bind(r,k.interactives,{subjectId:h,subjectName:"chapter",type:N.actionChoice,actionType:u.type,payload:u.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let C=m.find(A=>A.id===u.args.branchId);return C!=null&&C.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case V.setWeightlessRandomBranch.trim().toLowerCase():{let C=To(m);return C!=null&&C.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case V.setRandomBranch.trim().toLowerCase():{let C=xo(m);return C!=null&&C.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case V.setMaxWeightBranch.trim().toLowerCase():{let C=Io(m);return C!=null&&C.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case V.setMinWeightBranch.trim().toLowerCase():{let C=Eo(m);return C!=null&&C.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case V.continuePlayback.trim().toLowerCase():return I(),T(),S.bind(null,{subjectId:h,subjectName:"chapter",action:u});case V.openURI.trim().toLowerCase():return I(),T(),R.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let C="Unexpected chapter event",A=new F(1,1,{message:C});f(A,C);return}}};function f(h,u){console.error(u),e.error$.next(h),r.emit(k.errors,h)}function y(h){var m;let u=Hr(h.events);if(u){if(ee(h))return;r.emit(k.interactives,{subjectId:h.id,subjectName:"chapter",type:N.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:V.expect,action:b.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(m=h.events)==null||m.forEach(I=>{let T=l({chapterId:h.id,action:I.action,branches:h.branches});T&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:I.action.type,action:T})})}let b=({subjectId:h,subjectName:u})=>{t.pause(),r.emit(k.interactives,{subjectId:h,subjectName:u,type:N.actionExecution,actionType:V.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:V.expect})},g=({subjectId:h,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:h,subjectName:u,type:N.actionExecution,actionType:wo}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:wo})},S=({subjectId:h,subjectName:u,subjectType:m,action:I})=>{r.emit(k.interactives,{subjectId:h,subjectName:u,subjectType:m,type:N.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:I.type})},E=({subjectId:h,subjectName:u,subjectType:m,action:I,payload:T})=>{T.behaviour="change-chapter",r.emit(k.interactives,{subjectId:h,subjectName:u,subjectType:m,type:N.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:I.type,payload:T})},v=({subjectId:h,subjectName:u,subjectType:m,action:I,payload:T})=>{T.behaviour="change-manifest",r.emit(k.interactives,{subjectId:h,subjectName:u,subjectType:m,type:N.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:I.type,payload:T})},R=({subjectId:h,subjectName:u,subjectType:m,action:I,payload:T})=>{if(!T.URI)return;let C=window.open(T.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(k.interactives,{subjectId:h,subjectName:u,subjectType:m,type:N.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:I.type})};return{onControlEvent:o,onContainerEvent:c,onChapterEvent:l,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:y,setManifestContainerEvents:a,stopExpect:s,state:i}};var sn=re(Nr(),1);import{Subscription as ih,Subject as nn,ValueSubject as et}from"@vkontakte/videoplayer-shared/es2015";var rn=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(o=>o.id===n);if(!i)return null;let s=e.media.videos.find(o=>i.videoId===o.id);if(!s)return null;t[n]=Po(s)}return t[n]}).filter(Boolean)},th=r=>{for(let e of r.variants)if(rh(e)&&e.payload)return e.payload.id},rh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Po=r=>{let e=th(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},nh=(r,e)=>{for(let t of r.media.videos)if(e===Po(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},ko=(r,e)=>r.reduce((t,n)=>{let i=nh(e,n);return i?[...t,i]:t},[]);var ne,de,me,K,Ht,ie,se,te,fe,Pe,ke,tt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new et([]),hasPrevChapter$:new et(!1),prevChapter$:new et(null),isInitialChapter$:new et(!1),isGoBackLimited$:new et(!1)};U(this,ne,null);U(this,de);U(this,me,!1);U(this,K,null);U(this,Ht,null);this.events={inited$:new nn,destroyed$:new nn,error$:new nn};U(this,ie,null);U(this,se,null);U(this,te,null);U(this,fe,new ih);U(this,Pe,!1);U(this,ke,0);var o;$(this,ie,t),$(this,te,e),$(this,se,n),$(this,ne,i),$(this,de,s),this.state.history$&&w(this,fe)&&((o=w(this,fe))==null||o.add(this.state.history$.subscribe(c=>{var a,l;this.state.prevChapter$.next((0,sn.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((l=(a=w(this,K))==null?void 0:a.metadata)==null?void 0:l.initChapterId)),this.state.isGoBackLimited$.next(w(this,ke)===w(this,de).maxLength-1)})))}setManifest(e){return P(this,null,function*(){if(!w(this,se)||!w(this,te))return;$(this,K,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield w(this,se).setChapter({chapterId:t,pushToHistory:!1}),w(this,me)||($(this,me,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return w(this,me)}updateHistory(e,t=!0){return P(this,null,function*(){var c;if(!w(this,K))return;w(this,Pe)?($(this,Pe,!1),bn(this,ke)._++):$(this,ke,0);let n=w(this,K),i=e.length-w(this,de).maxLength,s=i>0?e.slice(i):e,o=rn(s,n);if($(this,Ht,o),this.state.history$.next(s),!(!t||!w(this,ne)||!w(this,ie)))try{yield w(this,ne).save(w(this,ie),o)}catch(a){let l=new F(1,5,"Unable to save interactive history");this.events.error$.next(l),(c=w(this,te))==null||c.emit(k.errors,l)}})}goBack(){return P(this,null,function*(){var n;if(!this.state||!w(this,se)){let i=new F(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=w(this,te))==null?void 0:n.emit(k.errors,i)}$(this,Pe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield w(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return P(this,null,function*(){var i;if(!w(this,K)||!w(this,ie))return;let e=w(this,K),t=[this.getInitialVideoId()];if(w(this,ne))try{let s=yield w(this,ne).get(w(this,ie));s.length&&(t=s)}catch(s){let o=new F(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=w(this,te))==null||i.emit(k.errors,o)}let n=ko(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,sn.default)(e,-1)||w(this,de).initChapterId||((t=w(this,K))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,K)){let e=this.getInitialChapterId();return rn([e],w(this,K)).pop()}return null}destroy(){var e,t;$(this,ie,null),$(this,ne,null),$(this,se,null),(e=w(this,fe))==null||e.unsubscribe(),$(this,fe,null),$(this,me,!1),(t=w(this,te))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),$(this,te,null)}};ne=new WeakMap,de=new WeakMap,me=new WeakMap,K=new WeakMap,Ht=new WeakMap,ie=new WeakMap,se=new WeakMap,te=new WeakMap,fe=new WeakMap,Pe=new WeakMap,ke=new WeakMap;var Ut=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 i;let e=(i=this.rootElement.getContext("2d"))==null?void 0:i.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let s=3;s<n;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 P(this,null,function*(){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n})}save(){return P(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 Gt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){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,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
var Ya=Object.create;var rr=Object.defineProperty,Za=Object.defineProperties,Ja=Object.getOwnPropertyDescriptor,el=Object.getOwnPropertyDescriptors,tl=Object.getOwnPropertyNames,ut=Object.getOwnPropertySymbols,rl=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty,Sn=Object.prototype.propertyIsEnumerable;var wn=r=>{throw TypeError(r)};var Tn=(r,e,t)=>e in r?rr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))nr.call(e,t)&&Tn(r,t,e[t]);if(ut)for(var t of ut(e))Sn.call(e,t)&&Tn(r,t,e[t]);return r},x=(r,e)=>Za(r,el(e));var Z=(r,e)=>{var t={};for(var n in r)nr.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&ut)for(var n of ut(r))e.indexOf(n)<0&&Sn.call(r,n)&&(t[n]=r[n]);return t};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var nl=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of tl(e))!nr.call(r,i)&&i!==t&&rr(r,i,{get:()=>e[i],enumerable:!(n=Ja(e,i))||n.enumerable});return r};var J=(r,e,t)=>(t=r!=null?Ya(rl(r)):{},nl(e||!r||!r.__esModule?rr(t,"default",{value:r,enumerable:!0}):t,r));var An=(r,e,t)=>e.has(r)||wn("Cannot "+t);var A=(r,e,t)=>(An(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?wn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$=(r,e,t,n)=>(An(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Rn=(r,e,t,n)=>({set _(i){$(r,e,i,t)},get _(){return A(r,e,n)}});var R=(r,e,t)=>new Promise((n,i)=>{var o=a=>{try{l(t.next(a))}catch(c){i(c)}},s=a=>{try{l(t.throw(a))}catch(c){i(c)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,s);l((t=t.apply(r,e)).next())});var te=h((mr,Bn)=>{"use strict";var Fe=function(r){return r&&r.Math===Math&&r};Bn.exports=Fe(typeof globalThis=="object"&&globalThis)||Fe(typeof window=="object"&&window)||Fe(typeof self=="object"&&self)||Fe(typeof global=="object"&&global)||Fe(typeof mr=="object"&&mr)||function(){return this}()||Function("return this")()});var z=h((Jd,qn)=>{"use strict";qn.exports=function(r){try{return!!r()}catch(e){return!0}}});var _e=h((em,Dn)=>{"use strict";var pl=z();Dn.exports=!pl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Wn=h((tm,zn)=>{"use strict";var hl=_e(),Gn=Function.prototype,Hn=Gn.apply,Un=Gn.call;zn.exports=typeof Reflect=="object"&&Reflect.apply||(hl?Un.bind(Hn):function(){return Un.apply(Hn,arguments)})});var Q=h((rm,Xn)=>{"use strict";var Kn=_e(),Qn=Function.prototype,fr=Qn.call,dl=Kn&&Qn.bind.bind(fr,fr);Xn.exports=Kn?dl:function(r){return function(){return fr.apply(r,arguments)}}});var Be=h((nm,Zn)=>{"use strict";var Yn=Q(),ml=Yn({}.toString),fl=Yn("".slice);Zn.exports=function(r){return fl(ml(r),8,-1)}});var vr=h((im,Jn)=>{"use strict";var vl=Be(),yl=Q();Jn.exports=function(r){if(vl(r)==="Function")return yl(r)}});var W=h((om,ei)=>{"use strict";var yr=typeof document=="object"&&document.all;ei.exports=typeof yr=="undefined"&&yr!==void 0?function(r){return typeof r=="function"||r===yr}:function(r){return typeof r=="function"}});var de=h((sm,ti)=>{"use strict";var bl=z();ti.exports=!bl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var wt=h((am,ri)=>{"use strict";var Cl=_e(),St=Function.prototype.call;ri.exports=Cl?St.bind(St):function(){return St.apply(St,arguments)}});var br=h(oi=>{"use strict";var ni={}.propertyIsEnumerable,ii=Object.getOwnPropertyDescriptor,gl=ii&&!ni.call({1:2},1);oi.f=gl?function(e){var t=ii(this,e);return!!t&&t.enumerable}:ni});var Cr=h((cm,si)=>{"use strict";si.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var li=h((um,ai)=>{"use strict";var El=Q(),Il=z(),xl=Be(),gr=Object,Tl=El("".split);ai.exports=Il(function(){return!gr("z").propertyIsEnumerable(0)})?function(r){return xl(r)==="String"?Tl(r,""):gr(r)}:gr});var Er=h((pm,ci)=>{"use strict";ci.exports=function(r){return r==null}});var Ir=h((hm,ui)=>{"use strict";var Sl=Er(),wl=TypeError;ui.exports=function(r){if(Sl(r))throw new wl("Can't call method on "+r);return r}});var qe=h((dm,pi)=>{"use strict";var Al=li(),Rl=Ir();pi.exports=function(r){return Al(Rl(r))}});var Ie=h((mm,hi)=>{"use strict";var kl=W();hi.exports=function(r){return typeof r=="object"?r!==null:kl(r)}});var At=h((fm,di)=>{"use strict";di.exports={}});var Rt=h((vm,fi)=>{"use strict";var xr=At(),Tr=te(),Ol=W(),mi=function(r){return Ol(r)?r:void 0};fi.exports=function(r,e){return arguments.length<2?mi(xr[r])||mi(Tr[r]):xr[r]&&xr[r][e]||Tr[r]&&Tr[r][e]}});var yi=h((ym,vi)=>{"use strict";var Pl=Q();vi.exports=Pl({}.isPrototypeOf)});var Ei=h((bm,gi)=>{"use strict";var Vl=te(),bi=Vl.navigator,Ci=bi&&bi.userAgent;gi.exports=Ci?String(Ci):""});var Ri=h((Cm,Ai)=>{"use strict";var wi=te(),Sr=Ei(),Ii=wi.process,xi=wi.Deno,Ti=Ii&&Ii.versions||xi&&xi.version,Si=Ti&&Ti.v8,X,kt;Si&&(X=Si.split("."),kt=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!kt&&Sr&&(X=Sr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=Sr.match(/Chrome\/(\d+)/),X&&(kt=+X[1])));Ai.exports=kt});var wr=h((gm,Oi)=>{"use strict";var ki=Ri(),Ml=z(),Nl=te(),Ll=Nl.String;Oi.exports=!!Object.getOwnPropertySymbols&&!Ml(function(){var r=Symbol("symbol detection");return!Ll(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ki&&ki<41})});var Ar=h((Em,Pi)=>{"use strict";var jl=wr();Pi.exports=jl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Rr=h((Im,Vi)=>{"use strict";var $l=Rt(),Fl=W(),_l=yi(),Bl=Ar(),ql=Object;Vi.exports=Bl?function(r){return typeof r=="symbol"}:function(r){var e=$l("Symbol");return Fl(e)&&_l(e.prototype,ql(r))}});var Ni=h((xm,Mi)=>{"use strict";var Dl=String;Mi.exports=function(r){try{return Dl(r)}catch(e){return"Object"}}});var kr=h((Tm,Li)=>{"use strict";var Hl=W(),Ul=Ni(),Gl=TypeError;Li.exports=function(r){if(Hl(r))return r;throw new Gl(Ul(r)+" is not a function")}});var $i=h((Sm,ji)=>{"use strict";var zl=kr(),Wl=Er();ji.exports=function(r,e){var t=r[e];return Wl(t)?void 0:zl(t)}});var _i=h((wm,Fi)=>{"use strict";var Or=wt(),Pr=W(),Vr=Ie(),Kl=TypeError;Fi.exports=function(r,e){var t,n;if(e==="string"&&Pr(t=r.toString)&&!Vr(n=Or(t,r))||Pr(t=r.valueOf)&&!Vr(n=Or(t,r))||e!=="string"&&Pr(t=r.toString)&&!Vr(n=Or(t,r)))return n;throw new Kl("Can't convert object to primitive value")}});var qi=h((Am,Bi)=>{"use strict";Bi.exports=!0});var Ui=h((Rm,Hi)=>{"use strict";var Di=te(),Ql=Object.defineProperty;Hi.exports=function(r,e){try{Ql(Di,r,{value:e,configurable:!0,writable:!0})}catch(t){Di[r]=e}return e}});var Ot=h((km,Wi)=>{"use strict";var Xl=qi(),Yl=te(),Zl=Ui(),Gi="__core-js_shared__",zi=Wi.exports=Yl[Gi]||Zl(Gi,{});(zi.versions||(zi.versions=[])).push({version:"3.38.0",mode:Xl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Mr=h((Om,Qi)=>{"use strict";var Ki=Ot();Qi.exports=function(r,e){return Ki[r]||(Ki[r]=e||{})}});var De=h((Pm,Xi)=>{"use strict";var Jl=Ir(),ec=Object;Xi.exports=function(r){return ec(Jl(r))}});var xe=h((Vm,Yi)=>{"use strict";var tc=Q(),rc=De(),nc=tc({}.hasOwnProperty);Yi.exports=Object.hasOwn||function(e,t){return nc(rc(e),t)}});var Nr=h((Mm,Zi)=>{"use strict";var ic=Q(),oc=0,sc=Math.random(),ac=ic(1 .toString);Zi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+ac(++oc+sc,36)}});var He=h((Nm,eo)=>{"use strict";var lc=te(),cc=Mr(),Ji=xe(),uc=Nr(),pc=wr(),hc=Ar(),Te=lc.Symbol,Lr=cc("wks"),dc=hc?Te.for||Te:Te&&Te.withoutSetter||uc;eo.exports=function(r){return Ji(Lr,r)||(Lr[r]=pc&&Ji(Te,r)?Te[r]:dc("Symbol."+r)),Lr[r]}});var io=h((Lm,no)=>{"use strict";var mc=wt(),to=Ie(),ro=Rr(),fc=$i(),vc=_i(),yc=He(),bc=TypeError,Cc=yc("toPrimitive");no.exports=function(r,e){if(!to(r)||ro(r))return r;var t=fc(r,Cc),n;if(t){if(e===void 0&&(e="default"),n=mc(t,r,e),!to(n)||ro(n))return n;throw new bc("Can't convert object to primitive value")}return e===void 0&&(e="number"),vc(r,e)}});var jr=h((jm,oo)=>{"use strict";var gc=io(),Ec=Rr();oo.exports=function(r){var e=gc(r,"string");return Ec(e)?e:e+""}});var lo=h(($m,ao)=>{"use strict";var Ic=te(),so=Ie(),$r=Ic.document,xc=so($r)&&so($r.createElement);ao.exports=function(r){return xc?$r.createElement(r):{}}});var Fr=h((Fm,co)=>{"use strict";var Tc=de(),Sc=z(),wc=lo();co.exports=!Tc&&!Sc(function(){return Object.defineProperty(wc("div"),"a",{get:function(){return 7}}).a!==7})});var ho=h(po=>{"use strict";var Ac=de(),Rc=wt(),kc=br(),Oc=Cr(),Pc=qe(),Vc=jr(),Mc=xe(),Nc=Fr(),uo=Object.getOwnPropertyDescriptor;po.f=Ac?uo:function(e,t){if(e=Pc(e),t=Vc(t),Nc)try{return uo(e,t)}catch(n){}if(Mc(e,t))return Oc(!Rc(kc.f,e,t),e[t])}});var fo=h((Bm,mo)=>{"use strict";var Lc=z(),jc=W(),$c=/#|\.prototype\./,Ue=function(r,e){var t=_c[Fc(r)];return t===qc?!0:t===Bc?!1:jc(e)?Lc(e):!!e},Fc=Ue.normalize=function(r){return String(r).replace($c,".").toLowerCase()},_c=Ue.data={},Bc=Ue.NATIVE="N",qc=Ue.POLYFILL="P";mo.exports=Ue});var _r=h((qm,yo)=>{"use strict";var vo=vr(),Dc=kr(),Hc=_e(),Uc=vo(vo.bind);yo.exports=function(r,e){return Dc(r),e===void 0?r:Hc?Uc(r,e):function(){return r.apply(e,arguments)}}});var Co=h((Dm,bo)=>{"use strict";var Gc=de(),zc=z();bo.exports=Gc&&zc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Eo=h((Hm,go)=>{"use strict";var Wc=Ie(),Kc=String,Qc=TypeError;go.exports=function(r){if(Wc(r))return r;throw new Qc(Kc(r)+" is not an object")}});var To=h(xo=>{"use strict";var Xc=de(),Yc=Fr(),Zc=Co(),Pt=Eo(),Io=jr(),Jc=TypeError,Br=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,qr="enumerable",Dr="configurable",Hr="writable";xo.f=Xc?Zc?function(e,t,n){if(Pt(e),t=Io(t),Pt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Hr in n&&!n[Hr]){var i=eu(e,t);i&&i[Hr]&&(e[t]=n.value,n={configurable:Dr in n?n[Dr]:i[Dr],enumerable:qr in n?n[qr]:i[qr],writable:!1})}return Br(e,t,n)}:Br:function(e,t,n){if(Pt(e),t=Io(t),Pt(n),Yc)try{return Br(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new Jc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var wo=h((Gm,So)=>{"use strict";var tu=de(),ru=To(),nu=Cr();So.exports=tu?function(r,e,t){return ru.f(r,e,nu(1,t))}:function(r,e,t){return r[e]=t,r}});var ze=h((zm,Ro)=>{"use strict";var Ge=te(),iu=Wn(),ou=vr(),su=W(),au=ho().f,lu=fo(),Se=At(),cu=_r(),we=wo(),Ao=xe();Ot();var uu=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return iu(r,this,arguments)};return e.prototype=r.prototype,e};Ro.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,s=n?Ge:i?Ge[t]:Ge[t]&&Ge[t].prototype,l=n?Se:Se[t]||we(Se,t,{})[t],a=l.prototype,c,f,v,y,g,w,E,m,u;for(y in e)c=lu(n?y:t+(i?".":"#")+y,r.forced),f=!c&&s&&Ao(s,y),w=l[y],f&&(r.dontCallGetSet?(u=au(s,y),E=u&&u.value):E=s[y]),g=f&&E?E:e[y],!(!c&&!o&&typeof w==typeof g)&&(r.bind&&f?m=cu(g,Ge):r.wrap&&f?m=uu(g):o&&su(g)?m=ou(g):m=g,(r.sham||g&&g.sham||w&&w.sham)&&we(m,"sham",!0),we(l,y,m),o&&(v=t+"Prototype",Ao(Se,v)||we(Se,v,{}),we(Se[v],y,g),r.real&&a&&(c||!a[y])&&we(a,y,g)))}});var Oo=h((Wm,ko)=>{"use strict";var pu=Math.ceil,hu=Math.floor;ko.exports=Math.trunc||function(e){var t=+e;return(t>0?hu:pu)(t)}});var We=h((Km,Po)=>{"use strict";var du=Oo();Po.exports=function(r){var e=+r;return e!==e||e===0?0:du(e)}});var Mo=h((Qm,Vo)=>{"use strict";var mu=We(),fu=Math.min;Vo.exports=function(r){var e=mu(r);return e>0?fu(e,9007199254740991):0}});var Ke=h((Xm,No)=>{"use strict";var vu=Mo();No.exports=function(r){return vu(r.length)}});var Vt=h((Ym,Lo)=>{"use strict";Lo.exports=function(){}});var jo=h(()=>{"use strict";var yu=ze(),bu=De(),Cu=Ke(),gu=We(),Eu=Vt();yu({target:"Array",proto:!0},{at:function(e){var t=bu(this),n=Cu(t),i=gu(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Eu("at")});var Mt=h((ef,$o)=>{"use strict";var Iu=Rt();$o.exports=Iu});var _o=h((tf,Fo)=>{"use strict";jo();var xu=Mt();Fo.exports=xu("Array","at")});var qo=h((rf,Bo)=>{"use strict";var Tu=_o();Bo.exports=Tu});var Ur=h((nf,Do)=>{"use strict";var Su=qo();Do.exports=Su});var Jo=h((nv,Zo)=>{"use strict";var Mu=We(),Nu=Math.max,Lu=Math.min;Zo.exports=function(r,e){var t=Mu(r);return t<0?Nu(t+e,0):Lu(t,e)}});var Xr=h((iv,ts)=>{"use strict";var ju=qe(),$u=Jo(),Fu=Ke(),es=function(r){return function(e,t,n){var i=ju(e),o=Fu(i);if(o===0)return!r&&-1;var s=$u(n,o),l;if(r&&t!==t){for(;o>s;)if(l=i[s++],l!==l)return!0}else for(;o>s;s++)if((r||s in i)&&i[s]===t)return r||s||0;return!r&&-1}};ts.exports={includes:es(!0),indexOf:es(!1)}});var rs=h(()=>{"use strict";var _u=ze(),Bu=Xr().includes,qu=z(),Du=Vt(),Hu=qu(function(){return!Array(1).includes()});_u({target:"Array",proto:!0,forced:Hu},{includes:function(e){return Bu(this,e,arguments.length>1?arguments[1]:void 0)}});Du("includes")});var is=h((av,ns)=>{"use strict";rs();var Uu=Mt();ns.exports=Uu("Array","includes")});var ss=h((lv,os)=>{"use strict";var Gu=is();os.exports=Gu});var tt=h((cv,as)=>{"use strict";var zu=ss();as.exports=zu});var ms=h((Ev,ds)=>{"use strict";var Qu=Mr(),Xu=Nr(),hs=Qu("keys");ds.exports=function(r){return hs[r]||(hs[r]=Xu(r))}});var vs=h((Iv,fs)=>{"use strict";var Yu=z();fs.exports=!Yu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Cs=h((xv,bs)=>{"use strict";var Zu=xe(),Ju=W(),ep=De(),tp=ms(),rp=vs(),ys=tp("IE_PROTO"),Jr=Object,np=Jr.prototype;bs.exports=rp?Jr.getPrototypeOf:function(r){var e=ep(r);if(Zu(e,ys))return e[ys];var t=e.constructor;return Ju(t)&&e instanceof t?t.prototype:e instanceof Jr?np:null}});var Es=h((Tv,gs)=>{"use strict";gs.exports={}});var Ts=h((Sv,xs)=>{"use strict";var ip=Q(),en=xe(),op=qe(),sp=Xr().indexOf,ap=Es(),Is=ip([].push);xs.exports=function(r,e){var t=op(r),n=0,i=[],o;for(o in t)!en(ap,o)&&en(t,o)&&Is(i,o);for(;e.length>n;)en(t,o=e[n++])&&(~sp(i,o)||Is(i,o));return i}});var ws=h((wv,Ss)=>{"use strict";Ss.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Rs=h((Av,As)=>{"use strict";var lp=Ts(),cp=ws();As.exports=Object.keys||function(e){return lp(e,cp)}});var Ns=h((Rv,Ms)=>{"use strict";var Os=de(),up=z(),Ps=Q(),pp=Cs(),hp=Rs(),dp=qe(),mp=br().f,Vs=Ps(mp),fp=Ps([].push),vp=Os&&up(function(){var r=Object.create(null);return r[2]=2,!Vs(r,2)}),ks=function(r){return function(e){for(var t=dp(e),n=hp(t),i=vp&&pp(t)===null,o=n.length,s=0,l=[],a;o>s;)a=n[s++],(!Os||(i?a in t:Vs(t,a)))&&fp(l,r?[a,t[a]]:t[a]);return l}};Ms.exports={entries:ks(!0),values:ks(!1)}});var Ls=h(()=>{"use strict";var yp=ze(),bp=Ns().values;yp({target:"Object",stat:!0},{values:function(e){return bp(e)}})});var $s=h((Pv,js)=>{"use strict";Ls();var Cp=At();js.exports=Cp.Object.values});var _s=h((Vv,Fs)=>{"use strict";var gp=$s();Fs.exports=gp});var Wt=h((Mv,Bs)=>{"use strict";var Ep=_s();Bs.exports=Ep});var an=h((ay,Ws)=>{"use strict";var Ap=Be();Ws.exports=Array.isArray||function(e){return Ap(e)==="Array"}});var Qs=h((ly,Ks)=>{"use strict";var Rp=TypeError,kp=9007199254740991;Ks.exports=function(r){if(r>kp)throw Rp("Maximum allowed index exceeded");return r}});var Zs=h((cy,Ys)=>{"use strict";var Op=an(),Pp=Ke(),Vp=Qs(),Mp=_r(),Xs=function(r,e,t,n,i,o,s,l){for(var a=i,c=0,f=s?Mp(s,l):!1,v,y;c<n;)c in t&&(v=f?f(t[c],c,e):t[c],o>0&&Op(v)?(y=Pp(v),a=Xs(r,e,v,y,a,o-1)-1):(Vp(a+1),r[a]=v),a++),c++;return a};Ys.exports=Xs});var ta=h((uy,ea)=>{"use strict";var Np=He(),Lp=Np("toStringTag"),Js={};Js[Lp]="z";ea.exports=String(Js)==="[object z]"});var na=h((py,ra)=>{"use strict";var jp=ta(),$p=W(),Qt=Be(),Fp=He(),_p=Fp("toStringTag"),Bp=Object,qp=Qt(function(){return arguments}())==="Arguments",Dp=function(r,e){try{return r[e]}catch(t){}};ra.exports=jp?Qt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Dp(e=Bp(r),_p))=="string"?t:qp?Qt(e):(n=Qt(e))==="Object"&&$p(e.callee)?"Arguments":n}});var oa=h((hy,ia)=>{"use strict";var Hp=Q(),Up=W(),ln=Ot(),Gp=Hp(Function.toString);Up(ln.inspectSource)||(ln.inspectSource=function(r){return Gp(r)});ia.exports=ln.inspectSource});var pa=h((dy,ua)=>{"use strict";var zp=Q(),Wp=z(),sa=W(),Kp=na(),Qp=Rt(),Xp=oa(),aa=function(){},la=Qp("Reflect","construct"),cn=/^\s*(?:class|function)\b/,Yp=zp(cn.exec),Zp=!cn.test(aa),ot=function(e){if(!sa(e))return!1;try{return la(aa,[],e),!0}catch(t){return!1}},ca=function(e){if(!sa(e))return!1;switch(Kp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Zp||!!Yp(cn,Xp(e))}catch(t){return!0}};ca.sham=!0;ua.exports=!la||Wp(function(){var r;return ot(ot.call)||!ot(Object)||!ot(function(){r=!0})||r})?ca:ot});var fa=h((my,ma)=>{"use strict";var ha=an(),Jp=pa(),eh=Ie(),th=He(),rh=th("species"),da=Array;ma.exports=function(r){var e;return ha(r)&&(e=r.constructor,Jp(e)&&(e===da||ha(e.prototype))?e=void 0:eh(e)&&(e=e[rh],e===null&&(e=void 0))),e===void 0?da:e}});var ya=h((fy,va)=>{"use strict";var nh=fa();va.exports=function(r,e){return new(nh(r))(e===0?0:e)}});var ba=h(()=>{"use strict";var ih=ze(),oh=Zs(),sh=De(),ah=Ke(),lh=We(),ch=ya();ih({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=sh(this),n=ah(t),i=ch(t,0);return i.length=oh(i,t,t,n,0,e===void 0?1:lh(e)),i}})});var Ca=h(()=>{"use strict";var uh=Vt();uh("flat")});var Ea=h((gy,ga)=>{"use strict";ba();Ca();var ph=Mt();ga.exports=ph("Array","flat")});var xa=h((Ey,Ia)=>{"use strict";var hh=Ea();Ia.exports=hh});var Sa=h((Iy,Ta)=>{"use strict";var dh=xa();Ta.exports=dh});var kn="1.0.35-dev.b58c8174.0";import{Subject as cl,Subscription as ul}from"@vkontakte/videoplayer-shared/es2015";var ir=class{constructor(e){this.layout=e}},pt=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))`}};function On(r){return"features"in r}var ge=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&On(this.options)&&this.options.features[e]}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,n)=>{let i=n.type.trim().toLowerCase(),o=this.factories.get(i);if(o){let s=o(n,this.options);if(s)return[...t,s]}return[...t]},[]))||[]}};import{fromEvent as Ct,once as al}from"@vkontakte/videoplayer-shared/es2015";function Me(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var Pn="interactive",F={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Vn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Vn||{}),Mn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Mn||{}),Nn=(n=>(n.start="left",n.end="right",n.center="center",n))(Nn||{}),ht=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Vn[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&Mn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&Nn[e.alignment])!=null?i:"center"},dt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,o,s,l,a,c;r.style.color=(o=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?o:t.textColor,r.style.fontSize=`calc(${n.height} * ${(l=(s=e==null?void 0:e.text)==null?void 0:s.size)!=null?l:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},mt=({target:r,props:e,fallback:t})=>{var n,i,o,s;r.style.backgroundColor=Me((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(s=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?s:t.backgroundAlpha)},Ne=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{var l,a,c,f,v,y,g,w,E,m,u;let o=i?t.borderWidthRawValue:`calc(${n.height} * ${(c=(a=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:a.width)!=null?c:t.borderWidth})`,s=i?t.roundCornersRawValue:`calc(${n.height} * ${(v=(f=e==null?void 0:e.shape)==null?void 0:f.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Me(i?t.borderColor:(w=(g=(y=e==null?void 0:e.shape)==null?void 0:y.border)==null?void 0:g.color)!=null?w:t.borderColor,i?t.borderAlpha:(u=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=s},Ln=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let s=Me(n.shadowColorLight,n.shadowColorAlpha),l=Me(n.shadowColorDark,n.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,f=`0px 0px ${a} ${c} ${e?l:s}`;r.style.boxShadow=f},Ee=({target:r,layoutParams:e,fallback:t})=>{var i;let n=(i=e.angle)!=null?i:t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};import{fromEvent as il,Subject as ol,Subscription as sl}from"@vkontakte/videoplayer-shared/es2015";var or="int",pe=(n=>(n.AREA=`${or}_area`,n.TEXT=`${or}_text`,n.BUTTON=`${or}_bttn`,n))(pe||{});function jn(r){return"features"in r}var ee="interactive-control",V={common:ee,selected:`${ee}-selected`,wrapper:`${ee}-wrapper`,disabled:`${ee}-disabled`,button:`${ee}-button`,area:`${ee}-area`,text:`${ee}-text`,blinkAnim:`${ee}-blink-anim`,blinkAnimButton:`${ee}-blink-anim-button`,blinkAnimArea:`${ee}-blink-anim-area`};var N=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var le=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new sl;this.error$=new ol}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(V.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:F.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:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&jn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(il(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>{let o=new N(1,1,{message:"Error happened on control interaction",error:i});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var ce=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ue=r=>ce(r,"Object"),ft=r=>ce(r,"String"),vt=r=>ce(r,"Array"),yt=r=>ce(r,"Number"),$n=r=>ce(r,"Function"),Fn=r=>ce(r,"Boolean"),sr=r=>yt(r)&&!isNaN(r);var he=r=>ue(r)&&Object.keys(r).length===0,ar=r=>vt(r)&&!r.length;var $e=(r,e)=>ft(r)&&(e?r.trim():r).length;var lr="interactive-blink-anim-reference",B={common:lr,animation:`${lr}-animation`,disabled:`${lr}-disabled`},bt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(B.common,B.animation),this._element=e}restart(){this._element&&(this._element.classList.add(B.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(B.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var cr="interactive-container",q={common:cr,hidden:`${cr}-hidden`,disabled:`${cr}-disabled`};var gt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new ur(r,e)},ur=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(V.common,V.area),n.setAttribute("data-testid",pe.AREA),mt({target:n,props:this.control.props,fallback:x(d({},F),{backgroundColor:"transparent"})}),Ee({target:n,layoutParams:this.control.layoutParams,fallback:F}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Ct(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(q.disabled))return;let n=e.parentElement;if(n){let i=n.querySelector(`.${B.common}`);i&&this.syncBlinkAnimation(i)}},n=>this.onError("Error happened in mouseleave callback",n))),this.subscriptions.add(Ct(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(q.disabled)||this.onBlinkHovering()},n=>this.onError("Error happened in mouseenter callback",n))).add(Ct(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},n=>this.onError("Error happened in mouseleave callback",n))))}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,n,i;if(!(!this.container||!this.controlElement))if(Fn(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Ln({target:this.controlElement,props:this.control.props,fallback:F,isDark:e,baseDimension:o}),Ne({target:this.controlElement,props:this.control.props,fallback:x(d({},F),{borderColor:e?F.shadowColorDark:F.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(i=(n=(t=this.control.props)==null?void 0:t.shape)==null?void 0:n.roundCorners)!=null?i:F.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else Ne({target:this.controlElement,props:this.control.props,fallback:x(d({},F),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(V.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(V.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${V.blinkAnimArea}`)||this.controlElement.classList.contains(V.selected)||this.controlElement.classList.contains(B.disabled)||(this.controlElement.classList.add(B.disabled),this.subscriptions.add(Ct(e,"animationiteration").pipe(al()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(B.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${V.blinkAnimArea}`)||this.controlElement.classList.contains(V.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new N(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};import{fromEvent as It,once as ll}from"@vkontakte/videoplayer-shared/es2015";var Et=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var xt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new pr(r,e)},pr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var s;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(V.common,V.button),n.setAttribute("data-testid",pe.BUTTON),Ee({target:n,layoutParams:this.control.layoutParams,fallback:F}),mt({target:n,props:this.control.props,fallback:F}),Ne({target:n,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),ht({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=Et(this.control.type.trim().toLowerCase()),o=(s=i.firstElementChild)!=null?s:i;dt({target:o,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(It(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(q.disabled))return;let n=e.parentElement;if(n){let i=n.querySelector(`.${B.common}`);i&&this.syncBlinkAnimation(i)}},n=>this.onError("Error happened in mouseleave callback",n))),this.subscriptions.add(It(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(q.disabled)||this.onBlinkHovering()},n=>this.onError("Error happened in mouseenter callback",n))).add(It(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},n=>this.onError("Error happened in mouseleave callback",n))))}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(V.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(V.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${V.blinkAnimButton}`)||this.controlElement.classList.contains(V.selected)||this.controlElement.classList.contains(B.disabled)||(this.controlElement.classList.add(B.disabled),this.subscriptions.add(It(e,"animationiteration").pipe(ll()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(B.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${V.blinkAnimButton}`)||this.controlElement.classList.contains(V.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new N(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var _n=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new hr(r,e)},hr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var s;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(V.common,V.text),n.setAttribute("data-testid",pe.TEXT),Ee({target:n,layoutParams:this.control.layoutParams,fallback:F}),ht({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=Et(this.control.type.trim().toLowerCase()),o=(s=i.firstElementChild)!=null?s:i;dt({target:o,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}onError(){}};var Tt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new dr(r,e,t)},dr=class extends ge{constructor(t,n,i){super(t,i);this.containerElement=null;this.controlSubscriptions=new ul;this.error$=new cl;this.rootElement=n,this.layout=new pt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",xt),this.addControlFactory("text",_n),this.addControlFactory("area",gt)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(q.common,q.disabled),requestAnimationFrame(()=>{n.classList.remove(q.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t),this.controlSubscriptions.add(i.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(q.hidden)}show(){let t=this.getElement();t&&t.classList.remove(q.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(q.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(q.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};var Qa=J(Ur(),1);import{combine as Sh,InterfaceLanguage as wh,Observable as za,once as Ah,Subject as D,Subscription as fn,ValueSubject as U,fromEvent as Wa}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as lt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as wu}from"@vkontakte/videoplayer-shared/es2015";function Qe(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var Ho="video_interactive",Uo="videoint";var Go=250,Xe=class{constructor(e){this.handleZoomChange=Qe(e=>{this.lastZoomInfo=e},Go);this.onResize=e=>{var n;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((n=this.ngEditor)==null||n.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,n,i;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(n=this.ngEditor)==null||n.selectChapter(e.id),(i=this.ngEditor)==null||i.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var n;if(this.isReady=!1,!yt(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"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:n,lang:i,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=n,this.lang=i!=null?i:"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(Qe(this.onResize,Go)),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 R(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 R(this,null,function*(){var n;if(!this.manifest)return;let e;try{e=yield wu(this.lang,Ho,Uo)}catch(i){(n=this.onError)==null||n.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",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 l=s,{name:i}=l,o=Z(l,["name"]);var a;i==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.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 Ye=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,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let s=o.startTime-e;if(s<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<s&&(t=t===-1?s:Math.min(t,s))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as Lt,ContainerTypes as Of,ControlTypes as jt,EventActionTypes as P,EventTypes as Pf,migrateManifestToLatestVersion as Qo,compareVersions as Vf}from"@interactiveplatform/movika-manifest";var zo={metadata:"Object",chapters:"Array"},Wo=r=>{if(!ue(r))return!1;for(let e in zo)if(!r[e]||!ce(r[e],zo[e]))return!1;return Lt(r.metadata.version)},Nt=r=>r.type===jt.Text,If=r=>r.type===jt.Button,xf=r=>r.type===jt.Area,Tf={Choice:"Choice",TextInput:"TextInput"},Sf={Button:"Button",Area:"Area",Text:"Text"},wf={onClick:"onClick",onSuspense:"onSuspense"},Ko={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var $t=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 n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Ft=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{$n(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==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 Ku}from"@vkontakte/videoplayer-shared/es2015";var _t=class{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!=null?n:[]}}exec(e,t){return R(this,null,function*(){return Ru(...this.loaders[e])(t)})}};function Ru(...r){return function(t){return R(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Ze(r,e,t){return r?x(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Bt(i){var o=i,{actions:r,errors:e,chapterId:t}=o,n=Z(o,["actions","errors","chapterId"]);if(t){let s=r.getManifest();if(s){let l=r.getChapter(s.chapters,t);if(l){let a=r.getMedia(s.media,l.videoId),c=r.getGraph(s.graph,l.id);return a?x(d({},n),{actions:r,errors:e,result:{chapter:l,media:a,graph:c}}):x(d({},n),{errors:Ze(e,Bt.name,"Could not find media"),actions:r})}}}return x(d({},n),{errors:Ze(e,Bt.name,"Could not find chapter"),actions:r})}var qt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,o=n.length;i<o;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,o=n.length;i<o;i++){let s=n[i];try{s.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}},Ae=class extends qt{constructor(){super(),this.listeners||qt.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)}},Je=class{constructor(){Object.defineProperty(this,"signal",{value:new Ae,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(i){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 n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(i){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Je.prototype[Symbol.toStringTag]="AbortController",Ae.prototype[Symbol.toStringTag]="AbortSignal");function Dt(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 Gr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Dt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||i)&&(o=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},o.prototype=t.prototype);let s=e;return{fetch:(a,c)=>{let f=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(f){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(f.aborted)return Promise.reject(v);let y=new Promise((g,w)=>{f.addEventListener("abort",()=>w(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([y,s(a,c)])}return s(a,c)},Request:o}}var et=Dt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Xo=et?Gr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,zr=et?Xo.fetch:window.fetch,zf=et?Xo.Request:window.Request,Wf=et?Je:window.AbortController,Kf=et?Ae:window.AbortSignal;var Wr=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let o=0;o<Math.max(t.length,n.length)&&!i;o++)t[o]>n[o]?i=1:t[o]<n[o]?i=-1:i=0;return i};var ku=r=>R(void 0,null,function*(){try{let e={},t;if(ft(r)){t=new URL(r).href;let i=yield zr(t);if(!i.ok)return{};e=yield i.json()}else if(ue(r))e=r;else return{};if(!Wo(e))return{};let n=e.metadata.media;if(ft(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=yield zr(i);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(i){return Vu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Yo(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield ku(r);if(!e)throw new Error("Failed on fetch");let n=Qo(e);return n.media=Ou(n.media,t),delete n.metadata.media,n})}function Ht(r,e){if(e)return r.find(t=>t.id===e)}function Kr(r,e){var t,n;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(i=>i.id===e):(n=r.view)!=null&&n.chapters?r.view.chapters.find(i=>i.id===e):void 0}function Qr(r,e){return r.videos.find(t=>t.id===e)}function Ou(r,e){return x(d({},r),{videos:r.videos.map(t=>x(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=Pu(i,e);return x(d({},n),{url:o||i})})}))})}function Pu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Vu(r){return Wr(r,"3.2.0")>=0}var ls=J(tt(),1);var Ut=r=>vt(r)&&!ar(r),re=r=>r.order==="end",Gt=r=>vt(r.containers)&&!ar(r.containers)&&re(r),cs=(r,e)=>{var n;let t=r*1e3;return Ut(e.controls)&&t<((n=e.startTime)!=null?n:0)},Yr=(r,e)=>{var n,i;let t=r*1e3;return Ut(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var me=(r=[])=>r.some(e=>e.action.type==="expect"),Zr=(r=[])=>r.find(e=>e.action.type==="expect"),Wu=r=>(r==null?void 0:r.length)===1,Re=r=>Wu(r)&&Nt(r[0]);function us(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,ls.default)(t,n.container.id)&&me(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function zt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),us(r,i.container.container.endTime,[i.container.container.id]).forEach(s=>{n(s)});break}}var ps=(r,e)=>{let t=E=>{let m=e.find(({container:u})=>u.container.id===E);return m==null?void 0:m.container.isRemoved},n=me(r.events)&&!t(r.id),i=(E,m=!1,u=!1)=>{let p=u?"every":"some";return E.controls[p](b=>{var S;let I=m?E.endTime===r.endTime:!0;return((S=b.events)==null?void 0:S[p](C=>{var T;return((T=C.action)==null?void 0:T.type)===Ko.openURI}))&&I})},o=E=>E.some(({container:m})=>i(m.container,!0,!1)&&!m.isRemoved),s=E=>E.every(({container:m})=>m.isRemoved?!0:i(m.container,!0,!0)),l=us(e,r.endTime,[r.id]).length,a=E=>E.controls.some(m=>{var u;return(u=m.events)==null?void 0:u.some(p=>{var b,I;return(I=(b=p.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=n||l>0,f=o(e),v=i(r),y=s(e),g=n?!1:l>0,w=a(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:f,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:y,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:w}};var ke=class extends _t{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Ku(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return R(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ze},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield Yo((i=n.result)!=null?i:t),this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(this,arguments,function*(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=yield this.exec("chapterLoaders",Bt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Kr,getChapter:Ht,getMedia:Qr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ze},result:null,errors:null,chapterId:t}));return i.errors&&this.errorHandler(i.errors),i.result&&(this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var n;return this.getByChapterId((n=this.manifest)==null?void 0:n.metadata.initChapterId)||null}getByChapterId(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t||!this.manifest)return null;let i=Ht(this.manifest.chapters,t);if(i){let o=Qr(this.manifest.media,i.videoId),s=Kr(this.manifest.graph,i.id);if(o)return{chapter:i,media:o,graph:s}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,o,s;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Ht(((s=this.manifest)==null?void 0:s.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let o=this.getByChapterId(i.chapterId);return o&&n.push(o),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,n;return((t=this.chapter)==null?void 0:t.id)===((n=this.manifest)==null?void 0:n.metadata.initChapterId)}isEndChapter(){return this.chapter?re(this.chapter):!1}};var Hs=J(Wt(),1);import{Player as Ip}from"@vkontakte/videoplayer-core/es2015";import{Subscription as nn,Tracer as xp,ValueSubject as Tp}from"@vkontakte/videoplayer-shared/es2015";var qs=r=>{let e=r.variants.find(t=>{var n;return((n=t.payload)==null?void 0:n.type)==="vk"});if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var Ds=J(Wt(),1);function tn(){let r=new Map;function e(a){var c=a,{listId:o=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=Z(c,["listId","itemId"]);let f=r.get(o),v=d({},l);return f?f[s]=v:r.set(o,{[s]:v}),d({listId:o,itemId:s},l)}function t(o){var s,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(s=o.statistics)==null||s.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function n(o,s){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(s){let a=l[s];a&&t(a),delete l[s],Object.keys(l).length||r.delete(o)}else{for(let a of(0,Ds.default)(l))t(a);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var Oe=J(tt(),1);function rn(r,e=[]){var o,s,l;let t={},n,i=!e.length;for(let a of r.variants)if(!n&&"cover"in a&&(n=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(i||(0,Oe.default)(e,"mp4"))&&(t.MPEG=x(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,Oe.default)(e,"mpeg"))&&(t.MPEG=x(d({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"hls":(i||(0,Oe.default)(e,"hls"))&&(t=x(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,Oe.default)(e,"dash"))&&(t=x(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(l=r.title)!=null?l:""}}var rt=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Oe.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Sp=2;function on(r){let e=tn(),t=new nn,n={},i=null,o=!1,s,l=new Tp(null);r&&a(r);function a(m){i=m}function c(m,u,p){var S;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=((S=e.map.get(m))!=null?S:{})[u];if(I){n=d({chapterId:p,listId:m,itemId:u},I);let C=n.player;n.subscription.add(C.info.currentQuality$.subscribe(T=>{let H=C.info.position$.getValue(),O=C.info.isAutoQualityEnabled$.getValue();if(!(!T||!H||O))for(let L of e.map)(0,Hs.default)(L[1]).forEach(({player:M})=>{rt(M,T)})})).add(C.events.started$.subscribe(()=>{f(u)})),I.container.remove(),i.setPlayer(I.player),o||(i.init(),o=!0),l.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function f(m){return R(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(he(n)||m!==n.itemId)return;let u=i.getChapterBranches(),p=new Set;for(let b of u)p.has(b.media.id)||(yield y({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),p.add(b.media.id))})}function v(p){return R(this,arguments,function*({chapter:{id:m},manifestVideo:u}){if(he(n)||!i)return;let b=n.player.info.muted$.getValue(),I=n.player.info.currentQuality$.getValue(),S=n.player.info.isAutoQualityEnabled$.getValue(),C=n.player.info.volume$.getValue(),T=n.player.info.currentPlaybackRate$.getValue(),H=!S,O=!1;for(let L of e.map)if(L[0]===u.id&&!i.state.isReplay$.getValue()){let M=Object.keys(L[1]);for(let _ of M)_===n.itemId?(M.length<Sp||(O=!0),e.removePlayer(L[0],_)):(O=!0,c(L[0],_,m),H?rt(n.player,I):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(b),n.player.setPlaybackRate(T))}else e.removePlayer(L[0]);O||(yield y({media:u,chapterId:m,setAsActive:!0,playbackRate:T}),H?rt(n.player,I):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(b))})}function y(H){return R(this,arguments,function*({media:m,chapterId:u,prefetch:p=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:S,title:C,playbackRate:T}){var bn,Cn,gn,En,In;let O=Math.random().toString(),L=document.createElement("div");s.append(L);let M;if((bn=i==null?void 0:i.options)!=null&&bn.vkVideoLoader){let ct=qs(m);ct.length&&(M=yield i.options.vkVideoLoader(...ct))}let _=((Cn=i==null?void 0:i.options)==null?void 0:Cn.coreConfig)||void 0,be=x(d({},_),{configName:[...(gn=_==null?void 0:_.configName)!=null?gn:[],"interactive"]}),ie=x(d({container:L},((En=M==null?void 0:M.videos)==null?void 0:En[0])||{sources:rn(m,S).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),Y=new Ip(be,xp.createRootTracer());Y.initVideo(ie);let vn=null;if(M!=null&&M.videos&&(i!=null&&i.options.createOneStat)){let ct=M.videos[0],tr=i.options.createOneStat(ct),xn=new nn;tr&&(xn.add(tr.attachTo(Y)),vn={oneStat:tr,statSubscription:xn})}let yn=new nn,Xa=(In=n==null?void 0:n.player)==null?void 0:In.info.isAutoQualityEnabled$.getValue();yn.add(Y.events.canplay$.subscribe(function(){Xa||rt(Y,n.player.info.currentQuality$.getValue()),T&&Y.setPlaybackRate(T)}));let Ce=e.createPlayer({listId:m.id,itemId:O,player:Y,container:L,sources:rn(m,S).sources,config:ie,subscription:yn,statistics:vn});return b&&c(m.id,Ce.itemId,u),I&&Ce.player.play(),p&&!I&&Ce.player.prepare(),{player:Ce.player,config:Ce.config,statistics:Ce.statistics}})}function g(){w(),i=null,s.remove()}function w(){t.unsubscribe(),e.removeAll(),n={},o=!1}function E(){return R(this,null,function*(){if(!i)throw Error("need to set interactive controller");w(),s=document.createElement("div");let{media:m,chapter:u}=i.getCurrentChapter();m&&u?(t.add(i.events.chapterChanged$.subscribe(v)),yield y({media:m,chapterId:u.id,title:u.label})):console.error("not found")})}return x(d({},e),{init:E,setInteractiveController:a,createPlayer:y,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:l})}var k={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},j={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Gs=J(tt(),1);import{Subscription as wp}from"@vkontakte/videoplayer-shared/es2015";function sn(r){return function(...t){return r(...t.reverse())}}function it(r,...e){return(...t)=>ue(e[0])&&ue(t[0])?r(d(d({},e[0]),t[0])):r(...e,...t)}var Kt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:s,globalEventEmitter:l,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:f,disabledControls$:v,onRemove:y,onError:g}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(me(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,n,i,o;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&s)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(a,c)=>{let{isExpectTime:f,hasOtherExpect:v,hasOpenURIEvent:y,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:w,hasShouldOpenNowEvent:E}=this.getContainerEventState(),m=this.interactiveTimeOpenUri&&!g,u=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||m)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||m)){if(this.interactiveTimeOpenUri){let p=!v&&!w&&g;p&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:p})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&y&&this.gameState!==5){if(u){let b=((I,S,C,T)=>!I&&!S&&C||I&&!S&&C&&!T||I&&!S&&C&&T)(f,v,w,this.isSelectedContainerEvent);this.fakeRemoveView(b)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!f||!v||!E)&&(this.selectBranches.stopExpect(),c())}},isEOV:()=>this.gameState===4},l=it(this.selectBranches.onControlEvent,s);this.container.createView({eventCallback:l}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((o=(i=this.container).disable)==null||o.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c,f,v;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Gs.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(cs(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Yr(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let y=this.gameState;this.gameState=3,y===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:y}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,w=this.interactiveTimeOpenUri&&y;if(w&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((f=(c=this.container).hide)==null||f.call(c)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!w&&this.removeView()}let s=Yr(o,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(v=this.container.container.endTime)!=null?v:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:o,isInteractiveTime:s};this.container.onProgress(o*1e3,s),this.globalEventEmitter.emit(k.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new wp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a,this.isPermanentText=c&&Re(t.container.controls),this.interactiveTimeOpenUri=f,this.disabledControls$=v,this.onRemove=y,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=s,this.onError=g,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(k.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(k.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,n,i,o;e?(n=(t=this.container).disable)==null||n.call(t):(o=(i=this.container).enable)==null||o.call(i)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var n,i;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(n=this.container.container.endTime)!=null?n:1/0,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(),n=this.interactiveTimeOpenUri?e||t:me(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(k.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)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}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 zs=(r=[])=>r.reduce((e,t,n)=>{var o,s,l;let i=((o=t==null?void 0:t.controls)!=null?o:[]).filter(a=>!Nt(a));if(Ut(i)){let a=[(s=t.startTime)!=null?s:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:a});else{let f=[],v=-1/0,y=1/0,g=[],w=[];for(let E=0;E<e.length;E++){let m=e[E];if(w.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[E].subjects.push(c),e;a[0]<m.range[0]&&a[1]>m.range[0]&&(f.push(E),g=g.concat(m.subjects)),a[0]>=m.range[0]&&a[0]<=m.range[1]&&(f.push(E),g=g.concat(m.subjects),a[0]=m.range[0]),a[1]>=m.range[0]&&a[1]<=m.range[1]&&(f.push(E),g=g.concat(m.subjects),a[1]=m.range[1])}if(w.push(c),a[0]<=y&&a[1]>=v)return[{subjects:w,range:a}];f.length&&f.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Aa=J(tt(),1),un=J(Wt(),1),Ra=J(Sa(),1);function wa(){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 n(l){let a={};for(let c in r)+c>=l&&(a[c]=r[c]);return a}function i({timestamp:l,priority:a,initiator:c}){var f;if(sr(l)){let v=(f=r[l])!=null?f:null;if(v&&a&&$e(a,!0)){let y={},g=v[a];if(g&&(y=d(d({},y),g)),y=he(y)?null:y,y&&$e(c,!0)){let w=y[c];return w!=null?w:null}return y}return v}return null}function o({timestamp:l,priority:a,initiator:c}){if(sr(l))if(r[l]){if(a&&$e(a,!0))if(r[l][a]){if(c&&$e(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 s(v){var y=v,{timestamp:l,priority:a,initiator:c}=y,f=Z(y,["timestamp","priority","initiator"]);var g,w,E;(w=(g=r[l])==null?void 0:g[a])!=null&&w[c]?r[l][a][c].push(d({},f)):(E=r[l])!=null&&E[a]?r[l][a]=x(d({},r[l][a]),{[c]:[d({},f)]}):r[l]?r[l]=x(d({},r[l]),{[a]:{[c]:[d({},f)]}}):r[l]={[a]:{[c]:[d({},f)]}}}return{map:r,remove:o,add:s,removeAll:e,get:i,getLte:t,getGte:n}}var mh=[P.expect,P.setNextBranch],fh=1/0;function ka(r,e){let t=r,n,i=vh(e),o=wa(),s,l=()=>{g(),u()},a=p=>{o.add.call(void 0,p),w()},c=(p=[])=>{for(let b of p)if(b.action(),(0,Aa.default)(mh,b.actionType))break},f=(p=1/0)=>{var C,T,H;let b=Xt((C=o.get({timestamp:p,priority:"control"}))!=null?C:{}),I=Xt((T=o.get({timestamp:p,priority:"container"}))!=null?T:{}),S=Xt((H=o.get({timestamp:p,priority:"chapter"}))!=null?H:{});return[...b,...I,...S]},v=p=>{i.isReady(p)&&c(f(p))},y=()=>{var p;c([...Xt((p=o.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},g=()=>{n&&(s==null||s.unsubscribe(),n=void 0)},w=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),s=t.events.ended$.subscribe(n))},E=p=>{g(),t=p},m=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),o.remove(p)},u=()=>{i.release(),o.removeAll()};return{setPlayer:E,add:a,remove:m,exec:v,execEndOfVideo:y,listen:w,unlisten:g,release:l,containersEventsCallState:i,getPreparedToExecActions:f}}function vh(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;for(let c of l){let f=(a=c.endTime)!=null?a:fh,v=e.get(f);e.set(f,x(d({},v),{[c.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,un.default)(a);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function Xt(r){return(0,Ra.default)((0,un.default)(r)).sort(e=>e.actionType===P.expect?-1:1)}var Oa={videoContentHeight:0,videoContentWidth:0},Pa=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Oa;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return Oa;let o=e/t,s=n/i,l,a;return s>o?(a=i,l=i*o):s<o?(a=n/o,l=n):(a=i,l=n),{videoContentWidth:a,videoContentHeight:l}};var yh=250;function Va(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function n(l){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:f,videoContentHeight:v}=Pa(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 i(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Qe(l=>{let{fns:a=[]}=r();n(l);for(let c of a)c()},yh);function s(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:s}}var bh=r=>Math.floor(Math.random()*r),Na=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let o=r[e],s=(i=o.weight)!=null?i:1;s<t&&(t=s,n=o)}return n},La=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let o=r[e],s=(i=o.weight)!=null?i:0;s>t&&(t=s,n=o)}return n};var ja=r=>{let e=r.length,t=bh(e);return r[t]},Ma=1,$a=r=>{var n,i;let e=0;for(let o=0;o<r.length;++o)e+=(n=r[o].weight)!=null?n:Ma;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(i=r[o].weight)!=null?i:Ma,e>=t)return r[o];return r[r.length-1]};var Fa={shouldOpenNow:!0,isDetachContainer:!0},_a="after-expect",pn=(r,e=!1)=>x(d({},r),{args:e?d(d({},r.args),Fa):d(d({},Fa),r.args)}),Ba=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},s=({action:u,controlType:p,controlId:b,containerId:I,branches:S=[],onEvent:C,isEOV:T=()=>!1,isDisabled:H=()=>!1})=>{let O=pn(u,T()),L={timestamp:1/0,priority:"control",initiator:b,actionType:O.type},M=H(),_=r.emit.bind(r,k.interactives,{subjectId:b,subjectType:p,subjectName:"control",type:M?j.actionChoiceCanceled:j.actionChoice,actionType:u.type,payload:d({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)}),be=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:p,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:u.type,payload:d({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)})};if(M){_(),be();return}switch(O.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let ie=S.find(Y=>Y.id===O.args.branchId);if(!ie)return;C(O.args.isDetachContainer,g.bind(null,{subjectId:b,subjectName:"control"})),_(),be(),O.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:p,action:O,payload:{chapterId:ie.chapterId,autoSelect:!1}}):n.add(x(d({},L),{action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:O,payload:{chapterId:ie.chapterId,autoSelect:!1}})}));return}case P.continuePlayback.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:b,subjectName:"control"})),_(),be(),O.args.shouldOpenNow?w({subjectId:b,subjectName:"control",subjectType:p,action:u}):n.add(x(d({},L),{action:w.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:u})}));return}case P.openURI.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:b,subjectName:"control"})),_(),be(),O.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:p,action:O,payload:{URI:u.args.uri}}):n.add(x(d({},L),{action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:O,payload:{URI:u.args.uri}})}));return}default:{let ie="Unexpected control event",Y=new N(1,1,{message:ie});f(Y,ie);return}}},l=({action:u,container:{id:p,endTime:b},branches:I=[],isEOV:S=!1,autoSelected:C=!1})=>{let T=pn(u,S),H={timestamp:!T.args.shouldOpenNow||S?1/0:b!=null?b:1/0,priority:"container",initiator:p,actionType:T.type},O=r.emit.bind(r,k.interactives,{subjectId:p,subjectName:"container",type:j.actionChoice,actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)}),L=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)})};switch(T.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let M=I.find(_=>_.id===T.args.branchId);if(!M)return;O(),L(),n.add(x(d({},H),{action:E.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{chapterId:M.chapterId,autoSelect:C}})}));return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{O(),L(),n.add(x(d({},H),{action:w.bind(null,{subjectId:p,subjectName:"container",action:T})}));return}case P.openURI.trim().toLowerCase():{O(),L(),n.add(x(d({},H),{action:m.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{URI:u.args.uri}})}));return}default:{let M="Unexpected container event",_=new N(1,1,{message:M});f(_,M);return}}};function a({container:u,branches:p,isEOV:b=!1}){var S,C;let I=Zr(u.events);if(I){let T=pn(I.action,b);r.emit(k.interactives,{subjectId:u.id,subjectName:"container",type:j.actionChoice,actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)}),n.add({timestamp:b?1/0:(S=u.endTime)!=null?S:1/0,priority:"container",initiator:u.id,actionType:P.expect,action:y.bind(null,{subjectId:u.id,subjectName:"container"})}),i.isExpect=!0}else for(let T of(C=u.events)!=null?C:[])l({action:T.action,container:u,branches:p,isEOV:b})}let c=({chapterId:u,action:p,branches:b=[]})=>{let I=r.emit.bind(r,k.interactives,{subjectId:u,subjectName:"chapter",type:j.actionChoice,actionType:p.type,payload:p.args}),S=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let C=b.find(T=>T.id===p.args.branchId);return C!=null&&C.chapterId?(I(),S(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let C=ja(b);return C!=null&&C.chapterId?(I(),S(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let C=$a(b);return C!=null&&C.chapterId?(I(),S(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let C=La(b);return C!=null&&C.chapterId?(I(),S(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let C=Na(b);return C!=null&&C.chapterId?(I(),S(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return I(),S(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p});case P.openURI.trim().toLowerCase():return I(),S(),m.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let C="Unexpected chapter event",T=new N(1,1,{message:C});f(T,C);return}}};function f(u,p){console.error(p),e.error$.next(u),r.emit(k.errors,u)}function v(u){var b;let p=Zr(u.events);if(p){if(re(u))return;r.emit(k.interactives,{subjectId:u.id,subjectName:"chapter",type:j.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:P.expect,action:y.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(b=u.events)==null||b.forEach(I=>{let S=c({chapterId:u.id,action:I.action,branches:u.branches});S&&n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:I.action.type,action:S})})}let y=({subjectId:u,subjectName:p})=>{t.pause(),r.emit(k.interactives,{subjectId:u,subjectName:p,type:j.actionExecution,actionType:P.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:P.expect})},g=({subjectId:u,subjectName:p})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:u,subjectName:p,type:j.actionExecution,actionType:_a}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:_a})},w=({subjectId:u,subjectName:p,subjectType:b,action:I})=>{r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:j.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:u,subjectName:p,subjectType:b,action:I,payload:S})=>{S.behaviour="change-chapter",r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:j.actionExecution,actionType:I.type,payload:S}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type,payload:S})},m=({subjectId:u,subjectName:p,subjectType:b,action:I,payload:S})=>{if(!S.URI)return;let C=window.open(S.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:j.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:s,onContainerEvent:l,onChapterEvent:c,onExpectEvent:y,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:a,stopExpect:o,state:i}};var mn=J(Ur(),1);import{Subscription as xh,Subject as dn,ValueSubject as st}from"@vkontakte/videoplayer-shared/es2015";var hn=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(s=>s.id===n);if(!i)return null;let o=e.media.videos.find(s=>i.videoId===s.id);if(!o)return null;t[n]=qa(o)}return t[n]}).filter(Boolean)},gh=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"),qa=r=>{let e=gh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ih=(r,e)=>{for(let t of r.media.videos)if(e===qa(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Da=(r,e)=>r.reduce((t,n)=>{let i=Ih(e,n);return i?[...t,i]:t},[]);var oe,fe,ve,K,Yt,se,ae,ne,ye,Pe,Ve,at=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new st([]),hasPrevChapter$:new st(!1),prevChapter$:new st(null),isInitialChapter$:new st(!1),isGoBackLimited$:new st(!1)};G(this,oe,null);G(this,fe);G(this,ve,!1);G(this,K,null);G(this,Yt,null);this.events={inited$:new dn,destroyed$:new dn,error$:new dn};G(this,se,null);G(this,ae,null);G(this,ne,null);G(this,ye,new xh);G(this,Pe,!1);G(this,Ve,0);var s;$(this,se,t),$(this,ne,e),$(this,ae,n),$(this,oe,i),$(this,fe,o),this.state.history$&&A(this,ye)&&((s=A(this,ye))==null||s.add(this.state.history$.subscribe(l=>{var a,c;this.state.prevChapter$.next((0,mn.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=A(this,K))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(A(this,Ve)===A(this,fe).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!A(this,ae)||!A(this,ne))return;$(this,K,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield A(this,ae).setChapter({chapterId:t,pushToHistory:!1}),A(this,ve)||($(this,ve,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return A(this,ve)}updateHistory(e,t=!0){return R(this,null,function*(){var l;if(!A(this,K))return;A(this,Pe)?($(this,Pe,!1),Rn(this,Ve)._++):$(this,Ve,0);let n=A(this,K),i=e.length-A(this,fe).maxLength,o=i>0?e.slice(i):e,s=hn(o,n);if($(this,Yt,s),this.state.history$.next(o),!(!t||!A(this,oe)||!A(this,se)))try{yield A(this,oe).save(A(this,se),s)}catch(a){let c=new N(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=A(this,ne))==null||l.emit(k.errors,c)}})}goBack(){return R(this,null,function*(){var n;if(!this.state||!A(this,ae)){let i=new N(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=A(this,ne))==null?void 0:n.emit(k.errors,i)}$(this,Pe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield A(this,ae).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var i;if(!A(this,K)||!A(this,se))return;let e=A(this,K),t=[this.getInitialVideoId()];if(A(this,oe))try{let o=yield A(this,oe).get(A(this,se));o.length&&(t=o)}catch(o){let s=new N(1,5,"Error while trying to fetch data");this.events.error$.next(s),(i=A(this,ne))==null||i.emit(k.errors,s)}let n=Da(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,mn.default)(e,-1)||A(this,fe).initChapterId||((t=A(this,K))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(A(this,K)){let e=this.getInitialChapterId();return hn([e],A(this,K)).pop()}return null}destroy(){var e,t;$(this,se,null),$(this,oe,null),$(this,ae,null),(e=A(this,ye))==null||e.unsubscribe(),$(this,ye,null),$(this,ve,!1),(t=A(this,ne))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),$(this,ne,null)}};oe=new WeakMap,fe=new WeakMap,ve=new WeakMap,K=new WeakMap,Yt=new WeakMap,se=new WeakMap,ae=new WeakMap,ne=new WeakMap,ye=new WeakMap,Pe=new WeakMap,Ve=new WeakMap;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 i;let e=(i=this.rootElement.getContext("2d"))==null?void 0:i.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let o=3;o<n;o+=40)if(t[o]!==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 R(this,null,function*(){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n})}save(){return R(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 Jt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){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,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,50 +11,139 @@ var Fo=Object.create;var Kt=Object.defineProperty,qo=Object.defineProperties,Bo=
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new Zt,this.endOffsetMs=t,this._callbacks={onError:n},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
|
|
20
|
-
|
|
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 R(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}})}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 n,i,o;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)==null?void 0:t.onError)==null||n.call(t,e)}};function Ha(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Ua=`/* interactive-container */
|
|
20
|
+
.interactive-container {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
visibility: visible;
|
|
23
|
+
transition: opacity var(--interactive-transition-1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.interactive-container-disabled {
|
|
27
|
+
opacity: 0.5;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.interactive-container-hidden {
|
|
31
|
+
visibility: hidden;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* blink-anim */
|
|
35
|
+
.interactive-control-blink-anim {
|
|
36
|
+
animation-duration: 2001ms;
|
|
37
|
+
animation-iteration-count: infinite;
|
|
38
|
+
animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.interactive-control-blink-anim-button {
|
|
42
|
+
animation-name: interactive-blinking-button;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.interactive-control-blink-anim-area {
|
|
46
|
+
animation-name: interactive-blinking-area;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@keyframes interactive-blinking-area {
|
|
50
|
+
0%, 100% {
|
|
21
51
|
opacity: 1;
|
|
22
|
-
visibility: visible;
|
|
23
|
-
transition: opacity var(--interactive-transition-1);
|
|
24
52
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
opacity: 0.5;
|
|
53
|
+
50% {
|
|
54
|
+
opacity: var(--interactive-area-hover-opacity);
|
|
28
55
|
}
|
|
56
|
+
}
|
|
29
57
|
|
|
30
|
-
|
|
31
|
-
|
|
58
|
+
@keyframes interactive-blinking-button {
|
|
59
|
+
0%, 100% {
|
|
60
|
+
opacity: 1;
|
|
32
61
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
position: absolute;
|
|
36
|
-
top: 0;
|
|
37
|
-
left: 0;
|
|
38
|
-
font-family: inherit;
|
|
39
|
-
|
|
40
|
-
--interactive-transition-1: 100ms ease-in-out;
|
|
62
|
+
50% {
|
|
63
|
+
opacity: var(--interactive-button-hover-opacity);
|
|
41
64
|
}
|
|
65
|
+
}
|
|
42
66
|
|
|
43
|
-
|
|
67
|
+
/* blink-anim-reference */
|
|
68
|
+
.interactive-blink-anim-reference {
|
|
69
|
+
position: absolute;
|
|
70
|
+
height: 0;
|
|
71
|
+
width: 0;
|
|
72
|
+
top: 0;
|
|
73
|
+
left: 0;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
}
|
|
44
76
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
77
|
+
.interactive-blink-anim-reference-animation {
|
|
78
|
+
animation-duration: 2001ms;
|
|
79
|
+
animation-iteration-count: infinite;
|
|
80
|
+
animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
|
|
81
|
+
animation-name: interactive-blinking-button;
|
|
82
|
+
}
|
|
51
83
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
.interactive-blink-anim-reference-disabled {
|
|
85
|
+
animation: none;
|
|
86
|
+
}
|
|
55
87
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
`,Mo=r=>{let e=document.createElement("style");e.textContent=ah,r.prepend(e)};import{clientChecker as uh}from"@vkontakte/videoplayer-core/es2015";var jo=Object.freeze({lang:ch.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function ph(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var zt=class{constructor(e){this.playerSubscriptions=new an;this.subscriptions=new an;this.globalEventEmitter=new Ot;this.animation=new Pt;this.seekToInteractiveController=new We;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ph();this.factories=new Map([["choice",dt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new an;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 B,graphVisibilityChanged$:new B,watchAgainIsClicked$:new B,chapterChanged$:new B,playerChanged$:new B,error$:new B,eachTick$:new B,manifestChanged$:new B,interactiveRangeEnded$:new B,interactiveContainerRemoved$:new B,interactiveContainerFakeRemoved$:new B,interactiveActionExecution$:new B,interactiveActionChoice$:new B,interactiveVisibilityChanged$:new B};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(k.errors,e)};this.clearHistoryIfEnded=()=>{var i;let e=(i=this.player)==null?void 0:i.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&ee(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=Z(i,["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(n),this.globalEventEmitter.emit(k.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(s=>x(d({},s),{subjects:s.subjects.filter(o=>o.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n;this._options=x(d(d({},jo),e),{config:d(d({},jo.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new tt({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(n=this._options.projectInfo)==null?void 0:n.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Gt({parentElement:this._options.parentElement,onError:i=>{let s=new F(1,6,i);this.emitErrorEvent(s)}})),Mo(this._options.parentElement),this.subscriptions.add(Lo(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(Lo(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new Re(this._options.loaders,i=>{let s=new F(1,3,i);this.emitErrorEvent(s)});let t=[];this._options.lastFrame&&t.push(()=>{var i;(i=this.lastFrame)==null||i.updateCanvasDimensions(!0)}),t.push(()=>{let i=this.state.isInteractiveTime$.getValue();for(let s of this.gameControllers)s.onResize(i)}),this.resizeManager=Co(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new ze({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(k.graph,{type:Ze.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let s=new F(1,2,{message:i});this.emitErrorEvent(s)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>P(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))}))),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,n;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:i}=e.payload;this.setChapter({chapterId:i}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((n=e.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:i}=e.payload;i&&this.setManifest(i)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}initSeamless(){return P(this,null,function*(){this.seamlessController=Xr(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,i=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(k.interactives,{type:N.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(lh()).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(oh({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var a;let i;if(n)i=!0;else{let l=e*1e3;i=!!t.find(({range:[y,b],subjects:g})=>y<l&&l<b&&g.some(S=>!S.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,c=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!s&&c?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!c&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,n;(t=this.lastFrame)==null||t.hide(),(n=this.lastFrame)==null||n.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,n;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),(n=this.interactiveEvents)==null||n.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(i=>i.container.container).filter(i=>!Ae(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i),o=s==null?void 0:s(n,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let c=new qt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Bs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(c.whilePlaying,!0),t.push(c)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var c,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(c=n&&ee(n)&&$t(n))!=null?c:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(s||i&&t){this.historyController.updateHistory([e]);return}(0,$o.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,s=n.getValue().map(o=>{let c=o.subjects.some(l=>l.id===e),a=o.subjects.map(l=>t&&c||l.id===e?x(d({},l),{isRemoved:!0}):l);return x(d({},o),{subjects:a})});n.next(s)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),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 P(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(k.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=vo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Oo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return P(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,l;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&uh.browser.isSafari&&(yield Vo(35));let i=!n&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:s,media:o,graph:c}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&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),(l=this.lastFrame)==null||l.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:o}),this.globalEventEmitter.emit(k.chapterChanged,{chapter:s,media:o,graph:c}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new No(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?rt.GRAPH_SHOW:rt.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(rt.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(rt.NEXT_BUTTON),i==="Area"&&e.next(rt.NEXT_AREA))}))}),nextMovie$:new No(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){return P(this,null,function*(){this.graph&&(e?(yield this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(k.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 n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===V.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(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&he(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&At(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 Va((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,n,i,s;this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(i=this.interactiveEvents)==null||i.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var hh={Container:be,createChoiceContainer:dt,createAreaControl:ut,createButtonControl:ht,classnamesPrefix:En};var nb={version:Cn};export{Hm as ContainerTypes,Rt as ControlTypes,F as CustomError,k as EVENT_NAMES,V as EventActionTypes,Um as EventTypes,zt as Interactives,Re as ManifestController,nb as SDKInfo,rn as chapterIdsToVKVideoIds,Fr as compareVersions,$m as containerTypes,_m as controlTypes,Ls as eventActionTypes,Fm as eventTypes,nh as getChapterIdByVkVideoId,Po as getVKVideoIdByMedia,th as getVideoRawIdByMedia,Ze as graphEventTypes,$t as hasEndTemplate,N as interactivesEventTypes,jm as isAreaControl,Lm as isButtonControl,ee as isLastChapter,Ae as isOneTextCtrlContainer,At as isSupportedManifest,wt as isTextControl,rh as isVKVariantItem,Ns as isValidManifest,js as migrateManifestToLatestVersion,hh as utils,ko as vkVideoIdsToChapterIds};
|
|
88
|
+
/* interactive-chapter */
|
|
89
|
+
.interactive-chapter {
|
|
90
|
+
position: absolute;
|
|
91
|
+
top: 0;
|
|
92
|
+
left: 0;
|
|
93
|
+
font-family: inherit;
|
|
94
|
+
|
|
95
|
+
--interactive-transition-1: 100ms ease-in-out;
|
|
96
|
+
--interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
97
|
+
--interactive-button-hover-opacity: 0.8;
|
|
98
|
+
--interactive-area-hover-opacity: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* interactive-control */
|
|
102
|
+
.interactive-control {
|
|
103
|
+
display: flex;
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: 100%;
|
|
106
|
+
font-family: inherit;
|
|
107
|
+
|
|
108
|
+
position: relative;
|
|
109
|
+
isolation: isolate;
|
|
110
|
+
opacity: 1;
|
|
111
|
+
|
|
112
|
+
box-shadow: none;
|
|
113
|
+
border: none;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.interactive-control-disabled {
|
|
117
|
+
cursor: default;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.interactive-control-button
|
|
121
|
+
.interactive-control-area {
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.interactive-control-button {
|
|
126
|
+
transition: opacity var(--interactive-transition-2);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.interactive-control-area {
|
|
130
|
+
transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.interactive-container.interactive-container-disabled .interactive-control-button,
|
|
134
|
+
.interactive-container.interactive-container-disabled .interactive-control-area {
|
|
135
|
+
animation: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-button:not(.interactive-control-selected):not(.interactive-control-blink-anim):hover,
|
|
139
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-button:not(.interactive-control-selected):not(.interactive-control-blink-anim):focus-visible {
|
|
140
|
+
opacity: var(--interactive-button-hover-opacity);
|
|
141
|
+
animation: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-area:not(.interactive-control-selected):not(.interactive-control-blink-anim):hover,
|
|
145
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-area:not(.interactive-control-selected):not(.interactive-control-blink-anim):focus-visible {
|
|
146
|
+
opacity: var(--interactive-area-hover-opacity);
|
|
147
|
+
animation: none;
|
|
148
|
+
}
|
|
149
|
+
`;var Ga=r=>{let e=document.createElement("style");e.textContent=Ua,r.prepend(e)};import{clientChecker as Rh}from"@vkontakte/videoplayer-core/es2015";var Ka=Object.freeze({lang:wh.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function kh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var er=class{constructor(e){this.playerSubscriptions=new fn;this.subscriptions=new fn;this.globalEventEmitter=new $t;this.animation=new Ft;this.seekToInteractiveController=new Ye;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=kh();this.factories=new Map([["choice",Tt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new fn;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new U(null),isInitialChapter$:new U(!1),isFirstChapter$:new U(!0),isEndChapter$:new U(!1),isInteractiveExpectation$:new U(!1),isReplay$:new U(!1),calledByInteractive$:new U(!1),lastChapterChangeWasInitiatedByInteractive$:new U(!1),disabledControls$:new U(!1),interactiveRanges$:new U([]),isInteractiveTime$:new U(!1),statistics$:new U(null),isSeekable$:new U(!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,interactiveContainerFakeRemoved$:new D,interactiveActionExecution$:new D,interactiveActionChoice$:new D,interactiveVisibilityChanged$:new D};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(k.errors,e)};this.clearHistoryIfEnded=()=>{var i;let e=(i=this.player)==null?void 0:i.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&re(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=Z(i,["statistics"]);if(t){let{statSubscription:o,oneStat:s}=t;o.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(k.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(o=>x(d({},o),{subjects:o.subjects.filter(s=>s.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var i,o;if(this._options=x(d(d({},Ka),e),{config:d(d({},Ka.config),e.config)}),(i=this._options.animationsFeatureToggles)==null?void 0:i.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new bt,this.blinkAnimationRef.create();let s=this.blinkAnimationRef.element;s&&this.rootElement.append(s)}this._options.parentElement.append(this.rootElement),this.historyController=new at({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Jt({parentElement:this._options.parentElement,onError:s=>{let l=new N(1,6,s);this.emitErrorEvent(l)}})),Ga(this._options.parentElement),this.subscriptions.add(Wa(this.rootElement,"mousedown").subscribe(s=>s.stopPropagation())).add(Wa(this.rootElement,"mouseup").subscribe(s=>s.stopPropagation())),this.manifestController=new ke(this._options.loaders,s=>{let l=new N(1,3,s);this.emitErrorEvent(l)});let n=[];this._options.lastFrame&&n.push(()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}),n.push(()=>{let s=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(s)}),this.resizeManager=Va(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Xe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(k.graph,{type:nt.watchAgainClicked,chapterId:s}),this.events.watchAgainIsClicked$.next(s)},onError:s=>{let l=new N(1,2,{message:s});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>R(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))}))),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,n;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:i}=e.payload;this.setChapter({chapterId:i}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((n=e.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:i}=e.payload;i&&this.setManifest(i)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}initSeamless(){return R(this,null,function*(){this.seamlessController=on(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,i=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(i){let o=i.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(k.interactives,{type:j.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.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(Sh({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var a;let i;if(n)i=!0;else{let c=e*1e3;i=!!t.find(({range:[v,y],subjects:g})=>v<c&&c<y&&g.some(w=>!w.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let o=!!this.noInteractionTimeout,l=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!o&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,n;(t=this.lastFrame)==null||t.hide(),(n=this.lastFrame)==null||n.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,n;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),(n=this.interactiveEvents)==null||n.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(i=>i.container.container).filter(i=>!Re(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{var l;let i=n.type.trim().toLowerCase(),o=this.factories.get(i),s=o==null?void 0:o(n,this.rootElement,{features:{controlsExpectTimeBlinkAnimation:(l=this._options.animationsFeatureToggles)==null?void 0:l.controlsExpectTimeBlinkAnimation}});if(s&&this.selectBranches&&this.interactiveEvents&&this.player){let a=new Kt({player:this.player,container:s,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ps(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent});this.animation.addFn(a.whilePlaying,!0),t.push(a)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&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(),n=this.state.prevChapter$.getValue(),i=(l=n&&re(n)&&Gt(n))!=null?l:!1,o=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,s=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,Qa.default)(s,-1)!==e&&this.historyController.updateHistory([...s,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(s=>{let l=s.subjects.some(c=>c.id===e),a=s.subjects.map(c=>t&&l||c.id===e?x(d({},c),{isRemoved:!0}):c);return x(d({},s),{subjects:a})});n.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var n,i;if(!((n=this._options.animationsFeatureToggles)!=null&&n.controlsExpectTimeBlinkAnimation))return;let t=(o,s)=>{o.toggleBlinkAnimation(s)};zt(x(d({},e),{gameControllers:this.gameControllers,execFn:it(sn(t),e.isExpect)})),e.isExpect&&((i=this.blinkAnimationRef)==null||i.restart())}updateControlsShadowStyles(e){var n;if(!((n=this._options.animationsFeatureToggles)!=null&&n.areaControlShadow))return;let t=(i,o)=>{i.updateControlsShadowStyles(o)};e.isExpect?zt(x(d({},e),{gameControllers:this.gameControllers,execFn:it(sn(t),!1)})):zt(x(d({},e),{gameControllers:this.gameControllers,execFn:t}))}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 R(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(k.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=ka(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Ba({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return R(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Rh.browser.isSafari&&(yield Ha(35));let i=!n&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:o,media:s,graph:l}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!s)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:s}),this.globalEventEmitter.emit(k.chapterChanged,{chapter:o,media:s,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new za(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?lt.GRAPH_SHOW:lt.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(lt.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(lt.NEXT_BUTTON),i==="Area"&&e.next(lt.NEXT_AREA))}))}),nextMovie$:new za(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){return R(this,null,function*(){this.graph&&(e?(yield this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(k.graph,{type:nt.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 n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===P.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(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&me(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&Lt(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 zs((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,n,i,o,s;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(n=this.seamlessController)==null||n.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.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:ge,createChoiceContainer:Tt,createAreaControl:gt,createButtonControl:xt,classnamesPrefix:Pn};var Ub={version:kn};export{Of as ContainerTypes,jt as ControlTypes,N as CustomError,k as EVENT_NAMES,P as EventActionTypes,Pf as EventTypes,er as Interactives,ke as ManifestController,Ub as SDKInfo,hn as chapterIdsToVKVideoIds,Wr as compareVersions,Tf as containerTypes,Sf as controlTypes,Ko as eventActionTypes,wf as eventTypes,Ih as getChapterIdByVkVideoId,qa as getVKVideoIdByMedia,gh as getVideoRawIdByMedia,nt as graphEventTypes,Gt as hasEndTemplate,j as interactivesEventTypes,xf as isAreaControl,If as isButtonControl,re as isLastChapter,Re as isOneTextCtrlContainer,Lt as isSupportedManifest,Nt as isTextControl,Eh as isVKVariantItem,Wo as isValidManifest,Qo as migrateManifestToLatestVersion,Oh as utils,Da as vkVideoIdsToChapterIds};
|