@vkontakte/videoplayer-interactive 1.0.21 → 1.0.22-dev.71ddf25e.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.21
3
- * Fri, 04 Oct 2024 14:28:56 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-21/doc/
2
+ * @vkontakte/videoplayer-interactive v1.0.22-dev.71ddf25e.0
3
+ * Mon, 14 Oct 2024 11:34:11 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-22/doc/
5
5
  */
6
- "use strict";var da=Object.create;var Re=Object.defineProperty,fa=Object.defineProperties,ma=Object.getOwnPropertyDescriptor,ya=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertyNames,Je=Object.getOwnPropertySymbols,ga=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty,Xr=Object.prototype.propertyIsEnumerable;var Jr=r=>{throw TypeError(r)};var Ft=(r,e,t)=>e in r?Re(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,h=(r,e)=>{for(var t in e||(e={}))$t.call(e,t)&&Ft(r,t,e[t]);if(Je)for(var t of Je(e))Xr.call(e,t)&&Ft(r,t,e[t]);return r},E=(r,e)=>fa(r,ya(e));var j=(r,e)=>{var t={};for(var i in r)$t.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Je)for(var i of Je(r))e.indexOf(i)<0&&Xr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ba=(r,e)=>{for(var t in e)Re(r,t,{get:e[t],enumerable:!0})},ei=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of va(e))!$t.call(r,n)&&n!==t&&Re(r,n,{get:()=>e[n],enumerable:!(i=ma(e,n))||i.enumerable});return r};var Bt=(r,e,t)=>(t=r!=null?da(ga(r)):{},ei(e||!r||!r.__esModule?Re(t,"default",{value:r,enumerable:!0}):t,r)),Ca=r=>ei(Re({},"__esModule",{value:!0}),r);var Ve=(r,e,t)=>Ft(r,typeof e!="symbol"?e+"":e,t),qt=(r,e,t)=>e.has(r)||Jr("Cannot "+t);var S=(r,e,t)=>(qt(r,e,"read from private field"),t?t.call(r):e.get(r)),q=(r,e,t)=>e.has(r)?Jr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,i)=>(qt(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ae=(r,e,t)=>(qt(r,e,"access private method"),t);var ti=(r,e,t,i)=>({set _(n){N(r,e,n,t)},get _(){return S(r,e,i)}});var _=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{o(t.next(a))}catch(c){n(c)}},l=a=>{try{o(t.throw(a))}catch(c){n(c)}},o=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var K=f((Qt,ci)=>{"use strict";var ke=function(r){return r&&r.Math===Math&&r};ci.exports=ke(typeof globalThis=="object"&&globalThis)||ke(typeof window=="object"&&window)||ke(typeof self=="object"&&self)||ke(typeof global=="object"&&global)||ke(typeof Qt=="object"&&Qt)||function(){return this}()||Function("return this")()});var re=f((Zc,ui)=>{"use strict";ui.exports=function(r){try{return!!r()}catch(e){return!0}}});var Pe=f((Xc,hi)=>{"use strict";var Ia=re();hi.exports=!Ia(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var yi=f((Jc,mi)=>{"use strict";var xa=Pe(),fi=Function.prototype,pi=fi.apply,di=fi.call;mi.exports=typeof Reflect=="object"&&Reflect.apply||(xa?di.bind(pi):function(){return di.apply(pi,arguments)})});var ae=f((eu,bi)=>{"use strict";var vi=Pe(),gi=Function.prototype,Yt=gi.call,Ta=vi&&gi.bind.bind(Yt,Yt);bi.exports=vi?Ta:function(r){return function(){return Yt.apply(r,arguments)}}});var Zt=f((tu,Ei)=>{"use strict";var Ci=ae(),wa=Ci({}.toString),Sa=Ci("".slice);Ei.exports=function(r){return Sa(wa(r),8,-1)}});var Xt=f((ru,Ii)=>{"use strict";var _a=Zt(),La=ae();Ii.exports=function(r){if(_a(r)==="Function")return La(r)}});var ie=f((iu,xi)=>{"use strict";var Jt=typeof document=="object"&&document.all;xi.exports=typeof Jt=="undefined"&&Jt!==void 0?function(r){return typeof r=="function"||r===Jt}:function(r){return typeof r=="function"}});var Ee=f((nu,Ti)=>{"use strict";var Ma=re();Ti.exports=!Ma(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var pt=f((su,wi)=>{"use strict";var Ra=Pe(),ht=Function.prototype.call;wi.exports=Ra?ht.bind(ht):function(){return ht.apply(ht,arguments)}});var Mi=f(Li=>{"use strict";var Si={}.propertyIsEnumerable,_i=Object.getOwnPropertyDescriptor,Va=_i&&!Si.call({1:2},1);Li.f=Va?function(e){var t=_i(this,e);return!!t&&t.enumerable}:Si});var er=f((ou,Ri)=>{"use strict";Ri.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ai=f((lu,Vi)=>{"use strict";var Aa=ae(),ka=re(),Pa=Zt(),tr=Object,Oa=Aa("".split);Vi.exports=ka(function(){return!tr("z").propertyIsEnumerable(0)})?function(r){return Pa(r)==="String"?Oa(r,""):tr(r)}:tr});var rr=f((cu,ki)=>{"use strict";ki.exports=function(r){return r==null}});var ir=f((uu,Pi)=>{"use strict";var Na=rr(),ja=TypeError;Pi.exports=function(r){if(Na(r))throw new ja("Can't call method on "+r);return r}});var Ni=f((hu,Oi)=>{"use strict";var Fa=Ai(),$a=ir();Oi.exports=function(r){return Fa($a(r))}});var Oe=f((pu,ji)=>{"use strict";var Ba=ie();ji.exports=function(r){return typeof r=="object"?r!==null:Ba(r)}});var nr=f((du,Fi)=>{"use strict";Fi.exports={}});var or=f((fu,Bi)=>{"use strict";var sr=nr(),ar=K(),qa=ie(),$i=function(r){return qa(r)?r:void 0};Bi.exports=function(r,e){return arguments.length<2?$i(sr[r])||$i(ar[r]):sr[r]&&sr[r][e]||ar[r]&&ar[r][e]}});var Di=f((mu,qi)=>{"use strict";var Da=ae();qi.exports=Da({}.isPrototypeOf)});var zi=f((yu,Ui)=>{"use strict";var Ha=K(),Hi=Ha.navigator,Gi=Hi&&Hi.userAgent;Ui.exports=Gi?String(Gi):""});var Ji=f((vu,Xi)=>{"use strict";var Zi=K(),lr=zi(),Wi=Zi.process,Ki=Zi.Deno,Qi=Wi&&Wi.versions||Ki&&Ki.version,Yi=Qi&&Qi.v8,U,dt;Yi&&(U=Yi.split("."),dt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!dt&&lr&&(U=lr.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=lr.match(/Chrome\/(\d+)/),U&&(dt=+U[1])));Xi.exports=dt});var cr=f((gu,tn)=>{"use strict";var en=Ji(),Ga=re(),Ua=K(),za=Ua.String;tn.exports=!!Object.getOwnPropertySymbols&&!Ga(function(){var r=Symbol("symbol detection");return!za(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&en&&en<41})});var ur=f((bu,rn)=>{"use strict";var Wa=cr();rn.exports=Wa&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var hr=f((Cu,nn)=>{"use strict";var Ka=or(),Qa=ie(),Ya=Di(),Za=ur(),Xa=Object;nn.exports=Za?function(r){return typeof r=="symbol"}:function(r){var e=Ka("Symbol");return Qa(e)&&Ya(e.prototype,Xa(r))}});var an=f((Eu,sn)=>{"use strict";var Ja=String;sn.exports=function(r){try{return Ja(r)}catch(e){return"Object"}}});var pr=f((Iu,on)=>{"use strict";var eo=ie(),to=an(),ro=TypeError;on.exports=function(r){if(eo(r))return r;throw new ro(to(r)+" is not a function")}});var cn=f((xu,ln)=>{"use strict";var io=pr(),no=rr();ln.exports=function(r,e){var t=r[e];return no(t)?void 0:io(t)}});var hn=f((Tu,un)=>{"use strict";var dr=pt(),fr=ie(),mr=Oe(),so=TypeError;un.exports=function(r,e){var t,i;if(e==="string"&&fr(t=r.toString)&&!mr(i=dr(t,r))||fr(t=r.valueOf)&&!mr(i=dr(t,r))||e!=="string"&&fr(t=r.toString)&&!mr(i=dr(t,r)))return i;throw new so("Can't convert object to primitive value")}});var dn=f((wu,pn)=>{"use strict";pn.exports=!0});var yn=f((Su,mn)=>{"use strict";var fn=K(),ao=Object.defineProperty;mn.exports=function(r,e){try{ao(fn,r,{value:e,configurable:!0,writable:!0})}catch(t){fn[r]=e}return e}});var yr=f((_u,bn)=>{"use strict";var oo=dn(),lo=K(),co=yn(),vn="__core-js_shared__",gn=bn.exports=lo[vn]||co(vn,{});(gn.versions||(gn.versions=[])).push({version:"3.38.0",mode:oo?"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 In=f((Lu,En)=>{"use strict";var Cn=yr();En.exports=function(r,e){return Cn[r]||(Cn[r]=e||{})}});var vr=f((Mu,xn)=>{"use strict";var uo=ir(),ho=Object;xn.exports=function(r){return ho(uo(r))}});var ft=f((Ru,Tn)=>{"use strict";var po=ae(),fo=vr(),mo=po({}.hasOwnProperty);Tn.exports=Object.hasOwn||function(e,t){return mo(fo(e),t)}});var Sn=f((Vu,wn)=>{"use strict";var yo=ae(),vo=0,go=Math.random(),bo=yo(1 .toString);wn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+bo(++vo+go,36)}});var Mn=f((Au,Ln)=>{"use strict";var Co=K(),Eo=In(),_n=ft(),Io=Sn(),xo=cr(),To=ur(),Ie=Co.Symbol,gr=Eo("wks"),wo=To?Ie.for||Ie:Ie&&Ie.withoutSetter||Io;Ln.exports=function(r){return _n(gr,r)||(gr[r]=xo&&_n(Ie,r)?Ie[r]:wo("Symbol."+r)),gr[r]}});var kn=f((ku,An)=>{"use strict";var So=pt(),Rn=Oe(),Vn=hr(),_o=cn(),Lo=hn(),Mo=Mn(),Ro=TypeError,Vo=Mo("toPrimitive");An.exports=function(r,e){if(!Rn(r)||Vn(r))return r;var t=_o(r,Vo),i;if(t){if(e===void 0&&(e="default"),i=So(t,r,e),!Rn(i)||Vn(i))return i;throw new Ro("Can't convert object to primitive value")}return e===void 0&&(e="number"),Lo(r,e)}});var br=f((Pu,Pn)=>{"use strict";var Ao=kn(),ko=hr();Pn.exports=function(r){var e=Ao(r,"string");return ko(e)?e:e+""}});var jn=f((Ou,Nn)=>{"use strict";var Po=K(),On=Oe(),Cr=Po.document,Oo=On(Cr)&&On(Cr.createElement);Nn.exports=function(r){return Oo?Cr.createElement(r):{}}});var Er=f((Nu,Fn)=>{"use strict";var No=Ee(),jo=re(),Fo=jn();Fn.exports=!No&&!jo(function(){return Object.defineProperty(Fo("div"),"a",{get:function(){return 7}}).a!==7})});var qn=f(Bn=>{"use strict";var $o=Ee(),Bo=pt(),qo=Mi(),Do=er(),Ho=Ni(),Go=br(),Uo=ft(),zo=Er(),$n=Object.getOwnPropertyDescriptor;Bn.f=$o?$n:function(e,t){if(e=Ho(e),t=Go(t),zo)try{return $n(e,t)}catch(i){}if(Uo(e,t))return Do(!Bo(qo.f,e,t),e[t])}});var Hn=f((Fu,Dn)=>{"use strict";var Wo=re(),Ko=ie(),Qo=/#|\.prototype\./,Ne=function(r,e){var t=Zo[Yo(r)];return t===Jo?!0:t===Xo?!1:Ko(e)?Wo(e):!!e},Yo=Ne.normalize=function(r){return String(r).replace(Qo,".").toLowerCase()},Zo=Ne.data={},Xo=Ne.NATIVE="N",Jo=Ne.POLYFILL="P";Dn.exports=Ne});var zn=f(($u,Un)=>{"use strict";var Gn=Xt(),el=pr(),tl=Pe(),rl=Gn(Gn.bind);Un.exports=function(r,e){return el(r),e===void 0?r:tl?rl(r,e):function(){return r.apply(e,arguments)}}});var Kn=f((Bu,Wn)=>{"use strict";var il=Ee(),nl=re();Wn.exports=il&&nl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Yn=f((qu,Qn)=>{"use strict";var sl=Oe(),al=String,ol=TypeError;Qn.exports=function(r){if(sl(r))return r;throw new ol(al(r)+" is not an object")}});var Jn=f(Xn=>{"use strict";var ll=Ee(),cl=Er(),ul=Kn(),mt=Yn(),Zn=br(),hl=TypeError,Ir=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,xr="enumerable",Tr="configurable",wr="writable";Xn.f=ll?ul?function(e,t,i){if(mt(e),t=Zn(t),mt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&wr in i&&!i[wr]){var n=pl(e,t);n&&n[wr]&&(e[t]=i.value,i={configurable:Tr in i?i[Tr]:n[Tr],enumerable:xr in i?i[xr]:n[xr],writable:!1})}return Ir(e,t,i)}:Ir:function(e,t,i){if(mt(e),t=Zn(t),mt(i),cl)try{return Ir(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new hl("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ts=f((Hu,es)=>{"use strict";var dl=Ee(),fl=Jn(),ml=er();es.exports=dl?function(r,e,t){return fl.f(r,e,ml(1,t))}:function(r,e,t){return r[e]=t,r}});var ns=f((Gu,is)=>{"use strict";var je=K(),yl=yi(),vl=Xt(),gl=ie(),bl=qn().f,Cl=Hn(),xe=nr(),El=zn(),Te=ts(),rs=ft();yr();var Il=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 yl(r,this,arguments)};return e.prototype=r.prototype,e};is.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?je:n?je[t]:je[t]&&je[t].prototype,o=i?xe:xe[t]||Te(xe,t,{})[t],a=o.prototype,c,m,y,d,C,T,I,x,p;for(d in e)c=Cl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&l&&rs(l,d),T=o[d],m&&(r.dontCallGetSet?(p=bl(l,d),I=p&&p.value):I=l[d]),C=m&&I?I:e[d],!(!c&&!s&&typeof T==typeof C)&&(r.bind&&m?x=El(C,je):r.wrap&&m?x=Il(C):s&&gl(C)?x=vl(C):x=C,(r.sham||C&&C.sham||T&&T.sham)&&Te(x,"sham",!0),Te(o,d,x),s&&(y=t+"Prototype",rs(xe,y)||Te(xe,y,{}),Te(xe[y],d,C),r.real&&a&&(c||!a[d])&&Te(a,d,C)))}});var as=f((Uu,ss)=>{"use strict";var xl=Math.ceil,Tl=Math.floor;ss.exports=Math.trunc||function(e){var t=+e;return(t>0?Tl:xl)(t)}});var Sr=f((zu,os)=>{"use strict";var wl=as();os.exports=function(r){var e=+r;return e!==e||e===0?0:wl(e)}});var cs=f((Wu,ls)=>{"use strict";var Sl=Sr(),_l=Math.min;ls.exports=function(r){var e=Sl(r);return e>0?_l(e,9007199254740991):0}});var hs=f((Ku,us)=>{"use strict";var Ll=cs();us.exports=function(r){return Ll(r.length)}});var ds=f((Qu,ps)=>{"use strict";ps.exports=function(){}});var fs=f(()=>{"use strict";var Ml=ns(),Rl=vr(),Vl=hs(),Al=Sr(),kl=ds();Ml({target:"Array",proto:!0},{at:function(e){var t=Rl(this),i=Vl(t),n=Al(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});kl("at")});var ys=f((Xu,ms)=>{"use strict";var Pl=or();ms.exports=Pl});var gs=f((Ju,vs)=>{"use strict";fs();var Ol=ys();vs.exports=Ol("Array","at")});var Cs=f((eh,bs)=>{"use strict";var Nl=gs();bs.exports=Nl});var _r=f((th,Es)=>{"use strict";var jl=Cs();Es.exports=jl});var lc={};ba(lc,{CustomError:()=>$,EVENT_NAMES:()=>b,Interactives:()=>Ze,ManifestController:()=>ue,SDKInfo:()=>oc,chapterIdsToVKVideoIds:()=>Vt,compareVersions:()=>Y,getChapterIdByVkVideoId:()=>oa,getVKVideoIdByMedia:()=>qr,getVideoRawIdByMedia:()=>sa,graphEventTypes:()=>Se,hasEndTemplate:()=>We,interactivesEventTypes:()=>R,isLastChapter:()=>z,isSupportedManifest:()=>He,isVKVariantItem:()=>aa,utils:()=>ha,vkVideoIdsToChapterIds:()=>Dr});module.exports=Ca(lc);var ri="1.0.21";function Dt(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="interactive",Ea="interactive-controls-container",et=()=>document.querySelector(`.${Ea}`),ai=.4,D={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ii={top:"flex-start",bottom:"flex-end",center:"center"},ni={start:"flex-start",end:"flex-end",center:"center"},si={start:"left",end:"right",center:"center"},tt=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=ii[(t=e==null?void 0:e.text)==null?void 0:t.gravityVertical])!=null?i:ii.center,r.style.justifyContent=(s=ni[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:ni.center,r.style.textAlign=(o=si[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?o:si.start},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c;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=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},it=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=Dt((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)},nt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,m,y,d,C,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 ${Dt((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(y=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:y.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(T=(C=e==null?void 0:e.shape)==null?void 0:C.roundCorners)!=null?T:t.roundCorners})`},be=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var Q=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${H}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:D.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Ht="int",se=(i=>(i.AREA=`${Ht}_area`,i.TEXT=`${Ht}_text`,i.BUTTON=`${Ht}_bttn`,i))(se||{});var st=r=>{if(r.type.trim().toLowerCase()==="area")return new Gt(r)},Gt=class extends Q{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",it({target:i,props:this.control.props,fallback:E(h({},D),{backgroundColor:"transparent"})}),nt({target:i,props:this.control.props,fallback:E(h({},D),{borderAlpha:0}),dependsOn:this.container.dimensions}),be({target:i,layoutParams:this.control.layoutParams,fallback:D}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var at=()=>{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 ot=r=>{if(r.type.trim().toLowerCase()==="button")return new Ut(r)},Ut=class extends Q{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",be({target:i,layoutParams:this.control.layoutParams,fallback:D}),it({target:i,props:this.control.props,fallback:D}),nt({target:i,props:this.control.props,fallback:D,dependsOn:this.container.dimensions}),tt({target:i,props:this.control.props});let n=at();rt({target:n,props:this.control.props,fallback:D,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var oi=r=>{if(r.type.trim().toLowerCase()==="text")return new zt(r)},zt=class extends Q{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",be({target:i,layoutParams:this.control.layoutParams,fallback:D}),tt({target:i,props:this.control.props});let n=at();rt({target:n,props:this.control.props,fallback:D,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var Wt=class{constructor(e){this.layout=e}},lt=class extends Wt{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 te,ct,li,Ce=class{constructor(e){q(this,te);this.container=e,this.factories=new Map,Ae(this,te,ct).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),Ae(this,te,ct).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),Ae(this,te,ct).call(this)}};te=new WeakSet,ct=function(){this.controls=Ae(this,te,li).call(this)},li=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 ut=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Kt(r,e)},Kt=class extends Ce{constructor(e,t){super(e),this.rootElement=t!=null?t:et(),this.layout=new lt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ot),this.addControlFactory("text",oi),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(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=ai,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${H}-${this.container.id}`)}};var ua=Bt(_r(),1),M=require("@vkontakte/videoplayer-shared"),Me=require("@vkontakte/videoplayer-statistics");var Ss=require("@vkontakte/videoplayer-shared");function Fe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,$e=r=>oe(r,"Object"),yt=r=>oe(r,"String"),vt=r=>oe(r,"Array"),gt=r=>oe(r,"Number"),Is=r=>oe(r,"Function");var Lr=r=>gt(r)&&!isNaN(r);var le=r=>$e(r)&&Object.keys(r).length===0,Mr=r=>vt(r)&&!r.length;var Be=(r,e)=>yt(r)&&(e?r.trim():r).length;var xs="video_interactive",Ts="videoint";var ws=250,qe=class{constructor(e){this.handleZoomChange=Fe(e=>{this.lastZoomInfo=e},ws);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!gt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Fl(e),this.resizeObserver=new ResizeObserver(Fe(this.onResize,ws)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return _(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return _(this,null,function*(){if(!this.manifest)return;let e;try{e=yield(0,Ss.loadVKLangPack)(this.lang,xs,Ts)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.ngEditor.on("control",s=>{var l=s,{name:i}=l,n=j(l,["name"]);var o;i==="openPreview"&&"chapterId"in n&&((o=this.onOpenPreviewClick)==null||o.call(this,n.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Fl(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 De=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 Y=(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 Ls=require("uuid");var $l="3.1",_s={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Bl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ms=r=>{let e=[];for(let l of r.chapters){let o,a=[];for(let t of l.branches){let i=t,{isDefault:y}=i,d=j(i,["isDefault"]);y&&(o=d.id),a.push(d)}let c=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:y}=s,d=j(s,["fallbackStrategy"]);let C=!!d.endTime,T=[Bl];switch(y){case"await":C?T=[]:c=[];break;case"default":{let I={type:"onSuspense",action:{type:_s.default,args:{branchId:o,shouldOpenNow:!C,isDetachContainer:!0}}};C?T=[I]:c=[I];break}case"random":case"weightlessRandom":case"max":case"min":{let I={type:"onSuspense",action:{type:_s[y],args:{}}};C?T=[I]:c=[I];break}}for(let I of d.controls)m.push(E(h({},d),{controls:[h({},I)],id:(0,Ls.v4)(),events:T}))}e.push(E(h({},l),{containers:m,events:c,branches:a}))}return r.metadata.version=$l,r.metadata.updated=new Date().toISOString(),E(h({},r),{chapters:e})};var ql="3.2",Rs=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=j(e,["media"]);return E(h({},r),{metadata:E(h({},i),{version:ql}),media:t})}return r};var Dl="3.3",Hl=(r=[])=>({edit:{chapters:r},view:{}}),Vs={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},As=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:l,x:o,y:a}=i,c=j(i,["id","x","y"]),m=c.containers.map(y=>{var d;return E(h({},y),{controls:y.controls.map(x=>{var p=x,{subtype:C,type:T}=p,I=j(p,["subtype","type"]);return E(h({},I),{type:C!=null?C:T})}),events:(d=y.events)!=null&&d.length?y.events:[Vs]})});e.push(E(h({id:l},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[Vs]})),t.push({id:l,x:o,y:a})}return E(h({},r),{chapters:e,graph:Hl(t),metadata:E(h({},r.metadata),{version:Dl})})};var Gl=[{version:"3.0",migrate:Ms},{version:"3.1",migrate:Rs},{version:"3.2",migrate:As}],Rr=r=>Gl.reduce((e,t)=>Y(e.metadata.version,t.version)?e:t.migrate(e),r);var Mh=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),ks=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Rh=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),V=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});var Ps={metadata:"Object",chapters:"Array"},Ul="3.0.0",zl="3.3.0",He=r=>{let e=Y(r,Ul);return e===-1?!1:e===0?!0:Y(r,zl)!==1},Os=r=>{if(!$e(r))return!1;for(let e in Ps)if(!r[e]||!oe(r[e],Ps[e]))return!1;return He(r.metadata.version)},bt=r=>r.type===ks.Text;var $=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Ct=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 Et=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Is(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var qs=require("@vkontakte/videoplayer-shared");var It=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 _(this,null,function*(){return Wl(...this.loaders[e])(t)})}};function Wl(...r){return function(t){return _(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Ge(r,e,t){return r?E(h({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function xt(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=j(s,["actions","errors","chapterId"]);if(t){let l=r.getManifest(),o=r.getChapter(l.chapters,t);if(o){let a=r.getMedia(l.media,o.videoId),c=r.getGraph(l.graph,o.id);return a?E(h({},i),{actions:r,errors:e,result:{chapter:o,media:a,graph:c}}):E(h({},i),{errors:Ge(e,xt.name,"Could not find media"),actions:r})}}return E(h({},i),{errors:Ge(e,xt.name,"Could not find chapter"),actions:r})}var Tt=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}},we=class extends Tt{constructor(){super(),this.listeners||Tt.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)}},Ue=class{constructor(){Object.defineProperty(this,"signal",{value:new we,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&&(Ue.prototype[Symbol.toStringTag]="AbortController",we.prototype[Symbol.toStringTag]="AbortSignal");function wt(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 Vr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!wt({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(c,m){let y;m&&m.signal&&(y=m.signal,delete m.signal);let d=new t(c,m);return y&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),d},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let m=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let y;try{y=new DOMException("Aborted","AbortError")}catch(C){y=new Error("Aborted"),y.name="AbortError"}if(m.aborted)return Promise.reject(y);let d=new Promise((C,T)=>{m.addEventListener("abort",()=>T(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,l(a,c)])}return l(a,c)},Request:s}}var ze=wt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ns=ze?Vr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ar=ze?Ns.fetch:window.fetch,ip=ze?Ns.Request:window.Request,np=ze?Ue:window.AbortController,sp=ze?we:window.AbortSignal;var Kl=r=>_(void 0,null,function*(){try{let e={},t;if(yt(r)){t=new URL(r).href;let n=yield Ar(t);if(!n.ok)return{};e=yield n.json()}else if($e(r))e=r;else return{};if(!Os(e))return{};let i=e.metadata.media;if(yt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Ar(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Zl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function js(r){return _(this,null,function*(){let{manifest:e,manifestURL:t}=yield Kl(r),i=Rr(e);return i.media=Ql(i.media,t),delete i.metadata.media,i})}function St(r,e){if(e)return r.find(t=>t.id===e)}function kr(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 Pr(r,e){return r.videos.find(t=>t.id===e)}function Ql(r,e){return E(h({},r),{videos:r.videos.map(t=>E(h({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Yl(n,e);return E(h({},i),{url:s||n})})}))})}function Yl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zl(r){return Y(r,"3.2.0")>=0}var k=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),_t=r=>vt(r)&&!Mr(r),z=r=>r.order==="end",We=r=>vt(r.containers)&&!Mr(r.containers)&&z(r),Fs=(r,e)=>{var i;let t=r*1e3;return _t(e.controls)&&t<((i=e.startTime)!=null?i:0)},Or=(r,e)=>{var i,n;let t=r*1e3;return _t(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ce=r=>r.some(e=>e.action.type==="expect"),Nr=r=>r.find(e=>e.action.type==="expect"),Xl=r=>(r==null?void 0:r.length)===1,Lt=r=>Xl(r)&&bt(r[0]);var $s=({fn:r,type:e=1},...t)=>(...i)=>e?r(...i,...t):r(h(h({},i[e]),t[e])),Bs=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var ue=class extends It{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new qs.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 _(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ge},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield js((n=i.result)!=null?n:t),this})}setInitial(){return _(this,null,function*(){return this.setNext()})}setNext(){return _(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",xt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:kr,getChapter:St,getMedia:Pr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ge},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=St(this.manifest.chapters,t);if(n){let s=Pr(this.manifest.media,n.videoId),l=kr(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=St(((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 z(this.chapter)}};var Hs=require("@vkontakte/videoplayer-core"),he=require("@vkontakte/videoplayer-shared");var Ds=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[]};function jr(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=c,o=j(c,["listId","itemId"]);let m=r.get(s),y=h({},o);return m?m[l]=y:r.set(s,{[l]:y}),h({listId:s,itemId:l},o)}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function Fr(r,e=[]){var s,l,o;let t={},i,n=!e.length;for(let a of r.variants)if(!i&&"cover"in a&&(i=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(t.MPEG=E(h({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=E(h({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=E(h({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=E(h({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var Ke=(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 Jl=2;function $r(r){let e=jr(),t={},i=null,n=!1,s,l=new he.ValueSubject(null);r&&o(r);function o(I){i=I}function a(I,x,p){var w;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let g=((w=e.map.get(I))!=null?w:{})[x];if(g){t=h({chapterId:p,listId:I,itemId:x},g);let v=t.player;t.subscription.add(v.info.currentQuality$.subscribe(P=>{let O=v.info.position$.getValue(),F=v.info.isAutoQualityEnabled$.getValue();if(!(!P||!O||F))for(let L of e.map)Object.values(L[1]).forEach(({player:A})=>{Ke(A,P)})})).add(v.events.started$.subscribe(()=>{c(x)})),g.container.remove(),i.setPlayer(g.player),n||(i.init(),n=!0),l.next({player:t.player,config:t.config,statistics:t.statistics});return}throw Error("Can't set. Not find.")}function c(I){return _(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(le(t)||I!==t.itemId)return;let x=i.getChapterBranches(),p=new Set;for(let u of x)p.has(u.media.id)||(yield y({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),p.add(u.media.id))})}function m(p){return _(this,arguments,function*({chapter:{id:I},media:x}){if(le(t))return;let u=t.player.info.muted$.getValue(),g=t.player.info.currentQuality$.getValue(),w=t.player.info.isAutoQualityEnabled$.getValue(),v=t.player.info.volume$.getValue(),P=t.player.info.currentPlaybackRate$.getValue(),O=!w,F=!1;for(let L of e.map)if(L[0]===x.id){let A=Object.keys(L[1]);for(let B of A)B===t.itemId?(A.length<Jl||(F=!0),e.removePlayer(L[0],B)):(F=!0,a(L[0],B,I),O?Ke(t.player,g):t.player.setAutoQuality(!0),t.player.setVolume(v),t.player.setMuted(u),t.player.setPlaybackRate(P))}else e.removePlayer(L[0]);F||(yield y({media:x,chapterId:I,setAsActive:!0,playbackRate:P}),O?Ke(t.player,g):t.player.setAutoQuality(!0),t.player.setVolume(v),t.player.setMuted(u))})}function y(O){return _(this,arguments,function*({media:I,chapterId:x,prefetch:p=!0,setAsActive:u=!0,autoplay:g=!1,preferredExt:w,title:v,playbackRate:P}){var zr,Wr,Kr,Qr,Yr;let F=Math.random().toString(),L=document.createElement("div");s.append(L);let A;if((zr=i==null?void 0:i.options)!=null&&zr.vkVideoLoader){let Xe=Ds(I);Xe.length&&(A=yield i.options.vkVideoLoader(...Xe))}let B=((Wr=i==null?void 0:i.options)==null?void 0:Wr.coreConfig)||void 0,ye=E(h({},B),{configName:[...(Kr=B==null?void 0:B.configName)!=null?Kr:[],"interactive"]}),ve=E(h({container:L},((Qr=A==null?void 0:A.videos)==null?void 0:Qr[0])||{sources:Fr(I,w).sources}),{title:v,failoverHosts:(A==null?void 0:A.failoverHosts)||[]}),ee=new Hs.Player(ye,he.Tracer.createRootTracer());ee.initVideo(ve);let Gr=null;if(A!=null&&A.videos&&(i!=null&&i.options.createOneStat)){let Xe=A.videos[0],jt=i.options.createOneStat(Xe),Zr=new he.Subscription;jt&&(Zr.add(jt.attachTo(ee)),Gr={oneStat:jt,statSubscription:Zr})}let Ur=new he.Subscription,pa=(Yr=t==null?void 0:t.player)==null?void 0:Yr.info.isAutoQualityEnabled$.getValue();Ur.add(ee.events.canplay$.subscribe(function(){pa||Ke(ee,t.player.info.currentQuality$.getValue()),P&&ee.setPlaybackRate(P)}));let ge=e.createPlayer({listId:I.id,itemId:F,player:ee,container:L,sources:Fr(I,w).sources,config:ve,subscription:Ur,statistics:Gr});return u&&a(I.id,ge.itemId,x),g&&ge.player.play(),p&&!g&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}})}function d(){C(),i=null,s.remove()}function C(){i==null||i.off(b.chapterChanged,m),e.removeAll(),t={},n=!1}function T(){return _(this,null,function*(){if(!i)throw Error("need to set interactive controller");C(),s=document.createElement("div");let{media:I,chapter:x}=i.getCurrentChapter();I&&x?(i.on(b.chapterChanged,m),yield y({media:I,chapterId:x.id,title:x.label})):console.error("not found")})}return E(h({},e),{init:T,setInteractiveController:o,createPlayer:y,removeAll:d,getActivePlayer:function(){return t},activePlayerChanged:l})}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"},Se={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},R={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Gs=require("@vkontakte/videoplayer-shared");var Mt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:a,disabledControls$:c,onRemove:m}){Ve(this,"hide",()=>{setTimeout(()=>{var e,t;this.gameState!==k.end&&(ce(this.container.container.events)&&this.gameState===k.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==k.interactive&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1})))})});Ve(this,"show",()=>{var e,t,i,n;if(this.gameState===k.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:R.visibility,visibility:!0,isFirst:!1});else{let l=$s({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:R.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1})),(this.gameState===k.end||this.gameState===k.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1}))},isEOV:()=>this.gameState===k.end});this.container.createView(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}});Ve(this,"onEndOfVideo",()=>{this.gameState=k.end,this.selectContainerEvent(!0)});Ve(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[k.destroyed,k.removed].includes(this.gameState)&&!this.isPermanentText)return;let t=this.player.getExactTime();if(Fs(t,this.container.container))this.gameState!==k.beforeInteractive&&(this.gameState=k.beforeInteractive,this.onBeforeStartTime());else if(Or(t,this.container.container))this.gameState!==k.interactive&&(this.gameState=k.interactive,this.onStartTime());else if(this.gameState!==k.afterInteractive){let o=this.gameState;this.gameState=k.afterInteractive,o===k.interactive&&this.onEndTime()}else this.gameState!==k.destroyed&&!this.isPermanentText&&this.removeView();let i=Or(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 Gs.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=a&&Lt(t.container.controls),this.disabledControls$=c,this.onRemove=m,this.globalEventEmitter=l,this.gameState=k.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=ce(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:R.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=k.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.containerRemoved,visibility:!1}),this.gameState=k.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=k.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 Us=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!bt(a));if(_t(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],y=-1/0,d=1/0,C=[],T=[];for(let I=0;I<e.length;I++){let x=e[I];if(T.push(...x.subjects),x.range[0]<d&&(d=x.range[0]),x.range[1]>y&&(y=x.range[1]),a[0]>=x.range[0]&&a[1]<=x.range[1])return e[I].subjects.push(c),e;a[0]<x.range[0]&&a[1]>x.range[0]&&(m.push(I),C=C.concat(x.subjects)),a[0]>=x.range[0]&&a[0]<=x.range[1]&&(m.push(I),C=C.concat(x.subjects),a[0]=x.range[0]),a[1]>=x.range[0]&&a[1]<=x.range[1]&&(m.push(I),C=C.concat(x.subjects),a[1]=x.range[1])}if(T.push(c),a[0]<=d&&a[1]>=y)return[{subjects:T,range:a}];m.length&&m.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:C.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function zs(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o];return!0}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var m;if(Lr(o)){let y=(m=r[o])!=null?m:null;if(y&&Be(a,!0)){let d={},C=y[a];if(C&&(d=h(h({},d),C)),d=le(d)?null:d,d&&Be(c,!0)){let T=d[c];return T!=null?T:null}return d}return y}return null}function s({timestamp:o,priority:a,initiator:c}){if(Lr(o))if(r[o]){if(Be(a,!0))if(r[o][a]){if(Be(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!le(r[o][a]))return!0}else return!1;if(delete r[o][a],!le(r[o]))return!0}else return!1;return delete r[o]}else return!1}function l(y){var d=y,{timestamp:o,priority:a,initiator:c}=d,m=j(d,["timestamp","priority","initiator"]);var C,T,I;(T=(C=r[o])==null?void 0:C[a])!=null&&T[c]?r[o][a][c].push(h({},m)):(I=r[o])!=null&&I[a]?r[o][a]=E(h({},r[o][a]),{[c]:[h({},m)]}):r[o]?r[o]=E(h({},r[o]),{[a]:{[c]:[h({},m)]}}):r[o]={[a]:{[c]:[h({},m)]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var ec=[V.expect,V.setNextBranch],tc=1/0;function Ws(r){let e=r,t,i=rc(),n=new zs,s,l=()=>{d(),p()},o=u=>{n.add.call(void 0,u),T()},a=(u=[])=>{for(let g of u)if(g.action(),ec.includes(g.actionType))break},c=(u=1/0)=>{var P,O,F;let g=Rt((P=n.get({timestamp:u,priority:"control"}))!=null?P:{}),w=Rt((O=n.get({timestamp:u,priority:"container"}))!=null?O:{}),v=Rt((F=n.get({timestamp:u,priority:"chapter"}))!=null?F:{});return[...g,...w,...v]},m=u=>{i.isReady(u)&&a(c(u))},y=()=>{var u;a([...Rt((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},C=u=>{},T=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},I=u=>{d(),e=u},x=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},p=()=>{i.release(),n.removeAll()};return{setPlayer:I,add:o,remove:x,exec:m,execEndOfVideo:y,listen:T,unlisten:d,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function rc(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let m=(o=c.endTime)!=null?o:tc,y=(a=r.get(m))!=null?a:{};r.set(m,E(h({},y),{[c.id]:!1}))}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function Rt(r){return Object.values(r).flat().sort(e=>e.actionType===V.expect?-1:1)}var Ks={videoContentHeight:0,videoContentWidth:0},Qs=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Ks;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Ks;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var ic=250;function Ys(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:y}=Qs(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=Fe(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},ic);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e()},release:l}}var Qe=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 nc=r=>Math.floor(Math.random()*r),Zs=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},Xs=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 Js=r=>{let e=r.length,t=nc(e);return r[t]};var ea=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 ta=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var Br=(r,e=!1)=>E(h({},r),{args:e?h(h({},r.args),ta):h(h({},ta),r.args)}),na=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:u,controlId:g,containerId:w,branches:v=[],onEvent:P,isEOV:O=()=>!1,isDisabled:F=()=>!1})=>{let L=Br(p,O()),A={timestamp:1/0,priority:"control",initiator:g,actionType:L.type},B=F(),ye=r.emit.bind(r,b.interactives,{subjectId:g,subjectType:u,subjectName:"control",type:B?R.actionChoiceCanceled:R.actionChoice,actionType:p.type,payload:h({containerId:w},L.args)});if(B){ye();return}switch(L.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let ve=v.find(ee=>ee.id===L.args.branchId);if(!ve)return;P(L.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),ye(),L.args.shouldOpenNow?T({subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ve.chapterId,autoSelect:!1}}):(t.add(E(h({},A),{action:T.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ve.chapterId,autoSelect:!1}})})),i==null||i());return}case V.continuePlayback.trim().toLowerCase():{P(L.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),ye(),L.args.shouldOpenNow?C({subjectId:g,subjectName:"control",subjectType:u,action:p}):t.add(E(h({},A),{action:C.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:p})}));return}case V.openURI.trim().toLowerCase():{P(L.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),ye(),L.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{URI:p.args.uri}}):(t.add(E(h({},A),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(b.errors,new $(1,1,{message:"Unexpected control event"}));return}},o=({action:p,container:{id:u,endTime:g},branches:w=[],isEOV:v=!1,autoSelected:P=!1})=>{let O=Br(p,v),F={timestamp:!O.args.shouldOpenNow||v?1/0:g,priority:"container",initiator:u,actionType:O.type},L=r.emit.bind(r,b.interactives,{subjectId:u,subjectName:"container",type:R.actionChoice,actionType:O.type,payload:O.args});switch(O.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let A=w.find(B=>B.id===O.args.branchId);if(!A)return;L(),t.add(E(h({},F),{action:T.bind(null,{subjectId:u,subjectName:"container",action:O,payload:{chapterId:A.chapterId,autoSelect:P}})})),i==null||i();return}case V.setMaxWeightBranch.trim().toLowerCase():return;case V.setMinWeightBranch.trim().toLowerCase():return;case V.setRandomBranch.trim().toLowerCase():return;case V.setWeightlessRandomBranch.trim().toLowerCase():return;case V.continuePlayback.trim().toLowerCase():{L(),t.add(E(h({},F),{action:C.bind(null,{subjectId:u,subjectName:"container",action:O})}));return}case V.openURI.trim().toLowerCase():{L(),t.add(E(h({},F),{action:x.bind(null,{subjectId:u,subjectName:"container",action:O,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(b.errors,new $(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:u,isEOV:g=!1}){let w=Nr(p.events);if(w){let v=Br(w.action,g);r.emit(b.interactives,{subjectId:p.id,subjectName:"container",type:R.actionChoice,actionType:v.type,payload:v.args}),t.add({timestamp:g?1/0:p.endTime,priority:"container",initiator:p.id,actionType:V.expect,action:y.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let v of p.events)o({action:v.action,container:p,branches:u,isEOV:g})}let c=({chapterId:p,action:u,branches:g=[]})=>{let w=r.emit.bind(r,b.interactives,{subjectId:p,subjectName:"chapter",type:R.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case V.setNextBranch.trim().toLowerCase():{let v=g.find(P=>P.id===u.args.branchId);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case V.setWeightlessRandomBranch.trim().toLowerCase():{let v=Js(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case V.setRandomBranch.trim().toLowerCase():{let v=ea(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case V.setMaxWeightBranch.trim().toLowerCase():{let v=Xs(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case V.setMinWeightBranch.trim().toLowerCase():{let v=Zs(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case V.continuePlayback.trim().toLowerCase():return w(),C.bind(null,{subjectId:p,subjectName:"chapter",action:u});case V.openURI.trim().toLowerCase():return w(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),r.emit(b.errors,new $(1,1,{message:"Unexpected chapter event"}));return}};function m(p){let u=Nr(p.events);if(u){if(z(p))return;r.emit(b.interactives,{subjectId:p.id,subjectName:"chapter",type:R.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:V.expect,action:y.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else p.events.forEach(g=>{let w=c({chapterId:p.id,action:g.action,branches:p.branches});w&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:g.action.type,action:w})})}let y=({subjectId:p,subjectName:u,action:g})=>{var w;e.pause(),r.emit(b.interactives,{subjectId:p,subjectName:u,type:R.actionExecution,actionType:(w=g==null?void 0:g.type)!=null?w:V.expect})},d=({subjectId:p,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(b.interactives,{subjectId:p,subjectName:u,type:R.actionExecution,actionType:"after-expect"})},C=({subjectId:p,subjectName:u,subjectType:g,action:w})=>{r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:w.type})},T=({subjectId:p,subjectName:u,subjectType:g,action:w,payload:v})=>{v.behaviour="change-chapter",r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:w.type,payload:v})},I=({subjectId:p,subjectName:u,subjectType:g,action:w,payload:v})=>{v.behaviour="change-manifest",r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:w.type,payload:v})},x=({subjectId:p,subjectName:u,subjectType:g,action:w,payload:v})=>{if(!v.URI)return;let P=window.open(v.URI,"_blank","noopener,noreferrer");P&&(P.opener=null),r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:w.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:y,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var Hr=Bt(_r(),1),ne=require("@vkontakte/videoplayer-shared");var Vt=(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]=qr(s)}return t[i]}).filter(Boolean)},sa=r=>{for(let e of r.variants)if(aa(e)&&"payload"in e)return e.payload.id},aa=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",qr=r=>{let e=sa(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},oa=(r,e)=>{for(let t of r.media.videos)if(e===qr(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Dr=(r,e)=>r.reduce((t,i)=>{let n=oa(e,i);return n?[...t,n]:t},[]);var Z,pe,de,G,At,X,J,W,fe,_e,Le,Ye=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new ne.ValueSubject([]),hasPrevChapter$:new ne.ValueSubject(!1),prevChapter$:new ne.ValueSubject(null),isInitialChapter$:new ne.ValueSubject(!1),isGoBackLimited$:new ne.ValueSubject(!1)};q(this,Z,null);q(this,pe);q(this,de,!1);q(this,G,null);q(this,At,null);q(this,X,null);q(this,J,null);q(this,W,null);q(this,fe,new ne.Subscription);q(this,_e,!1);q(this,Le,0);var l;N(this,X,t),N(this,W,e),N(this,J,i),N(this,Z,n),N(this,pe,s),this.state.history$&&S(this,fe)&&((l=S(this,fe))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,Hr.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=S(this,G))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,Le)===S(this,pe).maxLength-1)})))}setManifest(e){return _(this,null,function*(){!S(this,J)||!S(this,W)||(N(this,G,e),yield this.getProjectHistory(),yield S(this,J).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),S(this,de)||(N(this,de,!0),S(this,W).emit(b.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return S(this,de)}updateHistory(e,t=!0){return _(this,null,function*(){var o;if(!S(this,G))return;S(this,_e)?(N(this,_e,!1),ti(this,Le)._++):N(this,Le,0);let i=S(this,G),n=e.length-S(this,pe).maxLength,s=n>0?e.slice(n):e,l=Vt(s,i);if(N(this,At,l),this.state.history$.next(s),!(!t||!S(this,Z)||!S(this,X)))try{yield S(this,Z).save(S(this,X),l)}catch(a){(o=S(this,W))==null||o.emit(b.errors,new $(1,5,"Unable to save interactive history"))}})}goBack(){return _(this,null,function*(){var i;if(!this.state||!S(this,J))return(i=S(this,W))==null?void 0:i.emit(b.errors,new $(1,5,"Cannot go back because HistoryController has not been initialized"));N(this,_e,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,J).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return _(this,null,function*(){var n;if(!S(this,G)||!S(this,X))return;let e=S(this,G),t=[this.getInitialVideoId()];if(S(this,Z))try{let s=yield S(this,Z).get(S(this,X));s.length&&(t=s)}catch(s){(n=S(this,W))==null||n.emit(b.errors,new $(1,5,"Error while trying to fetch data"))}let i=Dr(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Hr.default)(e,-1)||S(this,pe).initChapterId||((t=S(this,G))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,G)){let e=this.getInitialChapterId();return Vt([e],S(this,G)).pop()}return null}destroy(){var e,t;N(this,X,null),N(this,Z,null),N(this,J,null),(e=S(this,fe))==null||e.unsubscribe(),N(this,fe,null),N(this,de,!1),(t=S(this,W))==null||t.emit(b.historyDestroyed),N(this,W,null)}};Z=new WeakMap,pe=new WeakMap,de=new WeakMap,G=new WeakMap,At=new WeakMap,X=new WeakMap,J=new WeakMap,W=new WeakMap,fe=new WeakMap,_e=new WeakMap,Le=new WeakMap;var me=class me{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=me._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(",")),me._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=me._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}me._supportsObject=t}return t||!1}};me._supportsObject=void 0;var kt=me;var Pt=class{constructor(){this.bindingMap=new Qe}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new kt(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 Ot=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 _(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 _(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 Nt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
6
+ "use strict";var da=Object.create;var _e=Object.defineProperty,fa=Object.defineProperties,ma=Object.getOwnPropertyDescriptor,ya=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertyNames,Xe=Object.getOwnPropertySymbols,ga=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty,Zr=Object.prototype.propertyIsEnumerable;var Xr=r=>{throw TypeError(r)};var Yr=(r,e,t)=>e in r?_e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,h=(r,e)=>{for(var t in e||(e={}))jt.call(e,t)&&Yr(r,t,e[t]);if(Xe)for(var t of Xe(e))Zr.call(e,t)&&Yr(r,t,e[t]);return r},C=(r,e)=>fa(r,ya(e));var j=(r,e)=>{var t={};for(var i in r)jt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Xe)for(var i of Xe(r))e.indexOf(i)<0&&Zr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ba=(r,e)=>{for(var t in e)_e(r,t,{get:e[t],enumerable:!0})},Jr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of va(e))!jt.call(r,n)&&n!==t&&_e(r,n,{get:()=>e[n],enumerable:!(i=ma(e,n))||i.enumerable});return r};var Ft=(r,e,t)=>(t=r!=null?da(ga(r)):{},Jr(e||!r||!r.__esModule?_e(t,"default",{value:r,enumerable:!0}):t,r)),Ca=r=>Jr(_e({},"__esModule",{value:!0}),r);var $t=(r,e,t)=>e.has(r)||Xr("Cannot "+t);var S=(r,e,t)=>($t(r,e,"read from private field"),t?t.call(r):e.get(r)),B=(r,e,t)=>e.has(r)?Xr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,i)=>($t(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ae=(r,e,t)=>($t(r,e,"access private method"),t);var ei=(r,e,t,i)=>({set _(n){N(r,e,n,t)},get _(){return S(r,e,i)}});var w=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{o(t.next(a))}catch(c){n(c)}},l=a=>{try{o(t.throw(a))}catch(c){n(c)}},o=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var Q=f((Wt,li)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};li.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof Wt=="object"&&Wt)||function(){return this}()||Function("return this")()});var te=f((Zc,ci)=>{"use strict";ci.exports=function(r){try{return!!r()}catch(e){return!0}}});var Pe=f((Xc,pi)=>{"use strict";var Ia=te();pi.exports=!Ia(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var mi=f((Jc,fi)=>{"use strict";var xa=Pe(),di=Function.prototype,ui=di.apply,hi=di.call;fi.exports=typeof Reflect=="object"&&Reflect.apply||(xa?hi.bind(ui):function(){return hi.apply(ui,arguments)})});var ae=f((ep,gi)=>{"use strict";var yi=Pe(),vi=Function.prototype,Qt=vi.call,Ta=yi&&vi.bind.bind(Qt,Qt);gi.exports=yi?Ta:function(r){return function(){return Qt.apply(r,arguments)}}});var Kt=f((tp,Ci)=>{"use strict";var bi=ae(),Sa=bi({}.toString),wa=bi("".slice);Ci.exports=function(r){return wa(Sa(r),8,-1)}});var Yt=f((rp,Ei)=>{"use strict";var La=Kt(),Ma=ae();Ei.exports=function(r){if(La(r)==="Function")return Ma(r)}});var re=f((ip,Ii)=>{"use strict";var Zt=typeof document=="object"&&document.all;Ii.exports=typeof Zt=="undefined"&&Zt!==void 0?function(r){return typeof r=="function"||r===Zt}:function(r){return typeof r=="function"}});var be=f((np,xi)=>{"use strict";var _a=te();xi.exports=!_a(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ut=f((sp,Ti)=>{"use strict";var Aa=Pe(),pt=Function.prototype.call;Ti.exports=Aa?pt.bind(pt):function(){return pt.apply(pt,arguments)}});var Mi=f(Li=>{"use strict";var Si={}.propertyIsEnumerable,wi=Object.getOwnPropertyDescriptor,Ra=wi&&!Si.call({1:2},1);Li.f=Ra?function(e){var t=wi(this,e);return!!t&&t.enumerable}:Si});var Xt=f((op,_i)=>{"use strict";_i.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ri=f((lp,Ai)=>{"use strict";var Pa=ae(),ka=te(),Va=Kt(),Jt=Object,Oa=Pa("".split);Ai.exports=ka(function(){return!Jt("z").propertyIsEnumerable(0)})?function(r){return Va(r)==="String"?Oa(r,""):Jt(r)}:Jt});var er=f((cp,Pi)=>{"use strict";Pi.exports=function(r){return r==null}});var tr=f((pp,ki)=>{"use strict";var Na=er(),ja=TypeError;ki.exports=function(r){if(Na(r))throw new ja("Can't call method on "+r);return r}});var Oi=f((up,Vi)=>{"use strict";var Fa=Ri(),$a=tr();Vi.exports=function(r){return Fa($a(r))}});var ke=f((hp,Ni)=>{"use strict";var Ba=re();Ni.exports=function(r){return typeof r=="object"?r!==null:Ba(r)}});var rr=f((dp,ji)=>{"use strict";ji.exports={}});var sr=f((fp,$i)=>{"use strict";var ir=rr(),nr=Q(),qa=re(),Fi=function(r){return qa(r)?r:void 0};$i.exports=function(r,e){return arguments.length<2?Fi(ir[r])||Fi(nr[r]):ir[r]&&ir[r][e]||nr[r]&&nr[r][e]}});var qi=f((mp,Bi)=>{"use strict";var Da=ae();Bi.exports=Da({}.isPrototypeOf)});var Gi=f((yp,Ui)=>{"use strict";var Ha=Q(),Di=Ha.navigator,Hi=Di&&Di.userAgent;Ui.exports=Hi?String(Hi):""});var Xi=f((vp,Zi)=>{"use strict";var Yi=Q(),ar=Gi(),zi=Yi.process,Wi=Yi.Deno,Qi=zi&&zi.versions||Wi&&Wi.version,Ki=Qi&&Qi.v8,G,ht;Ki&&(G=Ki.split("."),ht=G[0]>0&&G[0]<4?1:+(G[0]+G[1]));!ht&&ar&&(G=ar.match(/Edge\/(\d+)/),(!G||G[1]>=74)&&(G=ar.match(/Chrome\/(\d+)/),G&&(ht=+G[1])));Zi.exports=ht});var or=f((gp,en)=>{"use strict";var Ji=Xi(),Ua=te(),Ga=Q(),za=Ga.String;en.exports=!!Object.getOwnPropertySymbols&&!Ua(function(){var r=Symbol("symbol detection");return!za(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ji&&Ji<41})});var lr=f((bp,tn)=>{"use strict";var Wa=or();tn.exports=Wa&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var cr=f((Cp,rn)=>{"use strict";var Qa=sr(),Ka=re(),Ya=qi(),Za=lr(),Xa=Object;rn.exports=Za?function(r){return typeof r=="symbol"}:function(r){var e=Qa("Symbol");return Ka(e)&&Ya(e.prototype,Xa(r))}});var sn=f((Ep,nn)=>{"use strict";var Ja=String;nn.exports=function(r){try{return Ja(r)}catch(e){return"Object"}}});var pr=f((Ip,an)=>{"use strict";var eo=re(),to=sn(),ro=TypeError;an.exports=function(r){if(eo(r))return r;throw new ro(to(r)+" is not a function")}});var ln=f((xp,on)=>{"use strict";var io=pr(),no=er();on.exports=function(r,e){var t=r[e];return no(t)?void 0:io(t)}});var pn=f((Tp,cn)=>{"use strict";var ur=ut(),hr=re(),dr=ke(),so=TypeError;cn.exports=function(r,e){var t,i;if(e==="string"&&hr(t=r.toString)&&!dr(i=ur(t,r))||hr(t=r.valueOf)&&!dr(i=ur(t,r))||e!=="string"&&hr(t=r.toString)&&!dr(i=ur(t,r)))return i;throw new so("Can't convert object to primitive value")}});var hn=f((Sp,un)=>{"use strict";un.exports=!0});var mn=f((wp,fn)=>{"use strict";var dn=Q(),ao=Object.defineProperty;fn.exports=function(r,e){try{ao(dn,r,{value:e,configurable:!0,writable:!0})}catch(t){dn[r]=e}return e}});var fr=f((Lp,gn)=>{"use strict";var oo=hn(),lo=Q(),co=mn(),yn="__core-js_shared__",vn=gn.exports=lo[yn]||co(yn,{});(vn.versions||(vn.versions=[])).push({version:"3.38.0",mode:oo?"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 En=f((Mp,Cn)=>{"use strict";var bn=fr();Cn.exports=function(r,e){return bn[r]||(bn[r]=e||{})}});var mr=f((_p,In)=>{"use strict";var po=tr(),uo=Object;In.exports=function(r){return uo(po(r))}});var dt=f((Ap,xn)=>{"use strict";var ho=ae(),fo=mr(),mo=ho({}.hasOwnProperty);xn.exports=Object.hasOwn||function(e,t){return mo(fo(e),t)}});var Sn=f((Rp,Tn)=>{"use strict";var yo=ae(),vo=0,go=Math.random(),bo=yo(1 .toString);Tn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+bo(++vo+go,36)}});var Mn=f((Pp,Ln)=>{"use strict";var Co=Q(),Eo=En(),wn=dt(),Io=Sn(),xo=or(),To=lr(),Ce=Co.Symbol,yr=Eo("wks"),So=To?Ce.for||Ce:Ce&&Ce.withoutSetter||Io;Ln.exports=function(r){return wn(yr,r)||(yr[r]=xo&&wn(Ce,r)?Ce[r]:So("Symbol."+r)),yr[r]}});var Pn=f((kp,Rn)=>{"use strict";var wo=ut(),_n=ke(),An=cr(),Lo=ln(),Mo=pn(),_o=Mn(),Ao=TypeError,Ro=_o("toPrimitive");Rn.exports=function(r,e){if(!_n(r)||An(r))return r;var t=Lo(r,Ro),i;if(t){if(e===void 0&&(e="default"),i=wo(t,r,e),!_n(i)||An(i))return i;throw new Ao("Can't convert object to primitive value")}return e===void 0&&(e="number"),Mo(r,e)}});var vr=f((Vp,kn)=>{"use strict";var Po=Pn(),ko=cr();kn.exports=function(r){var e=Po(r,"string");return ko(e)?e:e+""}});var Nn=f((Op,On)=>{"use strict";var Vo=Q(),Vn=ke(),gr=Vo.document,Oo=Vn(gr)&&Vn(gr.createElement);On.exports=function(r){return Oo?gr.createElement(r):{}}});var br=f((Np,jn)=>{"use strict";var No=be(),jo=te(),Fo=Nn();jn.exports=!No&&!jo(function(){return Object.defineProperty(Fo("div"),"a",{get:function(){return 7}}).a!==7})});var Bn=f($n=>{"use strict";var $o=be(),Bo=ut(),qo=Mi(),Do=Xt(),Ho=Oi(),Uo=vr(),Go=dt(),zo=br(),Fn=Object.getOwnPropertyDescriptor;$n.f=$o?Fn:function(e,t){if(e=Ho(e),t=Uo(t),zo)try{return Fn(e,t)}catch(i){}if(Go(e,t))return Do(!Bo(qo.f,e,t),e[t])}});var Dn=f((Fp,qn)=>{"use strict";var Wo=te(),Qo=re(),Ko=/#|\.prototype\./,Ve=function(r,e){var t=Zo[Yo(r)];return t===Jo?!0:t===Xo?!1:Qo(e)?Wo(e):!!e},Yo=Ve.normalize=function(r){return String(r).replace(Ko,".").toLowerCase()},Zo=Ve.data={},Xo=Ve.NATIVE="N",Jo=Ve.POLYFILL="P";qn.exports=Ve});var Gn=f(($p,Un)=>{"use strict";var Hn=Yt(),el=pr(),tl=Pe(),rl=Hn(Hn.bind);Un.exports=function(r,e){return el(r),e===void 0?r:tl?rl(r,e):function(){return r.apply(e,arguments)}}});var Wn=f((Bp,zn)=>{"use strict";var il=be(),nl=te();zn.exports=il&&nl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Kn=f((qp,Qn)=>{"use strict";var sl=ke(),al=String,ol=TypeError;Qn.exports=function(r){if(sl(r))return r;throw new ol(al(r)+" is not an object")}});var Xn=f(Zn=>{"use strict";var ll=be(),cl=br(),pl=Wn(),ft=Kn(),Yn=vr(),ul=TypeError,Cr=Object.defineProperty,hl=Object.getOwnPropertyDescriptor,Er="enumerable",Ir="configurable",xr="writable";Zn.f=ll?pl?function(e,t,i){if(ft(e),t=Yn(t),ft(i),typeof e=="function"&&t==="prototype"&&"value"in i&&xr in i&&!i[xr]){var n=hl(e,t);n&&n[xr]&&(e[t]=i.value,i={configurable:Ir in i?i[Ir]:n[Ir],enumerable:Er in i?i[Er]:n[Er],writable:!1})}return Cr(e,t,i)}:Cr:function(e,t,i){if(ft(e),t=Yn(t),ft(i),cl)try{return Cr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new ul("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var es=f((Hp,Jn)=>{"use strict";var dl=be(),fl=Xn(),ml=Xt();Jn.exports=dl?function(r,e,t){return fl.f(r,e,ml(1,t))}:function(r,e,t){return r[e]=t,r}});var is=f((Up,rs)=>{"use strict";var Oe=Q(),yl=mi(),vl=Yt(),gl=re(),bl=Bn().f,Cl=Dn(),Ee=rr(),El=Gn(),Ie=es(),ts=dt();fr();var Il=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 yl(r,this,arguments)};return e.prototype=r.prototype,e};rs.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?Oe:n?Oe[t]:Oe[t]&&Oe[t].prototype,o=i?Ee:Ee[t]||Ie(Ee,t,{})[t],a=o.prototype,c,m,v,d,I,x,M,b,p;for(d in e)c=Cl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&l&&ts(l,d),x=o[d],m&&(r.dontCallGetSet?(p=bl(l,d),M=p&&p.value):M=l[d]),I=m&&M?M:e[d],!(!c&&!s&&typeof x==typeof I)&&(r.bind&&m?b=El(I,Oe):r.wrap&&m?b=Il(I):s&&gl(I)?b=vl(I):b=I,(r.sham||I&&I.sham||x&&x.sham)&&Ie(b,"sham",!0),Ie(o,d,b),s&&(v=t+"Prototype",ts(Ee,v)||Ie(Ee,v,{}),Ie(Ee[v],d,I),r.real&&a&&(c||!a[d])&&Ie(a,d,I)))}});var ss=f((Gp,ns)=>{"use strict";var xl=Math.ceil,Tl=Math.floor;ns.exports=Math.trunc||function(e){var t=+e;return(t>0?Tl:xl)(t)}});var Tr=f((zp,as)=>{"use strict";var Sl=ss();as.exports=function(r){var e=+r;return e!==e||e===0?0:Sl(e)}});var ls=f((Wp,os)=>{"use strict";var wl=Tr(),Ll=Math.min;os.exports=function(r){var e=wl(r);return e>0?Ll(e,9007199254740991):0}});var ps=f((Qp,cs)=>{"use strict";var Ml=ls();cs.exports=function(r){return Ml(r.length)}});var hs=f((Kp,us)=>{"use strict";us.exports=function(){}});var ds=f(()=>{"use strict";var _l=is(),Al=mr(),Rl=ps(),Pl=Tr(),kl=hs();_l({target:"Array",proto:!0},{at:function(e){var t=Al(this),i=Rl(t),n=Pl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});kl("at")});var ms=f((Xp,fs)=>{"use strict";var Vl=sr();fs.exports=Vl});var vs=f((Jp,ys)=>{"use strict";ds();var Ol=ms();ys.exports=Ol("Array","at")});var bs=f((eu,gs)=>{"use strict";var Nl=vs();gs.exports=Nl});var Sr=f((tu,Cs)=>{"use strict";var jl=bs();Cs.exports=jl});var lc={};ba(lc,{CustomError:()=>F,EVENT_NAMES:()=>E,Interactives:()=>Ke,ManifestController:()=>pe,SDKInfo:()=>oc,chapterIdsToVKVideoIds:()=>At,compareVersions:()=>Y,getChapterIdByVkVideoId:()=>oa,getVKVideoIdByMedia:()=>$r,getVideoRawIdByMedia:()=>sa,graphEventTypes:()=>Te,hasEndTemplate:()=>Ge,interactivesEventTypes:()=>_,isLastChapter:()=>z,isSupportedManifest:()=>qe,isVKVariantItem:()=>aa,utils:()=>ua,vkVideoIdsToChapterIds:()=>Br});module.exports=Ca(lc);var ti="1.0.22-dev.71ddf25e.0";function Bt(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="interactive",Ea="interactive-controls-container",Je=()=>document.querySelector(`.${Ea}`),ri=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ii=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ii||{}),ni=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ni||{}),si=(i=>(i.start="left",i.end="right",i.center="center",i))(si||{}),et=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&ii[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&ni[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(o=((l=e.text)==null?void 0:l.alignment)&&si[e.text.alignment])!=null?o:"left"},tt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c;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=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},rt=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=Bt((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)},it=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,m,v,d,I,x;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 ${Bt((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(v=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:v.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(x=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?x:t.roundCorners})`},ve=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var K=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${H}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:q.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var qt="int",se=(i=>(i.AREA=`${qt}_area`,i.TEXT=`${qt}_text`,i.BUTTON=`${qt}_bttn`,i))(se||{});var nt=r=>{if(r.type.trim().toLowerCase()==="area")return new Dt(r)},Dt=class extends K{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",rt({target:i,props:this.control.props,fallback:C(h({},q),{backgroundColor:"transparent"})}),it({target:i,props:this.control.props,fallback:C(h({},q),{borderAlpha:0}),dependsOn:this.container.dimensions}),ve({target:i,layoutParams:this.control.layoutParams,fallback:q}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var st=()=>{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 Ht(r)},Ht=class extends K{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ve({target:i,layoutParams:this.control.layoutParams,fallback:q}),rt({target:i,props:this.control.props,fallback:q}),it({target:i,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),et({target:i,props:this.control.props});let n=st();tt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ai=r=>{if(r.type.trim().toLowerCase()==="text")return new Ut(r)},Ut=class extends K{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ve({target:i,layoutParams:this.control.layoutParams,fallback:q}),et({target:i,props:this.control.props});let n=st();tt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var Gt=class{constructor(e){this.layout=e}},ot=class extends Gt{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 ee,lt,oi,ge=class{constructor(e){B(this,ee);this.container=e,this.factories=new Map,Ae(this,ee,lt).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),Ae(this,ee,lt).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),Ae(this,ee,lt).call(this)}};ee=new WeakSet,lt=function(){this.controls=Ae(this,ee,oi).call(this)},oi=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 ct=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new zt(r,e)},zt=class extends ge{constructor(e,t){super(e),this.rootElement=t!=null?t:Je(),this.layout=new ot(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",at),this.addControlFactory("text",ai),this.addControlFactory("area",nt)}createView(e){let t=document.createElement("div");return t.classList.add(`${H}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=ri,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${H}-${this.container.id}`)}};var pa=Ft(Sr(),1),L=require("@vkontakte/videoplayer-shared"),Le=require("@vkontakte/videoplayer-statistics");var Ss=require("@vkontakte/videoplayer-shared");function Ne(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,je=r=>oe(r,"Object"),mt=r=>oe(r,"String"),yt=r=>oe(r,"Array"),vt=r=>oe(r,"Number"),Es=r=>oe(r,"Function");var wr=r=>vt(r)&&!isNaN(r);var le=r=>je(r)&&Object.keys(r).length===0,Lr=r=>yt(r)&&!r.length;var Fe=(r,e)=>mt(r)&&(e?r.trim():r).length;var Is="video_interactive",xs="videoint";var Ts=250,$e=class{constructor(e){this.handleZoomChange=Ne(e=>{this.lastZoomInfo=e},Ts);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!vt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Fl(e),this.resizeObserver=new ResizeObserver(Ne(this.onResize,Ts)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return w(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return w(this,null,function*(){if(!this.manifest)return;let e;try{e=yield(0,Ss.loadVKLangPack)(this.lang,Is,xs)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.ngEditor.on("control",s=>{var l=s,{name:i}=l,n=j(l,["name"]);var o;i==="openPreview"&&"chapterId"in n&&((o=this.onOpenPreviewClick)==null||o.call(this,n.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Fl(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 Be=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 Y=(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 Ls=require("uuid");var $l="3.1",ws={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Bl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ms=r=>{let e=[];for(let l of r.chapters){let o,a=[];for(let t of l.branches){let i=t,{isDefault:v}=i,d=j(i,["isDefault"]);v&&(o=d.id),a.push(d)}let c=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:v}=s,d=j(s,["fallbackStrategy"]);let I=!!d.endTime,x=[Bl];switch(v){case"await":I?x=[]:c=[];break;case"default":{let M={type:"onSuspense",action:{type:ws.default,args:{branchId:o,shouldOpenNow:!I,isDetachContainer:!0}}};I?x=[M]:c=[M];break}case"random":case"weightlessRandom":case"max":case"min":{let M={type:"onSuspense",action:{type:ws[v],args:{}}};I?x=[M]:c=[M];break}}for(let M of d.controls)m.push(C(h({},d),{controls:[h({},M)],id:(0,Ls.v4)(),events:x}))}e.push(C(h({},l),{containers:m,events:c,branches:a}))}return r.metadata.version=$l,r.metadata.updated=new Date().toISOString(),C(h({},r),{chapters:e})};var ql="3.2",_s=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=j(e,["media"]);return C(h({},r),{metadata:C(h({},i),{version:ql}),media:t})}return r};var Dl="3.3",Hl=(r=[])=>({edit:{chapters:r},view:{}}),As={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Rs=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:l,x:o,y:a}=i,c=j(i,["id","x","y"]),m=c.containers.map(v=>{var d;return C(h({},v),{controls:v.controls.map(b=>{var p=b,{subtype:I,type:x}=p,M=j(p,["subtype","type"]);return C(h({},M),{type:I!=null?I:x})}),events:(d=v.events)!=null&&d.length?v.events:[As]})});e.push(C(h({id:l},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[As]})),t.push({id:l,x:o,y:a})}return C(h({},r),{chapters:e,graph:Hl(t),metadata:C(h({},r.metadata),{version:Dl})})};var Ul=[{version:"3.0",migrate:Ms},{version:"3.1",migrate:_s},{version:"3.2",migrate:Rs}],Mr=r=>Ul.reduce((e,t)=>Y(e.metadata.version,t.version)?e:t.migrate(e),r);var Ps={Button:"Button",Area:"Area",Text:"Text"};var R={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var ks={metadata:"Object",chapters:"Array"},Gl="3.0.0",zl="3.3.0",qe=r=>{let e=Y(r,Gl);return e===-1?!1:e===0?!0:Y(r,zl)!==1},Vs=r=>{if(!je(r))return!1;for(let e in ks)if(!r[e]||!oe(r[e],ks[e]))return!1;return qe(r.metadata.version)},gt=r=>r.type===Ps.Text;var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var bt=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 Ct=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Es(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Bs=require("@vkontakte/videoplayer-shared");var Et=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 w(this,null,function*(){return Wl(...this.loaders[e])(t)})}};function Wl(...r){return function(t){return w(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function De(r,e,t){return r?C(h({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function It(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=j(s,["actions","errors","chapterId"]);if(t){let l=r.getManifest(),o=r.getChapter(l.chapters,t);if(o){let a=r.getMedia(l.media,o.videoId),c=r.getGraph(l.graph,o.id);return a?C(h({},i),{actions:r,errors:e,result:{chapter:o,media:a,graph:c}}):C(h({},i),{errors:De(e,It.name,"Could not find media"),actions:r})}}return C(h({},i),{errors:De(e,It.name,"Could not find chapter"),actions:r})}var xt=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}},xe=class extends xt{constructor(){super(),this.listeners||xt.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)}},He=class{constructor(){Object.defineProperty(this,"signal",{value:new xe,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(He.prototype[Symbol.toStringTag]="AbortController",xe.prototype[Symbol.toStringTag]="AbortSignal");function Tt(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 _r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Tt({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(c,m){let v;m&&m.signal&&(v=m.signal,delete m.signal);let d=new t(c,m);return v&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),d},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let m=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let v;try{v=new DOMException("Aborted","AbortError")}catch(I){v=new Error("Aborted"),v.name="AbortError"}if(m.aborted)return Promise.reject(v);let d=new Promise((I,x)=>{m.addEventListener("abort",()=>x(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,l(a,c)])}return l(a,c)},Request:s}}var Ue=Tt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Os=Ue?_r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ar=Ue?Os.fetch:window.fetch,th=Ue?Os.Request:window.Request,rh=Ue?He:window.AbortController,ih=Ue?xe:window.AbortSignal;var Ql=r=>w(void 0,null,function*(){try{let e={},t;if(mt(r)){t=new URL(r).href;let n=yield Ar(t);if(!n.ok)return{};e=yield n.json()}else if(je(r))e=r;else return{};if(!Vs(e))return{};let i=e.metadata.media;if(mt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Ar(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Zl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ns(r){return w(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ql(r),i=Mr(e);return i.media=Kl(i.media,t),delete i.metadata.media,i})}function St(r,e){if(e)return r.find(t=>t.id===e)}function Rr(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 Pr(r,e){return r.videos.find(t=>t.id===e)}function Kl(r,e){return C(h({},r),{videos:r.videos.map(t=>C(h({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Yl(n,e);return C(h({},i),{url:s||n})})}))})}function Yl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zl(r){return Y(r,"3.2.0")>=0}var wt=r=>yt(r)&&!Lr(r),z=r=>r.order==="end",Ge=r=>yt(r.containers)&&!Lr(r.containers)&&z(r),js=(r,e)=>{var i;let t=r*1e3;return wt(e.controls)&&t<((i=e.startTime)!=null?i:0)},kr=(r,e)=>{var i,n;let t=r*1e3;return wt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),Vr=(r=[])=>r.find(e=>e.action.type==="expect"),Xl=r=>(r==null?void 0:r.length)===1,Lt=r=>Xl(r)&&gt(r[0]);function Fs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(h(h({},e[0]),t)):r(...e,...t)}var $s=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var pe=class extends Et{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Bs.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 w(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:De},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield Ns((n=i.result)!=null?n:t),this})}setInitial(){return w(this,null,function*(){return this.setNext()})}setNext(){return w(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",It({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Rr,getChapter:St,getMedia:Pr,getByBranches:this.getByBranches.bind(this),addErrorMessage:De},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=St(this.manifest.chapters,t);if(n){let s=Pr(this.manifest.media,n.videoId),l=Rr(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=St(((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 this.chapter?z(this.chapter):!1}};var Ds=require("@vkontakte/videoplayer-core"),ie=require("@vkontakte/videoplayer-shared");var qs=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[]};function Or(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=c,o=j(c,["listId","itemId"]);let m=r.get(s),v=h({},o);return m?m[l]=v:r.set(s,{[l]:v}),h({listId:s,itemId:l},o)}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function Nr(r,e=[]){var s,l,o;let t={},i,n=!e.length;for(let a of r.variants)if(!i&&"cover"in a&&(i=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(t.MPEG=C(h({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(h({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(h({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(h({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var ze=(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 Jl=2;function jr(r){let e=Or(),t=new ie.Subscription,i={},n=null,s=!1,l,o=new ie.ValueSubject(null);r&&a(r);function a(b){n=b}function c(b,p,u){var y;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((y=e.map.get(b))!=null?y:{})[p];if(T){i=h({chapterId:u,listId:b,itemId:p},T);let P=i.player;i.subscription.add(P.info.currentQuality$.subscribe(A=>{let D=P.info.position$.getValue(),k=P.info.isAutoQualityEnabled$.getValue();if(!(!A||!D||k))for(let O of e.map)Object.values(O[1]).forEach(({player:V})=>{ze(V,A)})})).add(P.events.started$.subscribe(()=>{m(p)})),T.container.remove(),n.setPlayer(T.player),s||(n.init(),s=!0),o.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function m(b){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(le(i)||b!==i.itemId)return;let p=n.getChapterBranches(),u=new Set;for(let g of p)u.has(g.media.id)||(yield d({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),u.add(g.media.id))})}function v(u){return w(this,arguments,function*({chapter:{id:b},manifestVideo:p}){if(le(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),y=i.player.info.isAutoQualityEnabled$.getValue(),P=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),D=!y,k=!1;for(let O of e.map)if(O[0]===p.id&&!n.state.isReplay$.getValue()){let V=Object.keys(O[1]);for(let $ of V)$===i.itemId?(V.length<Jl||(k=!0),e.removePlayer(O[0],$)):(k=!0,c(O[0],$,b),D?ze(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(P),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);k||(yield d({media:p,chapterId:b,setAsActive:!0,playbackRate:A}),D?ze(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(P),i.player.setMuted(g))})}function d(D){return w(this,arguments,function*({media:b,chapterId:p,prefetch:u=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:y,title:P,playbackRate:A}){var Ur,Gr,zr,Wr,Qr;let k=Math.random().toString(),O=document.createElement("div");l.append(O);let V;if((Ur=n==null?void 0:n.options)!=null&&Ur.vkVideoLoader){let Ze=qs(b);Ze.length&&(V=yield n.options.vkVideoLoader(...Ze))}let $=((Gr=n==null?void 0:n.options)==null?void 0:Gr.coreConfig)||void 0,Me=C(h({},$),{configName:[...(zr=$==null?void 0:$.configName)!=null?zr:[],"interactive"]}),Ye=C(h({container:O},((Wr=V==null?void 0:V.videos)==null?void 0:Wr[0])||{sources:Nr(b,y).sources}),{title:P,failoverHosts:(V==null?void 0:V.failoverHosts)||[]}),me=new Ds.Player(Me,ie.Tracer.createRootTracer());me.initVideo(Ye);let Dr=null;if(V!=null&&V.videos&&(n!=null&&n.options.createOneStat)){let Ze=V.videos[0],Nt=n.options.createOneStat(Ze),Kr=new ie.Subscription;Nt&&(Kr.add(Nt.attachTo(me)),Dr={oneStat:Nt,statSubscription:Kr})}let Hr=new ie.Subscription,ha=(Qr=i==null?void 0:i.player)==null?void 0:Qr.info.isAutoQualityEnabled$.getValue();Hr.add(me.events.canplay$.subscribe(function(){ha||ze(me,i.player.info.currentQuality$.getValue()),A&&me.setPlaybackRate(A)}));let ye=e.createPlayer({listId:b.id,itemId:k,player:me,container:O,sources:Nr(b,y).sources,config:Ye,subscription:Hr,statistics:Dr});return g&&c(b.id,ye.itemId,p),T&&ye.player.play(),u&&!T&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}})}function I(){x(),n=null,l.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function M(){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),l=document.createElement("div");let{media:b,chapter:p}=n.getCurrentChapter();b&&p?(t.add(n.events.chapterChanged$.subscribe(v)),yield d({media:b,chapterId:p.id,title:p.label})):console.error("not found")})}return C(h({},e),{init:M,setInteractiveController:a,createPlayer:d,removeAll:I,getActivePlayer:function(){return i},activePlayerChanged:o})}var E={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Te={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Hs=require("@vkontakte/videoplayer-shared");var Mt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:a,disabledControls$:c,onRemove:m}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})))})};this.show=()=>{var e,t,i,n;if(this.gameState===2&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let l=Fs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(l),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var a;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||n.includes(this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(js(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(kr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let c=this.gameState;this.gameState=3,c===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let l=kr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,(a=this.container.container.endTime)!=null?a:1/0]:[];this.globalEventEmitter.emit(E.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:l})};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Hs.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=a&&Lt(t.container.controls),this.disabledControls$=c,this.onRemove=m,this.globalEventEmitter=l,this.gameState=0,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){var t;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((t=this.container.container.endTime)!=null?t:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ce(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(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.containerRemoved,visibility:!1}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Us=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!gt(a));if(wt(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],v=-1/0,d=1/0,I=[],x=[];for(let M=0;M<e.length;M++){let b=e[M];if(x.push(...b.subjects),b.range[0]<d&&(d=b.range[0]),b.range[1]>v&&(v=b.range[1]),a[0]>=b.range[0]&&a[1]<=b.range[1])return e[M].subjects.push(c),e;a[0]<b.range[0]&&a[1]>b.range[0]&&(m.push(M),I=I.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(m.push(M),I=I.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(m.push(M),I=I.concat(b.subjects),a[1]=b.range[1])}if(x.push(c),a[0]<=d&&a[1]>=v)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(M=>{e.splice(M,1)}),e.push({subjects:I.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function Gs(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var m;if(wr(o)){let v=(m=r[o])!=null?m:null;if(v&&a&&Fe(a,!0)){let d={},I=v[a];if(I&&(d=h(h({},d),I)),d=le(d)?null:d,d&&Fe(c,!0)){let x=d[c];return x!=null?x:null}return d}return v}return null}function s({timestamp:o,priority:a,initiator:c}){if(wr(o))if(r[o]){if(a&&Fe(a,!0))if(r[o][a]){if(c&&Fe(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!le(r[o][a]))return!0}else return!1;if(delete r[o][a],!le(r[o]))return!0}else return!1;return delete r[o]}else return!1;return!1}function l(v){var d=v,{timestamp:o,priority:a,initiator:c}=d,m=j(d,["timestamp","priority","initiator"]);var I,x,M;(x=(I=r[o])==null?void 0:I[a])!=null&&x[c]?r[o][a][c].push(h({},m)):(M=r[o])!=null&&M[a]?r[o][a]=C(h({},r[o][a]),{[c]:[h({},m)]}):r[o]?r[o]=C(h({},r[o]),{[a]:{[c]:[h({},m)]}}):r[o]={[a]:{[c]:[h({},m)]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var ec=[R.expect,R.setNextBranch],tc=1/0;function zs(r){let e=r,t,i=rc(),n=Gs(),s,l=()=>{d(),p()},o=u=>{n.add.call(void 0,u),x()},a=(u=[])=>{for(let g of u)if(g.action(),ec.includes(g.actionType))break},c=(u=1/0)=>{var P,A,D;let g=_t((P=n.get({timestamp:u,priority:"control"}))!=null?P:{}),T=_t((A=n.get({timestamp:u,priority:"container"}))!=null?A:{}),y=_t((D=n.get({timestamp:u,priority:"chapter"}))!=null?D:{});return[...g,...T,...y]},m=u=>{i.isReady(u)&&a(c(u))},v=()=>{var u;a([..._t((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},I=u=>{},x=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},M=u=>{d(),e=u},b=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},p=()=>{i.release(),n.removeAll()};return{setPlayer:M,add:o,remove:b,exec:m,execEndOfVideo:v,listen:x,unlisten:d,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function rc(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let m=(o=c.endTime)!=null?o:tc,v=(a=r.get(m))!=null?a:{};r.set(m,C(h({},v),{[c.id]:!1}))}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function _t(r){return Object.values(r).flat().sort(e=>e.actionType===R.expect?-1:1)}var Ws={videoContentHeight:0,videoContentWidth:0},Qs=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Ws;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Ws;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var ic=250;function Ks(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:v}=Qs(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${v}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=Ne(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},ic);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var We=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 nc=r=>Math.floor(Math.random()*r),Zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:1;l<t&&(t=l,i=s)}return i},Xs=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:0;l>t&&(t=l,i=s)}return i};var Js=r=>{let e=r.length,t=nc(e);return r[t]},Ys=1,ea=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:Ys;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:Ys,e>=t)return r[s];return r[r.length-1]};var ta={shouldOpenNow:!0,isDetachContainer:!0};var Fr=(r,e=!1)=>C(h({},r),{args:e?h(h({},r.args),ta):h(h({},ta),r.args)}),na=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:u,controlId:g,containerId:T,branches:y=[],onEvent:P,isEOV:A=()=>!1,isDisabled:D=()=>!1})=>{let k=Fr(p,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:k.type},V=D(),$=r.emit.bind(r,E.interactives,{subjectId:g,subjectType:u,subjectName:"control",type:V?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:h({containerId:T},k.args)});if(V){$();return}switch(k.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let Me=y.find(Ye=>Ye.id===k.args.branchId);if(!Me)return;P(k.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),k.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:u,action:k,payload:{chapterId:Me.chapterId,autoSelect:!1}}):(t.add(C(h({},O),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:k,payload:{chapterId:Me.chapterId,autoSelect:!1}})})),i==null||i());return}case R.continuePlayback.trim().toLowerCase():{P(k.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),k.args.shouldOpenNow?I({subjectId:g,subjectName:"control",subjectType:u,action:p}):t.add(C(h({},O),{action:I.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:p})}));return}case R.openURI.trim().toLowerCase():{P(k.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),k.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:u,action:k,payload:{URI:p.args.uri}}):(t.add(C(h({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:k,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(E.errors,new F(1,1,{message:"Unexpected control event"}));return}},o=({action:p,container:{id:u,endTime:g},branches:T=[],isEOV:y=!1,autoSelected:P=!1})=>{let A=Fr(p,y),D={timestamp:!A.args.shouldOpenNow||y?1/0:g!=null?g:1/0,priority:"container",initiator:u,actionType:A.type},k=r.emit.bind(r,E.interactives,{subjectId:u,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args});switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let O=T.find(V=>V.id===A.args.branchId);if(!O)return;k(),t.add(C(h({},D),{action:x.bind(null,{subjectId:u,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:P}})})),i==null||i();return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{k(),t.add(C(h({},D),{action:I.bind(null,{subjectId:u,subjectName:"container",action:A})}));return}case R.openURI.trim().toLowerCase():{k(),t.add(C(h({},D),{action:b.bind(null,{subjectId:u,subjectName:"container",action:A,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(E.errors,new F(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:u,isEOV:g=!1}){var y,P;let T=Vr(p.events);if(T){let A=Fr(T.action,g);r.emit(E.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(y=p.endTime)!=null?y:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(P=p.events)!=null?P:[])o({action:A.action,container:p,branches:u,isEOV:g})}let c=({chapterId:p,action:u,branches:g=[]})=>{let T=r.emit.bind(r,E.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let y=g.find(P=>P.id===u.args.branchId);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let y=Js(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let y=ea(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let y=Xs(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let y=Zs(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return T(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u});case R.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),r.emit(E.errors,new F(1,1,{message:"Unexpected chapter event"}));return}};function m(p){var g;let u=Vr(p.events);if(u){if(z(p))return;r.emit(E.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(g=p.events)==null||g.forEach(T=>{let y=c({chapterId:p.id,action:T.action,branches:p.branches});y&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:T.action.type,action:y})})}let v=({subjectId:p,subjectName:u})=>{e.pause(),r.emit(E.interactives,{subjectId:p,subjectName:u,type:_.actionExecution,actionType:R.expect})},d=({subjectId:p,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(E.interactives,{subjectId:p,subjectName:u,type:_.actionExecution,actionType:"after-expect"})},I=({subjectId:p,subjectName:u,subjectType:g,action:T})=>{r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:y})=>{y.behaviour="change-chapter",r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type,payload:y})},M=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:y})=>{y.behaviour="change-manifest",r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type,payload:y})},b=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:y})=>{if(!y.URI)return;let P=window.open(y.URI,"_blank","noopener,noreferrer");P&&(P.opener=null),r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:v,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var qr=Ft(Sr(),1),ne=require("@vkontakte/videoplayer-shared");var At=(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]=$r(s)}return t[i]}).filter(Boolean)},sa=r=>{for(let e of r.variants)if(aa(e)&&"payload"in e)return e.payload.id},aa=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",$r=r=>{let e=sa(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},oa=(r,e)=>{for(let t of r.media.videos)if(e===$r(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Br=(r,e)=>r.reduce((t,i)=>{let n=oa(e,i);return n?[...t,n]:t},[]);var Z,ue,he,U,Rt,X,J,W,de,Se,we,Qe=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new ne.ValueSubject([]),hasPrevChapter$:new ne.ValueSubject(!1),prevChapter$:new ne.ValueSubject(null),isInitialChapter$:new ne.ValueSubject(!1),isGoBackLimited$:new ne.ValueSubject(!1)};B(this,Z,null);B(this,ue);B(this,he,!1);B(this,U,null);B(this,Rt,null);B(this,X,null);B(this,J,null);B(this,W,null);B(this,de,new ne.Subscription);B(this,Se,!1);B(this,we,0);var l;N(this,X,t),N(this,W,e),N(this,J,i),N(this,Z,n),N(this,ue,s),this.state.history$&&S(this,de)&&((l=S(this,de))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,qr.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=S(this,U))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,we)===S(this,ue).maxLength-1)})))}setManifest(e){return w(this,null,function*(){!S(this,J)||!S(this,W)||(N(this,U,e),yield this.getProjectHistory(),yield S(this,J).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),S(this,he)||(N(this,he,!0),S(this,W).emit(E.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return S(this,he)}updateHistory(e,t=!0){return w(this,null,function*(){var o;if(!S(this,U))return;S(this,Se)?(N(this,Se,!1),ei(this,we)._++):N(this,we,0);let i=S(this,U),n=e.length-S(this,ue).maxLength,s=n>0?e.slice(n):e,l=At(s,i);if(N(this,Rt,l),this.state.history$.next(s),!(!t||!S(this,Z)||!S(this,X)))try{yield S(this,Z).save(S(this,X),l)}catch(a){(o=S(this,W))==null||o.emit(E.errors,new F(1,5,"Unable to save interactive history"))}})}goBack(){return w(this,null,function*(){var i;if(!this.state||!S(this,J))return(i=S(this,W))==null?void 0:i.emit(E.errors,new F(1,5,"Cannot go back because HistoryController has not been initialized"));N(this,Se,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,J).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return w(this,null,function*(){var n;if(!S(this,U)||!S(this,X))return;let e=S(this,U),t=[this.getInitialVideoId()];if(S(this,Z))try{let s=yield S(this,Z).get(S(this,X));s.length&&(t=s)}catch(s){(n=S(this,W))==null||n.emit(E.errors,new F(1,5,"Error while trying to fetch data"))}let i=Br(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,qr.default)(e,-1)||S(this,ue).initChapterId||((t=S(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,U)){let e=this.getInitialChapterId();return At([e],S(this,U)).pop()}return null}destroy(){var e,t;N(this,X,null),N(this,Z,null),N(this,J,null),(e=S(this,de))==null||e.unsubscribe(),N(this,de,null),N(this,he,!1),(t=S(this,W))==null||t.emit(E.historyDestroyed),N(this,W,null)}};Z=new WeakMap,ue=new WeakMap,he=new WeakMap,U=new WeakMap,Rt=new WeakMap,X=new WeakMap,J=new WeakMap,W=new WeakMap,de=new WeakMap,Se=new WeakMap,we=new WeakMap;var fe=class fe{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=fe._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(",")),fe._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=fe._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}fe._supportsObject=t}return t||!1}};fe._supportsObject=void 0;var Pt=fe;var kt=class{constructor(){this.bindingMap=new We}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new Pt(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 Vt=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 w(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 w(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 Ot=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 Ot,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new Vt,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 _(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 la(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ca=Object.freeze({lang:M.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function ac(){let r=document.createElement("div");return r.style.cssText=`
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return w(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 la(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ca=Object.freeze({lang:L.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function ac(){let r=document.createElement("div");return r.style.cssText=`
20
20
  position: absolute;
21
21
  top: 0;
22
22
  left: 0;
23
- `,r}var Ze=class{constructor(e){this.subscription=new M.Subscription;this.globalEventEmitter=new Ct;this.animation=new Et;this.eventManager=new Pt;this.seekToInteractiveController=new De;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ac();this.factories=new Map([["choice",ut]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new M.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new M.ValueSubject(null),isInitialChapter$:new M.ValueSubject(!1),isFirstChapter$:new M.ValueSubject(!0),isEndChapter$:new M.ValueSubject(!1),isInteractiveExpectation$:new M.ValueSubject(!1),calledByInteractive$:new M.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new M.ValueSubject(!1),disabledControls$:new M.ValueSubject(!1),interactiveRanges$:new M.ValueSubject([]),isInteractiveTime$:new M.ValueSubject(!1),statistics$:new M.ValueSubject(null),isSeekable$:new M.ValueSubject(!1)};this.events={noInteraction$:new M.Subject,graphVisibilityChanged$:new M.Subject,watchAgainIsClicked$:new M.Subject};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&z(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=j(n,["statistics"]);if(t){let{statSubscription:s,oneStat:l}=t;s.add(l.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.globalEventEmitter.emit(b.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(s=>E(h({},s),{subjects:s.subjects.filter(l=>l!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options=E(h(h({},ca),e),{config:h(h({},ca.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new Ye({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(t=this._options.projectInfo)==null?void 0:t.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Nt({parentElement:this._options.parentElement,onError:i=>this.globalEventEmitter.emit(b.errors,new $(1,6,i))})),this.eventManager.listen(this.rootElement,"mousedown",i=>i.stopPropagation()),this.eventManager.listen(this.rootElement,"mouseup",i=>i.stopPropagation()),this.manifestController=new ue(this._options.loaders,i=>this.globalEventEmitter.emit(b.errors,new $(1,3,i))),this.resizeManager=Ys(()=>{var i,n;return{player:this.player,parentElement:(i=this._options)==null?void 0:i.parentElement,fns:(n=this._options)!=null&&n.lastFrame?[()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}]:[]}}),this._options.graph&&(this.graph=new qe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(b.graph,{type:Se.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>this.globalEventEmitter.emit(b.errors,new $(1,4,{message:i}))})),this.initSubscriptions()}initSubscriptions(){this.globalEventEmitter.on(b.historyInited,t=>_(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))})),this.globalEventEmitter.on(b.interactives,e=>_(this,null,function*(){var t,i;if(e.type===R.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===R.containerRemoved&&this.completeInteractiveRange(e.subjectId)})),this.globalEventEmitter.on(b.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}initSeamless(){return _(this,null,function*(){this.seamlessController=$r(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(n){let s=n.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(b.interactives,{type:R.rangeEnded,payload:n,visibility:!0}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.add(this.player.events.started$.pipe((0,M.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,M.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var a;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[y,d],subjects:C})=>y<c&&c<d&&C.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=!!this.noInteractionTimeout,o=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||i;n&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),this._options.lastFrame&&this.subscription.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Lt(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);if(s){let l=new Mt({player:this.player,container:s(i,this.rootElement),branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Bs(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var o,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&z(i)&&We(i))!=null?o:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(s||n&&t){this.historyController.updateHistory([e]);return}(0,ua.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}setManifest(e){return _(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&(yield this.graph.handleManifestChange(t.manifest)),yield this.historyController.setManifest(t.manifest),this.globalEventEmitter.emit(b.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest})}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=Ws(this.player),this.selectBranches=na({player:this.player,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,removeControllers:()=>this.removeControllers(!1)}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return _(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),M.clientChecker.isSafari&&(yield la(35));let n=!i&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e,{chapter:s,media:l,graph:o}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||n)&&this.state.isFirstChapter$.next(!0),s&&(t&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),(c=this.lastFrame)==null||c.setCurrentChapter(s),this.globalEventEmitter.emit(b.chapterChanged,{chapter:s,media:l,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new M.Observable(e=>{this.globalEventEmitter.on(b.graph,({type:t,visibility:i})=>{t==="visibility"&&e.next(i?Me.InteractiveInterfaceClick.GRAPH_SHOW:Me.InteractiveInterfaceClick.GRAPH_HIDE),t==="watchAgainClicked"&&e.next(Me.InteractiveInterfaceClick.WATCH_AGAIN)}),this.globalEventEmitter.on(b.interactives,({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Me.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(Me.InteractiveInterfaceClick.NEXT_AREA))})}),nextMovie$:new M.Observable(e=>{this.globalEventEmitter.on(b.playerChanged,({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(b.graph,{type:Se.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===V.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!n.isRemoved&&n.endTime===null&&ce(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&He(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return Us((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,s;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(n=this.interactiveEvents)==null||n.release(),this.manifestController.release(),this.eventManager.release(),this.subscription.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ha={Container:Ce,createChoiceContainer:ut,createAreaControl:st,createButtonControl:ot,getRootEl:et,classnamesPrefix:H};var oc={version:ri};
23
+ `,r}var Ke=class{constructor(e){this.subscription=new L.Subscription;this.globalEventEmitter=new bt;this.animation=new Ct;this.eventManager=new kt;this.seekToInteractiveController=new Be;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ac();this.factories=new Map([["choice",ct]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new L.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new L.ValueSubject(null),isInitialChapter$:new L.ValueSubject(!1),isFirstChapter$:new L.ValueSubject(!0),isEndChapter$:new L.ValueSubject(!1),isInteractiveExpectation$:new L.ValueSubject(!1),isReplay$:new L.ValueSubject(!1),calledByInteractive$:new L.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new L.ValueSubject(!1),disabledControls$:new L.ValueSubject(!1),interactiveRanges$:new L.ValueSubject([]),isInteractiveTime$:new L.ValueSubject(!1),statistics$:new L.ValueSubject(null),isSeekable$:new L.ValueSubject(!1)};this.events={noInteraction$:new L.Subject,graphVisibilityChanged$:new L.Subject,watchAgainIsClicked$:new L.Subject,chapterChanged$:new L.Subject};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&z(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=j(n,["statistics"]);if(t){let{statSubscription:s,oneStat:l}=t;s.add(l.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.globalEventEmitter.emit(E.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(s=>C(h({},s),{subjects:s.subjects.filter(l=>l!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options=C(h(h({},ca),e),{config:h(h({},ca.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new Qe({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(t=this._options.projectInfo)==null?void 0:t.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Ot({parentElement:this._options.parentElement,onError:i=>this.globalEventEmitter.emit(E.errors,new F(1,6,i))})),this.eventManager.listen(this.rootElement,"mousedown",i=>i.stopPropagation()),this.eventManager.listen(this.rootElement,"mouseup",i=>i.stopPropagation()),this.manifestController=new pe(this._options.loaders,i=>this.globalEventEmitter.emit(E.errors,new F(1,3,i))),this.resizeManager=Ks(()=>{var i,n;return{player:this.player,parentElement:(i=this._options)==null?void 0:i.parentElement,fns:(n=this._options)!=null&&n.lastFrame?[()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}]:[]}}),this._options.graph&&(this.graph=new $e({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(E.graph,{type:Te.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>this.globalEventEmitter.emit(E.errors,new F(1,4,{message:i}))})),this.initSubscriptions()}initSubscriptions(){this.globalEventEmitter.on(E.historyInited,t=>w(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))})),this.globalEventEmitter.on(E.interactives,e=>w(this,null,function*(){var t,i;if(e.type===_.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===_.containerRemoved&&this.completeInteractiveRange(e.subjectId)})),this.globalEventEmitter.on(E.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}initSeamless(){return w(this,null,function*(){this.seamlessController=jr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(n){let s=n.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(E.interactives,{type:_.rangeEnded,payload:n,visibility:!0}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.add(this.player.events.started$.pipe((0,L.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,L.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var a;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[v,d],subjects:I})=>v<c&&c<d&&I.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=!!this.noInteractionTimeout,o=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||i;n&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),this._options.lastFrame&&this.subscription.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Lt(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);if(s){let l=new Mt({player:this.player,container:s(i,this.rootElement),branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>$s(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var o,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&z(i)&&Ge(i))!=null?o:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(s||n&&t){this.historyController.updateHistory([e]);return}(0,pa.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}setManifest(e){return w(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&(yield this.graph.handleManifestChange(t.manifest)),yield this.historyController.setManifest(t.manifest),this.globalEventEmitter.emit(E.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest})}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=zs(this.player),this.selectBranches=na({player:this.player,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,removeControllers:()=>this.removeControllers(!1)}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return w(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),L.clientChecker.isSafari&&(yield la(35));let n=!i&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:s,media:l,graph:o}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||n)&&this.state.isFirstChapter$.next(!0),!(!s||!l)&&(t&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),(c=this.lastFrame)==null||c.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:l}),this.globalEventEmitter.emit(E.chapterChanged,{chapter:s,media:l,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new L.Observable(e=>{this.globalEventEmitter.on(E.graph,({type:t,visibility:i})=>{t==="visibility"&&e.next(i?Le.InteractiveInterfaceClick.GRAPH_SHOW:Le.InteractiveInterfaceClick.GRAPH_HIDE),t==="watchAgainClicked"&&e.next(Le.InteractiveInterfaceClick.WATCH_AGAIN)}),this.globalEventEmitter.on(E.interactives,({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Le.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(Le.InteractiveInterfaceClick.NEXT_AREA))})}),nextMovie$:new L.Observable(e=>{this.globalEventEmitter.on(E.playerChanged,({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(E.graph,{type:Te.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===R.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&n.endTime===null&&ce(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&qe(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return Us((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,s;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(n=this.interactiveEvents)==null||n.release(),this.manifestController.release(),this.eventManager.release(),this.subscription.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ua={Container:ge,createChoiceContainer:ct,createAreaControl:nt,createButtonControl:at,getRootEl:Je,classnamesPrefix:H};var oc={version:ti};