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