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