@vkontakte/videoplayer-interactive 1.0.14 → 1.0.15-dev.cdca0fbd.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 +7 -7
- package/es2015.esm.js +7 -7
- package/es2018.cjs.js +7 -7
- package/es2018.esm.js +7 -7
- package/esnext.cjs.js +6 -6
- package/esnext.esm.js +6 -6
- package/evergreen.esm.js +6 -6
- package/package.json +3 -3
- package/types/modules/Interactives/Interactives.d.ts +3 -3
- package/types/modules/SeamlessController/SeamlessController.d.ts +2 -2
- package/types/modules/SeekToInteractiveController/SeekToInteractiveController.d.ts +9 -5
- package/types/movika.core/manifest/types.d.ts +4 -0
- package/types/types/CustomError.d.ts +13 -0
- package/types/types/dom.d.ts +1 -0
- package/types/types/index.d.ts +2 -0
- package/types/utils/Binding.d.ts +21 -17
- package/types/utils/Error.d.ts +6 -37
- package/types/utils/EventEmitter.d.ts +10 -10
- package/types/utils/EventManager.d.ts +10 -6
- package/types/utils/MultiMap.d.ts +7 -7
- package/types/utils/Raf.d.ts +7 -7
- package/types/utils/compareVersions.d.ts +14 -1
- package/types/utils/getVideoContentSize.d.ts +4 -3
- package/types/utils/throttle.d.ts +1 -0
- package/types/utils/typeCheck.d.ts +24 -20
package/es2015.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.15-dev.cdca0fbd.0
|
|
3
|
+
* Fri, 23 Aug 2024 12:57:37 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-15/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var to=Object.create;var Ze=Object.defineProperty,ro=Object.defineProperties,io=Object.getOwnPropertyDescriptor,no=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertyNames,Ct=Object.getOwnPropertySymbols,ao=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable;var vr=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))gr.call(e,r)&&vr(t,r,e[r]);if(Ct)for(var r of Ct(e))Li.call(e,r)&&vr(t,r,e[r]);return t},x=(t,e)=>ro(t,no(e));var Y=(t,e)=>{var r={};for(var i in t)gr.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&Ct)for(var i of Ct(t))e.indexOf(i)<0&&Li.call(t,i)&&(r[i]=t[i]);return r};var p=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oo=(t,e)=>{for(var r in e)Ze(t,r,{get:e[r],enumerable:!0})},ji=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of so(e))!gr.call(t,n)&&n!==r&&Ze(t,n,{get:()=>e[n],enumerable:!(i=io(e,n))||i.enumerable});return t};var Ni=(t,e,r)=>(r=t!=null?to(ao(t)):{},ji(e||!t||!t.__esModule?Ze(r,"default",{value:t,enumerable:!0}):r,t)),co=t=>ji(Ze({},"__esModule",{value:!0}),t);var F=(t,e,r)=>(vr(t,typeof e!="symbol"?e+"":e,r),r),br=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var a=(t,e,r)=>(br(t,e,"read from private field"),r?r.call(t):e.get(t)),C=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},g=(t,e,r,i)=>(br(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r);var Pi=(t,e,r,i)=>({set _(n){g(t,e,n,r)},get _(){return a(t,e,i)}}),k=(t,e,r)=>(br(t,e,"access private method"),r);var A=(t,e,r)=>new Promise((i,n)=>{var s=c=>{try{o(r.next(c))}catch(h){n(h)}},l=c=>{try{o(r.throw(c))}catch(h){n(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);o((r=r.apply(t,e)).next())});var oe=p((Sn,Tn)=>{"use strict";var Wt=function(t){return t&&t.Math==Math&&t};Tn.exports=Wt(typeof globalThis=="object"&&globalThis)||Wt(typeof window=="object"&&window)||Wt(typeof self=="object"&&self)||Wt(typeof global=="object"&&global)||function(){return this}()||Sn||Function("return this")()});var ge=p((qd,wn)=>{"use strict";wn.exports=function(t){try{return!!t()}catch(e){return!0}}});var ht=p((Dd,_n)=>{"use strict";var No=ge();_n.exports=!No(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var On=p((Hd,Mn)=>{"use strict";var Po=ht(),An=Function.prototype,Rn=An.apply,Vn=An.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(Po?Vn.bind(Rn):function(){return Vn.apply(Rn,arguments)})});var Ve=p((Gd,Nn)=>{"use strict";var Ln=ht(),jn=Function.prototype,Dr=jn.call,ko=Ln&&jn.bind.bind(Dr,Dr);Nn.exports=Ln?ko:function(t){return function(){return Dr.apply(t,arguments)}}});var Hr=p((Ud,kn)=>{"use strict";var Pn=Ve(),$o=Pn({}.toString),Fo=Pn("".slice);kn.exports=function(t){return Fo($o(t),8,-1)}});var Gr=p((zd,$n)=>{"use strict";var Bo=Hr(),qo=Ve();$n.exports=function(t){if(Bo(t)==="Function")return qo(t)}});var zr=p((Wd,Fn)=>{"use strict";var Ur=typeof document=="object"&&document.all,Do=typeof Ur=="undefined"&&Ur!==void 0;Fn.exports={all:Ur,IS_HTMLDDA:Do}});var be=p((Kd,qn)=>{"use strict";var Bn=zr(),Ho=Bn.all;qn.exports=Bn.IS_HTMLDDA?function(t){return typeof t=="function"||t===Ho}:function(t){return typeof t=="function"}});var He=p((Qd,Dn)=>{"use strict";var Go=ge();Dn.exports=!Go(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})});var Qt=p((Yd,Hn)=>{"use strict";var Uo=ht(),Kt=Function.prototype.call;Hn.exports=Uo?Kt.bind(Kt):function(){return Kt.apply(Kt,arguments)}});var Wn=p(zn=>{"use strict";var Gn={}.propertyIsEnumerable,Un=Object.getOwnPropertyDescriptor,zo=Un&&!Gn.call({1:2},1);zn.f=zo?function(e){var r=Un(this,e);return!!r&&r.enumerable}:Gn});var Wr=p((Zd,Kn)=>{"use strict";Kn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var Yn=p((Jd,Qn)=>{"use strict";var Wo=Ve(),Ko=ge(),Qo=Hr(),Kr=Object,Yo=Wo("".split);Qn.exports=Ko(function(){return!Kr("z").propertyIsEnumerable(0)})?function(t){return Qo(t)=="String"?Yo(t,""):Kr(t)}:Kr});var Qr=p((ep,Xn)=>{"use strict";Xn.exports=function(t){return t==null}});var Yr=p((tp,Zn)=>{"use strict";var Xo=Qr(),Zo=TypeError;Zn.exports=function(t){if(Xo(t))throw Zo("Can't call method on "+t);return t}});var es=p((rp,Jn)=>{"use strict";var Jo=Yn(),ec=Yr();Jn.exports=function(t){return Jo(ec(t))}});var ut=p((ip,is)=>{"use strict";var ts=be(),rs=zr(),tc=rs.all;is.exports=rs.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:ts(t)||t===tc}:function(t){return typeof t=="object"?t!==null:ts(t)}});var Xr=p((np,ns)=>{"use strict";ns.exports={}});var ei=p((sp,as)=>{"use strict";var Zr=Xr(),Jr=oe(),rc=be(),ss=function(t){return rc(t)?t:void 0};as.exports=function(t,e){return arguments.length<2?ss(Zr[t])||ss(Jr[t]):Zr[t]&&Zr[t][e]||Jr[t]&&Jr[t][e]}});var cs=p((ap,os)=>{"use strict";var ic=Ve();os.exports=ic({}.isPrototypeOf)});var hs=p((op,ls)=>{"use strict";ls.exports=typeof navigator!="undefined"&&String(navigator.userAgent)||""});var vs=p((cp,ys)=>{"use strict";var ms=oe(),ti=hs(),us=ms.process,ds=ms.Deno,ps=us&&us.versions||ds&&ds.version,fs=ps&&ps.v8,ie,Yt;fs&&(ie=fs.split("."),Yt=ie[0]>0&&ie[0]<4?1:+(ie[0]+ie[1]));!Yt&&ti&&(ie=ti.match(/Edge\/(\d+)/),(!ie||ie[1]>=74)&&(ie=ti.match(/Chrome\/(\d+)/),ie&&(Yt=+ie[1])));ys.exports=Yt});var ri=p((lp,bs)=>{"use strict";var gs=vs(),nc=ge(),sc=oe(),ac=sc.String;bs.exports=!!Object.getOwnPropertySymbols&&!nc(function(){var t=Symbol();return!ac(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&gs&&gs<41})});var ii=p((hp,Es)=>{"use strict";var oc=ri();Es.exports=oc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ni=p((up,Cs)=>{"use strict";var cc=ei(),lc=be(),hc=cs(),uc=ii(),dc=Object;Cs.exports=uc?function(t){return typeof t=="symbol"}:function(t){var e=cc("Symbol");return lc(e)&&hc(e.prototype,dc(t))}});var Is=p((dp,xs)=>{"use strict";var pc=String;xs.exports=function(t){try{return pc(t)}catch(e){return"Object"}}});var si=p((pp,Ss)=>{"use strict";var fc=be(),mc=Is(),yc=TypeError;Ss.exports=function(t){if(fc(t))return t;throw yc(mc(t)+" is not a function")}});var ws=p((fp,Ts)=>{"use strict";var vc=si(),gc=Qr();Ts.exports=function(t,e){var r=t[e];return gc(r)?void 0:vc(r)}});var Rs=p((mp,_s)=>{"use strict";var ai=Qt(),oi=be(),ci=ut(),bc=TypeError;_s.exports=function(t,e){var r,i;if(e==="string"&&oi(r=t.toString)&&!ci(i=ai(r,t))||oi(r=t.valueOf)&&!ci(i=ai(r,t))||e!=="string"&&oi(r=t.toString)&&!ci(i=ai(r,t)))return i;throw bc("Can't convert object to primitive value")}});var As=p((yp,Vs)=>{"use strict";Vs.exports=!0});var Ls=p((vp,Os)=>{"use strict";var Ms=oe(),Ec=Object.defineProperty;Os.exports=function(t,e){try{Ec(Ms,t,{value:e,configurable:!0,writable:!0})}catch(r){Ms[t]=e}return e}});var Ps=p((gp,Ns)=>{"use strict";var Cc=oe(),xc=Ls(),js="__core-js_shared__",Ic=Cc[js]||xc(js,{});Ns.exports=Ic});var Fs=p((bp,$s)=>{"use strict";var Sc=As(),ks=Ps();($s.exports=function(t,e){return ks[t]||(ks[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:Sc?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var li=p((Ep,Bs)=>{"use strict";var Tc=Yr(),wc=Object;Bs.exports=function(t){return wc(Tc(t))}});var Xt=p((Cp,qs)=>{"use strict";var _c=Ve(),Rc=li(),Vc=_c({}.hasOwnProperty);qs.exports=Object.hasOwn||function(e,r){return Vc(Rc(e),r)}});var Hs=p((xp,Ds)=>{"use strict";var Ac=Ve(),Mc=0,Oc=Math.random(),Lc=Ac(1 .toString);Ds.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Lc(++Mc+Oc,36)}});var zs=p((Ip,Us)=>{"use strict";var jc=oe(),Nc=Fs(),Gs=Xt(),Pc=Hs(),kc=ri(),$c=ii(),Ge=jc.Symbol,hi=Nc("wks"),Fc=$c?Ge.for||Ge:Ge&&Ge.withoutSetter||Pc;Us.exports=function(t){return Gs(hi,t)||(hi[t]=kc&&Gs(Ge,t)?Ge[t]:Fc("Symbol."+t)),hi[t]}});var Ys=p((Sp,Qs)=>{"use strict";var Bc=Qt(),Ws=ut(),Ks=ni(),qc=ws(),Dc=Rs(),Hc=zs(),Gc=TypeError,Uc=Hc("toPrimitive");Qs.exports=function(t,e){if(!Ws(t)||Ks(t))return t;var r=qc(t,Uc),i;if(r){if(e===void 0&&(e="default"),i=Bc(r,t,e),!Ws(i)||Ks(i))return i;throw Gc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Dc(t,e)}});var ui=p((Tp,Xs)=>{"use strict";var zc=Ys(),Wc=ni();Xs.exports=function(t){var e=zc(t,"string");return Wc(e)?e:e+""}});var ea=p((wp,Js)=>{"use strict";var Kc=oe(),Zs=ut(),di=Kc.document,Qc=Zs(di)&&Zs(di.createElement);Js.exports=function(t){return Qc?di.createElement(t):{}}});var pi=p((_p,ta)=>{"use strict";var Yc=He(),Xc=ge(),Zc=ea();ta.exports=!Yc&&!Xc(function(){return Object.defineProperty(Zc("div"),"a",{get:function(){return 7}}).a!=7})});var na=p(ia=>{"use strict";var Jc=He(),el=Qt(),tl=Wn(),rl=Wr(),il=es(),nl=ui(),sl=Xt(),al=pi(),ra=Object.getOwnPropertyDescriptor;ia.f=Jc?ra:function(e,r){if(e=il(e),r=nl(r),al)try{return ra(e,r)}catch(i){}if(sl(e,r))return rl(!el(tl.f,e,r),e[r])}});var aa=p((Vp,sa)=>{"use strict";var ol=ge(),cl=be(),ll=/#|\.prototype\./,dt=function(t,e){var r=ul[hl(t)];return r==pl?!0:r==dl?!1:cl(e)?ol(e):!!e},hl=dt.normalize=function(t){return String(t).replace(ll,".").toLowerCase()},ul=dt.data={},dl=dt.NATIVE="N",pl=dt.POLYFILL="P";sa.exports=dt});var la=p((Ap,ca)=>{"use strict";var oa=Gr(),fl=si(),ml=ht(),yl=oa(oa.bind);ca.exports=function(t,e){return fl(t),e===void 0?t:ml?yl(t,e):function(){return t.apply(e,arguments)}}});var ua=p((Mp,ha)=>{"use strict";var vl=He(),gl=ge();ha.exports=vl&&gl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42})});var pa=p((Op,da)=>{"use strict";var bl=ut(),El=String,Cl=TypeError;da.exports=function(t){if(bl(t))return t;throw Cl(El(t)+" is not an object")}});var ya=p(ma=>{"use strict";var xl=He(),Il=pi(),Sl=ua(),Zt=pa(),fa=ui(),Tl=TypeError,fi=Object.defineProperty,wl=Object.getOwnPropertyDescriptor,mi="enumerable",yi="configurable",vi="writable";ma.f=xl?Sl?function(e,r,i){if(Zt(e),r=fa(r),Zt(i),typeof e=="function"&&r==="prototype"&&"value"in i&&vi in i&&!i[vi]){var n=wl(e,r);n&&n[vi]&&(e[r]=i.value,i={configurable:yi in i?i[yi]:n[yi],enumerable:mi in i?i[mi]:n[mi],writable:!1})}return fi(e,r,i)}:fi:function(e,r,i){if(Zt(e),r=fa(r),Zt(i),Il)try{return fi(e,r,i)}catch(n){}if("get"in i||"set"in i)throw Tl("Accessors not supported");return"value"in i&&(e[r]=i.value),e}});var ga=p((jp,va)=>{"use strict";var _l=He(),Rl=ya(),Vl=Wr();va.exports=_l?function(t,e,r){return Rl.f(t,e,Vl(1,r))}:function(t,e,r){return t[e]=r,t}});var Ca=p((Np,Ea)=>{"use strict";var Jt=oe(),Al=On(),Ml=Gr(),Ol=be(),Ll=na().f,jl=aa(),Ue=Xr(),Nl=la(),ze=ga(),ba=Xt(),Pl=function(t){var e=function(r,i,n){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,i)}return new t(r,i,n)}return Al(t,this,arguments)};return e.prototype=t.prototype,e};Ea.exports=function(t,e){var r=t.target,i=t.global,n=t.stat,s=t.proto,l=i?Jt:n?Jt[r]:(Jt[r]||{}).prototype,o=i?Ue:Ue[r]||ze(Ue,r,{})[r],c=o.prototype,h,m,S,v,I,T,V,_,f;for(v in e)h=jl(i?v:r+(n?".":"#")+v,t.forced),m=!h&&l&&ba(l,v),T=o[v],m&&(t.dontCallGetSet?(f=Ll(l,v),V=f&&f.value):V=l[v]),I=m&&V?V:e[v],!(m&&typeof T==typeof I)&&(t.bind&&m?_=Nl(I,Jt):t.wrap&&m?_=Pl(I):s&&Ol(I)?_=Ml(I):_=I,(t.sham||I&&I.sham||T&&T.sham)&&ze(_,"sham",!0),ze(o,v,_),s&&(S=r+"Prototype",ba(Ue,S)||ze(Ue,S,{}),ze(Ue[S],v,I),t.real&&c&&(h||!c[v])&&ze(c,v,I)))}});var Ia=p((Pp,xa)=>{"use strict";var kl=Math.ceil,$l=Math.floor;xa.exports=Math.trunc||function(e){var r=+e;return(r>0?$l:kl)(r)}});var gi=p((kp,Sa)=>{"use strict";var Fl=Ia();Sa.exports=function(t){var e=+t;return e!==e||e===0?0:Fl(e)}});var wa=p(($p,Ta)=>{"use strict";var Bl=gi(),ql=Math.min;Ta.exports=function(t){return t>0?ql(Bl(t),9007199254740991):0}});var Ra=p((Fp,_a)=>{"use strict";var Dl=wa();_a.exports=function(t){return Dl(t.length)}});var Aa=p((Bp,Va)=>{"use strict";Va.exports=function(){}});var Ma=p(()=>{"use strict";var Hl=Ca(),Gl=li(),Ul=Ra(),zl=gi(),Wl=Aa();Hl({target:"Array",proto:!0},{at:function(e){var r=Gl(this),i=Ul(r),n=zl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:r[s]}});Wl("at")});var La=p((Hp,Oa)=>{"use strict";var Kl=ei();Oa.exports=Kl});var Na=p((Gp,ja)=>{"use strict";Ma();var Ql=La();ja.exports=Ql("Array","at")});var ka=p((Up,Pa)=>{"use strict";var Yl=Na();Pa.exports=Yl});var Fa=p((zp,$a)=>{"use strict";var Xl=ka();$a.exports=Xl});var eh={};oo(eh,{CustomError:()=>R,EVENT_NAMES:()=>b,INTERACTIVE_CLICK_ACTIONS:()=>kt,Interactives:()=>yt,ManifestController:()=>Re,SDKInfo:()=>Jl,chapterIdsToVKVideoIds:()=>er,compareVersions:()=>ae,getChapterIdByVkVideoId:()=>Da,getVKVideoIdByMedia:()=>bi,getVideoRawIdByMedia:()=>Ba,graphEventTypes:()=>De,hasEndTemplate:()=>at,interactivesEventTypes:()=>M,isLastChapter:()=>se,isSupportedManifest:()=>nt,isVKVariantItem:()=>qa,utils:()=>Ja,vkVideoIdsToChapterIds:()=>Ei});module.exports=co(eh);var ki="1.0.14";function Er(t,e=1){let r="0",i="0",n="0";return t.length===4?(r="0x"+t[1]+t[1],i="0x"+t[2]+t[2],n="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],i="0x"+t[3]+t[4],n="0x"+t[5]+t[6]),`rgba(${+r},${+i},${+n},${e})`}var G="SDK_NAME",lo="SDK_NAME-controls-container",xt=()=>document.querySelector(`.${lo}`),qi=.4,X={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},$i={top:"flex-start",bottom:"flex-end",center:"center"},Fi={start:"flex-start",end:"flex-end",center:"center"},Bi={start:"left",end:"right",center:"center"},It=({target:t,props:e})=>{var r,i,n,s,l,o;t.style.alignItems=(i=$i[(r=e==null?void 0:e.text)==null?void 0:r.gravityVertical])!=null?i:$i.center,t.style.justifyContent=(s=Fi[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:Fi.center,t.style.textAlign=(o=Bi[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?o:Bi.start},St=({target:t,props:e,fallback:r,dependsOn:i})=>{var n,s,l,o,c,h;t.style.color=(s=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?s:r.textColor,t.style.fontSize=`calc(${i.height} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:r.textSize})`,t.textContent=(h=(c=e==null?void 0:e.text)==null?void 0:c.value)!=null?h:r.textContent},Tt=({target:t,props:e,fallback:r})=>{var i,n,s,l;t.style.backgroundColor=Er((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:r.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:r.backgroundAlpha)},wt=({target:t,props:e,fallback:r,dependsOn:i})=>{var n,s,l,o,c,h,m,S,v,I,T;t.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:r.borderWidth}) solid ${Er((h=(c=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:c.color)!=null?h:r.borderColor,(v=(S=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:S.alpha)!=null?v:r.borderAlpha)}`,t.style.borderRadius=`calc(${i.height} * ${(T=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?T:r.roundCorners})`},ke=({target:t,layoutParams:e,fallback:r})=>{t.style.transform=`rotate(${-e.angle}rad)`};var Cr="int",$e={AREA:`${Cr}_area`,TEXT:`${Cr}_text`,BUTTON:`${Cr}_bttn`};var ve=class{constructor(e){this.control=e}createView(e){var n;let r=document.createElement("div");r.classList.add(`${G}-control-container-${this.control.id}`),e(r,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:X.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:r,dependsOn:i}}setEvents(e,r){e&&this.control.events.forEach(i=>{switch(i.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),r&&r({action:i.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${G}-control-container-${this.control.id}`)}};var _t=t=>{if(t.type.trim().toLowerCase()==="area")return new xr(t)},xr=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("button");return s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",$e.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",Tt({target:s,props:this.control.props,fallback:x(d({},X),{backgroundColor:"transparent"})}),wt({target:s,props:this.control.props,fallback:x(d({},X),{borderAlpha:0}),dependsOn:i}),ke({target:s,layoutParams:this.control.layoutParams,fallback:X}),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Rt=()=>{let t=document.createElement("span");return t.style.display="inline-block",t.style.whiteSpace="pre",t.style.overflow="hidden",t.style.textOverflow="ellipsis",t.style.maxWidth="100%",t.style.maxHeight="100%",t};var Vt=t=>{if(t.type.trim().toLowerCase()==="button")return new Ir(t)},Ir=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("button");s.type="button",s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",$e.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=Rt();return ke({target:s,layoutParams:this.control.layoutParams,fallback:X}),Tt({target:s,props:this.control.props,fallback:X}),wt({target:s,props:this.control.props,fallback:X,dependsOn:i}),It({target:s,props:this.control.props}),St({target:l,props:this.control.props,fallback:X,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Di=t=>{if(t.type.trim().toLowerCase()==="text")return new Sr(t)},Sr=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("div");s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",$e.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=Rt();return ke({target:s,layoutParams:this.control.layoutParams,fallback:X}),It({target:s,props:this.control.props}),St({target:l,props:this.control.props,fallback:X,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){}enable(){}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Tr=class{constructor(e){this.layout=e}},Hi=t=>{if(t.type.trim().toLowerCase()==="relative")return new Je(t)},Je=class extends Tr{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,r){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${r.width})`,e.style.height=`calc(var(--interactive-content-height) * ${r.height})`,e.style.left=`calc(var(--interactive-content-width) * ${r.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${r.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var Fe,At,Mt,Gi,Be=class{constructor(e){C(this,Fe);C(this,Mt);this.container=e,this.factories=new Map,k(this,Fe,At).call(this)}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),k(this,Fe,At).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),k(this,Fe,At).call(this)}};Fe=new WeakSet,At=function(){this.controls=k(this,Mt,Gi).call(this)},Mt=new WeakSet,Gi=function(){var e;return(e=this.container.controls)==null?void 0:e.reduce((r,i)=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...r,s(i)]:[...r]},[])};var Ot=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new wr(t,e)},wr=class extends Be{constructor(e,r){super(e),this.rootElement=r!=null?r:xt(),this.layout=new Je(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Vt),this.addControlFactory("text",Di),this.addControlFactory("area",_t)}createView(e){let r=document.createElement("div");return r.classList.add(`${G}-${this.container.id}`),this.layout.setContainerLayout(r),this.controls.forEach(i=>{let n=i.createView({parent:r,layoutFn:this.layout.setControlLayout});i.setEvents(n,e)}),this.rootElement.append(r),this.isRemoved=!1,r}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(r=>r.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(r=>r.disable()),e.style.opacity=qi,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${G}-${this.container.id}`)}};var $=require("@vkontakte/videoplayer-shared");var Qi=require("@vkontakte/videoplayer-shared");function Lt(t,e){let r;return(...i)=>{clearTimeout(r),r=setTimeout(()=>t(...i),e)}}var et={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},Te=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,tt=t=>Te(t,et.Object),jt=t=>Te(t,et.String),Nt=t=>Te(t,et.Array),Pt=t=>Te(t,et.Number),Ui=t=>Te(t,et.Function);var _r=t=>Pt(t)&&!isNaN(t);var we=t=>tt(t)&&Object.keys(t).length===0,Rr=t=>Nt(t)&&!t.length;var rt=(t,e)=>jt(t)&&(e?t.trim():t).length;var Vr=window.navigator.userAgent.toLowerCase(),Hh=/ipad|iphone|ipod/.test(Vr),zi=/mobi/i.test(Vr),Gh=Vr.indexOf("android")>-1&&zi,ho=!zi,Uh=window.safari!==void 0&&ho;var Wi="video_interactive",Ki="videoint";var uo=250,it=class{constructor(e){F(this,"onResize",e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))});F(this,"handleChapterChange",e=>{var r;if(this.isReady){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(r=this.onError)==null||r.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor.selectChapter(e.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=void 0}});F(this,"handleManifestChange",(i,...n)=>A(this,[i,...n],function*(e,r=[]){var s;if(!Pt(e.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)==null||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let l;try{l=yield(0,Qi.loadVKLangPack)(this.lang,Wi,Ki)}catch(c){console.log("Unable to load graph language pack")}let{GraphEditor:o}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new o(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:l}),this.ngEditor.on("control",({name:c,chapterId:h})=>{c==="openPreview"&&this.onOpenPreviewClick(h)}),this.ngEditor.on("zoomEnd",c=>{this.lastZoomInfo=d({},c)})}this.visitedChapterIds=new Set(r),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}));this.init(e)}init({root:e,onOpenPreviewClick:r,onError:i,lang:n,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=r,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=po(e),this.resizeObserver=new ResizeObserver(Lt(this.onResize,uo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,r;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(r=this.ngEditor)==null||r.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function po(t){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",t.append(e),e}var Ar=()=>{let t=[],e=null;return{setPlayer:l=>{e=l},setContainers:l=>{t=l},deleteContainer:l=>{t=t.filter(o=>o.id!==l)},getNextInteractiveTime:(l=3e3)=>{if(!t.length||e===null)return null;let o=-1,c=!1,h=Math.round(e.info.position$.getValue()*1e3);for(let m of t){let S=m.startTime-l;if(S<=h&&(h<=m.endTime||m.endTime===null)){c=!0;break}h<S&&(o=o===-1?S:Math.min(o,S))}return!c&&o!==-1?o:null}}};var ae=(t="",e="")=>{t=t.split("."),e=e.split(".");let r=0;for(let i=0;i<Math.max(t.length,e.length)&&!r;i++)t[i]>e[i]?r=1:t[i]<e[i]?r=-1:r=0;return r};var Xi=require("uuid");var fo="3.1",Yi={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},mo={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Zi=t=>{let e=[];for(let l of t.chapters){let o,c=[];for(let r of l.branches){let i=r,{isDefault:S}=i,v=Y(i,["isDefault"]);S&&(o=v.id),c.push(v)}let h=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:S}=s,v=Y(s,["fallbackStrategy"]);let I=!!v.endTime,T=[mo];switch(S){case"await":I?T=[]:h=[];break;case"default":{let V={type:"onSuspense",action:{type:Yi.default,args:{branchId:o,shouldOpenNow:!I,isDetachContainer:!0}}};I?T=[V]:h=[V];break}case"random":case"weightlessRandom":case"max":case"min":{let V={type:"onSuspense",action:{type:Yi[S],args:{}}};I?T=[V]:h=[V];break}}for(let V of v.controls)m.push(x(d({},v),{controls:[d({},V)],id:(0,Xi.v4)(),events:T}))}e.push(x(d({},l),{containers:m,events:h,branches:c}))}return t.metadata.version=fo,t.metadata.updated=new Date().toISOString(),x(d({},t),{chapters:e})};var yo="3.2",Ji=t=>{if(!t.media){let e=t.metadata,{media:r}=e,i=Y(e,["media"]);return x(d({},t),{metadata:x(d({},i),{version:yo}),media:r})}return t};var vo="3.3",go=(t=[])=>({edit:{chapters:t},view:{}}),en={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},tn=t=>{var n;let e=[],r=[];for(let s of t.chapters){let i=s,{id:l,x:o,y:c}=i,h=Y(i,["id","x","y"]),m=h.containers.map(S=>{var v;return x(d({},S),{controls:S.controls.map(_=>{var f=_,{subtype:I,type:T}=f,V=Y(f,["subtype","type"]);return x(d({},V),{type:I!=null?I:T})}),events:(v=S.events)!=null&&v.length?S.events:[en]})});e.push(x(d({id:l},h),{containers:m,events:(n=h.events)!=null&&n.length?h.events:[en]})),r.push({id:l,x:o,y:c})}return x(d({},t),{chapters:e,graph:go(r),metadata:x(d({},t.metadata),{version:vo})})};var bo=[{version:"3.0",migrate:Zi},{version:"3.1",migrate:Ji},{version:"3.2",migrate:tn}],Mr=t=>bo.reduce((e,r)=>ae(e.metadata.version,r.version)?e:r.migrate(e),t);var gu=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),rn=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),bu=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),P=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),kt=(s=>(s.GO_NEXT_BUTTON="GO_NEXT_BUTTON",s.GO_NEXT_AREA="GO_NEXT_AREA",s.WATCH_AGAIN="WATCH_AGAIN",s.OPEN_GRAPH="OPEN_GRAPH",s.CLOSE_GRAPH="CLOSE_GRAPH",s))(kt||{});var nn={metadata:"Object",chapters:"Array"},Eo="3.0.0",Co="3.3.0",nt=t=>{let e=ae(t,Eo);return e===-1?!1:e===0?!0:ae(t,Co)!==1},sn=t=>{if(!tt(t))return!1;for(let e in nn)if(!t[e]||!Te(t[e],nn[e]))return!1;return nt(t.metadata.version)},$t=t=>t.type===rn.Text;var R=class{constructor(e,r,...i){this.severity=e,this.category=r,this.data=i}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}};F(R,"Severity",{RECOVERABLE:1,CRITICAL:2}),F(R,"Category",{VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6});var qe=class{constructor(){F(this,"listeners",{})}addListener(e,r){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(r),this}on(e,r){return this.addListener(e,r)}once(e,r){this.listeners[e]=this.listeners[e]||[];let i=()=>{r(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let i=this.listeners[e];if(!i)return this;for(let n=i.length;n>0;n--)if(i[n]===r){i.splice(n,1);break}return this}emit(e,...r){let i=this.listeners[e];return i?(i.forEach(n=>{n(...r)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}};var Ft=class{constructor(e){F(this,"addFn",(e,r=!1)=>{Ui(e)&&(this.fns.push(e),r&&this.updateFn())});F(this,"removeFn",(e,r=!1)=>{this.fns=this.fns.filter(i=>i!==e),r&&this.updateFn()});F(this,"updateFn",()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}});F(this,"forceRequestAnimation",()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))});F(this,"requestAnimation",()=>{this.raf||this.forceRequestAnimation()});F(this,"cancelAnimation",()=>{cancelAnimationFrame(this.raf),this.raf=void 0});this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var hn=require("@vkontakte/videoplayer-shared");var Bt=class{constructor(e){var r,i;this.loaders={chapterLoaders:(r=e==null?void 0:e.chapterLoaders)!=null?r:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,r){return A(this,null,function*(){return xo(...this.loaders[e])(r)})}};function xo(...t){return function(r){return A(this,null,function*(){let i=[...t];for(;i.length>0;)r=yield i.shift()(r);return r})}}function st(t,e,r){return t?x(d({},t),{[e]:t[e]?[r,...t[e]]:[r]}):{[e]:[r]}}function qt(n){var s=n,{actions:t,errors:e,chapterId:r}=s,i=Y(s,["actions","errors","chapterId"]);if(r){let l=t.getManifest(),o=t.getChapter(l.chapters,r);if(o){let c=t.getMedia(l.media,o.videoId),h=t.getGraph(l.graph,o.id);return c?x(d({},i),{actions:t,errors:e,result:{chapter:o,media:c,graph:h}}):x(d({},i),{errors:st(e,qt.name,"Could not find media"),actions:t})}}return x(d({},i),{errors:st(e,qt.name,"Could not find chapter"),actions:t})}var Io=t=>A(void 0,null,function*(){try{let e,r;if(tt(t))e=t;else if(jt(t)){r=new URL(t).href;let n=yield fetch(r);if(!n.ok)return{};e=yield n.json()}else return{};if(!sn(e))return{};let i=e.metadata.media;if(jt(i)&&!e.media)try{let n;r?n=new URL(i,r).href:(n=new URL(i).href,r=n);let s=yield fetch(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return wo(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch(e){return{}}});function an(t){return A(this,null,function*(){let{manifest:e,manifestURL:r}=yield Io(t),i=Mr(e);return i.media=So(i.media,r),delete i.metadata.media,i})}function Dt(t,e){return t.find(r=>r.id===e)}function Or(t,e){var r,i;return(r=t.edit)!=null&&r.chapters?t.edit.chapters.find(n=>n.id===e):(i=t.view)!=null&&i.chapters?t.view.chapters.find(n=>n.id===e):void 0}function Lr(t,e){return t.videos.find(r=>r.id===e)}function So(t,e){return x(d({},t),{videos:t.videos.map(r=>x(d({},r),{variants:r.variants.map(i=>{let n=To(i.url,e);return x(d({},i),{url:n||i.url})})}))})}function To(t,e){try{return new URL(t,e).href}catch(r){return""}}function wo(t){return ae(t,"3.2.0")>=0}var D=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Ht=t=>Nt(t)&&!Rr(t),se=t=>t.order==="end",at=t=>Nt(t.containers)&&!Rr(t.containers)&&se(t),on=(t,e)=>{var i;let r=t*1e3;return Ht(e.controls)&&r<((i=e.startTime)!=null?i:0)},jr=(t,e)=>{var i,n;let r=t*1e3;return Ht(e.controls)&&r>=((i=e.startTime)!=null?i:0)&&r<=((n=e.endTime)!=null?n:1/0)};var _e=t=>t.some(e=>e.action.type==="expect"),Nr=t=>t.find(e=>e.action.type==="expect"),_o=t=>(t==null?void 0:t.length)===1,Gt=t=>_o(t)&&$t(t[0]);var cn=({fn:t,type:e=1},...r)=>(...i)=>e?t(...i,...r):t(d(d({},i[e]),r[e])),ln=(t,e)=>_e(t.events)?!1:e.some(({container:r})=>r.container.id!==t.id&&_e(r.container.events)&&r.container.endTime===t.endTime&&!r.isRemoved);var Re=class extends Bt{constructor(e,r){super(e),this.onError=r,this.prevChapter$=new hn.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(e){return A(this,null,function*(){var n;this.release();let r=yield this.exec("manifestLoaders",{actions:{addErrorMessage:st},result:null,errors:null,source:e});r.errors&&this.errorHandler(r.errors);let i=yield an((n=r.result)!=null?n:e);return this.manifest=i,this})}setInitial(){return A(this,null,function*(){return this.setNext()})}setNext(){return A(this,arguments,function*(e=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let r=yield this.exec("chapterLoaders",qt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Or,getChapter:Dt,getMedia:Lr,getByBranches:this.getByBranches.bind(this),addErrorMessage:st},result:null,errors:null,chapterId:e}));return r.errors&&this.errorHandler(r.errors),this.chapter=r.result.chapter,this.media=r.result.media,this.graph=r.result.graph,this})}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){let r=Dt(this.manifest.chapters,e);if(r){let i=Lr(this.manifest.media,r.videoId),n=Or(this.manifest.graph,r.id);if(i)return{chapter:r,media:i,graph:n}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{let r=Dt(this.manifest.chapters,e);return this.getByBranches(r==null?void 0:r.branches)}}getByBranches(e=[]){return e.reduce((r,i)=>{let n=this.getByChapterId(i.chapterId);return n&&r.push(n),r},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return se(this.chapter)}};var dn=require("@vkontakte/videoplayer-core"),pn=require("@vkontakte/videoplayer-shared");var un=t=>{let e=t.variants.find(r=>{var i;return((i=r.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[r,i]=e.payload.id.split("_");return[r,i]}return[]};var b={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},De={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},M={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Pr(){let t=new Map;function e(o){var c=o,{listId:n=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=Y(c,["listId","itemId"]);let h=t.get(n),m=d({},l);return h?h[s]=m:t.set(n,{[s]:m}),d({listId:n,itemId:s},l)}function r(n,s){var o,c,h;let l=t.get(n);if(l){if(s)return(o=l[s])==null||o.player.destroy(),(c=l[s])==null||c.container.remove(),(h=l[s])==null||h.subscription.unsubscribe(),delete l[s],Object.keys(l).length||t.delete(n),!0;for(let m of Object.values(l))m.player.destroy(),m.container.remove();return t.delete(n),!0}else throw Error("Can't remove. Not find.")}function i(){for(let n of t)r(n[0])}return{createPlayer:e,removePlayer:r,map:t,removeAll:i}}function kr(t,e=[]){var s,l,o;let r={},i,n=!e.length;for(let c of t.variants)if(!i&&"cover"in c&&(i=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(r.MPEG=x(d({},r.MPEG),{[(s=c.standard)!=null?s:"Invariant quality"]:c.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(r.MPEG=x(d({},r.MPEG),{[(l=c.standard)!=null?l:"Invariant quality"]:c.url}));break;case"hls":(n||e.includes("hls"))&&(r=x(d({},r),{HLS:{type:"url",url:c.url}}));break;case"dash":(n||e.includes("dash"))&&(r=x(d({},r),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break;default:break}return{sources:r,thumbUrl:i,title:(o=t.title)!=null?o:""}}var ot=(t,e)=>{let r=t.info.currentQuality$.getValue(),i=t.info.availableQualities$.getValue();r!==e&&i.includes(e)&&(t.setQuality(e),t.setAutoQuality(!1))};var ct={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},Ro=2;function $r(t){let e=Pr(),r,i,n=new qe,s={},l=!1,o=null,c=!1,h;t&&m(t);function m(u){o=u}function S(u,E,w){var N;if(!o)throw Error("need to set interactive controller");if(!o.options)return;let O=((N=e.map.get(u))!=null?N:{})[E];if(O){s=d({chapterId:w,listId:u,itemId:E},O);let q=s.player;i=q.info.currentQuality$.subscribe(L=>{if(!(!L||!q.info.position$.getValue())){r=L;for(let re of e.map)Object.values(re[1]).forEach(({player:ee})=>{q.info.isAutoQualityEnabled$.getValue()||ot(ee,L)})}}),O.container.remove(),l=!1,o.setPlayer(O.player),c||(o.init(),c=!0),n.emit(ct.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function v(u,E,w){return A(this,null,function*(){if(!o)throw Error("need to set interactive controller");if(we(s)||u!==s.itemId)return;if(w>=0&&!l){let O=o.getChapterBranches();l=!0;let N=new Set;for(let q of O)N.has(q.media.id)||(yield T({media:q.media,chapterId:q.chapter.id,setAsActive:!1,title:q.chapter.label}),N.add(q.media.id))}})}function I(w){return A(this,arguments,function*({chapter:{id:u},media:E}){if(we(s))return;i==null||i.unsubscribe();let y=s.player.info.muted$.getValue(),O=s.player.info.currentQuality$.getValue(),N=s.player.info.isAutoQualityEnabled$.getValue(),q=s.player.info.volume$.getValue(),L=s.player.info.currentPlaybackRate$.getValue(),re=!N,ee=!1;for(let K of e.map)if(K[0]===E.id){let ye=Object.keys(K[1]);for(let Q of ye)Q===s.itemId?(ye.length<Ro||(ee=!0),e.removePlayer(K[0],Q)):(ee=!0,S(K[0],Q,u),re?ot(s.player,O):s.player.setAutoQuality(!0),s.player.setVolume(q),s.player.setMuted(y),s.player.setPlaybackRate(L))}else e.removePlayer(K[0]);ee||(yield T({media:E,chapterId:u,setAsActive:!0,playbackRate:L}),re?ot(s.player,O):s.player.setAutoQuality(!0),s.player.setVolume(q),s.player.setMuted(y))})}function T(re){return A(this,arguments,function*({media:u,chapterId:E,prefetch:w=!0,setAsActive:y=!0,autoplay:O=!1,preferredExt:N,title:q,playbackRate:L}){var Ri,Vi,Ai,Mi,Oi;let ee=Math.random().toString(),K=document.createElement("div");h.append(K);let ye=(Ri=s==null?void 0:s.player)==null?void 0:Ri.info.isAutoQualityEnabled$.getValue(),Q;if((Vi=o==null?void 0:o.options)!=null&&Vi.vkVideoLoader){let Et=un(u);Et.length&&(Q=yield o.options.vkVideoLoader(...Et))}let Ti=((Ai=o==null?void 0:o.options)==null?void 0:Ai.coreConfig)||{},eo=x(d({},Ti),{configName:[...(Mi=Ti.configName)!=null?Mi:[],"interactive"]}),wi=x(d({container:K},((Oi=Q==null?void 0:Q.videos)==null?void 0:Oi[0])||{sources:kr(u,N).sources}),{title:q,failoverHosts:(Q==null?void 0:Q.failoverHosts)||[]}),Se=new dn.Player(eo);Se.initVideo(wi);let _i=new pn.Subscription;_i.add(Se.info.position$.subscribe(function(Et){v(ee,Se.info.duration$.getValue(),Et)})).add(Se.events.canplay$.subscribe(function(){ye||ot(Se,r),L&&Se.setPlaybackRate(L)}));let Pe=e.createPlayer({listId:u.id,itemId:ee,player:Se,container:K,sources:kr(u,N).sources,config:wi,subscription:_i});return y&&S(u.id,Pe.itemId,E),O&&Pe.player.play(),w&&!O&&Pe.player.prepare(),n.emit(ct.playerCreated,Pe.player),{player:Pe.player,config:Pe.config}})}function V(){_(),o=null}function _(){o==null||o.off(b.chapterChanged,I),e.removeAll(),s={},c=!1,l=!1}function f(E){return A(this,arguments,function*({container:u}){if(!o)throw Error("need to set interactive controller");_(),h=u;let{media:w,chapter:y}=o.getCurrentChapter();if(w){o.on(b.chapterChanged,I);let{player:O,config:N}=yield T({media:w,chapterId:y.id,title:y.label});return n.emit(ct.initiated,{container:u,media:w,chapterId:y.id}),{player:O,config:N}}else console.error("not found")})}return x(d({},e),{on:n.on.bind(n),off:n.off.bind(n),init:f,setInteractiveController:m,createPlayer:T,removeAll:V,getActivePlayer:function(){return s}})}var fn=require("@vkontakte/videoplayer-shared");var Ut=class{constructor({player:e,container:r,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:h,onRemove:m}){F(this,"hide",()=>{setTimeout(()=>{var e,r;this.gameState!==D.end&&(_e(this.container.container.events)&&this.gameState===D.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==D.interactive&&((r=(e=this.container).hide)==null||r.call(e)),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})))})});F(this,"show",()=>{var e,r,i,n;if(this.gameState===D.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!0,isFirst:!1});else{let l=cn({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})},onEvent:(o,c)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})),(this.gameState===D.end||this.gameState===D.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1}))},isEOV:()=>this.gameState===D.end});this.container.createView(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((r=(e=this.container).disable)==null||r.call(e))}});F(this,"onEndOfVideo",()=>{this.gameState=D.end,this.selectContainerEvent(!0)});F(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[D.destroyed,D.removed].includes(this.gameState)&&!this.isPermanentText)return;let r=this.player.getExactTime();if(on(r,this.container.container))this.gameState!==D.beforeInteractive&&(this.gameState=D.beforeInteractive,this.onBeforeStartTime());else if(jr(r,this.container.container))this.gameState!==D.interactive&&(this.gameState=D.interactive,this.onStartTime());else if(this.gameState!==D.afterInteractive){let o=this.gameState;this.gameState=D.afterInteractive,o===D.interactive&&this.onEndTime()}else this.gameState!==D.destroyed&&!this.isPermanentText&&this.removeView();let i=jr(r,this.container.container),n=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(b.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:n,currentTime:r,isInteractiveTime:i})});this.container=r,this.branches=i,this.selectBranches=n,this.subscription=new fn.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&Gt(r.container.controls),this.disabledControls$=h,this.onRemove=m,this.globalEventEmitter=l,this.gameState=D.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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 r,i,n,s;e?(i=(r=this.container).disable)==null||i.call(r):(s=(n=this.container).enable)==null||s.call(n)}))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,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(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=_e(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,r;(r=(e=this.container).hide)==null||r.call(e),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=D.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.containerRemoved,visibility:!1}),this.gameState=D.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=D.destroyed,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 mn=(t=[])=>t.reduce((e,r,i)=>{var s,l,o;let n=((s=r==null?void 0:r.controls)!=null?s:[]).filter(c=>!$t(c));if(Ht(n)){let c=[(l=r.startTime)!=null?l:0,(o=r.endTime)!=null?o:1/0],h=r.id;if(!i)e.push({subjects:[h],range:c});else{let m=[],S=-1/0,v=1/0,I=[],T=[];for(let V=0;V<e.length;V++){let _=e[V];if(T.push(..._.subjects),_.range[0]<v&&(v=_.range[0]),_.range[1]>S&&(S=_.range[1]),c[0]>=_.range[0]&&c[1]<=_.range[1])return e[V].subjects.push(h),e;c[0]<_.range[0]&&c[1]>_.range[0]&&(m.push(V),I=I.concat(_.subjects)),c[0]>=_.range[0]&&c[0]<=_.range[1]&&(m.push(V),I=I.concat(_.subjects),c[0]=_.range[0]),c[1]>=_.range[0]&&c[1]<=_.range[1]&&(m.push(V),I=I.concat(_.subjects),c[1]=_.range[1])}if(T.push(h),c[0]<=v&&c[1]>=S)return[{subjects:T,range:c}];m.length&&m.reverse().forEach(V=>{e.splice(V,1)}),e.push({subjects:I.concat([h]),range:c})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);function yn(){let t={};function e(){for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&delete t[o];return!0}function r(o){let c={};for(let h in t)+h<=o&&(c[h]=t[h]);return c}function i(o){let c={};for(let h in t)+h>=o&&(c[h]=t[h]);return c}function n({timestamp:o,priority:c,initiator:h}){var m;if(_r(o)){let S=(m=t[o])!=null?m:null;if(S&&rt(c,!0)){let v={},I=S[c];if(I&&(v=d(d({},v),I)),v=we(v)?null:v,v&&rt(h,!0)){let T=v[h];return T!=null?T:null}return v}return S}return null}function s({timestamp:o,priority:c,initiator:h}){if(_r(o))if(t[o]){if(rt(c,!0))if(t[o][c]){if(rt(h,!0))if(t[o][c][h]){if(delete t[o][c][h],!we(t[o][c]))return!0}else return!1;if(delete t[o][c],!we(t[o]))return!0}else return!1;return delete t[o]}else return!1}function l(S){var v=S,{timestamp:o,priority:c,initiator:h}=v,m=Y(v,["timestamp","priority","initiator"]);var I,T,V;(T=(I=t[o])==null?void 0:I[c])!=null&&T[h]?t[o][c][h].push(d({},m)):(V=t[o])!=null&&V[c]?t[o][c]=x(d({},t[o][c]),{[h]:[d({},m)]}):t[o]?t[o]=x(d({},t[o]),{[c]:{[h]:[d({},m)]}}):t[o]={[c]:{[h]:[d({},m)]}}}return{map:t,remove:s,add:l,removeAll:e,get:n,getLte:r,getGte:i}}var Vo=[P.expect,P.setNextBranch],Ao=1/0;function Fr(t){let e=t,r,i=Mo(),n=new yn,s,l=()=>{v(),f()},o=u=>{n.add.call(void 0,u),T()},c=(u=[])=>{for(let E of u)if(E.action(),Vo.includes(E.actionType))break},h=(u=1/0)=>{var O,N,q;let E=zt((O=n.get({timestamp:u,priority:"control"}))!=null?O:{}),w=zt((N=n.get({timestamp:u,priority:"container"}))!=null?N:{}),y=zt((q=n.get({timestamp:u,priority:"chapter"}))!=null?q:{});return[...E,...w,...y]},m=u=>{i.isReady(u)&&c(h(u))},S=()=>{var u;c([...zt((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},v=()=>{r&&(s==null||s.unsubscribe(),r=void 0)},I=u=>{},T=()=>{r||(r=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(r))},V=u=>{v(),e=u},_=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},f=()=>{i.release(),n.removeAll()};return{setPlayer:V,add:o,remove:_,exec:m,execEndOfVideo:S,listen:T,unlisten:v,release:l,containersEventsCallState:i,getPreparedToExecActions:h}}function Mo(){let t=new Map;return{setCalled:({timestamp:l,id:o})=>{let c=t.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(let h of l){let m=(o=h.endTime)!=null?o:Ao,S=(c=t.get(m))!=null?c:{};t.set(m,x(d({},S),{[h.id]:!1}))}},resetCalled:l=>{let o=t.get(l);if(o)for(let c in o)o[c]=!1},isReady:l=>{let o=t.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>t.clear()}}function zt(t){return Object.values(t).flat().sort(e=>e.actionType===P.expect?-1:1)}var vn=(t,e)=>{let{height:r,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(r&&i))return{videoContentHeight:0,videoContentWidth:0};let{clientHeight:n,clientWidth:s}=e.experimental.element$.value||{};if(!(n&&s))return{videoContentHeight:0,videoContentWidth:0};let l=r/i,o=n/s,c,h;return o>l?(h=s,c=s*l):o<l?(h=n/l,c=n):(h=s,c=n),{videoContentWidth:h,videoContentHeight:c}};var Oo=250;function gn(t){let e=()=>{},r=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:c,player:h}=t();if(c&&h){let{videoContentWidth:m,videoContentHeight:S}=vn(c,h);c.style.setProperty("--interactive-content-width",`${m}px`),c.style.setProperty("--interactive-content-height",`${S}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=t();o.removeAttribute("style")}let s=Lt(o=>{let{fns:c=[]}=t();i(o);for(let h of c)h()},Oo);function l(){e=void 0,r.disconnect(),n()}return{resizeObserver:r,calc:()=>{e()},release:l}}var lt=class{constructor(){this.map={}}push(e,r){e in this.map?this.map[e].push(r):this.map[e]=[r]}get(e){let r=this.map[e];return r?r.slice():null}getAll(){let e=[];for(let r in this.map)e.push(...this.map[r]);return e}remove(e,r){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==r),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}};var Lo=t=>Math.floor(Math.random()*t),bn=t=>{let e=t.length,r=1/0,i=null;for(;e--;)t[e].weight<r&&(r=t[e].weight,i=t[e]);return i},En=t=>{let e=t.length,r=-1/0,i=null;for(;e--;)t[e].weight>r&&(r=t[e].weight,i=t[e]);return i};var Cn=t=>{let e=t.length,r=Lo(e);return t[r]};var xn=t=>{var i,n;let e=0;for(let s=0;s<t.length;++s)e+=(i=t[s].weight)!=null?i:1;let r=Math.random()*e;e=0;for(let s=0;s<t.length-1;++s)if(e+=(n=t[s].weight)!=null?n:1,e>=r)return t[s];return t[t.length-1]};var In=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var Br=(t,e=!1)=>x(d({},t),{args:e?d(d({},t.args),In):d(d({},In),t.args)}),qr=({globalEventEmitter:t,player:e,interactiveEvents:r,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:f,controlType:u,controlId:E,containerId:w,branches:y=[],onEvent:O,isEOV:N=()=>!1,isDisabled:q=()=>!1})=>{let L=Br(f,N()),re={timestamp:1/0,priority:"control",initiator:E,actionType:L.type},ee=q(),K=t.emit.bind(t,b.interactives,{subjectId:E,subjectType:u,subjectName:"control",type:ee?M.actionChoiceCanceled:M.actionChoice,actionType:f.type,payload:d({containerId:w},L.args)});if(ee){K();return}switch(L.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let ye=y.find(Q=>Q.id===L.args.branchId);if(!ye)return;O(L.args.isDetachContainer,v.bind(null,{subjectId:E,subjectName:"control"})),K(),L.args.shouldOpenNow?T({subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ye.chapterId,autoSelect:!1}}):(r.add(x(d({},re),{action:T.bind(null,{subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ye.chapterId,autoSelect:!1}})})),i==null||i());return}case P.continuePlayback.trim().toLowerCase():{O(L.args.isDetachContainer,v.bind(null,{subjectId:E,subjectName:"control"})),K(),L.args.shouldOpenNow?I({subjectId:E,subjectName:"control",subjectType:u,action:f}):r.add(x(d({},re),{action:I.bind(null,{subjectId:E,subjectName:"control",subjectType:u,action:f})}));return}case P.openURI.trim().toLowerCase():{O(L.args.isDetachContainer,v.bind(null,{subjectId:E,subjectName:"control"})),K(),L.args.shouldOpenNow?_({subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{URI:f.args.uri}}):(r.add(x(d({},re),{action:_.bind(null,{subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{URI:f.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),t.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:f,container:{id:u,endTime:E},branches:w=[],isEOV:y=!1,autoSelected:O=!1})=>{let N=Br(f,y),q={timestamp:!N.args.shouldOpenNow||y?1/0:E,priority:"container",initiator:u,actionType:N.type},L=t.emit.bind(t,b.interactives,{subjectId:u,subjectName:"container",type:M.actionChoice,actionType:N.type,payload:N.args});switch(N.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let re=w.find(ee=>ee.id===N.args.branchId);if(!re)return;L(),r.add(x(d({},q),{action:T.bind(null,{subjectId:u,subjectName:"container",action:N,payload:{chapterId:re.chapterId,autoSelect:O}})})),i==null||i();return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{L(),r.add(x(d({},q),{action:I.bind(null,{subjectId:u,subjectName:"container",action:N})}));return}case P.openURI.trim().toLowerCase():{L(),r.add(x(d({},q),{action:_.bind(null,{subjectId:u,subjectName:"container",action:N,payload:{URI:f.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),t.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:f,branches:u,isEOV:E=!1}){let w=Nr(f.events);if(w){let y=Br(w.action,E);t.emit(b.interactives,{subjectId:f.id,subjectName:"container",type:M.actionChoice,actionType:y.type,payload:y.args}),r.add({timestamp:E?1/0:f.endTime,priority:"container",initiator:f.id,actionType:P.expect,action:S.bind(null,{subjectId:f.id,subjectName:"container"})}),n.isExpect=!0}else for(let y of f.events)o({action:y.action,container:f,branches:u,isEOV:E})}let h=({chapterId:f,action:u,branches:E=[]})=>{let w=t.emit.bind(t,b.interactives,{subjectId:f,subjectName:"chapter",type:M.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let y=E.find(O=>O.id===u.args.branchId);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let y=Cn(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let y=xn(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let y=En(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let y=bn(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return w(),I.bind(null,{subjectId:f,subjectName:"chapter",action:u});case P.openURI.trim().toLowerCase():return w(),_.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),t.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function m(f){let u=Nr(f.events);if(u){if(se(f))return;t.emit(b.interactives,{subjectId:f.id,subjectName:"chapter",type:M.actionChoice,actionType:u.action.type,payload:u.action.args}),r.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:P.expect,action:S.bind(null,{subjectId:f.id,subjectName:"chapter"})})}else f.events.forEach(E=>{let w=h({chapterId:f.id,action:E.action,branches:f.branches});w&&r.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:E.action.type,action:w})})}let S=({subjectId:f,subjectName:u,action:E})=>{var w;e.pause(),t.emit(b.interactives,{subjectId:f,subjectName:u,type:M.actionExecution,actionType:(w=E==null?void 0:E.type)!=null?w:P.expect})},v=({subjectId:f,subjectName:u})=>{e.info.isEnded$.getValue()?r.execEndOfVideo():e.play(),t.emit(b.interactives,{subjectId:f,subjectName:u,type:M.actionExecution,actionType:"after-expect"})},I=({subjectId:f,subjectName:u,subjectType:E,action:w})=>{t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type})},T=({subjectId:f,subjectName:u,subjectType:E,action:w,payload:y})=>{y.behaviour="change-chapter",t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type,payload:y})},V=({subjectId:f,subjectName:u,subjectType:E,action:w,payload:y})=>{y.behaviour="change-manifest",t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type,payload:y})},_=({subjectId:f,subjectName:u,subjectType:E,action:w,payload:y})=>{if(!y.URI)return;let O=window.open(y.URI,"_blank","noopener,noreferrer");O&&(O.opener=null),t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:h,onExpectEvent:S,expectEventHandler:v,setManifestChapterEvents:m,setManifestContainerEvents:c,stopExpect:s,state:n}};var Ci=Ni(Fa(),1),Ee=require("@vkontakte/videoplayer-shared");var er=(t,e)=>{let r={};return t.map(i=>{if(!r[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;r[i]=bi(s)}return r[i]}).filter(Boolean)},Ba=t=>{for(let e of t.variants)if(qa(e)&&"payload"in e)return e.payload.id},qa=t=>t.type==="custom"&&"payload"in t&&t.payload.type==="vk",bi=t=>{let e=Ba(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},Da=(t,e)=>{for(let r of t.media.videos)if(e===bi(r)){for(let i of t.chapters)if(i.videoId===r.id)return i.id;return}},Ei=(t,e)=>t.reduce((r,i)=>{let n=Da(e,i);return n?[...r,n]:r},[]);var ce,Ae,Me,te,tr,le,he,ne,Oe,We,Ke,pt=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new Ee.ValueSubject([]),hasPrevChapter$:new Ee.ValueSubject(!1),prevChapter$:new Ee.ValueSubject(null),isInitialChapter$:new Ee.ValueSubject(!1),isGoBackLimited$:new Ee.ValueSubject(!1)};C(this,ce,null);C(this,Ae,void 0);C(this,Me,!1);C(this,te,null);C(this,tr,null);C(this,le,null);C(this,he,null);C(this,ne,null);C(this,Oe,new Ee.Subscription);C(this,We,!1);C(this,Ke,0);var l,o,c;g(this,le,r),g(this,ne,e),g(this,he,i),g(this,ce,n),g(this,Ae,s),(l=this.state)!=null&&l.history$&&a(this,Oe)&&((c=a(this,Oe))==null||c.add((o=this.state)==null?void 0:o.history$.subscribe(h=>{var m,S,v,I,T,V;(m=this.state)==null||m.prevChapter$.next((0,Ci.default)(h,-2)||null),(S=this.state)==null||S.hasPrevChapter$.next(h.length>1),(T=this.state)==null||T.isInitialChapter$.next(this.getInitialChapterId()===((I=(v=a(this,te))==null?void 0:v.metadata)==null?void 0:I.initChapterId)),(V=this.state)==null||V.isGoBackLimited$.next(a(this,Ke)===a(this,Ae).maxLength-1)})))}setManifest(e){return A(this,null,function*(){!a(this,he)||!a(this,ne)||(g(this,te,e),yield this.getProjectHistory(),yield a(this,he).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,Me)||(g(this,Me,!0),a(this,ne).emit(b.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,Me)}updateHistory(e,r=!0){return A(this,null,function*(){var o,c;if(!a(this,te))return;a(this,We)?(g(this,We,!1),Pi(this,Ke)._++):g(this,Ke,0);let i=a(this,te),n=e.length-a(this,Ae).maxLength,s=n>0?e.slice(n):e,l=er(s,i);if(g(this,tr,l),(o=this==null?void 0:this.state)==null||o.history$.next(s),!(!r||!a(this,ce)||!a(this,le)))try{yield a(this,ce).save(a(this,le),l)}catch(h){(c=a(this,ne))==null||c.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.HISTORY,"Unable to save interactive history"))}})}goBack(){return A(this,null,function*(){var i;if(!this.state||!a(this,he))return(i=a(this,ne))==null?void 0:i.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.HISTORY,"Cannot go back because HistoryController has not been initialized"));g(this,We,!0);let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),yield a(this,he).setChapter({chapterId:r})})}getProjectHistory(){return A(this,null,function*(){var n,s;if(!a(this,te)||!a(this,le))return;let e=a(this,te),r=[this.getInitialVideoId()];if(a(this,ce))try{let l=yield a(this,ce).get(a(this,le));l.length&&(r=l)}catch(l){(n=a(this,ne))==null||n.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.HISTORY,"Error while trying to fetch data"))}let i=Ei(r,e);(s=this==null?void 0:this.state)==null||s.history$.next(i)})}getInitialChapterId(){var r,i;let e=(r=this.state)==null?void 0:r.history$.getValue();return(0,Ci.default)(e,-1)||a(this,Ae).initChapterId||((i=a(this,te))==null?void 0:i.metadata.initChapterId)}getInitialVideoId(){if(a(this,te)){let e=this.getInitialChapterId();return er([e],a(this,te)).pop()}return null}destroy(){var e,r;this.state=null,g(this,le,null),g(this,ce,null),g(this,he,null),(e=a(this,Oe))==null||e.unsubscribe(),g(this,Oe,null),g(this,Me,!1),(r=a(this,ne))==null||r.emit(b.historyDestroyed),g(this,ne,null)}};ce=new WeakMap,Ae=new WeakMap,Me=new WeakMap,te=new WeakMap,tr=new WeakMap,le=new WeakMap,he=new WeakMap,ne=new WeakMap,Oe=new WeakMap,We=new WeakMap,Ke=new WeakMap;var ir,Ha,ft,nr,Ga,ue=class ue{constructor(e,r,i,n){var s;this.target=e,this.type=r,this.listener=i,this.options=k(s=ue,ir,Ha).call(s,e,n),this.target.addEventListener(r,i,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}};ir=new WeakSet,Ha=function(e,r){var i;if(r===void 0)return!1;if(typeof r=="boolean")return r;{let n=new Set(["passive","capture"]),s=Object.keys(r).filter(o=>!n.has(o));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),k(i=ue,nr,Ga).call(i,e)?r:r.capture||!1}},ft=new WeakMap,nr=new WeakSet,Ga=function(e){let r=a(ue,ft);if(r===void 0){r=!1;try{let i={},n={get:()=>(r=!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){r=!1}g(ue,ft,r)}return r||!1},C(ue,ir),C(ue,nr),C(ue,ft,void 0);var rr=ue;var sr=class{constructor(){this.bindingMap=new lt}release(){this.removeAll(),this.bindingMap=null}listen(e,r,i,n){if(!this.bindingMap)return;let s=new rr(e,r,i,n);this.bindingMap.push(r,s)}listenOnce(e,r,i,n){let s=l=>{this.unlisten(e,r,s),i(l)};this.listen(e,r,s,n)}unlisten(e,r,i){if(!this.bindingMap)return;let n=this.bindingMap.get(r)||[];for(let s of n)s.target===e&&(i===s.listener||!i)&&(s.unlisten(),this.bindingMap.remove(r,s))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let r of e)r.unlisten();this.bindingMap.clear()}};var ar=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 r=e.data,i=r.length;for(let s=3;s<i;s+=40)if(r[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))}updateCanvasDimensions(e,r=!1){return A(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;r&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&n&&this.restore(n),this._prevSizeId=i})}save(){return A(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,yield r.decode(),r})}restore(e){var r;this.rootElement&&((r=this.rootElement.getContext("2d"))==null||r.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var or=class{constructor({parentElement:e,endOffsetMs:r=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(r);if(this.isContainerTime(r))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 Fa=Object.create;var Xe=Object.defineProperty,Ba=Object.defineProperties,qa=Object.getOwnPropertyDescriptor,Da=Object.getOwnPropertyDescriptors,Ha=Object.getOwnPropertyNames,bt=Object.getOwnPropertySymbols,Ga=Object.getPrototypeOf,si=Object.prototype.hasOwnProperty,br=Object.prototype.propertyIsEnumerable;var Er=i=>{throw TypeError(i)};var ni=(i,e,t)=>e in i?Xe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,p=(i,e)=>{for(var t in e||(e={}))si.call(e,t)&&ni(i,t,e[t]);if(bt)for(var t of bt(e))br.call(e,t)&&ni(i,t,e[t]);return i},C=(i,e)=>Ba(i,Da(e));var Y=(i,e)=>{var t={};for(var r in i)si.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&bt)for(var r of bt(i))e.indexOf(r)<0&&br.call(i,r)&&(t[r]=i[r]);return t};var f=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Ua=(i,e)=>{for(var t in e)Xe(i,t,{get:e[t],enumerable:!0})},Cr=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ha(e))!si.call(i,n)&&n!==t&&Xe(i,n,{get:()=>e[n],enumerable:!(r=qa(e,n))||r.enumerable});return i};var xr=(i,e,t)=>(t=i!=null?Fa(Ga(i)):{},Cr(e||!i||!i.__esModule?Xe(t,"default",{value:i,enumerable:!0}):t,i)),za=i=>Cr(Xe({},"__esModule",{value:!0}),i);var te=(i,e,t)=>ni(i,typeof e!="symbol"?e+"":e,t),ai=(i,e,t)=>e.has(i)||Er("Cannot "+t);var a=(i,e,t)=>(ai(i,e,"read from private field"),t?t.call(i):e.get(i)),w=(i,e,t)=>e.has(i)?Er("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),E=(i,e,t,r)=>(ai(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),B=(i,e,t)=>(ai(i,e,"access private method"),t);var Ir=(i,e,t,r)=>({set _(n){E(i,e,n,t)},get _(){return a(i,e,r)}});var R=(i,e,t)=>new Promise((r,n)=>{var s=c=>{try{o(t.next(c))}catch(h){n(h)}},l=c=>{try{o(t.throw(c))}catch(h){n(h)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,l);o((t=t.apply(i,e)).next())});var oe=f((_i,dn)=>{"use strict";var lt=function(i){return i&&i.Math===Math&&i};dn.exports=lt(typeof globalThis=="object"&&globalThis)||lt(typeof window=="object"&&window)||lt(typeof self=="object"&&self)||lt(typeof global=="object"&&global)||lt(typeof _i=="object"&&_i)||function(){return this}()||Function("return this")()});var be=f((Cp,fn)=>{"use strict";fn.exports=function(i){try{return!!i()}catch(e){return!0}}});var ht=f((xp,mn)=>{"use strict";var go=be();mn.exports=!go(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")})});var En=f((Ip,bn)=>{"use strict";var bo=ht(),gn=Function.prototype,yn=gn.apply,vn=gn.call;bn.exports=typeof Reflect=="object"&&Reflect.apply||(bo?vn.bind(yn):function(){return vn.apply(yn,arguments)})});var Me=f((Tp,In)=>{"use strict";var Cn=ht(),xn=Function.prototype,Vi=xn.call,Eo=Cn&&xn.bind.bind(Vi,Vi);In.exports=Cn?Eo:function(i){return function(){return Vi.apply(i,arguments)}}});var Ri=f((Sp,Sn)=>{"use strict";var Tn=Me(),Co=Tn({}.toString),xo=Tn("".slice);Sn.exports=function(i){return xo(Co(i),8,-1)}});var Ai=f((wp,wn)=>{"use strict";var Io=Ri(),To=Me();wn.exports=function(i){if(Io(i)==="Function")return To(i)}});var Ee=f((_p,_n)=>{"use strict";var Mi=typeof document=="object"&&document.all;_n.exports=typeof Mi=="undefined"&&Mi!==void 0?function(i){return typeof i=="function"||i===Mi}:function(i){return typeof i=="function"}});var He=f((Vp,Vn)=>{"use strict";var So=be();Vn.exports=!So(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ut=f((Rp,Rn)=>{"use strict";var wo=ht(),Gt=Function.prototype.call;Rn.exports=wo?Gt.bind(Gt):function(){return Gt.apply(Gt,arguments)}});var Ln=f(On=>{"use strict";var An={}.propertyIsEnumerable,Mn=Object.getOwnPropertyDescriptor,_o=Mn&&!An.call({1:2},1);On.f=_o?function(e){var t=Mn(this,e);return!!t&&t.enumerable}:An});var Oi=f((Mp,Nn)=>{"use strict";Nn.exports=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}}});var Pn=f((Op,jn)=>{"use strict";var Vo=Me(),Ro=be(),Ao=Ri(),Li=Object,Mo=Vo("".split);jn.exports=Ro(function(){return!Li("z").propertyIsEnumerable(0)})?function(i){return Ao(i)==="String"?Mo(i,""):Li(i)}:Li});var Ni=f((Lp,kn)=>{"use strict";kn.exports=function(i){return i==null}});var ji=f((Np,$n)=>{"use strict";var Oo=Ni(),Lo=TypeError;$n.exports=function(i){if(Oo(i))throw new Lo("Can't call method on "+i);return i}});var Bn=f((jp,Fn)=>{"use strict";var No=Pn(),jo=ji();Fn.exports=function(i){return No(jo(i))}});var ut=f((Pp,qn)=>{"use strict";var Po=Ee();qn.exports=function(i){return typeof i=="object"?i!==null:Po(i)}});var Pi=f((kp,Dn)=>{"use strict";Dn.exports={}});var Fi=f(($p,Gn)=>{"use strict";var ki=Pi(),$i=oe(),ko=Ee(),Hn=function(i){return ko(i)?i:void 0};Gn.exports=function(i,e){return arguments.length<2?Hn(ki[i])||Hn($i[i]):ki[i]&&ki[i][e]||$i[i]&&$i[i][e]}});var zn=f((Fp,Un)=>{"use strict";var $o=Me();Un.exports=$o({}.isPrototypeOf)});var Yn=f((Bp,Qn)=>{"use strict";var Fo=oe(),Wn=Fo.navigator,Kn=Wn&&Wn.userAgent;Qn.exports=Kn?String(Kn):""});var rs=f((qp,is)=>{"use strict";var ts=oe(),Bi=Yn(),Xn=ts.process,Zn=ts.Deno,Jn=Xn&&Xn.versions||Zn&&Zn.version,es=Jn&&Jn.v8,ne,zt;es&&(ne=es.split("."),zt=ne[0]>0&&ne[0]<4?1:+(ne[0]+ne[1]));!zt&&Bi&&(ne=Bi.match(/Edge\/(\d+)/),(!ne||ne[1]>=74)&&(ne=Bi.match(/Chrome\/(\d+)/),ne&&(zt=+ne[1])));is.exports=zt});var qi=f((Dp,ss)=>{"use strict";var ns=rs(),Bo=be(),qo=oe(),Do=qo.String;ss.exports=!!Object.getOwnPropertySymbols&&!Bo(function(){var i=Symbol("symbol detection");return!Do(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&ns&&ns<41})});var Di=f((Hp,as)=>{"use strict";var Ho=qi();as.exports=Ho&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Hi=f((Gp,os)=>{"use strict";var Go=Fi(),Uo=Ee(),zo=zn(),Wo=Di(),Ko=Object;os.exports=Wo?function(i){return typeof i=="symbol"}:function(i){var e=Go("Symbol");return Uo(e)&&zo(e.prototype,Ko(i))}});var ls=f((Up,cs)=>{"use strict";var Qo=String;cs.exports=function(i){try{return Qo(i)}catch(e){return"Object"}}});var Gi=f((zp,hs)=>{"use strict";var Yo=Ee(),Xo=ls(),Zo=TypeError;hs.exports=function(i){if(Yo(i))return i;throw new Zo(Xo(i)+" is not a function")}});var ps=f((Wp,us)=>{"use strict";var Jo=Gi(),ec=Ni();us.exports=function(i,e){var t=i[e];return ec(t)?void 0:Jo(t)}});var fs=f((Kp,ds)=>{"use strict";var Ui=Ut(),zi=Ee(),Wi=ut(),tc=TypeError;ds.exports=function(i,e){var t,r;if(e==="string"&&zi(t=i.toString)&&!Wi(r=Ui(t,i))||zi(t=i.valueOf)&&!Wi(r=Ui(t,i))||e!=="string"&&zi(t=i.toString)&&!Wi(r=Ui(t,i)))return r;throw new tc("Can't convert object to primitive value")}});var ys=f((Qp,ms)=>{"use strict";ms.exports=!0});var bs=f((Yp,gs)=>{"use strict";var vs=oe(),ic=Object.defineProperty;gs.exports=function(i,e){try{ic(vs,i,{value:e,configurable:!0,writable:!0})}catch(t){vs[i]=e}return e}});var Ki=f((Xp,xs)=>{"use strict";var rc=ys(),nc=oe(),sc=bs(),Es="__core-js_shared__",Cs=xs.exports=nc[Es]||sc(Es,{});(Cs.versions||(Cs.versions=[])).push({version:"3.38.0",mode:rc?"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 Ss=f((Zp,Ts)=>{"use strict";var Is=Ki();Ts.exports=function(i,e){return Is[i]||(Is[i]=e||{})}});var Qi=f((Jp,ws)=>{"use strict";var ac=ji(),oc=Object;ws.exports=function(i){return oc(ac(i))}});var Wt=f((ed,_s)=>{"use strict";var cc=Me(),lc=Qi(),hc=cc({}.hasOwnProperty);_s.exports=Object.hasOwn||function(e,t){return hc(lc(e),t)}});var Rs=f((td,Vs)=>{"use strict";var uc=Me(),pc=0,dc=Math.random(),fc=uc(1 .toString);Vs.exports=function(i){return"Symbol("+(i===void 0?"":i)+")_"+fc(++pc+dc,36)}});var Os=f((id,Ms)=>{"use strict";var mc=oe(),yc=Ss(),As=Wt(),vc=Rs(),gc=qi(),bc=Di(),Ge=mc.Symbol,Yi=yc("wks"),Ec=bc?Ge.for||Ge:Ge&&Ge.withoutSetter||vc;Ms.exports=function(i){return As(Yi,i)||(Yi[i]=gc&&As(Ge,i)?Ge[i]:Ec("Symbol."+i)),Yi[i]}});var Ps=f((rd,js)=>{"use strict";var Cc=Ut(),Ls=ut(),Ns=Hi(),xc=ps(),Ic=fs(),Tc=Os(),Sc=TypeError,wc=Tc("toPrimitive");js.exports=function(i,e){if(!Ls(i)||Ns(i))return i;var t=xc(i,wc),r;if(t){if(e===void 0&&(e="default"),r=Cc(t,i,e),!Ls(r)||Ns(r))return r;throw new Sc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Ic(i,e)}});var Xi=f((nd,ks)=>{"use strict";var _c=Ps(),Vc=Hi();ks.exports=function(i){var e=_c(i,"string");return Vc(e)?e:e+""}});var Bs=f((sd,Fs)=>{"use strict";var Rc=oe(),$s=ut(),Zi=Rc.document,Ac=$s(Zi)&&$s(Zi.createElement);Fs.exports=function(i){return Ac?Zi.createElement(i):{}}});var Ji=f((ad,qs)=>{"use strict";var Mc=He(),Oc=be(),Lc=Bs();qs.exports=!Mc&&!Oc(function(){return Object.defineProperty(Lc("div"),"a",{get:function(){return 7}}).a!==7})});var Gs=f(Hs=>{"use strict";var Nc=He(),jc=Ut(),Pc=Ln(),kc=Oi(),$c=Bn(),Fc=Xi(),Bc=Wt(),qc=Ji(),Ds=Object.getOwnPropertyDescriptor;Hs.f=Nc?Ds:function(e,t){if(e=$c(e),t=Fc(t),qc)try{return Ds(e,t)}catch(r){}if(Bc(e,t))return kc(!jc(Pc.f,e,t),e[t])}});var zs=f((cd,Us)=>{"use strict";var Dc=be(),Hc=Ee(),Gc=/#|\.prototype\./,pt=function(i,e){var t=zc[Uc(i)];return t===Kc?!0:t===Wc?!1:Hc(e)?Dc(e):!!e},Uc=pt.normalize=function(i){return String(i).replace(Gc,".").toLowerCase()},zc=pt.data={},Wc=pt.NATIVE="N",Kc=pt.POLYFILL="P";Us.exports=pt});var Qs=f((ld,Ks)=>{"use strict";var Ws=Ai(),Qc=Gi(),Yc=ht(),Xc=Ws(Ws.bind);Ks.exports=function(i,e){return Qc(i),e===void 0?i:Yc?Xc(i,e):function(){return i.apply(e,arguments)}}});var Xs=f((hd,Ys)=>{"use strict";var Zc=He(),Jc=be();Ys.exports=Zc&&Jc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Js=f((ud,Zs)=>{"use strict";var el=ut(),tl=String,il=TypeError;Zs.exports=function(i){if(el(i))return i;throw new il(tl(i)+" is not an object")}});var ia=f(ta=>{"use strict";var rl=He(),nl=Ji(),sl=Xs(),Kt=Js(),ea=Xi(),al=TypeError,er=Object.defineProperty,ol=Object.getOwnPropertyDescriptor,tr="enumerable",ir="configurable",rr="writable";ta.f=rl?sl?function(e,t,r){if(Kt(e),t=ea(t),Kt(r),typeof e=="function"&&t==="prototype"&&"value"in r&&rr in r&&!r[rr]){var n=ol(e,t);n&&n[rr]&&(e[t]=r.value,r={configurable:ir in r?r[ir]:n[ir],enumerable:tr in r?r[tr]:n[tr],writable:!1})}return er(e,t,r)}:er:function(e,t,r){if(Kt(e),t=ea(t),Kt(r),nl)try{return er(e,t,r)}catch(n){}if("get"in r||"set"in r)throw new al("Accessors not supported");return"value"in r&&(e[t]=r.value),e}});var na=f((dd,ra)=>{"use strict";var cl=He(),ll=ia(),hl=Oi();ra.exports=cl?function(i,e,t){return ll.f(i,e,hl(1,t))}:function(i,e,t){return i[e]=t,i}});var oa=f((fd,aa)=>{"use strict";var dt=oe(),ul=En(),pl=Ai(),dl=Ee(),fl=Gs().f,ml=zs(),Ue=Pi(),yl=Qs(),ze=na(),sa=Wt();Ki();var vl=function(i){var e=function(t,r,n){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,r)}return new i(t,r,n)}return ul(i,this,arguments)};return e.prototype=i.prototype,e};aa.exports=function(i,e){var t=i.target,r=i.global,n=i.stat,s=i.proto,l=r?dt:n?dt[t]:dt[t]&&dt[t].prototype,o=r?Ue:Ue[t]||ze(Ue,t,{})[t],c=o.prototype,h,v,T,m,x,I,V,_,d;for(m in e)h=ml(r?m:t+(n?".":"#")+m,i.forced),v=!h&&l&&sa(l,m),I=o[m],v&&(i.dontCallGetSet?(d=fl(l,m),V=d&&d.value):V=l[m]),x=v&&V?V:e[m],!(!h&&!s&&typeof I==typeof x)&&(i.bind&&v?_=yl(x,dt):i.wrap&&v?_=vl(x):s&&dl(x)?_=pl(x):_=x,(i.sham||x&&x.sham||I&&I.sham)&&ze(_,"sham",!0),ze(o,m,_),s&&(T=t+"Prototype",sa(Ue,T)||ze(Ue,T,{}),ze(Ue[T],m,x),i.real&&c&&(h||!c[m])&&ze(c,m,x)))}});var la=f((md,ca)=>{"use strict";var gl=Math.ceil,bl=Math.floor;ca.exports=Math.trunc||function(e){var t=+e;return(t>0?bl:gl)(t)}});var nr=f((yd,ha)=>{"use strict";var El=la();ha.exports=function(i){var e=+i;return e!==e||e===0?0:El(e)}});var pa=f((vd,ua)=>{"use strict";var Cl=nr(),xl=Math.min;ua.exports=function(i){var e=Cl(i);return e>0?xl(e,9007199254740991):0}});var fa=f((gd,da)=>{"use strict";var Il=pa();da.exports=function(i){return Il(i.length)}});var ya=f((bd,ma)=>{"use strict";ma.exports=function(){}});var va=f(()=>{"use strict";var Tl=oa(),Sl=Qi(),wl=fa(),_l=nr(),Vl=ya();Tl({target:"Array",proto:!0},{at:function(e){var t=Sl(this),r=wl(t),n=_l(e),s=n>=0?n:r+n;return s<0||s>=r?void 0:t[s]}});Vl("at")});var ba=f((xd,ga)=>{"use strict";var Rl=Fi();ga.exports=Rl});var Ca=f((Id,Ea)=>{"use strict";va();var Al=ba();Ea.exports=Al("Array","at")});var Ia=f((Td,xa)=>{"use strict";var Ml=Ca();xa.exports=Ml});var Sa=f((Sd,Ta)=>{"use strict";var Ol=Ia();Ta.exports=Ol});var jl={};Ua(jl,{CustomError:()=>z,EVENT_NAMES:()=>g,INTERACTIVE_CLICK_ACTIONS:()=>Nt,Interactives:()=>yt,ManifestController:()=>Ae,SDKInfo:()=>Nl,chapterIdsToVKVideoIds:()=>Qt,compareVersions:()=>ce,getChapterIdByVkVideoId:()=>Va,getVKVideoIdByMedia:()=>sr,getVideoRawIdByMedia:()=>wa,graphEventTypes:()=>De,hasEndTemplate:()=>st,interactivesEventTypes:()=>A,isLastChapter:()=>ae,isSupportedManifest:()=>rt,isVKVariantItem:()=>_a,utils:()=>ka,vkVideoIdsToChapterIds:()=>ar});module.exports=za(jl);var Tr="1.0.15-dev.cdca0fbd.0";function oi(i,e=1){let t="0",r="0",n="0";return i.length===4?(t="0x"+i[1]+i[1],r="0x"+i[2]+i[2],n="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],r="0x"+i[3]+i[4],n="0x"+i[5]+i[6]),`rgba(${+t},${+r},${+n},${e})`}var H="SDK_NAME",Wa="SDK_NAME-controls-container",Et=()=>document.querySelector(`.${Wa}`),Vr=.4,X={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Sr={top:"flex-start",bottom:"flex-end",center:"center"},wr={start:"flex-start",end:"flex-end",center:"center"},_r={start:"left",end:"right",center:"center"},Ct=({target:i,props:e})=>{var t,r,n,s,l,o;i.style.alignItems=(r=Sr[(t=e==null?void 0:e.text)==null?void 0:t.gravityVertical])!=null?r:Sr.center,i.style.justifyContent=(s=wr[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:wr.center,i.style.textAlign=(o=_r[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?o:_r.start},xt=({target:i,props:e,fallback:t,dependsOn:r})=>{var n,s,l,o,c,h;i.style.color=(s=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?s:t.textColor,i.style.fontSize=`calc(${r.height} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:t.textSize})`,i.textContent=(h=(c=e==null?void 0:e.text)==null?void 0:c.value)!=null?h:t.textContent},It=({target:i,props:e,fallback:t})=>{var r,n,s,l;i.style.backgroundColor=oi((n=(r=e==null?void 0:e.background)==null?void 0:r.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},Tt=({target:i,props:e,fallback:t,dependsOn:r})=>{var n,s,l,o,c,h,v,T,m,x,I;i.style.border=`calc(${r.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${oi((h=(c=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:c.color)!=null?h:t.borderColor,(m=(T=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:T.alpha)!=null?m:t.borderAlpha)}`,i.style.borderRadius=`calc(${r.height} * ${(I=(x=e==null?void 0:e.shape)==null?void 0:x.roundCorners)!=null?I:t.roundCorners})`},$e=({target:i,layoutParams:e,fallback:t})=>{i.style.transform=`rotate(${-e.angle}rad)`};var ci="int",Fe={AREA:`${ci}_area`,TEXT:`${ci}_text`,BUTTON:`${ci}_bttn`};var ve=class{constructor(e){this.control=e}createView(e){var n;let t=document.createElement("div");t.classList.add(`${H}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let r=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:X.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:t,dependsOn:r}}setEvents(e,t){e&&this.control.events.forEach(r=>{switch(r.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),t&&t({action:r.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${H}-control-container-${this.control.id}`)}};var St=i=>{if(i.type.trim().toLowerCase()==="area")return new li(i)},li=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:t}){let{dependsOn:r,controlContainerEl:n}=super.createView(t),s=document.createElement("button");return s.classList.add(`${H}-${this.control.id}`),s.setAttribute("data-testid",Fe.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",It({target:s,props:this.control.props,fallback:C(p({},X),{backgroundColor:"transparent"})}),Tt({target:s,props:this.control.props,fallback:C(p({},X),{borderAlpha:0}),dependsOn:r}),$e({target:s,layoutParams:this.control.layoutParams,fallback:X}),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${H}-${this.control.id}`)}};var wt=()=>{let i=document.createElement("span");return i.style.display="inline-block",i.style.whiteSpace="pre",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.maxWidth="100%",i.style.maxHeight="100%",i};var _t=i=>{if(i.type.trim().toLowerCase()==="button")return new hi(i)},hi=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:t}){let{dependsOn:r,controlContainerEl:n}=super.createView(t),s=document.createElement("button");s.type="button",s.classList.add(`${H}-${this.control.id}`),s.setAttribute("data-testid",Fe.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=wt();return $e({target:s,layoutParams:this.control.layoutParams,fallback:X}),It({target:s,props:this.control.props,fallback:X}),Tt({target:s,props:this.control.props,fallback:X,dependsOn:r}),Ct({target:s,props:this.control.props}),xt({target:l,props:this.control.props,fallback:X,dependsOn:r}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${H}-${this.control.id}`)}};var Rr=i=>{if(i.type.trim().toLowerCase()==="text")return new ui(i)},ui=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:t}){let{dependsOn:r,controlContainerEl:n}=super.createView(t),s=document.createElement("div");s.classList.add(`${H}-${this.control.id}`),s.setAttribute("data-testid",Fe.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=wt();return $e({target:s,layoutParams:this.control.layoutParams,fallback:X}),Ct({target:s,props:this.control.props}),xt({target:l,props:this.control.props,fallback:X,dependsOn:r}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){}enable(){}getElement(){return document.querySelector(`.${H}-${this.control.id}`)}};var pi=class{constructor(e){this.layout=e}},Ar=i=>{if(i.type.trim().toLowerCase()==="relative")return new Ze(i)},Ze=class extends pi{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 ge,Vt,Mr,Be=class{constructor(e){w(this,ge);this.container=e,this.factories=new Map,B(this,ge,Vt).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),B(this,ge,Vt).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),B(this,ge,Vt).call(this)}};ge=new WeakSet,Vt=function(){this.controls=B(this,ge,Mr).call(this)},Mr=function(){var e;return(e=this.container.controls)==null?void 0:e.reduce((t,r)=>{let n=r.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...t,s(r)]:[...t]},[])};var Rt=(i,e)=>{if(i.type.trim().toLowerCase()==="choice")return new di(i,e)},di=class extends Be{constructor(e,t){super(e),this.rootElement=t!=null?t:Et(),this.layout=new Ze(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",_t),this.addControlFactory("text",Rr),this.addControlFactory("area",St)}createView(e){let t=document.createElement("div");return t.classList.add(`${H}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(r=>{let n=r.createView({parent:t,layoutFn:this.layout.setControlLayout});r.setEvents(n,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=Vr,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${H}-${this.container.id}`)}};var $=require("@vkontakte/videoplayer-shared");var jr=require("@vkontakte/videoplayer-shared");function At(i,e){let t;return(...r)=>{clearTimeout(t),t=setTimeout(()=>i(...r),e)}}var _e=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,Je=i=>_e(i,"Object"),Mt=i=>_e(i,"String"),Ot=i=>_e(i,"Array"),Lt=i=>_e(i,"Number"),Or=i=>_e(i,"Function");var fi=i=>Lt(i)&&!isNaN(i);var Ve=i=>Je(i)&&Object.keys(i).length===0,mi=i=>Ot(i)&&!i.length;var et=(i,e)=>Mt(i)&&(e?i.trim():i).length;var Lr="video_interactive",Nr="videoint";var Ka=250,tt=class{constructor(e){te(this,"onResize",e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))});te(this,"handleChapterChange",e=>{var t;if(this.isReady){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),this.ngEditor.selectChapter(e.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=void 0}});te(this,"handleManifestChange",(r,...n)=>R(this,[r,...n],function*(e,t=[]){var s;if(!Lt(e.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)==null||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let l;try{l=yield(0,jr.loadVKLangPack)(this.lang,Lr,Nr)}catch(c){console.log("Unable to load graph language pack")}let{GraphEditor:o}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new o(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:l}),this.ngEditor.on("control",({name:c,chapterId:h})=>{c==="openPreview"&&this.onOpenPreviewClick(h)}),this.ngEditor.on("zoomEnd",c=>{this.lastZoomInfo=p({},c)})}this.visitedChapterIds=new Set(t),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}));this.init(e)}init({root:e,onOpenPreviewClick:t,onError:r,lang:n,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=r,this.lang=n!=null?n:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=Qa(e),this.resizeObserver=new ResizeObserver(At(this.onResize,Ka)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),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 Qa(i){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",i.append(e),e}var it=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,r=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){r=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!r&&t!==-1?t:null}}};var ce=(i="",e="")=>{let t=i.split("."),r=e.split("."),n=0;for(let s=0;s<Math.max(t.length,r.length)&&!n;s++)t[s]>r[s]?n=1:t[s]<r[s]?n=-1:n=0;return n};var kr=require("uuid");var Ya="3.1",Pr={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Xa={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},$r=i=>{let e=[];for(let l of i.chapters){let o,c=[];for(let t of l.branches){let r=t,{isDefault:T}=r,m=Y(r,["isDefault"]);T&&(o=m.id),c.push(m)}let h=[],v=[];for(let n of l.containers){let s=n,{fallbackStrategy:T}=s,m=Y(s,["fallbackStrategy"]);let x=!!m.endTime,I=[Xa];switch(T){case"await":x?I=[]:h=[];break;case"default":{let V={type:"onSuspense",action:{type:Pr.default,args:{branchId:o,shouldOpenNow:!x,isDetachContainer:!0}}};x?I=[V]:h=[V];break}case"random":case"weightlessRandom":case"max":case"min":{let V={type:"onSuspense",action:{type:Pr[T],args:{}}};x?I=[V]:h=[V];break}}for(let V of m.controls)v.push(C(p({},m),{controls:[p({},V)],id:(0,kr.v4)(),events:I}))}e.push(C(p({},l),{containers:v,events:h,branches:c}))}return i.metadata.version=Ya,i.metadata.updated=new Date().toISOString(),C(p({},i),{chapters:e})};var Za="3.2",Fr=i=>{if(!i.media){let e=i.metadata,{media:t}=e,r=Y(e,["media"]);return C(p({},i),{metadata:C(p({},r),{version:Za}),media:t})}return i};var Ja="3.3",eo=(i=[])=>({edit:{chapters:i},view:{}}),Br={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},qr=i=>{var n;let e=[],t=[];for(let s of i.chapters){let r=s,{id:l,x:o,y:c}=r,h=Y(r,["id","x","y"]),v=h.containers.map(T=>{var m;return C(p({},T),{controls:T.controls.map(_=>{var d=_,{subtype:x,type:I}=d,V=Y(d,["subtype","type"]);return C(p({},V),{type:x!=null?x:I})}),events:(m=T.events)!=null&&m.length?T.events:[Br]})});e.push(C(p({id:l},h),{containers:v,events:(n=h.events)!=null&&n.length?h.events:[Br]})),t.push({id:l,x:o,y:c})}return C(p({},i),{chapters:e,graph:eo(t),metadata:C(p({},i.metadata),{version:Ja})})};var to=[{version:"3.0",migrate:$r},{version:"3.1",migrate:Fr},{version:"3.2",migrate:qr}],yi=i=>to.reduce((e,t)=>ce(e.metadata.version,t.version)?e:t.migrate(e),i);var Yh=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),Dr=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Xh=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),P=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),Nt=(s=>(s.GO_NEXT_BUTTON="GO_NEXT_BUTTON",s.GO_NEXT_AREA="GO_NEXT_AREA",s.WATCH_AGAIN="WATCH_AGAIN",s.OPEN_GRAPH="OPEN_GRAPH",s.CLOSE_GRAPH="CLOSE_GRAPH",s))(Nt||{});var Hr={metadata:"Object",chapters:"Array"},io="3.0.0",ro="3.3.0",rt=i=>{let e=ce(i,io);return e===-1?!1:e===0?!0:ce(i,ro)!==1},Gr=i=>{if(!Je(i))return!1;for(let e in Hr)if(!i[e]||!_e(i[e],Hr[e]))return!1;return rt(i.metadata.version)},jt=i=>i.type===Dr.Text;var z=class{constructor(e,t,...r){this.severity=e;this.category=t;this.data=r}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var qe=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 r=()=>{t(),this.off(e,r)};return this.listeners[e].push(r),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let r=this.listeners[e]||[];for(let n=r.length;n>0;n--)if(r[n]===t){r.splice(n,1);break}return this}emit(e,...t){let r=this.listeners[e];return r?(r.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Pt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Or(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(r=>r!==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)};this.fn=e,this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Qr=require("@vkontakte/videoplayer-shared");var kt=class{constructor(e){var t,r;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(r=e==null?void 0:e.manifestLoaders)!=null?r:[]}}exec(e,t){return R(this,null,function*(){return no(...this.loaders[e])(t)})}};function no(...i){return function(t){return R(this,null,function*(){let r=[...i];for(;r.length>0;)t=yield r.shift()(t);return t})}}function nt(i,e,t){return i?C(p({},i),{[e]:i[e]?[t,...i[e]]:[t]}):{[e]:[t]}}function $t(n){var s=n,{actions:i,errors:e,chapterId:t}=s,r=Y(s,["actions","errors","chapterId"]);if(t){let l=i.getManifest(),o=i.getChapter(l.chapters,t);if(o){let c=i.getMedia(l.media,o.videoId),h=i.getGraph(l.graph,o.id);return c?C(p({},r),{actions:i,errors:e,result:{chapter:o,media:c,graph:h}}):C(p({},r),{errors:nt(e,$t.name,"Could not find media"),actions:i})}}return C(p({},r),{errors:nt(e,$t.name,"Could not find chapter"),actions:i})}var so=i=>R(void 0,null,function*(){try{let e,t;if(Je(i))e=i;else if(Mt(i)){t=new URL(i).href;let n=yield fetch(t);if(!n.ok)return{};e=yield n.json()}else return{};if(!Gr(e))return{};let r=e.metadata.media;if(Mt(r)&&!e.media)try{let n;t?n=new URL(r,t).href:(n=new URL(r).href,t=n);let s=yield fetch(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return co(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ur(i){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield so(i),r=yi(e);return r.media=ao(r.media,t),delete r.metadata.media,r})}function Ft(i,e){return i.find(t=>t.id===e)}function vi(i,e){var t,r;return(t=i.edit)!=null&&t.chapters?i.edit.chapters.find(n=>n.id===e):(r=i.view)!=null&&r.chapters?i.view.chapters.find(n=>n.id===e):void 0}function gi(i,e){return i.videos.find(t=>t.id===e)}function ao(i,e){return C(p({},i),{videos:i.videos.map(t=>C(p({},t),{variants:t.variants.map(r=>{let n=oo(r.url,e);return C(p({},r),{url:n||r.url})})}))})}function oo(i,e){try{return new URL(i,e).href}catch(t){return""}}function co(i){return ce(i,"3.2.0")>=0}var q=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Bt=i=>Ot(i)&&!mi(i),ae=i=>i.order==="end",st=i=>Ot(i.containers)&&!mi(i.containers)&&ae(i),zr=(i,e)=>{var r;let t=i*1e3;return Bt(e.controls)&&t<((r=e.startTime)!=null?r:0)},bi=(i,e)=>{var r,n;let t=i*1e3;return Bt(e.controls)&&t>=((r=e.startTime)!=null?r:0)&&t<=((n=e.endTime)!=null?n:1/0)};var Re=i=>i.some(e=>e.action.type==="expect"),Ei=i=>i.find(e=>e.action.type==="expect"),lo=i=>(i==null?void 0:i.length)===1,qt=i=>lo(i)&&jt(i[0]);var Wr=({fn:i,type:e=1},...t)=>(...r)=>e?i(...r,...t):i(p(p({},r[e]),t[e])),Kr=(i,e)=>Re(i.events)?!1:e.some(({container:t})=>t.container.id!==i.id&&Re(t.container.events)&&t.container.endTime===i.endTime&&!t.isRemoved);var Ae=class extends kt{constructor(e,t){super(e),this.onError=t,this.prevChapter$=new Qr.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(e){return R(this,null,function*(){var n;this.release();let t=yield this.exec("manifestLoaders",{actions:{addErrorMessage:nt},result:null,errors:null,source:e});t.errors&&this.errorHandler(t.errors);let r=yield Ur((n=t.result)!=null?n:e);return this.manifest=r,this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(this,arguments,function*(e=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let t=yield this.exec("chapterLoaders",$t({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:vi,getChapter:Ft,getMedia:gi,getByBranches:this.getByBranches.bind(this),addErrorMessage:nt},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph,this})}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){let t=Ft(this.manifest.chapters,e);if(t){let r=gi(this.manifest.media,t.videoId),n=vi(this.manifest.graph,t.id);if(r)return{chapter:t,media:r,graph:n}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{let t=Ft(this.manifest.chapters,e);return this.getByBranches(t==null?void 0:t.branches)}}getByBranches(e=[]){return e.reduce((t,r)=>{let n=this.getByChapterId(r.chapterId);return n&&t.push(n),t},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return ae(this.chapter)}};var Xr=require("@vkontakte/videoplayer-core"),Zr=require("@vkontakte/videoplayer-shared");var Yr=i=>{let e=i.variants.find(t=>{var r;return((r=t.payload)==null?void 0:r.type)==="vk"});if(e&&"payload"in e){let[t,r]=e.payload.id.split("_");return[t,r]}return[]};var g={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},De={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},A={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Ci(){let i=new Map;function e(o){var c=o,{listId:n=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=Y(c,["listId","itemId"]);let h=i.get(n),v=p({},l);return h?h[s]=v:i.set(n,{[s]:v}),p({listId:n,itemId:s},l)}function t(n,s){var o,c,h;let l=i.get(n);if(l){if(s)return(o=l[s])==null||o.player.destroy(),(c=l[s])==null||c.container.remove(),(h=l[s])==null||h.subscription.unsubscribe(),delete l[s],Object.keys(l).length||i.delete(n),!0;for(let v of Object.values(l))v.player.destroy(),v.container.remove();return i.delete(n),!0}else throw Error("Can't remove. Not find.")}function r(){for(let n of i)t(n[0])}return{createPlayer:e,removePlayer:t,map:i,removeAll:r}}function xi(i,e=[]){var s,l,o;let t={},r,n=!e.length;for(let c of i.variants)if(!r&&"cover"in c&&(r=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(t.MPEG=C(p({},t.MPEG),{[(s=c.standard)!=null?s:"Invariant quality"]:c.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(p({},t.MPEG),{[(l=c.standard)!=null?l:"Invariant quality"]:c.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(p({},t),{HLS:{type:"url",url:c.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(p({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break;default:break}return{sources:t,thumbUrl:r,title:(o=i.title)!=null?o:""}}var at=(i,e)=>{let t=i.info.currentQuality$.getValue(),r=i.info.availableQualities$.getValue();t!==e&&r.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))};var ot={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},ho=2;function Ii(i){let e=Ci(),t,r,n=new qe,s={},l=!1,o=null,c=!1,h;i&&v(i);function v(u){o=u}function T(u,b,S){var j;if(!o)throw Error("need to set interactive controller");if(!o.options)return;let O=((j=e.map.get(u))!=null?j:{})[b];if(O){s=p({chapterId:S,listId:u,itemId:b},O);let F=s.player;r=F.info.currentQuality$.subscribe(L=>{if(!(!L||!F.info.position$.getValue())){t=L;for(let re of e.map)Object.values(re[1]).forEach(({player:ee})=>{F.info.isAutoQualityEnabled$.getValue()||at(ee,L)})}}),O.container.remove(),l=!1,o.setPlayer(O.player),c||(o.init(),c=!0),n.emit(ot.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function m(u,b,S){return R(this,null,function*(){if(!o)throw Error("need to set interactive controller");if(Ve(s)||u!==s.itemId)return;if(S>=0&&!l){let O=o.getChapterBranches();l=!0;let j=new Set;for(let F of O)j.has(F.media.id)||(yield I({media:F.media,chapterId:F.chapter.id,setAsActive:!1,title:F.chapter.label}),j.add(F.media.id))}})}function x(S){return R(this,arguments,function*({chapter:{id:u},media:b}){if(Ve(s))return;r==null||r.unsubscribe();let y=s.player.info.muted$.getValue(),O=s.player.info.currentQuality$.getValue(),j=s.player.info.isAutoQualityEnabled$.getValue(),F=s.player.info.volume$.getValue(),L=s.player.info.currentPlaybackRate$.getValue(),re=!j,ee=!1;for(let K of e.map)if(K[0]===b.id){let ye=Object.keys(K[1]);for(let Q of ye)Q===s.itemId?(ye.length<ho||(ee=!0),e.removePlayer(K[0],Q)):(ee=!0,T(K[0],Q,u),re?at(s.player,O):s.player.setAutoQuality(!0),s.player.setVolume(F),s.player.setMuted(y),s.player.setPlaybackRate(L))}else e.removePlayer(K[0]);ee||(yield I({media:b,chapterId:u,setAsActive:!0,playbackRate:L}),re?at(s.player,O):s.player.setAutoQuality(!0),s.player.setVolume(F),s.player.setMuted(y))})}function I(re){return R(this,arguments,function*({media:u,chapterId:b,prefetch:S=!0,setAsActive:y=!0,autoplay:O=!1,preferredExt:j,title:F,playbackRate:L}){var fr,mr,yr,vr,gr;let ee=Math.random().toString(),K=document.createElement("div");h.append(K);let ye=(fr=s==null?void 0:s.player)==null?void 0:fr.info.isAutoQualityEnabled$.getValue(),Q;if((mr=o==null?void 0:o.options)!=null&&mr.vkVideoLoader){let gt=Yr(u);gt.length&&(Q=yield o.options.vkVideoLoader(...gt))}let ur=((yr=o==null?void 0:o.options)==null?void 0:yr.coreConfig)||{},$a=C(p({},ur),{configName:[...(vr=ur.configName)!=null?vr:[],"interactive"]}),pr=C(p({container:K},((gr=Q==null?void 0:Q.videos)==null?void 0:gr[0])||{sources:xi(u,j).sources}),{title:F,failoverHosts:(Q==null?void 0:Q.failoverHosts)||[]}),we=new Xr.Player($a);we.initVideo(pr);let dr=new Zr.Subscription;dr.add(we.info.position$.subscribe(function(gt){m(ee,we.info.duration$.getValue(),gt)})).add(we.events.canplay$.subscribe(function(){ye||at(we,t),L&&we.setPlaybackRate(L)}));let ke=e.createPlayer({listId:u.id,itemId:ee,player:we,container:K,sources:xi(u,j).sources,config:pr,subscription:dr});return y&&T(u.id,ke.itemId,b),O&&ke.player.play(),S&&!O&&ke.player.prepare(),n.emit(ot.playerCreated,ke.player),{player:ke.player,config:ke.config}})}function V(){_(),o=null}function _(){o==null||o.off(g.chapterChanged,x),e.removeAll(),s={},c=!1,l=!1}function d(b){return R(this,arguments,function*({container:u}){if(!o)throw Error("need to set interactive controller");_(),h=u;let{media:S,chapter:y}=o.getCurrentChapter();if(S){o.on(g.chapterChanged,x);let{player:O,config:j}=yield I({media:S,chapterId:y.id,title:y.label});return n.emit(ot.initiated,{container:u,media:S,chapterId:y.id}),{player:O,config:j}}else console.error("not found")})}return C(p({},e),{on:n.on.bind(n),off:n.off.bind(n),init:d,setInteractiveController:v,createPlayer:I,removeAll:V,getActivePlayer:function(){return s}})}var Jr=require("@vkontakte/videoplayer-shared");var Dt=class{constructor({player:e,container:t,branches:r,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:h,onRemove:v}){te(this,"hide",()=>{setTimeout(()=>{var e,t;this.gameState!==q.end&&(Re(this.container.container.events)&&this.gameState===q.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==q.interactive&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!1})))})});te(this,"show",()=>{var e,t,r,n;if(this.gameState===q.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(r=this.container).show)==null||n.call(r),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!0,isFirst:!1});else{let l=Wr({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!1})},onEvent:(o,c)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!1})),(this.gameState===q.end||this.gameState===q.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!1}))},isEOV:()=>this.gameState===q.end});this.container.createView(l),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}});te(this,"onEndOfVideo",()=>{this.gameState=q.end,this.selectContainerEvent(!0)});te(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[q.destroyed,q.removed].includes(this.gameState)&&!this.isPermanentText)return;let t=this.player.getExactTime();if(zr(t,this.container.container))this.gameState!==q.beforeInteractive&&(this.gameState=q.beforeInteractive,this.onBeforeStartTime());else if(bi(t,this.container.container))this.gameState!==q.interactive&&(this.gameState=q.interactive,this.onStartTime());else if(this.gameState!==q.afterInteractive){let o=this.gameState;this.gameState=q.afterInteractive,o===q.interactive&&this.onEndTime()}else this.gameState!==q.destroyed&&!this.isPermanentText&&this.removeView();let r=bi(t,this.container.container),n=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(g.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:n,currentTime:t,isInteractiveTime:r})});this.container=t,this.branches=r,this.selectBranches=n,this.subscription=new Jr.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&qt(t.container.controls),this.disabledControls$=h,this.onRemove=v,this.globalEventEmitter=l,this.gameState=q.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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,r,n,s;e?(r=(t=this.container).disable)==null||r.call(t):(s=(n=this.container).enable)==null||s.call(n)}))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,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(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=Re(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.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=q.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:A.containerRemoved,visibility:!1}),this.gameState=q.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=q.destroyed,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 en=(i=[])=>i.reduce((e,t,r)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(c=>!jt(c));if(Bt(n)){let c=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],h=t.id;if(!r)e.push({subjects:[h],range:c});else{let v=[],T=-1/0,m=1/0,x=[],I=[];for(let V=0;V<e.length;V++){let _=e[V];if(I.push(..._.subjects),_.range[0]<m&&(m=_.range[0]),_.range[1]>T&&(T=_.range[1]),c[0]>=_.range[0]&&c[1]<=_.range[1])return e[V].subjects.push(h),e;c[0]<_.range[0]&&c[1]>_.range[0]&&(v.push(V),x=x.concat(_.subjects)),c[0]>=_.range[0]&&c[0]<=_.range[1]&&(v.push(V),x=x.concat(_.subjects),c[0]=_.range[0]),c[1]>=_.range[0]&&c[1]<=_.range[1]&&(v.push(V),x=x.concat(_.subjects),c[1]=_.range[1])}if(I.push(h),c[0]<=m&&c[1]>=T)return[{subjects:I,range:c}];v.length&&v.reverse().forEach(V=>{e.splice(V,1)}),e.push({subjects:x.concat([h]),range:c})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function tn(){let i={};function e(){for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&delete i[o];return!0}function t(o){let c={};for(let h in i)+h<=o&&(c[h]=i[h]);return c}function r(o){let c={};for(let h in i)+h>=o&&(c[h]=i[h]);return c}function n({timestamp:o,priority:c,initiator:h}){var v;if(fi(o)){let T=(v=i[o])!=null?v:null;if(T&&et(c,!0)){let m={},x=T[c];if(x&&(m=p(p({},m),x)),m=Ve(m)?null:m,m&&et(h,!0)){let I=m[h];return I!=null?I:null}return m}return T}return null}function s({timestamp:o,priority:c,initiator:h}){if(fi(o))if(i[o]){if(et(c,!0))if(i[o][c]){if(et(h,!0))if(i[o][c][h]){if(delete i[o][c][h],!Ve(i[o][c]))return!0}else return!1;if(delete i[o][c],!Ve(i[o]))return!0}else return!1;return delete i[o]}else return!1}function l(T){var m=T,{timestamp:o,priority:c,initiator:h}=m,v=Y(m,["timestamp","priority","initiator"]);var x,I,V;(I=(x=i[o])==null?void 0:x[c])!=null&&I[h]?i[o][c][h].push(p({},v)):(V=i[o])!=null&&V[c]?i[o][c]=C(p({},i[o][c]),{[h]:[p({},v)]}):i[o]?i[o]=C(p({},i[o]),{[c]:{[h]:[p({},v)]}}):i[o]={[c]:{[h]:[p({},v)]}}}return{map:i,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:r}}var uo=[P.expect,P.setNextBranch],po=1/0;function Ti(i){let e=i,t,r=fo(),n=new tn,s,l=()=>{m(),d()},o=u=>{n.add.call(void 0,u),I()},c=(u=[])=>{for(let b of u)if(b.action(),uo.includes(b.actionType))break},h=(u=1/0)=>{var O,j,F;let b=Ht((O=n.get({timestamp:u,priority:"control"}))!=null?O:{}),S=Ht((j=n.get({timestamp:u,priority:"container"}))!=null?j:{}),y=Ht((F=n.get({timestamp:u,priority:"chapter"}))!=null?F:{});return[...b,...S,...y]},v=u=>{r.isReady(u)&&c(h(u))},T=()=>{var u;c([...Ht((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},m=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},x=u=>{},I=()=>{t||(t=()=>setTimeout(()=>{v(1/0)}),s=e.events.ended$.subscribe(t))},V=u=>{m(),e=u},_=u=>{u.priority==="container"&&r.resetCalled(u.timestamp),n.remove(u)},d=()=>{r.release(),n.removeAll()};return{setPlayer:V,add:o,remove:_,exec:v,execEndOfVideo:T,listen:I,unlisten:m,release:l,containersEventsCallState:r,getPreparedToExecActions:h}}function fo(){let i=new Map;return{setCalled:({timestamp:l,id:o})=>{let c=i.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(let h of l){let v=(o=h.endTime)!=null?o:po,T=(c=i.get(v))!=null?c:{};i.set(v,C(p({},T),{[h.id]:!1}))}},resetCalled:l=>{let o=i.get(l);if(o)for(let c in o)o[c]=!1},isReady:l=>{let o=i.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>i.clear()}}function Ht(i){return Object.values(i).flat().sort(e=>e.actionType===P.expect?-1:1)}var rn={videoContentHeight:0,videoContentWidth:0},nn=(i,e)=>{let{height:t,width:r}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&r))return rn;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return rn;let l=t/r,o=n/s,c,h;return o>l?(h=s,c=s*l):o<l?(h=n/l,c=n):(h=s,c=n),{videoContentWidth:h,videoContentHeight:c}};var mo=250;function sn(i){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function r(o){let{parentElement:c,player:h}=i();if(c&&h){let{videoContentWidth:v,videoContentHeight:T}=nn(c,h);c.style.setProperty("--interactive-content-width",`${v}px`),c.style.setProperty("--interactive-content-height",`${T}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=i();o.removeAttribute("style")}let s=At(o=>{let{fns:c=[]}=i();r(o);for(let h of c)h()},mo);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e()},release:l}}var ct=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(r=>r!==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 yo=i=>Math.floor(Math.random()*i),an=i=>{let e=i.length,t=1/0,r=null;for(;e--;)i[e].weight<t&&(t=i[e].weight,r=i[e]);return r},on=i=>{let e=i.length,t=-1/0,r=null;for(;e--;)i[e].weight>t&&(t=i[e].weight,r=i[e]);return r};var cn=i=>{let e=i.length,t=yo(e);return i[t]};var ln=i=>{var r,n;let e=0;for(let s=0;s<i.length;++s)e+=(r=i[s].weight)!=null?r:1;let t=Math.random()*e;e=0;for(let s=0;s<i.length-1;++s)if(e+=(n=i[s].weight)!=null?n:1,e>=t)return i[s];return i[i.length-1]};var hn=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var Si=(i,e=!1)=>C(p({},i),{args:e?p(p({},i.args),hn):p(p({},hn),i.args)}),wi=({globalEventEmitter:i,player:e,interactiveEvents:t,removeControllers:r})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:d,controlType:u,controlId:b,containerId:S,branches:y=[],onEvent:O,isEOV:j=()=>!1,isDisabled:F=()=>!1})=>{let L=Si(d,j()),re={timestamp:1/0,priority:"control",initiator:b,actionType:L.type},ee=F(),K=i.emit.bind(i,g.interactives,{subjectId:b,subjectType:u,subjectName:"control",type:ee?A.actionChoiceCanceled:A.actionChoice,actionType:d.type,payload:p({containerId:S},L.args)});if(ee){K();return}switch(L.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let ye=y.find(Q=>Q.id===L.args.branchId);if(!ye)return;O(L.args.isDetachContainer,m.bind(null,{subjectId:b,subjectName:"control"})),K(),L.args.shouldOpenNow?I({subjectId:b,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ye.chapterId,autoSelect:!1}}):(t.add(C(p({},re),{action:I.bind(null,{subjectId:b,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ye.chapterId,autoSelect:!1}})})),r==null||r());return}case P.continuePlayback.trim().toLowerCase():{O(L.args.isDetachContainer,m.bind(null,{subjectId:b,subjectName:"control"})),K(),L.args.shouldOpenNow?x({subjectId:b,subjectName:"control",subjectType:u,action:d}):t.add(C(p({},re),{action:x.bind(null,{subjectId:b,subjectName:"control",subjectType:u,action:d})}));return}case P.openURI.trim().toLowerCase():{O(L.args.isDetachContainer,m.bind(null,{subjectId:b,subjectName:"control"})),K(),L.args.shouldOpenNow?_({subjectId:b,subjectName:"control",subjectType:u,action:L,payload:{URI:d.args.uri}}):(t.add(C(p({},re),{action:_.bind(null,{subjectId:b,subjectName:"control",subjectType:u,action:L,payload:{URI:d.args.uri}})})),r==null||r());return}default:console.error("Unexpected control event"),i.emit(g.errors,new z(1,1,{message:"Unexpected control event"}));return}},o=({action:d,container:{id:u,endTime:b},branches:S=[],isEOV:y=!1,autoSelected:O=!1})=>{let j=Si(d,y),F={timestamp:!j.args.shouldOpenNow||y?1/0:b,priority:"container",initiator:u,actionType:j.type},L=i.emit.bind(i,g.interactives,{subjectId:u,subjectName:"container",type:A.actionChoice,actionType:j.type,payload:j.args});switch(j.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let re=S.find(ee=>ee.id===j.args.branchId);if(!re)return;L(),t.add(C(p({},F),{action:I.bind(null,{subjectId:u,subjectName:"container",action:j,payload:{chapterId:re.chapterId,autoSelect:O}})})),r==null||r();return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{L(),t.add(C(p({},F),{action:x.bind(null,{subjectId:u,subjectName:"container",action:j})}));return}case P.openURI.trim().toLowerCase():{L(),t.add(C(p({},F),{action:_.bind(null,{subjectId:u,subjectName:"container",action:j,payload:{URI:d.args.uri}})})),r==null||r();return}default:console.error("Unexpected container event"),i.emit(g.errors,new z(1,1,{message:"Unexpected container event"}));return}};function c({container:d,branches:u,isEOV:b=!1}){let S=Ei(d.events);if(S){let y=Si(S.action,b);i.emit(g.interactives,{subjectId:d.id,subjectName:"container",type:A.actionChoice,actionType:y.type,payload:y.args}),t.add({timestamp:b?1/0:d.endTime,priority:"container",initiator:d.id,actionType:P.expect,action:T.bind(null,{subjectId:d.id,subjectName:"container"})}),n.isExpect=!0}else for(let y of d.events)o({action:y.action,container:d,branches:u,isEOV:b})}let h=({chapterId:d,action:u,branches:b=[]})=>{let S=i.emit.bind(i,g.interactives,{subjectId:d,subjectName:"chapter",type:A.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let y=b.find(O=>O.id===u.args.branchId);return y!=null&&y.chapterId?(S(),I.bind(null,{subjectId:d,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let y=cn(b);return y!=null&&y.chapterId?(S(),I.bind(null,{subjectId:d,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let y=ln(b);return y!=null&&y.chapterId?(S(),I.bind(null,{subjectId:d,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let y=on(b);return y!=null&&y.chapterId?(S(),I.bind(null,{subjectId:d,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let y=an(b);return y!=null&&y.chapterId?(S(),I.bind(null,{subjectId:d,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return S(),x.bind(null,{subjectId:d,subjectName:"chapter",action:u});case P.openURI.trim().toLowerCase():return S(),_.bind(null,{subjectId:d,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),i.emit(g.errors,new z(1,1,{message:"Unexpected chapter event"}));return}};function v(d){let u=Ei(d.events);if(u){if(ae(d))return;i.emit(g.interactives,{subjectId:d.id,subjectName:"chapter",type:A.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:P.expect,action:T.bind(null,{subjectId:d.id,subjectName:"chapter"})})}else d.events.forEach(b=>{let S=h({chapterId:d.id,action:b.action,branches:d.branches});S&&t.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:b.action.type,action:S})})}let T=({subjectId:d,subjectName:u,action:b})=>{var S;e.pause(),i.emit(g.interactives,{subjectId:d,subjectName:u,type:A.actionExecution,actionType:(S=b==null?void 0:b.type)!=null?S:P.expect})},m=({subjectId:d,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),i.emit(g.interactives,{subjectId:d,subjectName:u,type:A.actionExecution,actionType:"after-expect"})},x=({subjectId:d,subjectName:u,subjectType:b,action:S})=>{i.emit(g.interactives,{subjectId:d,subjectName:u,subjectType:b,type:A.actionExecution,actionType:S.type})},I=({subjectId:d,subjectName:u,subjectType:b,action:S,payload:y})=>{y.behaviour="change-chapter",i.emit(g.interactives,{subjectId:d,subjectName:u,subjectType:b,type:A.actionExecution,actionType:S.type,payload:y})},V=({subjectId:d,subjectName:u,subjectType:b,action:S,payload:y})=>{y.behaviour="change-manifest",i.emit(g.interactives,{subjectId:d,subjectName:u,subjectType:b,type:A.actionExecution,actionType:S.type,payload:y})},_=({subjectId:d,subjectName:u,subjectType:b,action:S,payload:y})=>{if(!y.URI)return;let O=window.open(y.URI,"_blank","noopener,noreferrer");O&&(O.opener=null),i.emit(g.interactives,{subjectId:d,subjectName:u,subjectType:b,type:A.actionExecution,actionType:S.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:h,onExpectEvent:T,expectEventHandler:m,setManifestChapterEvents:v,setManifestContainerEvents:c,stopExpect:s,state:n}};var or=xr(Sa(),1),Ce=require("@vkontakte/videoplayer-shared");var Qt=(i,e)=>{let t={};return i.map(r=>{if(!t[r]){let n=e.chapters.find(l=>l.id===r);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[r]=sr(s)}return t[r]}).filter(Boolean)},wa=i=>{for(let e of i.variants)if(_a(e)&&"payload"in e)return e.payload.id},_a=i=>i.type==="custom"&&"payload"in i&&i.payload.type==="vk",sr=i=>{let e=wa(i);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Va=(i,e)=>{for(let t of i.media.videos)if(e===sr(t)){for(let r of i.chapters)if(r.videoId===t.id)return r.id;return}},ar=(i,e)=>i.reduce((t,r)=>{let n=Va(e,r);return n?[...t,n]:t},[]);var le,Oe,Le,ie,Yt,he,ue,se,Ne,We,Ke,ft=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:r,historyApi:n,settings:s}){this.state={history$:new Ce.ValueSubject([]),hasPrevChapter$:new Ce.ValueSubject(!1),prevChapter$:new Ce.ValueSubject(null),isInitialChapter$:new Ce.ValueSubject(!1),isGoBackLimited$:new Ce.ValueSubject(!1)};w(this,le,null);w(this,Oe);w(this,Le,!1);w(this,ie,null);w(this,Yt,null);w(this,he,null);w(this,ue,null);w(this,se,null);w(this,Ne,new Ce.Subscription);w(this,We,!1);w(this,Ke,0);var l,o,c;E(this,he,t),E(this,se,e),E(this,ue,r),E(this,le,n),E(this,Oe,s),(l=this.state)!=null&&l.history$&&a(this,Ne)&&((c=a(this,Ne))==null||c.add((o=this.state)==null?void 0:o.history$.subscribe(h=>{var v,T,m,x,I,V;(v=this.state)==null||v.prevChapter$.next((0,or.default)(h,-2)||null),(T=this.state)==null||T.hasPrevChapter$.next(h.length>1),(I=this.state)==null||I.isInitialChapter$.next(this.getInitialChapterId()===((x=(m=a(this,ie))==null?void 0:m.metadata)==null?void 0:x.initChapterId)),(V=this.state)==null||V.isGoBackLimited$.next(a(this,Ke)===a(this,Oe).maxLength-1)})))}setManifest(e){return R(this,null,function*(){!a(this,ue)||!a(this,se)||(E(this,ie,e),yield this.getProjectHistory(),yield a(this,ue).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,Le)||(E(this,Le,!0),a(this,se).emit(g.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,Le)}updateHistory(e,t=!0){return R(this,null,function*(){var o,c;if(!a(this,ie))return;a(this,We)?(E(this,We,!1),Ir(this,Ke)._++):E(this,Ke,0);let r=a(this,ie),n=e.length-a(this,Oe).maxLength,s=n>0?e.slice(n):e,l=Qt(s,r);if(E(this,Yt,l),(o=this==null?void 0:this.state)==null||o.history$.next(s),!(!t||!a(this,le)||!a(this,he)))try{yield a(this,le).save(a(this,he),l)}catch(h){(c=a(this,se))==null||c.emit(g.errors,new z(1,5,"Unable to save interactive history"))}})}goBack(){return R(this,null,function*(){var r;if(!this.state||!a(this,ue))return(r=a(this,se))==null?void 0:r.emit(g.errors,new z(1,5,"Cannot go back because HistoryController has not been initialized"));E(this,We,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield a(this,ue).setChapter({chapterId:t})})}getProjectHistory(){return R(this,null,function*(){var n,s;if(!a(this,ie)||!a(this,he))return;let e=a(this,ie),t=[this.getInitialVideoId()];if(a(this,le))try{let l=yield a(this,le).get(a(this,he));l.length&&(t=l)}catch(l){(n=a(this,se))==null||n.emit(g.errors,new z(1,5,"Error while trying to fetch data"))}let r=ar(t,e);(s=this==null?void 0:this.state)==null||s.history$.next(r)})}getInitialChapterId(){var t,r;let e=(t=this.state)==null?void 0:t.history$.getValue();return(0,or.default)(e,-1)||a(this,Oe).initChapterId||((r=a(this,ie))==null?void 0:r.metadata.initChapterId)}getInitialVideoId(){if(a(this,ie)){let e=this.getInitialChapterId();return Qt([e],a(this,ie)).pop()}return null}destroy(){var e,t;this.state=null,E(this,he,null),E(this,le,null),E(this,ue,null),(e=a(this,Ne))==null||e.unsubscribe(),E(this,Ne,null),E(this,Le,!1),(t=a(this,se))==null||t.emit(g.historyDestroyed),E(this,se,null)}};le=new WeakMap,Oe=new WeakMap,Le=new WeakMap,ie=new WeakMap,Yt=new WeakMap,he=new WeakMap,ue=new WeakMap,se=new WeakMap,Ne=new WeakMap,We=new WeakMap,Ke=new WeakMap;var je=class je{constructor(e,t,r,n){this.target=e,this.type=t,this.listener=r,this.options=je._convertOptions(e,n),this.target.addEventListener(t,r,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 r=new Set(["passive","capture"]),n=Object.keys(t).filter(l=>!r.has(l));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),je._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=je._supportsObject;if(t===void 0){t=!1;try{let r={},n={get:()=>(t=!0,!1)};Object.defineProperty(r,"passive",n),Object.defineProperty(r,"capture",n);let s=()=>{};e.addEventListener("test",s,r),e.removeEventListener("test",s,r)}catch(r){t=!1}je._supportsObject=t}return t||!1}};je._supportsObject=void 0;var Xt=je;var Zt=class{constructor(){this.bindingMap=new ct}release(){this.removeAll(),this.bindingMap=null}listen(e,t,r,n){if(!this.bindingMap)return;let s=new Xt(e,t,r,n);this.bindingMap.push(t,s)}listenOnce(e,t,r,n){let s=l=>{this.unlisten(e,t,s),r(l)};this.listen(e,t,s,n)}unlisten(e,t,r){if(!this.bindingMap)return;let n=this.bindingMap.get(t)||[];for(let s of n)s.target===e&&(r===s.listener||!r)&&(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 Jt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var 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,r=t.length;for(let s=3;s<r;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))}updateCanvasDimensions(e,t=!1){return R(this,null,function*(){let r=e.width+e.height;if(this._prevSizeId===r)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=r})}save(){return R(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var ei=class{constructor({parentElement:e,endOffsetMs:t=250,onError:r}){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,r=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(r)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,13 +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 Jt,this.endOffsetMs=t,this._callbacks={onError:r},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return R(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),r={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(r,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 r,n,s;return((r=t.controls)==null?void 0:r.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,r;(r=(t=this._callbacks)==null?void 0:t.onError)==null||r.call(t,e)}};function Ra(i=0){return new Promise(e=>{setTimeout(()=>{e(0)},i)})}var Aa=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,historyApi:null,historyParams:null,projectInfo:{},initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}}),pe=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function Ll(){let i=document.createElement("div");return i.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,t}var Ce,Z,xe,W,pe,U,J,fe,B,me,Qe,z,Ye,H,j,Ie,Le,lr,Wa,hr,Ka,Xe,cr,Si,ur,dr,Qa,vt,xi,je,Ne,mt,pr,Ya,gt,Ii,fr,Xa,mr,Za,yr,bt,yt=class{constructor(e){C(this,lr);C(this,hr);C(this,Xe);C(this,dr);C(this,vt);C(this,Ne);C(this,pr);C(this,gt);C(this,fr);C(this,mr);C(this,Ce,null);C(this,Z,null);C(this,xe,null);C(this,W,null);C(this,pe,null);C(this,U,null);C(this,J,null);C(this,fe,null);C(this,B,null);C(this,me,new $.ValueSubject(!1));C(this,Qe,new Set);C(this,z,null);C(this,Ye,null);C(this,H,null);C(this,j,null);C(this,Ie,Ar());C(this,Le,null);F(this,"state",{prevChapter$:new $.ValueSubject(null),isInitialChapter$:new $.ValueSubject(!1),isEndChapter$:new $.ValueSubject(!1),isInteractiveExpectation$:new $.ValueSubject(!1),calledByInteractive$:new $.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new $.ValueSubject(!1),disabledControls$:new $.ValueSubject(!1),interactiveRanges$:new $.ValueSubject([]),isInteractiveTime$:new $.ValueSubject(!1)});F(this,"events",{noInteraction$:new $.Subject});F(this,"emitPlayerChanged",e=>{a(this,j).emit(b.playerChanged,e)});C(this,Si,()=>{a(this,J).fns.forEach(i=>i());let e=this.options.player.info.position$.getValue()*1e3,r=(a(this,B).chapter.containers||[]).filter(i=>i.startTime>=Math.floor(e));for(let i of r){a(this,U).remove({timestamp:1/0,priority:"container",initiator:i.id});for(let n of i.controls)a(this,U).remove({timestamp:1/0,priority:"control",initiator:n.id});a(this,Z).find(n=>n.container.container.id===i.id).reset()}});C(this,ur,()=>{a(this,Ce).calc(),a(this,J).requestAnimation()});C(this,je,(e=!0)=>{a(this,Z).forEach(r=>{!e&&r.isPermanentText||(a(this,J).removeFn(r.whilePlaying),r.destroy())})});C(this,yr,e=>{let{interactiveRanges$:r}=this.state,n=r.getValue().map(s=>x(d({},s),{subjects:s.subjects.filter(l=>l!==e)}));r.next(n)});C(this,bt,()=>{a(this,Le)&&(clearTimeout(a(this,Le)),g(this,Le,null))});var r;this.options=x(d(d({},za),e),{config:d(d({},za.config),e.config)}),g(this,Z,[]),this.factories=new Map([["choice",Ot]]),this.rootElement=Zl(),this.options.parentElement.append(this.rootElement),g(this,j,new qe),g(this,pe,new $.Subscription),g(this,xe,new sr),g(this,W,new pt({interactiveController:this,globalEventEmitter:a(this,j),videoId:(r=this.options.projectInfo)==null?void 0:r.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}})),this.options.lastFrame&&g(this,H,new or({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:i=>a(this,j).emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.SEAMLESS,i))})),a(this,xe).listen(this.rootElement,"mousedown",i=>i.stopPropagation()),a(this,xe).listen(this.rootElement,"mouseup",i=>i.stopPropagation()),g(this,B,new Re(this.options.loaders,i=>a(this,j).emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.MANIFEST,i)))),g(this,U,Fr(this.options.player)),g(this,J,new Ft),g(this,fe,qr({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,j),removeControllers:a(this,je)})),g(this,Ce,gn(()=>{var i,n,s;return{player:(i=this.options)==null?void 0:i.player,parentElement:(n=this.options)==null?void 0:n.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,H).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&g(this,z,new it({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),a(this,j).emit(b.graph,{type:De.watchAgainClicked,chapterId:i})},onError:i=>a(this,j).emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.LOADERS,{message:i}))})),k(this,lr,Wa).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=de.created}getStatEvents(){return{click$:new $.Observable(e=>{a(this,j).on(b.graph,({type:r,visibility:i})=>{r==="visibility"&&e.next(i?"OPEN_GRAPH":"CLOSE_GRAPH"),r==="watchAgainClicked"&&e.next("WATCH_AGAIN")}),a(this,j).on(b.interactives,({type:r,subjectName:i,subjectType:n})=>{r!=="action-choice"||i!=="control"||(n==="Button"&&e.next("GO_NEXT_BUTTON"),n==="Area"&&e.next("GO_NEXT_AREA"))})}),nextMovie$:new $.Observable(e=>{a(this,j).on(b.playerChanged,({config:r})=>{r!=null&&r.unitedVideoId&&e.next(r.unitedVideoId)})})}}setPlayer(e){k(this,Xe,cr).call(this),this.options.player=e,a(this,Ie).setPlayer(this.options.player),a(this,U)?a(this,U).setPlayer(this.options.player):g(this,U,Fr(this.options.player)),g(this,fe,qr({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,j),removeControllers:()=>a(this,je).call(this,!1)})),this.appState===de.initiated&&(k(this,vt,xi).call(this),k(this,Ne,mt).call(this,a(this,B).chapter))}setManifest(e){return A(this,null,function*(){k(this,Xe,cr).call(this),this.isFirstChapterFetched=!1;let r=yield a(this,B).setManifest(e);return a(this,z)&&(yield a(this,z).handleManifestChange(r.manifest)),yield a(this,W).setManifest(r.manifest),a(this,j).emit(b.manifestChanged,{manifest:r.manifest}),k(this,Ne,mt).call(this,a(this,B).chapter),r.manifest})}setVisitedChapters(e){var r;Array.isArray(e)&&((r=a(this,z))==null||r.setVisitedChapters(e))}updateGraphVideosInfo(e){var r;Array.isArray(e)&&((r=a(this,z))==null||r.updateVideosInfo(e))}setChapter(){return A(this,arguments,function*({chapterId:e,pushToHistory:r=!0}={}){var o;k(this,Xe,cr).call(this),a(this,H)&&this.isFirstChapterFetched&&(a(this,H).draw(),a(this,H).show()),(0,$.getCurrentBrowser)().browser===$.CurrentClientBrowser.Safari&&(yield Ua(35));let{chapter:n,media:s,graph:l}=yield e?a(this,B).setNext(e):a(this,B).setInitial();return r&&k(this,mr,Za).call(this,n.id),this.state.isInitialChapter$.next(a(this,B).isInitialChapter()),this.state.isEndChapter$.next(a(this,B).isEndChapter()),a(this,z)&&a(this,z).handleChapterChange(l),(o=a(this,H))==null||o.setCurrentChapter(this.getCurrentChapter().chapter),a(this,j).emit(b.chapterChanged,{chapter:n,media:s,graph:l}),k(this,Ne,mt).call(this,a(this,B).chapter),g(this,Qe,new Set),this.isFirstChapterFetched=!0,{chapter:n,media:s,graph:l}})}toggleGraphView(e=!0){a(this,z)&&(e?(a(this,z).show(),a(this,me).next(!1)):(a(this,z).hide(),k(this,gt,Ii).call(this)),a(this,j).emit(b.graph,{type:De.visibility,visibility:e}))}init(){a(this,B).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===de.created&&(a(this,Ce).resizeObserver.observe(this.options.fullscreenTargetElement),k(this,vt,xi).call(this),this.appState=de.initiated,k(this,Ne,mt).call(this,a(this,B).chapter))}deadEndCheck(){var i,n;return!((n=(i=a(this,U))==null?void 0:i.getPreparedToExecActions())!=null?n:[]).some(s=>s.actionType===P.setNextBranch)}allControlsAreRemoved(){return!a(this,Z).some(r=>!r.container.isRemoved)}isEndedExpectation(){var i;if(!((i=this.options)!=null&&i.player)||!a(this,Z))return!1;let e=this.options.player.info.position$.getValue(),r=this.options.player.info.duration$.getValue();return e===r&&a(this,Z).some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&_e(s.events)})}playPrevChapter(){var e;(e=a(this,W))==null||e.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=a(this,B).manifest){return nt(e.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,W).getInitialVideoId(),chapterId:a(this,W).getInitialChapterId()}}getHistoryState(){return a(this,W).state}getIsSeekable(){return a(this,me)}getInteractiveRanges(){var e;return mn((e=a(this,B).chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return a(this,Ie).getNextInteractiveTime(e)}getChapterBranches(e){return a(this,B).getBranches(e)}getCurrentChapter(){return a(this,B).getCurrent()}getCurrentManifest(){return a(this,B).manifest}addFactory(e,r){this.factories.set(e.trim().toLowerCase(),r)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return a(this,j).on(...e),this}off(...e){return a(this,j).off(...e),this}once(...e){return a(this,j).once(...e),this}destroy(){var e,r;a(this,je).call(this),g(this,Z,void 0),this.state=void 0,(e=a(this,z))==null||e.destroy(),g(this,z,void 0),a(this,Ce).release(),g(this,Ce,void 0),g(this,fe,void 0),a(this,J).release(),g(this,J,void 0),a(this,U).release(),g(this,U,void 0),a(this,B).release(),g(this,fe,void 0),a(this,xe).release(),g(this,xe,void 0),a(this,pe).unsubscribe(),g(this,pe,void 0),a(this,j).reset(),g(this,j,void 0),(r=a(this,H))==null||r.destroy(),g(this,H,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,W).destroy(),g(this,W,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=de.destroyed}};Ce=new WeakMap,Z=new WeakMap,xe=new WeakMap,W=new WeakMap,pe=new WeakMap,U=new WeakMap,J=new WeakMap,fe=new WeakMap,B=new WeakMap,me=new WeakMap,Qe=new WeakMap,z=new WeakMap,Ye=new WeakMap,H=new WeakMap,j=new WeakMap,Ie=new WeakMap,Le=new WeakMap,lr=new WeakSet,Wa=function(e=!1){a(this,j).on(b.historyInited,n=>A(this,[n],function*({initChapterId:r,videosInfo:i=[]}){e&&(yield k(this,hr,Ka).call(this,{initialChapter:r,videosInfo:i}))})),a(this,j).on(b.interactives,r=>A(this,null,function*(){var i,n;if(r.type===M.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((i=r.payload)==null?void 0:i.behaviour)==="change-chapter"){let{chapterId:l}=r.payload;this.setChapter({chapterId:l})}if(((n=r.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:l}=r.payload;this.setManifest(l)}let s=r.type==="action-execution";s&&r.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):s&&r.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}r.type===M.containerRemoved&&a(this,yr).call(this,r.subjectId)})),a(this,j).on(b.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},hr=new WeakSet,Ka=function(i){return A(this,arguments,function*({source:e,videosInfo:r=[]}){g(this,Ye,$r(this));let n=document.createElement("div");a(this,Ye).on(ct.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:l}=yield a(this,Ye).init({source:e,initialChapter:a(this,W).getInitialChapterId(),container:n});return this.updateGraphVideosInfo(r),{player:s,config:l}})},Xe=new WeakSet,cr=function(){var e;this.appState===de.ready&&(a(this,je).call(this),g(this,Z,[]),a(this,J).release(),(e=a(this,U))==null||e.release(),this.appState=de.initiated,a(this,me).next(!1),a(this,bt).call(this))},Si=new WeakMap,ur=new WeakMap,dr=new WeakSet,Qa=function(e){(!a(this,z)||a(this,z).isHidden)&&k(this,gt,Ii).call(this);let r=e*1e3,n=this.getInteractiveRanges().findLast(({range:s})=>r>=s[1]);if(n){let s=n.range.join("-");a(this,Qe).has(s)||(a(this,Qe).add(s),a(this,j).emit(b.interactives,{type:M.rangeEnded,payload:n,visibility:!0}))}},vt=new WeakSet,xi=function(){a(this,pe).unsubscribe(),a(this,pe).add(this.options.player.events.started$.pipe((0,$.once)()).subscribe(a(this,ur))).add(this.options.player.events.playing$.subscribe(a(this,J).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,J).cancelAnimation)).add(this.options.player.info.position$.subscribe(k(this,dr,Qa).bind(this))).add(a(this,B).prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,$.combine)({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:i})=>{let n;if(i)n=!0;else{let s=e*1e3;n=!!(r==null?void 0:r.find(({range:[o,c],subjects:h})=>o<s&&s<c&&h.length))}n!==this.state.isInteractiveTime$.getValue()&&(this.state.isInteractiveTime$.next(n),n?g(this,Le,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):a(this,bt).call(this))})),this.options.lastFrame&&a(this,pe).add(this.options.player.info.duration$.subscribe(e=>{a(this,H).setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,H).setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,H).reset(),setTimeout(()=>{a(this,H).hide(),a(this,H).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,H).onSeek))},je=new WeakMap,Ne=new WeakSet,mt=function(e){a(this,B).chapter&&this.appState===de.initiated&&(a(this,fe).setManifestChapterEvents(e),g(this,Z,k(this,pr,Ya).call(this,e)),a(this,U).containersEventsCallState.setData(e.containers),a(this,Ie).setContainers(a(this,Z).map(r=>r.container.container).filter(r=>!Gt(r.controls))),this.options.lastFrame&&a(this,J).addFn(()=>{a(this,H).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=de.ready)},pr=new WeakSet,Ya=function(e){var r,i;return(i=(r=e==null?void 0:e.containers)==null?void 0:r.reduce((n,s)=>{let l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){let c=new Ut({player:this.options.player,container:o(s,this.rootElement),branches:a(this,B).chapter.branches,selectBranches:a(this,fe),interactiveEvents:a(this,U),globalEventEmitter:a(this,j),ignoreContainerEvent:()=>ln(s,a(this,Z)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,Ie).deleteContainer(s.id)}});return a(this,J).addFn(c.whilePlaying,!0),[...n,c]}return[...n]},[]))!=null?i:[]},gt=new WeakSet,Ii=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,me).next(!1);return}let r=a(this,me).getValue(),i=!!a(this,Ie).getNextInteractiveTime();(i&&!r||!i&&r)&&a(this,me).next(!r)},fr=new WeakSet,Xa=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},mr=new WeakSet,Za=function(e){var o;if(k(this,fr,Xa).call(this),!a(this,W).inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&se(i)&&at(i))!=null?o:!1,s=a(this,B).manifest.metadata.initChapterId===e,l=a(this,W).state.history$.getValue();if(s||n&&r){a(this,W).updateHistory([e]);return}l.at(-1)!==e&&a(this,W).updateHistory([...l,e])},yr=new WeakMap,bt=new WeakMap;var Ja={Container:Be,createChoiceContainer:Ot,createAreaControl:_t,createButtonControl:Vt,createRelativeLayout:Hi,getRootEl:xt,classnamesPrefix:G};var Jl={version:ki};
|
|
23
|
+
`,i}var xe,Z,Ie,W,de,G,J,fe,k,me,Qe,U,Ye,D,N,Te,Se,M,Ma,Oa,ti,hr,ii,La,cr,Pe,mt,Na,lr,ja,Pa,ri,vt,yt=class{constructor(e){w(this,M);w(this,xe,null);w(this,Z,null);w(this,Ie,null);w(this,W,null);w(this,de,null);w(this,G,null);w(this,J,null);w(this,fe,null);w(this,k,null);w(this,me,new $.ValueSubject(!1));w(this,Qe,new Set);w(this,U,null);w(this,Ye,null);w(this,D,null);w(this,N,null);w(this,Te,new it);w(this,Se,null);te(this,"state",{prevChapter$:new $.ValueSubject(null),isInitialChapter$:new $.ValueSubject(!1),isEndChapter$:new $.ValueSubject(!1),isInteractiveExpectation$:new $.ValueSubject(!1),calledByInteractive$:new $.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new $.ValueSubject(!1),disabledControls$:new $.ValueSubject(!1),interactiveRanges$:new $.ValueSubject([]),isInteractiveTime$:new $.ValueSubject(!1)});te(this,"events",{noInteraction$:new $.Subject});te(this,"emitPlayerChanged",e=>{a(this,N).emit(g.playerChanged,e)});w(this,hr,()=>{a(this,J).fns.forEach(r=>r());let e=this.options.player.info.position$.getValue()*1e3,t=(a(this,k).chapter.containers||[]).filter(r=>r.startTime>=Math.floor(e));for(let r of t){a(this,G).remove({timestamp:1/0,priority:"container",initiator:r.id});for(let n of r.controls)a(this,G).remove({timestamp:1/0,priority:"control",initiator:n.id});a(this,Z).find(n=>n.container.container.id===r.id).reset()}});w(this,ii,()=>{a(this,xe).calc(),a(this,J).requestAnimation()});w(this,Pe,(e=!0)=>{a(this,Z).forEach(t=>{!e&&t.isPermanentText||(a(this,J).removeFn(t.whilePlaying),t.destroy())})});w(this,ri,e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(s=>C(p({},s),{subjects:s.subjects.filter(l=>l!==e)}));t.next(n)});w(this,vt,()=>{a(this,Se)&&(clearTimeout(a(this,Se)),E(this,Se,null))});var t;this.options=C(p(p({},Aa),e),{config:p(p({},Aa.config),e.config)}),E(this,Z,[]),this.factories=new Map([["choice",Rt]]),this.rootElement=Ll(),this.options.parentElement.append(this.rootElement),E(this,N,new qe),E(this,de,new $.Subscription),E(this,Ie,new Zt),E(this,W,new ft({interactiveController:this,globalEventEmitter:a(this,N),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&&E(this,D,new ei({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:r=>a(this,N).emit(g.errors,new z(1,6,r))})),a(this,Ie).listen(this.rootElement,"mousedown",r=>r.stopPropagation()),a(this,Ie).listen(this.rootElement,"mouseup",r=>r.stopPropagation()),E(this,k,new Ae(this.options.loaders,r=>a(this,N).emit(g.errors,new z(1,3,r)))),E(this,G,Ti(this.options.player)),E(this,J,new Pt),E(this,fe,wi({player:this.options.player,interactiveEvents:a(this,G),globalEventEmitter:a(this,N),removeControllers:a(this,Pe)})),E(this,xe,sn(()=>{var r,n,s;return{player:(r=this.options)==null?void 0:r.player,parentElement:(n=this.options)==null?void 0:n.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,D).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&E(this,U,new tt({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:r=>{this.setChapter({chapterId:r}),a(this,N).emit(g.graph,{type:De.watchAgainClicked,chapterId:r})},onError:r=>a(this,N).emit(g.errors,new z(1,4,{message:r}))})),B(this,M,Ma).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=pe.created}getStatEvents(){return{click$:new $.Observable(e=>{a(this,N).on(g.graph,({type:t,visibility:r})=>{t==="visibility"&&e.next(r?"OPEN_GRAPH":"CLOSE_GRAPH"),t==="watchAgainClicked"&&e.next("WATCH_AGAIN")}),a(this,N).on(g.interactives,({type:t,subjectName:r,subjectType:n})=>{t!=="action-choice"||r!=="control"||(n==="Button"&&e.next("GO_NEXT_BUTTON"),n==="Area"&&e.next("GO_NEXT_AREA"))})}),nextMovie$:new $.Observable(e=>{a(this,N).on(g.playerChanged,({config:t})=>{t!=null&&t.unitedVideoId&&e.next(t.unitedVideoId)})})}}setPlayer(e){B(this,M,ti).call(this),this.options.player=e,a(this,Te).setPlayer(this.options.player),a(this,G)?a(this,G).setPlayer(this.options.player):E(this,G,Ti(this.options.player)),E(this,fe,wi({player:this.options.player,interactiveEvents:a(this,G),globalEventEmitter:a(this,N),removeControllers:()=>a(this,Pe).call(this,!1)})),this.appState===pe.initiated&&(B(this,M,cr).call(this),B(this,M,mt).call(this,a(this,k).chapter))}setManifest(e){return R(this,null,function*(){B(this,M,ti).call(this),this.isFirstChapterFetched=!1;let t=yield a(this,k).setManifest(e);return a(this,U)&&(yield a(this,U).handleManifestChange(t.manifest)),yield a(this,W).setManifest(t.manifest),a(this,N).emit(g.manifestChanged,{manifest:t.manifest}),B(this,M,mt).call(this,a(this,k).chapter),t.manifest})}setVisitedChapters(e){var t;Array.isArray(e)&&((t=a(this,U))==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=a(this,U))==null||t.updateVideosInfo(e))}setChapter(){return R(this,arguments,function*({chapterId:e,pushToHistory:t=!0}={}){var l;B(this,M,ti).call(this),a(this,D)&&this.isFirstChapterFetched&&(a(this,D).draw(),a(this,D).show()),$.clientChecker.isSafari&&(yield Ra(35));let{chapter:r,media:n,graph:s}=yield e?a(this,k).setNext(e):a(this,k).setInitial();return t&&B(this,M,Pa).call(this,r.id),this.state.isInitialChapter$.next(a(this,k).isInitialChapter()),this.state.isEndChapter$.next(a(this,k).isEndChapter()),a(this,U)&&a(this,U).handleChapterChange(s),(l=a(this,D))==null||l.setCurrentChapter(this.getCurrentChapter().chapter),a(this,N).emit(g.chapterChanged,{chapter:r,media:n,graph:s}),B(this,M,mt).call(this,a(this,k).chapter),E(this,Qe,new Set),this.isFirstChapterFetched=!0,{chapter:r,media:n,graph:s}})}toggleGraphView(e=!0){a(this,U)&&(e?(a(this,U).show(),a(this,me).next(!1)):(a(this,U).hide(),B(this,M,lr).call(this)),a(this,N).emit(g.graph,{type:De.visibility,visibility:e}))}init(){a(this,k).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===pe.created&&(a(this,xe).resizeObserver.observe(this.options.fullscreenTargetElement),B(this,M,cr).call(this),this.appState=pe.initiated,B(this,M,mt).call(this,a(this,k).chapter))}deadEndCheck(){var r,n;return!((n=(r=a(this,G))==null?void 0:r.getPreparedToExecActions())!=null?n:[]).some(s=>s.actionType===P.setNextBranch)}allControlsAreRemoved(){return!a(this,Z).some(t=>!t.container.isRemoved)}isEndedExpectation(){var r;if(!((r=this.options)!=null&&r.player)||!a(this,Z))return!1;let e=this.options.player.info.position$.getValue(),t=this.options.player.info.duration$.getValue();return e===t&&a(this,Z).some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&Re(s.events)})}playPrevChapter(){var e;(e=a(this,W))==null||e.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=a(this,k).manifest){return rt(e.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,W).getInitialVideoId(),chapterId:a(this,W).getInitialChapterId()}}getHistoryState(){return a(this,W).state}getIsSeekable(){return a(this,me)}getInteractiveRanges(){var e;return en((e=a(this,k).chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return a(this,Te).getNextInteractiveTime(e)}getChapterBranches(e){return a(this,k).getBranches(e)}getCurrentChapter(){return a(this,k).getCurrent()}getCurrentManifest(){return a(this,k).manifest}addFactory(e,t){this.factories.set(e.trim().toLowerCase(),t)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return a(this,N).on(...e),this}off(...e){return a(this,N).off(...e),this}once(...e){return a(this,N).once(...e),this}destroy(){var e,t;a(this,Pe).call(this),E(this,Z,void 0),this.state=void 0,(e=a(this,U))==null||e.destroy(),E(this,U,void 0),a(this,xe).release(),E(this,xe,void 0),E(this,fe,void 0),a(this,J).release(),E(this,J,void 0),a(this,G).release(),E(this,G,void 0),a(this,k).release(),E(this,fe,void 0),a(this,Ie).release(),E(this,Ie,void 0),a(this,de).unsubscribe(),E(this,de,void 0),a(this,N).reset(),E(this,N,void 0),(t=a(this,D))==null||t.destroy(),E(this,D,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,W).destroy(),E(this,W,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=pe.destroyed}};xe=new WeakMap,Z=new WeakMap,Ie=new WeakMap,W=new WeakMap,de=new WeakMap,G=new WeakMap,J=new WeakMap,fe=new WeakMap,k=new WeakMap,me=new WeakMap,Qe=new WeakMap,U=new WeakMap,Ye=new WeakMap,D=new WeakMap,N=new WeakMap,Te=new WeakMap,Se=new WeakMap,M=new WeakSet,Ma=function(e=!1){a(this,N).on(g.historyInited,n=>R(this,[n],function*({initChapterId:t,videosInfo:r=[]}){e&&(yield B(this,M,Oa).call(this,{initialChapter:t,videosInfo:r}))})),a(this,N).on(g.interactives,t=>R(this,null,function*(){var r,n;if(t.type===A.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((r=t.payload)==null?void 0:r.behaviour)==="change-chapter"){let{chapterId:l}=t.payload;this.setChapter({chapterId:l})}if(((n=t.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:l}=t.payload;this.setManifest(l)}let s=t.type==="action-execution";s&&t.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):s&&t.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}t.type===A.containerRemoved&&a(this,ri).call(this,t.subjectId)})),a(this,N).on(g.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},Oa=function(r){return R(this,arguments,function*({source:e,videosInfo:t=[]}){E(this,Ye,Ii(this));let n=document.createElement("div");a(this,Ye).on(ot.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:l}=yield a(this,Ye).init({source:e,initialChapter:a(this,W).getInitialChapterId(),container:n});return this.updateGraphVideosInfo(t),{player:s,config:l}})},ti=function(){var e;this.appState===pe.ready&&(a(this,Pe).call(this),E(this,Z,[]),a(this,J).release(),(e=a(this,G))==null||e.release(),this.appState=pe.initiated,a(this,me).next(!1),a(this,vt).call(this))},hr=new WeakMap,ii=new WeakMap,La=function(e){(!a(this,U)||a(this,U).isHidden)&&B(this,M,lr).call(this);let t=e*1e3,n=this.getInteractiveRanges().findLast(({range:s})=>t>=s[1]);if(n){let s=n.range.join("-");a(this,Qe).has(s)||(a(this,Qe).add(s),a(this,N).emit(g.interactives,{type:A.rangeEnded,payload:n,visibility:!0}))}},cr=function(){a(this,de).unsubscribe(),a(this,de).add(this.options.player.events.started$.pipe((0,$.once)()).subscribe(a(this,ii))).add(this.options.player.events.playing$.subscribe(a(this,J).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,J).cancelAnimation)).add(this.options.player.info.position$.subscribe(B(this,M,La).bind(this))).add(a(this,k).prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,$.combine)({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:r})=>{let n;if(r)n=!0;else{let c=e*1e3;n=!!(t==null?void 0:t.find(({range:[v,T],subjects:m})=>v<c&&c<T&&m.length))}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=a(this,Se)!==null,o=this.options.player.info.playbackState$.getValue()==="playing"||r;n&&!s&&o?E(this,Se,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):s&&!o&&a(this,vt).call(this)})),this.options.lastFrame&&a(this,de).add(this.options.player.info.duration$.subscribe(e=>{a(this,D).setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,D).setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,D).reset(),setTimeout(()=>{a(this,D).hide(),a(this,D).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,D).onSeek))},Pe=new WeakMap,mt=function(e){a(this,k).chapter&&this.appState===pe.initiated&&(a(this,fe).setManifestChapterEvents(e),E(this,Z,B(this,M,Na).call(this,e)),a(this,G).containersEventsCallState.setData(e.containers),a(this,Te).setContainers(a(this,Z).map(t=>t.container.container).filter(t=>!qt(t.controls))),this.options.lastFrame&&a(this,J).addFn(()=>{a(this,D).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=pe.ready)},Na=function(e){var t,r;return(r=(t=e==null?void 0:e.containers)==null?void 0:t.reduce((n,s)=>{let l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){let c=new Dt({player:this.options.player,container:o(s,this.rootElement),branches:a(this,k).chapter.branches,selectBranches:a(this,fe),interactiveEvents:a(this,G),globalEventEmitter:a(this,N),ignoreContainerEvent:()=>Kr(s,a(this,Z)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,Te).deleteContainer(s.id)}});return a(this,J).addFn(c.whilePlaying,!0),[...n,c]}return[...n]},[]))!=null?r:[]},lr=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,me).next(!1);return}let t=a(this,me).getValue(),r=!!a(this,Te).getNextInteractiveTime();(r&&!t||!r&&t)&&a(this,me).next(!t)},ja=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},Pa=function(e){var o;if(B(this,M,ja).call(this),!a(this,W).inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),r=this.state.prevChapter$.getValue(),n=(o=r&&ae(r)&&st(r))!=null?o:!1,s=a(this,k).manifest.metadata.initChapterId===e,l=a(this,W).state.history$.getValue();if(s||n&&t){a(this,W).updateHistory([e]);return}l.at(-1)!==e&&a(this,W).updateHistory([...l,e])},ri=new WeakMap,vt=new WeakMap;var ka={Container:Be,createChoiceContainer:Rt,createAreaControl:St,createButtonControl:_t,createRelativeLayout:Ar,getRootEl:Et,classnamesPrefix:H};var Nl={version:Tr};
|