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