@vkontakte/videoplayer-interactive 1.0.31-beta.0 → 1.0.31-dev.0b1013c5.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/es2018.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.31-beta.0
3
- * Sun, 09 Feb 2025 19:03:53 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.31-dev.0b1013c5.0
3
+ * Mon, 10 Mar 2025 12:13:35 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
5
5
  */
6
- var To=Object.create;var ii=Object.defineProperty;var So=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var Ao=Object.getPrototypeOf,Ro=Object.prototype.hasOwnProperty;var ni=r=>{throw TypeError(r)};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Po=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wo(e))!Ro.call(r,n)&&n!==t&&ii(r,n,{get:()=>e[n],enumerable:!(i=So(e,n))||i.enumerable});return r};var Z=(r,e,t)=>(t=r!=null?To(Ao(r)):{},Po(e||!r||!r.__esModule?ii(t,"default",{value:r,enumerable:!0}):t,r));var ai=(r,e,t)=>e.has(r)||ni("Cannot "+t);var T=(r,e,t)=>(ai(r,e,"read from private field"),t?t.call(r):e.get(r)),F=(r,e,t)=>e.has(r)?ni("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),V=(r,e,t,i)=>(ai(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var si=(r,e,t,i)=>({set _(n){V(r,e,n,t)},get _(){return T(r,e,i)}});var K=p((Qt,di)=>{"use strict";var we=function(r){return r&&r.Math===Math&&r};di.exports=we(typeof globalThis=="object"&&globalThis)||we(typeof window=="object"&&window)||we(typeof self=="object"&&self)||we(typeof global=="object"&&global)||we(typeof Qt=="object"&&Qt)||function(){return this}()||Function("return this")()});var q=p(($h,fi)=>{"use strict";fi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ae=p((Nh,mi)=>{"use strict";var ko=q();mi.exports=!ko(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Ci=p((_h,gi)=>{"use strict";var Vo=Ae(),bi=Function.prototype,yi=bi.apply,vi=bi.call;gi.exports=typeof Reflect=="object"&&Reflect.apply||(Vo?vi.bind(yi):function(){return vi.apply(yi,arguments)})});var z=p((Fh,xi)=>{"use strict";var Ei=Ae(),Ii=Function.prototype,Yt=Ii.call,Mo=Ei&&Ii.bind.bind(Yt,Yt);xi.exports=Ei?Mo:function(r){return function(){return Yt.apply(r,arguments)}}});var Re=p((qh,Si)=>{"use strict";var Ti=z(),jo=Ti({}.toString),Lo=Ti("".slice);Si.exports=function(r){return Lo(jo(r),8,-1)}});var Xt=p((Bh,wi)=>{"use strict";var $o=Re(),No=z();wi.exports=function(r){if($o(r)==="Function")return No(r)}});var B=p((Dh,Ai)=>{"use strict";var Zt=typeof document=="object"&&document.all;Ai.exports=typeof Zt=="undefined"&&Zt!==void 0?function(r){return typeof r=="function"||r===Zt}:function(r){return typeof r=="function"}});var ne=p((Hh,Ri)=>{"use strict";var _o=q();Ri.exports=!_o(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ct=p((Gh,Pi)=>{"use strict";var Fo=Ae(),lt=Function.prototype.call;Pi.exports=Fo?lt.bind(lt):function(){return lt.apply(lt,arguments)}});var Jt=p(Vi=>{"use strict";var Oi={}.propertyIsEnumerable,ki=Object.getOwnPropertyDescriptor,qo=ki&&!Oi.call({1:2},1);Vi.f=qo?function(e){var t=ki(this,e);return!!t&&t.enumerable}:Oi});var er=p((zh,Mi)=>{"use strict";Mi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Li=p((Wh,ji)=>{"use strict";var Bo=z(),Do=q(),Ho=Re(),tr=Object,Go=Bo("".split);ji.exports=Do(function(){return!tr("z").propertyIsEnumerable(0)})?function(r){return Ho(r)==="String"?Go(r,""):tr(r)}:tr});var rr=p((Kh,$i)=>{"use strict";$i.exports=function(r){return r==null}});var ir=p((Qh,Ni)=>{"use strict";var Uo=rr(),zo=TypeError;Ni.exports=function(r){if(Uo(r))throw new zo("Can't call method on "+r);return r}});var Pe=p((Yh,_i)=>{"use strict";var Wo=Li(),Ko=ir();_i.exports=function(r){return Wo(Ko(r))}});var me=p((Xh,Fi)=>{"use strict";var Qo=B();Fi.exports=function(r){return typeof r=="object"?r!==null:Qo(r)}});var ut=p((Zh,qi)=>{"use strict";qi.exports={}});var pt=p((Jh,Di)=>{"use strict";var nr=ut(),ar=K(),Yo=B(),Bi=function(r){return Yo(r)?r:void 0};Di.exports=function(r,e){return arguments.length<2?Bi(nr[r])||Bi(ar[r]):nr[r]&&nr[r][e]||ar[r]&&ar[r][e]}});var Gi=p((ed,Hi)=>{"use strict";var Xo=z();Hi.exports=Xo({}.isPrototypeOf)});var Ki=p((td,Wi)=>{"use strict";var Zo=K(),Ui=Zo.navigator,zi=Ui&&Ui.userAgent;Wi.exports=zi?String(zi):""});var tn=p((rd,en)=>{"use strict";var Ji=K(),sr=Ki(),Qi=Ji.process,Yi=Ji.Deno,Xi=Qi&&Qi.versions||Yi&&Yi.version,Zi=Xi&&Xi.v8,W,ht;Zi&&(W=Zi.split("."),ht=W[0]>0&&W[0]<4?1:+(W[0]+W[1]));!ht&&sr&&(W=sr.match(/Edge\/(\d+)/),(!W||W[1]>=74)&&(W=sr.match(/Chrome\/(\d+)/),W&&(ht=+W[1])));en.exports=ht});var or=p((id,nn)=>{"use strict";var rn=tn(),Jo=q(),el=K(),tl=el.String;nn.exports=!!Object.getOwnPropertySymbols&&!Jo(function(){var r=Symbol("symbol detection");return!tl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&rn&&rn<41})});var lr=p((nd,an)=>{"use strict";var rl=or();an.exports=rl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var cr=p((ad,sn)=>{"use strict";var il=pt(),nl=B(),al=Gi(),sl=lr(),ol=Object;sn.exports=sl?function(r){return typeof r=="symbol"}:function(r){var e=il("Symbol");return nl(e)&&al(e.prototype,ol(r))}});var ln=p((sd,on)=>{"use strict";var ll=String;on.exports=function(r){try{return ll(r)}catch(e){return"Object"}}});var ur=p((od,cn)=>{"use strict";var cl=B(),ul=ln(),pl=TypeError;cn.exports=function(r){if(cl(r))return r;throw new pl(ul(r)+" is not a function")}});var pn=p((ld,un)=>{"use strict";var hl=ur(),dl=rr();un.exports=function(r,e){var t=r[e];return dl(t)?void 0:hl(t)}});var dn=p((cd,hn)=>{"use strict";var pr=ct(),hr=B(),dr=me(),fl=TypeError;hn.exports=function(r,e){var t,i;if(e==="string"&&hr(t=r.toString)&&!dr(i=pr(t,r))||hr(t=r.valueOf)&&!dr(i=pr(t,r))||e!=="string"&&hr(t=r.toString)&&!dr(i=pr(t,r)))return i;throw new fl("Can't convert object to primitive value")}});var mn=p((ud,fn)=>{"use strict";fn.exports=!0});var bn=p((pd,vn)=>{"use strict";var yn=K(),ml=Object.defineProperty;vn.exports=function(r,e){try{ml(yn,r,{value:e,configurable:!0,writable:!0})}catch(t){yn[r]=e}return e}});var dt=p((hd,En)=>{"use strict";var yl=mn(),vl=K(),bl=bn(),gn="__core-js_shared__",Cn=En.exports=vl[gn]||bl(gn,{});(Cn.versions||(Cn.versions=[])).push({version:"3.38.0",mode:yl?"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 fr=p((dd,xn)=>{"use strict";var In=dt();xn.exports=function(r,e){return In[r]||(In[r]=e||{})}});var Oe=p((fd,Tn)=>{"use strict";var gl=ir(),Cl=Object;Tn.exports=function(r){return Cl(gl(r))}});var ye=p((md,Sn)=>{"use strict";var El=z(),Il=Oe(),xl=El({}.hasOwnProperty);Sn.exports=Object.hasOwn||function(e,t){return xl(Il(e),t)}});var mr=p((yd,wn)=>{"use strict";var Tl=z(),Sl=0,wl=Math.random(),Al=Tl(1 .toString);wn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Al(++Sl+wl,36)}});var ke=p((vd,Rn)=>{"use strict";var Rl=K(),Pl=fr(),An=ye(),Ol=mr(),kl=or(),Vl=lr(),ve=Rl.Symbol,yr=Pl("wks"),Ml=Vl?ve.for||ve:ve&&ve.withoutSetter||Ol;Rn.exports=function(r){return An(yr,r)||(yr[r]=kl&&An(ve,r)?ve[r]:Ml("Symbol."+r)),yr[r]}});var Vn=p((bd,kn)=>{"use strict";var jl=ct(),Pn=me(),On=cr(),Ll=pn(),$l=dn(),Nl=ke(),_l=TypeError,Fl=Nl("toPrimitive");kn.exports=function(r,e){if(!Pn(r)||On(r))return r;var t=Ll(r,Fl),i;if(t){if(e===void 0&&(e="default"),i=jl(t,r,e),!Pn(i)||On(i))return i;throw new _l("Can't convert object to primitive value")}return e===void 0&&(e="number"),$l(r,e)}});var vr=p((gd,Mn)=>{"use strict";var ql=Vn(),Bl=cr();Mn.exports=function(r){var e=ql(r,"string");return Bl(e)?e:e+""}});var $n=p((Cd,Ln)=>{"use strict";var Dl=K(),jn=me(),br=Dl.document,Hl=jn(br)&&jn(br.createElement);Ln.exports=function(r){return Hl?br.createElement(r):{}}});var gr=p((Ed,Nn)=>{"use strict";var Gl=ne(),Ul=q(),zl=$n();Nn.exports=!Gl&&!Ul(function(){return Object.defineProperty(zl("div"),"a",{get:function(){return 7}}).a!==7})});var qn=p(Fn=>{"use strict";var Wl=ne(),Kl=ct(),Ql=Jt(),Yl=er(),Xl=Pe(),Zl=vr(),Jl=ye(),ec=gr(),_n=Object.getOwnPropertyDescriptor;Fn.f=Wl?_n:function(e,t){if(e=Xl(e),t=Zl(t),ec)try{return _n(e,t)}catch(i){}if(Jl(e,t))return Yl(!Kl(Ql.f,e,t),e[t])}});var Dn=p((xd,Bn)=>{"use strict";var tc=q(),rc=B(),ic=/#|\.prototype\./,Ve=function(r,e){var t=ac[nc(r)];return t===oc?!0:t===sc?!1:rc(e)?tc(e):!!e},nc=Ve.normalize=function(r){return String(r).replace(ic,".").toLowerCase()},ac=Ve.data={},sc=Ve.NATIVE="N",oc=Ve.POLYFILL="P";Bn.exports=Ve});var Cr=p((Td,Gn)=>{"use strict";var Hn=Xt(),lc=ur(),cc=Ae(),uc=Hn(Hn.bind);Gn.exports=function(r,e){return lc(r),e===void 0?r:cc?uc(r,e):function(){return r.apply(e,arguments)}}});var zn=p((Sd,Un)=>{"use strict";var pc=ne(),hc=q();Un.exports=pc&&hc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Kn=p((wd,Wn)=>{"use strict";var dc=me(),fc=String,mc=TypeError;Wn.exports=function(r){if(dc(r))return r;throw new mc(fc(r)+" is not an object")}});var Xn=p(Yn=>{"use strict";var yc=ne(),vc=gr(),bc=zn(),ft=Kn(),Qn=vr(),gc=TypeError,Er=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Ir="enumerable",xr="configurable",Tr="writable";Yn.f=yc?bc?function(e,t,i){if(ft(e),t=Qn(t),ft(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Tr in i&&!i[Tr]){var n=Cc(e,t);n&&n[Tr]&&(e[t]=i.value,i={configurable:xr in i?i[xr]:n[xr],enumerable:Ir in i?i[Ir]:n[Ir],writable:!1})}return Er(e,t,i)}:Er:function(e,t,i){if(ft(e),t=Qn(t),ft(i),vc)try{return Er(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new gc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Jn=p((Rd,Zn)=>{"use strict";var Ec=ne(),Ic=Xn(),xc=er();Zn.exports=Ec?function(r,e,t){return Ic.f(r,e,xc(1,t))}:function(r,e,t){return r[e]=t,r}});var je=p((Pd,ta)=>{"use strict";var Me=K(),Tc=Ci(),Sc=Xt(),wc=B(),Ac=qn().f,Rc=Dn(),be=ut(),Pc=Cr(),ge=Jn(),ea=ye();dt();var Oc=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 Tc(r,this,arguments)};return e.prototype=r.prototype,e};ta.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,a=r.proto,o=i?Me:n?Me[t]:Me[t]&&Me[t].prototype,l=i?be:be[t]||ge(be,t,{})[t],s=l.prototype,c,f,b,d,E,w,R,v,P;for(d in e)c=Rc(i?d:t+(n?".":"#")+d,r.forced),f=!c&&o&&ea(o,d),w=l[d],f&&(r.dontCallGetSet?(P=Ac(o,d),R=P&&P.value):R=o[d]),E=f&&R?R:e[d],!(!c&&!a&&typeof w==typeof E)&&(r.bind&&f?v=Pc(E,Me):r.wrap&&f?v=Oc(E):a&&wc(E)?v=Sc(E):v=E,(r.sham||E&&E.sham||w&&w.sham)&&ge(v,"sham",!0),ge(l,d,v),a&&(b=t+"Prototype",ea(be,b)||ge(be,b,{}),ge(be[b],d,E),r.real&&s&&(c||!s[d])&&ge(s,d,E)))}});var ia=p((Od,ra)=>{"use strict";var kc=Math.ceil,Vc=Math.floor;ra.exports=Math.trunc||function(e){var t=+e;return(t>0?Vc:kc)(t)}});var Le=p((kd,na)=>{"use strict";var Mc=ia();na.exports=function(r){var e=+r;return e!==e||e===0?0:Mc(e)}});var sa=p((Vd,aa)=>{"use strict";var jc=Le(),Lc=Math.min;aa.exports=function(r){var e=jc(r);return e>0?Lc(e,9007199254740991):0}});var $e=p((Md,oa)=>{"use strict";var $c=sa();oa.exports=function(r){return $c(r.length)}});var mt=p((jd,la)=>{"use strict";la.exports=function(){}});var ca=p(()=>{"use strict";var Nc=je(),_c=Oe(),Fc=$e(),qc=Le(),Bc=mt();Nc({target:"Array",proto:!0},{at:function(e){var t=_c(this),i=Fc(t),n=qc(e),a=n>=0?n:i+n;return a<0||a>=i?void 0:t[a]}});Bc("at")});var yt=p((Nd,ua)=>{"use strict";var Dc=pt();ua.exports=Dc});var ha=p((_d,pa)=>{"use strict";ca();var Hc=yt();pa.exports=Hc("Array","at")});var fa=p((Fd,da)=>{"use strict";var Gc=ha();da.exports=Gc});var Sr=p((qd,ma)=>{"use strict";var Uc=fa();ma.exports=Uc});var Oa=p((Jf,Pa)=>{"use strict";var tu=fr(),ru=mr(),Ra=tu("keys");Pa.exports=function(r){return Ra[r]||(Ra[r]=ru(r))}});var Va=p((em,ka)=>{"use strict";var iu=q();ka.exports=!iu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var La=p((tm,ja)=>{"use strict";var nu=ye(),au=B(),su=Oe(),ou=Oa(),lu=Va(),Ma=ou("IE_PROTO"),Lr=Object,cu=Lr.prototype;ja.exports=lu?Lr.getPrototypeOf:function(r){var e=su(r);if(nu(e,Ma))return e[Ma];var t=e.constructor;return au(t)&&e instanceof t?t.prototype:e instanceof Lr?cu:null}});var Na=p((rm,$a)=>{"use strict";var uu=Le(),pu=Math.max,hu=Math.min;$a.exports=function(r,e){var t=uu(r);return t<0?pu(t+e,0):hu(t,e)}});var $r=p((im,Fa)=>{"use strict";var du=Pe(),fu=Na(),mu=$e(),_a=function(r){return function(e,t,i){var n=du(e),a=mu(n);if(a===0)return!r&&-1;var o=fu(i,a),l;if(r&&t!==t){for(;a>o;)if(l=n[o++],l!==l)return!0}else for(;a>o;o++)if((r||o in n)&&n[o]===t)return r||o||0;return!r&&-1}};Fa.exports={includes:_a(!0),indexOf:_a(!1)}});var Ba=p((nm,qa)=>{"use strict";qa.exports={}});var Ga=p((am,Ha)=>{"use strict";var yu=z(),Nr=ye(),vu=Pe(),bu=$r().indexOf,gu=Ba(),Da=yu([].push);Ha.exports=function(r,e){var t=vu(r),i=0,n=[],a;for(a in t)!Nr(gu,a)&&Nr(t,a)&&Da(n,a);for(;e.length>i;)Nr(t,a=e[i++])&&(~bu(n,a)||Da(n,a));return n}});var za=p((sm,Ua)=>{"use strict";Ua.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ka=p((om,Wa)=>{"use strict";var Cu=Ga(),Eu=za();Wa.exports=Object.keys||function(e){return Cu(e,Eu)}});var es=p((lm,Ja)=>{"use strict";var Ya=ne(),Iu=q(),Xa=z(),xu=La(),Tu=Ka(),Su=Pe(),wu=Jt().f,Za=Xa(wu),Au=Xa([].push),Ru=Ya&&Iu(function(){var r=Object.create(null);return r[2]=2,!Za(r,2)}),Qa=function(r){return function(e){for(var t=Su(e),i=Tu(t),n=Ru&&xu(t)===null,a=i.length,o=0,l=[],s;a>o;)s=i[o++],(!Ya||(n?s in t:Za(t,s)))&&Au(l,r?[s,t[s]]:t[s]);return l}};Ja.exports={entries:Qa(!0),values:Qa(!1)}});var ts=p(()=>{"use strict";var Pu=je(),Ou=es().values;Pu({target:"Object",stat:!0},{values:function(e){return Ou(e)}})});var is=p((pm,rs)=>{"use strict";ts();var ku=ut();rs.exports=ku.Object.values});var as=p((hm,ns)=>{"use strict";var Vu=is();ns.exports=Vu});var Vt=p((dm,ss)=>{"use strict";var Mu=as();ss.exports=Mu});var cs=p(()=>{"use strict";var ju=je(),Lu=$r().includes,$u=q(),Nu=mt(),_u=$u(function(){return!Array(1).includes()});ju({target:"Array",proto:!0,forced:_u},{includes:function(e){return Lu(this,e,arguments.length>1?arguments[1]:void 0)}});Nu("includes")});var ps=p((bm,us)=>{"use strict";cs();var Fu=yt();us.exports=Fu("Array","includes")});var ds=p((gm,hs)=>{"use strict";var qu=ps();hs.exports=qu});var Mt=p((Cm,fs)=>{"use strict";var Bu=ds();fs.exports=Bu});var Dr=p((_m,gs)=>{"use strict";var Wu=Re();gs.exports=Array.isArray||function(e){return Wu(e)==="Array"}});var Es=p((Fm,Cs)=>{"use strict";var Ku=TypeError,Qu=9007199254740991;Cs.exports=function(r){if(r>Qu)throw Ku("Maximum allowed index exceeded");return r}});var Ts=p((qm,xs)=>{"use strict";var Yu=Dr(),Xu=$e(),Zu=Es(),Ju=Cr(),Is=function(r,e,t,i,n,a,o,l){for(var s=n,c=0,f=o?Ju(o,l):!1,b,d;c<i;)c in t&&(b=f?f(t[c],c,e):t[c],a>0&&Yu(b)?(d=Xu(b),s=Is(r,e,b,d,s,a-1)-1):(Zu(s+1),r[s]=b),s++),c++;return s};xs.exports=Is});var As=p((Bm,ws)=>{"use strict";var ep=ke(),tp=ep("toStringTag"),Ss={};Ss[tp]="z";ws.exports=String(Ss)==="[object z]"});var Ps=p((Dm,Rs)=>{"use strict";var rp=As(),ip=B(),Lt=Re(),np=ke(),ap=np("toStringTag"),sp=Object,op=Lt(function(){return arguments}())==="Arguments",lp=function(r,e){try{return r[e]}catch(t){}};Rs.exports=rp?Lt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=lp(e=sp(r),ap))=="string"?t:op?Lt(e):(i=Lt(e))==="Object"&&ip(e.callee)?"Arguments":i}});var ks=p((Hm,Os)=>{"use strict";var cp=z(),up=B(),Hr=dt(),pp=cp(Function.toString);up(Hr.inspectSource)||(Hr.inspectSource=function(r){return pp(r)});Os.exports=Hr.inspectSource});var Ns=p((Gm,$s)=>{"use strict";var hp=z(),dp=q(),Vs=B(),fp=Ps(),mp=pt(),yp=ks(),Ms=function(){},js=mp("Reflect","construct"),Gr=/^\s*(?:class|function)\b/,vp=hp(Gr.exec),bp=!Gr.test(Ms),We=function(e){if(!Vs(e))return!1;try{return js(Ms,[],e),!0}catch(t){return!1}},Ls=function(e){if(!Vs(e))return!1;switch(fp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return bp||!!vp(Gr,yp(e))}catch(t){return!0}};Ls.sham=!0;$s.exports=!js||dp(function(){var r;return We(We.call)||!We(Object)||!We(function(){r=!0})||r})?Ls:We});var Bs=p((Um,qs)=>{"use strict";var _s=Dr(),gp=Ns(),Cp=me(),Ep=ke(),Ip=Ep("species"),Fs=Array;qs.exports=function(r){var e;return _s(r)&&(e=r.constructor,gp(e)&&(e===Fs||_s(e.prototype))?e=void 0:Cp(e)&&(e=e[Ip],e===null&&(e=void 0))),e===void 0?Fs:e}});var Hs=p((zm,Ds)=>{"use strict";var xp=Bs();Ds.exports=function(r,e){return new(xp(r))(e===0?0:e)}});var Gs=p(()=>{"use strict";var Tp=je(),Sp=Ts(),wp=Oe(),Ap=$e(),Rp=Le(),Pp=Hs();Tp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=wp(this),i=Ap(t),n=Pp(t,0);return n.length=Sp(n,t,t,i,0,e===void 0?1:Rp(e)),n}})});var Us=p(()=>{"use strict";var Op=mt();Op("flat")});var Ws=p((Xm,zs)=>{"use strict";Gs();Us();var kp=yt();zs.exports=kp("Array","flat")});var Qs=p((Zm,Ks)=>{"use strict";var Vp=Ws();Ks.exports=Vp});var Xs=p((Jm,Ys)=>{"use strict";var Mp=Qs();Ys.exports=Mp});var oi="1.0.31-beta.0";function Dt(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var $="interactive",Oo="interactive-controls-container",Ze=()=>document.querySelector(`.${Oo}`),li=.4,L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ci=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ci||{}),ui=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ui||{}),pi=(i=>(i.start="left",i.end="right",i.center="center",i))(pi||{}),Je=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&ci[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&ui[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&pi[e.alignment])!=null?n:"center"},et=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c;r.style.color=(a=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?a: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=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},tt=({target:r,props:e,fallback:t})=>{var i,n,a,o;r.style.backgroundColor=Dt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(a=e==null?void 0:e.background)==null?void 0:a.alpha)!=null?o:t.backgroundAlpha)},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c,f,b,d,E,w;r.style.border=`calc(${i.height} * ${(o=(a=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:a.width)!=null?o:t.borderWidth}) solid ${Dt((c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.color)!=null?c:t.borderColor,(d=(b=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:b.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(w=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?w:t.roundCorners})`},de=({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 J=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(`${$}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Ht="int",ie=(i=>(i.AREA=`${Ht}_area`,i.TEXT=`${Ht}_text`,i.BUTTON=`${Ht}_bttn`,i))(ie||{});var it=r=>{if(r.type.trim().toLowerCase()==="area")return new Gt(r)},Gt=class extends J{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(`${$}-${this.control.id}`),i.setAttribute("data-testid",ie.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:{...L,backgroundColor:"transparent"}}),rt({target:i,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions}),de({target:i,layoutParams:this.control.layoutParams,fallback:L}),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=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var at=r=>{if(r.type.trim().toLowerCase()==="button")return new Ut(r)},Ut=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${$}-${this.control.id}`),i.setAttribute("data-testid",ie.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",de({target:i,layoutParams:this.control.layoutParams,fallback:L}),tt({target:i,props:this.control.props,fallback:L}),rt({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),Je({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=nt(this.control.type.trim().toLowerCase()),a=(o=n.firstElementChild)!=null?o:n;et({target:a,props:this.control.props,fallback:L,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 hi=r=>{if(r.type.trim().toLowerCase()==="text")return new zt(r)},zt=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${$}-${this.control.id}`),i.setAttribute("data-testid",ie.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",de({target:i,layoutParams:this.control.layoutParams,fallback:L}),Je({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=nt(this.control.type.trim().toLowerCase()),a=(o=n.firstElementChild)!=null?o:n;et({target:a,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var Wt=class{constructor(e){this.layout=e}},st=class extends Wt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var fe=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(),a=this.factories.get(n);if(a){let o=a(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ot=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Kt(r,e)},Kt=class extends fe{constructor(e,t){super(e),this.rootElement=t!=null?t:Ze(),this.layout=new st(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",at),this.addControlFactory("text",hi),this.addControlFactory("area",it)}createView(e){let t=document.createElement("div");return t.classList.add(`${$}-${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=`${li}`,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(`.${$}-${this.container.id}`)}};var Io=Z(Sr(),1);import{clientChecker as Gp,combine as Up,InterfaceLanguage as zp,Observable as go,once as Wp,Subject as N,Subscription as Yr,ValueSubject as _,fromEvent as Co}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as Ye}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as zc}from"@vkontakte/videoplayer-shared/es2018";function Ne(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ae=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,_e=r=>ae(r,"Object"),vt=r=>ae(r,"String"),bt=r=>ae(r,"Array"),gt=r=>ae(r,"Number"),ya=r=>ae(r,"Function");var wr=r=>gt(r)&&!isNaN(r);var se=r=>_e(r)&&Object.keys(r).length===0,Ar=r=>bt(r)&&!r.length;var Fe=(r,e)=>vt(r)&&(e?r.trim():r).length;var va="video_interactive",ba="videoint";var ga=250,qe=class{constructor(e){this.handleZoomChange=Ne(e=>{this.lastZoomInfo=e},ga);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!gt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:a=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(a),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=Wc(e),this.resizeObserver=new ResizeObserver(Ne(this.onResize,ga)),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)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await zc(this.lang,va,ba)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=await 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.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:i,...n})=>{var a;i==="openPreview"&&"chapterId"in n&&((a=this.onOpenPreviewClick)==null||a.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 Wc(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Be=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let a of this._containers){let o=a.startTime-e;if(o<=n&&(a.endTime&&n<=a.endTime||a.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};import{isSupportedManifest as Et,ContainerTypes as df,ControlTypes as It,EventActionTypes as A,EventTypes as ff,migrateManifestToLatestVersion as Ia,compareVersions as mf}from"@interactiveplatform/movika-manifest";var Ca={metadata:"Object",chapters:"Array"},Ea=r=>{if(!_e(r))return!1;for(let e in Ca)if(!r[e]||!ae(r[e],Ca[e]))return!1;return Et(r.metadata.version)},Ct=r=>r.type===It.Text,nf=r=>r.type===It.Button,af=r=>r.type===It.Area,sf={Choice:"Choice",TextInput:"TextInput"},of={Button:"Button",Area:"Area",Text:"Text"},lf={onClick:"onClick",onSuspense:"onSuspense"},cf={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var j=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var xt=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 Tt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{ya(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=[]}};import{ValueSubject as eu}from"@vkontakte/videoplayer-shared/es2018";var St=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:[]}}async exec(e,t){return Kc(...this.loaders[e])(t)}};function Kc(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function De(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function wt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let a=r.getChapter(n.chapters,t);if(a){let o=r.getMedia(n.media,a.videoId),l=r.getGraph(n.graph,a.id);return o?{...i,actions:r,errors:e,result:{chapter:a,media:o,graph:l}}:{...i,errors:De(e,wt.name,"Could not find media"),actions:r}}}}return{...i,errors:De(e,wt.name,"Could not find chapter"),actions:r}}var At=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,a=i.length;n<a;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,a=i.length;n<a;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}},Ce=class extends At{constructor(){super(),this.listeners||At.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},He=class{constructor(){Object.defineProperty(this,"signal",{value:new Ce,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(He.prototype[Symbol.toStringTag]="AbortController",Ce.prototype[Symbol.toStringTag]="AbortSignal");function Rt(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 Rr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Rt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||n)&&(a=function(c,f){let b;f&&f.signal&&(b=f.signal,delete f.signal);let d=new t(c,f);return b&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:b}),d},a.prototype=t.prototype);let o=e;return{fetch:(s,c)=>{let f=a&&a.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(f){let b;try{b=new DOMException("Aborted","AbortError")}catch(E){b=new Error("Aborted"),b.name="AbortError"}if(f.aborted)return Promise.reject(b);let d=new Promise((E,w)=>{f.addEventListener("abort",()=>w(b),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,o(s,c)])}return o(s,c)},Request:a}}var Ge=Rt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),xa=Ge?Rr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Pr=Ge?xa.fetch:window.fetch,Mf=Ge?xa.Request:window.Request,jf=Ge?He:window.AbortController,Lf=Ge?Ce:window.AbortSignal;var Or=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let a=0;a<Math.max(t.length,i.length)&&!n;a++)t[a]>i[a]?n=1:t[a]<i[a]?n=-1:n=0;return n};var Qc=async r=>{try{let e={},t;if(vt(r)){t=new URL(r).href;let n=await Pr(t);if(!n.ok)return{};e=await n.json()}else if(_e(r))e=r;else return{};if(!Ea(e))return{};let i=e.metadata.media;if(vt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let a=await Pr(n);if(!a.ok)throw new Error;e.metadata.media=await a.json()}catch(n){return Zc(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function Ta(r){let{manifest:e,manifestURL:t}=await Qc(r);if(!e)throw new Error("Failed on fetch");let i=Ia(e);return i.media=Yc(i.media,t),delete i.metadata.media,i}function Pt(r,e){if(e)return r.find(t=>t.id===e)}function kr(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function Vr(r,e){return r.videos.find(t=>t.id===e)}function Yc(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",a=Xc(n,e);return{...i,url:a||n}})}))}}function Xc(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zc(r){return Or(r,"3.2.0")>=0}var Ot=r=>bt(r)&&!Ar(r),Q=r=>r.order==="end",kt=r=>bt(r.containers)&&!Ar(r.containers)&&Q(r),Sa=(r,e)=>{var i;let t=r*1e3;return Ot(e.controls)&&t<((i=e.startTime)!=null?i:0)},Mr=(r,e)=>{var i,n;let t=r*1e3;return Ot(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var oe=(r=[])=>r.some(e=>e.action.type==="expect"),jr=(r=[])=>r.find(e=>e.action.type==="expect"),Jc=r=>(r==null?void 0:r.length)===1,Ee=r=>Jc(r)&&Ct(r[0]);function wa(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r({...e[0],...t}):r(...e,...t)}var Aa=(r,e)=>oe(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&oe(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Ie=class extends St{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new eu(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}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:De},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await Ta((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",wt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:kr,getChapter:Pt,getMedia:Vr,getByBranches:this.getByBranches.bind(this),addErrorMessage:De},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(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=Pt(this.manifest.chapters,t);if(n){let a=Vr(this.manifest.media,n.videoId),o=kr(this.manifest.graph,n.id);if(a)return{chapter:n,media:a,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,a,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((a=this.chapter)==null?void 0:a.branches);{let l=Pt(((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 a=this.getByChapterId(n.chapterId);return a&&i.push(a),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?Q(this.chapter):!1}};var ms=Z(Vt(),1);import{Player as Du}from"@vkontakte/videoplayer-core/es2018";import{Subscription as qr,Tracer as Hu,ValueSubject as Gu}from"@vkontakte/videoplayer-shared/es2018";var os=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var ls=Z(Vt(),1);function _r(){let r=new Map;function e({listId:a=Math.random().toString(),itemId:o=Math.random().toString(),...l}){let s=r.get(a),c={...l};return s?s[o]=c:r.set(a,{[o]:c}),{listId:a,itemId:o,...l}}function t(a){var o,l;a.player.destroy(),a.container.remove(),a.subscription.unsubscribe(),(o=a.statistics)==null||o.oneStat.destroy(),(l=a.statistics)==null||l.statSubscription.unsubscribe()}function i(a,o){let l=r.get(a);if(!l)throw Error("Can't remove. Not find.");if(o){let s=l[o];s&&t(s),delete l[o],Object.keys(l).length||r.delete(a)}else{for(let s of(0,ls.default)(l))t(s);r.delete(a)}}function n(){for(let a of r)i(a[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var xe=Z(Mt(),1);function Fr(r,e=[]){var a,o,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,xe.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(a=s.standard)!=null?a:"Invariant quality"]:s.url});break;case"mpeg":(n||(0,xe.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(o=s.standard)!=null?o:"Invariant quality"]:s.url});break;case"hls":(n||(0,xe.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(n||(0,xe.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Ue=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,xe.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Uu=2;function Br(r){let e=_r(),t=new qr,i={},n=null,a=!1,o,l=new Gu(null);r&&s(r);function s(v){n=v}function c(v,P,u){var C;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let m=((C=e.map.get(v))!=null?C:{})[P];if(m){i={chapterId:u,listId:v,itemId:P,...m};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(y=>{let I=g.info.position$.getValue(),M=g.info.isAutoQualityEnabled$.getValue();if(!(!y||!I||M))for(let x of e.map)(0,ms.default)(x[1]).forEach(({player:k})=>{Ue(k,y)})})).add(g.events.started$.subscribe(()=>{f(P)})),m.container.remove(),n.setPlayer(m.player),a||(n.init(),a=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function f(v){if(!n)throw Error("need to set interactive controller");if(se(i)||v!==i.itemId)return;let P=n.getChapterBranches(),u=new Set;for(let h of P)u.has(h.media.id)||(await d({media:h.media,chapterId:h.chapter.id,setAsActive:!1,title:h.chapter.label}),u.add(h.media.id))}async function b({chapter:{id:v},manifestVideo:P}){if(se(i)||!n)return;let u=i.player.info.muted$.getValue(),h=i.player.info.currentQuality$.getValue(),m=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),y=!m,I=!1;for(let M of e.map)if(M[0]===P.id&&!n.state.isReplay$.getValue()){let x=Object.keys(M[1]);for(let k of x)k===i.itemId?(x.length<Uu||(I=!0),e.removePlayer(M[0],k)):(I=!0,c(M[0],k,v),y?Ue(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(u),i.player.setPlaybackRate(g))}else e.removePlayer(M[0]);I||(await d({media:P,chapterId:v,setAsActive:!0,playbackRate:g}),y?Ue(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(u))}async function d({media:v,chapterId:P,prefetch:u=!0,setAsActive:h=!0,autoplay:m=!1,preferredExt:C,title:g,playbackRate:y}){var Xr,Zr,Jr,ei,ti;let I=Math.random().toString(),M=document.createElement("div");o.append(M);let x;if((Xr=n==null?void 0:n.options)!=null&&Xr.vkVideoLoader){let Xe=os(v);Xe.length&&(x=await n.options.vkVideoLoader(...Xe))}let k=((Zr=n==null?void 0:n.options)==null?void 0:Zr.coreConfig)||void 0,H={...k,configName:[...(Jr=k==null?void 0:k.configName)!=null?Jr:[],"interactive"]},G={container:M,...((ei=x==null?void 0:x.videos)==null?void 0:ei[0])||{sources:Fr(v,C).sources},title:g,failoverHosts:(x==null?void 0:x.failoverHosts)||[]},U=new Du(H,Hu.createRootTracer());U.initVideo(G);let X=null;if(x!=null&&x.videos&&(n!=null&&n.options.createOneStat)){let Xe=x.videos[0],Bt=n.options.createOneStat(Xe),ri=new qr;Bt&&(ri.add(Bt.attachTo(U)),X={oneStat:Bt,statSubscription:ri})}let pe=new qr,xo=(ti=i==null?void 0:i.player)==null?void 0:ti.info.isAutoQualityEnabled$.getValue();pe.add(U.events.canplay$.subscribe(function(){xo||Ue(U,i.player.info.currentQuality$.getValue()),y&&U.setPlaybackRate(y)}));let he=e.createPlayer({listId:v.id,itemId:I,player:U,container:M,sources:Fr(v,C).sources,config:G,subscription:pe,statistics:X});return h&&c(v.id,he.itemId,P),m&&he.player.play(),u&&!m&&he.player.prepare(),{player:he.player,config:he.config,statistics:he.statistics}}function E(){w(),n=null,o.remove()}function w(){t.unsubscribe(),e.removeAll(),i={},a=!1}async function R(){if(!n)throw Error("need to set interactive controller");w(),o=document.createElement("div");let{media:v,chapter:P}=n.getCurrentChapter();v&&P?(t.add(n.events.chapterChanged$.subscribe(b)),await d({media:v,chapterId:P.id,title:P.label})):console.error("not found")}return{...e,init:R,setInteractiveController:s,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:l}}var S={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},ze={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},O={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var vs=Z(Mt(),1);import{Subscription as zu}from"@vkontakte/videoplayer-shared/es2018";var jt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:a,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:s,permanentTextControls:c,disabledControls$:f,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(oe(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,a;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement())(i=(t=this.container).show)==null||i.call(t),this.emitContainerVisibilityEvent(!0,!1);else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(s,c)=>{this.isSelectedControlEvent=!0,s!==!1&&(this.removeView(),this.emitContainerVisibilityEvent(!1)),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.emitContainerVisibilityEvent(!1))},isEOV:()=>this.gameState===4},l=wa(this.selectBranches.onControlEvent,o);this.container.createView(l),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((a=(n=this.container).disable)==null||a.call(n))}};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||(0,vs.default)(n,this.gameState)&&!this.isPermanentText)return;let a=this.player.getExactTime();if(Sa(a,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Mr(a,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=Mr(a,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:a,isInteractiveTime:o};this.globalEventEmitter.emit(S.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new zu,this.player=e,this.interactiveEvents=a,this.ignoreContainerEvent=s,this.isPermanentText=c&&Ee(t.container.controls),this.disabledControls$=f,this.onRemove=b,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}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,a;e?(i=(t=this.container).disable)==null||i.call(t):(a=(n=this.container).enable)==null||a.call(n)}))}selectContainerEvent(e=!1){var t,i;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(t=this.container.container.endTime)!=null?t:1/0,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((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=oe(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.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),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 a,o,l;let n=((a=t==null?void 0:t.controls)!=null?a:[]).filter(s=>!Ct(s));if(Ot(n)){let s=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:s});else{let f=[],b=-1/0,d=1/0,E=[],w=[];for(let R=0;R<e.length;R++){let v=e[R];if(w.push(...v.subjects),v.range[0]<d&&(d=v.range[0]),v.range[1]>b&&(b=v.range[1]),s[0]>=v.range[0]&&s[1]<=v.range[1])return e[R].subjects.push(c),e;s[0]<v.range[0]&&s[1]>v.range[0]&&(f.push(R),E=E.concat(v.subjects)),s[0]>=v.range[0]&&s[0]<=v.range[1]&&(f.push(R),E=E.concat(v.subjects),s[0]=v.range[0]),s[1]>=v.range[0]&&s[1]<=v.range[1]&&(f.push(R),E=E.concat(v.subjects),s[1]=v.range[1])}if(w.push(c),s[0]<=d&&s[1]>=b)return[{subjects:w,range:s}];f.length&&f.reverse().forEach(R=>{e.splice(R,1)}),e.push({subjects:E.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Js=Z(Mt(),1),Ur=Z(Vt(),1),eo=Z(Xs(),1);function Zs(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var f;if(wr(l)){let b=(f=r[l])!=null?f:null;if(b&&s&&Fe(s,!0)){let d={},E=b[s];if(E&&(d={...d,...E}),d=se(d)?null:d,d&&Fe(c,!0)){let w=d[c];return w!=null?w:null}return d}return b}return null}function a({timestamp:l,priority:s,initiator:c}){if(wr(l))if(r[l]){if(s&&Fe(s,!0))if(r[l][s]){if(c&&Fe(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!se(r[l][s]))return!0}else return!1;if(delete r[l][s],!se(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o({timestamp:l,priority:s,initiator:c,...f}){var b,d,E;(d=(b=r[l])==null?void 0:b[s])!=null&&d[c]?r[l][s][c].push({...f}):(E=r[l])!=null&&E[s]?r[l][s]={...r[l][s],[c]:[{...f}]}:r[l]?r[l]={...r[l],[s]:{[c]:[{...f}]}}:r[l]={[s]:{[c]:[{...f}]}}}return{map:r,remove:a,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var jp=[A.expect,A.setNextBranch],Lp=1/0;function to(r){let e=r,t,i=$p(),n=Zs(),a,o=()=>{d(),P()},l=u=>{n.add.call(void 0,u),w()},s=(u=[])=>{for(let h of u)if(h.action(),(0,Js.default)(jp,h.actionType))break},c=(u=1/0)=>{var g,y,I;let h=$t((g=n.get({timestamp:u,priority:"control"}))!=null?g:{}),m=$t((y=n.get({timestamp:u,priority:"container"}))!=null?y:{}),C=$t((I=n.get({timestamp:u,priority:"chapter"}))!=null?I:{});return[...h,...m,...C]},f=u=>{i.isReady(u)&&s(c(u))},b=()=>{var u;s([...$t((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(a==null||a.unsubscribe(),t=void 0)},E=u=>{},w=()=>{t||(t=()=>setTimeout(()=>{f(1/0)}),a=e.events.ended$.subscribe(t))},R=u=>{d(),e=u},v=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},P=()=>{i.release(),n.removeAll()};return{setPlayer:R,add:l,remove:v,exec:f,execEndOfVideo:b,listen:w,unlisten:d,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function $p(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let s=r.get(o);s&&s[l]!==void 0&&(s[l]=!0)},setData:(o=[])=>{var l;for(let s of o){let c=(l=s.endTime)!=null?l:Lp,f=r.get(c);r.set(c,{...f,[s.id]:!1})}},resetCalled:o=>{let l=r.get(o);if(l)for(let s in l)l[s]=!1},isReady:o=>{let l=r.get(o);return l?!(0,Ur.default)(l).some(s=>!s):!0},release:()=>r.clear()}}function $t(r){return(0,eo.default)((0,Ur.default)(r)).sort(e=>e.actionType===A.expect?-1:1)}var ro={videoContentHeight:0,videoContentWidth:0},io=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return ro;let{clientHeight:n,clientWidth:a}=e.experimental.element$.getValue()||{};if(!(n&&a))return ro;let o=t/i,l=n/a,s,c;return l>o?(c=a,s=a*o):l<o?(c=n/o,s=n):(c=a,s=n),{videoContentWidth:c,videoContentHeight:s}};var Np=250;function no(r){let e=()=>{},t=new ResizeObserver(l=>{a(l),e=a.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:f,videoContentHeight:b}=io(s,c);s.style.setProperty("--interactive-content-width",`${f}px`),s.style.setProperty("--interactive-content-height",`${b}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let a=Ne(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},Np);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var _p=r=>Math.floor(Math.random()*r),so=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:1;o<t&&(t=o,i=a)}return i},oo=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:0;o>t&&(t=o,i=a)}return i};var lo=r=>{let e=r.length,t=_p(e);return r[t]},ao=1,co=r=>{var i,n;let e=0;for(let a=0;a<r.length;++a)e+=(i=r[a].weight)!=null?i:ao;let t=Math.random()*e;e=0;for(let a=0;a<r.length-1;++a)if(e+=(n=r[a].weight)!=null?n:ao,e>=t)return r[a];return r[r.length-1]};var uo={shouldOpenNow:!0,isDetachContainer:!0},po="after-expect";var zr=(r,e=!1)=>({...r,args:e?{...r.args,...uo}:{...uo,...r.args}}),mo=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},a=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:u,controlType:h,controlId:m,containerId:C,branches:g=[],onEvent:y,isEOV:I=()=>!1,isDisabled:M=()=>!1})=>{let x=zr(u,I()),k={timestamp:1/0,priority:"control",initiator:m,actionType:x.type},H=M(),G=r.emit.bind(r,S.interactives,{subjectId:m,subjectType:h,subjectName:"control",type:H?O.actionChoiceCanceled:O.actionChoice,actionType:u.type,payload:{invokeImmediately:x.args.shouldOpenNow,containerId:C,...x.args}}),U=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:h,subjectName:"control",type:H?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:x.args.shouldOpenNow,containerId:C,...x.args}})};if(H){G(),U();return}switch(x.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let X=g.find(pe=>pe.id===x.args.branchId);if(!X)return;y(x.args.isDetachContainer,E.bind(null,{subjectId:m,subjectName:"control"})),G(),U(),x.args.shouldOpenNow?R({subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{chapterId:X.chapterId,autoSelect:!1}}):i.add({...k,action:R.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{chapterId:X.chapterId,autoSelect:!1}})});return}case A.continuePlayback.trim().toLowerCase():{y(x.args.isDetachContainer,E.bind(null,{subjectId:m,subjectName:"control"})),G(),U(),x.args.shouldOpenNow?w({subjectId:m,subjectName:"control",subjectType:h,action:u}):i.add({...k,action:w.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:u})});return}case A.openURI.trim().toLowerCase():{y(x.args.isDetachContainer,E.bind(null,{subjectId:m,subjectName:"control"})),G(),U(),x.args.shouldOpenNow?P({subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{URI:u.args.uri}}):i.add({...k,action:P.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{URI:u.args.uri}})});return}default:{let X="Unexpected control event",pe=new j(1,1,{message:X});f(pe,X);return}}},l=({action:u,container:{id:h,endTime:m},branches:C=[],isEOV:g=!1,autoSelected:y=!1})=>{let I=zr(u,g),M={timestamp:!I.args.shouldOpenNow||g?1/0:m!=null?m:1/0,priority:"container",initiator:h,actionType:I.type},x=r.emit.bind(r,S.interactives,{subjectId:h,subjectName:"container",type:O.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),k=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}})};switch(I.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let H=C.find(G=>G.id===I.args.branchId);if(!H)return;x(),k(),i.add({...M,action:R.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{chapterId:H.chapterId,autoSelect:y}})});return}case A.setMaxWeightBranch.trim().toLowerCase():return;case A.setMinWeightBranch.trim().toLowerCase():return;case A.setRandomBranch.trim().toLowerCase():return;case A.setWeightlessRandomBranch.trim().toLowerCase():return;case A.continuePlayback.trim().toLowerCase():{x(),k(),i.add({...M,action:w.bind(null,{subjectId:h,subjectName:"container",action:I})});return}case A.openURI.trim().toLowerCase():{x(),k(),i.add({...M,action:P.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{URI:u.args.uri}})});return}default:{let H="Unexpected container event",G=new j(1,1,{message:H});f(G,H);return}}};function s({container:u,branches:h,isEOV:m=!1}){var g,y;let C=jr(u.events);if(C){let I=zr(C.action,m);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:O.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),i.add({timestamp:m?1/0:(g=u.endTime)!=null?g:1/0,priority:"container",initiator:u.id,actionType:A.expect,action:d.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let I of(y=u.events)!=null?y:[])l({action:I.action,container:u,branches:h,isEOV:m})}let c=({chapterId:u,action:h,branches:m=[]})=>{let C=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:O.actionChoice,actionType:h.type,payload:h.args}),g=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let y=m.find(I=>I.id===h.args.branchId);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setWeightlessRandomBranch.trim().toLowerCase():{let y=lo(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setRandomBranch.trim().toLowerCase():{let y=co(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setMaxWeightBranch.trim().toLowerCase():{let y=oo(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setMinWeightBranch.trim().toLowerCase():{let y=so(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.continuePlayback.trim().toLowerCase():return C(),g(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h});case A.openURI.trim().toLowerCase():return C(),g(),P.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let y="Unexpected chapter event",I=new j(1,1,{message:y});f(I,y);return}}};function f(u,h){console.error(h),e.error$.next(u),r.emit(S.errors,u)}function b(u){var m;let h=jr(u.events);if(h){if(Q(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:O.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:A.expect,action:d.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(m=u.events)==null||m.forEach(C=>{let g=c({chapterId:u.id,action:C.action,branches:u.branches});g&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:C.action.type,action:g})})}let d=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:O.actionExecution,actionType:A.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:A.expect})},E=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:O.actionExecution,actionType:po}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:po})},w=({subjectId:u,subjectName:h,subjectType:m,action:C})=>{r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type})},R=({subjectId:u,subjectName:h,subjectType:m,action:C,payload:g})=>{g.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type,payload:g}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type,payload:g})},v=({subjectId:u,subjectName:h,subjectType:m,action:C,payload:g})=>{g.behaviour="change-manifest",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type,payload:g}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type,payload:g})},P=({subjectId:u,subjectName:h,subjectType:m,action:C,payload:g})=>{if(!g.URI)return;let y=window.open(g.URI,"_blank","noopener,noreferrer");y&&(y.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:d,expectEventHandler:E,setManifestChapterEvents:b,setManifestContainerEvents:s,stopExpect:a,state:n}};var Qr=Z(Sr(),1);import{Subscription as Hp,Subject as Kr,ValueSubject as Ke}from"@vkontakte/videoplayer-shared/es2018";var Wr=(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 a=e.media.videos.find(o=>n.videoId===o.id);if(!a)return null;t[i]=yo(a)}return t[i]}).filter(Boolean)},qp=r=>{for(let e of r.variants)if(Bp(e)&&e.payload)return e.payload.id},Bp=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),yo=r=>{let e=qp(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Dp=(r,e)=>{for(let t of r.media.videos)if(e===yo(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},vo=(r,e)=>r.reduce((t,i)=>{let n=Dp(e,i);return n?[...t,n]:t},[]);var ee,le,ce,D,Nt,te,re,Y,ue,Te,Se,Qe=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:a}){this.state={history$:new Ke([]),hasPrevChapter$:new Ke(!1),prevChapter$:new Ke(null),isInitialChapter$:new Ke(!1),isGoBackLimited$:new Ke(!1)};F(this,ee,null);F(this,le);F(this,ce,!1);F(this,D,null);F(this,Nt,null);this.events={inited$:new Kr,destroyed$:new Kr,error$:new Kr};F(this,te,null);F(this,re,null);F(this,Y,null);F(this,ue,new Hp);F(this,Te,!1);F(this,Se,0);var o;V(this,te,t),V(this,Y,e),V(this,re,i),V(this,ee,n),V(this,le,a),this.state.history$&&T(this,ue)&&((o=T(this,ue))==null||o.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,Qr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=T(this,D))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(T(this,Se)===T(this,le).maxLength-1)})))}async setManifest(e){if(!T(this,re)||!T(this,Y))return;V(this,D,e),await this.getProjectHistory();let t=this.getInitialChapterId();await T(this,re).setChapter({chapterId:t,pushToHistory:!1}),T(this,ce)||(V(this,ce,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return T(this,ce)}async updateHistory(e,t=!0){var l;if(!T(this,D))return;T(this,Te)?(V(this,Te,!1),si(this,Se)._++):V(this,Se,0);let i=T(this,D),n=e.length-T(this,le).maxLength,a=n>0?e.slice(n):e,o=Wr(a,i);if(V(this,Nt,o),this.state.history$.next(a),!(!t||!T(this,ee)||!T(this,te)))try{await T(this,ee).save(T(this,te),o)}catch(s){let c=new j(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=T(this,Y))==null||l.emit(S.errors,c)}}async goBack(){var i;if(!this.state||!T(this,re)){let n=new j(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=T(this,Y))==null?void 0:i.emit(S.errors,n)}V(this,Te,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await T(this,re).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!T(this,D)||!T(this,te))return;let e=T(this,D),t=[this.getInitialVideoId()];if(T(this,ee))try{let a=await T(this,ee).get(T(this,te));a.length&&(t=a)}catch(a){let o=new j(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=T(this,Y))==null||n.emit(S.errors,o)}let i=vo(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Qr.default)(e,-1)||T(this,le).initChapterId||((t=T(this,D))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(T(this,D)){let e=this.getInitialChapterId();return Wr([e],T(this,D)).pop()}return null}destroy(){var e,t;V(this,te,null),V(this,ee,null),V(this,re,null),(e=T(this,ue))==null||e.unsubscribe(),V(this,ue,null),V(this,ce,!1),(t=T(this,Y))==null||t.emit(S.historyDestroyed),this.events.destroyed$.next(),V(this,Y,null)}};ee=new WeakMap,le=new WeakMap,ce=new WeakMap,D=new WeakMap,Nt=new WeakMap,te=new WeakMap,re=new WeakMap,Y=new WeakMap,ue=new WeakMap,Te=new WeakMap,Se=new WeakMap;var _t=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 a=3;a<i;a+=40)if(t[a]!==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))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await 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 Ft=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
+ var To=Object.create;var ii=Object.defineProperty;var So=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var Ao=Object.getPrototypeOf,Ro=Object.prototype.hasOwnProperty;var ni=r=>{throw TypeError(r)};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Po=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wo(e))!Ro.call(r,n)&&n!==t&&ii(r,n,{get:()=>e[n],enumerable:!(i=So(e,n))||i.enumerable});return r};var Z=(r,e,t)=>(t=r!=null?To(Ao(r)):{},Po(e||!r||!r.__esModule?ii(t,"default",{value:r,enumerable:!0}):t,r));var ai=(r,e,t)=>e.has(r)||ni("Cannot "+t);var T=(r,e,t)=>(ai(r,e,"read from private field"),t?t.call(r):e.get(r)),F=(r,e,t)=>e.has(r)?ni("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),V=(r,e,t,i)=>(ai(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var si=(r,e,t,i)=>({set _(n){V(r,e,n,t)},get _(){return T(r,e,i)}});var K=p((Qt,di)=>{"use strict";var we=function(r){return r&&r.Math===Math&&r};di.exports=we(typeof globalThis=="object"&&globalThis)||we(typeof window=="object"&&window)||we(typeof self=="object"&&self)||we(typeof global=="object"&&global)||we(typeof Qt=="object"&&Qt)||function(){return this}()||Function("return this")()});var q=p(($h,fi)=>{"use strict";fi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ae=p((Nh,mi)=>{"use strict";var ko=q();mi.exports=!ko(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Ci=p((_h,gi)=>{"use strict";var Vo=Ae(),bi=Function.prototype,yi=bi.apply,vi=bi.call;gi.exports=typeof Reflect=="object"&&Reflect.apply||(Vo?vi.bind(yi):function(){return vi.apply(yi,arguments)})});var z=p((Fh,xi)=>{"use strict";var Ei=Ae(),Ii=Function.prototype,Yt=Ii.call,Mo=Ei&&Ii.bind.bind(Yt,Yt);xi.exports=Ei?Mo:function(r){return function(){return Yt.apply(r,arguments)}}});var Re=p((qh,Si)=>{"use strict";var Ti=z(),jo=Ti({}.toString),Lo=Ti("".slice);Si.exports=function(r){return Lo(jo(r),8,-1)}});var Xt=p((Bh,wi)=>{"use strict";var $o=Re(),No=z();wi.exports=function(r){if($o(r)==="Function")return No(r)}});var B=p((Dh,Ai)=>{"use strict";var Zt=typeof document=="object"&&document.all;Ai.exports=typeof Zt=="undefined"&&Zt!==void 0?function(r){return typeof r=="function"||r===Zt}:function(r){return typeof r=="function"}});var ne=p((Hh,Ri)=>{"use strict";var _o=q();Ri.exports=!_o(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ct=p((Gh,Pi)=>{"use strict";var Fo=Ae(),lt=Function.prototype.call;Pi.exports=Fo?lt.bind(lt):function(){return lt.apply(lt,arguments)}});var Jt=p(Vi=>{"use strict";var Oi={}.propertyIsEnumerable,ki=Object.getOwnPropertyDescriptor,qo=ki&&!Oi.call({1:2},1);Vi.f=qo?function(e){var t=ki(this,e);return!!t&&t.enumerable}:Oi});var er=p((zh,Mi)=>{"use strict";Mi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Li=p((Wh,ji)=>{"use strict";var Bo=z(),Do=q(),Ho=Re(),tr=Object,Go=Bo("".split);ji.exports=Do(function(){return!tr("z").propertyIsEnumerable(0)})?function(r){return Ho(r)==="String"?Go(r,""):tr(r)}:tr});var rr=p((Kh,$i)=>{"use strict";$i.exports=function(r){return r==null}});var ir=p((Qh,Ni)=>{"use strict";var Uo=rr(),zo=TypeError;Ni.exports=function(r){if(Uo(r))throw new zo("Can't call method on "+r);return r}});var Pe=p((Yh,_i)=>{"use strict";var Wo=Li(),Ko=ir();_i.exports=function(r){return Wo(Ko(r))}});var me=p((Xh,Fi)=>{"use strict";var Qo=B();Fi.exports=function(r){return typeof r=="object"?r!==null:Qo(r)}});var ut=p((Zh,qi)=>{"use strict";qi.exports={}});var pt=p((Jh,Di)=>{"use strict";var nr=ut(),ar=K(),Yo=B(),Bi=function(r){return Yo(r)?r:void 0};Di.exports=function(r,e){return arguments.length<2?Bi(nr[r])||Bi(ar[r]):nr[r]&&nr[r][e]||ar[r]&&ar[r][e]}});var Gi=p((ed,Hi)=>{"use strict";var Xo=z();Hi.exports=Xo({}.isPrototypeOf)});var Ki=p((td,Wi)=>{"use strict";var Zo=K(),Ui=Zo.navigator,zi=Ui&&Ui.userAgent;Wi.exports=zi?String(zi):""});var tn=p((rd,en)=>{"use strict";var Ji=K(),sr=Ki(),Qi=Ji.process,Yi=Ji.Deno,Xi=Qi&&Qi.versions||Yi&&Yi.version,Zi=Xi&&Xi.v8,W,ht;Zi&&(W=Zi.split("."),ht=W[0]>0&&W[0]<4?1:+(W[0]+W[1]));!ht&&sr&&(W=sr.match(/Edge\/(\d+)/),(!W||W[1]>=74)&&(W=sr.match(/Chrome\/(\d+)/),W&&(ht=+W[1])));en.exports=ht});var or=p((id,nn)=>{"use strict";var rn=tn(),Jo=q(),el=K(),tl=el.String;nn.exports=!!Object.getOwnPropertySymbols&&!Jo(function(){var r=Symbol("symbol detection");return!tl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&rn&&rn<41})});var lr=p((nd,an)=>{"use strict";var rl=or();an.exports=rl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var cr=p((ad,sn)=>{"use strict";var il=pt(),nl=B(),al=Gi(),sl=lr(),ol=Object;sn.exports=sl?function(r){return typeof r=="symbol"}:function(r){var e=il("Symbol");return nl(e)&&al(e.prototype,ol(r))}});var ln=p((sd,on)=>{"use strict";var ll=String;on.exports=function(r){try{return ll(r)}catch(e){return"Object"}}});var ur=p((od,cn)=>{"use strict";var cl=B(),ul=ln(),pl=TypeError;cn.exports=function(r){if(cl(r))return r;throw new pl(ul(r)+" is not a function")}});var pn=p((ld,un)=>{"use strict";var hl=ur(),dl=rr();un.exports=function(r,e){var t=r[e];return dl(t)?void 0:hl(t)}});var dn=p((cd,hn)=>{"use strict";var pr=ct(),hr=B(),dr=me(),fl=TypeError;hn.exports=function(r,e){var t,i;if(e==="string"&&hr(t=r.toString)&&!dr(i=pr(t,r))||hr(t=r.valueOf)&&!dr(i=pr(t,r))||e!=="string"&&hr(t=r.toString)&&!dr(i=pr(t,r)))return i;throw new fl("Can't convert object to primitive value")}});var mn=p((ud,fn)=>{"use strict";fn.exports=!0});var bn=p((pd,vn)=>{"use strict";var yn=K(),ml=Object.defineProperty;vn.exports=function(r,e){try{ml(yn,r,{value:e,configurable:!0,writable:!0})}catch(t){yn[r]=e}return e}});var dt=p((hd,En)=>{"use strict";var yl=mn(),vl=K(),bl=bn(),gn="__core-js_shared__",Cn=En.exports=vl[gn]||bl(gn,{});(Cn.versions||(Cn.versions=[])).push({version:"3.38.0",mode:yl?"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 fr=p((dd,xn)=>{"use strict";var In=dt();xn.exports=function(r,e){return In[r]||(In[r]=e||{})}});var Oe=p((fd,Tn)=>{"use strict";var gl=ir(),Cl=Object;Tn.exports=function(r){return Cl(gl(r))}});var ye=p((md,Sn)=>{"use strict";var El=z(),Il=Oe(),xl=El({}.hasOwnProperty);Sn.exports=Object.hasOwn||function(e,t){return xl(Il(e),t)}});var mr=p((yd,wn)=>{"use strict";var Tl=z(),Sl=0,wl=Math.random(),Al=Tl(1 .toString);wn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Al(++Sl+wl,36)}});var ke=p((vd,Rn)=>{"use strict";var Rl=K(),Pl=fr(),An=ye(),Ol=mr(),kl=or(),Vl=lr(),ve=Rl.Symbol,yr=Pl("wks"),Ml=Vl?ve.for||ve:ve&&ve.withoutSetter||Ol;Rn.exports=function(r){return An(yr,r)||(yr[r]=kl&&An(ve,r)?ve[r]:Ml("Symbol."+r)),yr[r]}});var Vn=p((bd,kn)=>{"use strict";var jl=ct(),Pn=me(),On=cr(),Ll=pn(),$l=dn(),Nl=ke(),_l=TypeError,Fl=Nl("toPrimitive");kn.exports=function(r,e){if(!Pn(r)||On(r))return r;var t=Ll(r,Fl),i;if(t){if(e===void 0&&(e="default"),i=jl(t,r,e),!Pn(i)||On(i))return i;throw new _l("Can't convert object to primitive value")}return e===void 0&&(e="number"),$l(r,e)}});var vr=p((gd,Mn)=>{"use strict";var ql=Vn(),Bl=cr();Mn.exports=function(r){var e=ql(r,"string");return Bl(e)?e:e+""}});var $n=p((Cd,Ln)=>{"use strict";var Dl=K(),jn=me(),br=Dl.document,Hl=jn(br)&&jn(br.createElement);Ln.exports=function(r){return Hl?br.createElement(r):{}}});var gr=p((Ed,Nn)=>{"use strict";var Gl=ne(),Ul=q(),zl=$n();Nn.exports=!Gl&&!Ul(function(){return Object.defineProperty(zl("div"),"a",{get:function(){return 7}}).a!==7})});var qn=p(Fn=>{"use strict";var Wl=ne(),Kl=ct(),Ql=Jt(),Yl=er(),Xl=Pe(),Zl=vr(),Jl=ye(),ec=gr(),_n=Object.getOwnPropertyDescriptor;Fn.f=Wl?_n:function(e,t){if(e=Xl(e),t=Zl(t),ec)try{return _n(e,t)}catch(i){}if(Jl(e,t))return Yl(!Kl(Ql.f,e,t),e[t])}});var Dn=p((xd,Bn)=>{"use strict";var tc=q(),rc=B(),ic=/#|\.prototype\./,Ve=function(r,e){var t=ac[nc(r)];return t===oc?!0:t===sc?!1:rc(e)?tc(e):!!e},nc=Ve.normalize=function(r){return String(r).replace(ic,".").toLowerCase()},ac=Ve.data={},sc=Ve.NATIVE="N",oc=Ve.POLYFILL="P";Bn.exports=Ve});var Cr=p((Td,Gn)=>{"use strict";var Hn=Xt(),lc=ur(),cc=Ae(),uc=Hn(Hn.bind);Gn.exports=function(r,e){return lc(r),e===void 0?r:cc?uc(r,e):function(){return r.apply(e,arguments)}}});var zn=p((Sd,Un)=>{"use strict";var pc=ne(),hc=q();Un.exports=pc&&hc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Kn=p((wd,Wn)=>{"use strict";var dc=me(),fc=String,mc=TypeError;Wn.exports=function(r){if(dc(r))return r;throw new mc(fc(r)+" is not an object")}});var Xn=p(Yn=>{"use strict";var yc=ne(),vc=gr(),bc=zn(),ft=Kn(),Qn=vr(),gc=TypeError,Er=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Ir="enumerable",xr="configurable",Tr="writable";Yn.f=yc?bc?function(e,t,i){if(ft(e),t=Qn(t),ft(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Tr in i&&!i[Tr]){var n=Cc(e,t);n&&n[Tr]&&(e[t]=i.value,i={configurable:xr in i?i[xr]:n[xr],enumerable:Ir in i?i[Ir]:n[Ir],writable:!1})}return Er(e,t,i)}:Er:function(e,t,i){if(ft(e),t=Qn(t),ft(i),vc)try{return Er(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new gc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Jn=p((Rd,Zn)=>{"use strict";var Ec=ne(),Ic=Xn(),xc=er();Zn.exports=Ec?function(r,e,t){return Ic.f(r,e,xc(1,t))}:function(r,e,t){return r[e]=t,r}});var je=p((Pd,ta)=>{"use strict";var Me=K(),Tc=Ci(),Sc=Xt(),wc=B(),Ac=qn().f,Rc=Dn(),be=ut(),Pc=Cr(),ge=Jn(),ea=ye();dt();var Oc=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 Tc(r,this,arguments)};return e.prototype=r.prototype,e};ta.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,a=r.proto,o=i?Me:n?Me[t]:Me[t]&&Me[t].prototype,l=i?be:be[t]||ge(be,t,{})[t],s=l.prototype,c,f,b,d,E,w,R,v,P;for(d in e)c=Rc(i?d:t+(n?".":"#")+d,r.forced),f=!c&&o&&ea(o,d),w=l[d],f&&(r.dontCallGetSet?(P=Ac(o,d),R=P&&P.value):R=o[d]),E=f&&R?R:e[d],!(!c&&!a&&typeof w==typeof E)&&(r.bind&&f?v=Pc(E,Me):r.wrap&&f?v=Oc(E):a&&wc(E)?v=Sc(E):v=E,(r.sham||E&&E.sham||w&&w.sham)&&ge(v,"sham",!0),ge(l,d,v),a&&(b=t+"Prototype",ea(be,b)||ge(be,b,{}),ge(be[b],d,E),r.real&&s&&(c||!s[d])&&ge(s,d,E)))}});var ia=p((Od,ra)=>{"use strict";var kc=Math.ceil,Vc=Math.floor;ra.exports=Math.trunc||function(e){var t=+e;return(t>0?Vc:kc)(t)}});var Le=p((kd,na)=>{"use strict";var Mc=ia();na.exports=function(r){var e=+r;return e!==e||e===0?0:Mc(e)}});var sa=p((Vd,aa)=>{"use strict";var jc=Le(),Lc=Math.min;aa.exports=function(r){var e=jc(r);return e>0?Lc(e,9007199254740991):0}});var $e=p((Md,oa)=>{"use strict";var $c=sa();oa.exports=function(r){return $c(r.length)}});var mt=p((jd,la)=>{"use strict";la.exports=function(){}});var ca=p(()=>{"use strict";var Nc=je(),_c=Oe(),Fc=$e(),qc=Le(),Bc=mt();Nc({target:"Array",proto:!0},{at:function(e){var t=_c(this),i=Fc(t),n=qc(e),a=n>=0?n:i+n;return a<0||a>=i?void 0:t[a]}});Bc("at")});var yt=p((Nd,ua)=>{"use strict";var Dc=pt();ua.exports=Dc});var ha=p((_d,pa)=>{"use strict";ca();var Hc=yt();pa.exports=Hc("Array","at")});var fa=p((Fd,da)=>{"use strict";var Gc=ha();da.exports=Gc});var Sr=p((qd,ma)=>{"use strict";var Uc=fa();ma.exports=Uc});var Oa=p((Jf,Pa)=>{"use strict";var tu=fr(),ru=mr(),Ra=tu("keys");Pa.exports=function(r){return Ra[r]||(Ra[r]=ru(r))}});var Va=p((em,ka)=>{"use strict";var iu=q();ka.exports=!iu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var La=p((tm,ja)=>{"use strict";var nu=ye(),au=B(),su=Oe(),ou=Oa(),lu=Va(),Ma=ou("IE_PROTO"),Lr=Object,cu=Lr.prototype;ja.exports=lu?Lr.getPrototypeOf:function(r){var e=su(r);if(nu(e,Ma))return e[Ma];var t=e.constructor;return au(t)&&e instanceof t?t.prototype:e instanceof Lr?cu:null}});var Na=p((rm,$a)=>{"use strict";var uu=Le(),pu=Math.max,hu=Math.min;$a.exports=function(r,e){var t=uu(r);return t<0?pu(t+e,0):hu(t,e)}});var $r=p((im,Fa)=>{"use strict";var du=Pe(),fu=Na(),mu=$e(),_a=function(r){return function(e,t,i){var n=du(e),a=mu(n);if(a===0)return!r&&-1;var o=fu(i,a),l;if(r&&t!==t){for(;a>o;)if(l=n[o++],l!==l)return!0}else for(;a>o;o++)if((r||o in n)&&n[o]===t)return r||o||0;return!r&&-1}};Fa.exports={includes:_a(!0),indexOf:_a(!1)}});var Ba=p((nm,qa)=>{"use strict";qa.exports={}});var Ga=p((am,Ha)=>{"use strict";var yu=z(),Nr=ye(),vu=Pe(),bu=$r().indexOf,gu=Ba(),Da=yu([].push);Ha.exports=function(r,e){var t=vu(r),i=0,n=[],a;for(a in t)!Nr(gu,a)&&Nr(t,a)&&Da(n,a);for(;e.length>i;)Nr(t,a=e[i++])&&(~bu(n,a)||Da(n,a));return n}});var za=p((sm,Ua)=>{"use strict";Ua.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ka=p((om,Wa)=>{"use strict";var Cu=Ga(),Eu=za();Wa.exports=Object.keys||function(e){return Cu(e,Eu)}});var es=p((lm,Ja)=>{"use strict";var Ya=ne(),Iu=q(),Xa=z(),xu=La(),Tu=Ka(),Su=Pe(),wu=Jt().f,Za=Xa(wu),Au=Xa([].push),Ru=Ya&&Iu(function(){var r=Object.create(null);return r[2]=2,!Za(r,2)}),Qa=function(r){return function(e){for(var t=Su(e),i=Tu(t),n=Ru&&xu(t)===null,a=i.length,o=0,l=[],s;a>o;)s=i[o++],(!Ya||(n?s in t:Za(t,s)))&&Au(l,r?[s,t[s]]:t[s]);return l}};Ja.exports={entries:Qa(!0),values:Qa(!1)}});var ts=p(()=>{"use strict";var Pu=je(),Ou=es().values;Pu({target:"Object",stat:!0},{values:function(e){return Ou(e)}})});var is=p((pm,rs)=>{"use strict";ts();var ku=ut();rs.exports=ku.Object.values});var as=p((hm,ns)=>{"use strict";var Vu=is();ns.exports=Vu});var Vt=p((dm,ss)=>{"use strict";var Mu=as();ss.exports=Mu});var cs=p(()=>{"use strict";var ju=je(),Lu=$r().includes,$u=q(),Nu=mt(),_u=$u(function(){return!Array(1).includes()});ju({target:"Array",proto:!0,forced:_u},{includes:function(e){return Lu(this,e,arguments.length>1?arguments[1]:void 0)}});Nu("includes")});var ps=p((bm,us)=>{"use strict";cs();var Fu=yt();us.exports=Fu("Array","includes")});var ds=p((gm,hs)=>{"use strict";var qu=ps();hs.exports=qu});var Mt=p((Cm,fs)=>{"use strict";var Bu=ds();fs.exports=Bu});var Dr=p((_m,gs)=>{"use strict";var Wu=Re();gs.exports=Array.isArray||function(e){return Wu(e)==="Array"}});var Es=p((Fm,Cs)=>{"use strict";var Ku=TypeError,Qu=9007199254740991;Cs.exports=function(r){if(r>Qu)throw Ku("Maximum allowed index exceeded");return r}});var Ts=p((qm,xs)=>{"use strict";var Yu=Dr(),Xu=$e(),Zu=Es(),Ju=Cr(),Is=function(r,e,t,i,n,a,o,l){for(var s=n,c=0,f=o?Ju(o,l):!1,b,d;c<i;)c in t&&(b=f?f(t[c],c,e):t[c],a>0&&Yu(b)?(d=Xu(b),s=Is(r,e,b,d,s,a-1)-1):(Zu(s+1),r[s]=b),s++),c++;return s};xs.exports=Is});var As=p((Bm,ws)=>{"use strict";var ep=ke(),tp=ep("toStringTag"),Ss={};Ss[tp]="z";ws.exports=String(Ss)==="[object z]"});var Ps=p((Dm,Rs)=>{"use strict";var rp=As(),ip=B(),Lt=Re(),np=ke(),ap=np("toStringTag"),sp=Object,op=Lt(function(){return arguments}())==="Arguments",lp=function(r,e){try{return r[e]}catch(t){}};Rs.exports=rp?Lt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=lp(e=sp(r),ap))=="string"?t:op?Lt(e):(i=Lt(e))==="Object"&&ip(e.callee)?"Arguments":i}});var ks=p((Hm,Os)=>{"use strict";var cp=z(),up=B(),Hr=dt(),pp=cp(Function.toString);up(Hr.inspectSource)||(Hr.inspectSource=function(r){return pp(r)});Os.exports=Hr.inspectSource});var Ns=p((Gm,$s)=>{"use strict";var hp=z(),dp=q(),Vs=B(),fp=Ps(),mp=pt(),yp=ks(),Ms=function(){},js=mp("Reflect","construct"),Gr=/^\s*(?:class|function)\b/,vp=hp(Gr.exec),bp=!Gr.test(Ms),We=function(e){if(!Vs(e))return!1;try{return js(Ms,[],e),!0}catch(t){return!1}},Ls=function(e){if(!Vs(e))return!1;switch(fp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return bp||!!vp(Gr,yp(e))}catch(t){return!0}};Ls.sham=!0;$s.exports=!js||dp(function(){var r;return We(We.call)||!We(Object)||!We(function(){r=!0})||r})?Ls:We});var Bs=p((Um,qs)=>{"use strict";var _s=Dr(),gp=Ns(),Cp=me(),Ep=ke(),Ip=Ep("species"),Fs=Array;qs.exports=function(r){var e;return _s(r)&&(e=r.constructor,gp(e)&&(e===Fs||_s(e.prototype))?e=void 0:Cp(e)&&(e=e[Ip],e===null&&(e=void 0))),e===void 0?Fs:e}});var Hs=p((zm,Ds)=>{"use strict";var xp=Bs();Ds.exports=function(r,e){return new(xp(r))(e===0?0:e)}});var Gs=p(()=>{"use strict";var Tp=je(),Sp=Ts(),wp=Oe(),Ap=$e(),Rp=Le(),Pp=Hs();Tp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=wp(this),i=Ap(t),n=Pp(t,0);return n.length=Sp(n,t,t,i,0,e===void 0?1:Rp(e)),n}})});var Us=p(()=>{"use strict";var Op=mt();Op("flat")});var Ws=p((Xm,zs)=>{"use strict";Gs();Us();var kp=yt();zs.exports=kp("Array","flat")});var Qs=p((Zm,Ks)=>{"use strict";var Vp=Ws();Ks.exports=Vp});var Xs=p((Jm,Ys)=>{"use strict";var Mp=Qs();Ys.exports=Mp});var oi="1.0.31-dev.0b1013c5.0";function Dt(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var $="interactive",Oo="interactive-controls-container",Ze=()=>document.querySelector(`.${Oo}`),li=.4,L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ci=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ci||{}),ui=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ui||{}),pi=(i=>(i.start="left",i.end="right",i.center="center",i))(pi||{}),Je=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&ci[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&ui[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&pi[e.alignment])!=null?n:"center"},et=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c;r.style.color=(a=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?a: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=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},tt=({target:r,props:e,fallback:t})=>{var i,n,a,o;r.style.backgroundColor=Dt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(a=e==null?void 0:e.background)==null?void 0:a.alpha)!=null?o:t.backgroundAlpha)},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c,f,b,d,E,w;r.style.border=`calc(${i.height} * ${(o=(a=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:a.width)!=null?o:t.borderWidth}) solid ${Dt((c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.color)!=null?c:t.borderColor,(d=(b=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:b.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(w=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?w:t.roundCorners})`},de=({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 J=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(`${$}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Ht="int",ie=(i=>(i.AREA=`${Ht}_area`,i.TEXT=`${Ht}_text`,i.BUTTON=`${Ht}_bttn`,i))(ie||{});var it=r=>{if(r.type.trim().toLowerCase()==="area")return new Gt(r)},Gt=class extends J{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(`${$}-${this.control.id}`),i.setAttribute("data-testid",ie.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:{...L,backgroundColor:"transparent"}}),rt({target:i,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions}),de({target:i,layoutParams:this.control.layoutParams,fallback:L}),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=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var at=r=>{if(r.type.trim().toLowerCase()==="button")return new Ut(r)},Ut=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${$}-${this.control.id}`),i.setAttribute("data-testid",ie.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",de({target:i,layoutParams:this.control.layoutParams,fallback:L}),tt({target:i,props:this.control.props,fallback:L}),rt({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),Je({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=nt(this.control.type.trim().toLowerCase()),a=(o=n.firstElementChild)!=null?o:n;et({target:a,props:this.control.props,fallback:L,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 hi=r=>{if(r.type.trim().toLowerCase()==="text")return new zt(r)},zt=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${$}-${this.control.id}`),i.setAttribute("data-testid",ie.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",de({target:i,layoutParams:this.control.layoutParams,fallback:L}),Je({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=nt(this.control.type.trim().toLowerCase()),a=(o=n.firstElementChild)!=null?o:n;et({target:a,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var Wt=class{constructor(e){this.layout=e}},st=class extends Wt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var fe=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(),a=this.factories.get(n);if(a){let o=a(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ot=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Kt(r,e)},Kt=class extends fe{constructor(e,t){super(e),this.rootElement=t!=null?t:Ze(),this.layout=new st(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",at),this.addControlFactory("text",hi),this.addControlFactory("area",it)}createView(e){let t=document.createElement("div");return t.classList.add(`${$}-${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=`${li}`,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(`.${$}-${this.container.id}`)}};var Io=Z(Sr(),1);import{clientChecker as Gp,combine as Up,InterfaceLanguage as zp,Observable as go,once as Wp,Subject as N,Subscription as Yr,ValueSubject as _,fromEvent as Co}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as Ye}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as zc}from"@vkontakte/videoplayer-shared/es2018";function Ne(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ae=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,_e=r=>ae(r,"Object"),vt=r=>ae(r,"String"),bt=r=>ae(r,"Array"),gt=r=>ae(r,"Number"),ya=r=>ae(r,"Function");var wr=r=>gt(r)&&!isNaN(r);var se=r=>_e(r)&&Object.keys(r).length===0,Ar=r=>bt(r)&&!r.length;var Fe=(r,e)=>vt(r)&&(e?r.trim():r).length;var va="video_interactive",ba="videoint";var ga=250,qe=class{constructor(e){this.handleZoomChange=Ne(e=>{this.lastZoomInfo=e},ga);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,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!gt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph");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:a=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(a),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=Wc(e),this.resizeObserver=new ResizeObserver(Ne(this.onResize,ga)),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)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var i;if(!this.manifest)return;let e;try{e=await zc(this.lang,va,ba)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=await 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.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...a})=>{var o;n==="openPreview"&&"chapterId"in a&&((o=this.onOpenPreviewClick)==null||o.call(this,a.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 Wc(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Be=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let a of this._containers){let o=a.startTime-e;if(o<=n&&(a.endTime&&n<=a.endTime||a.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};import{isSupportedManifest as Et,ContainerTypes as df,ControlTypes as It,EventActionTypes as A,EventTypes as ff,migrateManifestToLatestVersion as Ia,compareVersions as mf}from"@interactiveplatform/movika-manifest";var Ca={metadata:"Object",chapters:"Array"},Ea=r=>{if(!_e(r))return!1;for(let e in Ca)if(!r[e]||!ae(r[e],Ca[e]))return!1;return Et(r.metadata.version)},Ct=r=>r.type===It.Text,nf=r=>r.type===It.Button,af=r=>r.type===It.Area,sf={Choice:"Choice",TextInput:"TextInput"},of={Button:"Button",Area:"Area",Text:"Text"},lf={onClick:"onClick",onSuspense:"onSuspense"},cf={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var j=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var xt=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 Tt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{ya(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=[]}};import{ValueSubject as eu}from"@vkontakte/videoplayer-shared/es2018";var St=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:[]}}async exec(e,t){return Kc(...this.loaders[e])(t)}};function Kc(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function De(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function wt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let a=r.getChapter(n.chapters,t);if(a){let o=r.getMedia(n.media,a.videoId),l=r.getGraph(n.graph,a.id);return o?{...i,actions:r,errors:e,result:{chapter:a,media:o,graph:l}}:{...i,errors:De(e,wt.name,"Could not find media"),actions:r}}}}return{...i,errors:De(e,wt.name,"Could not find chapter"),actions:r}}var At=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,a=i.length;n<a;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,a=i.length;n<a;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}},Ce=class extends At{constructor(){super(),this.listeners||At.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},He=class{constructor(){Object.defineProperty(this,"signal",{value:new Ce,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(He.prototype[Symbol.toStringTag]="AbortController",Ce.prototype[Symbol.toStringTag]="AbortSignal");function Rt(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 Rr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Rt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||n)&&(a=function(c,f){let b;f&&f.signal&&(b=f.signal,delete f.signal);let d=new t(c,f);return b&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:b}),d},a.prototype=t.prototype);let o=e;return{fetch:(s,c)=>{let f=a&&a.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(f){let b;try{b=new DOMException("Aborted","AbortError")}catch(E){b=new Error("Aborted"),b.name="AbortError"}if(f.aborted)return Promise.reject(b);let d=new Promise((E,w)=>{f.addEventListener("abort",()=>w(b),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,o(s,c)])}return o(s,c)},Request:a}}var Ge=Rt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),xa=Ge?Rr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Pr=Ge?xa.fetch:window.fetch,Mf=Ge?xa.Request:window.Request,jf=Ge?He:window.AbortController,Lf=Ge?Ce:window.AbortSignal;var Or=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let a=0;a<Math.max(t.length,i.length)&&!n;a++)t[a]>i[a]?n=1:t[a]<i[a]?n=-1:n=0;return n};var Qc=async r=>{try{let e={},t;if(vt(r)){t=new URL(r).href;let n=await Pr(t);if(!n.ok)return{};e=await n.json()}else if(_e(r))e=r;else return{};if(!Ea(e))return{};let i=e.metadata.media;if(vt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let a=await Pr(n);if(!a.ok)throw new Error;e.metadata.media=await a.json()}catch(n){return Zc(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function Ta(r){let{manifest:e,manifestURL:t}=await Qc(r);if(!e)throw new Error("Failed on fetch");let i=Ia(e);return i.media=Yc(i.media,t),delete i.metadata.media,i}function Pt(r,e){if(e)return r.find(t=>t.id===e)}function kr(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function Vr(r,e){return r.videos.find(t=>t.id===e)}function Yc(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",a=Xc(n,e);return{...i,url:a||n}})}))}}function Xc(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zc(r){return Or(r,"3.2.0")>=0}var Ot=r=>bt(r)&&!Ar(r),Q=r=>r.order==="end",kt=r=>bt(r.containers)&&!Ar(r.containers)&&Q(r),Sa=(r,e)=>{var i;let t=r*1e3;return Ot(e.controls)&&t<((i=e.startTime)!=null?i:0)},Mr=(r,e)=>{var i,n;let t=r*1e3;return Ot(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var oe=(r=[])=>r.some(e=>e.action.type==="expect"),jr=(r=[])=>r.find(e=>e.action.type==="expect"),Jc=r=>(r==null?void 0:r.length)===1,Ee=r=>Jc(r)&&Ct(r[0]);function wa(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r({...e[0],...t}):r(...e,...t)}var Aa=(r,e)=>oe(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&oe(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Ie=class extends St{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new eu(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}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:De},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await Ta((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",wt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:kr,getChapter:Pt,getMedia:Vr,getByBranches:this.getByBranches.bind(this),addErrorMessage:De},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(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=Pt(this.manifest.chapters,t);if(n){let a=Vr(this.manifest.media,n.videoId),o=kr(this.manifest.graph,n.id);if(a)return{chapter:n,media:a,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,a,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((a=this.chapter)==null?void 0:a.branches);{let l=Pt(((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 a=this.getByChapterId(n.chapterId);return a&&i.push(a),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?Q(this.chapter):!1}};var ms=Z(Vt(),1);import{Player as Du}from"@vkontakte/videoplayer-core/es2018";import{Subscription as qr,Tracer as Hu,ValueSubject as Gu}from"@vkontakte/videoplayer-shared/es2018";var os=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var ls=Z(Vt(),1);function _r(){let r=new Map;function e({listId:a=Math.random().toString(),itemId:o=Math.random().toString(),...l}){let s=r.get(a),c={...l};return s?s[o]=c:r.set(a,{[o]:c}),{listId:a,itemId:o,...l}}function t(a){var o,l;a.player.destroy(),a.container.remove(),a.subscription.unsubscribe(),(o=a.statistics)==null||o.oneStat.destroy(),(l=a.statistics)==null||l.statSubscription.unsubscribe()}function i(a,o){let l=r.get(a);if(!l)throw Error("Can't remove. Not find.");if(o){let s=l[o];s&&t(s),delete l[o],Object.keys(l).length||r.delete(a)}else{for(let s of(0,ls.default)(l))t(s);r.delete(a)}}function n(){for(let a of r)i(a[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var xe=Z(Mt(),1);function Fr(r,e=[]){var a,o,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,xe.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(a=s.standard)!=null?a:"Invariant quality"]:s.url});break;case"mpeg":(n||(0,xe.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(o=s.standard)!=null?o:"Invariant quality"]:s.url});break;case"hls":(n||(0,xe.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(n||(0,xe.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Ue=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,xe.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Uu=2;function Br(r){let e=_r(),t=new qr,i={},n=null,a=!1,o,l=new Gu(null);r&&s(r);function s(v){n=v}function c(v,P,u){var C;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let m=((C=e.map.get(v))!=null?C:{})[P];if(m){i={chapterId:u,listId:v,itemId:P,...m};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(y=>{let I=g.info.position$.getValue(),M=g.info.isAutoQualityEnabled$.getValue();if(!(!y||!I||M))for(let x of e.map)(0,ms.default)(x[1]).forEach(({player:k})=>{Ue(k,y)})})).add(g.events.started$.subscribe(()=>{f(P)})),m.container.remove(),n.setPlayer(m.player),a||(n.init(),a=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function f(v){if(!n)throw Error("need to set interactive controller");if(se(i)||v!==i.itemId)return;let P=n.getChapterBranches(),u=new Set;for(let h of P)u.has(h.media.id)||(await d({media:h.media,chapterId:h.chapter.id,setAsActive:!1,title:h.chapter.label}),u.add(h.media.id))}async function b({chapter:{id:v},manifestVideo:P}){if(se(i)||!n)return;let u=i.player.info.muted$.getValue(),h=i.player.info.currentQuality$.getValue(),m=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),y=!m,I=!1;for(let M of e.map)if(M[0]===P.id&&!n.state.isReplay$.getValue()){let x=Object.keys(M[1]);for(let k of x)k===i.itemId?(x.length<Uu||(I=!0),e.removePlayer(M[0],k)):(I=!0,c(M[0],k,v),y?Ue(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(u),i.player.setPlaybackRate(g))}else e.removePlayer(M[0]);I||(await d({media:P,chapterId:v,setAsActive:!0,playbackRate:g}),y?Ue(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(u))}async function d({media:v,chapterId:P,prefetch:u=!0,setAsActive:h=!0,autoplay:m=!1,preferredExt:C,title:g,playbackRate:y}){var Xr,Zr,Jr,ei,ti;let I=Math.random().toString(),M=document.createElement("div");o.append(M);let x;if((Xr=n==null?void 0:n.options)!=null&&Xr.vkVideoLoader){let Xe=os(v);Xe.length&&(x=await n.options.vkVideoLoader(...Xe))}let k=((Zr=n==null?void 0:n.options)==null?void 0:Zr.coreConfig)||void 0,H={...k,configName:[...(Jr=k==null?void 0:k.configName)!=null?Jr:[],"interactive"]},G={container:M,...((ei=x==null?void 0:x.videos)==null?void 0:ei[0])||{sources:Fr(v,C).sources},title:g,failoverHosts:(x==null?void 0:x.failoverHosts)||[]},U=new Du(H,Hu.createRootTracer());U.initVideo(G);let X=null;if(x!=null&&x.videos&&(n!=null&&n.options.createOneStat)){let Xe=x.videos[0],Bt=n.options.createOneStat(Xe),ri=new qr;Bt&&(ri.add(Bt.attachTo(U)),X={oneStat:Bt,statSubscription:ri})}let pe=new qr,xo=(ti=i==null?void 0:i.player)==null?void 0:ti.info.isAutoQualityEnabled$.getValue();pe.add(U.events.canplay$.subscribe(function(){xo||Ue(U,i.player.info.currentQuality$.getValue()),y&&U.setPlaybackRate(y)}));let he=e.createPlayer({listId:v.id,itemId:I,player:U,container:M,sources:Fr(v,C).sources,config:G,subscription:pe,statistics:X});return h&&c(v.id,he.itemId,P),m&&he.player.play(),u&&!m&&he.player.prepare(),{player:he.player,config:he.config,statistics:he.statistics}}function E(){w(),n=null,o.remove()}function w(){t.unsubscribe(),e.removeAll(),i={},a=!1}async function R(){if(!n)throw Error("need to set interactive controller");w(),o=document.createElement("div");let{media:v,chapter:P}=n.getCurrentChapter();v&&P?(t.add(n.events.chapterChanged$.subscribe(b)),await d({media:v,chapterId:P.id,title:P.label})):console.error("not found")}return{...e,init:R,setInteractiveController:s,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:l}}var S={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},ze={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},O={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var vs=Z(Mt(),1);import{Subscription as zu}from"@vkontakte/videoplayer-shared/es2018";var jt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:a,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:s,permanentTextControls:c,disabledControls$:f,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(oe(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,a;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement())(i=(t=this.container).show)==null||i.call(t),this.emitContainerVisibilityEvent(!0,!1);else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(s,c)=>{this.isSelectedControlEvent=!0,s!==!1&&(this.removeView(),this.emitContainerVisibilityEvent(!1)),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.emitContainerVisibilityEvent(!1))},isEOV:()=>this.gameState===4},l=wa(this.selectBranches.onControlEvent,o);this.container.createView(l),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((a=(n=this.container).disable)==null||a.call(n))}};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||(0,vs.default)(n,this.gameState)&&!this.isPermanentText)return;let a=this.player.getExactTime();if(Sa(a,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Mr(a,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=Mr(a,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:a,isInteractiveTime:o};this.globalEventEmitter.emit(S.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new zu,this.player=e,this.interactiveEvents=a,this.ignoreContainerEvent=s,this.isPermanentText=c&&Ee(t.container.controls),this.disabledControls$=f,this.onRemove=b,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}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,a;e?(i=(t=this.container).disable)==null||i.call(t):(a=(n=this.container).enable)==null||a.call(n)}))}selectContainerEvent(e=!1){var t,i;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(t=this.container.container.endTime)!=null?t:1/0,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((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=oe(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.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),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 a,o,l;let n=((a=t==null?void 0:t.controls)!=null?a:[]).filter(s=>!Ct(s));if(Ot(n)){let s=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:s});else{let f=[],b=-1/0,d=1/0,E=[],w=[];for(let R=0;R<e.length;R++){let v=e[R];if(w.push(...v.subjects),v.range[0]<d&&(d=v.range[0]),v.range[1]>b&&(b=v.range[1]),s[0]>=v.range[0]&&s[1]<=v.range[1])return e[R].subjects.push(c),e;s[0]<v.range[0]&&s[1]>v.range[0]&&(f.push(R),E=E.concat(v.subjects)),s[0]>=v.range[0]&&s[0]<=v.range[1]&&(f.push(R),E=E.concat(v.subjects),s[0]=v.range[0]),s[1]>=v.range[0]&&s[1]<=v.range[1]&&(f.push(R),E=E.concat(v.subjects),s[1]=v.range[1])}if(w.push(c),s[0]<=d&&s[1]>=b)return[{subjects:w,range:s}];f.length&&f.reverse().forEach(R=>{e.splice(R,1)}),e.push({subjects:E.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Js=Z(Mt(),1),Ur=Z(Vt(),1),eo=Z(Xs(),1);function Zs(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var f;if(wr(l)){let b=(f=r[l])!=null?f:null;if(b&&s&&Fe(s,!0)){let d={},E=b[s];if(E&&(d={...d,...E}),d=se(d)?null:d,d&&Fe(c,!0)){let w=d[c];return w!=null?w:null}return d}return b}return null}function a({timestamp:l,priority:s,initiator:c}){if(wr(l))if(r[l]){if(s&&Fe(s,!0))if(r[l][s]){if(c&&Fe(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!se(r[l][s]))return!0}else return!1;if(delete r[l][s],!se(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o({timestamp:l,priority:s,initiator:c,...f}){var b,d,E;(d=(b=r[l])==null?void 0:b[s])!=null&&d[c]?r[l][s][c].push({...f}):(E=r[l])!=null&&E[s]?r[l][s]={...r[l][s],[c]:[{...f}]}:r[l]?r[l]={...r[l],[s]:{[c]:[{...f}]}}:r[l]={[s]:{[c]:[{...f}]}}}return{map:r,remove:a,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var jp=[A.expect,A.setNextBranch],Lp=1/0;function to(r){let e=r,t,i=$p(),n=Zs(),a,o=()=>{d(),P()},l=u=>{n.add.call(void 0,u),w()},s=(u=[])=>{for(let h of u)if(h.action(),(0,Js.default)(jp,h.actionType))break},c=(u=1/0)=>{var g,y,I;let h=$t((g=n.get({timestamp:u,priority:"control"}))!=null?g:{}),m=$t((y=n.get({timestamp:u,priority:"container"}))!=null?y:{}),C=$t((I=n.get({timestamp:u,priority:"chapter"}))!=null?I:{});return[...h,...m,...C]},f=u=>{i.isReady(u)&&s(c(u))},b=()=>{var u;s([...$t((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(a==null||a.unsubscribe(),t=void 0)},E=u=>{},w=()=>{t||(t=()=>setTimeout(()=>{f(1/0)}),a=e.events.ended$.subscribe(t))},R=u=>{d(),e=u},v=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},P=()=>{i.release(),n.removeAll()};return{setPlayer:R,add:l,remove:v,exec:f,execEndOfVideo:b,listen:w,unlisten:d,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function $p(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let s=r.get(o);s&&s[l]!==void 0&&(s[l]=!0)},setData:(o=[])=>{var l;for(let s of o){let c=(l=s.endTime)!=null?l:Lp,f=r.get(c);r.set(c,{...f,[s.id]:!1})}},resetCalled:o=>{let l=r.get(o);if(l)for(let s in l)l[s]=!1},isReady:o=>{let l=r.get(o);return l?!(0,Ur.default)(l).some(s=>!s):!0},release:()=>r.clear()}}function $t(r){return(0,eo.default)((0,Ur.default)(r)).sort(e=>e.actionType===A.expect?-1:1)}var ro={videoContentHeight:0,videoContentWidth:0},io=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return ro;let{clientHeight:n,clientWidth:a}=e.experimental.element$.getValue()||{};if(!(n&&a))return ro;let o=t/i,l=n/a,s,c;return l>o?(c=a,s=a*o):l<o?(c=n/o,s=n):(c=a,s=n),{videoContentWidth:c,videoContentHeight:s}};var Np=250;function no(r){let e=()=>{},t=new ResizeObserver(l=>{a(l),e=a.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:f,videoContentHeight:b}=io(s,c);s.style.setProperty("--interactive-content-width",`${f}px`),s.style.setProperty("--interactive-content-height",`${b}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let a=Ne(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},Np);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var _p=r=>Math.floor(Math.random()*r),so=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:1;o<t&&(t=o,i=a)}return i},oo=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:0;o>t&&(t=o,i=a)}return i};var lo=r=>{let e=r.length,t=_p(e);return r[t]},ao=1,co=r=>{var i,n;let e=0;for(let a=0;a<r.length;++a)e+=(i=r[a].weight)!=null?i:ao;let t=Math.random()*e;e=0;for(let a=0;a<r.length-1;++a)if(e+=(n=r[a].weight)!=null?n:ao,e>=t)return r[a];return r[r.length-1]};var uo={shouldOpenNow:!0,isDetachContainer:!0},po="after-expect";var zr=(r,e=!1)=>({...r,args:e?{...r.args,...uo}:{...uo,...r.args}}),mo=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},a=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:u,controlType:h,controlId:m,containerId:C,branches:g=[],onEvent:y,isEOV:I=()=>!1,isDisabled:M=()=>!1})=>{let x=zr(u,I()),k={timestamp:1/0,priority:"control",initiator:m,actionType:x.type},H=M(),G=r.emit.bind(r,S.interactives,{subjectId:m,subjectType:h,subjectName:"control",type:H?O.actionChoiceCanceled:O.actionChoice,actionType:u.type,payload:{invokeImmediately:x.args.shouldOpenNow,containerId:C,...x.args}}),U=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:h,subjectName:"control",type:H?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:x.args.shouldOpenNow,containerId:C,...x.args}})};if(H){G(),U();return}switch(x.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let X=g.find(pe=>pe.id===x.args.branchId);if(!X)return;y(x.args.isDetachContainer,E.bind(null,{subjectId:m,subjectName:"control"})),G(),U(),x.args.shouldOpenNow?R({subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{chapterId:X.chapterId,autoSelect:!1}}):i.add({...k,action:R.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{chapterId:X.chapterId,autoSelect:!1}})});return}case A.continuePlayback.trim().toLowerCase():{y(x.args.isDetachContainer,E.bind(null,{subjectId:m,subjectName:"control"})),G(),U(),x.args.shouldOpenNow?w({subjectId:m,subjectName:"control",subjectType:h,action:u}):i.add({...k,action:w.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:u})});return}case A.openURI.trim().toLowerCase():{y(x.args.isDetachContainer,E.bind(null,{subjectId:m,subjectName:"control"})),G(),U(),x.args.shouldOpenNow?P({subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{URI:u.args.uri}}):i.add({...k,action:P.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:x,payload:{URI:u.args.uri}})});return}default:{let X="Unexpected control event",pe=new j(1,1,{message:X});f(pe,X);return}}},l=({action:u,container:{id:h,endTime:m},branches:C=[],isEOV:g=!1,autoSelected:y=!1})=>{let I=zr(u,g),M={timestamp:!I.args.shouldOpenNow||g?1/0:m!=null?m:1/0,priority:"container",initiator:h,actionType:I.type},x=r.emit.bind(r,S.interactives,{subjectId:h,subjectName:"container",type:O.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),k=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}})};switch(I.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let H=C.find(G=>G.id===I.args.branchId);if(!H)return;x(),k(),i.add({...M,action:R.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{chapterId:H.chapterId,autoSelect:y}})});return}case A.setMaxWeightBranch.trim().toLowerCase():return;case A.setMinWeightBranch.trim().toLowerCase():return;case A.setRandomBranch.trim().toLowerCase():return;case A.setWeightlessRandomBranch.trim().toLowerCase():return;case A.continuePlayback.trim().toLowerCase():{x(),k(),i.add({...M,action:w.bind(null,{subjectId:h,subjectName:"container",action:I})});return}case A.openURI.trim().toLowerCase():{x(),k(),i.add({...M,action:P.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{URI:u.args.uri}})});return}default:{let H="Unexpected container event",G=new j(1,1,{message:H});f(G,H);return}}};function s({container:u,branches:h,isEOV:m=!1}){var g,y;let C=jr(u.events);if(C){let I=zr(C.action,m);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:O.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),i.add({timestamp:m?1/0:(g=u.endTime)!=null?g:1/0,priority:"container",initiator:u.id,actionType:A.expect,action:d.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let I of(y=u.events)!=null?y:[])l({action:I.action,container:u,branches:h,isEOV:m})}let c=({chapterId:u,action:h,branches:m=[]})=>{let C=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:O.actionChoice,actionType:h.type,payload:h.args}),g=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let y=m.find(I=>I.id===h.args.branchId);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setWeightlessRandomBranch.trim().toLowerCase():{let y=lo(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setRandomBranch.trim().toLowerCase():{let y=co(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setMaxWeightBranch.trim().toLowerCase():{let y=oo(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setMinWeightBranch.trim().toLowerCase():{let y=so(m);return y!=null&&y.chapterId?(C(),g(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.continuePlayback.trim().toLowerCase():return C(),g(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h});case A.openURI.trim().toLowerCase():return C(),g(),P.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let y="Unexpected chapter event",I=new j(1,1,{message:y});f(I,y);return}}};function f(u,h){console.error(h),e.error$.next(u),r.emit(S.errors,u)}function b(u){var m;let h=jr(u.events);if(h){if(Q(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:O.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:A.expect,action:d.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(m=u.events)==null||m.forEach(C=>{let g=c({chapterId:u.id,action:C.action,branches:u.branches});g&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:C.action.type,action:g})})}let d=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:O.actionExecution,actionType:A.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:A.expect})},E=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:O.actionExecution,actionType:po}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:po})},w=({subjectId:u,subjectName:h,subjectType:m,action:C})=>{r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type})},R=({subjectId:u,subjectName:h,subjectType:m,action:C,payload:g})=>{g.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type,payload:g}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type,payload:g})},v=({subjectId:u,subjectName:h,subjectType:m,action:C,payload:g})=>{g.behaviour="change-manifest",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type,payload:g}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type,payload:g})},P=({subjectId:u,subjectName:h,subjectType:m,action:C,payload:g})=>{if(!g.URI)return;let y=window.open(g.URI,"_blank","noopener,noreferrer");y&&(y.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:C.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:d,expectEventHandler:E,setManifestChapterEvents:b,setManifestContainerEvents:s,stopExpect:a,state:n}};var Qr=Z(Sr(),1);import{Subscription as Hp,Subject as Kr,ValueSubject as Ke}from"@vkontakte/videoplayer-shared/es2018";var Wr=(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 a=e.media.videos.find(o=>n.videoId===o.id);if(!a)return null;t[i]=yo(a)}return t[i]}).filter(Boolean)},qp=r=>{for(let e of r.variants)if(Bp(e)&&e.payload)return e.payload.id},Bp=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),yo=r=>{let e=qp(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Dp=(r,e)=>{for(let t of r.media.videos)if(e===yo(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},vo=(r,e)=>r.reduce((t,i)=>{let n=Dp(e,i);return n?[...t,n]:t},[]);var ee,le,ce,D,Nt,te,re,Y,ue,Te,Se,Qe=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:a}){this.state={history$:new Ke([]),hasPrevChapter$:new Ke(!1),prevChapter$:new Ke(null),isInitialChapter$:new Ke(!1),isGoBackLimited$:new Ke(!1)};F(this,ee,null);F(this,le);F(this,ce,!1);F(this,D,null);F(this,Nt,null);this.events={inited$:new Kr,destroyed$:new Kr,error$:new Kr};F(this,te,null);F(this,re,null);F(this,Y,null);F(this,ue,new Hp);F(this,Te,!1);F(this,Se,0);var o;V(this,te,t),V(this,Y,e),V(this,re,i),V(this,ee,n),V(this,le,a),this.state.history$&&T(this,ue)&&((o=T(this,ue))==null||o.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,Qr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=T(this,D))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(T(this,Se)===T(this,le).maxLength-1)})))}async setManifest(e){if(!T(this,re)||!T(this,Y))return;V(this,D,e),await this.getProjectHistory();let t=this.getInitialChapterId();await T(this,re).setChapter({chapterId:t,pushToHistory:!1}),T(this,ce)||(V(this,ce,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return T(this,ce)}async updateHistory(e,t=!0){var l;if(!T(this,D))return;T(this,Te)?(V(this,Te,!1),si(this,Se)._++):V(this,Se,0);let i=T(this,D),n=e.length-T(this,le).maxLength,a=n>0?e.slice(n):e,o=Wr(a,i);if(V(this,Nt,o),this.state.history$.next(a),!(!t||!T(this,ee)||!T(this,te)))try{await T(this,ee).save(T(this,te),o)}catch(s){let c=new j(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=T(this,Y))==null||l.emit(S.errors,c)}}async goBack(){var i;if(!this.state||!T(this,re)){let n=new j(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=T(this,Y))==null?void 0:i.emit(S.errors,n)}V(this,Te,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await T(this,re).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!T(this,D)||!T(this,te))return;let e=T(this,D),t=[this.getInitialVideoId()];if(T(this,ee))try{let a=await T(this,ee).get(T(this,te));a.length&&(t=a)}catch(a){let o=new j(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=T(this,Y))==null||n.emit(S.errors,o)}let i=vo(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Qr.default)(e,-1)||T(this,le).initChapterId||((t=T(this,D))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(T(this,D)){let e=this.getInitialChapterId();return Wr([e],T(this,D)).pop()}return null}destroy(){var e,t;V(this,te,null),V(this,ee,null),V(this,re,null),(e=T(this,ue))==null||e.unsubscribe(),V(this,ue,null),V(this,ce,!1),(t=T(this,Y))==null||t.emit(S.historyDestroyed),this.events.destroyed$.next(),V(this,Y,null)}};ee=new WeakMap,le=new WeakMap,ce=new WeakMap,D=new WeakMap,Nt=new WeakMap,te=new WeakMap,re=new WeakMap,Y=new WeakMap,ue=new WeakMap,Te=new WeakMap,Se=new WeakMap;var _t=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 a=3;a<i;a+=40)if(t[a]!==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))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await 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 Ft=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;
@@ -20,4 +20,4 @@ var To=Object.create;var ii=Object.defineProperty;var So=Object.getOwnPropertyDe
20
20
  position: absolute;
21
21
  top: 0;
22
22
  left: 0;
23
- `,r}var qt=class{constructor(e){this.playerSubscriptions=new Yr;this.subscriptions=new Yr;this.globalEventEmitter=new xt;this.animation=new Tt;this.seekToInteractiveController=new Be;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Kp();this.factories=new Map([["choice",ot]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Yr;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new _(null),isInitialChapter$:new _(!1),isFirstChapter$:new _(!0),isEndChapter$:new _(!1),isInteractiveExpectation$:new _(!1),isReplay$:new _(!1),calledByInteractive$:new _(!1),lastChapterChangeWasInitiatedByInteractive$:new _(!1),disabledControls$:new _(!1),interactiveRanges$:new _([]),isInteractiveTime$:new _(!1),statistics$:new _(null),isSeekable$:new _(!1)};this.events={noInteraction$:new N,graphVisibilityChanged$:new N,watchAgainIsClicked$:new N,chapterChanged$:new N,playerChanged$:new N,error$:new N,eachTick$:new N,manifestChanged$:new N,interactiveRangeEnded$:new N,interactiveContainerRemoved$:new N,interactiveActionExecution$:new N,interactiveActionChoice$:new N,interactiveVisibilityChanged$:new N};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&Q(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:a}=t;n.add(a.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(S.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(a=>({...a,subjects:a.subjects.filter(o=>o!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options={...Eo,...e,config:{...Eo.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new Qe({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(t=this._options.projectInfo)==null?void 0:t.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Ft({parentElement:this._options.parentElement,onError:i=>{let n=new j(1,6,i);this.emitErrorEvent(n)}})),this.subscriptions.add(Co(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(Co(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new Ie(this._options.loaders,i=>{let n=new j(1,3,i);this.emitErrorEvent(n)}),this.resizeManager=no(()=>{var i,n;return{player:this.player,parentElement:(i=this._options)==null?void 0:i.parentElement,fns:(n=this._options)!=null&&n.lastFrame?[()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}]:[]}}),this._options.graph&&(this.graph=new qe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(S.graph,{type:ze.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let n=new j(1,4,{message:i});this.emitErrorEvent(n)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.removeControllers(!1)}))}async initSeamless(){this.seamlessController=Br(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:a})=>t>=a[1]);if(n){let a=n.range.join("-");this.endedRanges.has(a)||(this.endedRanges.add(a),this.globalEventEmitter.emit(S.interactives,{type:O.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(Wp()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(Up({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var s;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[b,d],subjects:E})=>b<c&&c<d&&E.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let a=!!this.noInteractionTimeout,l=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||i;n&&!a&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):a&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Ee(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),a=this.factories.get(n),o=a==null?void 0:a(i,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let l=new jt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Aa(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(l=i&&Q(i)&&kt(i))!=null?l:!1,a=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(a||n&&t){this.historyController.updateHistory([e]);return}(0,Io.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(S.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=to(this.player),this.selectBranches=mo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),Gp.isSafari&&await bo(35);let n=!i&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:a,media:o,graph:l}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!a||!o)&&(t&&this.pushChapterToHistory(a.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(a),(c=this.lastFrame)==null||c.setCurrentChapter(a),this.events.chapterChanged$.next({chapter:a,manifestVideo:o}),this.globalEventEmitter.emit(S.chapterChanged,{chapter:a,media:o,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new go(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ye.GRAPH_SHOW:Ye.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ye.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Ye.NEXT_BUTTON),n==="Area"&&e.next(Ye.NEXT_AREA))}))}),nextMovie$:new go(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(S.graph,{type:ze.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===A.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&n.endTime===null&&oe(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&Et(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return bs((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,a;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(n=this.interactiveEvents)==null||n.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Qp={Container:fe,createChoiceContainer:ot,createAreaControl:it,createButtonControl:at,getRootEl:Ze,classnamesPrefix:$};var lv={version:oi};export{df as ContainerTypes,It as ControlTypes,j as CustomError,S as EVENT_NAMES,A as EventActionTypes,ff as EventTypes,qt as Interactives,Ie as ManifestController,lv as SDKInfo,Wr as chapterIdsToVKVideoIds,Or as compareVersions,sf as containerTypes,of as controlTypes,cf as eventActionTypes,lf as eventTypes,Dp as getChapterIdByVkVideoId,yo as getVKVideoIdByMedia,qp as getVideoRawIdByMedia,ze as graphEventTypes,kt as hasEndTemplate,O as interactivesEventTypes,af as isAreaControl,nf as isButtonControl,Q as isLastChapter,Ee as isOneTextCtrlContainer,Et as isSupportedManifest,Ct as isTextControl,Bp as isVKVariantItem,Ea as isValidManifest,Ia as migrateManifestToLatestVersion,Qp as utils,vo as vkVideoIdsToChapterIds};
23
+ `,r}var qt=class{constructor(e){this.playerSubscriptions=new Yr;this.subscriptions=new Yr;this.globalEventEmitter=new xt;this.animation=new Tt;this.seekToInteractiveController=new Be;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Kp();this.factories=new Map([["choice",ot]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Yr;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new _(null),isInitialChapter$:new _(!1),isFirstChapter$:new _(!0),isEndChapter$:new _(!1),isInteractiveExpectation$:new _(!1),isReplay$:new _(!1),calledByInteractive$:new _(!1),lastChapterChangeWasInitiatedByInteractive$:new _(!1),disabledControls$:new _(!1),interactiveRanges$:new _([]),isInteractiveTime$:new _(!1),statistics$:new _(null),isSeekable$:new _(!1)};this.events={noInteraction$:new N,graphVisibilityChanged$:new N,watchAgainIsClicked$:new N,chapterChanged$:new N,playerChanged$:new N,error$:new N,eachTick$:new N,manifestChanged$:new N,interactiveRangeEnded$:new N,interactiveContainerRemoved$:new N,interactiveActionExecution$:new N,interactiveActionChoice$:new N,interactiveVisibilityChanged$:new N};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&Q(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:a}=t;n.add(a.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(S.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(a=>({...a,subjects:a.subjects.filter(o=>o!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options={...Eo,...e,config:{...Eo.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new Qe({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(t=this._options.projectInfo)==null?void 0:t.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Ft({parentElement:this._options.parentElement,onError:i=>{let n=new j(1,6,i);this.emitErrorEvent(n)}})),this.subscriptions.add(Co(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(Co(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new Ie(this._options.loaders,i=>{let n=new j(1,3,i);this.emitErrorEvent(n)}),this.resizeManager=no(()=>{var i,n;return{player:this.player,parentElement:(i=this._options)==null?void 0:i.parentElement,fns:(n=this._options)!=null&&n.lastFrame?[()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}]:[]}}),this._options.graph&&(this.graph=new qe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(S.graph,{type:ze.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let n=new j(1,2,{message:i});this.emitErrorEvent(n)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.removeControllers(!1)}))}async initSeamless(){this.seamlessController=Br(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:a})=>t>=a[1]);if(n){let a=n.range.join("-");this.endedRanges.has(a)||(this.endedRanges.add(a),this.globalEventEmitter.emit(S.interactives,{type:O.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(Wp()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(Up({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var s;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[b,d],subjects:E})=>b<c&&c<d&&E.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let a=!!this.noInteractionTimeout,l=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||i;n&&!a&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):a&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Ee(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),a=this.factories.get(n),o=a==null?void 0:a(i,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let l=new jt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Aa(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(l=i&&Q(i)&&kt(i))!=null?l:!1,a=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(a||n&&t){this.historyController.updateHistory([e]);return}(0,Io.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(S.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=to(this.player),this.selectBranches=mo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),Gp.isSafari&&await bo(35);let n=!i&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:a,media:o,graph:l}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!a||!o)&&(t&&this.pushChapterToHistory(a.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(a),(c=this.lastFrame)==null||c.setCurrentChapter(a),this.events.chapterChanged$.next({chapter:a,manifestVideo:o}),this.globalEventEmitter.emit(S.chapterChanged,{chapter:a,media:o,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new go(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ye.GRAPH_SHOW:Ye.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ye.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Ye.NEXT_BUTTON),n==="Area"&&e.next(Ye.NEXT_AREA))}))}),nextMovie$:new go(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(S.graph,{type:ze.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===A.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&n.endTime===null&&oe(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&Et(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return bs((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,a;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(n=this.interactiveEvents)==null||n.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Qp={Container:fe,createChoiceContainer:ot,createAreaControl:it,createButtonControl:at,getRootEl:Ze,classnamesPrefix:$};var lv={version:oi};export{df as ContainerTypes,It as ControlTypes,j as CustomError,S as EVENT_NAMES,A as EventActionTypes,ff as EventTypes,qt as Interactives,Ie as ManifestController,lv as SDKInfo,Wr as chapterIdsToVKVideoIds,Or as compareVersions,sf as containerTypes,of as controlTypes,cf as eventActionTypes,lf as eventTypes,Dp as getChapterIdByVkVideoId,yo as getVKVideoIdByMedia,qp as getVideoRawIdByMedia,ze as graphEventTypes,kt as hasEndTemplate,O as interactivesEventTypes,af as isAreaControl,nf as isButtonControl,Q as isLastChapter,Ee as isOneTextCtrlContainer,Et as isSupportedManifest,Ct as isTextControl,Bp as isVKVariantItem,Ea as isValidManifest,Ia as migrateManifestToLatestVersion,Qp as utils,vo as vkVideoIdsToChapterIds};