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