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