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