@vkontakte/videoplayer-interactive 1.0.37-beta.2 → 1.0.37-dev.09adc98d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -41
- package/es2015.esm.js +6 -41
- package/es2018.cjs.js +6 -41
- package/es2018.esm.js +6 -41
- package/es2024.cjs.js +6 -41
- package/es2024.esm.js +6 -41
- package/esnext.cjs.js +6 -41
- package/esnext.esm.js +6 -41
- package/evergreen.esm.js +6 -41
- package/package.json +4 -4
- package/types/modules/Interactives/Interactives.d.ts +1 -0
- package/types/modules/Interactives/Layout.d.ts +4 -2
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +4 -2
- package/types/modules/Interactives/containers/Container.d.ts +3 -1
- package/types/modules/Interactives/containers/types.d.ts +1 -2
- package/types/modules/Interactives/controls/AreaControl.d.ts +2 -2
- package/types/modules/Interactives/controls/ButtonControl.d.ts +2 -2
- package/types/modules/Interactives/controls/Control.d.ts +5 -8
- package/types/modules/Interactives/controls/types.d.ts +2 -4
- package/types/modules/Interactives/controls/utils.d.ts +0 -1
- package/types/modules/Interactives/index.d.ts +3 -67
- package/types/modules/Interactives/types.d.ts +0 -2
- package/types/modules/Interactives/utils/ResizeManager.d.ts +2 -0
- package/types/utils/CssVarsManager.d.ts +23 -0
- package/types/modules/Interactives/utils/ControlTap/ControlTap.d.ts +0 -17
- package/types/modules/Interactives/utils/ControlTap/index.d.ts +0 -1
- package/types/modules/Interactives/utils/ControlTap/utils.d.ts +0 -6
- package/types/modules/Interactives/utils/angleUtils.d.ts +0 -2
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.37-
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.37-dev.09adc98d.0
|
|
3
|
+
* Tue, 03 Jun 2025 07:21:50 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-37/doc/
|
|
5
5
|
*/
|
|
6
|
-
var rl=Object.create;var rr=Object.defineProperty,nl=Object.defineProperties,il=Object.getOwnPropertyDescriptor,ol=Object.getOwnPropertyDescriptors,al=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,sl=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty,On=Object.prototype.propertyIsEnumerable;var Pn=r=>{throw TypeError(r)};var kn=(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)&&kn(r,t,e[t]);if(ct)for(var t of ct(e))On.call(e,t)&&kn(r,t,e[t]);return r},x=(r,e)=>nl(r,ol(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&&ct)for(var n of ct(r))e.indexOf(n)<0&&On.call(r,n)&&(t[n]=r[n]);return t};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ll=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of al(e))!nr.call(r,i)&&i!==t&&rr(r,i,{get:()=>e[i],enumerable:!(n=il(e,i))||n.enumerable});return r};var J=(r,e,t)=>(t=r!=null?rl(sl(r)):{},ll(e||!r||!r.__esModule?rr(t,"default",{value:r,enumerable:!0}):t,r));var Vn=(r,e,t)=>e.has(r)||Pn("Cannot "+t);var A=(r,e,t)=>(Vn(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?Pn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,n)=>(Vn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Mn=(r,e,t,n)=>({set _(i){j(r,e,i,t)},get _(){return A(r,e,n)}});var R=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{l(t.next(s))}catch(c){i(c)}},a=s=>{try{l(t.throw(s))}catch(c){i(c)}},l=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);l((t=t.apply(r,e)).next())});var te=h((Cr,Gn)=>{"use strict";var je=function(r){return r&&r.Math===Math&&r};Gn.exports=je(typeof globalThis=="object"&&globalThis)||je(typeof window=="object"&&window)||je(typeof self=="object"&&self)||je(typeof global=="object"&&global)||je(typeof Cr=="object"&&Cr)||function(){return this}()||Function("return this")()});var z=h((cm,zn)=>{"use strict";zn.exports=function(r){try{return!!r()}catch(e){return!0}}});var $e=h((um,Wn)=>{"use strict";var bl=z();Wn.exports=!bl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Zn=h((pm,Yn)=>{"use strict";var Cl=$e(),Xn=Function.prototype,Kn=Xn.apply,Qn=Xn.call;Yn.exports=typeof Reflect=="object"&&Reflect.apply||(Cl?Qn.bind(Kn):function(){return Qn.apply(Kn,arguments)})});var Q=h((hm,ti)=>{"use strict";var Jn=$e(),ei=Function.prototype,gr=ei.call,gl=Jn&&ei.bind.bind(gr,gr);ti.exports=Jn?gl:function(r){return function(){return gr.apply(r,arguments)}}});var Fe=h((dm,ni)=>{"use strict";var ri=Q(),El=ri({}.toString),Il=ri("".slice);ni.exports=function(r){return Il(El(r),8,-1)}});var Er=h((mm,ii)=>{"use strict";var xl=Fe(),Tl=Q();ii.exports=function(r){if(xl(r)==="Function")return Tl(r)}});var W=h((fm,oi)=>{"use strict";var Ir=typeof document=="object"&&document.all;oi.exports=typeof Ir=="undefined"&&Ir!==void 0?function(r){return typeof r=="function"||r===Ir}:function(r){return typeof r=="function"}});var de=h((vm,ai)=>{"use strict";var Sl=z();ai.exports=!Sl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var wt=h((ym,si)=>{"use strict";var wl=$e(),St=Function.prototype.call;si.exports=wl?St.bind(St):function(){return St.apply(St,arguments)}});var xr=h(ui=>{"use strict";var li={}.propertyIsEnumerable,ci=Object.getOwnPropertyDescriptor,Al=ci&&!li.call({1:2},1);ui.f=Al?function(e){var t=ci(this,e);return!!t&&t.enumerable}:li});var Tr=h((Cm,pi)=>{"use strict";pi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var di=h((gm,hi)=>{"use strict";var Rl=Q(),kl=z(),Ol=Fe(),Sr=Object,Pl=Rl("".split);hi.exports=kl(function(){return!Sr("z").propertyIsEnumerable(0)})?function(r){return Ol(r)==="String"?Pl(r,""):Sr(r)}:Sr});var wr=h((Em,mi)=>{"use strict";mi.exports=function(r){return r==null}});var Ar=h((Im,fi)=>{"use strict";var Vl=wr(),Ml=TypeError;fi.exports=function(r){if(Vl(r))throw new Ml("Can't call method on "+r);return r}});var Be=h((xm,vi)=>{"use strict";var Ll=di(),Nl=Ar();vi.exports=function(r){return Ll(Nl(r))}});var xe=h((Tm,yi)=>{"use strict";var _l=W();yi.exports=function(r){return typeof r=="object"?r!==null:_l(r)}});var At=h((Sm,bi)=>{"use strict";bi.exports={}});var Rt=h((wm,gi)=>{"use strict";var Rr=At(),kr=te(),jl=W(),Ci=function(r){return jl(r)?r:void 0};gi.exports=function(r,e){return arguments.length<2?Ci(Rr[r])||Ci(kr[r]):Rr[r]&&Rr[r][e]||kr[r]&&kr[r][e]}});var Ii=h((Am,Ei)=>{"use strict";var $l=Q();Ei.exports=$l({}.isPrototypeOf)});var wi=h((Rm,Si)=>{"use strict";var Fl=te(),xi=Fl.navigator,Ti=xi&&xi.userAgent;Si.exports=Ti?String(Ti):""});var Mi=h((km,Vi)=>{"use strict";var Pi=te(),Or=wi(),Ai=Pi.process,Ri=Pi.Deno,ki=Ai&&Ai.versions||Ri&&Ri.version,Oi=ki&&ki.v8,X,kt;Oi&&(X=Oi.split("."),kt=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!kt&&Or&&(X=Or.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=Or.match(/Chrome\/(\d+)/),X&&(kt=+X[1])));Vi.exports=kt});var Pr=h((Om,Ni)=>{"use strict";var Li=Mi(),Bl=z(),ql=te(),Dl=ql.String;Ni.exports=!!Object.getOwnPropertySymbols&&!Bl(function(){var r=Symbol("symbol detection");return!Dl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Li&&Li<41})});var Vr=h((Pm,_i)=>{"use strict";var Hl=Pr();_i.exports=Hl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Mr=h((Vm,ji)=>{"use strict";var Ul=Rt(),Gl=W(),zl=Ii(),Wl=Vr(),Kl=Object;ji.exports=Wl?function(r){return typeof r=="symbol"}:function(r){var e=Ul("Symbol");return Gl(e)&&zl(e.prototype,Kl(r))}});var Fi=h((Mm,$i)=>{"use strict";var Ql=String;$i.exports=function(r){try{return Ql(r)}catch(e){return"Object"}}});var Lr=h((Lm,Bi)=>{"use strict";var Xl=W(),Yl=Fi(),Zl=TypeError;Bi.exports=function(r){if(Xl(r))return r;throw new Zl(Yl(r)+" is not a function")}});var Di=h((Nm,qi)=>{"use strict";var Jl=Lr(),ec=wr();qi.exports=function(r,e){var t=r[e];return ec(t)?void 0:Jl(t)}});var Ui=h((_m,Hi)=>{"use strict";var Nr=wt(),_r=W(),jr=xe(),tc=TypeError;Hi.exports=function(r,e){var t,n;if(e==="string"&&_r(t=r.toString)&&!jr(n=Nr(t,r))||_r(t=r.valueOf)&&!jr(n=Nr(t,r))||e!=="string"&&_r(t=r.toString)&&!jr(n=Nr(t,r)))return n;throw new tc("Can't convert object to primitive value")}});var zi=h((jm,Gi)=>{"use strict";Gi.exports=!0});var Qi=h(($m,Ki)=>{"use strict";var Wi=te(),rc=Object.defineProperty;Ki.exports=function(r,e){try{rc(Wi,r,{value:e,configurable:!0,writable:!0})}catch(t){Wi[r]=e}return e}});var Ot=h((Fm,Zi)=>{"use strict";var nc=zi(),ic=te(),oc=Qi(),Xi="__core-js_shared__",Yi=Zi.exports=ic[Xi]||oc(Xi,{});(Yi.versions||(Yi.versions=[])).push({version:"3.38.0",mode:nc?"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=h((Bm,eo)=>{"use strict";var Ji=Ot();eo.exports=function(r,e){return Ji[r]||(Ji[r]=e||{})}});var qe=h((qm,to)=>{"use strict";var ac=Ar(),sc=Object;to.exports=function(r){return sc(ac(r))}});var Te=h((Dm,ro)=>{"use strict";var lc=Q(),cc=qe(),uc=lc({}.hasOwnProperty);ro.exports=Object.hasOwn||function(e,t){return uc(cc(e),t)}});var Fr=h((Hm,no)=>{"use strict";var pc=Q(),hc=0,dc=Math.random(),mc=pc(1 .toString);no.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+mc(++hc+dc,36)}});var De=h((Um,oo)=>{"use strict";var fc=te(),vc=$r(),io=Te(),yc=Fr(),bc=Pr(),Cc=Vr(),Se=fc.Symbol,Br=vc("wks"),gc=Cc?Se.for||Se:Se&&Se.withoutSetter||yc;oo.exports=function(r){return io(Br,r)||(Br[r]=bc&&io(Se,r)?Se[r]:gc("Symbol."+r)),Br[r]}});var co=h((Gm,lo)=>{"use strict";var Ec=wt(),ao=xe(),so=Mr(),Ic=Di(),xc=Ui(),Tc=De(),Sc=TypeError,wc=Tc("toPrimitive");lo.exports=function(r,e){if(!ao(r)||so(r))return r;var t=Ic(r,wc),n;if(t){if(e===void 0&&(e="default"),n=Ec(t,r,e),!ao(n)||so(n))return n;throw new Sc("Can't convert object to primitive value")}return e===void 0&&(e="number"),xc(r,e)}});var qr=h((zm,uo)=>{"use strict";var Ac=co(),Rc=Mr();uo.exports=function(r){var e=Ac(r,"string");return Rc(e)?e:e+""}});var mo=h((Wm,ho)=>{"use strict";var kc=te(),po=xe(),Dr=kc.document,Oc=po(Dr)&&po(Dr.createElement);ho.exports=function(r){return Oc?Dr.createElement(r):{}}});var Hr=h((Km,fo)=>{"use strict";var Pc=de(),Vc=z(),Mc=mo();fo.exports=!Pc&&!Vc(function(){return Object.defineProperty(Mc("div"),"a",{get:function(){return 7}}).a!==7})});var bo=h(yo=>{"use strict";var Lc=de(),Nc=wt(),_c=xr(),jc=Tr(),$c=Be(),Fc=qr(),Bc=Te(),qc=Hr(),vo=Object.getOwnPropertyDescriptor;yo.f=Lc?vo:function(e,t){if(e=$c(e),t=Fc(t),qc)try{return vo(e,t)}catch(n){}if(Bc(e,t))return jc(!Nc(_c.f,e,t),e[t])}});var go=h((Xm,Co)=>{"use strict";var Dc=z(),Hc=W(),Uc=/#|\.prototype\./,He=function(r,e){var t=zc[Gc(r)];return t===Kc?!0:t===Wc?!1:Hc(e)?Dc(e):!!e},Gc=He.normalize=function(r){return String(r).replace(Uc,".").toLowerCase()},zc=He.data={},Wc=He.NATIVE="N",Kc=He.POLYFILL="P";Co.exports=He});var Ur=h((Ym,Io)=>{"use strict";var Eo=Er(),Qc=Lr(),Xc=$e(),Yc=Eo(Eo.bind);Io.exports=function(r,e){return Qc(r),e===void 0?r:Xc?Yc(r,e):function(){return r.apply(e,arguments)}}});var To=h((Zm,xo)=>{"use strict";var Zc=de(),Jc=z();xo.exports=Zc&&Jc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var wo=h((Jm,So)=>{"use strict";var eu=xe(),tu=String,ru=TypeError;So.exports=function(r){if(eu(r))return r;throw new ru(tu(r)+" is not an object")}});var ko=h(Ro=>{"use strict";var nu=de(),iu=Hr(),ou=To(),Pt=wo(),Ao=qr(),au=TypeError,Gr=Object.defineProperty,su=Object.getOwnPropertyDescriptor,zr="enumerable",Wr="configurable",Kr="writable";Ro.f=nu?ou?function(e,t,n){if(Pt(e),t=Ao(t),Pt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Kr in n&&!n[Kr]){var i=su(e,t);i&&i[Kr]&&(e[t]=n.value,n={configurable:Wr in n?n[Wr]:i[Wr],enumerable:zr in n?n[zr]:i[zr],writable:!1})}return Gr(e,t,n)}:Gr:function(e,t,n){if(Pt(e),t=Ao(t),Pt(n),iu)try{return Gr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new au("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Po=h((tf,Oo)=>{"use strict";var lu=de(),cu=ko(),uu=Tr();Oo.exports=lu?function(r,e,t){return cu.f(r,e,uu(1,t))}:function(r,e,t){return r[e]=t,r}});var Ge=h((rf,Mo)=>{"use strict";var Ue=te(),pu=Zn(),hu=Er(),du=W(),mu=bo().f,fu=go(),we=At(),vu=Ur(),Ae=Po(),Vo=Te();Ot();var yu=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 pu(r,this,arguments)};return e.prototype=r.prototype,e};Mo.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,a=n?Ue:i?Ue[t]:Ue[t]&&Ue[t].prototype,l=n?we:we[t]||Ae(we,t,{})[t],s=l.prototype,c,m,v,y,g,w,E,f,u;for(y in e)c=fu(n?y:t+(i?".":"#")+y,r.forced),m=!c&&a&&Vo(a,y),w=l[y],m&&(r.dontCallGetSet?(u=mu(a,y),E=u&&u.value):E=a[y]),g=m&&E?E:e[y],!(!c&&!o&&typeof w==typeof g)&&(r.bind&&m?f=vu(g,Ue):r.wrap&&m?f=yu(g):o&&du(g)?f=hu(g):f=g,(r.sham||g&&g.sham||w&&w.sham)&&Ae(f,"sham",!0),Ae(l,y,f),o&&(v=t+"Prototype",Vo(we,v)||Ae(we,v,{}),Ae(we[v],y,g),r.real&&s&&(c||!s[y])&&Ae(s,y,g)))}});var No=h((nf,Lo)=>{"use strict";var bu=Math.ceil,Cu=Math.floor;Lo.exports=Math.trunc||function(e){var t=+e;return(t>0?Cu:bu)(t)}});var ze=h((of,_o)=>{"use strict";var gu=No();_o.exports=function(r){var e=+r;return e!==e||e===0?0:gu(e)}});var $o=h((af,jo)=>{"use strict";var Eu=ze(),Iu=Math.min;jo.exports=function(r){var e=Eu(r);return e>0?Iu(e,9007199254740991):0}});var We=h((sf,Fo)=>{"use strict";var xu=$o();Fo.exports=function(r){return xu(r.length)}});var Vt=h((lf,Bo)=>{"use strict";Bo.exports=function(){}});var qo=h(()=>{"use strict";var Tu=Ge(),Su=qe(),wu=We(),Au=ze(),Ru=Vt();Tu({target:"Array",proto:!0},{at:function(e){var t=Su(this),n=wu(t),i=Au(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Ru("at")});var Mt=h((pf,Do)=>{"use strict";var ku=Rt();Do.exports=ku});var Uo=h((hf,Ho)=>{"use strict";qo();var Ou=Mt();Ho.exports=Ou("Array","at")});var zo=h((df,Go)=>{"use strict";var Pu=Uo();Go.exports=Pu});var Qr=h((mf,Wo)=>{"use strict";var Vu=zo();Wo.exports=Vu});var ia=h((dv,na)=>{"use strict";var qu=ze(),Du=Math.max,Hu=Math.min;na.exports=function(r,e){var t=qu(r);return t<0?Du(t+e,0):Hu(t,e)}});var tn=h((mv,aa)=>{"use strict";var Uu=Be(),Gu=ia(),zu=We(),oa=function(r){return function(e,t,n){var i=Uu(e),o=zu(i);if(o===0)return!r&&-1;var a=Gu(n,o),l;if(r&&t!==t){for(;o>a;)if(l=i[a++],l!==l)return!0}else for(;o>a;a++)if((r||a in i)&&i[a]===t)return r||a||0;return!r&&-1}};aa.exports={includes:oa(!0),indexOf:oa(!1)}});var sa=h(()=>{"use strict";var Wu=Ge(),Ku=tn().includes,Qu=z(),Xu=Vt(),Yu=Qu(function(){return!Array(1).includes()});Wu({target:"Array",proto:!0,forced:Yu},{includes:function(e){return Ku(this,e,arguments.length>1?arguments[1]:void 0)}});Xu("includes")});var ca=h((yv,la)=>{"use strict";sa();var Zu=Mt();la.exports=Zu("Array","includes")});var pa=h((bv,ua)=>{"use strict";var Ju=ca();ua.exports=Ju});var et=h((Cv,ha)=>{"use strict";var ep=pa();ha.exports=ep});var Ca=h((Pv,ba)=>{"use strict";var np=$r(),ip=Fr(),ya=np("keys");ba.exports=function(r){return ya[r]||(ya[r]=ip(r))}});var Ea=h((Vv,ga)=>{"use strict";var op=z();ga.exports=!op(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ta=h((Mv,xa)=>{"use strict";var ap=Te(),sp=W(),lp=qe(),cp=Ca(),up=Ea(),Ia=cp("IE_PROTO"),on=Object,pp=on.prototype;xa.exports=up?on.getPrototypeOf:function(r){var e=lp(r);if(ap(e,Ia))return e[Ia];var t=e.constructor;return sp(t)&&e instanceof t?t.prototype:e instanceof on?pp:null}});var wa=h((Lv,Sa)=>{"use strict";Sa.exports={}});var ka=h((Nv,Ra)=>{"use strict";var hp=Q(),an=Te(),dp=Be(),mp=tn().indexOf,fp=wa(),Aa=hp([].push);Ra.exports=function(r,e){var t=dp(r),n=0,i=[],o;for(o in t)!an(fp,o)&&an(t,o)&&Aa(i,o);for(;e.length>n;)an(t,o=e[n++])&&(~mp(i,o)||Aa(i,o));return i}});var Pa=h((_v,Oa)=>{"use strict";Oa.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ma=h((jv,Va)=>{"use strict";var vp=ka(),yp=Pa();Va.exports=Object.keys||function(e){return vp(e,yp)}});var Fa=h(($v,$a)=>{"use strict";var Na=de(),bp=z(),_a=Q(),Cp=Ta(),gp=Ma(),Ep=Be(),Ip=xr().f,ja=_a(Ip),xp=_a([].push),Tp=Na&&bp(function(){var r=Object.create(null);return r[2]=2,!ja(r,2)}),La=function(r){return function(e){for(var t=Ep(e),n=gp(t),i=Tp&&Cp(t)===null,o=n.length,a=0,l=[],s;o>a;)s=n[a++],(!Na||(i?s in t:ja(t,s)))&&xp(l,r?[s,t[s]]:t[s]);return l}};$a.exports={entries:La(!0),values:La(!1)}});var Ba=h(()=>{"use strict";var Sp=Ge(),wp=Fa().values;Sp({target:"Object",stat:!0},{values:function(e){return wp(e)}})});var Da=h((qv,qa)=>{"use strict";Ba();var Ap=At();qa.exports=Ap.Object.values});var Ua=h((Dv,Ha)=>{"use strict";var Rp=Da();Ha.exports=Rp});var Wt=h((Hv,Ga)=>{"use strict";var kp=Ua();Ga.exports=kp});var hn=h((yy,Za)=>{"use strict";var Np=Fe();Za.exports=Array.isArray||function(e){return Np(e)==="Array"}});var es=h((by,Ja)=>{"use strict";var _p=TypeError,jp=9007199254740991;Ja.exports=function(r){if(r>jp)throw _p("Maximum allowed index exceeded");return r}});var ns=h((Cy,rs)=>{"use strict";var $p=hn(),Fp=We(),Bp=es(),qp=Ur(),ts=function(r,e,t,n,i,o,a,l){for(var s=i,c=0,m=a?qp(a,l):!1,v,y;c<n;)c in t&&(v=m?m(t[c],c,e):t[c],o>0&&$p(v)?(y=Fp(v),s=ts(r,e,v,y,s,o-1)-1):(Bp(s+1),r[s]=v),s++),c++;return s};rs.exports=ts});var as=h((gy,os)=>{"use strict";var Dp=De(),Hp=Dp("toStringTag"),is={};is[Hp]="z";os.exports=String(is)==="[object z]"});var ls=h((Ey,ss)=>{"use strict";var Up=as(),Gp=W(),Qt=Fe(),zp=De(),Wp=zp("toStringTag"),Kp=Object,Qp=Qt(function(){return arguments}())==="Arguments",Xp=function(r,e){try{return r[e]}catch(t){}};ss.exports=Up?Qt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Xp(e=Kp(r),Wp))=="string"?t:Qp?Qt(e):(n=Qt(e))==="Object"&&Gp(e.callee)?"Arguments":n}});var us=h((Iy,cs)=>{"use strict";var Yp=Q(),Zp=W(),dn=Ot(),Jp=Yp(Function.toString);Zp(dn.inspectSource)||(dn.inspectSource=function(r){return Jp(r)});cs.exports=dn.inspectSource});var vs=h((xy,fs)=>{"use strict";var eh=Q(),th=z(),ps=W(),rh=ls(),nh=Rt(),ih=us(),hs=function(){},ds=nh("Reflect","construct"),mn=/^\s*(?:class|function)\b/,oh=eh(mn.exec),ah=!mn.test(hs),it=function(e){if(!ps(e))return!1;try{return ds(hs,[],e),!0}catch(t){return!1}},ms=function(e){if(!ps(e))return!1;switch(rh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ah||!!oh(mn,ih(e))}catch(t){return!0}};ms.sham=!0;fs.exports=!ds||th(function(){var r;return it(it.call)||!it(Object)||!it(function(){r=!0})||r})?ms:it});var gs=h((Ty,Cs)=>{"use strict";var ys=hn(),sh=vs(),lh=xe(),ch=De(),uh=ch("species"),bs=Array;Cs.exports=function(r){var e;return ys(r)&&(e=r.constructor,sh(e)&&(e===bs||ys(e.prototype))?e=void 0:lh(e)&&(e=e[uh],e===null&&(e=void 0))),e===void 0?bs:e}});var Is=h((Sy,Es)=>{"use strict";var ph=gs();Es.exports=function(r,e){return new(ph(r))(e===0?0:e)}});var xs=h(()=>{"use strict";var hh=Ge(),dh=ns(),mh=qe(),fh=We(),vh=ze(),yh=Is();hh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=mh(this),n=fh(t),i=yh(t,0);return i.length=dh(i,t,t,n,0,e===void 0?1:vh(e)),i}})});var Ts=h(()=>{"use strict";var bh=Vt();bh("flat")});var ws=h((Oy,Ss)=>{"use strict";xs();Ts();var Ch=Mt();Ss.exports=Ch("Array","flat")});var Rs=h((Py,As)=>{"use strict";var gh=ws();As.exports=gh});var Os=h((Vy,ks)=>{"use strict";var Eh=Rs();ks.exports=Eh});var Ln="1.0.37-beta.2";import{Subject as vl,Subscription as yl}from"@vkontakte/videoplayer-shared/es2015";var ir=class{constructor(e){this.layout=e}},ut=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} + ${2e-4}))`,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 Nn(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&&Nn(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 a=o(n,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as Ct,once as ml}from"@vkontakte/videoplayer-shared/es2015";var le=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ce=r=>le(r,"Object"),pt=r=>le(r,"String"),ht=r=>le(r,"Array"),dt=r=>le(r,"Number"),_n=r=>le(r,"Function"),jn=r=>le(r,"Boolean"),or=r=>dt(r)&&!isNaN(r);var pe=r=>ce(r)&&Object.keys(r).length===0,ar=r=>ht(r)&&!r.length;var Le=(r,e)=>pt(r)&&(e?r.trim():r).length;function Ne(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 $n="interactive",N={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},Fn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Fn||{}),Bn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Bn||{}),qn=(n=>(n.start="left",n.end="right",n.center="center",n))(qn||{}),mt=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Fn[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&Bn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&qn[e.alignment])!=null?i:"center"},ft=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,o,a,l,s,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=(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},vt=({target:r,props:e,fallback:t})=>{var n,i,o,a;r.style.backgroundColor=Ne((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i: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:n,useRawValues:i=!1})=>{var l,s,c,m,v,y,g,w,E,f,u;let o=i?t.borderWidthRawValue:`calc(${n.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=i?t.roundCornersRawValue:`calc(${n.height} * ${(v=(m=e==null?void 0:e.shape)==null?void 0:m.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Ne(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=(f=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:f.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=a},Dn=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let a=Ne(n.shadowColorLight,n.shadowColorAlpha),l=Ne(n.shadowColorDark,n.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,m=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=m},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 ur,Subject as pl,Subscription as hl,ValueSubject as dl}from"@vkontakte/videoplayer-shared/es2015";var sr="interactive-control-tap",Ie={common:sr,animation:`${sr}-animation`,visible:`${sr}-visible`};var cl=60,yt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:n=cl,useDimensionsBasedSize:i=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let n=t.getBoundingClientRect(),i={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(i.width,i.height),a=n.left+n.width/2,l=n.top+n.height/2,s=e.clientX-a,c=e.clientY-l,m=ul(s,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=m.x+n.width/2-o/2+"px",this.element.style.top=m.y+n.height/2-o/2+"px",this.element.classList.add(Ie.visible,Ie.animation)};this.onAnimationEnd=e=>{!e.target||!e.currentTarget||e.target===e.currentTarget&&this.element.classList.remove(Ie.visible,Ie.animation)};let o=document.createElement("div");o.classList.add(Ie.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=n,this.useDimensionsBasedSize=i}};function ul(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var lr="int",he=(n=>(n.AREA=`${lr}_area`,n.TEXT=`${lr}_text`,n.BUTTON=`${lr}_bttn`,n))(he||{});function cr(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`},Hn=40;var F=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ue=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new hl;this.error$=new pl;this.isInteracted$=new dl(!1)}onError(e="",t){let n=new F(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let n=(t=this.control.layoutParams.angle)!=null?t:N.angle;this.controlTap=new yt({controlRotateAngleRad:n,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Hn:void 0}),this.subscriptions.add(ur(e,"click").subscribe(this.controlTap.onElementClick,i=>this.onError("Control click tap animation error",i))).add(ur(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,i=>this.onError("Tap animationend error",i))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(V.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:N.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},i=()=>{var a,l;return(l=(a=e.isContainerDisabled)==null?void 0:a.call(e))!=null?l:!1};this.container={element:t,dimensions:n,isManifestContainerDisabled:i}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted$.next(!0),e()}}featureIsEnabled(e){return this.options&&cr(this.options)&&this.options.features[e]}isTouch(){return this.options&&cr(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(ur(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>this.onError("Error happened on control interaction",i)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var dr="interactive-blink-anim-reference",B={common:dr,animation:`${dr}-animation`,disabled:`${dr}-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 mr="interactive-container",q={common:mr,hidden:`${mr}-hidden`,disabled:`${mr}-disabled`};var gt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new fr(r,e)},fr=class extends ue{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",he.AREA),vt({target:n,props:this.control.props,fallback:x(d({},N),{backgroundColor:"transparent"})}),Ee({target:n,layoutParams:this.control.layoutParams,fallback:N}),this.addControlTap(n),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(jn(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Dn({target:this.controlElement,props:this.control.props,fallback:N,isDark:e,baseDimension:o}),_e({target:this.controlElement,props:this.control.props,fallback:x(d({},N),{borderColor:e?N.shadowColorDark:N.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:N.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else _e({target:this.controlElement,props:this.control.props,fallback:x(d({},N),{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(ml()).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)})}onProgress(){}onResize(){}};import{fromEvent as It,once as fl}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 vr(r,e)},vr=class extends ue{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;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",he.BUTTON),Ee({target:n,layoutParams:this.control.layoutParams,fallback:N}),vt({target:n,props:this.control.props,fallback:N}),_e({target:n,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),mt({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=Et(this.control.type.trim().toLowerCase()),o=(a=i.firstElementChild)!=null?a:i;ft({target:o,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),this.addControlTap(n),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(fl()).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)})}onProgress(){}onResize(){}updateShadowStyles(){}};var Un=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new yr(r,e)},yr=class extends ue{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(V.common,V.text),n.setAttribute("data-testid",he.TEXT),Ee({target:n,layoutParams:this.control.layoutParams,fallback:N}),mt({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=Et(this.control.type.trim().toLowerCase()),o=(a=i.firstElementChild)!=null?a:i;ft({target:o,props:this.control.props,fallback:N,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 br(r,e,t)},br=class extends ge{constructor(t,n,i){super(t,i);this.containerElement=null;this.controlSubscriptions=new yl;this.error$=new vl;this.rootElement=n,this.layout=new ut(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",xt),this.addControlFactory("text",Un),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,isContainerDisabled:()=>this.isDisabled}}),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 el=J(Qr(),1);import{combine as Mh,InterfaceLanguage as Lh,Observable as Ys,once as Nh,Subject as D,Subscription as gn,ValueSubject as U,fromEvent as Zs}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as st}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Mu}from"@vkontakte/videoplayer-shared/es2015";function Ke(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var Ko="video_interactive",Qo="videoint";var Xo=250,Qe=class{constructor(e){this.handleZoomChange=Ke(e=>{this.lastZoomInfo=e},Xo);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,!dt(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=Lu(e),this.resizeObserver=new ResizeObserver(Ke(this.onResize,Xo)),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 Mu(this.lang,Ko,Qo)}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",a=>{var l=a,{name:i}=l,o=Z(l,["name"]);var s;i==="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 Lu(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 Xe=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 a=o.startTime-e;if(a<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<a&&(t=t===-1?a:Math.min(t,a))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as Nt,ContainerTypes as Bf,ControlTypes as _t,EventActionTypes as P,EventTypes as qf,migrateManifestToLatestVersion as ea,compareVersions as Df}from"@interactiveplatform/movika-manifest";var Yo={metadata:"Object",chapters:"Array"},Zo=r=>{if(!ce(r))return!1;for(let e in Yo)if(!r[e]||!le(r[e],Yo[e]))return!1;return Nt(r.metadata.version)},Lt=r=>r.type===_t.Text,Vf=r=>r.type===_t.Button,Mf=r=>r.type===_t.Area,Lf={Choice:"Choice",TextInput:"TextInput"},Nf={Button:"Button",Area:"Area",Text:"Text"},_f={onClick:"onClick",onSuspense:"onSuspense"},Jo={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var jt=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 $t=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 rp}from"@vkontakte/videoplayer-shared/es2015";var Ft=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 Nu(...this.loaders[e])(t)})}};function Nu(...r){return function(t){return R(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Ye(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 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?x(d({},n),{actions:r,errors:e,result:{chapter:l,media:s,graph:c}}):x(d({},n),{errors:Ye(e,Bt.name,"Could not find media"),actions:r})}}}return x(d({},n),{errors:Ye(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 a=n[i];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}},Re=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)}},Ze=class{constructor(){Object.defineProperty(this,"signal",{value:new Re,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&&(Ze.prototype[Symbol.toStringTag]="AbortController",Re.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 Xr(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,m){let v;m&&m.signal&&(v=m.signal,delete m.signal);let y=new t(c,m);return v&&Object.defineProperty(y,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),y},o.prototype=t.prototype);let a=e;return{fetch:(s,c)=>{let m=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(m){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(m.aborted)return Promise.reject(v);let y=new Promise((g,w)=>{m.addEventListener("abort",()=>w(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([y,a(s,c)])}return a(s,c)},Request:o}}var _u=()=>"fetch"in window,Je=_u()&&Dt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ta=Je?Xr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Yr=Je?ta.fetch:window.fetch,rv=Je?ta.Request:window.Request,nv=Je?Ze:window.AbortController,iv=Je?Re:window.AbortSignal;var Zr=(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 ju=r=>R(void 0,null,function*(){try{let e={},t;if(pt(r)){t=new URL(r).href;let i=yield Yr(t);if(!i.ok)return{};e=yield i.json()}else if(ce(r))e=r;else return{};if(!Zo(e))return{};let n=e.metadata.media;if(pt(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=yield Yr(i);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(i){return Bu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function ra(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield ju(r);if(!e)throw new Error("Failed on fetch");let n=ea(e);return n.media=$u(n.media,t),delete n.metadata.media,n})}function Ht(r,e){if(e)return r.find(t=>t.id===e)}function Jr(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 en(r,e){return r.videos.find(t=>t.id===e)}function $u(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=Fu(i,e);return x(d({},n),{url:o||i})})}))})}function Fu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Bu(r){return Zr(r,"3.2.0")>=0}var da=J(et(),1);var Ut=r=>ht(r)&&!ar(r),re=r=>r.order==="end",Gt=r=>ht(r.containers)&&!ar(r.containers)&&re(r),ma=(r,e)=>{var n;let t=r*1e3;return Ut(e.controls)&&t<((n=e.startTime)!=null?n:0)},rn=(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"),nn=(r=[])=>r.find(e=>e.action.type==="expect"),tp=r=>(r==null?void 0:r.length)===1,ke=r=>tp(r)&&Lt(r[0]);function fa(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,da.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),fa(r,i.container.container.endTime,[i.container.container.id]).forEach(a=>{n(a)});break}}var va=(r,e)=>{let t=E=>{let f=e.find(({container:u})=>u.container.id===E);return f==null?void 0:f.container.isRemoved},n=me(r.events)&&!t(r.id),i=(E,f=!1,u=!1)=>{let p=u?"every":"some";return E.controls[p](b=>{var S;let I=f?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)===Jo.openURI}))&&I})},o=E=>E.some(({container:f})=>i(f.container,!0,!1)&&!f.isRemoved),a=E=>E.every(({container:f})=>f.isRemoved?!0:i(f.container,!0,!0)),l=fa(e,r.endTime,[r.id]).length,s=E=>E.controls.some(f=>{var u;return(u=f.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,m=o(e),v=i(r),y=a(e),g=n?!1:l>0,w=s(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:m,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:y,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:w}};var Oe=class extends Ft{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new rp(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:Ye},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield ra((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:Jr,getChapter:Ht,getMedia:en,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ye},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=en(this.manifest.media,i.videoId),a=Jr(this.manifest.graph,i.id);if(o)return{chapter:i,media:o,graph:a}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,o,a;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Ht(((a=this.manifest)==null?void 0:a.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 Ka=J(Wt(),1);import{Player as Op}from"@vkontakte/videoplayer-core/es2015";import{Subscription as cn,Tracer as Pp,ValueSubject as Vp}from"@vkontakte/videoplayer-shared/es2015";var za=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 Wa=J(Wt(),1);function sn(){let r=new Map;function e(s){var c=s,{listId:o=Math.random().toString(),itemId:a=Math.random().toString()}=c,l=Z(c,["listId","itemId"]);let m=r.get(o),v=d({},l);return m?m[a]=v:r.set(o,{[a]:v}),d({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 n(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,Wa.default)(l))t(s);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var Pe=J(et(),1);function ln(r,e=[]){var o,a,l;let t={},n,i=!e.length;for(let s of r.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(i||(0,Pe.default)(e,"mp4"))&&(t.MPEG=x(d({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"mpeg":(i||(0,Pe.default)(e,"mpeg"))&&(t.MPEG=x(d({},t.MPEG),{[(a=s.standard)!=null?a:"Invariant quality"]:s.url}));break;case"hls":(i||(0,Pe.default)(e,"hls"))&&(t=x(d({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(i||(0,Pe.default)(e,"dash"))&&(t=x(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(l=r.title)!=null?l:""}}var tt=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Pe.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Mp=2;function un(r){let e=sn(),t=new cn,n={},i=null,o=!1,a,l=new Vp(null);r&&s(r);function s(f){i=f}function c(f,u,p){var S;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=((S=e.map.get(f))!=null?S:{})[u];if(I){n=d({chapterId:p,listId:f,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,Ka.default)(L[1]).forEach(({player:M})=>{tt(M,T)})})).add(C.events.started$.subscribe(()=>{m(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 m(f){return R(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(pe(n)||f!==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:f},manifestVideo:u}){if(pe(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<Mp||(O=!0),e.removePlayer(L[0],$)):(O=!0,c(L[0],$,f),H?tt(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:f,setAsActive:!0,playbackRate:T}),H?tt(n.player,I):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(b))})}function y(H){return R(this,arguments,function*({media:f,chapterId:u,prefetch:p=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:S,title:C,playbackRate:T}){var xn,Tn,Sn,wn,An;let O=Math.random().toString(),L=document.createElement("div");a.append(L);let M;if((xn=i==null?void 0:i.options)!=null&&xn.vkVideoLoader){let lt=za(f);lt.length&&(M=yield i.options.vkVideoLoader(...lt))}let $=((Tn=i==null?void 0:i.options)==null?void 0:Tn.coreConfig)||void 0,be=x(d({},$),{configName:[...(Sn=$==null?void 0:$.configName)!=null?Sn:[],"interactive"]}),ie=x(d({container:L},((wn=M==null?void 0:M.videos)==null?void 0:wn[0])||{sources:ln(f,S).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),Y=new Op(be,Pp.createRootTracer());Y.initVideo(ie);let En=null;if(M!=null&&M.videos&&(i!=null&&i.options.createOneStat)){let lt=M.videos[0],tr=i.options.createOneStat(lt),Rn=new cn;tr&&(Rn.add(tr.attachTo(Y)),En={oneStat:tr,statSubscription:Rn})}let In=new cn,tl=(An=n==null?void 0:n.player)==null?void 0:An.info.isAutoQualityEnabled$.getValue();In.add(Y.events.canplay$.subscribe(function(){tl||tt(Y,n.player.info.currentQuality$.getValue()),T&&Y.setPlaybackRate(T)}));let Ce=e.createPlayer({listId:f.id,itemId:O,player:Y,container:L,sources:ln(f,S).sources,config:ie,subscription:In,statistics:En});return b&&c(f.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,a.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(),a=document.createElement("div");let{media:f,chapter:u}=i.getCurrentChapter();f&&u?(t.add(i.events.chapterChanged$.subscribe(v)),yield y({media:f,chapterId:u.id,title:u.label})):console.error("not found")})}return x(d({},e),{init:E,setInteractiveController:s,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"},rt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Xa=J(et(),1);import{Subscription as Lp}from"@vkontakte/videoplayer-shared/es2015";function pn(r){return function(...t){return r(...t.reverse())}}function nt(r,...e){return(...t)=>ce(e[0])&&ce(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:a,globalEventEmitter:l,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:m,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:a}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&a)return;this.emitContainerVisibilityEvent(!0,!1)}else{let a={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(s,c)=>{let{isExpectTime:m,hasOtherExpect:v,hasOpenURIEvent:y,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:w,hasShouldOpenNowEvent:E}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!g,u=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),s!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){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)(m,v,w,this.isSelectedContainerEvent);this.fakeRemoveView(b)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!m||!v||!E)&&(this.selectBranches.stopExpect(),c())}},isEOV:()=>this.gameState===4},l=nt(this.selectBranches.onControlEvent,a);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,m,v;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Xa.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(ma(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(rn(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"&&((m=(c=this.container).hide)==null||m.call(c)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!w&&this.removeView()}let a=rn(o,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(v=this.container.container.endTime)!=null?v:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:o,isInteractiveTime:a};this.container.onProgress(o*1e3,a),this.globalEventEmitter.emit(k.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Lp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s,this.isPermanentText=c&&ke(t.container.controls),this.interactiveTimeOpenUri=m,this.disabledControls$=v,this.onRemove=y,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=a,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:_.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:_.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:_.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 Ya=(r=[])=>r.reduce((e,t,n)=>{var o,a,l;let i=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!Lt(s));if(Ut(i)){let s=[(a=t.startTime)!=null?a:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:s});else{let m=[],v=-1/0,y=1/0,g=[],w=[];for(let E=0;E<e.length;E++){let f=e[E];if(w.push(...f.subjects),f.range[0]<y&&(y=f.range[0]),f.range[1]>v&&(v=f.range[1]),s[0]>=f.range[0]&&s[1]<=f.range[1])return e[E].subjects.push(c),e;s[0]<f.range[0]&&s[1]>f.range[0]&&(m.push(E),g=g.concat(f.subjects)),s[0]>=f.range[0]&&s[0]<=f.range[1]&&(m.push(E),g=g.concat(f.subjects),s[0]=f.range[0]),s[1]>=f.range[0]&&s[1]<=f.range[1]&&(m.push(E),g=g.concat(f.subjects),s[1]=f.range[1])}if(w.push(c),s[0]<=y&&s[1]>=v)return[{subjects:w,range:s}];m.length&&m.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Vs=J(et(),1),fn=J(Wt(),1),Ms=J(Os(),1);function Ps(){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 n(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function i({timestamp:l,priority:s,initiator:c}){var m;if(or(l)){let v=(m=r[l])!=null?m:null;if(v&&s&&Le(s,!0)){let y={},g=v[s];if(g&&(y=d(d({},y),g)),y=pe(y)?null:y,y&&Le(c,!0)){let w=y[c];return w!=null?w:null}return y}return v}return null}function o({timestamp:l,priority:s,initiator:c}){if(or(l))if(r[l]){if(s&&Le(s,!0))if(r[l][s]){if(c&&Le(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!pe(r[l][s]))return!0}else return!1;if(delete r[l][s],!pe(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function a(v){var y=v,{timestamp:l,priority:s,initiator:c}=y,m=Z(y,["timestamp","priority","initiator"]);var g,w,E;(w=(g=r[l])==null?void 0:g[s])!=null&&w[c]?r[l][s][c].push(d({},m)):(E=r[l])!=null&&E[s]?r[l][s]=x(d({},r[l][s]),{[c]:[d({},m)]}):r[l]?r[l]=x(d({},r[l]),{[s]:{[c]:[d({},m)]}}):r[l]={[s]:{[c]:[d({},m)]}}}return{map:r,remove:o,add:a,removeAll:e,get:i,getLte:t,getGte:n}}var Ih=[P.expect,P.setNextBranch],xh=1/0;function Ls(r,e){let t=r,n,i=Th(e),o=Ps(),a,l=()=>{g(),u()},s=p=>{o.add.call(void 0,p),w()},c=(p=[])=>{for(let b of p)if(b.action(),(0,Vs.default)(Ih,b.actionType))break},m=(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(m(p))},y=()=>{var p;c([...Xt((p=o.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},g=()=>{n&&(a==null||a.unsubscribe(),n=void 0)},w=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),a=t.events.ended$.subscribe(n))},E=p=>{g(),t=p},f=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),o.remove(p)},u=()=>{i.release(),o.removeAll()};return{setPlayer:E,add:s,remove:f,exec:v,execEndOfVideo:y,listen:w,unlisten:g,release:l,containersEventsCallState:i,getPreparedToExecActions:m}}function Th(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 m=(s=c.endTime)!=null?s:xh,v=e.get(m);e.set(m,x(d({},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,fn.default)(s);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function Xt(r){return(0,Ms.default)((0,fn.default)(r)).sort(e=>e.actionType===P.expect?-1:1)}var Ns={videoContentHeight:0,videoContentWidth:0},_s=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ns;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return Ns;let o=e/t,a=n/i,l,s;return a>o?(s=i,l=i*o):a<o?(s=n/o,l=n):(s=i,l=n),{videoContentWidth:s,videoContentHeight:l}};var Sh=250;function js(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function n(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:m,videoContentHeight:v}=_s(c);s.style.setProperty("--interactive-content-width",`${m}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 i(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Ke(l=>{let{fns:s=[]}=r();n(l);for(let c of s)c()},Sh);function a(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var wh=r=>Math.floor(Math.random()*r),Fs=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let o=r[e],a=(i=o.weight)!=null?i:1;a<t&&(t=a,n=o)}return n},Bs=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let o=r[e],a=(i=o.weight)!=null?i:0;a>t&&(t=a,n=o)}return n};var qs=r=>{let e=r.length,t=wh(e);return r[t]},$s=1,Ds=r=>{var n,i;let e=0;for(let o=0;o<r.length;++o)e+=(n=r[o].weight)!=null?n:$s;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(i=r[o].weight)!=null?i:$s,e>=t)return r[o];return r[r.length-1]};var Hs={shouldOpenNow:!0,isDetachContainer:!0},Us="after-expect",vn=(r,e=!1)=>x(d({},r),{args:e?d(d({},r.args),Hs):d(d({},Hs),r.args)}),Gs=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},a=({action:u,controlType:p,controlId:b,containerId:I,branches:S=[],onEvent:C,isEOV:T=()=>!1,isDisabled:H=()=>!1})=>{let O=vn(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?_.actionChoiceCanceled:_.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?f({subjectId:b,subjectName:"control",subjectType:p,action:O,payload:{URI:u.args.uri}}):n.add(x(d({},L),{action:f.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:O,payload:{URI:u.args.uri}})}));return}default:{let ie="Unexpected control event",Y=new F(1,1,{message:ie});m(Y,ie);return}}},l=({action:u,container:{id:p,endTime:b},branches:I=[],isEOV:S=!1,autoSelected:C=!1})=>{let T=vn(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:_.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:f.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{URI:u.args.uri}})}));return}default:{let M="Unexpected container event",$=new F(1,1,{message:M});m($,M);return}}};function s({container:u,branches:p,isEOV:b=!1}){var S,C;let I=nn(u.events);if(I){let T=vn(I.action,b);r.emit(k.interactives,{subjectId:u.id,subjectName:"container",type:_.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:_.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=qs(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=Ds(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=Bs(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=Fs(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(),f.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let C="Unexpected chapter event",T=new F(1,1,{message:C});m(T,C);return}}};function m(u,p){console.error(p),e.error$.next(u),r.emit(k.errors,u)}function v(u){var b;let p=nn(u.events);if(p){if(re(u))return;r.emit(k.interactives,{subjectId:u.id,subjectName:"chapter",type:_.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:_.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:_.actionExecution,actionType:Us}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:Us})},w=({subjectId:u,subjectName:p,subjectType:b,action:I})=>{r.emit(k.interactives,{subjectId:u,subjectName:p,subjectType:b,type:_.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:_.actionExecution,actionType:I.type,payload:S}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type,payload:S})},f=({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:_.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:l,onChapterEvent:c,onExpectEvent:y,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:s,stopExpect:o,state:i}};var Cn=J(Qr(),1);import{Subscription as Ph,Subject as bn,ValueSubject as ot}from"@vkontakte/videoplayer-shared/es2015";var yn=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(a=>a.id===n);if(!i)return null;let o=e.media.videos.find(a=>i.videoId===a.id);if(!o)return null;t[n]=zs(o)}return t[n]}).filter(Boolean)},Rh=r=>{for(let e of r.variants)if(kh(e)&&e.payload)return e.payload.id},kh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),zs=r=>{let e=Rh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Oh=(r,e)=>{for(let t of r.media.videos)if(e===zs(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Ws=(r,e)=>r.reduce((t,n)=>{let i=Oh(e,n);return i?[...t,i]:t},[]);var oe,fe,ve,K,Yt,ae,se,ne,ye,Ve,Me,at=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new ot([]),hasPrevChapter$:new ot(!1),prevChapter$:new ot(null),isInitialChapter$:new ot(!1),isGoBackLimited$:new ot(!1)};G(this,oe,null);G(this,fe);G(this,ve,!1);G(this,K,null);G(this,Yt,null);this.events={inited$:new bn,destroyed$:new bn,error$:new bn};G(this,ae,null);G(this,se,null);G(this,ne,null);G(this,ye,new Ph);G(this,Ve,!1);G(this,Me,0);var a;j(this,ae,t),j(this,ne,e),j(this,se,n),j(this,oe,i),j(this,fe,o),this.state.history$&&A(this,ye)&&((a=A(this,ye))==null||a.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,Cn.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=A(this,K))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(A(this,Me)===A(this,fe).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!A(this,se)||!A(this,ne))return;j(this,K,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield A(this,se).setChapter({chapterId:t,pushToHistory:!1}),A(this,ve)||(j(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,Ve)?(j(this,Ve,!1),Mn(this,Me)._++):j(this,Me,0);let n=A(this,K),i=e.length-A(this,fe).maxLength,o=i>0?e.slice(i):e,a=yn(o,n);if(j(this,Yt,a),this.state.history$.next(o),!(!t||!A(this,oe)||!A(this,ae)))try{yield A(this,oe).save(A(this,ae),a)}catch(s){let c=new F(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,se)){let i=new F(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)}j(this,Ve,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield A(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var i;if(!A(this,K)||!A(this,ae))return;let e=A(this,K),t=[this.getInitialVideoId()];if(A(this,oe))try{let o=yield A(this,oe).get(A(this,ae));o.length&&(t=o)}catch(o){let a=new F(1,5,"Error while trying to fetch data");this.events.error$.next(a),(i=A(this,ne))==null||i.emit(k.errors,a)}let n=Ws(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Cn.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 yn([e],A(this,K)).pop()}return null}destroy(){var e,t;j(this,ae,null),j(this,oe,null),j(this,se,null),(e=A(this,ye))==null||e.unsubscribe(),j(this,ye,null),j(this,ve,!1),(t=A(this,ne))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),j(this,ne,null)}};oe=new WeakMap,fe=new WeakMap,ve=new WeakMap,K=new WeakMap,Yt=new WeakMap,ae=new WeakMap,se=new WeakMap,ne=new WeakMap,ye=new WeakMap,Ve=new WeakMap,Me=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 sl=Object.create;var nr=Object.defineProperty,al=Object.defineProperties,ll=Object.getOwnPropertyDescriptor,cl=Object.getOwnPropertyDescriptors,ul=Object.getOwnPropertyNames,pt=Object.getOwnPropertySymbols,pl=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var Rn=r=>{throw TypeError(r)};var wn=(r,e,t)=>e in r?nr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))ir.call(e,t)&&wn(r,t,e[t]);if(pt)for(var t of pt(e))An.call(e,t)&&wn(r,t,e[t]);return r},x=(r,e)=>al(r,cl(e));var J=(r,e)=>{var t={};for(var n in r)ir.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&pt)for(var n of pt(r))e.indexOf(n)<0&&An.call(r,n)&&(t[n]=r[n]);return t};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var hl=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ul(e))!ir.call(r,i)&&i!==t&&nr(r,i,{get:()=>e[i],enumerable:!(n=ll(e,i))||n.enumerable});return r};var Q=(r,e,t)=>(t=r!=null?sl(pl(r)):{},hl(e||!r||!r.__esModule?nr(t,"default",{value:r,enumerable:!0}):t,r));var kn=(r,e,t)=>e.has(r)||Rn("Cannot "+t);var A=(r,e,t)=>(kn(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?Rn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,n)=>(kn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var On=(r,e,t,n)=>({set _(i){j(r,e,i,t)},get _(){return A(r,e,n)}});var R=(r,e,t)=>new Promise((n,i)=>{var o=a=>{try{s(t.next(a))}catch(c){i(c)}},l=a=>{try{s(t.throw(a))}catch(c){i(c)}},s=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,l);s((t=t.apply(r,e)).next())});var te=u((fr,Dn)=>{"use strict";var Fe=function(r){return r&&r.Math===Math&&r};Dn.exports=Fe(typeof globalThis=="object"&&globalThis)||Fe(typeof window=="object"&&window)||Fe(typeof self=="object"&&self)||Fe(typeof global=="object"&&global)||Fe(typeof fr=="object"&&fr)||function(){return this}()||Function("return this")()});var z=u((dm,Hn)=>{"use strict";Hn.exports=function(r){try{return!!r()}catch(e){return!0}}});var Be=u((mm,Un)=>{"use strict";var Cl=z();Un.exports=!Cl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Qn=u((fm,Kn)=>{"use strict";var El=Be(),Wn=Function.prototype,Gn=Wn.apply,zn=Wn.call;Kn.exports=typeof Reflect=="object"&&Reflect.apply||(El?zn.bind(Gn):function(){return zn.apply(Gn,arguments)})});var X=u((vm,Zn)=>{"use strict";var Xn=Be(),Yn=Function.prototype,vr=Yn.call,Il=Xn&&Yn.bind.bind(vr,vr);Zn.exports=Xn?Il:function(r){return function(){return vr.apply(r,arguments)}}});var qe=u((ym,ei)=>{"use strict";var Jn=X(),xl=Jn({}.toString),Tl=Jn("".slice);ei.exports=function(r){return Tl(xl(r),8,-1)}});var yr=u((bm,ti)=>{"use strict";var Sl=qe(),wl=X();ti.exports=function(r){if(Sl(r)==="Function")return wl(r)}});var W=u((gm,ri)=>{"use strict";var br=typeof document=="object"&&document.all;ri.exports=typeof br=="undefined"&&br!==void 0?function(r){return typeof r=="function"||r===br}:function(r){return typeof r=="function"}});var de=u((Cm,ni)=>{"use strict";var Al=z();ni.exports=!Al(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var At=u((Em,ii)=>{"use strict";var Rl=Be(),wt=Function.prototype.call;ii.exports=Rl?wt.bind(wt):function(){return wt.apply(wt,arguments)}});var gr=u(ai=>{"use strict";var oi={}.propertyIsEnumerable,si=Object.getOwnPropertyDescriptor,kl=si&&!oi.call({1:2},1);ai.f=kl?function(e){var t=si(this,e);return!!t&&t.enumerable}:oi});var Cr=u((xm,li)=>{"use strict";li.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var ui=u((Tm,ci)=>{"use strict";var Ol=X(),Vl=z(),Pl=qe(),Er=Object,Ml=Ol("".split);ci.exports=Vl(function(){return!Er("z").propertyIsEnumerable(0)})?function(r){return Pl(r)==="String"?Ml(r,""):Er(r)}:Er});var Ir=u((Sm,pi)=>{"use strict";pi.exports=function(r){return r==null}});var xr=u((wm,hi)=>{"use strict";var Nl=Ir(),Ll=TypeError;hi.exports=function(r){if(Nl(r))throw new Ll("Can't call method on "+r);return r}});var De=u((Am,di)=>{"use strict";var $l=ui(),jl=xr();di.exports=function(r){return $l(jl(r))}});var Ie=u((Rm,mi)=>{"use strict";var _l=W();mi.exports=function(r){return typeof r=="object"?r!==null:_l(r)}});var He=u((km,fi)=>{"use strict";fi.exports={}});var Rt=u((Om,yi)=>{"use strict";var Tr=He(),Sr=te(),Fl=W(),vi=function(r){return Fl(r)?r:void 0};yi.exports=function(r,e){return arguments.length<2?vi(Tr[r])||vi(Sr[r]):Tr[r]&&Tr[r][e]||Sr[r]&&Sr[r][e]}});var gi=u((Vm,bi)=>{"use strict";var Bl=X();bi.exports=Bl({}.isPrototypeOf)});var xi=u((Pm,Ii)=>{"use strict";var ql=te(),Ci=ql.navigator,Ei=Ci&&Ci.userAgent;Ii.exports=Ei?String(Ei):""});var Oi=u((Mm,ki)=>{"use strict";var Ri=te(),wr=xi(),Ti=Ri.process,Si=Ri.Deno,wi=Ti&&Ti.versions||Si&&Si.version,Ai=wi&&wi.v8,Y,kt;Ai&&(Y=Ai.split("."),kt=Y[0]>0&&Y[0]<4?1:+(Y[0]+Y[1]));!kt&&wr&&(Y=wr.match(/Edge\/(\d+)/),(!Y||Y[1]>=74)&&(Y=wr.match(/Chrome\/(\d+)/),Y&&(kt=+Y[1])));ki.exports=kt});var Ar=u((Nm,Pi)=>{"use strict";var Vi=Oi(),Dl=z(),Hl=te(),Ul=Hl.String;Pi.exports=!!Object.getOwnPropertySymbols&&!Dl(function(){var r=Symbol("symbol detection");return!Ul(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Vi&&Vi<41})});var Rr=u((Lm,Mi)=>{"use strict";var Gl=Ar();Mi.exports=Gl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var kr=u(($m,Ni)=>{"use strict";var zl=Rt(),Wl=W(),Kl=gi(),Ql=Rr(),Xl=Object;Ni.exports=Ql?function(r){return typeof r=="symbol"}:function(r){var e=zl("Symbol");return Wl(e)&&Kl(e.prototype,Xl(r))}});var $i=u((jm,Li)=>{"use strict";var Yl=String;Li.exports=function(r){try{return Yl(r)}catch(e){return"Object"}}});var Or=u((_m,ji)=>{"use strict";var Zl=W(),Jl=$i(),ec=TypeError;ji.exports=function(r){if(Zl(r))return r;throw new ec(Jl(r)+" is not a function")}});var Fi=u((Fm,_i)=>{"use strict";var tc=Or(),rc=Ir();_i.exports=function(r,e){var t=r[e];return rc(t)?void 0:tc(t)}});var qi=u((Bm,Bi)=>{"use strict";var Vr=At(),Pr=W(),Mr=Ie(),nc=TypeError;Bi.exports=function(r,e){var t,n;if(e==="string"&&Pr(t=r.toString)&&!Mr(n=Vr(t,r))||Pr(t=r.valueOf)&&!Mr(n=Vr(t,r))||e!=="string"&&Pr(t=r.toString)&&!Mr(n=Vr(t,r)))return n;throw new nc("Can't convert object to primitive value")}});var Hi=u((qm,Di)=>{"use strict";Di.exports=!0});var zi=u((Dm,Gi)=>{"use strict";var Ui=te(),ic=Object.defineProperty;Gi.exports=function(r,e){try{ic(Ui,r,{value:e,configurable:!0,writable:!0})}catch(t){Ui[r]=e}return e}});var Ot=u((Hm,Qi)=>{"use strict";var oc=Hi(),sc=te(),ac=zi(),Wi="__core-js_shared__",Ki=Qi.exports=sc[Wi]||ac(Wi,{});(Ki.versions||(Ki.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 Nr=u((Um,Yi)=>{"use strict";var Xi=Ot();Yi.exports=function(r,e){return Xi[r]||(Xi[r]=e||{})}});var Ue=u((Gm,Zi)=>{"use strict";var lc=xr(),cc=Object;Zi.exports=function(r){return cc(lc(r))}});var xe=u((zm,Ji)=>{"use strict";var uc=X(),pc=Ue(),hc=uc({}.hasOwnProperty);Ji.exports=Object.hasOwn||function(e,t){return hc(pc(e),t)}});var Lr=u((Wm,eo)=>{"use strict";var dc=X(),mc=0,fc=Math.random(),vc=dc(1 .toString);eo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+vc(++mc+fc,36)}});var Ge=u((Km,ro)=>{"use strict";var yc=te(),bc=Nr(),to=xe(),gc=Lr(),Cc=Ar(),Ec=Rr(),Te=yc.Symbol,$r=bc("wks"),Ic=Ec?Te.for||Te:Te&&Te.withoutSetter||gc;ro.exports=function(r){return to($r,r)||($r[r]=Cc&&to(Te,r)?Te[r]:Ic("Symbol."+r)),$r[r]}});var so=u((Qm,oo)=>{"use strict";var xc=At(),no=Ie(),io=kr(),Tc=Fi(),Sc=qi(),wc=Ge(),Ac=TypeError,Rc=wc("toPrimitive");oo.exports=function(r,e){if(!no(r)||io(r))return r;var t=Tc(r,Rc),n;if(t){if(e===void 0&&(e="default"),n=xc(t,r,e),!no(n)||io(n))return n;throw new Ac("Can't convert object to primitive value")}return e===void 0&&(e="number"),Sc(r,e)}});var jr=u((Xm,ao)=>{"use strict";var kc=so(),Oc=kr();ao.exports=function(r){var e=kc(r,"string");return Oc(e)?e:e+""}});var uo=u((Ym,co)=>{"use strict";var Vc=te(),lo=Ie(),_r=Vc.document,Pc=lo(_r)&&lo(_r.createElement);co.exports=function(r){return Pc?_r.createElement(r):{}}});var Fr=u((Zm,po)=>{"use strict";var Mc=de(),Nc=z(),Lc=uo();po.exports=!Mc&&!Nc(function(){return Object.defineProperty(Lc("div"),"a",{get:function(){return 7}}).a!==7})});var fo=u(mo=>{"use strict";var $c=de(),jc=At(),_c=gr(),Fc=Cr(),Bc=De(),qc=jr(),Dc=xe(),Hc=Fr(),ho=Object.getOwnPropertyDescriptor;mo.f=$c?ho:function(e,t){if(e=Bc(e),t=qc(t),Hc)try{return ho(e,t)}catch(n){}if(Dc(e,t))return Fc(!jc(_c.f,e,t),e[t])}});var yo=u((ef,vo)=>{"use strict";var Uc=z(),Gc=W(),zc=/#|\.prototype\./,ze=function(r,e){var t=Kc[Wc(r)];return t===Xc?!0:t===Qc?!1:Gc(e)?Uc(e):!!e},Wc=ze.normalize=function(r){return String(r).replace(zc,".").toLowerCase()},Kc=ze.data={},Qc=ze.NATIVE="N",Xc=ze.POLYFILL="P";vo.exports=ze});var Br=u((tf,go)=>{"use strict";var bo=yr(),Yc=Or(),Zc=Be(),Jc=bo(bo.bind);go.exports=function(r,e){return Yc(r),e===void 0?r:Zc?Jc(r,e):function(){return r.apply(e,arguments)}}});var Eo=u((rf,Co)=>{"use strict";var eu=de(),tu=z();Co.exports=eu&&tu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var xo=u((nf,Io)=>{"use strict";var ru=Ie(),nu=String,iu=TypeError;Io.exports=function(r){if(ru(r))return r;throw new iu(nu(r)+" is not an object")}});var wo=u(So=>{"use strict";var ou=de(),su=Fr(),au=Eo(),Vt=xo(),To=jr(),lu=TypeError,qr=Object.defineProperty,cu=Object.getOwnPropertyDescriptor,Dr="enumerable",Hr="configurable",Ur="writable";So.f=ou?au?function(e,t,n){if(Vt(e),t=To(t),Vt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Ur in n&&!n[Ur]){var i=cu(e,t);i&&i[Ur]&&(e[t]=n.value,n={configurable:Hr in n?n[Hr]:i[Hr],enumerable:Dr in n?n[Dr]:i[Dr],writable:!1})}return qr(e,t,n)}:qr:function(e,t,n){if(Vt(e),t=To(t),Vt(n),su)try{return qr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new lu("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Ro=u((sf,Ao)=>{"use strict";var uu=de(),pu=wo(),hu=Cr();Ao.exports=uu?function(r,e,t){return pu.f(r,e,hu(1,t))}:function(r,e,t){return r[e]=t,r}});var Ae=u((af,Oo)=>{"use strict";var We=te(),du=Qn(),mu=yr(),fu=W(),vu=fo().f,yu=yo(),Se=He(),bu=Br(),we=Ro(),ko=xe();Ot();var gu=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 du(r,this,arguments)};return e.prototype=r.prototype,e};Oo.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,l=n?We:i?We[t]:We[t]&&We[t].prototype,s=n?Se:Se[t]||we(Se,t,{})[t],a=s.prototype,c,f,y,v,C,w,E,m,p;for(v in e)c=yu(n?v:t+(i?".":"#")+v,r.forced),f=!c&&l&&ko(l,v),w=s[v],f&&(r.dontCallGetSet?(p=vu(l,v),E=p&&p.value):E=l[v]),C=f&&E?E:e[v],!(!c&&!o&&typeof w==typeof C)&&(r.bind&&f?m=bu(C,We):r.wrap&&f?m=gu(C):o&&fu(C)?m=mu(C):m=C,(r.sham||C&&C.sham||w&&w.sham)&&we(m,"sham",!0),we(s,v,m),o&&(y=t+"Prototype",ko(Se,y)||we(Se,y,{}),we(Se[y],v,C),r.real&&a&&(c||!a[v])&&we(a,v,C)))}});var Po=u((lf,Vo)=>{"use strict";var Cu=Math.ceil,Eu=Math.floor;Vo.exports=Math.trunc||function(e){var t=+e;return(t>0?Eu:Cu)(t)}});var Ke=u((cf,Mo)=>{"use strict";var Iu=Po();Mo.exports=function(r){var e=+r;return e!==e||e===0?0:Iu(e)}});var Lo=u((uf,No)=>{"use strict";var xu=Ke(),Tu=Math.min;No.exports=function(r){var e=xu(r);return e>0?Tu(e,9007199254740991):0}});var Qe=u((pf,$o)=>{"use strict";var Su=Lo();$o.exports=function(r){return Su(r.length)}});var Pt=u((hf,jo)=>{"use strict";jo.exports=function(){}});var _o=u(()=>{"use strict";var wu=Ae(),Au=Ue(),Ru=Qe(),ku=Ke(),Ou=Pt();wu({target:"Array",proto:!0},{at:function(e){var t=Au(this),n=Ru(t),i=ku(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Ou("at")});var Mt=u((ff,Fo)=>{"use strict";var Vu=Rt();Fo.exports=Vu});var qo=u((vf,Bo)=>{"use strict";_o();var Pu=Mt();Bo.exports=Pu("Array","at")});var Ho=u((yf,Do)=>{"use strict";var Mu=qo();Do.exports=Mu});var Gr=u((bf,Uo)=>{"use strict";var Nu=Ho();Uo.exports=Nu});var es=u((Yf,Jo)=>{"use strict";var ju=Nr(),_u=Lr(),Zo=ju("keys");Jo.exports=function(r){return Zo[r]||(Zo[r]=_u(r))}});var rs=u((Zf,ts)=>{"use strict";var Fu=z();ts.exports=!Fu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var os=u((Jf,is)=>{"use strict";var Bu=xe(),qu=W(),Du=Ue(),Hu=es(),Uu=rs(),ns=Hu("IE_PROTO"),zr=Object,Gu=zr.prototype;is.exports=Uu?zr.getPrototypeOf:function(r){var e=Du(r);if(Bu(e,ns))return e[ns];var t=e.constructor;return qu(t)&&e instanceof t?t.prototype:e instanceof zr?Gu:null}});var as=u((ev,ss)=>{"use strict";var zu=Ke(),Wu=Math.max,Ku=Math.min;ss.exports=function(r,e){var t=zu(r);return t<0?Wu(t+e,0):Ku(t,e)}});var Wr=u((tv,cs)=>{"use strict";var Qu=De(),Xu=as(),Yu=Qe(),ls=function(r){return function(e,t,n){var i=Qu(e),o=Yu(i);if(o===0)return!r&&-1;var l=Xu(n,o),s;if(r&&t!==t){for(;o>l;)if(s=i[l++],s!==s)return!0}else for(;o>l;l++)if((r||l in i)&&i[l]===t)return r||l||0;return!r&&-1}};cs.exports={includes:ls(!0),indexOf:ls(!1)}});var ps=u((rv,us)=>{"use strict";us.exports={}});var ms=u((nv,ds)=>{"use strict";var Zu=X(),Kr=xe(),Ju=De(),ep=Wr().indexOf,tp=ps(),hs=Zu([].push);ds.exports=function(r,e){var t=Ju(r),n=0,i=[],o;for(o in t)!Kr(tp,o)&&Kr(t,o)&&hs(i,o);for(;e.length>n;)Kr(t,o=e[n++])&&(~ep(i,o)||hs(i,o));return i}});var vs=u((iv,fs)=>{"use strict";fs.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var bs=u((ov,ys)=>{"use strict";var rp=ms(),np=vs();ys.exports=Object.keys||function(e){return rp(e,np)}});var Qr=u((sv,xs)=>{"use strict";var Cs=de(),ip=z(),Es=X(),op=os(),sp=bs(),ap=De(),lp=gr().f,Is=Es(lp),cp=Es([].push),up=Cs&&ip(function(){var r=Object.create(null);return r[2]=2,!Is(r,2)}),gs=function(r){return function(e){for(var t=ap(e),n=sp(t),i=up&&op(t)===null,o=n.length,l=0,s=[],a;o>l;)a=n[l++],(!Cs||(i?a in t:Is(t,a)))&&cp(s,r?[a,t[a]]:t[a]);return s}};xs.exports={entries:gs(!0),values:gs(!1)}});var Ts=u(()=>{"use strict";var pp=Ae(),hp=Qr().entries;pp({target:"Object",stat:!0},{entries:function(e){return hp(e)}})});var ws=u((cv,Ss)=>{"use strict";Ts();var dp=He();Ss.exports=dp.Object.entries});var Rs=u((uv,As)=>{"use strict";var mp=ws();As.exports=mp});var Os=u((pv,ks)=>{"use strict";var fp=Rs();ks.exports=fp});var Ns=u(()=>{"use strict";var Ep=Ae(),Ip=Wr().includes,xp=z(),Tp=Pt(),Sp=xp(function(){return!Array(1).includes()});Ep({target:"Array",proto:!0,forced:Sp},{includes:function(e){return Ip(this,e,arguments.length>1?arguments[1]:void 0)}});Tp("includes")});var $s=u(($v,Ls)=>{"use strict";Ns();var wp=Mt();Ls.exports=wp("Array","includes")});var _s=u((jv,js)=>{"use strict";var Ap=$s();js.exports=Ap});var rt=u((_v,Fs)=>{"use strict";var Rp=_s();Fs.exports=Rp});var Us=u(()=>{"use strict";var Vp=Ae(),Pp=Qr().values;Vp({target:"Object",stat:!0},{values:function(e){return Pp(e)}})});var zs=u((Zv,Gs)=>{"use strict";Us();var Mp=He();Gs.exports=Mp.Object.values});var Ks=u((Jv,Ws)=>{"use strict";var Np=zs();Ws.exports=Np});var Kt=u((ey,Qs)=>{"use strict";var Lp=Ks();Qs.exports=Lp});var cn=u((Ry,ra)=>{"use strict";var qp=qe();ra.exports=Array.isArray||function(e){return qp(e)==="Array"}});var ia=u((ky,na)=>{"use strict";var Dp=TypeError,Hp=9007199254740991;na.exports=function(r){if(r>Hp)throw Dp("Maximum allowed index exceeded");return r}});var aa=u((Oy,sa)=>{"use strict";var Up=cn(),Gp=Qe(),zp=ia(),Wp=Br(),oa=function(r,e,t,n,i,o,l,s){for(var a=i,c=0,f=l?Wp(l,s):!1,y,v;c<n;)c in t&&(y=f?f(t[c],c,e):t[c],o>0&&Up(y)?(v=Gp(y),a=oa(r,e,y,v,a,o-1)-1):(zp(a+1),r[a]=y),a++),c++;return a};sa.exports=oa});var ua=u((Vy,ca)=>{"use strict";var Kp=Ge(),Qp=Kp("toStringTag"),la={};la[Qp]="z";ca.exports=String(la)==="[object z]"});var ha=u((Py,pa)=>{"use strict";var Xp=ua(),Yp=W(),Xt=qe(),Zp=Ge(),Jp=Zp("toStringTag"),eh=Object,th=Xt(function(){return arguments}())==="Arguments",rh=function(r,e){try{return r[e]}catch(t){}};pa.exports=Xp?Xt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=rh(e=eh(r),Jp))=="string"?t:th?Xt(e):(n=Xt(e))==="Object"&&Yp(e.callee)?"Arguments":n}});var ma=u((My,da)=>{"use strict";var nh=X(),ih=W(),un=Ot(),oh=nh(Function.toString);ih(un.inspectSource)||(un.inspectSource=function(r){return oh(r)});da.exports=un.inspectSource});var Ca=u((Ny,ga)=>{"use strict";var sh=X(),ah=z(),fa=W(),lh=ha(),ch=Rt(),uh=ma(),va=function(){},ya=ch("Reflect","construct"),pn=/^\s*(?:class|function)\b/,ph=sh(pn.exec),hh=!pn.test(va),st=function(e){if(!fa(e))return!1;try{return ya(va,[],e),!0}catch(t){return!1}},ba=function(e){if(!fa(e))return!1;switch(lh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return hh||!!ph(pn,uh(e))}catch(t){return!0}};ba.sham=!0;ga.exports=!ya||ah(function(){var r;return st(st.call)||!st(Object)||!st(function(){r=!0})||r})?ba:st});var Ta=u((Ly,xa)=>{"use strict";var Ea=cn(),dh=Ca(),mh=Ie(),fh=Ge(),vh=fh("species"),Ia=Array;xa.exports=function(r){var e;return Ea(r)&&(e=r.constructor,dh(e)&&(e===Ia||Ea(e.prototype))?e=void 0:mh(e)&&(e=e[vh],e===null&&(e=void 0))),e===void 0?Ia:e}});var wa=u(($y,Sa)=>{"use strict";var yh=Ta();Sa.exports=function(r,e){return new(yh(r))(e===0?0:e)}});var Aa=u(()=>{"use strict";var bh=Ae(),gh=aa(),Ch=Ue(),Eh=Qe(),Ih=Ke(),xh=wa();bh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Ch(this),n=Eh(t),i=xh(t,0);return i.length=gh(i,t,t,n,0,e===void 0?1:Ih(e)),i}})});var Ra=u(()=>{"use strict";var Th=Pt();Th("flat")});var Oa=u((qy,ka)=>{"use strict";Aa();Ra();var Sh=Mt();ka.exports=Sh("Array","flat")});var Pa=u((Dy,Va)=>{"use strict";var wh=Oa();Va.exports=wh});var Na=u((Hy,Ma)=>{"use strict";var Ah=Pa();Ma.exports=Ah});var Vn="1.0.37-dev.09adc98d.0";import{Subject as bl,Subscription as gl}from"@vkontakte/videoplayer-shared/es2015";var or=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},ht=class extends or{constructor(e,t){super(e,t),this.cssVarsManager=t,console.log("cssVarsManager",t,this.cssVarsManager)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){console.log("@@@THIS",this,this.cssVarsManager);let n=this.cssVarsManager.getPropValue("--interactive-content-width"),i=this.cssVarsManager.getPropValue("--interactive-content-height"),o=this.cssVarsManager.getPropValue("--interactive-width"),l=this.cssVarsManager.getPropValue("--interactive-height");e.style.position="absolute",e.style.width=`calc(${n} * ${t.width})`,e.style.height=`calc(${i} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${o} - ${n}) / 2))`,e.style.top=`calc(${i} * ${t.y} + ((${l} - ${i}) / 2))`}};function Pn(r){return"features"in r}var Ce=class{constructor(e,t,n){this.container=e,this.options=n,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&Pn(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 l=o(n,this.options);if(l)return[...t,l]}return[...t]},[]))||[]}};import{fromEvent as Ct,once as vl}from"@vkontakte/videoplayer-shared/es2015";function Ne(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 Mn="interactive",_={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},Nn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Nn||{}),Ln=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Ln||{}),$n=(n=>(n.start="left",n.end="right",n.center="center",n))($n||{}),dt=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Nn[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&Ln[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&$n[e.alignment])!=null?i:"center"},mt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,o,l,s,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} * ${(s=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?s:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},ft=({target:r,props:e,fallback:t})=>{var n,i,o,l;r.style.backgroundColor=Ne((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(l=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?l:t.backgroundAlpha)},Le=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{var s,a,c,f,y,v,C,w,E,m,p;let o=i?t.borderWidthRawValue:`calc(${n.height} * ${(c=(a=(s=e==null?void 0:e.shape)==null?void 0:s.border)==null?void 0:a.width)!=null?c:t.borderWidth})`,l=i?t.roundCornersRawValue:`calc(${n.height} * ${(y=(f=e==null?void 0:e.shape)==null?void 0:f.roundCorners)!=null?y:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Ne(i?t.borderColor:(w=(C=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:C.color)!=null?w:t.borderColor,i?t.borderAlpha:(p=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=l},jn=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let l=Ne(n.shadowColorLight,n.shadowColorAlpha),s=Ne(n.shadowColorDark,n.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,f=`0px 0px ${a} ${c} ${e?s:l}`;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 dl,Subject as ml,Subscription as fl}from"@vkontakte/videoplayer-shared/es2015";var sr="int",pe=(n=>(n.AREA=`${sr}_area`,n.TEXT=`${sr}_text`,n.BUTTON=`${sr}_bttn`,n))(pe||{});function _n(r){return"features"in r}var ee="interactive-control",P={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 fl;this.error$=new ml;this.cssVarsManager=null}setCssVarsManager(e){this.cssVarsManager=e}createContainerElement(e){var i,o,l,s,a;let t=document.createElement("div");t.classList.add(P.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:_.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:(l=(o=this.cssVarsManager)==null?void 0:o.getPropValue("--interactive-content-height)"))!=null?l:0,width:(a=(s=this.cssVarsManager)==null?void 0:s.getPropValue("--interactive-content-width"))!=null?a:0};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&_n(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(dl(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"),vt=r=>ce(r,"String"),yt=r=>ce(r,"Array"),bt=r=>ce(r,"Number"),Fn=r=>ce(r,"Function"),Bn=r=>ce(r,"Boolean"),ar=r=>bt(r)&&!isNaN(r);var he=r=>ue(r)&&Object.keys(r).length===0,lr=r=>yt(r)&&!r.length;var _e=(r,e)=>vt(r)&&(e?r.trim():r).length;var cr="interactive-blink-anim-reference",B={common:cr,animation:`${cr}-animation`,disabled:`${cr}-disabled`},gt=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 ur="interactive-container",q={common:ur,hidden:`${ur}-hidden`,disabled:`${ur}-disabled`};var Et=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new pr(r,e)},pr=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(P.common,P.area),n.setAttribute("data-testid",pe.AREA),ft({target:n,props:this.control.props,fallback:x(d({},_),{backgroundColor:"transparent"})}),Ee({target:n,layoutParams:this.control.layoutParams,fallback:_}),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(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,n,i;if(!(!this.container||!this.controlElement))if(Bn(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";jn({target:this.controlElement,props:this.control.props,fallback:_,isDark:e,baseDimension:o}),Le({target:this.controlElement,props:this.control.props,fallback:x(d({},_),{borderColor:e?_.shadowColorDark:_.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:_.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else Le({target:this.controlElement,props:this.control.props,fallback:x(d({},_),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(P.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(P.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${P.blinkAnimArea}`)||this.controlElement.classList.contains(P.selected)||this.controlElement.classList.contains(B.disabled)||(this.controlElement.classList.add(B.disabled),this.subscriptions.add(Ct(e,"animationiteration").pipe(vl()).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(`${P.blinkAnimArea}`)||this.controlElement.classList.contains(P.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 xt,once as yl}from"@vkontakte/videoplayer-shared/es2015";var It=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 Tt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new hr(r,e)},hr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(P.common,P.button),n.setAttribute("data-testid",pe.BUTTON),Ee({target:n,layoutParams:this.control.layoutParams,fallback:_}),ft({target:n,props:this.control.props,fallback:_}),Le({target:n,props:this.control.props,fallback:_,dependsOn:this.container.dimensions}),dt({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=It(this.control.type.trim().toLowerCase()),o=(l=i.firstElementChild)!=null?l:i;mt({target:o,props:this.control.props,fallback:_,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(xt(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(xt(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(q.disabled)||this.onBlinkHovering()},n=>this.onError("Error happened in mouseenter callback",n))).add(xt(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(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,n;(t=this.controlElement)==null||t.classList.toggle(P.blinkAnim,e),(n=this.controlElement)==null||n.classList.toggle(P.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${P.blinkAnimButton}`)||this.controlElement.classList.contains(P.selected)||this.controlElement.classList.contains(B.disabled)||(this.controlElement.classList.add(B.disabled),this.subscriptions.add(xt(e,"animationiteration").pipe(yl()).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(`${P.blinkAnimButton}`)||this.controlElement.classList.contains(P.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 qn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new dr(r,e)},dr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(P.common,P.text),n.setAttribute("data-testid",pe.TEXT),Ee({target:n,layoutParams:this.control.layoutParams,fallback:_}),dt({target:n,props:x(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=It(this.control.type.trim().toLowerCase()),o=(l=i.firstElementChild)!=null?l:i;mt({target:o,props:this.control.props,fallback:_,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 St=(r,e,t,n)=>{if(r.type.trim().toLowerCase()==="choice")return new mr(r,e,t,n)},mr=class extends Ce{constructor(t,n,i,o){super(t,i,o);this.containerElement=null;this.controlSubscriptions=new gl;this.error$=new bl;this.rootElement=n,this.layout=new ht(this.container.layout,i),this.cssVarsManager=i,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Tt),this.addControlFactory("text",qn),this.addControlFactory("area",Et)}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.setCssVarsManager(this.cssVarsManager),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 il=Q(Gr(),1);import{combine as Fh,InterfaceLanguage as Bh,Observable as tl,once as qh,Subject as D,Subscription as yn,ValueSubject as U,fromEvent as rl}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as ct}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Lu}from"@vkontakte/videoplayer-shared/es2015";function Xe(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var Go="video_interactive",zo="videoint";var Wo=250,Ye=class{constructor(e){this.handleZoomChange=Xe(e=>{this.lastZoomInfo=e},Wo);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,!bt(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=$u(e),this.resizeObserver=new ResizeObserver(Xe(this.onResize,Wo)),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 Lu(this.lang,Go,zo)}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",l=>{var s=l,{name:i}=s,o=J(s,["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 $u(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 Ze=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 l=o.startTime-e;if(l<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<l&&(t=t===-1?l:Math.min(t,l))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as Lt,ContainerTypes as Uf,ControlTypes as $t,EventActionTypes as V,EventTypes as Gf,migrateManifestToLatestVersion as Yo,compareVersions as zf}from"@interactiveplatform/movika-manifest";var Ko={metadata:"Object",chapters:"Array"},Qo=r=>{if(!ue(r))return!1;for(let e in Ko)if(!r[e]||!ce(r[e],Ko[e]))return!1;return Lt(r.metadata.version)},Nt=r=>r.type===$t.Text,$f=r=>r.type===$t.Button,jf=r=>r.type===$t.Area,_f={Choice:"Choice",TextInput:"TextInput"},Ff={Button:"Button",Area:"Area",Text:"Text"},Bf={onClick:"onClick",onSuspense:"onSuspense"},Xo={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var jt=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 _t=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Fn(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=[]}};var Vs=Q(Os(),1);var Ft=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",n="test";e.style.setProperty(t,n);let i=e.style.getPropertyValue(t)===n;return i&&e.style.removeProperty(t),i}getPropValue(e){var t;return this.isCssVarsSupported?`var(${e})`:(t=this.rootElementProps[e])!=null?t:""}setup(e){if(this.rootElementProps=d(d({},this.rootElementProps),e),this.isCssVarsSupported)for(let[t,n]of(0,Vs.default)(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as Op}from"@vkontakte/videoplayer-shared/es2015";var Bt=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 vp(...this.loaders[e])(t)})}};function vp(...r){return function(t){return R(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Je(r,e,t){return r?x(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function qt(i){var o=i,{actions:r,errors:e,chapterId:t}=o,n=J(o,["actions","errors","chapterId"]);if(t){let l=r.getManifest();if(l){let s=r.getChapter(l.chapters,t);if(s){let a=r.getMedia(l.media,s.videoId),c=r.getGraph(l.graph,s.id);return a?x(d({},n),{actions:r,errors:e,result:{chapter:s,media:a,graph:c}}):x(d({},n),{errors:Je(e,qt.name,"Could not find media"),actions:r})}}}return x(d({},n),{errors:Je(e,qt.name,"Could not find chapter"),actions:r})}var Dt=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 l=n[i];try{l.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Re=class extends Dt{constructor(){super(),this.listeners||Dt.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)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Re,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&&(et.prototype[Symbol.toStringTag]="AbortController",Re.prototype[Symbol.toStringTag]="AbortSignal");function Ht(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 Xr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Ht({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 y;f&&f.signal&&(y=f.signal,delete f.signal);let v=new t(c,f);return y&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),v},o.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let f=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(f){let y;try{y=new DOMException("Aborted","AbortError")}catch(C){y=new Error("Aborted"),y.name="AbortError"}if(f.aborted)return Promise.reject(y);let v=new Promise((C,w)=>{f.addEventListener("abort",()=>w(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,l(a,c)])}return l(a,c)},Request:o}}var tt=Ht({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ps=tt?Xr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Yr=tt?Ps.fetch:window.fetch,xv=tt?Ps.Request:window.Request,Tv=tt?et:window.AbortController,Sv=tt?Re:window.AbortSignal;var Zr=(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 yp=r=>R(void 0,null,function*(){try{let e={},t;if(vt(r)){t=new URL(r).href;let i=yield Yr(t);if(!i.ok)return{};e=yield i.json()}else if(ue(r))e=r;else return{};if(!Qo(e))return{};let n=e.metadata.media;if(vt(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=yield Yr(i);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(i){return Cp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ms(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield yp(r);if(!e)throw new Error("Failed on fetch");let n=Yo(e);return n.media=bp(n.media,t),delete n.metadata.media,n})}function Ut(r,e){if(e)return r.find(t=>t.id===e)}function Jr(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 en(r,e){return r.videos.find(t=>t.id===e)}function bp(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=gp(i,e);return x(d({},n),{url:o||i})})}))})}function gp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Cp(r){return Zr(r,"3.2.0")>=0}var Bs=Q(rt(),1);var Gt=r=>yt(r)&&!lr(r),re=r=>r.order==="end",zt=r=>yt(r.containers)&&!lr(r.containers)&&re(r),qs=(r,e)=>{var n;let t=r*1e3;return Gt(e.controls)&&t<((n=e.startTime)!=null?n:0)},tn=(r,e)=>{var n,i;let t=r*1e3;return Gt(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"),rn=(r=[])=>r.find(e=>e.action.type==="expect"),kp=r=>(r==null?void 0:r.length)===1,ke=r=>kp(r)&&Nt(r[0]);function Ds(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,Bs.default)(t,n.container.id)&&me(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Wt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),Ds(r,i.container.container.endTime,[i.container.container.id]).forEach(l=>{n(l)});break}}var Hs=(r,e)=>{let t=E=>{let m=e.find(({container:p})=>p.container.id===E);return m==null?void 0:m.container.isRemoved},n=me(r.events)&&!t(r.id),i=(E,m=!1,p=!1)=>{let h=p?"every":"some";return E.controls[h](b=>{var S;let I=m?E.endTime===r.endTime:!0;return((S=b.events)==null?void 0:S[h](g=>{var T;return((T=g.action)==null?void 0:T.type)===Xo.openURI}))&&I})},o=E=>E.some(({container:m})=>i(m.container,!0,!1)&&!m.isRemoved),l=E=>E.every(({container:m})=>m.isRemoved?!0:i(m.container,!0,!0)),s=Ds(e,r.endTime,[r.id]).length,a=E=>E.controls.some(m=>{var p;return(p=m.events)==null?void 0:p.some(h=>{var b,I;return(I=(b=h.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=n||s>0,f=o(e),y=i(r),v=l(e),C=n?!1:s>0,w=a(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:f,hasOpenURIEventInCurrentContainer:y,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:C,hasShouldOpenNowEvent:w}};var Oe=class extends Bt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Op(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:Je},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield Ms((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",qt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Jr,getChapter:Ut,getMedia:en,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},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=Ut(this.manifest.chapters,t);if(i){let o=en(this.manifest.media,i.videoId),l=Jr(this.manifest.graph,i.id);if(o)return{chapter:i,media:o,graph:l}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,o,l;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let s=Ut(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(s==null?void 0:s.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 Zs=Q(Kt(),1);import{Player as $p}from"@vkontakte/videoplayer-core/es2015";import{Subscription as sn,Tracer as jp,ValueSubject as _p}from"@vkontakte/videoplayer-shared/es2015";var Xs=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 Ys=Q(Kt(),1);function nn(){let r=new Map;function e(a){var c=a,{listId:o=Math.random().toString(),itemId:l=Math.random().toString()}=c,s=J(c,["listId","itemId"]);let f=r.get(o),y=d({},s);return f?f[l]=y:r.set(o,{[l]:y}),d({listId:o,itemId:l},s)}function t(o){var l,s;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(l=o.statistics)==null||l.oneStat.destroy(),(s=o.statistics)==null||s.statSubscription.unsubscribe()}function n(o,l){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(l){let a=s[l];a&&t(a),delete s[l],Object.keys(s).length||r.delete(o)}else{for(let a of(0,Ys.default)(s))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 Ve=Q(rt(),1);function on(r,e=[]){var o,l,s;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,Ve.default)(e,"mp4"))&&(t.MPEG=x(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,Ve.default)(e,"mpeg"))&&(t.MPEG=x(d({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(i||(0,Ve.default)(e,"hls"))&&(t=x(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,Ve.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:(s=r.title)!=null?s:""}}var nt=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Ve.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Fp=2;function an(r){let e=nn(),t=new sn,n={},i=null,o=!1,l,s=new _p(null);r&&a(r);function a(m){i=m}function c(m,p,h){var S;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=((S=e.map.get(m))!=null?S:{})[p];if(I){n=d({chapterId:h,listId:m,itemId:p},I);let g=n.player;n.subscription.add(g.info.currentQuality$.subscribe(T=>{let H=g.info.position$.getValue(),O=g.info.isAutoQualityEnabled$.getValue();if(!(!T||!H||O))for(let L of e.map)(0,Zs.default)(L[1]).forEach(({player:M})=>{nt(M,T)})})).add(g.events.started$.subscribe(()=>{f(p)})),I.container.remove(),i.setPlayer(I.player),o||(i.init(),o=!0),s.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 p=i.getChapterBranches(),h=new Set;for(let b of p)h.has(b.media.id)||(yield v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),h.add(b.media.id))})}function y(h){return R(this,arguments,function*({chapter:{id:m},manifestVideo:p}){if(he(n)||!i)return;let b=n.player.info.muted$.getValue(),I=n.player.info.currentQuality$.getValue(),S=n.player.info.isAutoQualityEnabled$.getValue(),g=n.player.info.volume$.getValue(),T=n.player.info.currentPlaybackRate$.getValue(),H=!S,O=!1;for(let L of e.map)if(L[0]===p.id&&!i.state.isReplay$.getValue()){let M=Object.keys(L[1]);for(let F of M)F===n.itemId?(M.length<Fp||(O=!0),e.removePlayer(L[0],F)):(O=!0,c(L[0],F,m),H?nt(n.player,I):n.player.setAutoQuality(!0),n.player.setVolume(g),n.player.setMuted(b),n.player.setPlaybackRate(T))}else e.removePlayer(L[0]);O||(yield v({media:p,chapterId:m,setAsActive:!0,playbackRate:T}),H?nt(n.player,I):n.player.setAutoQuality(!0),n.player.setVolume(g),n.player.setMuted(b))})}function v(H){return R(this,arguments,function*({media:m,chapterId:p,prefetch:h=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:S,title:g,playbackRate:T}){var Cn,En,In,xn,Tn;let O=Math.random().toString(),L=document.createElement("div");l.append(L);let M;if((Cn=i==null?void 0:i.options)!=null&&Cn.vkVideoLoader){let ut=Xs(m);ut.length&&(M=yield i.options.vkVideoLoader(...ut))}let F=((En=i==null?void 0:i.options)==null?void 0:En.coreConfig)||void 0,be=x(d({},F),{configName:[...(In=F==null?void 0:F.configName)!=null?In:[],"interactive"]}),ie=x(d({container:L},((xn=M==null?void 0:M.videos)==null?void 0:xn[0])||{sources:on(m,S).sources}),{title:g,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),Z=new $p(be,jp.createRootTracer());Z.initVideo(ie);let bn=null;if(M!=null&&M.videos&&(i!=null&&i.options.createOneStat)){let ut=M.videos[0],rr=i.options.createOneStat(ut),Sn=new sn;rr&&(Sn.add(rr.attachTo(Z)),bn={oneStat:rr,statSubscription:Sn})}let gn=new sn,ol=(Tn=n==null?void 0:n.player)==null?void 0:Tn.info.isAutoQualityEnabled$.getValue();gn.add(Z.events.canplay$.subscribe(function(){ol||nt(Z,n.player.info.currentQuality$.getValue()),T&&Z.setPlaybackRate(T)}));let ge=e.createPlayer({listId:m.id,itemId:O,player:Z,container:L,sources:on(m,S).sources,config:ie,subscription:gn,statistics:bn});return b&&c(m.id,ge.itemId,p),I&&ge.player.play(),h&&!I&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}})}function C(){w(),i=null,l.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(),l=document.createElement("div");let{media:m,chapter:p}=i.getCurrentChapter();m&&p?(t.add(i.events.chapterChanged$.subscribe(y)),yield v({media:m,chapterId:p.id,title:p.label})):console.error("not found")})}return x(d({},e),{init:E,setInteractiveController:a,createPlayer:v,removeAll:C,getActivePlayer:function(){return n},activePlayerChanged:s})}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"},it={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},$={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ea=Q(rt(),1);import{Subscription as Bp}from"@vkontakte/videoplayer-shared/es2015";function ln(r){return function(...t){return r(...t.reverse())}}function ot(r,...e){return(...t)=>ue(e[0])&&ue(t[0])?r(d(d({},e[0]),t[0])):r(...e,...t)}var Qt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:l,globalEventEmitter:s,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:f,disabledControls$:y,onRemove:v,onError:C}){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:l}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&l)return;this.emitContainerVisibilityEvent(!0,!1)}else{let l={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:y,hasOpenURIEvent:v,hasOpenURIEventInCurrentContainer:C,isAllOpenURIEventsValid:w,hasShouldOpenNowEvent:E}=this.getContainerEventState(),m=this.interactiveTimeOpenUri&&!C,p=this.interactiveTimeOpenUri&&C;if((!this.interactiveTimeOpenUri||m)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||m)){if(this.interactiveTimeOpenUri){let h=!y&&!w&&C;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&v&&this.gameState!==5){if(p){let b=((I,S,g,T)=>!I&&!S&&g||I&&!S&&g&&!T||I&&!S&&g&&T)(f,y,w,this.isSelectedContainerEvent);this.fakeRemoveView(b)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!f||!y||!E)&&(this.selectBranches.stopExpect(),c())}},isEOV:()=>this.gameState===4},s=ot(this.selectBranches.onControlEvent,l);this.container.createView({eventCallback:s}),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,y;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,ea.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(qs(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(tn(o,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(),C=this.selectBranches.state.isExpect,w=this.interactiveTimeOpenUri&&v;if(w&&!C){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 l=tn(o,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,(y=this.container.container.endTime)!=null?y:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:o,isInteractiveTime:l};this.container.onProgress(o*1e3,l),this.globalEventEmitter.emit(k.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Bp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a,this.isPermanentText=c&&ke(t.container.controls),this.interactiveTimeOpenUri=f,this.disabledControls$=y,this.onRemove=v,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=l,this.onError=C,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:$.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:$.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:$.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 ta=(r=[])=>r.reduce((e,t,n)=>{var o,l,s;let i=((o=t==null?void 0:t.controls)!=null?o:[]).filter(a=>!Nt(a));if(Gt(i)){let a=[(l=t.startTime)!=null?l:0,(s=t.endTime)!=null?s:1/0],c={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:a});else{let f=[],y=-1/0,v=1/0,C=[],w=[];for(let E=0;E<e.length;E++){let m=e[E];if(w.push(...m.subjects),m.range[0]<v&&(v=m.range[0]),m.range[1]>y&&(y=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),C=C.concat(m.subjects)),a[0]>=m.range[0]&&a[0]<=m.range[1]&&(f.push(E),C=C.concat(m.subjects),a[0]=m.range[0]),a[1]>=m.range[0]&&a[1]<=m.range[1]&&(f.push(E),C=C.concat(m.subjects),a[1]=m.range[1])}if(w.push(c),a[0]<=v&&a[1]>=y)return[{subjects:w,range:a}];f.length&&f.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:C.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var $a=Q(rt(),1),hn=Q(Kt(),1),ja=Q(Na(),1);function La(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let a={};for(let c in r)+c<=s&&(a[c]=r[c]);return a}function n(s){let a={};for(let c in r)+c>=s&&(a[c]=r[c]);return a}function i({timestamp:s,priority:a,initiator:c}){var f;if(ar(s)){let y=(f=r[s])!=null?f:null;if(y&&a&&_e(a,!0)){let v={},C=y[a];if(C&&(v=d(d({},v),C)),v=he(v)?null:v,v&&_e(c,!0)){let w=v[c];return w!=null?w:null}return v}return y}return null}function o({timestamp:s,priority:a,initiator:c}){if(ar(s))if(r[s]){if(a&&_e(a,!0))if(r[s][a]){if(c&&_e(c,!0))if(r[s][a][c]){if(delete r[s][a][c],!he(r[s][a]))return!0}else return!1;if(delete r[s][a],!he(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function l(y){var v=y,{timestamp:s,priority:a,initiator:c}=v,f=J(v,["timestamp","priority","initiator"]);var C,w,E;(w=(C=r[s])==null?void 0:C[a])!=null&&w[c]?r[s][a][c].push(d({},f)):(E=r[s])!=null&&E[a]?r[s][a]=x(d({},r[s][a]),{[c]:[d({},f)]}):r[s]?r[s]=x(d({},r[s]),{[a]:{[c]:[d({},f)]}}):r[s]={[a]:{[c]:[d({},f)]}}}return{map:r,remove:o,add:l,removeAll:e,get:i,getLte:t,getGte:n}}var Rh=[V.expect,V.setNextBranch],kh=1/0;function _a(r,e){let t=r,n,i=Oh(e),o=La(),l,s=()=>{C(),p()},a=h=>{o.add.call(void 0,h),w()},c=(h=[])=>{for(let b of h)if(b.action(),(0,$a.default)(Rh,b.actionType))break},f=(h=1/0)=>{var g,T,H;let b=Yt((g=o.get({timestamp:h,priority:"control"}))!=null?g:{}),I=Yt((T=o.get({timestamp:h,priority:"container"}))!=null?T:{}),S=Yt((H=o.get({timestamp:h,priority:"chapter"}))!=null?H:{});return[...b,...I,...S]},y=h=>{i.isReady(h)&&c(f(h))},v=()=>{var h;c([...Yt((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},C=()=>{n&&(l==null||l.unsubscribe(),n=void 0)},w=()=>{n||(n=()=>setTimeout(()=>{y(1/0)}),l=t.events.ended$.subscribe(n))},E=h=>{C(),t=h},m=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),o.remove(h)},p=()=>{i.release(),o.removeAll()};return{setPlayer:E,add:a,remove:m,exec:y,execEndOfVideo:v,listen:w,unlisten:C,release:s,containersEventsCallState:i,getPreparedToExecActions:f}}function Oh(r){let e=new Map;return{setCalled:({timestamp:s,id:a})=>{let c=e.get(s);c&&c[a]!==void 0&&(c[a]=!0)},setData:(s=[])=>{var a;for(let c of s){let f=(a=c.endTime)!=null?a:kh,y=e.get(f);e.set(f,x(d({},y),{[c.id]:!1}))}},resetCalled:s=>{let a=e.get(s);if(a)for(let c in a)a[c]=!1},isReady:s=>{let a=e.get(s);if(!a)return!0;let c=(0,hn.default)(a);return r?c.some(y=>y):!c.some(y=>!y)},release:()=>e.clear()}}function Yt(r){return(0,ja.default)((0,hn.default)(r)).sort(e=>e.actionType===V.expect?-1:1)}var Fa={videoContentHeight:0,videoContentWidth:0},Ba=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Fa;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return Fa;let o=e/t,l=n/i,s,a;return l>o?(a=i,s=i*o):l<o?(a=n/o,s=n):(a=i,s=n),{videoContentWidth:a,videoContentHeight:s}};var Vh=250;function qa(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:a,player:c,cssVarsManager:f}=r();if(!a||!c)return;let{videoContentWidth:y,videoContentHeight:v}=Ba(c);f.setup({"--interactive-content-width":`${y}px`,"--interactive-content-height":`${v}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function i(){let{parentElement:s}=r();s.removeAttribute("style")}let o=Xe(s=>{let{fns:a=[]}=r();n(s);for(let c of a)c()},Vh);function l(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var Ph=r=>Math.floor(Math.random()*r),Ha=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let o=r[e],l=(i=o.weight)!=null?i:1;l<t&&(t=l,n=o)}return n},Ua=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let o=r[e],l=(i=o.weight)!=null?i:0;l>t&&(t=l,n=o)}return n};var Ga=r=>{let e=r.length,t=Ph(e);return r[t]},Da=1,za=r=>{var n,i;let e=0;for(let o=0;o<r.length;++o)e+=(n=r[o].weight)!=null?n:Da;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(i=r[o].weight)!=null?i:Da,e>=t)return r[o];return r[r.length-1]};var Wa={shouldOpenNow:!0,isDetachContainer:!0},Ka="after-expect",dn=(r,e=!1)=>x(d({},r),{args:e?d(d({},r.args),Wa):d(d({},Wa),r.args)}),Qa=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},l=({action:p,controlType:h,controlId:b,containerId:I,branches:S=[],onEvent:g,isEOV:T=()=>!1,isDisabled:H=()=>!1})=>{let O=dn(p,T()),L={timestamp:1/0,priority:"control",initiator:b,actionType:O.type},M=H(),F=r.emit.bind(r,k.interactives,{subjectId:b,subjectType:h,subjectName:"control",type:M?$.actionChoiceCanceled:$.actionChoice,actionType:p.type,payload:d({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)}),be=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:p.type,payload:d({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)})};if(M){F(),be();return}switch(O.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let ie=S.find(Z=>Z.id===O.args.branchId);if(!ie)return;g(O.args.isDetachContainer,C.bind(null,{subjectId:b,subjectName:"control"})),F(),be(),O.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:h,action:O,payload:{chapterId:ie.chapterId,autoSelect:!1}}):n.add(x(d({},L),{action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:O,payload:{chapterId:ie.chapterId,autoSelect:!1}})}));return}case V.continuePlayback.trim().toLowerCase():{g(O.args.isDetachContainer,C.bind(null,{subjectId:b,subjectName:"control"})),F(),be(),O.args.shouldOpenNow?w({subjectId:b,subjectName:"control",subjectType:h,action:p}):n.add(x(d({},L),{action:w.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:p})}));return}case V.openURI.trim().toLowerCase():{g(O.args.isDetachContainer,C.bind(null,{subjectId:b,subjectName:"control"})),F(),be(),O.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:h,action:O,payload:{URI:p.args.uri}}):n.add(x(d({},L),{action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:O,payload:{URI:p.args.uri}})}));return}default:{let ie="Unexpected control event",Z=new N(1,1,{message:ie});f(Z,ie);return}}},s=({action:p,container:{id:h,endTime:b},branches:I=[],isEOV:S=!1,autoSelected:g=!1})=>{let T=dn(p,S),H={timestamp:!T.args.shouldOpenNow||S?1/0:b!=null?b:1/0,priority:"container",initiator:h,actionType:T.type},O=r.emit.bind(r,k.interactives,{subjectId:h,subjectName:"container",type:$.actionChoice,actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)}),L=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)})};switch(T.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let M=I.find(F=>F.id===T.args.branchId);if(!M)return;O(),L(),n.add(x(d({},H),{action:E.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{chapterId:M.chapterId,autoSelect:g}})}));return}case V.setMaxWeightBranch.trim().toLowerCase():return;case V.setMinWeightBranch.trim().toLowerCase():return;case V.setRandomBranch.trim().toLowerCase():return;case V.setWeightlessRandomBranch.trim().toLowerCase():return;case V.continuePlayback.trim().toLowerCase():{O(),L(),n.add(x(d({},H),{action:w.bind(null,{subjectId:h,subjectName:"container",action:T})}));return}case V.openURI.trim().toLowerCase():{O(),L(),n.add(x(d({},H),{action:m.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{URI:p.args.uri}})}));return}default:{let M="Unexpected container event",F=new N(1,1,{message:M});f(F,M);return}}};function a({container:p,branches:h,isEOV:b=!1}){var S,g;let I=rn(p.events);if(I){let T=dn(I.action,b);r.emit(k.interactives,{subjectId:p.id,subjectName:"container",type:$.actionChoice,actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:d({invokeImmediately:T.args.shouldOpenNow},T.args)}),n.add({timestamp:b?1/0:(S=p.endTime)!=null?S:1/0,priority:"container",initiator:p.id,actionType:V.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),i.isExpect=!0}else for(let T of(g=p.events)!=null?g:[])s({action:T.action,container:p,branches:h,isEOV:b})}let c=({chapterId:p,action:h,branches:b=[]})=>{let I=r.emit.bind(r,k.interactives,{subjectId:p,subjectName:"chapter",type:$.actionChoice,actionType:h.type,payload:h.args}),S=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let g=b.find(T=>T.id===h.args.branchId);return g!=null&&g.chapterId?(I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case V.setWeightlessRandomBranch.trim().toLowerCase():{let g=Ga(b);return g!=null&&g.chapterId?(I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case V.setRandomBranch.trim().toLowerCase():{let g=za(b);return g!=null&&g.chapterId?(I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case V.setMaxWeightBranch.trim().toLowerCase():{let g=Ua(b);return g!=null&&g.chapterId?(I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case V.setMinWeightBranch.trim().toLowerCase():{let g=Ha(b);return g!=null&&g.chapterId?(I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case V.continuePlayback.trim().toLowerCase():return I(),S(),w.bind(null,{subjectId:p,subjectName:"chapter",action:h});case V.openURI.trim().toLowerCase():return I(),S(),m.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let g="Unexpected chapter event",T=new N(1,1,{message:g});f(T,g);return}}};function f(p,h){console.error(h),e.error$.next(p),r.emit(k.errors,p)}function y(p){var b;let h=rn(p.events);if(h){if(re(p))return;r.emit(k.interactives,{subjectId:p.id,subjectName:"chapter",type:$.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:V.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(b=p.events)==null||b.forEach(I=>{let S=c({chapterId:p.id,action:I.action,branches:p.branches});S&&n.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.action.type,action:S})})}let v=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(k.interactives,{subjectId:p,subjectName:h,type:$.actionExecution,actionType:V.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:V.expect})},C=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:p,subjectName:h,type:$.actionExecution,actionType:Ka}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:Ka})},w=({subjectId:p,subjectName:h,subjectType:b,action:I})=>{r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:b,type:$.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:S})=>{S.behaviour="change-chapter",r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:b,type:$.actionExecution,actionType:I.type,payload:S}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type,payload:S})},m=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:S})=>{if(!S.URI)return;let g=window.open(S.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:b,type:$.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:l,onContainerEvent:s,onChapterEvent:c,onExpectEvent:v,expectEventHandler:C,setManifestChapterEvents:y,setManifestContainerEvents:a,stopExpect:o,state:i}};var vn=Q(Gr(),1);import{Subscription as jh,Subject as fn,ValueSubject as at}from"@vkontakte/videoplayer-shared/es2015";var mn=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(l=>l.id===n);if(!i)return null;let o=e.media.videos.find(l=>i.videoId===l.id);if(!o)return null;t[n]=Xa(o)}return t[n]}).filter(Boolean)},Nh=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"),Xa=r=>{let e=Nh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},$h=(r,e)=>{for(let t of r.media.videos)if(e===Xa(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Ya=(r,e)=>r.reduce((t,n)=>{let i=$h(e,n);return i?[...t,i]:t},[]);var oe,fe,ve,K,Zt,se,ae,ne,ye,Pe,Me,lt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new at([]),hasPrevChapter$:new at(!1),prevChapter$:new at(null),isInitialChapter$:new at(!1),isGoBackLimited$:new at(!1)};G(this,oe,null);G(this,fe);G(this,ve,!1);G(this,K,null);G(this,Zt,null);this.events={inited$:new fn,destroyed$:new fn,error$:new fn};G(this,se,null);G(this,ae,null);G(this,ne,null);G(this,ye,new jh);G(this,Pe,!1);G(this,Me,0);var l;j(this,se,t),j(this,ne,e),j(this,ae,n),j(this,oe,i),j(this,fe,o),this.state.history$&&A(this,ye)&&((l=A(this,ye))==null||l.add(this.state.history$.subscribe(s=>{var a,c;this.state.prevChapter$.next((0,vn.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.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,Me)===A(this,fe).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!A(this,ae)||!A(this,ne))return;j(this,K,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield A(this,ae).setChapter({chapterId:t,pushToHistory:!1}),A(this,ve)||(j(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 s;if(!A(this,K))return;A(this,Pe)?(j(this,Pe,!1),On(this,Me)._++):j(this,Me,0);let n=A(this,K),i=e.length-A(this,fe).maxLength,o=i>0?e.slice(i):e,l=mn(o,n);if(j(this,Zt,l),this.state.history$.next(o),!(!t||!A(this,oe)||!A(this,se)))try{yield A(this,oe).save(A(this,se),l)}catch(a){let c=new N(1,5,"Unable to save interactive history");this.events.error$.next(c),(s=A(this,ne))==null||s.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)}j(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 l=new N(1,5,"Error while trying to fetch data");this.events.error$.next(l),(i=A(this,ne))==null||i.emit(k.errors,l)}let n=Ya(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,vn.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 mn([e],A(this,K)).pop()}return null}destroy(){var e,t;j(this,se,null),j(this,oe,null),j(this,ae,null),(e=A(this,ye))==null||e.unsubscribe(),j(this,ye,null),j(this,ve,!1),(t=A(this,ne))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),j(this,ne,null)}};oe=new WeakMap,fe=new WeakMap,ve=new WeakMap,K=new WeakMap,Zt=new WeakMap,se=new WeakMap,ae=new WeakMap,ne=new WeakMap,ye=new WeakMap,Pe=new WeakMap,Me=new WeakMap;var Jt=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 er=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,12 +11,12 @@ var rl=Object.create;var rr=Object.defineProperty,nl=Object.defineProperties,il=
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new Jt,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return R(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var n,i,o;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)==null?void 0:t.onError)==null||n.call(t,e)}};function
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return R(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var n,i,o;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)==null?void 0:t.onError)==null||n.call(t,e)}};function Za(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Ja=`/* interactive-container */
|
|
20
20
|
.interactive-container {
|
|
21
21
|
opacity: 1;
|
|
22
22
|
visibility: visible;
|
|
@@ -85,39 +85,6 @@ var rl=Object.create;var rr=Object.defineProperty,nl=Object.defineProperties,il=
|
|
|
85
85
|
animation: none;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/* control tap */
|
|
89
|
-
.interactive-control-tap {
|
|
90
|
-
position: absolute;
|
|
91
|
-
aspect-ratio: 1;
|
|
92
|
-
background-color: var(--interactive-bg-color-1);
|
|
93
|
-
border: 1px solid var(--interactive-color-1);
|
|
94
|
-
border-radius: 50%;
|
|
95
|
-
transition: opacity var(--interactive-transition-1);
|
|
96
|
-
opacity: 0;
|
|
97
|
-
pointer-events: none;
|
|
98
|
-
z-index: 1;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.interactive-control-tap-animation {
|
|
102
|
-
animation-duration: 300ms;
|
|
103
|
-
animation-iteration-count: 1;
|
|
104
|
-
animation-timing-function: ease;
|
|
105
|
-
animation-name: interactive-control-tap-bounce;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@keyframes interactive-control-tap-bounce {
|
|
109
|
-
0%, 100% {
|
|
110
|
-
transform: scale(1);
|
|
111
|
-
}
|
|
112
|
-
50% {
|
|
113
|
-
transform: scale(0.3);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.interactive-container:not(.interactive-container-disabled) .interactive-control-tap-visible {
|
|
118
|
-
opacity: 1;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
88
|
/* interactive-chapter */
|
|
122
89
|
.interactive-chapter {
|
|
123
90
|
position: absolute;
|
|
@@ -127,8 +94,6 @@ var rl=Object.create;var rr=Object.defineProperty,nl=Object.defineProperties,il=
|
|
|
127
94
|
|
|
128
95
|
--interactive-transition-1: 100ms ease-in-out;
|
|
129
96
|
--interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
130
|
-
--interactive-color-1: #fff;
|
|
131
|
-
--interactive-bg-color-1: rgba(255, 255, 255, 0.08);
|
|
132
97
|
--interactive-button-hover-opacity: 0.8;
|
|
133
98
|
--interactive-area-hover-opacity: 0;
|
|
134
99
|
}
|
|
@@ -181,4 +146,4 @@ var rl=Object.create;var rr=Object.defineProperty,nl=Object.defineProperties,il=
|
|
|
181
146
|
opacity: var(--interactive-area-hover-opacity);
|
|
182
147
|
animation: none;
|
|
183
148
|
}
|
|
184
|
-
`;var Xs=r=>{let e=document.createElement("style");e.textContent=Qs,r.prepend(e)};import{clientChecker as _h}from"@vkontakte/videoplayer-core/es2015";var Js=Object.freeze({lang:Lh.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}});function jh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var er=class{constructor(e){this.playerSubscriptions=new gn;this.subscriptions=new gn;this.globalEventEmitter=new jt;this.animation=new $t;this.seekToInteractiveController=new Xe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=jh();this.factories=new Map([["choice",Tt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new gn;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: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(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(a=>a.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({},Js),e),{config:d(d({},Js.config),e.config)}),(i=this._options.animationsFeatureToggles)==null?void 0:i.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 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:a=>{let l=new F(1,6,a);this.emitErrorEvent(l)}})),Xs(this._options.parentElement),this.subscriptions.add(Zs(this.rootElement,"mousedown").subscribe(a=>a.stopPropagation())).add(Zs(this.rootElement,"mouseup").subscribe(a=>a.stopPropagation())),this.manifestController=new Oe(this._options.loaders,a=>{let l=new F(1,3,a);this.emitErrorEvent(l)});let n=[];this._options.lastFrame&&n.push(()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}),n.push(()=>{let a=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(a)}),this.resizeManager=js(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Qe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:a=>{this.setChapter({chapterId:a}),this.globalEventEmitter.emit(k.graph,{type:rt.watchAgainClicked,chapterId:a}),this.events.watchAgainIsClicked$.next(a)},onError:a=>{let l=new F(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,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=un(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:_.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(Nh()).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(Mh({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var s;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=((s=this.player)==null?void 0:s.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=>!ke(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,s,c,m;let i=n.type.trim().toLowerCase(),o=this.factories.get(i),a=o==null?void 0:o(n,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:(m=this._options.animationsFeatureToggles)==null?void 0:m.controlsTapPlace}});if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let v=new Kt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>va(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(v.whilePlaying,!0),t.push(v)}}),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,s;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=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,a=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,el.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(a=>{let l=a.subjects.some(c=>c.id===e),s=a.subjects.map(c=>t&&l||c.id===e?x(d({},c),{isRemoved:!0}):c);return x(d({},a),{subjects:s})});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,a)=>{o.toggleBlinkAnimation(a)};zt(x(d({},e),{gameControllers:this.gameControllers,execFn:nt(pn(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:nt(pn(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=Ls(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Gs({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 s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&_h.browser.isSafari&&(yield Ks(35));let i=!n&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:o,media:a,graph:l}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&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(k.chapterChanged,{chapter:o,media:a,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new Ys(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?st.GRAPH_SHOW:st.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(st.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(st.NEXT_BUTTON),i==="Area"&&e.next(st.NEXT_AREA))}))}),nextMovie$:new Ys(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:rt.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&&Nt(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 Ya((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,a;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(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var $h={Container:ge,createChoiceContainer:Tt,createAreaControl:gt,createButtonControl:xt,classnamesPrefix:$n};var eC={version:Ln};export{Bf as ContainerTypes,_t as ControlTypes,F as CustomError,k as EVENT_NAMES,P as EventActionTypes,qf as EventTypes,er as Interactives,Oe as ManifestController,eC as SDKInfo,yn as chapterIdsToVKVideoIds,Zr as compareVersions,Lf as containerTypes,Nf as controlTypes,Jo as eventActionTypes,_f as eventTypes,Oh as getChapterIdByVkVideoId,zs as getVKVideoIdByMedia,Rh as getVideoRawIdByMedia,rt as graphEventTypes,Gt as hasEndTemplate,_ as interactivesEventTypes,Mf as isAreaControl,Vf as isButtonControl,re as isLastChapter,ke as isOneTextCtrlContainer,Nt as isSupportedManifest,Lt as isTextControl,kh as isVKVariantItem,Zo as isValidManifest,ea as migrateManifestToLatestVersion,$h as utils,Ws as vkVideoIdsToChapterIds};
|
|
149
|
+
`;var el=r=>{let e=document.createElement("style");e.textContent=Ja,r.prepend(e)};import{clientChecker as Dh}from"@vkontakte/videoplayer-core/es2015";var nl=Object.freeze({lang:Bh.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function Hh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var tr=class{constructor(e){this.playerSubscriptions=new yn;this.subscriptions=new yn;this.globalEventEmitter=new jt;this.animation=new _t;this.seekToInteractiveController=new Ze;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Hh();this.factories=new Map([["choice",St]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new yn;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=J(i,["statistics"]);if(t){let{statSubscription:o,oneStat:l}=t;o.add(l.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(l=>l.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var i,o,l;if(this._options=x(d(d({},nl),e),{config:d(d({},nl.config),e.config)}),(i=this._options.animationsFeatureToggles)==null?void 0:i.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new gt,this.blinkAnimationRef.create();let s=this.blinkAnimationRef.element;s&&this.rootElement.append(s)}this._options.parentElement.append(this.rootElement),this.historyController=new lt({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 er({parentElement:this._options.parentElement,onError:s=>{let a=new N(1,6,s);this.emitErrorEvent(a)}})),el(this._options.parentElement),this.subscriptions.add(rl(this.rootElement,"mousedown").subscribe(s=>s.stopPropagation())).add(rl(this.rootElement,"mouseup").subscribe(s=>s.stopPropagation())),this.manifestController=new Oe(this._options.loaders,s=>{let a=new N(1,3,s);this.emitErrorEvent(a)});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 a of this.gameControllers)a.onResize(s)}),this.cssVarsManager=new Ft((l=this._options)==null?void 0:l.parentElement),this.resizeManager=qa(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Ye({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(k.graph,{type:it.watchAgainClicked,chapterId:s}),this.events.watchAgainIsClicked$.next(s)},onError:s=>{let a=new N(1,2,{message:s});this.emitErrorEvent(a)}})),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=an(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:$.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(qh()).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(Fh({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:[y,v],subjects:C})=>y<c&&c<v&&C.some(w=>!w.isRemoved)&&C.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let o=!!this.noInteractionTimeout,s=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!o&&s?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!s&&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=>!ke(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),o=this.factories.get(i),l=o==null?void 0:o(n,this.rootElement,this.cssVarsManager);if(l&&this.selectBranches&&this.interactiveEvents&&this.player){let s=new Qt({player:this.player,container:l,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Hs(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(s.whilePlaying,!0),t.push(s)}}),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 s,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(s=n&&re(n)&&zt(n))!=null?s:!1,o=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,il.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(l=>{let s=l.subjects.some(c=>c.id===e),a=l.subjects.map(c=>t&&s||c.id===e?x(d({},c),{isRemoved:!0}):c);return x(d({},l),{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,l)=>{o.toggleBlinkAnimation(l)};Wt(x(d({},e),{gameControllers:this.gameControllers,execFn:ot(ln(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?Wt(x(d({},e),{gameControllers:this.gameControllers,execFn:ot(ln(t),!1)})):Wt(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=_a(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Qa({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&&Dh.browser.isSafari&&(yield Za(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:l,graph:s}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!l)&&(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:l}),this.globalEventEmitter.emit(k.chapterChanged,{chapter:o,media:l,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new tl(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?ct.GRAPH_SHOW:ct.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(ct.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(ct.NEXT_BUTTON),i==="Area"&&e.next(ct.NEXT_AREA))}))}),nextMovie$:new tl(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:it.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))})}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===V.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&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 ta((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,l;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(),(l=this.lastFrame)==null||l.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Uh={Container:Ce,createChoiceContainer:St,createAreaControl:Et,createButtonControl:Tt,classnamesPrefix:Mn};var hg={version:Vn};export{Uf as ContainerTypes,$t as ControlTypes,N as CustomError,k as EVENT_NAMES,V as EventActionTypes,Gf as EventTypes,tr as Interactives,Oe as ManifestController,hg as SDKInfo,mn as chapterIdsToVKVideoIds,Zr as compareVersions,_f as containerTypes,Ff as controlTypes,Xo as eventActionTypes,Bf as eventTypes,$h as getChapterIdByVkVideoId,Xa as getVKVideoIdByMedia,Nh as getVideoRawIdByMedia,it as graphEventTypes,zt as hasEndTemplate,$ as interactivesEventTypes,jf as isAreaControl,$f as isButtonControl,re as isLastChapter,ke as isOneTextCtrlContainer,Lt as isSupportedManifest,Nt as isTextControl,Lh as isVKVariantItem,Qo as isValidManifest,Yo as migrateManifestToLatestVersion,Uh as utils,Ya as vkVideoIdsToChapterIds};
|