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