@vkontakte/videoplayer-interactive 1.0.26-dev.23975e61.0 → 1.0.26-dev.ac7b329a.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 +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +3 -3
- package/package.json +4 -4
package/es2015.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.26-dev.
|
|
3
|
-
* Thu, 21 Nov 2024
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.26-dev.ac7b329a.0
|
|
3
|
+
* Thu, 21 Nov 2024 07:49:17 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-26/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var ca=Object.create;var _e=Object.defineProperty,pa=Object.defineProperties,ha=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertyDescriptors,da=Object.getOwnPropertyNames,Ze=Object.getOwnPropertySymbols,fa=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty,Wr=Object.prototype.propertyIsEnumerable;var Qr=r=>{throw TypeError(r)};var zr=(r,e,t)=>e in r?_e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))Vt.call(e,t)&&zr(r,t,e[t]);if(Ze)for(var t of Ze(e))Wr.call(e,t)&&zr(r,t,e[t]);return r},C=(r,e)=>pa(r,ua(e));var N=(r,e)=>{var t={};for(var i in r)Vt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Ze)for(var i of Ze(r))e.indexOf(i)<0&&Wr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ma=(r,e)=>{for(var t in e)_e(r,t,{get:e[t],enumerable:!0})},Kr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of da(e))!Vt.call(r,n)&&n!==t&&_e(r,n,{get:()=>e[n],enumerable:!(i=ha(e,n))||i.enumerable});return r};var Ot=(r,e,t)=>(t=r!=null?ca(fa(r)):{},Kr(e||!r||!r.__esModule?_e(t,"default",{value:r,enumerable:!0}):t,r)),ya=r=>Kr(_e({},"__esModule",{value:!0}),r);var Yr=(r,e,t)=>e.has(r)||Qr("Cannot "+t);var S=(r,e,t)=>(Yr(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?Qr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,i)=>(Yr(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Zr=(r,e,t,i)=>({set _(n){j(r,e,n,t)},get _(){return S(r,e,i)}});var L=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{l(t.next(a))}catch(c){n(c)}},o=a=>{try{l(t.throw(a))}catch(c){n(c)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,o);l((t=t.apply(r,e)).next())});var Q=f((Ht,ni)=>{"use strict";var Ae=function(r){return r&&r.Math===Math&&r};ni.exports=Ae(typeof globalThis=="object"&&globalThis)||Ae(typeof window=="object"&&window)||Ae(typeof self=="object"&&self)||Ae(typeof global=="object"&&global)||Ae(typeof Ht=="object"&&Ht)||function(){return this}()||Function("return this")()});var te=f((zc,si)=>{"use strict";si.exports=function(r){try{return!!r()}catch(e){return!0}}});var Re=f((Wc,ai)=>{"use strict";var ga=te();ai.exports=!ga(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var hi=f((Qc,pi)=>{"use strict";var ba=Re(),ci=Function.prototype,oi=ci.apply,li=ci.call;pi.exports=typeof Reflect=="object"&&Reflect.apply||(ba?li.bind(oi):function(){return li.apply(oi,arguments)})});var se=f((Kc,fi)=>{"use strict";var ui=Re(),di=Function.prototype,Ut=di.call,Ca=ui&&di.bind.bind(Ut,Ut);fi.exports=ui?Ca:function(r){return function(){return Ut.apply(r,arguments)}}});var Gt=f((Yc,yi)=>{"use strict";var mi=se(),Ea=mi({}.toString),Ia=mi("".slice);yi.exports=function(r){return Ia(Ea(r),8,-1)}});var zt=f((Zc,vi)=>{"use strict";var xa=Gt(),Ta=se();vi.exports=function(r){if(xa(r)==="Function")return Ta(r)}});var re=f((Xc,gi)=>{"use strict";var Wt=typeof document=="object"&&document.all;gi.exports=typeof Wt=="undefined"&&Wt!==void 0?function(r){return typeof r=="function"||r===Wt}:function(r){return typeof r=="function"}});var be=f((Jc,bi)=>{"use strict";var Sa=te();bi.exports=!Sa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ct=f((ep,Ci)=>{"use strict";var wa=Re(),lt=Function.prototype.call;Ci.exports=wa?lt.bind(lt):function(){return lt.apply(lt,arguments)}});var Ti=f(xi=>{"use strict";var Ei={}.propertyIsEnumerable,Ii=Object.getOwnPropertyDescriptor,La=Ii&&!Ei.call({1:2},1);xi.f=La?function(e){var t=Ii(this,e);return!!t&&t.enumerable}:Ei});var Qt=f((rp,Si)=>{"use strict";Si.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Li=f((ip,wi)=>{"use strict";var Ma=se(),_a=te(),Aa=Gt(),Kt=Object,Ra=Ma("".split);wi.exports=_a(function(){return!Kt("z").propertyIsEnumerable(0)})?function(r){return Aa(r)==="String"?Ra(r,""):Kt(r)}:Kt});var Yt=f((np,Mi)=>{"use strict";Mi.exports=function(r){return r==null}});var Zt=f((sp,_i)=>{"use strict";var ka=Yt(),Pa=TypeError;_i.exports=function(r){if(ka(r))throw new Pa("Can't call method on "+r);return r}});var Ri=f((ap,Ai)=>{"use strict";var Va=Li(),Oa=Zt();Ai.exports=function(r){return Va(Oa(r))}});var ke=f((op,ki)=>{"use strict";var ja=re();ki.exports=function(r){return typeof r=="object"?r!==null:ja(r)}});var Xt=f((lp,Pi)=>{"use strict";Pi.exports={}});var tr=f((cp,Oi)=>{"use strict";var Jt=Xt(),er=Q(),Na=re(),Vi=function(r){return Na(r)?r:void 0};Oi.exports=function(r,e){return arguments.length<2?Vi(Jt[r])||Vi(er[r]):Jt[r]&&Jt[r][e]||er[r]&&er[r][e]}});var Ni=f((pp,ji)=>{"use strict";var $a=se();ji.exports=$a({}.isPrototypeOf)});var qi=f((hp,Bi)=>{"use strict";var Fa=Q(),$i=Fa.navigator,Fi=$i&&$i.userAgent;Bi.exports=Fi?String(Fi):""});var Qi=f((up,Wi)=>{"use strict";var zi=Q(),rr=qi(),Di=zi.process,Hi=zi.Deno,Ui=Di&&Di.versions||Hi&&Hi.version,Gi=Ui&&Ui.v8,z,pt;Gi&&(z=Gi.split("."),pt=z[0]>0&&z[0]<4?1:+(z[0]+z[1]));!pt&&rr&&(z=rr.match(/Edge\/(\d+)/),(!z||z[1]>=74)&&(z=rr.match(/Chrome\/(\d+)/),z&&(pt=+z[1])));Wi.exports=pt});var ir=f((dp,Yi)=>{"use strict";var Ki=Qi(),Ba=te(),qa=Q(),Da=qa.String;Yi.exports=!!Object.getOwnPropertySymbols&&!Ba(function(){var r=Symbol("symbol detection");return!Da(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ki&&Ki<41})});var nr=f((fp,Zi)=>{"use strict";var Ha=ir();Zi.exports=Ha&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var sr=f((mp,Xi)=>{"use strict";var Ua=tr(),Ga=re(),za=Ni(),Wa=nr(),Qa=Object;Xi.exports=Wa?function(r){return typeof r=="symbol"}:function(r){var e=Ua("Symbol");return Ga(e)&&za(e.prototype,Qa(r))}});var en=f((yp,Ji)=>{"use strict";var Ka=String;Ji.exports=function(r){try{return Ka(r)}catch(e){return"Object"}}});var ar=f((vp,tn)=>{"use strict";var Ya=re(),Za=en(),Xa=TypeError;tn.exports=function(r){if(Ya(r))return r;throw new Xa(Za(r)+" is not a function")}});var nn=f((gp,rn)=>{"use strict";var Ja=ar(),eo=Yt();rn.exports=function(r,e){var t=r[e];return eo(t)?void 0:Ja(t)}});var an=f((bp,sn)=>{"use strict";var or=ct(),lr=re(),cr=ke(),to=TypeError;sn.exports=function(r,e){var t,i;if(e==="string"&&lr(t=r.toString)&&!cr(i=or(t,r))||lr(t=r.valueOf)&&!cr(i=or(t,r))||e!=="string"&&lr(t=r.toString)&&!cr(i=or(t,r)))return i;throw new to("Can't convert object to primitive value")}});var ln=f((Cp,on)=>{"use strict";on.exports=!0});var hn=f((Ep,pn)=>{"use strict";var cn=Q(),ro=Object.defineProperty;pn.exports=function(r,e){try{ro(cn,r,{value:e,configurable:!0,writable:!0})}catch(t){cn[r]=e}return e}});var pr=f((Ip,fn)=>{"use strict";var io=ln(),no=Q(),so=hn(),un="__core-js_shared__",dn=fn.exports=no[un]||so(un,{});(dn.versions||(dn.versions=[])).push({version:"3.38.0",mode:io?"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 vn=f((xp,yn)=>{"use strict";var mn=pr();yn.exports=function(r,e){return mn[r]||(mn[r]=e||{})}});var hr=f((Tp,gn)=>{"use strict";var ao=Zt(),oo=Object;gn.exports=function(r){return oo(ao(r))}});var ht=f((Sp,bn)=>{"use strict";var lo=se(),co=hr(),po=lo({}.hasOwnProperty);bn.exports=Object.hasOwn||function(e,t){return po(co(e),t)}});var En=f((wp,Cn)=>{"use strict";var ho=se(),uo=0,fo=Math.random(),mo=ho(1 .toString);Cn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+mo(++uo+fo,36)}});var Tn=f((Lp,xn)=>{"use strict";var yo=Q(),vo=vn(),In=ht(),go=En(),bo=ir(),Co=nr(),Ce=yo.Symbol,ur=vo("wks"),Eo=Co?Ce.for||Ce:Ce&&Ce.withoutSetter||go;xn.exports=function(r){return In(ur,r)||(ur[r]=bo&&In(Ce,r)?Ce[r]:Eo("Symbol."+r)),ur[r]}});var Mn=f((Mp,Ln)=>{"use strict";var Io=ct(),Sn=ke(),wn=sr(),xo=nn(),To=an(),So=Tn(),wo=TypeError,Lo=So("toPrimitive");Ln.exports=function(r,e){if(!Sn(r)||wn(r))return r;var t=xo(r,Lo),i;if(t){if(e===void 0&&(e="default"),i=Io(t,r,e),!Sn(i)||wn(i))return i;throw new wo("Can't convert object to primitive value")}return e===void 0&&(e="number"),To(r,e)}});var dr=f((_p,_n)=>{"use strict";var Mo=Mn(),_o=sr();_n.exports=function(r){var e=Mo(r,"string");return _o(e)?e:e+""}});var kn=f((Ap,Rn)=>{"use strict";var Ao=Q(),An=ke(),fr=Ao.document,Ro=An(fr)&&An(fr.createElement);Rn.exports=function(r){return Ro?fr.createElement(r):{}}});var mr=f((Rp,Pn)=>{"use strict";var ko=be(),Po=te(),Vo=kn();Pn.exports=!ko&&!Po(function(){return Object.defineProperty(Vo("div"),"a",{get:function(){return 7}}).a!==7})});var jn=f(On=>{"use strict";var Oo=be(),jo=ct(),No=Ti(),$o=Qt(),Fo=Ri(),Bo=dr(),qo=ht(),Do=mr(),Vn=Object.getOwnPropertyDescriptor;On.f=Oo?Vn:function(e,t){if(e=Fo(e),t=Bo(t),Do)try{return Vn(e,t)}catch(i){}if(qo(e,t))return $o(!jo(No.f,e,t),e[t])}});var $n=f((Pp,Nn)=>{"use strict";var Ho=te(),Uo=re(),Go=/#|\.prototype\./,Pe=function(r,e){var t=Wo[zo(r)];return t===Ko?!0:t===Qo?!1:Uo(e)?Ho(e):!!e},zo=Pe.normalize=function(r){return String(r).replace(Go,".").toLowerCase()},Wo=Pe.data={},Qo=Pe.NATIVE="N",Ko=Pe.POLYFILL="P";Nn.exports=Pe});var qn=f((Vp,Bn)=>{"use strict";var Fn=zt(),Yo=ar(),Zo=Re(),Xo=Fn(Fn.bind);Bn.exports=function(r,e){return Yo(r),e===void 0?r:Zo?Xo(r,e):function(){return r.apply(e,arguments)}}});var Hn=f((Op,Dn)=>{"use strict";var Jo=be(),el=te();Dn.exports=Jo&&el(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Gn=f((jp,Un)=>{"use strict";var tl=ke(),rl=String,il=TypeError;Un.exports=function(r){if(tl(r))return r;throw new il(rl(r)+" is not an object")}});var Qn=f(Wn=>{"use strict";var nl=be(),sl=mr(),al=Hn(),ut=Gn(),zn=dr(),ol=TypeError,yr=Object.defineProperty,ll=Object.getOwnPropertyDescriptor,vr="enumerable",gr="configurable",br="writable";Wn.f=nl?al?function(e,t,i){if(ut(e),t=zn(t),ut(i),typeof e=="function"&&t==="prototype"&&"value"in i&&br in i&&!i[br]){var n=ll(e,t);n&&n[br]&&(e[t]=i.value,i={configurable:gr in i?i[gr]:n[gr],enumerable:vr in i?i[vr]:n[vr],writable:!1})}return yr(e,t,i)}:yr:function(e,t,i){if(ut(e),t=zn(t),ut(i),sl)try{return yr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new ol("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Yn=f(($p,Kn)=>{"use strict";var cl=be(),pl=Qn(),hl=Qt();Kn.exports=cl?function(r,e,t){return pl.f(r,e,hl(1,t))}:function(r,e,t){return r[e]=t,r}});var Jn=f((Fp,Xn)=>{"use strict";var Ve=Q(),ul=hi(),dl=zt(),fl=re(),ml=jn().f,yl=$n(),Ee=Xt(),vl=qn(),Ie=Yn(),Zn=ht();pr();var gl=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 ul(r,this,arguments)};return e.prototype=r.prototype,e};Xn.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,o=i?Ve:n?Ve[t]:Ve[t]&&Ve[t].prototype,l=i?Ee:Ee[t]||Ie(Ee,t,{})[t],a=l.prototype,c,m,y,d,E,x,M,b,p;for(d in e)c=yl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&o&&Zn(o,d),x=l[d],m&&(r.dontCallGetSet?(p=ml(o,d),M=p&&p.value):M=o[d]),E=m&&M?M:e[d],!(!c&&!s&&typeof x==typeof E)&&(r.bind&&m?b=vl(E,Ve):r.wrap&&m?b=gl(E):s&&fl(E)?b=dl(E):b=E,(r.sham||E&&E.sham||x&&x.sham)&&Ie(b,"sham",!0),Ie(l,d,b),s&&(y=t+"Prototype",Zn(Ee,y)||Ie(Ee,y,{}),Ie(Ee[y],d,E),r.real&&a&&(c||!a[d])&&Ie(a,d,E)))}});var ts=f((Bp,es)=>{"use strict";var bl=Math.ceil,Cl=Math.floor;es.exports=Math.trunc||function(e){var t=+e;return(t>0?Cl:bl)(t)}});var Cr=f((qp,rs)=>{"use strict";var El=ts();rs.exports=function(r){var e=+r;return e!==e||e===0?0:El(e)}});var ns=f((Dp,is)=>{"use strict";var Il=Cr(),xl=Math.min;is.exports=function(r){var e=Il(r);return e>0?xl(e,9007199254740991):0}});var as=f((Hp,ss)=>{"use strict";var Tl=ns();ss.exports=function(r){return Tl(r.length)}});var ls=f((Up,os)=>{"use strict";os.exports=function(){}});var cs=f(()=>{"use strict";var Sl=Jn(),wl=hr(),Ll=as(),Ml=Cr(),_l=ls();Sl({target:"Array",proto:!0},{at:function(e){var t=wl(this),i=Ll(t),n=Ml(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});_l("at")});var hs=f((Wp,ps)=>{"use strict";var Al=tr();ps.exports=Al});var ds=f((Qp,us)=>{"use strict";cs();var Rl=hs();us.exports=Rl("Array","at")});var ms=f((Kp,fs)=>{"use strict";var kl=ds();fs.exports=kl});var Er=f((Yp,ys)=>{"use strict";var Pl=ms();ys.exports=Pl});var nc={};ma(nc,{CustomError:()=>$,EVENT_NAMES:()=>I,Interactives:()=>Qe,ManifestController:()=>pe,SDKInfo:()=>ic,chapterIdsToVKVideoIds:()=>Lt,compareVersions:()=>Z,getChapterIdByVkVideoId:()=>ia,getVKVideoIdByMedia:()=>Or,getVideoRawIdByMedia:()=>ta,graphEventTypes:()=>Te,hasEndTemplate:()=>Ue,interactivesEventTypes:()=>_,isLastChapter:()=>W,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>Be,isVKVariantItem:()=>ra,utils:()=>oa,vkVideoIdsToChapterIds:()=>jr});module.exports=ya(nc);var Xr="1.0.26-dev.23975e61.0";function jt(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 D="interactive",va="interactive-controls-container",Xe=()=>document.querySelector(`.${va}`),Jr=.4,B={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ei=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ei||{}),ti=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ti||{}),ri=(i=>(i.start="left",i.end="right",i.center="center",i))(ri||{}),Je=({target:r,props:e})=>{var t,i,n,s,o,l;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&ei[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&ti[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(l=((o=e.text)==null?void 0:o.alignment)&&ri[e.text.alignment])!=null?l:"left"},et=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,o,l,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} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},tt=({target:r,props:e,fallback:t})=>{var i,n,s,o;r.style.backgroundColor=jt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?o:t.backgroundAlpha)},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,o,l,a,c,m,y,d,E,x;r.style.border=`calc(${i.height} * ${(o=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?o:t.borderWidth}) solid ${jt((c=(a=(l=e==null?void 0:e.shape)==null?void 0:l.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} * ${(x=(E=e==null?void 0:e.shape)==null?void 0:E.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 Y=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(`${D}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:B.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 Nt="int",ne=(i=>(i.AREA=`${Nt}_area`,i.TEXT=`${Nt}_text`,i.BUTTON=`${Nt}_bttn`,i))(ne||{});var it=r=>{if(r.type.trim().toLowerCase()==="area")return new $t(r)},$t=class extends Y{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(`${D}-${this.control.id}`),i.setAttribute("data-testid",ne.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",tt({target:i,props:this.control.props,fallback:C(u({},B),{backgroundColor:"transparent"})}),rt({target:i,props:this.control.props,fallback:C(u({},B),{borderAlpha:0}),dependsOn:this.container.dimensions}),ve({target:i,layoutParams:this.control.layoutParams,fallback:B}),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 nt=()=>{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 st=r=>{if(r.type.trim().toLowerCase()==="button")return new Ft(r)},Ft=class extends Y{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(`${D}-${this.control.id}`),i.setAttribute("data-testid",ne.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:B}),tt({target:i,props:this.control.props,fallback:B}),rt({target:i,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),Je({target:i,props:this.control.props});let n=nt();et({target:n,props:this.control.props,fallback:B,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 ii=r=>{if(r.type.trim().toLowerCase()==="text")return new Bt(r)},Bt=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${D}-${this.control.id}`),i.setAttribute("data-testid",ne.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:B}),Je({target:i,props:this.control.props});let n=nt();et({target:n,props:this.control.props,fallback:B,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 qt=class{constructor(e){this.layout=e}},at=class extends qt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ge=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){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);if(s){let o=s(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ot=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Dt(r,e)},Dt=class extends ge{constructor(e,t){super(e),this.rootElement=t!=null?t:Xe(),this.layout=new at(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",st),this.addControlFactory("text",ii),this.addControlFactory("area",it)}createView(e){let t=document.createElement("div");return t.classList.add(`${D}-${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=`${Jr}`,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(`.${D}-${this.container.id}`)}};var aa=Ot(Er(),1),w=require("@vkontakte/videoplayer-shared"),Le=require("@vkontakte/videoplayer-statistics");var Es=require("@vkontakte/videoplayer-shared");function Oe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ae=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,je=r=>ae(r,"Object"),dt=r=>ae(r,"String"),ft=r=>ae(r,"Array"),mt=r=>ae(r,"Number"),vs=r=>ae(r,"Function");var Ir=r=>mt(r)&&!isNaN(r);var oe=r=>je(r)&&Object.keys(r).length===0,xr=r=>ft(r)&&!r.length;var Ne=(r,e)=>dt(r)&&(e?r.trim():r).length;var gs="video_interactive",bs="videoint";var Cs=250,$e=class{constructor(e){this.handleZoomChange=Oe(e=>{this.lastZoomInfo=e},Cs);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,!mt(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=Vl(e),this.resizeObserver=new ResizeObserver(Oe(this.onResize,Cs)),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 L(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 L(this,null,function*(){if(!this.manifest)return;let e;try{e=yield(0,Es.loadVKLangPack)(this.lang,gs,bs)}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 o=s,{name:i}=o,n=N(o,["name"]);var l;i==="openPreview"&&"chapterId"in n&&((l=this.onOpenPreviewClick)==null||l.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 Vl(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 Fe=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 o=s.startTime-e;if(o<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};var Z=(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 xs=require("uuid");var Ol="3.1",Is={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},jl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ts=r=>{let e=[];for(let o of r.chapters){let l,a=[];for(let t of o.branches){let i=t,{isDefault:y}=i,d=N(i,["isDefault"]);y&&(l=d.id),a.push(d)}let c=[],m=[];for(let n of o.containers){let s=n,{fallbackStrategy:y}=s,d=N(s,["fallbackStrategy"]);let E=!!d.endTime,x=[jl];switch(y){case"await":E?x=[]:c=[];break;case"default":{let M={type:"onSuspense",action:{type:Is.default,args:{branchId:l,shouldOpenNow:!E,isDetachContainer:!0}}};E?x=[M]:c=[M];break}case"random":case"weightlessRandom":case"max":case"min":{let M={type:"onSuspense",action:{type:Is[y],args:{}}};E?x=[M]:c=[M];break}}for(let M of d.controls)m.push(C(u({},d),{controls:[u({},M)],id:(0,xs.v4)(),events:x}))}e.push(C(u({},o),{containers:m,events:c,branches:a}))}return r.metadata.version=Ol,r.metadata.updated=new Date().toISOString(),C(u({},r),{chapters:e})};var Nl="3.2",Ss=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=N(e,["media"]);return C(u({},r),{metadata:C(u({},i),{version:Nl}),media:t})}return r};var $l="3.3",Fl=(r=[])=>({edit:{chapters:r},view:{}}),ws={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ls=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:o,x:l,y:a}=i,c=N(i,["id","x","y"]),m=c.containers.map(y=>{var d;return C(u({},y),{controls:y.controls.map(b=>{var p=b,{subtype:E,type:x}=p,M=N(p,["subtype","type"]);return C(u({},M),{type:E!=null?E:x})}),events:(d=y.events)!=null&&d.length?y.events:[ws]})});e.push(C(u({id:o},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[ws]})),t.push({id:o,x:l,y:a})}return C(u({},r),{chapters:e,graph:Fl(t),metadata:C(u({},r.metadata),{version:$l})})};var Bl=[{version:"3.0",migrate:Ts},{version:"3.1",migrate:Ss},{version:"3.2",migrate:Ls}],Tr=r=>Bl.reduce((e,t)=>Z(e.metadata.version,t.version)?e:t.migrate(e),r);var Ms={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 _s={metadata:"Object",chapters:"Array"},ql="3.0.0",Dl="3.3.0",Be=r=>{let e=Z(r,ql);return e===-1?!1:e===0?!0:Z(r,Dl)!==1},As=r=>{if(!je(r))return!1;for(let e in _s)if(!r[e]||!ae(r[e],_s[e]))return!1;return Be(r.metadata.version)},yt=r=>r.type===Ms.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 vt=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 gt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{vs(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 js=require("@vkontakte/videoplayer-shared");var bt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,t){return L(this,null,function*(){return Hl(...this.loaders[e])(t)})}};function Hl(...r){return function(t){return L(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function qe(r,e,t){return r?C(u({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Ct(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=N(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest(),l=r.getChapter(o.chapters,t);if(l){let a=r.getMedia(o.media,l.videoId),c=r.getGraph(o.graph,l.id);return a?C(u({},i),{actions:r,errors:e,result:{chapter:l,media:a,graph:c}}):C(u({},i),{errors:qe(e,Ct.name,"Could not find media"),actions:r})}}return C(u({},i),{errors:qe(e,Ct.name,"Could not find chapter"),actions:r})}var Et=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 o=i[n];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},xe=class extends Et{constructor(){super(),this.listeners||Et.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)}},De=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&&(De.prototype[Symbol.toStringTag]="AbortController",xe.prototype[Symbol.toStringTag]="AbortSignal");function It(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 Sr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!It({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 o=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(E){y=new Error("Aborted"),y.name="AbortError"}if(m.aborted)return Promise.reject(y);let d=new Promise((E,x)=>{m.addEventListener("abort",()=>x(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,o(a,c)])}return o(a,c)},Request:s}}var He=It({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Rs=He?Sr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,wr=He?Rs.fetch:window.fetch,Yh=He?Rs.Request:window.Request,Zh=He?De:window.AbortController,Xh=He?xe:window.AbortSignal;var Ul=r=>L(void 0,null,function*(){try{let e={},t;if(dt(r)){t=new URL(r).href;let n=yield wr(t);if(!n.ok)return{};e=yield n.json()}else if(je(r))e=r;else return{};if(!As(e))return{};let i=e.metadata.media;if(dt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield wr(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Wl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function ks(r){return L(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ul(r),i=Tr(e);return i.media=Gl(i.media,t),delete i.metadata.media,i})}function xt(r,e){if(e)return r.find(t=>t.id===e)}function Lr(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 Mr(r,e){return r.videos.find(t=>t.id===e)}function Gl(r,e){return C(u({},r),{videos:r.videos.map(t=>C(u({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=zl(n,e);return C(u({},i),{url:s||n})})}))})}function zl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Wl(r){return Z(r,"3.2.0")>=0}var Tt=r=>ft(r)&&!xr(r),W=r=>r.order==="end",Ue=r=>ft(r.containers)&&!xr(r.containers)&&W(r),Ps=(r,e)=>{var i;let t=r*1e3;return Tt(e.controls)&&t<((i=e.startTime)!=null?i:0)},_r=(r,e)=>{var i,n;let t=r*1e3;return Tt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var le=(r=[])=>r.some(e=>e.action.type==="expect"),Ar=(r=[])=>r.find(e=>e.action.type==="expect"),Ql=r=>(r==null?void 0:r.length)===1,ce=r=>Ql(r)&&yt(r[0]);function Vs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(u(u({},e[0]),t)):r(...e,...t)}var Os=(r,e)=>le(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&le(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var pe=class extends bt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new js.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 L(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:qe},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield ks((n=i.result)!=null?n:t),this})}setInitial(){return L(this,null,function*(){return this.setNext()})}setNext(){return L(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",Ct({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Lr,getChapter:xt,getMedia:Mr,getByBranches:this.getByBranches.bind(this),addErrorMessage:qe},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=xt(this.manifest.chapters,t);if(n){let s=Mr(this.manifest.media,n.videoId),o=Lr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let l=xt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.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?W(this.chapter):!1}};var $s=require("@vkontakte/videoplayer-core"),ie=require("@vkontakte/videoplayer-shared");var Ns=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 Rr(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=c,l=N(c,["listId","itemId"]);let m=r.get(s),y=u({},l);return m?m[o]=y:r.set(s,{[o]:y}),u({listId:s,itemId:o},l)}function t(s){var o,l;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(l=s.statistics)==null||l.statSubscription.unsubscribe()}function i(s,o){let l=r.get(s);if(!l)throw Error("Can't remove. Not find.");if(o){let a=l[o];a&&t(a),delete l[o],Object.keys(l).length||r.delete(s)}else{for(let a of Object.values(l))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 kr(r,e=[]){var s,o,l;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(u({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(u({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(u({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(u({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Ge=(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 Kl=2;function Pr(r){let e=Rr(),t=new ie.Subscription,i={},n=null,s=!1,o,l=new ie.ValueSubject(null);r&&a(r);function a(b){n=b}function c(b,p,h){var v;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((v=e.map.get(b))!=null?v:{})[p];if(T){i=u({chapterId:h,listId:b,itemId:p},T);let k=i.player;i.subscription.add(k.info.currentQuality$.subscribe(A=>{let q=k.info.position$.getValue(),P=k.info.isAutoQualityEnabled$.getValue();if(!(!A||!q||P))for(let O of e.map)Object.values(O[1]).forEach(({player:V})=>{Ge(V,A)})})).add(k.events.started$.subscribe(()=>{m(p)})),T.container.remove(),n.setPlayer(T.player),s||(n.init(),s=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function m(b){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(oe(i)||b!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let g of p)h.has(g.media.id)||(yield d({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),h.add(g.media.id))})}function y(h){return L(this,arguments,function*({chapter:{id:b},manifestVideo:p}){if(oe(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),k=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),q=!v,P=!1;for(let O of e.map)if(O[0]===p.id&&!n.state.isReplay$.getValue()){let V=Object.keys(O[1]);for(let F of V)F===i.itemId?(V.length<Kl||(P=!0),e.removePlayer(O[0],F)):(P=!0,c(O[0],F,b),q?Ge(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);P||(yield d({media:p,chapterId:b,setAsActive:!0,playbackRate:A}),q?Ge(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g))})}function d(q){return L(this,arguments,function*({media:b,chapterId:p,prefetch:h=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:v,title:k,playbackRate:A}){var Br,qr,Dr,Hr,Ur;let P=Math.random().toString(),O=document.createElement("div");o.append(O);let V;if((Br=n==null?void 0:n.options)!=null&&Br.vkVideoLoader){let Ye=Ns(b);Ye.length&&(V=yield n.options.vkVideoLoader(...Ye))}let F=((qr=n==null?void 0:n.options)==null?void 0:qr.coreConfig)||void 0,Me=C(u({},F),{configName:[...(Dr=F==null?void 0:F.configName)!=null?Dr:[],"interactive"]}),Ke=C(u({container:O},((Hr=V==null?void 0:V.videos)==null?void 0:Hr[0])||{sources:kr(b,v).sources}),{title:k,failoverHosts:(V==null?void 0:V.failoverHosts)||[]}),me=new $s.Player(Me,ie.Tracer.createRootTracer());me.initVideo(Ke);let $r=null;if(V!=null&&V.videos&&(n!=null&&n.options.createOneStat)){let Ye=V.videos[0],Pt=n.options.createOneStat(Ye),Gr=new ie.Subscription;Pt&&(Gr.add(Pt.attachTo(me)),$r={oneStat:Pt,statSubscription:Gr})}let Fr=new ie.Subscription,la=(Ur=i==null?void 0:i.player)==null?void 0:Ur.info.isAutoQualityEnabled$.getValue();Fr.add(me.events.canplay$.subscribe(function(){la||Ge(me,i.player.info.currentQuality$.getValue()),A&&me.setPlaybackRate(A)}));let ye=e.createPlayer({listId:b.id,itemId:P,player:me,container:O,sources:kr(b,v).sources,config:Ke,subscription:Fr,statistics:$r});return g&&c(b.id,ye.itemId,p),T&&ye.player.play(),h&&!T&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}})}function E(){x(),n=null,o.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function M(){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),o=document.createElement("div");let{media:b,chapter:p}=n.getCurrentChapter();b&&p?(t.add(n.events.chapterChanged$.subscribe(y)),yield d({media:b,chapterId:p.id,title:p.label})):console.error("not found")})}return C(u({},e),{init:M,setInteractiveController:a,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:l})}var I={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 Fs=require("@vkontakte/videoplayer-shared");var St=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:m,onRemove:y}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(le(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(I.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(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let o=Vs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(l,a)=>{this.isSelectedControlEvent=!0,l!==!1&&(this.removeView(),this.globalEventEmitter.emit(I.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(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(o),this.globalEventEmitter.emit(I.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 c;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(Ps(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(_r(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let m=this.gameState;this.gameState=3,m===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=_r(s,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(I.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Fs.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&ce(t.container.controls),this.disabledControls$=m,this.onRemove=y,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,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=le(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(I.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(I.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 Bs=(r=[])=>r.reduce((e,t,i)=>{var s,o,l;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!yt(a));if(Tt(n)){let a=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],y=-1/0,d=1/0,E=[],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]>y&&(y=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),E=E.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[1]=b.range[1])}if(x.push(c),a[0]<=d&&a[1]>=y)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(M=>{e.splice(M,1)}),e.push({subjects:E.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function qs(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let a={};for(let c in r)+c<=l&&(a[c]=r[c]);return a}function i(l){let a={};for(let c in r)+c>=l&&(a[c]=r[c]);return a}function n({timestamp:l,priority:a,initiator:c}){var m;if(Ir(l)){let y=(m=r[l])!=null?m:null;if(y&&a&&Ne(a,!0)){let d={},E=y[a];if(E&&(d=u(u({},d),E)),d=oe(d)?null:d,d&&Ne(c,!0)){let x=d[c];return x!=null?x:null}return d}return y}return null}function s({timestamp:l,priority:a,initiator:c}){if(Ir(l))if(r[l]){if(a&&Ne(a,!0))if(r[l][a]){if(c&&Ne(c,!0))if(r[l][a][c]){if(delete r[l][a][c],!oe(r[l][a]))return!0}else return!1;if(delete r[l][a],!oe(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o(y){var d=y,{timestamp:l,priority:a,initiator:c}=d,m=N(d,["timestamp","priority","initiator"]);var E,x,M;(x=(E=r[l])==null?void 0:E[a])!=null&&x[c]?r[l][a][c].push(u({},m)):(M=r[l])!=null&&M[a]?r[l][a]=C(u({},r[l][a]),{[c]:[u({},m)]}):r[l]?r[l]=C(u({},r[l]),{[a]:{[c]:[u({},m)]}}):r[l]={[a]:{[c]:[u({},m)]}}}return{map:r,remove:s,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var Yl=[R.expect,R.setNextBranch],Zl=1/0;function Ds(r){let e=r,t,i=Xl(),n=qs(),s,o=()=>{d(),p()},l=h=>{n.add.call(void 0,h),x()},a=(h=[])=>{for(let g of h)if(g.action(),Yl.includes(g.actionType))break},c=(h=1/0)=>{var k,A,q;let g=wt((k=n.get({timestamp:h,priority:"control"}))!=null?k:{}),T=wt((A=n.get({timestamp:h,priority:"container"}))!=null?A:{}),v=wt((q=n.get({timestamp:h,priority:"chapter"}))!=null?q:{});return[...g,...T,...v]},m=h=>{i.isReady(h)&&a(c(h))},y=()=>{var h;a([...wt((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},E=h=>{},x=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},M=h=>{d(),e=h},b=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},p=()=>{i.release(),n.removeAll()};return{setPlayer:M,add:l,remove:b,exec:m,execEndOfVideo:y,listen:x,unlisten:d,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function Xl(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let a=r.get(o);a&&a[l]!==void 0&&(a[l]=!0)},setData:(o=[])=>{var l,a;for(let c of o){let m=(l=c.endTime)!=null?l:Zl,y=(a=r.get(m))!=null?a:{};r.set(m,C(u({},y),{[c.id]:!1}))}},resetCalled:o=>{let l=r.get(o);if(l)for(let a in l)l[a]=!1},isReady:o=>{let l=r.get(o);return l?!Object.values(l).some(a=>!a):!0},release:()=>r.clear()}}function wt(r){return Object.values(r).flat().sort(e=>e.actionType===R.expect?-1:1)}var Hs={videoContentHeight:0,videoContentWidth:0},Us=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Hs;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Hs;let o=t/i,l=n/s,a,c;return l>o?(c=s,a=s*o):l<o?(c=n/o,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var Jl=250;function Gs(r){let e=()=>{},t=new ResizeObserver(l=>{s(l),e=s.bind(null,l)});function i(l){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:y}=Us(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let s=Oe(l=>{let{fns:a=[]}=r();i(l);for(let c of a)c()},Jl);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var ze=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 ec=r=>Math.floor(Math.random()*r),Ws=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],o=(n=s.weight)!=null?n:1;o<t&&(t=o,i=s)}return i},Qs=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],o=(n=s.weight)!=null?n:0;o>t&&(t=o,i=s)}return i};var Ks=r=>{let e=r.length,t=ec(e);return r[t]},zs=1,Ys=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:zs;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:zs,e>=t)return r[s];return r[r.length-1]};var Zs={shouldOpenNow:!0,isDetachContainer:!0};var Vr=(r,e=!1)=>C(u({},r),{args:e?u(u({},r.args),Zs):u(u({},Zs),r.args)}),ea=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:p,controlType:h,controlId:g,containerId:T,branches:v=[],onEvent:k,isEOV:A=()=>!1,isDisabled:q=()=>!1})=>{let P=Vr(p,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},V=q(),F=r.emit.bind(r,I.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:V?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:u({containerId:T},P.args)});if(V){F();return}switch(P.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let Me=v.find(Ke=>Ke.id===P.args.branchId);if(!Me)return;k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Me.chapterId,autoSelect:!1}}):(t.add(C(u({},O),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Me.chapterId,autoSelect:!1}})})),i==null||i());return}case R.continuePlayback.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:h,action:p}):t.add(C(u({},O),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:p})}));return}case R.openURI.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}}):(t.add(C(u({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(I.errors,new $(1,1,{message:"Unexpected control event"}));return}},l=({action:p,container:{id:h,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:k=!1})=>{let A=Vr(p,v),q={timestamp:!A.args.shouldOpenNow||v?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:A.type},P=r.emit.bind(r,I.interactives,{subjectId:h,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;P(),t.add(C(u({},q),{action:x.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:k}})})),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():{P(),t.add(C(u({},q),{action:E.bind(null,{subjectId:h,subjectName:"container",action:A})}));return}case R.openURI.trim().toLowerCase():{P(),t.add(C(u({},q),{action:b.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(I.errors,new $(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:h,isEOV:g=!1}){var v,k;let T=Ar(p.events);if(T){let A=Vr(T.action,g);r.emit(I.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(v=p.endTime)!=null?v:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(k=p.events)!=null?k:[])l({action:A.action,container:p,branches:h,isEOV:g})}let c=({chapterId:p,action:h,branches:g=[]})=>{let T=r.emit.bind(r,I.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:h.type,payload:h.args});switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let v=g.find(k=>k.id===h.args.branchId);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let v=Ks(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let v=Ys(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let v=Qs(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let v=Ws(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:console.error("Unexpected chapter event"),r.emit(I.errors,new $(1,1,{message:"Unexpected chapter event"}));return}};function m(p){var g;let h=Ar(p.events);if(h){if(W(p))return;r.emit(I.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:h.action.type,payload:h.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(g=p.events)==null||g.forEach(T=>{let v=c({chapterId:p.id,action:T.action,branches:p.branches});v&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:T.action.type,action:v})})}let y=({subjectId:p,subjectName:h})=>{e.pause(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:R.expect})},d=({subjectId:p,subjectName:h})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:"after-expect"})},E=({subjectId:p,subjectName:h,subjectType:g,action:T})=>{r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},M=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},b=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let k=window.open(v.URI,"_blank","noopener,noreferrer");k&&(k.opener=null),r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:y,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var Nr=Ot(Er(),1),G=require("@vkontakte/videoplayer-shared");var Lt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(o=>o.id===i);if(!n)return null;let s=e.media.videos.find(o=>n.videoId===o.id);if(!s)return null;t[i]=Or(s)}return t[i]}).filter(Boolean)},ta=r=>{for(let e of r.variants)if(ra(e)&&"payload"in e)return e.payload.id},ra=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",Or=r=>{let e=ta(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},ia=(r,e)=>{for(let t of r.media.videos)if(e===Or(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},jr=(r,e)=>r.reduce((t,i)=>{let n=ia(e,i);return n?[...t,n]:t},[]);var X,he,ue,U,Mt,J,ee,K,de,Se,we,We=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new G.ValueSubject([]),hasPrevChapter$:new G.ValueSubject(!1),prevChapter$:new G.ValueSubject(null),isInitialChapter$:new G.ValueSubject(!1),isGoBackLimited$:new G.ValueSubject(!1)};H(this,X,null);H(this,he);H(this,ue,!1);H(this,U,null);H(this,Mt,null);this.events={inited$:new G.Subject,destroyed$:new G.Subject,error$:new G.Subject};H(this,J,null);H(this,ee,null);H(this,K,null);H(this,de,new G.Subscription);H(this,Se,!1);H(this,we,0);var o;j(this,J,t),j(this,K,e),j(this,ee,i),j(this,X,n),j(this,he,s),this.state.history$&&S(this,de)&&((o=S(this,de))==null||o.add(this.state.history$.subscribe(l=>{var a,c;this.state.prevChapter$.next((0,Nr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.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,he).maxLength-1)})))}setManifest(e){return L(this,null,function*(){if(!S(this,ee)||!S(this,K))return;j(this,U,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield S(this,ee).setChapter({chapterId:t,pushToHistory:!1}),S(this,ue)||(j(this,ue,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return S(this,ue)}updateHistory(e,t=!0){return L(this,null,function*(){var l;if(!S(this,U))return;S(this,Se)?(j(this,Se,!1),Zr(this,we)._++):j(this,we,0);let i=S(this,U),n=e.length-S(this,he).maxLength,s=n>0?e.slice(n):e,o=Lt(s,i);if(j(this,Mt,o),this.state.history$.next(s),!(!t||!S(this,X)||!S(this,J)))try{yield S(this,X).save(S(this,J),o)}catch(a){let c=new $(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=S(this,K))==null||l.emit(I.errors,c)}})}goBack(){return L(this,null,function*(){var i;if(!this.state||!S(this,ee)){let n=new $(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,K))==null?void 0:i.emit(I.errors,n)}j(this,Se,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,ee).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return L(this,null,function*(){var n;if(!S(this,U)||!S(this,J))return;let e=S(this,U),t=[this.getInitialVideoId()];if(S(this,X))try{let s=yield S(this,X).get(S(this,J));s.length&&(t=s)}catch(s){let o=new $(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=S(this,K))==null||n.emit(I.errors,o)}let i=jr(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Nr.default)(e,-1)||S(this,he).initChapterId||((t=S(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,U)){let e=this.getInitialChapterId();return Lt([e],S(this,U)).pop()}return null}destroy(){var e,t;j(this,J,null),j(this,X,null),j(this,ee,null),(e=S(this,de))==null||e.unsubscribe(),j(this,de,null),j(this,ue,!1),(t=S(this,K))==null||t.emit(I.historyDestroyed),this.events.destroyed$.next(),j(this,K,null)}};X=new WeakMap,he=new WeakMap,ue=new WeakMap,U=new WeakMap,Mt=new WeakMap,J=new WeakMap,ee=new WeakMap,K=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(o=>!i.has(o));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 _t=fe;var At=class{constructor(){this.bindingMap=new ze}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new _t(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=o=>{this.unlisten(e,t,s),i(o)};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 Rt=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 L(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 L(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 kt=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 ca=Object.create;var _e=Object.defineProperty,pa=Object.defineProperties,ha=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertyDescriptors,da=Object.getOwnPropertyNames,Ze=Object.getOwnPropertySymbols,fa=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty,Wr=Object.prototype.propertyIsEnumerable;var Qr=r=>{throw TypeError(r)};var zr=(r,e,t)=>e in r?_e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))Vt.call(e,t)&&zr(r,t,e[t]);if(Ze)for(var t of Ze(e))Wr.call(e,t)&&zr(r,t,e[t]);return r},C=(r,e)=>pa(r,ua(e));var N=(r,e)=>{var t={};for(var i in r)Vt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Ze)for(var i of Ze(r))e.indexOf(i)<0&&Wr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ma=(r,e)=>{for(var t in e)_e(r,t,{get:e[t],enumerable:!0})},Kr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of da(e))!Vt.call(r,n)&&n!==t&&_e(r,n,{get:()=>e[n],enumerable:!(i=ha(e,n))||i.enumerable});return r};var Ot=(r,e,t)=>(t=r!=null?ca(fa(r)):{},Kr(e||!r||!r.__esModule?_e(t,"default",{value:r,enumerable:!0}):t,r)),ya=r=>Kr(_e({},"__esModule",{value:!0}),r);var Yr=(r,e,t)=>e.has(r)||Qr("Cannot "+t);var S=(r,e,t)=>(Yr(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?Qr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,i)=>(Yr(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Zr=(r,e,t,i)=>({set _(n){j(r,e,n,t)},get _(){return S(r,e,i)}});var L=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{l(t.next(a))}catch(c){n(c)}},o=a=>{try{l(t.throw(a))}catch(c){n(c)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,o);l((t=t.apply(r,e)).next())});var Q=f((Ht,ni)=>{"use strict";var Ae=function(r){return r&&r.Math===Math&&r};ni.exports=Ae(typeof globalThis=="object"&&globalThis)||Ae(typeof window=="object"&&window)||Ae(typeof self=="object"&&self)||Ae(typeof global=="object"&&global)||Ae(typeof Ht=="object"&&Ht)||function(){return this}()||Function("return this")()});var te=f((zc,si)=>{"use strict";si.exports=function(r){try{return!!r()}catch(e){return!0}}});var Re=f((Wc,ai)=>{"use strict";var ga=te();ai.exports=!ga(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var hi=f((Qc,pi)=>{"use strict";var ba=Re(),ci=Function.prototype,oi=ci.apply,li=ci.call;pi.exports=typeof Reflect=="object"&&Reflect.apply||(ba?li.bind(oi):function(){return li.apply(oi,arguments)})});var se=f((Kc,fi)=>{"use strict";var ui=Re(),di=Function.prototype,Ut=di.call,Ca=ui&&di.bind.bind(Ut,Ut);fi.exports=ui?Ca:function(r){return function(){return Ut.apply(r,arguments)}}});var Gt=f((Yc,yi)=>{"use strict";var mi=se(),Ea=mi({}.toString),Ia=mi("".slice);yi.exports=function(r){return Ia(Ea(r),8,-1)}});var zt=f((Zc,vi)=>{"use strict";var xa=Gt(),Ta=se();vi.exports=function(r){if(xa(r)==="Function")return Ta(r)}});var re=f((Xc,gi)=>{"use strict";var Wt=typeof document=="object"&&document.all;gi.exports=typeof Wt=="undefined"&&Wt!==void 0?function(r){return typeof r=="function"||r===Wt}:function(r){return typeof r=="function"}});var be=f((Jc,bi)=>{"use strict";var Sa=te();bi.exports=!Sa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ct=f((ep,Ci)=>{"use strict";var wa=Re(),lt=Function.prototype.call;Ci.exports=wa?lt.bind(lt):function(){return lt.apply(lt,arguments)}});var Ti=f(xi=>{"use strict";var Ei={}.propertyIsEnumerable,Ii=Object.getOwnPropertyDescriptor,La=Ii&&!Ei.call({1:2},1);xi.f=La?function(e){var t=Ii(this,e);return!!t&&t.enumerable}:Ei});var Qt=f((rp,Si)=>{"use strict";Si.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Li=f((ip,wi)=>{"use strict";var Ma=se(),_a=te(),Aa=Gt(),Kt=Object,Ra=Ma("".split);wi.exports=_a(function(){return!Kt("z").propertyIsEnumerable(0)})?function(r){return Aa(r)==="String"?Ra(r,""):Kt(r)}:Kt});var Yt=f((np,Mi)=>{"use strict";Mi.exports=function(r){return r==null}});var Zt=f((sp,_i)=>{"use strict";var ka=Yt(),Pa=TypeError;_i.exports=function(r){if(ka(r))throw new Pa("Can't call method on "+r);return r}});var Ri=f((ap,Ai)=>{"use strict";var Va=Li(),Oa=Zt();Ai.exports=function(r){return Va(Oa(r))}});var ke=f((op,ki)=>{"use strict";var ja=re();ki.exports=function(r){return typeof r=="object"?r!==null:ja(r)}});var Xt=f((lp,Pi)=>{"use strict";Pi.exports={}});var tr=f((cp,Oi)=>{"use strict";var Jt=Xt(),er=Q(),Na=re(),Vi=function(r){return Na(r)?r:void 0};Oi.exports=function(r,e){return arguments.length<2?Vi(Jt[r])||Vi(er[r]):Jt[r]&&Jt[r][e]||er[r]&&er[r][e]}});var Ni=f((pp,ji)=>{"use strict";var $a=se();ji.exports=$a({}.isPrototypeOf)});var qi=f((hp,Bi)=>{"use strict";var Fa=Q(),$i=Fa.navigator,Fi=$i&&$i.userAgent;Bi.exports=Fi?String(Fi):""});var Qi=f((up,Wi)=>{"use strict";var zi=Q(),rr=qi(),Di=zi.process,Hi=zi.Deno,Ui=Di&&Di.versions||Hi&&Hi.version,Gi=Ui&&Ui.v8,z,pt;Gi&&(z=Gi.split("."),pt=z[0]>0&&z[0]<4?1:+(z[0]+z[1]));!pt&&rr&&(z=rr.match(/Edge\/(\d+)/),(!z||z[1]>=74)&&(z=rr.match(/Chrome\/(\d+)/),z&&(pt=+z[1])));Wi.exports=pt});var ir=f((dp,Yi)=>{"use strict";var Ki=Qi(),Ba=te(),qa=Q(),Da=qa.String;Yi.exports=!!Object.getOwnPropertySymbols&&!Ba(function(){var r=Symbol("symbol detection");return!Da(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ki&&Ki<41})});var nr=f((fp,Zi)=>{"use strict";var Ha=ir();Zi.exports=Ha&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var sr=f((mp,Xi)=>{"use strict";var Ua=tr(),Ga=re(),za=Ni(),Wa=nr(),Qa=Object;Xi.exports=Wa?function(r){return typeof r=="symbol"}:function(r){var e=Ua("Symbol");return Ga(e)&&za(e.prototype,Qa(r))}});var en=f((yp,Ji)=>{"use strict";var Ka=String;Ji.exports=function(r){try{return Ka(r)}catch(e){return"Object"}}});var ar=f((vp,tn)=>{"use strict";var Ya=re(),Za=en(),Xa=TypeError;tn.exports=function(r){if(Ya(r))return r;throw new Xa(Za(r)+" is not a function")}});var nn=f((gp,rn)=>{"use strict";var Ja=ar(),eo=Yt();rn.exports=function(r,e){var t=r[e];return eo(t)?void 0:Ja(t)}});var an=f((bp,sn)=>{"use strict";var or=ct(),lr=re(),cr=ke(),to=TypeError;sn.exports=function(r,e){var t,i;if(e==="string"&&lr(t=r.toString)&&!cr(i=or(t,r))||lr(t=r.valueOf)&&!cr(i=or(t,r))||e!=="string"&&lr(t=r.toString)&&!cr(i=or(t,r)))return i;throw new to("Can't convert object to primitive value")}});var ln=f((Cp,on)=>{"use strict";on.exports=!0});var hn=f((Ep,pn)=>{"use strict";var cn=Q(),ro=Object.defineProperty;pn.exports=function(r,e){try{ro(cn,r,{value:e,configurable:!0,writable:!0})}catch(t){cn[r]=e}return e}});var pr=f((Ip,fn)=>{"use strict";var io=ln(),no=Q(),so=hn(),un="__core-js_shared__",dn=fn.exports=no[un]||so(un,{});(dn.versions||(dn.versions=[])).push({version:"3.38.0",mode:io?"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 vn=f((xp,yn)=>{"use strict";var mn=pr();yn.exports=function(r,e){return mn[r]||(mn[r]=e||{})}});var hr=f((Tp,gn)=>{"use strict";var ao=Zt(),oo=Object;gn.exports=function(r){return oo(ao(r))}});var ht=f((Sp,bn)=>{"use strict";var lo=se(),co=hr(),po=lo({}.hasOwnProperty);bn.exports=Object.hasOwn||function(e,t){return po(co(e),t)}});var En=f((wp,Cn)=>{"use strict";var ho=se(),uo=0,fo=Math.random(),mo=ho(1 .toString);Cn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+mo(++uo+fo,36)}});var Tn=f((Lp,xn)=>{"use strict";var yo=Q(),vo=vn(),In=ht(),go=En(),bo=ir(),Co=nr(),Ce=yo.Symbol,ur=vo("wks"),Eo=Co?Ce.for||Ce:Ce&&Ce.withoutSetter||go;xn.exports=function(r){return In(ur,r)||(ur[r]=bo&&In(Ce,r)?Ce[r]:Eo("Symbol."+r)),ur[r]}});var Mn=f((Mp,Ln)=>{"use strict";var Io=ct(),Sn=ke(),wn=sr(),xo=nn(),To=an(),So=Tn(),wo=TypeError,Lo=So("toPrimitive");Ln.exports=function(r,e){if(!Sn(r)||wn(r))return r;var t=xo(r,Lo),i;if(t){if(e===void 0&&(e="default"),i=Io(t,r,e),!Sn(i)||wn(i))return i;throw new wo("Can't convert object to primitive value")}return e===void 0&&(e="number"),To(r,e)}});var dr=f((_p,_n)=>{"use strict";var Mo=Mn(),_o=sr();_n.exports=function(r){var e=Mo(r,"string");return _o(e)?e:e+""}});var kn=f((Ap,Rn)=>{"use strict";var Ao=Q(),An=ke(),fr=Ao.document,Ro=An(fr)&&An(fr.createElement);Rn.exports=function(r){return Ro?fr.createElement(r):{}}});var mr=f((Rp,Pn)=>{"use strict";var ko=be(),Po=te(),Vo=kn();Pn.exports=!ko&&!Po(function(){return Object.defineProperty(Vo("div"),"a",{get:function(){return 7}}).a!==7})});var jn=f(On=>{"use strict";var Oo=be(),jo=ct(),No=Ti(),$o=Qt(),Fo=Ri(),Bo=dr(),qo=ht(),Do=mr(),Vn=Object.getOwnPropertyDescriptor;On.f=Oo?Vn:function(e,t){if(e=Fo(e),t=Bo(t),Do)try{return Vn(e,t)}catch(i){}if(qo(e,t))return $o(!jo(No.f,e,t),e[t])}});var $n=f((Pp,Nn)=>{"use strict";var Ho=te(),Uo=re(),Go=/#|\.prototype\./,Pe=function(r,e){var t=Wo[zo(r)];return t===Ko?!0:t===Qo?!1:Uo(e)?Ho(e):!!e},zo=Pe.normalize=function(r){return String(r).replace(Go,".").toLowerCase()},Wo=Pe.data={},Qo=Pe.NATIVE="N",Ko=Pe.POLYFILL="P";Nn.exports=Pe});var qn=f((Vp,Bn)=>{"use strict";var Fn=zt(),Yo=ar(),Zo=Re(),Xo=Fn(Fn.bind);Bn.exports=function(r,e){return Yo(r),e===void 0?r:Zo?Xo(r,e):function(){return r.apply(e,arguments)}}});var Hn=f((Op,Dn)=>{"use strict";var Jo=be(),el=te();Dn.exports=Jo&&el(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Gn=f((jp,Un)=>{"use strict";var tl=ke(),rl=String,il=TypeError;Un.exports=function(r){if(tl(r))return r;throw new il(rl(r)+" is not an object")}});var Qn=f(Wn=>{"use strict";var nl=be(),sl=mr(),al=Hn(),ut=Gn(),zn=dr(),ol=TypeError,yr=Object.defineProperty,ll=Object.getOwnPropertyDescriptor,vr="enumerable",gr="configurable",br="writable";Wn.f=nl?al?function(e,t,i){if(ut(e),t=zn(t),ut(i),typeof e=="function"&&t==="prototype"&&"value"in i&&br in i&&!i[br]){var n=ll(e,t);n&&n[br]&&(e[t]=i.value,i={configurable:gr in i?i[gr]:n[gr],enumerable:vr in i?i[vr]:n[vr],writable:!1})}return yr(e,t,i)}:yr:function(e,t,i){if(ut(e),t=zn(t),ut(i),sl)try{return yr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new ol("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Yn=f(($p,Kn)=>{"use strict";var cl=be(),pl=Qn(),hl=Qt();Kn.exports=cl?function(r,e,t){return pl.f(r,e,hl(1,t))}:function(r,e,t){return r[e]=t,r}});var Jn=f((Fp,Xn)=>{"use strict";var Ve=Q(),ul=hi(),dl=zt(),fl=re(),ml=jn().f,yl=$n(),Ee=Xt(),vl=qn(),Ie=Yn(),Zn=ht();pr();var gl=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 ul(r,this,arguments)};return e.prototype=r.prototype,e};Xn.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,o=i?Ve:n?Ve[t]:Ve[t]&&Ve[t].prototype,l=i?Ee:Ee[t]||Ie(Ee,t,{})[t],a=l.prototype,c,m,y,d,E,x,M,b,p;for(d in e)c=yl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&o&&Zn(o,d),x=l[d],m&&(r.dontCallGetSet?(p=ml(o,d),M=p&&p.value):M=o[d]),E=m&&M?M:e[d],!(!c&&!s&&typeof x==typeof E)&&(r.bind&&m?b=vl(E,Ve):r.wrap&&m?b=gl(E):s&&fl(E)?b=dl(E):b=E,(r.sham||E&&E.sham||x&&x.sham)&&Ie(b,"sham",!0),Ie(l,d,b),s&&(y=t+"Prototype",Zn(Ee,y)||Ie(Ee,y,{}),Ie(Ee[y],d,E),r.real&&a&&(c||!a[d])&&Ie(a,d,E)))}});var ts=f((Bp,es)=>{"use strict";var bl=Math.ceil,Cl=Math.floor;es.exports=Math.trunc||function(e){var t=+e;return(t>0?Cl:bl)(t)}});var Cr=f((qp,rs)=>{"use strict";var El=ts();rs.exports=function(r){var e=+r;return e!==e||e===0?0:El(e)}});var ns=f((Dp,is)=>{"use strict";var Il=Cr(),xl=Math.min;is.exports=function(r){var e=Il(r);return e>0?xl(e,9007199254740991):0}});var as=f((Hp,ss)=>{"use strict";var Tl=ns();ss.exports=function(r){return Tl(r.length)}});var ls=f((Up,os)=>{"use strict";os.exports=function(){}});var cs=f(()=>{"use strict";var Sl=Jn(),wl=hr(),Ll=as(),Ml=Cr(),_l=ls();Sl({target:"Array",proto:!0},{at:function(e){var t=wl(this),i=Ll(t),n=Ml(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});_l("at")});var hs=f((Wp,ps)=>{"use strict";var Al=tr();ps.exports=Al});var ds=f((Qp,us)=>{"use strict";cs();var Rl=hs();us.exports=Rl("Array","at")});var ms=f((Kp,fs)=>{"use strict";var kl=ds();fs.exports=kl});var Er=f((Yp,ys)=>{"use strict";var Pl=ms();ys.exports=Pl});var nc={};ma(nc,{CustomError:()=>$,EVENT_NAMES:()=>I,Interactives:()=>Qe,ManifestController:()=>pe,SDKInfo:()=>ic,chapterIdsToVKVideoIds:()=>Lt,compareVersions:()=>Z,getChapterIdByVkVideoId:()=>ia,getVKVideoIdByMedia:()=>Or,getVideoRawIdByMedia:()=>ta,graphEventTypes:()=>Te,hasEndTemplate:()=>Ue,interactivesEventTypes:()=>_,isLastChapter:()=>W,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>Be,isVKVariantItem:()=>ra,utils:()=>oa,vkVideoIdsToChapterIds:()=>jr});module.exports=ya(nc);var Xr="1.0.26-dev.ac7b329a.0";function jt(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 D="interactive",va="interactive-controls-container",Xe=()=>document.querySelector(`.${va}`),Jr=.4,B={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ei=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ei||{}),ti=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ti||{}),ri=(i=>(i.start="left",i.end="right",i.center="center",i))(ri||{}),Je=({target:r,props:e})=>{var t,i,n,s,o,l;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&ei[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&ti[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(l=((o=e.text)==null?void 0:o.alignment)&&ri[e.text.alignment])!=null?l:"left"},et=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,o,l,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} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},tt=({target:r,props:e,fallback:t})=>{var i,n,s,o;r.style.backgroundColor=jt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?o:t.backgroundAlpha)},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,o,l,a,c,m,y,d,E,x;r.style.border=`calc(${i.height} * ${(o=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?o:t.borderWidth}) solid ${jt((c=(a=(l=e==null?void 0:e.shape)==null?void 0:l.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} * ${(x=(E=e==null?void 0:e.shape)==null?void 0:E.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 Y=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(`${D}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:B.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 Nt="int",ne=(i=>(i.AREA=`${Nt}_area`,i.TEXT=`${Nt}_text`,i.BUTTON=`${Nt}_bttn`,i))(ne||{});var it=r=>{if(r.type.trim().toLowerCase()==="area")return new $t(r)},$t=class extends Y{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(`${D}-${this.control.id}`),i.setAttribute("data-testid",ne.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",tt({target:i,props:this.control.props,fallback:C(u({},B),{backgroundColor:"transparent"})}),rt({target:i,props:this.control.props,fallback:C(u({},B),{borderAlpha:0}),dependsOn:this.container.dimensions}),ve({target:i,layoutParams:this.control.layoutParams,fallback:B}),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 nt=()=>{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 st=r=>{if(r.type.trim().toLowerCase()==="button")return new Ft(r)},Ft=class extends Y{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(`${D}-${this.control.id}`),i.setAttribute("data-testid",ne.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:B}),tt({target:i,props:this.control.props,fallback:B}),rt({target:i,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),Je({target:i,props:this.control.props});let n=nt();et({target:n,props:this.control.props,fallback:B,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 ii=r=>{if(r.type.trim().toLowerCase()==="text")return new Bt(r)},Bt=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${D}-${this.control.id}`),i.setAttribute("data-testid",ne.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:B}),Je({target:i,props:this.control.props});let n=nt();et({target:n,props:this.control.props,fallback:B,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 qt=class{constructor(e){this.layout=e}},at=class extends qt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ge=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){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);if(s){let o=s(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ot=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Dt(r,e)},Dt=class extends ge{constructor(e,t){super(e),this.rootElement=t!=null?t:Xe(),this.layout=new at(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",st),this.addControlFactory("text",ii),this.addControlFactory("area",it)}createView(e){let t=document.createElement("div");return t.classList.add(`${D}-${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=`${Jr}`,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(`.${D}-${this.container.id}`)}};var aa=Ot(Er(),1),w=require("@vkontakte/videoplayer-shared"),Le=require("@vkontakte/videoplayer-statistics");var Es=require("@vkontakte/videoplayer-shared");function Oe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ae=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,je=r=>ae(r,"Object"),dt=r=>ae(r,"String"),ft=r=>ae(r,"Array"),mt=r=>ae(r,"Number"),vs=r=>ae(r,"Function");var Ir=r=>mt(r)&&!isNaN(r);var oe=r=>je(r)&&Object.keys(r).length===0,xr=r=>ft(r)&&!r.length;var Ne=(r,e)=>dt(r)&&(e?r.trim():r).length;var gs="video_interactive",bs="videoint";var Cs=250,$e=class{constructor(e){this.handleZoomChange=Oe(e=>{this.lastZoomInfo=e},Cs);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,!mt(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=Vl(e),this.resizeObserver=new ResizeObserver(Oe(this.onResize,Cs)),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 L(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 L(this,null,function*(){if(!this.manifest)return;let e;try{e=yield(0,Es.loadVKLangPack)(this.lang,gs,bs)}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 o=s,{name:i}=o,n=N(o,["name"]);var l;i==="openPreview"&&"chapterId"in n&&((l=this.onOpenPreviewClick)==null||l.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 Vl(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 Fe=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 o=s.startTime-e;if(o<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};var Z=(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 xs=require("uuid");var Ol="3.1",Is={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},jl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ts=r=>{let e=[];for(let o of r.chapters){let l,a=[];for(let t of o.branches){let i=t,{isDefault:y}=i,d=N(i,["isDefault"]);y&&(l=d.id),a.push(d)}let c=[],m=[];for(let n of o.containers){let s=n,{fallbackStrategy:y}=s,d=N(s,["fallbackStrategy"]);let E=!!d.endTime,x=[jl];switch(y){case"await":E?x=[]:c=[];break;case"default":{let M={type:"onSuspense",action:{type:Is.default,args:{branchId:l,shouldOpenNow:!E,isDetachContainer:!0}}};E?x=[M]:c=[M];break}case"random":case"weightlessRandom":case"max":case"min":{let M={type:"onSuspense",action:{type:Is[y],args:{}}};E?x=[M]:c=[M];break}}for(let M of d.controls)m.push(C(u({},d),{controls:[u({},M)],id:(0,xs.v4)(),events:x}))}e.push(C(u({},o),{containers:m,events:c,branches:a}))}return r.metadata.version=Ol,r.metadata.updated=new Date().toISOString(),C(u({},r),{chapters:e})};var Nl="3.2",Ss=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=N(e,["media"]);return C(u({},r),{metadata:C(u({},i),{version:Nl}),media:t})}return r};var $l="3.3",Fl=(r=[])=>({edit:{chapters:r},view:{}}),ws={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ls=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:o,x:l,y:a}=i,c=N(i,["id","x","y"]),m=c.containers.map(y=>{var d;return C(u({},y),{controls:y.controls.map(b=>{var p=b,{subtype:E,type:x}=p,M=N(p,["subtype","type"]);return C(u({},M),{type:E!=null?E:x})}),events:(d=y.events)!=null&&d.length?y.events:[ws]})});e.push(C(u({id:o},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[ws]})),t.push({id:o,x:l,y:a})}return C(u({},r),{chapters:e,graph:Fl(t),metadata:C(u({},r.metadata),{version:$l})})};var Bl=[{version:"3.0",migrate:Ts},{version:"3.1",migrate:Ss},{version:"3.2",migrate:Ls}],Tr=r=>Bl.reduce((e,t)=>Z(e.metadata.version,t.version)?e:t.migrate(e),r);var Ms={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 _s={metadata:"Object",chapters:"Array"},ql="3.0.0",Dl="3.3.0",Be=r=>{let e=Z(r,ql);return e===-1?!1:e===0?!0:Z(r,Dl)!==1},As=r=>{if(!je(r))return!1;for(let e in _s)if(!r[e]||!ae(r[e],_s[e]))return!1;return Be(r.metadata.version)},yt=r=>r.type===Ms.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 vt=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 gt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{vs(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 js=require("@vkontakte/videoplayer-shared");var bt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,t){return L(this,null,function*(){return Hl(...this.loaders[e])(t)})}};function Hl(...r){return function(t){return L(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function qe(r,e,t){return r?C(u({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Ct(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=N(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest(),l=r.getChapter(o.chapters,t);if(l){let a=r.getMedia(o.media,l.videoId),c=r.getGraph(o.graph,l.id);return a?C(u({},i),{actions:r,errors:e,result:{chapter:l,media:a,graph:c}}):C(u({},i),{errors:qe(e,Ct.name,"Could not find media"),actions:r})}}return C(u({},i),{errors:qe(e,Ct.name,"Could not find chapter"),actions:r})}var Et=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 o=i[n];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},xe=class extends Et{constructor(){super(),this.listeners||Et.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)}},De=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&&(De.prototype[Symbol.toStringTag]="AbortController",xe.prototype[Symbol.toStringTag]="AbortSignal");function It(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 Sr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!It({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 o=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(E){y=new Error("Aborted"),y.name="AbortError"}if(m.aborted)return Promise.reject(y);let d=new Promise((E,x)=>{m.addEventListener("abort",()=>x(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,o(a,c)])}return o(a,c)},Request:s}}var He=It({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Rs=He?Sr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,wr=He?Rs.fetch:window.fetch,Yh=He?Rs.Request:window.Request,Zh=He?De:window.AbortController,Xh=He?xe:window.AbortSignal;var Ul=r=>L(void 0,null,function*(){try{let e={},t;if(dt(r)){t=new URL(r).href;let n=yield wr(t);if(!n.ok)return{};e=yield n.json()}else if(je(r))e=r;else return{};if(!As(e))return{};let i=e.metadata.media;if(dt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield wr(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Wl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function ks(r){return L(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ul(r),i=Tr(e);return i.media=Gl(i.media,t),delete i.metadata.media,i})}function xt(r,e){if(e)return r.find(t=>t.id===e)}function Lr(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 Mr(r,e){return r.videos.find(t=>t.id===e)}function Gl(r,e){return C(u({},r),{videos:r.videos.map(t=>C(u({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=zl(n,e);return C(u({},i),{url:s||n})})}))})}function zl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Wl(r){return Z(r,"3.2.0")>=0}var Tt=r=>ft(r)&&!xr(r),W=r=>r.order==="end",Ue=r=>ft(r.containers)&&!xr(r.containers)&&W(r),Ps=(r,e)=>{var i;let t=r*1e3;return Tt(e.controls)&&t<((i=e.startTime)!=null?i:0)},_r=(r,e)=>{var i,n;let t=r*1e3;return Tt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var le=(r=[])=>r.some(e=>e.action.type==="expect"),Ar=(r=[])=>r.find(e=>e.action.type==="expect"),Ql=r=>(r==null?void 0:r.length)===1,ce=r=>Ql(r)&&yt(r[0]);function Vs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(u(u({},e[0]),t)):r(...e,...t)}var Os=(r,e)=>le(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&le(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var pe=class extends bt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new js.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 L(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:qe},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield ks((n=i.result)!=null?n:t),this})}setInitial(){return L(this,null,function*(){return this.setNext()})}setNext(){return L(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",Ct({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Lr,getChapter:xt,getMedia:Mr,getByBranches:this.getByBranches.bind(this),addErrorMessage:qe},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=xt(this.manifest.chapters,t);if(n){let s=Mr(this.manifest.media,n.videoId),o=Lr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let l=xt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.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?W(this.chapter):!1}};var $s=require("@vkontakte/videoplayer-core"),ie=require("@vkontakte/videoplayer-shared");var Ns=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 Rr(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=c,l=N(c,["listId","itemId"]);let m=r.get(s),y=u({},l);return m?m[o]=y:r.set(s,{[o]:y}),u({listId:s,itemId:o},l)}function t(s){var o,l;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(l=s.statistics)==null||l.statSubscription.unsubscribe()}function i(s,o){let l=r.get(s);if(!l)throw Error("Can't remove. Not find.");if(o){let a=l[o];a&&t(a),delete l[o],Object.keys(l).length||r.delete(s)}else{for(let a of Object.values(l))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 kr(r,e=[]){var s,o,l;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(u({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(u({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(u({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(u({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Ge=(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 Kl=2;function Pr(r){let e=Rr(),t=new ie.Subscription,i={},n=null,s=!1,o,l=new ie.ValueSubject(null);r&&a(r);function a(b){n=b}function c(b,p,h){var v;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((v=e.map.get(b))!=null?v:{})[p];if(T){i=u({chapterId:h,listId:b,itemId:p},T);let k=i.player;i.subscription.add(k.info.currentQuality$.subscribe(A=>{let q=k.info.position$.getValue(),P=k.info.isAutoQualityEnabled$.getValue();if(!(!A||!q||P))for(let O of e.map)Object.values(O[1]).forEach(({player:V})=>{Ge(V,A)})})).add(k.events.started$.subscribe(()=>{m(p)})),T.container.remove(),n.setPlayer(T.player),s||(n.init(),s=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function m(b){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(oe(i)||b!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let g of p)h.has(g.media.id)||(yield d({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),h.add(g.media.id))})}function y(h){return L(this,arguments,function*({chapter:{id:b},manifestVideo:p}){if(oe(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),k=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),q=!v,P=!1;for(let O of e.map)if(O[0]===p.id&&!n.state.isReplay$.getValue()){let V=Object.keys(O[1]);for(let F of V)F===i.itemId?(V.length<Kl||(P=!0),e.removePlayer(O[0],F)):(P=!0,c(O[0],F,b),q?Ge(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);P||(yield d({media:p,chapterId:b,setAsActive:!0,playbackRate:A}),q?Ge(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g))})}function d(q){return L(this,arguments,function*({media:b,chapterId:p,prefetch:h=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:v,title:k,playbackRate:A}){var Br,qr,Dr,Hr,Ur;let P=Math.random().toString(),O=document.createElement("div");o.append(O);let V;if((Br=n==null?void 0:n.options)!=null&&Br.vkVideoLoader){let Ye=Ns(b);Ye.length&&(V=yield n.options.vkVideoLoader(...Ye))}let F=((qr=n==null?void 0:n.options)==null?void 0:qr.coreConfig)||void 0,Me=C(u({},F),{configName:[...(Dr=F==null?void 0:F.configName)!=null?Dr:[],"interactive"]}),Ke=C(u({container:O},((Hr=V==null?void 0:V.videos)==null?void 0:Hr[0])||{sources:kr(b,v).sources}),{title:k,failoverHosts:(V==null?void 0:V.failoverHosts)||[]}),me=new $s.Player(Me,ie.Tracer.createRootTracer());me.initVideo(Ke);let $r=null;if(V!=null&&V.videos&&(n!=null&&n.options.createOneStat)){let Ye=V.videos[0],Pt=n.options.createOneStat(Ye),Gr=new ie.Subscription;Pt&&(Gr.add(Pt.attachTo(me)),$r={oneStat:Pt,statSubscription:Gr})}let Fr=new ie.Subscription,la=(Ur=i==null?void 0:i.player)==null?void 0:Ur.info.isAutoQualityEnabled$.getValue();Fr.add(me.events.canplay$.subscribe(function(){la||Ge(me,i.player.info.currentQuality$.getValue()),A&&me.setPlaybackRate(A)}));let ye=e.createPlayer({listId:b.id,itemId:P,player:me,container:O,sources:kr(b,v).sources,config:Ke,subscription:Fr,statistics:$r});return g&&c(b.id,ye.itemId,p),T&&ye.player.play(),h&&!T&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}})}function E(){x(),n=null,o.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function M(){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),o=document.createElement("div");let{media:b,chapter:p}=n.getCurrentChapter();b&&p?(t.add(n.events.chapterChanged$.subscribe(y)),yield d({media:b,chapterId:p.id,title:p.label})):console.error("not found")})}return C(u({},e),{init:M,setInteractiveController:a,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:l})}var I={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 Fs=require("@vkontakte/videoplayer-shared");var St=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:m,onRemove:y}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(le(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(I.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(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let o=Vs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(l,a)=>{this.isSelectedControlEvent=!0,l!==!1&&(this.removeView(),this.globalEventEmitter.emit(I.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(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(o),this.globalEventEmitter.emit(I.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 c;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(Ps(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(_r(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let m=this.gameState;this.gameState=3,m===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=_r(s,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(I.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Fs.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&ce(t.container.controls),this.disabledControls$=m,this.onRemove=y,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,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=le(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(I.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(I.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 Bs=(r=[])=>r.reduce((e,t,i)=>{var s,o,l;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!yt(a));if(Tt(n)){let a=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],y=-1/0,d=1/0,E=[],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]>y&&(y=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),E=E.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[1]=b.range[1])}if(x.push(c),a[0]<=d&&a[1]>=y)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(M=>{e.splice(M,1)}),e.push({subjects:E.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function qs(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let a={};for(let c in r)+c<=l&&(a[c]=r[c]);return a}function i(l){let a={};for(let c in r)+c>=l&&(a[c]=r[c]);return a}function n({timestamp:l,priority:a,initiator:c}){var m;if(Ir(l)){let y=(m=r[l])!=null?m:null;if(y&&a&&Ne(a,!0)){let d={},E=y[a];if(E&&(d=u(u({},d),E)),d=oe(d)?null:d,d&&Ne(c,!0)){let x=d[c];return x!=null?x:null}return d}return y}return null}function s({timestamp:l,priority:a,initiator:c}){if(Ir(l))if(r[l]){if(a&&Ne(a,!0))if(r[l][a]){if(c&&Ne(c,!0))if(r[l][a][c]){if(delete r[l][a][c],!oe(r[l][a]))return!0}else return!1;if(delete r[l][a],!oe(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o(y){var d=y,{timestamp:l,priority:a,initiator:c}=d,m=N(d,["timestamp","priority","initiator"]);var E,x,M;(x=(E=r[l])==null?void 0:E[a])!=null&&x[c]?r[l][a][c].push(u({},m)):(M=r[l])!=null&&M[a]?r[l][a]=C(u({},r[l][a]),{[c]:[u({},m)]}):r[l]?r[l]=C(u({},r[l]),{[a]:{[c]:[u({},m)]}}):r[l]={[a]:{[c]:[u({},m)]}}}return{map:r,remove:s,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var Yl=[R.expect,R.setNextBranch],Zl=1/0;function Ds(r){let e=r,t,i=Xl(),n=qs(),s,o=()=>{d(),p()},l=h=>{n.add.call(void 0,h),x()},a=(h=[])=>{for(let g of h)if(g.action(),Yl.includes(g.actionType))break},c=(h=1/0)=>{var k,A,q;let g=wt((k=n.get({timestamp:h,priority:"control"}))!=null?k:{}),T=wt((A=n.get({timestamp:h,priority:"container"}))!=null?A:{}),v=wt((q=n.get({timestamp:h,priority:"chapter"}))!=null?q:{});return[...g,...T,...v]},m=h=>{i.isReady(h)&&a(c(h))},y=()=>{var h;a([...wt((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},E=h=>{},x=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},M=h=>{d(),e=h},b=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},p=()=>{i.release(),n.removeAll()};return{setPlayer:M,add:l,remove:b,exec:m,execEndOfVideo:y,listen:x,unlisten:d,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function Xl(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let a=r.get(o);a&&a[l]!==void 0&&(a[l]=!0)},setData:(o=[])=>{var l,a;for(let c of o){let m=(l=c.endTime)!=null?l:Zl,y=(a=r.get(m))!=null?a:{};r.set(m,C(u({},y),{[c.id]:!1}))}},resetCalled:o=>{let l=r.get(o);if(l)for(let a in l)l[a]=!1},isReady:o=>{let l=r.get(o);return l?!Object.values(l).some(a=>!a):!0},release:()=>r.clear()}}function wt(r){return Object.values(r).flat().sort(e=>e.actionType===R.expect?-1:1)}var Hs={videoContentHeight:0,videoContentWidth:0},Us=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Hs;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Hs;let o=t/i,l=n/s,a,c;return l>o?(c=s,a=s*o):l<o?(c=n/o,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var Jl=250;function Gs(r){let e=()=>{},t=new ResizeObserver(l=>{s(l),e=s.bind(null,l)});function i(l){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:y}=Us(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let s=Oe(l=>{let{fns:a=[]}=r();i(l);for(let c of a)c()},Jl);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var ze=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 ec=r=>Math.floor(Math.random()*r),Ws=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],o=(n=s.weight)!=null?n:1;o<t&&(t=o,i=s)}return i},Qs=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],o=(n=s.weight)!=null?n:0;o>t&&(t=o,i=s)}return i};var Ks=r=>{let e=r.length,t=ec(e);return r[t]},zs=1,Ys=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:zs;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:zs,e>=t)return r[s];return r[r.length-1]};var Zs={shouldOpenNow:!0,isDetachContainer:!0};var Vr=(r,e=!1)=>C(u({},r),{args:e?u(u({},r.args),Zs):u(u({},Zs),r.args)}),ea=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:p,controlType:h,controlId:g,containerId:T,branches:v=[],onEvent:k,isEOV:A=()=>!1,isDisabled:q=()=>!1})=>{let P=Vr(p,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},V=q(),F=r.emit.bind(r,I.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:V?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:u({containerId:T},P.args)});if(V){F();return}switch(P.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let Me=v.find(Ke=>Ke.id===P.args.branchId);if(!Me)return;k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Me.chapterId,autoSelect:!1}}):(t.add(C(u({},O),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Me.chapterId,autoSelect:!1}})})),i==null||i());return}case R.continuePlayback.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:h,action:p}):t.add(C(u({},O),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:p})}));return}case R.openURI.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}}):(t.add(C(u({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(I.errors,new $(1,1,{message:"Unexpected control event"}));return}},l=({action:p,container:{id:h,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:k=!1})=>{let A=Vr(p,v),q={timestamp:!A.args.shouldOpenNow||v?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:A.type},P=r.emit.bind(r,I.interactives,{subjectId:h,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;P(),t.add(C(u({},q),{action:x.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:k}})})),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():{P(),t.add(C(u({},q),{action:E.bind(null,{subjectId:h,subjectName:"container",action:A})}));return}case R.openURI.trim().toLowerCase():{P(),t.add(C(u({},q),{action:b.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(I.errors,new $(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:h,isEOV:g=!1}){var v,k;let T=Ar(p.events);if(T){let A=Vr(T.action,g);r.emit(I.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(v=p.endTime)!=null?v:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(k=p.events)!=null?k:[])l({action:A.action,container:p,branches:h,isEOV:g})}let c=({chapterId:p,action:h,branches:g=[]})=>{let T=r.emit.bind(r,I.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:h.type,payload:h.args});switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let v=g.find(k=>k.id===h.args.branchId);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let v=Ks(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let v=Ys(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let v=Qs(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let v=Ws(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:console.error("Unexpected chapter event"),r.emit(I.errors,new $(1,1,{message:"Unexpected chapter event"}));return}};function m(p){var g;let h=Ar(p.events);if(h){if(W(p))return;r.emit(I.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:h.action.type,payload:h.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(g=p.events)==null||g.forEach(T=>{let v=c({chapterId:p.id,action:T.action,branches:p.branches});v&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:T.action.type,action:v})})}let y=({subjectId:p,subjectName:h})=>{e.pause(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:R.expect})},d=({subjectId:p,subjectName:h})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:"after-expect"})},E=({subjectId:p,subjectName:h,subjectType:g,action:T})=>{r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},M=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},b=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let k=window.open(v.URI,"_blank","noopener,noreferrer");k&&(k.opener=null),r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:y,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var Nr=Ot(Er(),1),G=require("@vkontakte/videoplayer-shared");var Lt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(o=>o.id===i);if(!n)return null;let s=e.media.videos.find(o=>n.videoId===o.id);if(!s)return null;t[i]=Or(s)}return t[i]}).filter(Boolean)},ta=r=>{for(let e of r.variants)if(ra(e)&&"payload"in e)return e.payload.id},ra=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",Or=r=>{let e=ta(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},ia=(r,e)=>{for(let t of r.media.videos)if(e===Or(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},jr=(r,e)=>r.reduce((t,i)=>{let n=ia(e,i);return n?[...t,n]:t},[]);var X,he,ue,U,Mt,J,ee,K,de,Se,we,We=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new G.ValueSubject([]),hasPrevChapter$:new G.ValueSubject(!1),prevChapter$:new G.ValueSubject(null),isInitialChapter$:new G.ValueSubject(!1),isGoBackLimited$:new G.ValueSubject(!1)};H(this,X,null);H(this,he);H(this,ue,!1);H(this,U,null);H(this,Mt,null);this.events={inited$:new G.Subject,destroyed$:new G.Subject,error$:new G.Subject};H(this,J,null);H(this,ee,null);H(this,K,null);H(this,de,new G.Subscription);H(this,Se,!1);H(this,we,0);var o;j(this,J,t),j(this,K,e),j(this,ee,i),j(this,X,n),j(this,he,s),this.state.history$&&S(this,de)&&((o=S(this,de))==null||o.add(this.state.history$.subscribe(l=>{var a,c;this.state.prevChapter$.next((0,Nr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.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,he).maxLength-1)})))}setManifest(e){return L(this,null,function*(){if(!S(this,ee)||!S(this,K))return;j(this,U,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield S(this,ee).setChapter({chapterId:t,pushToHistory:!1}),S(this,ue)||(j(this,ue,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return S(this,ue)}updateHistory(e,t=!0){return L(this,null,function*(){var l;if(!S(this,U))return;S(this,Se)?(j(this,Se,!1),Zr(this,we)._++):j(this,we,0);let i=S(this,U),n=e.length-S(this,he).maxLength,s=n>0?e.slice(n):e,o=Lt(s,i);if(j(this,Mt,o),this.state.history$.next(s),!(!t||!S(this,X)||!S(this,J)))try{yield S(this,X).save(S(this,J),o)}catch(a){let c=new $(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=S(this,K))==null||l.emit(I.errors,c)}})}goBack(){return L(this,null,function*(){var i;if(!this.state||!S(this,ee)){let n=new $(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,K))==null?void 0:i.emit(I.errors,n)}j(this,Se,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,ee).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return L(this,null,function*(){var n;if(!S(this,U)||!S(this,J))return;let e=S(this,U),t=[this.getInitialVideoId()];if(S(this,X))try{let s=yield S(this,X).get(S(this,J));s.length&&(t=s)}catch(s){let o=new $(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=S(this,K))==null||n.emit(I.errors,o)}let i=jr(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Nr.default)(e,-1)||S(this,he).initChapterId||((t=S(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,U)){let e=this.getInitialChapterId();return Lt([e],S(this,U)).pop()}return null}destroy(){var e,t;j(this,J,null),j(this,X,null),j(this,ee,null),(e=S(this,de))==null||e.unsubscribe(),j(this,de,null),j(this,ue,!1),(t=S(this,K))==null||t.emit(I.historyDestroyed),this.events.destroyed$.next(),j(this,K,null)}};X=new WeakMap,he=new WeakMap,ue=new WeakMap,U=new WeakMap,Mt=new WeakMap,J=new WeakMap,ee=new WeakMap,K=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(o=>!i.has(o));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 _t=fe;var At=class{constructor(){this.bindingMap=new ze}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new _t(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=o=>{this.unlisten(e,t,s),i(o)};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 Rt=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 L(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 L(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 kt=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;
|