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