@vkontakte/videoplayer-interactive 1.0.30-dev.f10d9ff4.0 → 1.0.30-dev.f55796c8.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.
Files changed (37) hide show
  1. package/es2015.cjs.js +5 -196
  2. package/es2015.esm.js +6 -197
  3. package/es2018.cjs.js +6 -197
  4. package/es2018.esm.js +5 -196
  5. package/esnext.cjs.js +6 -197
  6. package/esnext.esm.js +6 -197
  7. package/evergreen.esm.js +6 -197
  8. package/package.json +4 -4
  9. package/types/modules/Interactives/Interactives.d.ts +9 -19
  10. package/types/modules/Interactives/Layout.d.ts +0 -4
  11. package/types/modules/Interactives/containers/ChoiceContainer.d.ts +7 -16
  12. package/types/modules/Interactives/containers/Container.d.ts +6 -9
  13. package/types/modules/Interactives/controls/AreaControl.d.ts +2 -22
  14. package/types/modules/Interactives/controls/ButtonControl.d.ts +2 -27
  15. package/types/modules/Interactives/controls/Control.d.ts +9 -22
  16. package/types/modules/Interactives/controls/types.d.ts +7 -21
  17. package/types/modules/Interactives/index.d.ts +4 -69
  18. package/types/modules/Interactives/types.d.ts +12 -12
  19. package/types/modules/Interactives/utils/GameController.d.ts +12 -16
  20. package/types/modules/Interactives/utils/InteractiveEvents.d.ts +3 -3
  21. package/types/modules/Interactives/utils/SelectBranches.d.ts +1 -2
  22. package/types/modules/Interactives/utils/SelectBranches.types.d.ts +0 -1
  23. package/types/modules/Interactives/utils/events.d.ts +1 -0
  24. package/types/modules/Interactives/utils/events.types.d.ts +1 -3
  25. package/types/modules/Interactives/utils/gameUtils.d.ts +2 -1
  26. package/types/modules/Interactives/utils/getInteractiveRanges.d.ts +5 -1
  27. package/types/modules/Interactives/utils/renderingUtils.d.ts +3 -15
  28. package/types/utils/Binding.d.ts +34 -0
  29. package/types/utils/EventManager.d.ts +13 -0
  30. package/types/utils/getVideoContentSize.d.ts +1 -1
  31. package/types/modules/Interactives/styles.d.ts +0 -1
  32. package/types/modules/Interactives/utils/BlinkAnimationReference.d.ts +0 -2
  33. package/types/modules/Interactives/utils/FillAnimation.d.ts +0 -29
  34. package/types/modules/Interactives/utils/TapElement.d.ts +0 -10
  35. package/types/utils/AverageColor/FrameAverageColor.d.ts +0 -19
  36. package/types/utils/AverageColor/helpers.d.ts +0 -17
  37. package/types/utils/AverageColor/index.d.ts +0 -2
package/es2015.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.30-dev.f10d9ff4.0
3
- * Wed, 29 Jan 2025 15:55:51 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.30-dev.f55796c8.0
3
+ * Wed, 05 Feb 2025 12:44:42 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-30/doc/
5
5
  */
6
- var Ks=Object.create;var Jt=Object.defineProperty,Qs=Object.defineProperties,Xs=Object.getOwnPropertyDescriptor,Ys=Object.getOwnPropertyDescriptors,Zs=Object.getOwnPropertyNames,lt=Object.getOwnPropertySymbols,Js=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty,gi=Object.prototype.propertyIsEnumerable;var Ci=r=>{throw TypeError(r)};var bi=(r,e,t)=>e in r?Jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))er.call(e,t)&&bi(r,t,e[t]);if(lt)for(var t of lt(e))gi.call(e,t)&&bi(r,t,e[t]);return r},C=(r,e)=>Qs(r,Ys(e));var K=(r,e)=>{var t={};for(var i in r)er.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&lt)for(var i of lt(r))e.indexOf(i)<0&&gi.call(r,i)&&(t[i]=r[i]);return t};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var el=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Zs(e))!er.call(r,n)&&n!==t&&Jt(r,n,{get:()=>e[n],enumerable:!(i=Xs(e,n))||i.enumerable});return r};var te=(r,e,t)=>(t=r!=null?Ks(Js(r)):{},el(e||!r||!r.__esModule?Jt(t,"default",{value:r,enumerable:!0}):t,r));var Ei=(r,e,t)=>e.has(r)||Ci("Cannot "+t);var x=(r,e,t)=>(Ei(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?Ci("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,i)=>(Ei(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Ti=(r,e,t,i)=>({set _(n){j(r,e,n,t)},get _(){return x(r,e,i)}});var R=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{a(t.next(l))}catch(c){n(c)}},s=l=>{try{a(t.throw(l))}catch(c){n(c)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);a((t=t.apply(r,e)).next())});var Z=u((cr,Fi)=>{"use strict";var je=function(r){return r&&r.Math===Math&&r};Fi.exports=je(typeof globalThis=="object"&&globalThis)||je(typeof window=="object"&&window)||je(typeof self=="object"&&self)||je(typeof global=="object"&&global)||je(typeof cr=="object"&&cr)||function(){return this}()||Function("return this")()});var z=u((Hd,$i)=>{"use strict";$i.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ne=u((Gd,ji)=>{"use strict";var il=z();ji.exports=!il(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Di=u((zd,Bi)=>{"use strict";var nl=Ne(),qi=Function.prototype,Ni=qi.apply,_i=qi.call;Bi.exports=typeof Reflect=="object"&&Reflect.apply||(nl?_i.bind(Ni):function(){return _i.apply(Ni,arguments)})});var Q=u((Ud,zi)=>{"use strict";var Hi=Ne(),Gi=Function.prototype,ur=Gi.call,ol=Hi&&Gi.bind.bind(ur,ur);zi.exports=Hi?ol:function(r){return function(){return ur.apply(r,arguments)}}});var _e=u((Wd,Wi)=>{"use strict";var Ui=Q(),al=Ui({}.toString),sl=Ui("".slice);Wi.exports=function(r){return sl(al(r),8,-1)}});var hr=u((Kd,Ki)=>{"use strict";var ll=_e(),cl=Q();Ki.exports=function(r){if(ll(r)==="Function")return cl(r)}});var U=u((Qd,Qi)=>{"use strict";var pr=typeof document=="object"&&document.all;Qi.exports=typeof pr=="undefined"&&pr!==void 0?function(r){return typeof r=="function"||r===pr}:function(r){return typeof r=="function"}});var pe=u((Xd,Xi)=>{"use strict";var ul=z();Xi.exports=!ul(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var wt=u((Yd,Yi)=>{"use strict";var hl=Ne(),xt=Function.prototype.call;Yi.exports=hl?xt.bind(xt):function(){return xt.apply(xt,arguments)}});var dr=u(en=>{"use strict";var Zi={}.propertyIsEnumerable,Ji=Object.getOwnPropertyDescriptor,pl=Ji&&!Zi.call({1:2},1);en.f=pl?function(e){var t=Ji(this,e);return!!t&&t.enumerable}:Zi});var mr=u((Jd,tn)=>{"use strict";tn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var nn=u((em,rn)=>{"use strict";var dl=Q(),ml=z(),fl=_e(),fr=Object,vl=dl("".split);rn.exports=ml(function(){return!fr("z").propertyIsEnumerable(0)})?function(r){return fl(r)==="String"?vl(r,""):fr(r)}:fr});var vr=u((tm,on)=>{"use strict";on.exports=function(r){return r==null}});var yr=u((rm,an)=>{"use strict";var yl=vr(),bl=TypeError;an.exports=function(r){if(yl(r))throw new bl("Can't call method on "+r);return r}});var qe=u((im,sn)=>{"use strict";var gl=nn(),Cl=yr();sn.exports=function(r){return gl(Cl(r))}});var Ee=u((nm,ln)=>{"use strict";var El=U();ln.exports=function(r){return typeof r=="object"?r!==null:El(r)}});var St=u((om,cn)=>{"use strict";cn.exports={}});var At=u((am,hn)=>{"use strict";var br=St(),gr=Z(),Tl=U(),un=function(r){return Tl(r)?r:void 0};hn.exports=function(r,e){return arguments.length<2?un(br[r])||un(gr[r]):br[r]&&br[r][e]||gr[r]&&gr[r][e]}});var dn=u((sm,pn)=>{"use strict";var Il=Q();pn.exports=Il({}.isPrototypeOf)});var yn=u((lm,vn)=>{"use strict";var xl=Z(),mn=xl.navigator,fn=mn&&mn.userAgent;vn.exports=fn?String(fn):""});var xn=u((cm,In)=>{"use strict";var Tn=Z(),Cr=yn(),bn=Tn.process,gn=Tn.Deno,Cn=bn&&bn.versions||gn&&gn.version,En=Cn&&Cn.v8,X,Rt;En&&(X=En.split("."),Rt=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!Rt&&Cr&&(X=Cr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=Cr.match(/Chrome\/(\d+)/),X&&(Rt=+X[1])));In.exports=Rt});var Er=u((um,Sn)=>{"use strict";var wn=xn(),wl=z(),Sl=Z(),Al=Sl.String;Sn.exports=!!Object.getOwnPropertySymbols&&!wl(function(){var r=Symbol("symbol detection");return!Al(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&wn&&wn<41})});var Tr=u((hm,An)=>{"use strict";var Rl=Er();An.exports=Rl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Ir=u((pm,Rn)=>{"use strict";var Pl=At(),Ol=U(),kl=dn(),Ll=Tr(),Ml=Object;Rn.exports=Ll?function(r){return typeof r=="symbol"}:function(r){var e=Pl("Symbol");return Ol(e)&&kl(e.prototype,Ml(r))}});var On=u((dm,Pn)=>{"use strict";var Vl=String;Pn.exports=function(r){try{return Vl(r)}catch(e){return"Object"}}});var xr=u((mm,kn)=>{"use strict";var Fl=U(),$l=On(),jl=TypeError;kn.exports=function(r){if(Fl(r))return r;throw new jl($l(r)+" is not a function")}});var Mn=u((fm,Ln)=>{"use strict";var Nl=xr(),_l=vr();Ln.exports=function(r,e){var t=r[e];return _l(t)?void 0:Nl(t)}});var Fn=u((vm,Vn)=>{"use strict";var wr=wt(),Sr=U(),Ar=Ee(),ql=TypeError;Vn.exports=function(r,e){var t,i;if(e==="string"&&Sr(t=r.toString)&&!Ar(i=wr(t,r))||Sr(t=r.valueOf)&&!Ar(i=wr(t,r))||e!=="string"&&Sr(t=r.toString)&&!Ar(i=wr(t,r)))return i;throw new ql("Can't convert object to primitive value")}});var jn=u((ym,$n)=>{"use strict";$n.exports=!0});var qn=u((bm,_n)=>{"use strict";var Nn=Z(),Bl=Object.defineProperty;_n.exports=function(r,e){try{Bl(Nn,r,{value:e,configurable:!0,writable:!0})}catch(t){Nn[r]=e}return e}});var Pt=u((gm,Hn)=>{"use strict";var Dl=jn(),Hl=Z(),Gl=qn(),Bn="__core-js_shared__",Dn=Hn.exports=Hl[Bn]||Gl(Bn,{});(Dn.versions||(Dn.versions=[])).push({version:"3.38.0",mode:Dl?"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 Rr=u((Cm,zn)=>{"use strict";var Gn=Pt();zn.exports=function(r,e){return Gn[r]||(Gn[r]=e||{})}});var Be=u((Em,Un)=>{"use strict";var zl=yr(),Ul=Object;Un.exports=function(r){return Ul(zl(r))}});var Te=u((Tm,Wn)=>{"use strict";var Wl=Q(),Kl=Be(),Ql=Wl({}.hasOwnProperty);Wn.exports=Object.hasOwn||function(e,t){return Ql(Kl(e),t)}});var Pr=u((Im,Kn)=>{"use strict";var Xl=Q(),Yl=0,Zl=Math.random(),Jl=Xl(1 .toString);Kn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Jl(++Yl+Zl,36)}});var De=u((xm,Xn)=>{"use strict";var ec=Z(),tc=Rr(),Qn=Te(),rc=Pr(),ic=Er(),nc=Tr(),Ie=ec.Symbol,Or=tc("wks"),oc=nc?Ie.for||Ie:Ie&&Ie.withoutSetter||rc;Xn.exports=function(r){return Qn(Or,r)||(Or[r]=ic&&Qn(Ie,r)?Ie[r]:oc("Symbol."+r)),Or[r]}});var eo=u((wm,Jn)=>{"use strict";var ac=wt(),Yn=Ee(),Zn=Ir(),sc=Mn(),lc=Fn(),cc=De(),uc=TypeError,hc=cc("toPrimitive");Jn.exports=function(r,e){if(!Yn(r)||Zn(r))return r;var t=sc(r,hc),i;if(t){if(e===void 0&&(e="default"),i=ac(t,r,e),!Yn(i)||Zn(i))return i;throw new uc("Can't convert object to primitive value")}return e===void 0&&(e="number"),lc(r,e)}});var kr=u((Sm,to)=>{"use strict";var pc=eo(),dc=Ir();to.exports=function(r){var e=pc(r,"string");return dc(e)?e:e+""}});var no=u((Am,io)=>{"use strict";var mc=Z(),ro=Ee(),Lr=mc.document,fc=ro(Lr)&&ro(Lr.createElement);io.exports=function(r){return fc?Lr.createElement(r):{}}});var Mr=u((Rm,oo)=>{"use strict";var vc=pe(),yc=z(),bc=no();oo.exports=!vc&&!yc(function(){return Object.defineProperty(bc("div"),"a",{get:function(){return 7}}).a!==7})});var lo=u(so=>{"use strict";var gc=pe(),Cc=wt(),Ec=dr(),Tc=mr(),Ic=qe(),xc=kr(),wc=Te(),Sc=Mr(),ao=Object.getOwnPropertyDescriptor;so.f=gc?ao:function(e,t){if(e=Ic(e),t=xc(t),Sc)try{return ao(e,t)}catch(i){}if(wc(e,t))return Tc(!Cc(Ec.f,e,t),e[t])}});var uo=u((Om,co)=>{"use strict";var Ac=z(),Rc=U(),Pc=/#|\.prototype\./,He=function(r,e){var t=kc[Oc(r)];return t===Mc?!0:t===Lc?!1:Rc(e)?Ac(e):!!e},Oc=He.normalize=function(r){return String(r).replace(Pc,".").toLowerCase()},kc=He.data={},Lc=He.NATIVE="N",Mc=He.POLYFILL="P";co.exports=He});var Vr=u((km,po)=>{"use strict";var ho=hr(),Vc=xr(),Fc=Ne(),$c=ho(ho.bind);po.exports=function(r,e){return Vc(r),e===void 0?r:Fc?$c(r,e):function(){return r.apply(e,arguments)}}});var fo=u((Lm,mo)=>{"use strict";var jc=pe(),Nc=z();mo.exports=jc&&Nc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var yo=u((Mm,vo)=>{"use strict";var _c=Ee(),qc=String,Bc=TypeError;vo.exports=function(r){if(_c(r))return r;throw new Bc(qc(r)+" is not an object")}});var Co=u(go=>{"use strict";var Dc=pe(),Hc=Mr(),Gc=fo(),Ot=yo(),bo=kr(),zc=TypeError,Fr=Object.defineProperty,Uc=Object.getOwnPropertyDescriptor,$r="enumerable",jr="configurable",Nr="writable";go.f=Dc?Gc?function(e,t,i){if(Ot(e),t=bo(t),Ot(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Nr in i&&!i[Nr]){var n=Uc(e,t);n&&n[Nr]&&(e[t]=i.value,i={configurable:jr in i?i[jr]:n[jr],enumerable:$r in i?i[$r]:n[$r],writable:!1})}return Fr(e,t,i)}:Fr:function(e,t,i){if(Ot(e),t=bo(t),Ot(i),Hc)try{return Fr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new zc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var To=u((Fm,Eo)=>{"use strict";var Wc=pe(),Kc=Co(),Qc=mr();Eo.exports=Wc?function(r,e,t){return Kc.f(r,e,Qc(1,t))}:function(r,e,t){return r[e]=t,r}});var ze=u(($m,xo)=>{"use strict";var Ge=Z(),Xc=Di(),Yc=hr(),Zc=U(),Jc=lo().f,eu=uo(),xe=St(),tu=Vr(),we=To(),Io=Te();Pt();var ru=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 Xc(r,this,arguments)};return e.prototype=r.prototype,e};xo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,s=i?Ge:n?Ge[t]:Ge[t]&&Ge[t].prototype,a=i?xe:xe[t]||we(xe,t,{})[t],l=a.prototype,c,p,v,f,E,w,P,g,k;for(f in e)c=eu(i?f:t+(n?".":"#")+f,r.forced),p=!c&&s&&Io(s,f),w=a[f],p&&(r.dontCallGetSet?(k=Jc(s,f),P=k&&k.value):P=s[f]),E=p&&P?P:e[f],!(!c&&!o&&typeof w==typeof E)&&(r.bind&&p?g=tu(E,Ge):r.wrap&&p?g=ru(E):o&&Zc(E)?g=Yc(E):g=E,(r.sham||E&&E.sham||w&&w.sham)&&we(g,"sham",!0),we(a,f,g),o&&(v=t+"Prototype",Io(xe,v)||we(xe,v,{}),we(xe[v],f,E),r.real&&l&&(c||!l[f])&&we(l,f,E)))}});var So=u((jm,wo)=>{"use strict";var iu=Math.ceil,nu=Math.floor;wo.exports=Math.trunc||function(e){var t=+e;return(t>0?nu:iu)(t)}});var Ue=u((Nm,Ao)=>{"use strict";var ou=So();Ao.exports=function(r){var e=+r;return e!==e||e===0?0:ou(e)}});var Po=u((_m,Ro)=>{"use strict";var au=Ue(),su=Math.max,lu=Math.min;Ro.exports=function(r,e){var t=au(r);return t<0?su(t+e,0):lu(t,e)}});var ko=u((qm,Oo)=>{"use strict";var cu=Ue(),uu=Math.min;Oo.exports=function(r){var e=cu(r);return e>0?uu(e,9007199254740991):0}});var We=u((Bm,Lo)=>{"use strict";var hu=ko();Lo.exports=function(r){return hu(r.length)}});var _r=u((Dm,Vo)=>{"use strict";var pu=qe(),du=Po(),mu=We(),Mo=function(r){return function(e,t,i){var n=pu(e),o=mu(n);if(o===0)return!r&&-1;var s=du(i,o),a;if(r&&t!==t){for(;o>s;)if(a=n[s++],a!==a)return!0}else for(;o>s;s++)if((r||s in n)&&n[s]===t)return r||s||0;return!r&&-1}};Vo.exports={includes:Mo(!0),indexOf:Mo(!1)}});var kt=u((Hm,Fo)=>{"use strict";Fo.exports=function(){}});var $o=u(()=>{"use strict";var fu=ze(),vu=_r().includes,yu=z(),bu=kt(),gu=yu(function(){return!Array(1).includes()});fu({target:"Array",proto:!0,forced:gu},{includes:function(e){return vu(this,e,arguments.length>1?arguments[1]:void 0)}});bu("includes")});var Lt=u((Um,jo)=>{"use strict";var Cu=At();jo.exports=Cu});var _o=u((Wm,No)=>{"use strict";$o();var Eu=Lt();No.exports=Eu("Array","includes")});var Bo=u((Km,qo)=>{"use strict";var Tu=_o();qo.exports=Tu});var Mt=u((Qm,Do)=>{"use strict";var Iu=Bo();Do.exports=Iu});var Ho=u(()=>{"use strict";var xu=ze(),wu=Be(),Su=We(),Au=Ue(),Ru=kt();xu({target:"Array",proto:!0},{at:function(e){var t=wu(this),i=Su(t),n=Au(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Ru("at")});var zo=u((Zm,Go)=>{"use strict";Ho();var Pu=Lt();Go.exports=Pu("Array","at")});var Wo=u((Jm,Uo)=>{"use strict";var Ou=zo();Uo.exports=Ou});var qr=u((ef,Ko)=>{"use strict";var ku=Wo();Ko.exports=ku});var oa=u((tv,na)=>{"use strict";var Bu=Rr(),Du=Pr(),ia=Bu("keys");na.exports=function(r){return ia[r]||(ia[r]=Du(r))}});var sa=u((rv,aa)=>{"use strict";var Hu=z();aa.exports=!Hu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var ua=u((iv,ca)=>{"use strict";var Gu=Te(),zu=U(),Uu=Be(),Wu=oa(),Ku=sa(),la=Wu("IE_PROTO"),Kr=Object,Qu=Kr.prototype;ca.exports=Ku?Kr.getPrototypeOf:function(r){var e=Uu(r);if(Gu(e,la))return e[la];var t=e.constructor;return zu(t)&&e instanceof t?t.prototype:e instanceof Kr?Qu:null}});var pa=u((nv,ha)=>{"use strict";ha.exports={}});var fa=u((ov,ma)=>{"use strict";var Xu=Q(),Qr=Te(),Yu=qe(),Zu=_r().indexOf,Ju=pa(),da=Xu([].push);ma.exports=function(r,e){var t=Yu(r),i=0,n=[],o;for(o in t)!Qr(Ju,o)&&Qr(t,o)&&da(n,o);for(;e.length>i;)Qr(t,o=e[i++])&&(~Zu(n,o)||da(n,o));return n}});var ya=u((av,va)=>{"use strict";va.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ga=u((sv,ba)=>{"use strict";var eh=fa(),th=ya();ba.exports=Object.keys||function(e){return eh(e,th)}});var wa=u((lv,xa)=>{"use strict";var Ea=pe(),rh=z(),Ta=Q(),ih=ua(),nh=ga(),oh=qe(),ah=dr().f,Ia=Ta(ah),sh=Ta([].push),lh=Ea&&rh(function(){var r=Object.create(null);return r[2]=2,!Ia(r,2)}),Ca=function(r){return function(e){for(var t=oh(e),i=nh(t),n=lh&&ih(t)===null,o=i.length,s=0,a=[],l;o>s;)l=i[s++],(!Ea||(n?l in t:Ia(t,l)))&&sh(a,r?[l,t[l]]:t[l]);return a}};xa.exports={entries:Ca(!0),values:Ca(!1)}});var Sa=u(()=>{"use strict";var ch=ze(),uh=wa().values;ch({target:"Object",stat:!0},{values:function(e){return uh(e)}})});var Ra=u((hv,Aa)=>{"use strict";Sa();var hh=St();Aa.exports=hh.Object.values});var Oa=u((pv,Pa)=>{"use strict";var ph=Ra();Pa.exports=ph});var Ht=u((dv,ka)=>{"use strict";var dh=Oa();ka.exports=dh});var ei=u(($v,ja)=>{"use strict";var gh=_e();ja.exports=Array.isArray||function(e){return gh(e)==="Array"}});var _a=u((jv,Na)=>{"use strict";var Ch=TypeError,Eh=9007199254740991;Na.exports=function(r){if(r>Eh)throw Ch("Maximum allowed index exceeded");return r}});var Da=u((Nv,Ba)=>{"use strict";var Th=ei(),Ih=We(),xh=_a(),wh=Vr(),qa=function(r,e,t,i,n,o,s,a){for(var l=n,c=0,p=s?wh(s,a):!1,v,f;c<i;)c in t&&(v=p?p(t[c],c,e):t[c],o>0&&Th(v)?(f=Ih(v),l=qa(r,e,v,f,l,o-1)-1):(xh(l+1),r[l]=v),l++),c++;return l};Ba.exports=qa});var za=u((_v,Ga)=>{"use strict";var Sh=De(),Ah=Sh("toStringTag"),Ha={};Ha[Ah]="z";Ga.exports=String(Ha)==="[object z]"});var Wa=u((qv,Ua)=>{"use strict";var Rh=za(),Ph=U(),zt=_e(),Oh=De(),kh=Oh("toStringTag"),Lh=Object,Mh=zt(function(){return arguments}())==="Arguments",Vh=function(r,e){try{return r[e]}catch(t){}};Ua.exports=Rh?zt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Vh(e=Lh(r),kh))=="string"?t:Mh?zt(e):(i=zt(e))==="Object"&&Ph(e.callee)?"Arguments":i}});var Qa=u((Bv,Ka)=>{"use strict";var Fh=Q(),$h=U(),ti=Pt(),jh=Fh(Function.toString);$h(ti.inspectSource)||(ti.inspectSource=function(r){return jh(r)});Ka.exports=ti.inspectSource});var ts=u((Dv,es)=>{"use strict";var Nh=Q(),_h=z(),Xa=U(),qh=Wa(),Bh=At(),Dh=Qa(),Ya=function(){},Za=Bh("Reflect","construct"),ri=/^\s*(?:class|function)\b/,Hh=Nh(ri.exec),Gh=!ri.test(Ya),rt=function(e){if(!Xa(e))return!1;try{return Za(Ya,[],e),!0}catch(t){return!1}},Ja=function(e){if(!Xa(e))return!1;switch(qh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Gh||!!Hh(ri,Dh(e))}catch(t){return!0}};Ja.sham=!0;es.exports=!Za||_h(function(){var r;return rt(rt.call)||!rt(Object)||!rt(function(){r=!0})||r})?Ja:rt});var os=u((Hv,ns)=>{"use strict";var rs=ei(),zh=ts(),Uh=Ee(),Wh=De(),Kh=Wh("species"),is=Array;ns.exports=function(r){var e;return rs(r)&&(e=r.constructor,zh(e)&&(e===is||rs(e.prototype))?e=void 0:Uh(e)&&(e=e[Kh],e===null&&(e=void 0))),e===void 0?is:e}});var ss=u((Gv,as)=>{"use strict";var Qh=os();as.exports=function(r,e){return new(Qh(r))(e===0?0:e)}});var ls=u(()=>{"use strict";var Xh=ze(),Yh=Da(),Zh=Be(),Jh=We(),ep=Ue(),tp=ss();Xh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Zh(this),i=Jh(t),n=tp(t,0);return n.length=Yh(n,t,t,i,0,e===void 0?1:ep(e)),n}})});var cs=u(()=>{"use strict";var rp=kt();rp("flat")});var hs=u((Qv,us)=>{"use strict";ls();cs();var ip=Lt();us.exports=ip("Array","flat")});var ds=u((Xv,ps)=>{"use strict";var np=hs();ps.exports=np});var fs=u((Yv,ms)=>{"use strict";var op=ds();ms.exports=op});var Ii="1.0.30-dev.f10d9ff4.0";function Le(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})`}function Me(r){for(;r>Math.PI;)r-=2*Math.PI;for(;r<=-Math.PI;)r+=2*Math.PI;return r}function tl(r){return r*180/Math.PI}var ct=class{constructor(e){this.widthExpansionCoef=0;var f;let t=document.createElement("div");t.classList.add("interactive-fillAnimationElement");let i=document.createElement("div");i.classList.add("interactive-fillAnimationElement-filler"),t.append(i);let n=Me(e.rotateAngle),o=n>Math.PI/2&&n<=Math.PI||n<0&&n<-Math.PI/2,s=n===Math.PI/2,a=n===-Math.PI/2,l=!o&&!s&&!a,c=s||a,p=!!(n%Math.PI/2)&&!c,v=p?n:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${v*-1}rad)`,c?i.classList.add("interactive-fillHeight",s?"interactive-fromTop":"interactive-fromBottom"):(i.classList.add("interactive-fillWidth"),i.style.top="0"),e.debug&&console.log({widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:c,rotateAngleRad:n,rotateAngelDeg:tl(n),rotateAngleRaw:e.rotateAngle,fromRight:o,fromTop:s,fromBottom:a,fromLeft:l}),this.useSkew=p,this.fromLeft=l,this.rotateAngle=n,this.fillAnimationElement=t,this.fillAnimationFillerElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=c,this.isDebug=(f=e.debug)!=null?f:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);n=Math.round(n*(100*this.widthExpansionCoef+100)),this.shouldFillHeight?this.fillAnimationFillerElement.style.height=n+"%":this.fillAnimationFillerElement.style.width=n+"%"}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var N="interactive";var F={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},xi=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(xi||{}),wi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(wi||{}),Si=(i=>(i.start="left",i.end="right",i.center="center",i))(Si||{}),ut=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&xi[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&wi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Si[e.alignment])!=null?n:"left"},ht=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,s,a,l,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(a=(s=e==null?void 0:e.text)==null?void 0:s.size)!=null?a:t.textSize})`,r.textContent=(c=(l=e==null?void 0:e.text)==null?void 0:l.value)!=null?c:t.textContent},pt=({target:r,props:e,fallback:t})=>{var i,n,o,s;r.style.backgroundColor=Le((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(s=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?s:t.backgroundAlpha)},Ve=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var a,l,c,p,v,f,E,w,P,g,k;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(l=(a=e==null?void 0:e.shape)==null?void 0:a.border)==null?void 0:l.width)!=null?c:t.borderWidth})`,s=n?t.roundCornersRawValue:`calc(${i.height} * ${(v=(p=e==null?void 0:e.shape)==null?void 0:p.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Le(n?t.borderColor:(w=(E=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:E.color)!=null?w:t.borderColor,n?t.borderAlpha:(k=(g=(P=e==null?void 0:e.shape)==null?void 0:P.border)==null?void 0:g.alpha)!=null?k:t.borderAlpha),r.style.borderRadius=s},Ai=({target:r,frameToneIsDark:e,baseDimension:t,fallback:i})=>{let s=Le(i.shadowColorLight,i.shadowColorAlpha),a=Le(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,p=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=p},be=({target:r,layoutParams:e,fallback:t})=>{var n;let i=Me((n=e.angle)!=null?n:t.angle);i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var tr="int",le=(i=>(i.AREA=`${tr}_area`,i.TEXT=`${tr}_text`,i.BUTTON=`${tr}_bttn`,i))(le||{});function dt(r){return"features"in r}var oe=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.clickListener=null;this.isInteracted=!1;this.isRemoved=!1}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(`${N}-control-container-${this.control.id}`),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:F.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>{var s,a;return(a=(s=e.isContainerDisabled)==null?void 0:s.call(e))!=null?a:!1};this.container={element:t,dimensions:i,getComputedDimensions:e.getComputedDimensions,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&dt(this.options)&&this.options.features[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 Ri=!1,Pi=60,ge=class{constructor(e,t){this.onElementClick=e=>{if(!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:Ri?t.offsetWidth:Pi,height:Ri?t.offsetHeight:Pi},o=Math.min(n.width,n.height),s=i.left+i.width/2,a=i.top+i.height/2,l=e.clientX-s,c=e.clientY-a,p=rl(l,c,Me(this.controlRotateAngleRad));this.element.style.width=o+"px",this.element.style.left=p.x+i.width/2-o/2+"px",this.element.style.top=p.y+i.height/2-o/2+"px",this.element.classList.add("interactive-tap-visible","interactive-tap-animation")};let i=document.createElement("div");i.classList.add("interactive-tap"),this.controlRotateAngleRad=e,this.element=i,this.clickCancelCondition=t}};function rl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var mt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new rr(r,e)},rr=class extends oe{constructor(t,i){super(t,i);this.onControlSelect=()=>{var t;this.container&&this.container.isManifestContainerDisabled()||(t=this.controlElement)==null||t.classList.add("interactive-control-selected")};this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&(t.currentTarget.removeEventListener("transitionend",this.onTransitionEnd),this.removeView())}}createView({parentElement:t,callbacks:i}){var o;if(super.createContainerElement(i),!this.container)return;let n=document.createElement("button");if(n.type="button",n.classList.add(`${N}-${this.control.id}`,`${N}-control`,`${N}-control-area`),n.setAttribute("data-testid",le.AREA),this.controlElement=n,pt({target:n,props:this.control.props,fallback:C(m({},F),{backgroundColor:"transparent"})}),this.updateShadowStyles(),be({target:n,layoutParams:this.control.layoutParams,fallback:F}),this.featureIsEnabled("tapPlaceShow")){let s=(o=this.control.layoutParams.angle)!=null?o:F.angle;this.tapElement=new ge(s,this.container.isManifestContainerDisabled),n.addEventListener("click",this.tapElement.onElementClick),this.container.element.append(this.tapElement.element)}n.addEventListener("click",this.onControlSelect,{once:!0}),this.container.element.append(n),t.append(this.container.element)}updateShadowStyles(t=!1){var i,n,o;if(!(!this.container||!this.controlElement))if(t){let s=getComputedStyle(this.controlElement),a=s.getPropertyValue("--interactive-frame-tone");if(!a)return;let l=Math.min(Number.parseFloat(s.height),Number.parseFloat(s.width))+"px",c=a==="dark";Ai({target:this.controlElement,props:this.control.props,fallback:F,frameToneIsDark:c,baseDimension:l}),Ve({target:this.controlElement,props:this.control.props,fallback:C(m({},F),{borderColor:c?"#fff":"#000",borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(o=(n=(i=this.control.props)==null?void 0:i.shape)==null?void 0:n.roundCorners)!=null?o:F.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else Ve({target:this.controlElement,props:this.control.props,fallback:C(m({},F),{borderAlpha:0}),dependsOn:this.container.dimensions})}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}setShowTimeRange(){}onProgress(){}onResize(){}removeView(t=!1){let i=this.getElement();if(i){if(t){if(i.classList.contains("interactive-control-before-remove"))return;i.classList.add("interactive-control-before-remove"),i.addEventListener("transitionend",this.onTransitionEnd);return}this.removeListeners(),i.remove(),this.isRemoved=!0}}removeListeners(){var i,n;super.removeListeners(),(i=this.controlElement)==null||i.removeEventListener("click",this.onControlSelect);let t=this.getElement();t==null||t.removeEventListener("transitionend",this.onTransitionEnd),!(!this.tapElement||!this.featureIsEnabled("tapPlaceShow"))&&((n=this.controlElement)==null||n.removeEventListener("click",this.tapElement.onElementClick))}getElement(){return this.controlElement}toggleCTAAnimation(t){var i;(i=this.controlElement)==null||i.classList.toggle("interactive-control-cta-area",t)}};var ft=()=>{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 vt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new ir(r,e)},ir=class extends oe{constructor(t,i){super(t,i);this.onControlSelect=()=>{var t;this.container&&this.container.isManifestContainerDisabled()||(t=this.controlElement)==null||t.classList.add("interactive-control-selected")};this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&(t.currentTarget.removeEventListener("transitionend",this.onTransitionEnd),this.removeView())}}createView({parentElement:t,callbacks:i}){var s,a,l,c;if(super.createContainerElement(i),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(`${N}-${this.control.id}`,`${N}-control`,`${N}-control-button`),n.setAttribute("data-testid",le.BUTTON),be({target:n,layoutParams:this.control.layoutParams,fallback:F}),pt({target:n,props:this.control.props,fallback:F}),Ve({target:n,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),ut({target:n,props:C(m({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let o=ft();if(ht({target:o,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("buttonControlInteractiveTimeTimer")&&(this.fillAnimation=new ct({startTime:this.startTime,endTime:this.endTime,rotateAngle:(s=this.control.layoutParams.angle)!=null?s:F.angle,borderRadius:n.style.borderRadius})),this.featureIsEnabled("tapPlaceShow")){let p=(a=this.control.layoutParams.angle)!=null?a:F.angle;this.tapElement=new ge(p,this.container.isManifestContainerDisabled),n.addEventListener("click",this.tapElement.onElementClick),this.container.element.append(this.tapElement.element)}n.addEventListener("click",this.onControlSelect,{once:!0}),n.append(o,(c=(l=this.fillAnimation)==null?void 0:l.fillAnimationElement)!=null?c:""),this.container.element.append(n),t.append(this.container.element),this.controlElement=n,requestAnimationFrame(()=>{this.fillAnimation&&this.updateFillAnimationDimension()})}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}setShowTimeRange(t,i){this.startTime=t,this.endTime=i}onProgress(t){var i;(i=this.fillAnimation)==null||i.updateAnimation(t)}updateFillAnimationDimension(){var n;if(!this.container||!this.controlElement)return;let t=getComputedStyle(this.controlElement),i={width:parseFloat(t.width),height:parseFloat(t.height),borderWidth:parseFloat(t.borderWidth)||0};(n=this.fillAnimation)==null||n.updateDimension(i)}onResize(){this.updateFillAnimationDimension()}getElement(){return this.controlElement}removeView(t=!1){let i=this.getElement();if(i){if(t){if(i.classList.contains("interactive-control-before-remove"))return;i.classList.add("interactive-control-before-remove"),i.addEventListener("transitionend",this.onTransitionEnd);return}this.removeListeners(),i.remove(),this.isRemoved=!0}}removeListeners(){var i,n;super.removeListeners(),(i=this.controlElement)==null||i.removeEventListener("click",this.onControlSelect);let t=this.getElement();t==null||t.removeEventListener("transitionend",this.onTransitionEnd),!(!this.tapElement||!this.featureIsEnabled("tapPlaceShow"))&&((n=this.controlElement)==null||n.removeEventListener("click",this.tapElement.onElementClick))}toggleCTAAnimation(t){var i;(i=this.controlElement)==null||i.classList.toggle("interactive-control-cta-button",t)}updateShadowStyles(){}};var Oi=r=>{if(r.type.trim().toLowerCase()==="text")return new nr(r)},nr=class extends oe{constructor(t){super(t);this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&(t.currentTarget.removeEventListener("transitionend",this.onTransitionEnd),this.removeView())}}createView({parentElement:t,callbacks:i}){if(super.createContainerElement(i),!this.container)return;let n=document.createElement("div");n.classList.add(`${N}-${this.control.id}`,`${N}-control`,`${N}-control-text`),n.setAttribute("data-testid",le.TEXT),be({target:n,layoutParams:this.control.layoutParams,fallback:F}),ut({target:n,props:C(m({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let o=ft();ht({target:o,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),n.append(o),this.container.element.append(n),t.append(this.container.element),this.controlElement=n}disable(){}enable(){}setShowTimeRange(){}onProgress(){}onResize(){}toggleCTAAnimation(){}updateShadowStyles(){}removeView(t=!1){let i=this.getElement();if(i){if(t){if(i.classList.contains("interactive-control-before-remove"))return;i.classList.add("interactive-control-before-remove"),i.addEventListener("transitionend",this.onTransitionEnd);return}this.removeListeners(),i.remove(),this.isRemoved=!0}}removeListeners(){super.removeListeners();let t=this.getElement();t==null||t.removeEventListener("transitionend",this.onTransitionEnd)}getElement(){return this.controlElement}};var or=class{constructor(e){this.layout=e}},yt=class extends or{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))`}getComputedDimensions(e,t){let i=window.getComputedStyle(e),n=parseFloat(i.getPropertyValue("--interactive-content-width")),o=parseFloat(i.getPropertyValue("--interactive-content-height"));return{width:n*t.width,height:o*t.height}}};var Ce=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}featureIsEnabled(e){return this.options&&dt(this.options)&&this.options.features[e]}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(),o=this.factories.get(n);if(o){let s=o(i,this.options);if(s)return[...t,s]}return[...t]},[]))||[]}};import{isSupportedManifest as Tt,ContainerTypes as Ad,ControlTypes as he,EventActionTypes as L,EventTypes as Rd,migrateManifestToLatestVersion as Vi,compareVersions as Pd}from"@interactiveplatform/movika-manifest";var ce=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Fe=r=>ce(r,"Object"),bt=r=>ce(r,"String"),gt=r=>ce(r,"Array"),Ct=r=>ce(r,"Number"),ki=r=>ce(r,"Function");var ar=r=>Ct(r)&&!isNaN(r);var ue=r=>Fe(r)&&Object.keys(r).length===0,sr=r=>gt(r)&&!r.length;var $e=(r,e)=>bt(r)&&(e?r.trim():r).length;var Li={metadata:"Object",chapters:"Array"},Mi=r=>{if(!Fe(r))return!1;for(let e in Li)if(!r[e]||!ce(r[e],Li[e]))return!1;return Tt(r.metadata.version)},Et=r=>r.type===he.Text,bd=r=>r.type===he.Button,gd=r=>r.type===he.Area,Cd={Choice:"Choice",TextInput:"TextInput"},Ed={Button:"Button",Area:"Area",Text:"Text"},Td={onClick:"onClick",onSuspense:"onSuspense"},Id={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var It=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new lr(r,e,t)},lr=class extends Ce{constructor(t,i,n){super(t,n);this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&(t.currentTarget.removeEventListener("transitionend",this.onTransitionEnd),this.removeView())};this.rootElement=i,this.layout=new yt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.willRemoved=!1,this.addControlFactory("button",vt),this.addControlFactory("text",Oi),this.addControlFactory("area",mt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return this.featureIsEnabled("controlsShowAnimation")?(n.classList.add("interactive-container-before-show"),requestAnimationFrame(()=>{n.classList.remove("interactive-container-before-show"),n.classList.add("interactive-container")})):n.classList.add("interactive-container"),n.classList.add(`${N}-${this.container.id}`),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var s,a;if(o.setShowTimeRange(this.container.startTime,(s=this.container.endTime)!=null?s:i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,getComputedDimensions:()=>this.layout.getComputedDimensions(this.rootElement,o.control.layoutParams),isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.featureIsEnabled("controlsCTAAnimation")){let l=o.control.type;(l===he.Button||l===he.Area)&&((a=o.controlElement)==null||a.addEventListener("mouseleave",()=>{o.controlElement&&this.setupControlsBlinkAnimSync(o.controlElement,l)}))}}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,n}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(){this.controls.forEach(t=>{t.onResize()})}hide(){let t=this.getElement();t&&(t.style.visibility="hidden")}show(){let t=this.getElement();t&&(t.style.visibility="visible")}enable(){let t=this.getElement();t&&(this.controls.forEach(i=>i.enable()),t.classList.remove("interactive-container-disabled"),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(this.controls.forEach(i=>i.disable()),t.classList.add("interactive-container-disabled"),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),n.addEventListener("transitionend",this.onTransitionEnd);return}this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}getElement(){return this.rootElement.querySelector(`.${N}-${this.container.id}`)}toggleCTAAnimation(t){this.controls.forEach(i=>i.toggleCTAAnimation(t))}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}setupControlsBlinkAnimSync(t,i){if(!t.classList.contains(`interactive-control-cta-${i.toLowerCase()}`)||t.classList.contains("interactive-control-selected")||t.classList.contains("interactive-blink-reference-disable-animation"))return;let n=this.rootElement.querySelector(".interactive-blink-reference-animation");n&&(t.classList.add("interactive-blink-reference-disable-animation"),n.addEventListener("animationiteration",()=>{t.classList.remove("interactive-blink-reference-disable-animation")},{once:!0}))}};var zs=te(Mt(),1),Us=te(qr(),1);import{clientChecker as Cp,combine as Ep,InterfaceLanguage as Tp,Observable as Ds,once as Ip,Subject as D,Subscription as Xt,ValueSubject as H,fromEvent as Hs}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as at}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Lu}from"@vkontakte/videoplayer-shared/es2015";function Ke(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Qo="video_interactive",Xo="videoint";var Yo=250,Qe=class{constructor(e){this.handleZoomChange=Ke(e=>{this.lastZoomInfo=e},Yo);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,!Ct(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:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),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=Mu(e),this.resizeObserver=new ResizeObserver(Ke(this.onResize,Yo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return R(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return R(this,null,function*(){if(!this.manifest)return;let e;try{e=yield Lu(this.lang,Qo,Xo)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",o=>{var s=o,{name:i}=s,n=K(s,["name"]);var a;i==="openPreview"&&"chapterId"in n&&((a=this.onOpenPreviewClick)==null||a.call(this,n.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Mu(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 Xe=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 o of this._containers){let s=o.startTime-e;if(s<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<s&&(t=t===-1?s:Math.min(t,s))}return!i&&t!==-1?t:null}}};var _=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Vt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Ft=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{ki(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 qu}from"@vkontakte/videoplayer-shared/es2015";var $t=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,t){return R(this,null,function*(){return Vu(...this.loaders[e])(t)})}};function Vu(...r){return function(t){return R(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Ye(r,e,t){return r?C(m({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function jt(n){var o=n,{actions:r,errors:e,chapterId:t}=o,i=K(o,["actions","errors","chapterId"]);if(t){let s=r.getManifest();if(s){let a=r.getChapter(s.chapters,t);if(a){let l=r.getMedia(s.media,a.videoId),c=r.getGraph(s.graph,a.id);return l?C(m({},i),{actions:r,errors:e,result:{chapter:a,media:l,graph:c}}):C(m({},i),{errors:Ye(e,jt.name,"Could not find media"),actions:r})}}}return C(m({},i),{errors:Ye(e,jt.name,"Could not find chapter"),actions:r})}var Nt=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,o=i.length;n<o;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,o=i.length;n<o;n++){let s=i[n];try{s.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}},Se=class extends Nt{constructor(){super(),this.listeners||Nt.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)}},Ze=class{constructor(){Object.defineProperty(this,"signal",{value:new Se,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&&(Ze.prototype[Symbol.toStringTag]="AbortController",Se.prototype[Symbol.toStringTag]="AbortSignal");function _t(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 Br(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!_t({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,p){let v;p&&p.signal&&(v=p.signal,delete p.signal);let f=new t(c,p);return v&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),f},o.prototype=t.prototype);let s=e;return{fetch:(l,c)=>{let p=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(p){let v;try{v=new DOMException("Aborted","AbortError")}catch(E){v=new Error("Aborted"),v.name="AbortError"}if(p.aborted)return Promise.reject(v);let f=new Promise((E,w)=>{p.addEventListener("abort",()=>w(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([f,s(l,c)])}return s(l,c)},Request:o}}var Je=_t({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Zo=Je?Br({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Dr=Je?Zo.fetch:window.fetch,Lf=Je?Zo.Request:window.Request,Mf=Je?Ze:window.AbortController,Vf=Je?Se:window.AbortSignal;var Hr=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Fu=r=>R(void 0,null,function*(){try{let e={},t;if(bt(r)){t=new URL(r).href;let n=yield Dr(t);if(!n.ok)return{};e=yield n.json()}else if(Fe(r))e=r;else return{};if(!Mi(e))return{};let i=e.metadata.media;if(bt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=yield Dr(n);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(n){return Nu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Jo(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield Fu(r);if(!e)throw new Error("Failed on fetch");let i=Vi(e);return i.media=$u(i.media,t),delete i.metadata.media,i})}function qt(r,e){if(e)return r.find(t=>t.id===e)}function Gr(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 zr(r,e){return r.videos.find(t=>t.id===e)}function $u(r,e){return C(m({},r),{videos:r.videos.map(t=>C(m({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=ju(n,e);return C(m({},i),{url:o||n})})}))})}function ju(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Nu(r){return Hr(r,"3.2.0")>=0}var Bt=r=>gt(r)&&!sr(r),J=r=>r.order==="end",Dt=r=>gt(r.containers)&&!sr(r.containers)&&J(r),ea=(r,e)=>{var i;let t=r*1e3;return Bt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Ur=(r,e)=>{var i,n;let t=r*1e3;return Bt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ae=(r=[])=>r.some(e=>e.action.type==="expect"),Wr=(r=[])=>r.find(e=>e.action.type==="expect"),_u=r=>(r==null?void 0:r.length)===1,Ae=r=>_u(r)&&Et(r[0]);function ta(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(m(m({},e[0]),t)):r(...e,...t)}var ra=(r,e)=>ae(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ae(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved&&!t.willRemoved);var Re=class extends $t{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new qu(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return R(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ye},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield Jo((n=i.result)!=null?n:t),this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(this,arguments,function*(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=yield this.exec("chapterLoaders",jt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Gr,getChapter:qt,getMedia:zr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ye},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=qt(this.manifest.chapters,t);if(n){let o=zr(this.manifest.media,n.videoId),s=Gr(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:s}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,s;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let a=qt(((s=this.manifest)==null?void 0:s.chapters)||[],t);return this.getByBranches(a==null?void 0:a.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),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?J(this.chapter):!1}};var Va=te(Ht(),1);import{Player as mh}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Zr,Tracer as fh,ValueSubject as vh}from"@vkontakte/videoplayer-shared/es2015";var La=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 Ma=te(Ht(),1);function Xr(){let r=new Map;function e(l){var c=l,{listId:o=Math.random().toString(),itemId:s=Math.random().toString()}=c,a=K(c,["listId","itemId"]);let p=r.get(o),v=m({},a);return p?p[s]=v:r.set(o,{[s]:v}),m({listId:o,itemId:s},a)}function t(o){var s,a;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(s=o.statistics)==null||s.oneStat.destroy(),(a=o.statistics)==null||a.statSubscription.unsubscribe()}function i(o,s){let a=r.get(o);if(!a)throw Error("Can't remove. Not find.");if(s){let l=a[s];l&&t(l),delete a[s],Object.keys(a).length||r.delete(o)}else{for(let l of(0,Ma.default)(a))t(l);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Pe=te(Mt(),1);function Yr(r,e=[]){var o,s,a;let t={},i,n=!e.length;for(let l of r.variants)if(!i&&"cover"in l&&(i=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(n||(0,Pe.default)(e,"mp4"))&&(t.MPEG=C(m({},t.MPEG),{[(o=l.standard)!=null?o:"Invariant quality"]:l.url}));break;case"mpeg":(n||(0,Pe.default)(e,"mpeg"))&&(t.MPEG=C(m({},t.MPEG),{[(s=l.standard)!=null?s:"Invariant quality"]:l.url}));break;case"hls":(n||(0,Pe.default)(e,"hls"))&&(t=C(m({},t),{HLS:{type:"url",url:l.url}}));break;case"dash":(n||(0,Pe.default)(e,"dash"))&&(t=C(m({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(a=r.title)!=null?a:""}}var et=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Pe.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var yh=2;function Jr(r){let e=Xr(),t=new Zr,i={},n=null,o=!1,s,a=new vh(null);r&&l(r);function l(g){n=g}function c(g,k,h){var I;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let y=((I=e.map.get(g))!=null?I:{})[k];if(y){i=m({chapterId:h,listId:g,itemId:k},y);let T=i.player;i.subscription.add(T.info.currentQuality$.subscribe(b=>{let S=T.info.position$.getValue(),q=T.info.isAutoQualityEnabled$.getValue();if(!(!b||!S||q))for(let A of e.map)(0,Va.default)(A[1]).forEach(({player:M})=>{et(M,b)})})).add(T.events.started$.subscribe(()=>{p(k)})),y.container.remove(),n.setPlayer(y.player),o||(n.init(),o=!0),a.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function p(g){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(ue(i)||g!==i.itemId)return;let k=n.getChapterBranches(),h=new Set;for(let d of k)h.has(d.media.id)||(yield f({media:d.media,chapterId:d.chapter.id,setAsActive:!1,title:d.chapter.label}),h.add(d.media.id))})}function v(h){return R(this,arguments,function*({chapter:{id:g},manifestVideo:k}){if(ue(i)||!n)return;let d=i.player.info.muted$.getValue(),y=i.player.info.currentQuality$.getValue(),I=i.player.info.isAutoQualityEnabled$.getValue(),T=i.player.info.volume$.getValue(),b=i.player.info.currentPlaybackRate$.getValue(),S=!I,q=!1;for(let A of e.map)if(A[0]===k.id&&!n.state.isReplay$.getValue()){let M=Object.keys(A[1]);for(let $ of M)$===i.itemId?(M.length<yh||(q=!0),e.removePlayer(A[0],$)):(q=!0,c(A[0],$,g),S?et(i.player,y):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(d),i.player.setPlaybackRate(b))}else e.removePlayer(A[0]);q||(yield f({media:k,chapterId:g,setAsActive:!0,playbackRate:b}),S?et(i.player,y):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(d))})}function f(S){return R(this,arguments,function*({media:g,chapterId:k,prefetch:h=!0,setAsActive:d=!0,autoplay:y=!1,preferredExt:I,title:T,playbackRate:b}){var pi,di,mi,fi,vi;let q=Math.random().toString(),A=document.createElement("div");s.append(A);let M;if((pi=n==null?void 0:n.options)!=null&&pi.vkVideoLoader){let st=La(g);st.length&&(M=yield n.options.vkVideoLoader(...st))}let $=((di=n==null?void 0:n.options)==null?void 0:di.coreConfig)||void 0,Y=C(m({},$),{configName:[...(mi=$==null?void 0:$.configName)!=null?mi:[],"interactive"]}),se=C(m({container:A},((fi=M==null?void 0:M.videos)==null?void 0:fi[0])||{sources:Yr(g,I).sources}),{title:T,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),B=new mh(Y,fh.createRootTracer());B.initVideo(se);let ve=null;if(M!=null&&M.videos&&(n!=null&&n.options.createOneStat)){let st=M.videos[0],Zt=n.options.createOneStat(st),yi=new Zr;Zt&&(yi.add(Zt.attachTo(B)),ve={oneStat:Zt,statSubscription:yi})}let hi=new Zr,Ws=(vi=i==null?void 0:i.player)==null?void 0:vi.info.isAutoQualityEnabled$.getValue();hi.add(B.events.canplay$.subscribe(function(){Ws||et(B,i.player.info.currentQuality$.getValue()),b&&B.setPlaybackRate(b)}));let ye=e.createPlayer({listId:g.id,itemId:q,player:B,container:A,sources:Yr(g,I).sources,config:se,subscription:hi,statistics:ve});return d&&c(g.id,ye.itemId,k),y&&ye.player.play(),h&&!y&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}})}function E(){w(),n=null,s.remove()}function w(){t.unsubscribe(),e.removeAll(),i={},o=!1}function P(){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");w(),s=document.createElement("div");let{media:g,chapter:k}=n.getCurrentChapter();g&&k?(t.add(n.events.chapterChanged$.subscribe(v)),yield f({media:g,chapterId:k.id,title:k.label})):console.error("not found")})}return C(m({},e),{init:P,setInteractiveController:l,createPlayer:f,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:a})}var O={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},tt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},V={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as bh}from"@vkontakte/videoplayer-shared/es2015";var Gt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:s,globalEventEmitter:a,ignoreContainerEvent:l,permanentTextControls:c,disabledControls$:p,onRemove:v,features:f}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ae(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,s,a;if(this.gameState!==2||this.container.isInteracted())return;if(this.container.getElement())(i=(t=this.container).show)==null||i.call(t),this.emitContainerVisibilityEvent(!0,!1);else{let l={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(v,f)=>{this.isSelectedControlEvent=!0,v!==!1&&(this.removeView(),this.emitContainerVisibilityEvent(!1)),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),f(),this.removeView(),this.emitContainerVisibilityEvent(!1))},isEOV:()=>this.gameState===4},c=ta(this.selectBranches.onControlEvent,l),p=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:p}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((a=(s=this.container).disable)==null||a.call(s))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,c;let e=this.player.experimental.element$.getValue();if(!(e instanceof HTMLVideoElement?e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(ea(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Ur(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let p=this.gameState;this.gameState=3,p===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=Ur(n,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:n,isInteractiveTime:o};this.globalEventEmitter.emit(O.eachTick,a),this.globalEvents.eachTick$.next(a),(c=this.container)==null||c.onProgress(n*1e3,o)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new bh,this.player=e,this.interactiveEvents=o,this.ignoreContainerEvent=l,this.isPermanentText=c&&Ae(t.container.controls),this.disabledControls$=p,this.onRemove=v,this.globalEventEmitter=a,this.gameState=0,this.globalEvents=s,this.features=f,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)}))}selectContainerEvent(e=!1){var t,i;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ae(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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)}toggleControlsCTAAnimation(e){this.container.toggleCTAAnimation(e)}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}destroy(){var e;this.reset(),this.removeView(!1),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 $a=(r=[])=>r.reduce((e,t,i)=>{var o,s,a;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(l=>!Et(l));if(Bt(n)){let l=[(s=t.startTime)!=null?s:0,(a=t.endTime)!=null?a:1/0],c=t.id;if(!i)e.push({subjects:[c],range:l});else{let p=[],v=-1/0,f=1/0,E=[],w=[];for(let P=0;P<e.length;P++){let g=e[P];if(w.push(...g.subjects),g.range[0]<f&&(f=g.range[0]),g.range[1]>v&&(v=g.range[1]),l[0]>=g.range[0]&&l[1]<=g.range[1])return e[P].subjects.push(c),e;l[0]<g.range[0]&&l[1]>g.range[0]&&(p.push(P),E=E.concat(g.subjects)),l[0]>=g.range[0]&&l[0]<=g.range[1]&&(p.push(P),E=E.concat(g.subjects),l[0]=g.range[0]),l[1]>=g.range[0]&&l[1]<=g.range[1]&&(p.push(P),E=E.concat(g.subjects),l[1]=g.range[1])}if(w.push(c),l[0]<=f&&l[1]>=v)return[{subjects:w,range:l}];p.length&&p.reverse().forEach(P=>{e.splice(P,1)}),e.push({subjects:E.concat([c]),range:l})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var ys=te(Mt(),1),ii=te(Ht(),1),bs=te(fs(),1);function vs(){let r={};function e(){for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&delete r[a]}function t(a){let l={};for(let c in r)+c<=a&&(l[c]=r[c]);return l}function i(a){let l={};for(let c in r)+c>=a&&(l[c]=r[c]);return l}function n({timestamp:a,priority:l,initiator:c}){var p;if(ar(a)){let v=(p=r[a])!=null?p:null;if(v&&l&&$e(l,!0)){let f={},E=v[l];if(E&&(f=m(m({},f),E)),f=ue(f)?null:f,f&&$e(c,!0)){let w=f[c];return w!=null?w:null}return f}return v}return null}function o({timestamp:a,priority:l,initiator:c}){if(ar(a))if(r[a]){if(l&&$e(l,!0))if(r[a][l]){if(c&&$e(c,!0))if(r[a][l][c]){if(delete r[a][l][c],!ue(r[a][l]))return!0}else return!1;if(delete r[a][l],!ue(r[a]))return!0}else return!1;return delete r[a]}else return!1;return!1}function s(v){var f=v,{timestamp:a,priority:l,initiator:c}=f,p=K(f,["timestamp","priority","initiator"]);var E,w,P;(w=(E=r[a])==null?void 0:E[l])!=null&&w[c]?r[a][l][c].push(m({},p)):(P=r[a])!=null&&P[l]?r[a][l]=C(m({},r[a][l]),{[c]:[m({},p)]}):r[a]?r[a]=C(m({},r[a]),{[l]:{[c]:[m({},p)]}}):r[a]={[l]:{[c]:[m({},p)]}}}return{map:r,remove:o,add:s,removeAll:e,get:n,getLte:t,getGte:i}}var ap=[L.expect,L.setNextBranch],sp=1/0;function gs(r){let e=r,t,i=lp(),n=vs(),o,s=()=>{f(),k()},a=h=>{n.add.call(void 0,h),w()},l=(h=[])=>{for(let d of h)if(d.action(),(0,ys.default)(ap,d.actionType))break},c=(h=1/0)=>{var T,b,S;let d=Ut((T=n.get({timestamp:h,priority:"control"}))!=null?T:{}),y=Ut((b=n.get({timestamp:h,priority:"container"}))!=null?b:{}),I=Ut((S=n.get({timestamp:h,priority:"chapter"}))!=null?S:{});return[...d,...y,...I]},p=h=>{i.isReady(h)&&l(c(h))},v=()=>{var h;l([...Ut((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},f=()=>{t&&(o==null||o.unsubscribe(),t=void 0)},E=h=>{},w=()=>{t||(t=()=>setTimeout(()=>{p(1/0)}),o=e.events.ended$.subscribe(t))},P=h=>{f(),e=h},g=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},k=()=>{i.release(),n.removeAll()};return{setPlayer:P,add:a,remove:g,exec:p,execEndOfVideo:v,listen:w,unlisten:f,release:s,containersEventsCallState:i,getPreparedToExecActions:c}}function lp(){let r=new Map;return{setCalled:({timestamp:s,id:a})=>{let l=r.get(s);l&&l[a]!==void 0&&(l[a]=!0)},setData:(s=[])=>{var a;for(let l of s){let c=(a=l.endTime)!=null?a:sp,p=r.get(c);r.set(c,C(m({},p),{[l.id]:!1}))}},resetCalled:s=>{let a=r.get(s);if(a)for(let l in a)a[l]=!1},isReady:s=>{let a=r.get(s);return a?!(0,ii.default)(a).some(l=>!l):!0},release:()=>r.clear()}}function Ut(r){return(0,bs.default)((0,ii.default)(r)).sort(e=>e.actionType===L.expect?-1:1)}var Cs={videoContentHeight:0,videoContentWidth:0},Es=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Cs;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Cs;let o=e/t,s=i/n,a,l;return s>o?(l=n,a=n*o):s<o?(l=i/o,a=i):(l=n,a=i),{videoContentWidth:l,videoContentHeight:a}};var cp=250;function Ts(r){let e=()=>{},t=new ResizeObserver(a=>{o(a),e=o.bind(null,a)});function i(a){let{parentElement:l,player:c}=r();if(l&&c){let{videoContentWidth:p,videoContentHeight:v}=Es(c);l.style.setProperty("--interactive-content-width",`${Math.ceil(p)}px`),l.style.setProperty("--interactive-content-height",`${Math.ceil(v)}px`),l.style.setProperty("--interactive-width",`${Math.ceil(a[0].contentRect.width)}px`),l.style.setProperty("--interactive-height",`${Math.ceil(a[0].contentRect.height)}px`)}}function n(){let{parentElement:a}=r();a.removeAttribute("style")}let o=Ke(a=>{let{fns:l=[]}=r();i(a);for(let c of l)c()},cp);function s(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:s}}var up=r=>Math.floor(Math.random()*r),xs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],s=(n=o.weight)!=null?n:1;s<t&&(t=s,i=o)}return i},ws=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],s=(n=o.weight)!=null?n:0;s>t&&(t=s,i=o)}return i};var Ss=r=>{let e=r.length,t=up(e);return r[t]},Is=1,As=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:Is;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:Is,e>=t)return r[o];return r[r.length-1]};var Rs={shouldOpenNow:!0,isDetachContainer:!0},Ps="after-expect";var ni=(r,e=!1)=>C(m({},r),{args:e?m(m({},r.args),Rs):m(m({},Rs),r.args)}),Ls=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},s=({action:h,controlType:d,controlId:y,containerId:I,branches:T=[],onEvent:b,isEOV:S=()=>!1,isDisabled:q=()=>!1})=>{let A=ni(h,S()),M={timestamp:1/0,priority:"control",initiator:y,actionType:A.type},$=q(),Y=r.emit.bind(r,O.interactives,{subjectId:y,subjectType:d,subjectName:"control",type:$?V.actionChoiceCanceled:V.actionChoice,actionType:h.type,payload:m({invokeImmediately:A.args.shouldOpenNow,containerId:I},A.args)}),se=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:d,subjectName:"control",type:$?"action-choice-canceled":"action-choice",actionType:h.type,payload:m({invokeImmediately:A.args.shouldOpenNow,containerId:I},A.args)})};if($){Y(),se();return}switch(A.type.trim().toLowerCase()){case L.setNextBranch.trim().toLowerCase():{let B=T.find(ve=>ve.id===A.args.branchId);if(!B)return;b(A.args.isDetachContainer,E.bind(null,{subjectId:y,subjectName:"control"})),Y(),se(),A.args.shouldOpenNow?P({subjectId:y,subjectName:"control",subjectType:d,action:A,payload:{chapterId:B.chapterId,autoSelect:!1}}):i.add(C(m({},M),{action:P.bind(null,{subjectId:y,subjectName:"control",subjectType:d,action:A,payload:{chapterId:B.chapterId,autoSelect:!1}})}));return}case L.continuePlayback.trim().toLowerCase():{b(A.args.isDetachContainer,E.bind(null,{subjectId:y,subjectName:"control"})),Y(),se(),A.args.shouldOpenNow?w({subjectId:y,subjectName:"control",subjectType:d,action:h}):i.add(C(m({},M),{action:w.bind(null,{subjectId:y,subjectName:"control",subjectType:d,action:h})}));return}case L.openURI.trim().toLowerCase():{b(A.args.isDetachContainer,E.bind(null,{subjectId:y,subjectName:"control"})),Y(),se(),A.args.shouldOpenNow?k({subjectId:y,subjectName:"control",subjectType:d,action:A,payload:{URI:h.args.uri}}):i.add(C(m({},M),{action:k.bind(null,{subjectId:y,subjectName:"control",subjectType:d,action:A,payload:{URI:h.args.uri}})}));return}default:{let B="Unexpected control event",ve=new _(1,1,{message:B});p(ve,B);return}}},a=({action:h,container:{id:d,endTime:y},branches:I=[],isEOV:T=!1,autoSelected:b=!1})=>{let S=ni(h,T),q={timestamp:!S.args.shouldOpenNow||T?1/0:y!=null?y:1/0,priority:"container",initiator:d,actionType:S.type},A=r.emit.bind(r,O.interactives,{subjectId:d,subjectName:"container",type:V.actionChoice,actionType:S.type,payload:m({invokeImmediately:S.args.shouldOpenNow},S.args)}),M=()=>{e.interactiveActionChoice$.next({subjectId:d,subjectName:"container",type:"action-choice",actionType:S.type,payload:m({invokeImmediately:S.args.shouldOpenNow},S.args)})};switch(S.type.trim().toLowerCase()){case L.setNextBranch.trim().toLowerCase():{let $=I.find(Y=>Y.id===S.args.branchId);if(!$)return;A(),M(),i.add(C(m({},q),{action:P.bind(null,{subjectId:d,subjectName:"container",action:S,payload:{chapterId:$.chapterId,autoSelect:b}})}));return}case L.setMaxWeightBranch.trim().toLowerCase():return;case L.setMinWeightBranch.trim().toLowerCase():return;case L.setRandomBranch.trim().toLowerCase():return;case L.setWeightlessRandomBranch.trim().toLowerCase():return;case L.continuePlayback.trim().toLowerCase():{A(),M(),i.add(C(m({},q),{action:w.bind(null,{subjectId:d,subjectName:"container",action:S})}));return}case L.openURI.trim().toLowerCase():{A(),M(),i.add(C(m({},q),{action:k.bind(null,{subjectId:d,subjectName:"container",action:S,payload:{URI:h.args.uri}})}));return}default:{let $="Unexpected container event",Y=new _(1,1,{message:$});p(Y,$);return}}};function l({container:h,branches:d,isEOV:y=!1}){var T,b;let I=Wr(h.events);if(I){let S=ni(I.action,y);r.emit(O.interactives,{subjectId:h.id,subjectName:"container",type:V.actionChoice,actionType:S.type,payload:m({invokeImmediately:S.args.shouldOpenNow},S.args)}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:S.type,payload:m({invokeImmediately:S.args.shouldOpenNow},S.args)}),i.add({timestamp:y?1/0:(T=h.endTime)!=null?T:1/0,priority:"container",initiator:h.id,actionType:L.expect,action:f.bind(null,{subjectId:h.id,subjectName:"container"})}),n.isExpect=!0}else for(let S of(b=h.events)!=null?b:[])a({action:S.action,container:h,branches:d,isEOV:y})}let c=({chapterId:h,action:d,branches:y=[]})=>{let I=r.emit.bind(r,O.interactives,{subjectId:h,subjectName:"chapter",type:V.actionChoice,actionType:d.type,payload:d.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:d.type,payload:d.args})};switch(d.type.trim().toLowerCase()){case L.setNextBranch.trim().toLowerCase():{let b=y.find(S=>S.id===d.args.branchId);return b!=null&&b.chapterId?(I(),T(),P.bind(null,{subjectId:h,subjectName:"chapter",action:d,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case L.setWeightlessRandomBranch.trim().toLowerCase():{let b=Ss(y);return b!=null&&b.chapterId?(I(),T(),P.bind(null,{subjectId:h,subjectName:"chapter",action:d,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case L.setRandomBranch.trim().toLowerCase():{let b=As(y);return b!=null&&b.chapterId?(I(),T(),P.bind(null,{subjectId:h,subjectName:"chapter",action:d,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case L.setMaxWeightBranch.trim().toLowerCase():{let b=ws(y);return b!=null&&b.chapterId?(I(),T(),P.bind(null,{subjectId:h,subjectName:"chapter",action:d,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case L.setMinWeightBranch.trim().toLowerCase():{let b=xs(y);return b!=null&&b.chapterId?(I(),T(),P.bind(null,{subjectId:h,subjectName:"chapter",action:d,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case L.continuePlayback.trim().toLowerCase():return I(),T(),w.bind(null,{subjectId:h,subjectName:"chapter",action:d});case L.openURI.trim().toLowerCase():return I(),T(),k.bind(null,{subjectId:h,subjectName:"chapter",action:d,payload:{URI:d.args.uri}});default:{let b="Unexpected chapter event",S=new _(1,1,{message:b});p(S,b);return}}};function p(h,d){console.error(d),e.error$.next(h),r.emit(O.errors,h)}function v(h){var y;let d=Wr(h.events);if(d){if(J(h))return;r.emit(O.interactives,{subjectId:h.id,subjectName:"chapter",type:V.actionChoice,actionType:d.action.type,payload:d.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:d.action.type,payload:d.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:L.expect,action:f.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(y=h.events)==null||y.forEach(I=>{let T=c({chapterId:h.id,action:I.action,branches:h.branches});T&&i.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:I.action.type,action:T})})}let f=({subjectId:h,subjectName:d})=>{t.pause(),r.emit(O.interactives,{subjectId:h,subjectName:d,type:V.actionExecution,actionType:L.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:d,type:"action-execution",actionType:L.expect})},E=({subjectId:h,subjectName:d})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(O.interactives,{subjectId:h,subjectName:d,type:V.actionExecution,actionType:Ps}),e.interactiveActionExecution$.next({subjectId:h,subjectName:d,type:"action-execution",actionType:Ps})},w=({subjectId:h,subjectName:d,subjectType:y,action:I})=>{r.emit(O.interactives,{subjectId:h,subjectName:d,subjectType:y,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:d,subjectType:y,type:"action-execution",actionType:I.type})},P=({subjectId:h,subjectName:d,subjectType:y,action:I,payload:T})=>{T.behaviour="change-chapter",r.emit(O.interactives,{subjectId:h,subjectName:d,subjectType:y,type:V.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:d,subjectType:y,type:"action-execution",actionType:I.type,payload:T})},g=({subjectId:h,subjectName:d,subjectType:y,action:I,payload:T})=>{T.behaviour="change-manifest",r.emit(O.interactives,{subjectId:h,subjectName:d,subjectType:y,type:V.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:d,subjectType:y,type:"action-execution",actionType:I.type,payload:T})},k=({subjectId:h,subjectName:d,subjectType:y,action:I,payload:T})=>{if(!T.URI)return;let b=window.open(T.URI,"_blank","noopener,noreferrer");b&&(b.opener=null),r.emit(O.interactives,{subjectId:h,subjectName:d,subjectType:y,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:d,subjectType:y,type:"action-execution",actionType:I.type})};return{onControlEvent:s,onContainerEvent:a,onChapterEvent:c,onExpectEvent:f,expectEventHandler:E,setManifestChapterEvents:v,setManifestContainerEvents:l,stopExpect:o,state:n}};var si=te(qr(),1);import{Subscription as fp,Subject as ai,ValueSubject as it}from"@vkontakte/videoplayer-shared/es2015";var oi=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(s=>s.id===i);if(!n)return null;let o=e.media.videos.find(s=>n.videoId===s.id);if(!o)return null;t[i]=Ms(o)}return t[i]}).filter(Boolean)},pp=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"),Ms=r=>{let e=pp(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},mp=(r,e)=>{for(let t of r.media.videos)if(e===Ms(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Vs=(r,e)=>r.reduce((t,i)=>{let n=mp(e,i);return n?[...t,n]:t},[]);var re,de,me,W,Wt,ie,ne,ee,fe,Oe,ke,nt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new it([]),hasPrevChapter$:new it(!1),prevChapter$:new it(null),isInitialChapter$:new it(!1),isGoBackLimited$:new it(!1)};G(this,re,null);G(this,de);G(this,me,!1);G(this,W,null);G(this,Wt,null);this.events={inited$:new ai,destroyed$:new ai,error$:new ai};G(this,ie,null);G(this,ne,null);G(this,ee,null);G(this,fe,new fp);G(this,Oe,!1);G(this,ke,0);var s;j(this,ie,t),j(this,ee,e),j(this,ne,i),j(this,re,n),j(this,de,o),this.state.history$&&x(this,fe)&&((s=x(this,fe))==null||s.add(this.state.history$.subscribe(a=>{var l,c;this.state.prevChapter$.next((0,si.default)(a,-2)||null),this.state.hasPrevChapter$.next(a.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(l=x(this,W))==null?void 0:l.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(x(this,ke)===x(this,de).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!x(this,ne)||!x(this,ee))return;j(this,W,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield x(this,ne).setChapter({chapterId:t,pushToHistory:!1}),x(this,me)||(j(this,me,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return x(this,me)}updateHistory(e,t=!0){return R(this,null,function*(){var a;if(!x(this,W))return;x(this,Oe)?(j(this,Oe,!1),Ti(this,ke)._++):j(this,ke,0);let i=x(this,W),n=e.length-x(this,de).maxLength,o=n>0?e.slice(n):e,s=oi(o,i);if(j(this,Wt,s),this.state.history$.next(o),!(!t||!x(this,re)||!x(this,ie)))try{yield x(this,re).save(x(this,ie),s)}catch(l){let c=new _(1,5,"Unable to save interactive history");this.events.error$.next(c),(a=x(this,ee))==null||a.emit(O.errors,c)}})}goBack(){return R(this,null,function*(){var i;if(!this.state||!x(this,ne)){let n=new _(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=x(this,ee))==null?void 0:i.emit(O.errors,n)}j(this,Oe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield x(this,ne).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var n;if(!x(this,W)||!x(this,ie))return;let e=x(this,W),t=[this.getInitialVideoId()];if(x(this,re))try{let o=yield x(this,re).get(x(this,ie));o.length&&(t=o)}catch(o){let s=new _(1,5,"Error while trying to fetch data");this.events.error$.next(s),(n=x(this,ee))==null||n.emit(O.errors,s)}let i=Vs(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,si.default)(e,-1)||x(this,de).initChapterId||((t=x(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(x(this,W)){let e=this.getInitialChapterId();return oi([e],x(this,W)).pop()}return null}destroy(){var e,t;j(this,ie,null),j(this,re,null),j(this,ne,null),(e=x(this,fe))==null||e.unsubscribe(),j(this,fe,null),j(this,me,!1),(t=x(this,ee))==null||t.emit(O.historyDestroyed),this.events.destroyed$.next(),j(this,ee,null)}};re=new WeakMap,de=new WeakMap,me=new WeakMap,W=new WeakMap,Wt=new WeakMap,ie=new WeakMap,ne=new WeakMap,ee=new WeakMap,fe=new WeakMap,Oe=new WeakMap,ke=new WeakMap;var Kt=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 o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return R(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i})}save(){return R(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Qt=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 No=Object.create;var Jt=Object.defineProperty,_o=Object.defineProperties,Fo=Object.getOwnPropertyDescriptor,qo=Object.getOwnPropertyDescriptors,Bo=Object.getOwnPropertyNames,at=Object.getOwnPropertySymbols,Do=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty,yi=Object.prototype.propertyIsEnumerable;var bi=r=>{throw TypeError(r)};var vi=(r,e,t)=>e in r?Jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))er.call(e,t)&&vi(r,t,e[t]);if(at)for(var t of at(e))yi.call(e,t)&&vi(r,t,e[t]);return r},E=(r,e)=>_o(r,qo(e));var Y=(r,e)=>{var t={};for(var i in r)er.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&at)for(var i of at(r))e.indexOf(i)<0&&yi.call(r,i)&&(t[i]=r[i]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Ho=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Bo(e))!er.call(r,n)&&n!==t&&Jt(r,n,{get:()=>e[n],enumerable:!(i=Fo(e,n))||i.enumerable});return r};var te=(r,e,t)=>(t=r!=null?No(Do(r)):{},Ho(e||!r||!r.__esModule?Jt(t,"default",{value:r,enumerable:!0}):t,r));var gi=(r,e,t)=>e.has(r)||bi("Cannot "+t);var w=(r,e,t)=>(gi(r,e,"read from private field"),t?t.call(r):e.get(r)),U=(r,e,t)=>e.has(r)?bi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$=(r,e,t,i)=>(gi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Ci=(r,e,t,i)=>({set _(n){$(r,e,n,t)},get _(){return w(r,e,i)}});var O=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{c(t.next(a))}catch(l){n(l)}},o=a=>{try{c(t.throw(a))}catch(l){n(l)}},c=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,o);c((t=t.apply(r,e)).next())});var X=p((cr,Ai)=>{"use strict";var Me=function(r){return r&&r.Math===Math&&r};Ai.exports=Me(typeof globalThis=="object"&&globalThis)||Me(typeof window=="object"&&window)||Me(typeof self=="object"&&self)||Me(typeof global=="object"&&global)||Me(typeof cr=="object"&&cr)||function(){return this}()||Function("return this")()});var G=p((Jh,Ri)=>{"use strict";Ri.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ve=p((ed,Oi)=>{"use strict";var Go=G();Oi.exports=!Go(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var ji=p((td,Vi)=>{"use strict";var zo=Ve(),Mi=Function.prototype,Pi=Mi.apply,ki=Mi.call;Vi.exports=typeof Reflect=="object"&&Reflect.apply||(zo?ki.bind(Pi):function(){return ki.apply(Pi,arguments)})});var K=p((rd,Ni)=>{"use strict";var Li=Ve(),$i=Function.prototype,lr=$i.call,Wo=Li&&$i.bind.bind(lr,lr);Ni.exports=Li?Wo:function(r){return function(){return lr.apply(r,arguments)}}});var je=p((id,Fi)=>{"use strict";var _i=K(),Ko=_i({}.toString),Qo=_i("".slice);Fi.exports=function(r){return Qo(Ko(r),8,-1)}});var ur=p((nd,qi)=>{"use strict";var Yo=je(),Xo=K();qi.exports=function(r){if(Yo(r)==="Function")return Xo(r)}});var z=p((sd,Bi)=>{"use strict";var pr=typeof document=="object"&&document.all;Bi.exports=typeof pr=="undefined"&&pr!==void 0?function(r){return typeof r=="function"||r===pr}:function(r){return typeof r=="function"}});var ue=p((ad,Di)=>{"use strict";var Zo=G();Di.exports=!Zo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var bt=p((od,Hi)=>{"use strict";var Jo=Ve(),yt=Function.prototype.call;Hi.exports=Jo?yt.bind(yt):function(){return yt.apply(yt,arguments)}});var hr=p(zi=>{"use strict";var Ui={}.propertyIsEnumerable,Gi=Object.getOwnPropertyDescriptor,ec=Gi&&!Ui.call({1:2},1);zi.f=ec?function(e){var t=Gi(this,e);return!!t&&t.enumerable}:Ui});var dr=p((ld,Wi)=>{"use strict";Wi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qi=p((ud,Ki)=>{"use strict";var tc=K(),rc=G(),ic=je(),fr=Object,nc=tc("".split);Ki.exports=rc(function(){return!fr("z").propertyIsEnumerable(0)})?function(r){return ic(r)==="String"?nc(r,""):fr(r)}:fr});var mr=p((pd,Yi)=>{"use strict";Yi.exports=function(r){return r==null}});var vr=p((hd,Xi)=>{"use strict";var sc=mr(),ac=TypeError;Xi.exports=function(r){if(sc(r))throw new ac("Can't call method on "+r);return r}});var Le=p((dd,Zi)=>{"use strict";var oc=Qi(),cc=vr();Zi.exports=function(r){return oc(cc(r))}});var Ce=p((fd,Ji)=>{"use strict";var lc=z();Ji.exports=function(r){return typeof r=="object"?r!==null:lc(r)}});var gt=p((md,en)=>{"use strict";en.exports={}});var Ct=p((vd,rn)=>{"use strict";var yr=gt(),br=X(),uc=z(),tn=function(r){return uc(r)?r:void 0};rn.exports=function(r,e){return arguments.length<2?tn(yr[r])||tn(br[r]):yr[r]&&yr[r][e]||br[r]&&br[r][e]}});var sn=p((yd,nn)=>{"use strict";var pc=K();nn.exports=pc({}.isPrototypeOf)});var ln=p((bd,cn)=>{"use strict";var hc=X(),an=hc.navigator,on=an&&an.userAgent;cn.exports=on?String(on):""});var vn=p((gd,mn)=>{"use strict";var fn=X(),gr=ln(),un=fn.process,pn=fn.Deno,hn=un&&un.versions||pn&&pn.version,dn=hn&&hn.v8,Q,Et;dn&&(Q=dn.split("."),Et=Q[0]>0&&Q[0]<4?1:+(Q[0]+Q[1]));!Et&&gr&&(Q=gr.match(/Edge\/(\d+)/),(!Q||Q[1]>=74)&&(Q=gr.match(/Chrome\/(\d+)/),Q&&(Et=+Q[1])));mn.exports=Et});var Cr=p((Cd,bn)=>{"use strict";var yn=vn(),dc=G(),fc=X(),mc=fc.String;bn.exports=!!Object.getOwnPropertySymbols&&!dc(function(){var r=Symbol("symbol detection");return!mc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&yn&&yn<41})});var Er=p((Ed,gn)=>{"use strict";var vc=Cr();gn.exports=vc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Ir=p((Id,Cn)=>{"use strict";var yc=Ct(),bc=z(),gc=sn(),Cc=Er(),Ec=Object;Cn.exports=Cc?function(r){return typeof r=="symbol"}:function(r){var e=yc("Symbol");return bc(e)&&gc(e.prototype,Ec(r))}});var In=p((Td,En)=>{"use strict";var Ic=String;En.exports=function(r){try{return Ic(r)}catch(e){return"Object"}}});var Tr=p((xd,Tn)=>{"use strict";var Tc=z(),xc=In(),Sc=TypeError;Tn.exports=function(r){if(Tc(r))return r;throw new Sc(xc(r)+" is not a function")}});var Sn=p((Sd,xn)=>{"use strict";var wc=Tr(),Ac=mr();xn.exports=function(r,e){var t=r[e];return Ac(t)?void 0:wc(t)}});var An=p((wd,wn)=>{"use strict";var xr=bt(),Sr=z(),wr=Ce(),Rc=TypeError;wn.exports=function(r,e){var t,i;if(e==="string"&&Sr(t=r.toString)&&!wr(i=xr(t,r))||Sr(t=r.valueOf)&&!wr(i=xr(t,r))||e!=="string"&&Sr(t=r.toString)&&!wr(i=xr(t,r)))return i;throw new Rc("Can't convert object to primitive value")}});var On=p((Ad,Rn)=>{"use strict";Rn.exports=!0});var Mn=p((Rd,kn)=>{"use strict";var Pn=X(),Oc=Object.defineProperty;kn.exports=function(r,e){try{Oc(Pn,r,{value:e,configurable:!0,writable:!0})}catch(t){Pn[r]=e}return e}});var It=p((Od,Ln)=>{"use strict";var Pc=On(),kc=X(),Mc=Mn(),Vn="__core-js_shared__",jn=Ln.exports=kc[Vn]||Mc(Vn,{});(jn.versions||(jn.versions=[])).push({version:"3.38.0",mode:Pc?"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 Ar=p((Pd,Nn)=>{"use strict";var $n=It();Nn.exports=function(r,e){return $n[r]||($n[r]=e||{})}});var $e=p((kd,_n)=>{"use strict";var Vc=vr(),jc=Object;_n.exports=function(r){return jc(Vc(r))}});var Ee=p((Md,Fn)=>{"use strict";var Lc=K(),$c=$e(),Nc=Lc({}.hasOwnProperty);Fn.exports=Object.hasOwn||function(e,t){return Nc($c(e),t)}});var Rr=p((Vd,qn)=>{"use strict";var _c=K(),Fc=0,qc=Math.random(),Bc=_c(1 .toString);qn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Bc(++Fc+qc,36)}});var Ne=p((jd,Dn)=>{"use strict";var Dc=X(),Hc=Ar(),Bn=Ee(),Uc=Rr(),Gc=Cr(),zc=Er(),Ie=Dc.Symbol,Or=Hc("wks"),Wc=zc?Ie.for||Ie:Ie&&Ie.withoutSetter||Uc;Dn.exports=function(r){return Bn(Or,r)||(Or[r]=Gc&&Bn(Ie,r)?Ie[r]:Wc("Symbol."+r)),Or[r]}});var zn=p((Ld,Gn)=>{"use strict";var Kc=bt(),Hn=Ce(),Un=Ir(),Qc=Sn(),Yc=An(),Xc=Ne(),Zc=TypeError,Jc=Xc("toPrimitive");Gn.exports=function(r,e){if(!Hn(r)||Un(r))return r;var t=Qc(r,Jc),i;if(t){if(e===void 0&&(e="default"),i=Kc(t,r,e),!Hn(i)||Un(i))return i;throw new Zc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Yc(r,e)}});var Pr=p(($d,Wn)=>{"use strict";var el=zn(),tl=Ir();Wn.exports=function(r){var e=el(r,"string");return tl(e)?e:e+""}});var Yn=p((Nd,Qn)=>{"use strict";var rl=X(),Kn=Ce(),kr=rl.document,il=Kn(kr)&&Kn(kr.createElement);Qn.exports=function(r){return il?kr.createElement(r):{}}});var Mr=p((_d,Xn)=>{"use strict";var nl=ue(),sl=G(),al=Yn();Xn.exports=!nl&&!sl(function(){return Object.defineProperty(al("div"),"a",{get:function(){return 7}}).a!==7})});var es=p(Jn=>{"use strict";var ol=ue(),cl=bt(),ll=hr(),ul=dr(),pl=Le(),hl=Pr(),dl=Ee(),fl=Mr(),Zn=Object.getOwnPropertyDescriptor;Jn.f=ol?Zn:function(e,t){if(e=pl(e),t=hl(t),fl)try{return Zn(e,t)}catch(i){}if(dl(e,t))return ul(!cl(ll.f,e,t),e[t])}});var rs=p((qd,ts)=>{"use strict";var ml=G(),vl=z(),yl=/#|\.prototype\./,_e=function(r,e){var t=gl[bl(r)];return t===El?!0:t===Cl?!1:vl(e)?ml(e):!!e},bl=_e.normalize=function(r){return String(r).replace(yl,".").toLowerCase()},gl=_e.data={},Cl=_e.NATIVE="N",El=_e.POLYFILL="P";ts.exports=_e});var Vr=p((Bd,ns)=>{"use strict";var is=ur(),Il=Tr(),Tl=Ve(),xl=is(is.bind);ns.exports=function(r,e){return Il(r),e===void 0?r:Tl?xl(r,e):function(){return r.apply(e,arguments)}}});var as=p((Dd,ss)=>{"use strict";var Sl=ue(),wl=G();ss.exports=Sl&&wl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var cs=p((Hd,os)=>{"use strict";var Al=Ce(),Rl=String,Ol=TypeError;os.exports=function(r){if(Al(r))return r;throw new Ol(Rl(r)+" is not an object")}});var ps=p(us=>{"use strict";var Pl=ue(),kl=Mr(),Ml=as(),Tt=cs(),ls=Pr(),Vl=TypeError,jr=Object.defineProperty,jl=Object.getOwnPropertyDescriptor,Lr="enumerable",$r="configurable",Nr="writable";us.f=Pl?Ml?function(e,t,i){if(Tt(e),t=ls(t),Tt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Nr in i&&!i[Nr]){var n=jl(e,t);n&&n[Nr]&&(e[t]=i.value,i={configurable:$r in i?i[$r]:n[$r],enumerable:Lr in i?i[Lr]:n[Lr],writable:!1})}return jr(e,t,i)}:jr:function(e,t,i){if(Tt(e),t=ls(t),Tt(i),kl)try{return jr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Vl("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ds=p((Gd,hs)=>{"use strict";var Ll=ue(),$l=ps(),Nl=dr();hs.exports=Ll?function(r,e,t){return $l.f(r,e,Nl(1,t))}:function(r,e,t){return r[e]=t,r}});var qe=p((zd,ms)=>{"use strict";var Fe=X(),_l=ji(),Fl=ur(),ql=z(),Bl=es().f,Dl=rs(),Te=gt(),Hl=Vr(),xe=ds(),fs=Ee();It();var Ul=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 _l(r,this,arguments)};return e.prototype=r.prototype,e};ms.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,o=i?Fe:n?Fe[t]:Fe[t]&&Fe[t].prototype,c=i?Te:Te[t]||xe(Te,t,{})[t],a=c.prototype,l,m,v,d,b,x,R,y,M;for(d in e)l=Dl(i?d:t+(n?".":"#")+d,r.forced),m=!l&&o&&fs(o,d),x=c[d],m&&(r.dontCallGetSet?(M=Bl(o,d),R=M&&M.value):R=o[d]),b=m&&R?R:e[d],!(!l&&!s&&typeof x==typeof b)&&(r.bind&&m?y=Hl(b,Fe):r.wrap&&m?y=Ul(b):s&&ql(b)?y=Fl(b):y=b,(r.sham||b&&b.sham||x&&x.sham)&&xe(y,"sham",!0),xe(c,d,y),s&&(v=t+"Prototype",fs(Te,v)||xe(Te,v,{}),xe(Te[v],d,b),r.real&&a&&(l||!a[d])&&xe(a,d,b)))}});var ys=p((Wd,vs)=>{"use strict";var Gl=Math.ceil,zl=Math.floor;vs.exports=Math.trunc||function(e){var t=+e;return(t>0?zl:Gl)(t)}});var Be=p((Kd,bs)=>{"use strict";var Wl=ys();bs.exports=function(r){var e=+r;return e!==e||e===0?0:Wl(e)}});var Cs=p((Qd,gs)=>{"use strict";var Kl=Be(),Ql=Math.min;gs.exports=function(r){var e=Kl(r);return e>0?Ql(e,9007199254740991):0}});var De=p((Yd,Es)=>{"use strict";var Yl=Cs();Es.exports=function(r){return Yl(r.length)}});var xt=p((Xd,Is)=>{"use strict";Is.exports=function(){}});var Ts=p(()=>{"use strict";var Xl=qe(),Zl=$e(),Jl=De(),eu=Be(),tu=xt();Xl({target:"Array",proto:!0},{at:function(e){var t=Zl(this),i=Jl(t),n=eu(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});tu("at")});var St=p((ef,xs)=>{"use strict";var ru=Ct();xs.exports=ru});var ws=p((tf,Ss)=>{"use strict";Ts();var iu=St();Ss.exports=iu("Array","at")});var Rs=p((rf,As)=>{"use strict";var nu=ws();As.exports=nu});var _r=p((nf,Os)=>{"use strict";var su=Rs();Os.exports=su});var Gs=p((Cm,Us)=>{"use strict";var mu=Ar(),vu=Rr(),Hs=mu("keys");Us.exports=function(r){return Hs[r]||(Hs[r]=vu(r))}});var Ws=p((Em,zs)=>{"use strict";var yu=G();zs.exports=!yu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ys=p((Im,Qs)=>{"use strict";var bu=Ee(),gu=z(),Cu=$e(),Eu=Gs(),Iu=Ws(),Ks=Eu("IE_PROTO"),Kr=Object,Tu=Kr.prototype;Qs.exports=Iu?Kr.getPrototypeOf:function(r){var e=Cu(r);if(bu(e,Ks))return e[Ks];var t=e.constructor;return gu(t)&&e instanceof t?t.prototype:e instanceof Kr?Tu:null}});var Zs=p((Tm,Xs)=>{"use strict";var xu=Be(),Su=Math.max,wu=Math.min;Xs.exports=function(r,e){var t=xu(r);return t<0?Su(t+e,0):wu(t,e)}});var Qr=p((xm,ea)=>{"use strict";var Au=Le(),Ru=Zs(),Ou=De(),Js=function(r){return function(e,t,i){var n=Au(e),s=Ou(n);if(s===0)return!r&&-1;var o=Ru(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}};ea.exports={includes:Js(!0),indexOf:Js(!1)}});var ra=p((Sm,ta)=>{"use strict";ta.exports={}});var sa=p((wm,na)=>{"use strict";var Pu=K(),Yr=Ee(),ku=Le(),Mu=Qr().indexOf,Vu=ra(),ia=Pu([].push);na.exports=function(r,e){var t=ku(r),i=0,n=[],s;for(s in t)!Yr(Vu,s)&&Yr(t,s)&&ia(n,s);for(;e.length>i;)Yr(t,s=e[i++])&&(~Mu(n,s)||ia(n,s));return n}});var oa=p((Am,aa)=>{"use strict";aa.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var la=p((Rm,ca)=>{"use strict";var ju=sa(),Lu=oa();ca.exports=Object.keys||function(e){return ju(e,Lu)}});var ma=p((Om,fa)=>{"use strict";var pa=ue(),$u=G(),ha=K(),Nu=Ys(),_u=la(),Fu=Le(),qu=hr().f,da=ha(qu),Bu=ha([].push),Du=pa&&$u(function(){var r=Object.create(null);return r[2]=2,!da(r,2)}),ua=function(r){return function(e){for(var t=Fu(e),i=_u(t),n=Du&&Nu(t)===null,s=i.length,o=0,c=[],a;s>o;)a=i[o++],(!pa||(n?a in t:da(t,a)))&&Bu(c,r?[a,t[a]]:t[a]);return c}};fa.exports={entries:ua(!0),values:ua(!1)}});var va=p(()=>{"use strict";var Hu=qe(),Uu=ma().values;Hu({target:"Object",stat:!0},{values:function(e){return Uu(e)}})});var ba=p((Mm,ya)=>{"use strict";va();var Gu=gt();ya.exports=Gu.Object.values});var Ca=p((Vm,ga)=>{"use strict";var zu=ba();ga.exports=zu});var Bt=p((jm,Ea)=>{"use strict";var Wu=Ca();Ea.exports=Wu});var xa=p(()=>{"use strict";var Ku=qe(),Qu=Qr().includes,Yu=G(),Xu=xt(),Zu=Yu(function(){return!Array(1).includes()});Ku({target:"Array",proto:!0,forced:Zu},{includes:function(e){return Qu(this,e,arguments.length>1?arguments[1]:void 0)}});Xu("includes")});var wa=p((qm,Sa)=>{"use strict";xa();var Ju=St();Sa.exports=Ju("Array","includes")});var Ra=p((Bm,Aa)=>{"use strict";var ep=wa();Aa.exports=ep});var Dt=p((Dm,Oa)=>{"use strict";var tp=Ra();Oa.exports=tp});var ti=p((cv,ja)=>{"use strict";var op=je();ja.exports=Array.isArray||function(e){return op(e)==="Array"}});var $a=p((lv,La)=>{"use strict";var cp=TypeError,lp=9007199254740991;La.exports=function(r){if(r>lp)throw cp("Maximum allowed index exceeded");return r}});var Fa=p((uv,_a)=>{"use strict";var up=ti(),pp=De(),hp=$a(),dp=Vr(),Na=function(r,e,t,i,n,s,o,c){for(var a=n,l=0,m=o?dp(o,c):!1,v,d;l<i;)l in t&&(v=m?m(t[l],l,e):t[l],s>0&&up(v)?(d=pp(v),a=Na(r,e,v,d,a,s-1)-1):(hp(a+1),r[a]=v),a++),l++;return a};_a.exports=Na});var Da=p((pv,Ba)=>{"use strict";var fp=Ne(),mp=fp("toStringTag"),qa={};qa[mp]="z";Ba.exports=String(qa)==="[object z]"});var Ua=p((hv,Ha)=>{"use strict";var vp=Da(),yp=z(),Ut=je(),bp=Ne(),gp=bp("toStringTag"),Cp=Object,Ep=Ut(function(){return arguments}())==="Arguments",Ip=function(r,e){try{return r[e]}catch(t){}};Ha.exports=vp?Ut:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Ip(e=Cp(r),gp))=="string"?t:Ep?Ut(e):(i=Ut(e))==="Object"&&yp(e.callee)?"Arguments":i}});var za=p((dv,Ga)=>{"use strict";var Tp=K(),xp=z(),ri=It(),Sp=Tp(Function.toString);xp(ri.inspectSource)||(ri.inspectSource=function(r){return Sp(r)});Ga.exports=ri.inspectSource});var Za=p((fv,Xa)=>{"use strict";var wp=K(),Ap=G(),Wa=z(),Rp=Ua(),Op=Ct(),Pp=za(),Ka=function(){},Qa=Op("Reflect","construct"),ii=/^\s*(?:class|function)\b/,kp=wp(ii.exec),Mp=!ii.test(Ka),Je=function(e){if(!Wa(e))return!1;try{return Qa(Ka,[],e),!0}catch(t){return!1}},Ya=function(e){if(!Wa(e))return!1;switch(Rp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Mp||!!kp(ii,Pp(e))}catch(t){return!0}};Ya.sham=!0;Xa.exports=!Qa||Ap(function(){var r;return Je(Je.call)||!Je(Object)||!Je(function(){r=!0})||r})?Ya:Je});var ro=p((mv,to)=>{"use strict";var Ja=ti(),Vp=Za(),jp=Ce(),Lp=Ne(),$p=Lp("species"),eo=Array;to.exports=function(r){var e;return Ja(r)&&(e=r.constructor,Vp(e)&&(e===eo||Ja(e.prototype))?e=void 0:jp(e)&&(e=e[$p],e===null&&(e=void 0))),e===void 0?eo:e}});var no=p((vv,io)=>{"use strict";var Np=ro();io.exports=function(r,e){return new(Np(r))(e===0?0:e)}});var so=p(()=>{"use strict";var _p=qe(),Fp=Fa(),qp=$e(),Bp=De(),Dp=Be(),Hp=no();_p({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=qp(this),i=Bp(t),n=Hp(t,0);return n.length=Fp(n,t,t,i,0,e===void 0?1:Dp(e)),n}})});var ao=p(()=>{"use strict";var Up=xt();Up("flat")});var co=p((Ev,oo)=>{"use strict";so();ao();var Gp=St();oo.exports=Gp("Array","flat")});var uo=p((Iv,lo)=>{"use strict";var zp=co();lo.exports=zp});var ho=p((Tv,po)=>{"use strict";var Wp=uo();po.exports=Wp});var Ei="1.0.30-dev.f55796c8.0";function tr(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 B="interactive",Uo="interactive-controls-container",ot=()=>document.querySelector(`.${Uo}`),Ii=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ti=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ti||{}),xi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(xi||{}),Si=(i=>(i.start="left",i.end="right",i.center="center",i))(Si||{}),ct=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ti[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&xi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Si[e.alignment])!=null?n:"left"},lt=({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},ut=({target:r,props:e,fallback:t})=>{var i,n,s,o;r.style.backgroundColor=tr((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)},pt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,o,c,a,l,m,v,d,b,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 ${tr((l=(a=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:a.color)!=null?l:t.borderColor,(d=(v=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:v.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(x=(b=e==null?void 0:e.shape)==null?void 0:b.roundCorners)!=null?x:t.roundCorners})`},be=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var re=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(`${B}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:q.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var rr="int",le=(i=>(i.AREA=`${rr}_area`,i.TEXT=`${rr}_text`,i.BUTTON=`${rr}_bttn`,i))(le||{});var ht=r=>{if(r.type.trim().toLowerCase()==="area")return new ir(r)},ir=class extends re{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(`${B}-${this.control.id}`),i.setAttribute("data-testid",le.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",ut({target:i,props:this.control.props,fallback:E(f({},q),{backgroundColor:"transparent"})}),pt({target:i,props:this.control.props,fallback:E(f({},q),{borderAlpha:0}),dependsOn:this.container.dimensions}),be({target:i,layoutParams:this.control.layoutParams,fallback:q}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var dt=()=>{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 ft=r=>{if(r.type.trim().toLowerCase()==="button")return new nr(r)},nr=class extends re{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(`${B}-${this.control.id}`),i.setAttribute("data-testid",le.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",be({target:i,layoutParams:this.control.layoutParams,fallback:q}),ut({target:i,props:this.control.props,fallback:q}),pt({target:i,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),ct({target:i,props:E(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=dt();lt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var wi=r=>{if(r.type.trim().toLowerCase()==="text")return new sr(r)},sr=class extends re{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",le.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",be({target:i,layoutParams:this.control.layoutParams,fallback:q}),ct({target:i,props:E(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=dt();lt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var ar=class{constructor(e){this.layout=e}},mt=class extends ar{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ge=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);if(s){let o=s(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var vt=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new or(r,e)},or=class extends ge{constructor(e,t){super(e),this.rootElement=t!=null?t:ot(),this.layout=new mt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ft),this.addControlFactory("text",wi),this.addControlFactory("area",ht)}createView(e){let t=document.createElement("div");return t.classList.add(`${B}-${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=`${Ii}`,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(`.${B}-${this.container.id}`)}};var $o=te(_r(),1);import{clientChecker as nh,combine as sh,InterfaceLanguage as ah,Observable as jo,once as oh,Subject as D,Subscription as li,ValueSubject as H}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as it}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as au}from"@vkontakte/videoplayer-shared/es2015";function He(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var pe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Ue=r=>pe(r,"Object"),wt=r=>pe(r,"String"),At=r=>pe(r,"Array"),Rt=r=>pe(r,"Number"),Ps=r=>pe(r,"Function");var Fr=r=>Rt(r)&&!isNaN(r);var he=r=>Ue(r)&&Object.keys(r).length===0,qr=r=>At(r)&&!r.length;var Ge=(r,e)=>wt(r)&&(e?r.trim():r).length;var ks="video_interactive",Ms="videoint";var Vs=250,ze=class{constructor(e){this.handleZoomChange=He(e=>{this.lastZoomInfo=e},Vs);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,!Rt(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=ou(e),this.resizeObserver=new ResizeObserver(He(this.onResize,Vs)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return O(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return O(this,null,function*(){if(!this.manifest)return;let e;try{e=yield au(this.lang,ks,Ms)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",s=>{var o=s,{name:i}=o,n=Y(o,["name"]);var c;i==="openPreview"&&"chapterId"in n&&((c=this.onOpenPreviewClick)==null||c.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 ou(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 We=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 Pt,ContainerTypes as Pf,ControlTypes as kt,EventActionTypes as k,EventTypes as kf,migrateManifestToLatestVersion as Ns,compareVersions as Mf}from"@interactiveplatform/movika-manifest";var js={metadata:"Object",chapters:"Array"},Ls=r=>{if(!Ue(r))return!1;for(let e in js)if(!r[e]||!pe(r[e],js[e]))return!1;return Pt(r.metadata.version)},Ot=r=>r.type===kt.Text,If=r=>r.type===kt.Button,Tf=r=>r.type===kt.Area,xf={Choice:"Choice",TextInput:"TextInput"},Sf={Button:"Button",Area:"Area",Text:"Text"},wf={onClick:"onClick",onSuspense:"onSuspense"},$s={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var _=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Mt=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 Vt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Ps(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 fu}from"@vkontakte/videoplayer-shared/es2015";var jt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,t){return O(this,null,function*(){return cu(...this.loaders[e])(t)})}};function cu(...r){return function(t){return O(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Ke(r,e,t){return r?E(f({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Lt(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=Y(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest(),c=r.getChapter(o.chapters,t);if(c){let a=r.getMedia(o.media,c.videoId),l=r.getGraph(o.graph,c.id);return a?E(f({},i),{actions:r,errors:e,result:{chapter:c,media:a,graph:l}}):E(f({},i),{errors:Ke(e,Lt.name,"Could not find media"),actions:r})}}return E(f({},i),{errors:Ke(e,Lt.name,"Could not find chapter"),actions:r})}var $t=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}},Se=class extends $t{constructor(){super(),this.listeners||$t.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)}},Qe=class{constructor(){Object.defineProperty(this,"signal",{value:new Se,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&&(Qe.prototype[Symbol.toStringTag]="AbortController",Se.prototype[Symbol.toStringTag]="AbortSignal");function Nt(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 Br(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Nt({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 v;m&&m.signal&&(v=m.signal,delete m.signal);let d=new t(l,m);return v&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),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 v;try{v=new DOMException("Aborted","AbortError")}catch(b){v=new Error("Aborted"),v.name="AbortError"}if(m.aborted)return Promise.reject(v);let d=new Promise((b,x)=>{m.addEventListener("abort",()=>x(v),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([d,o(a,l)])}return o(a,l)},Request:s}}var Ye=Nt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),_s=Ye?Br({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Dr=Ye?_s.fetch:window.fetch,Xf=Ye?_s.Request:window.Request,Zf=Ye?Qe:window.AbortController,Jf=Ye?Se:window.AbortSignal;var Hr=(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 lu=r=>O(void 0,null,function*(){try{let e={},t;if(wt(r)){t=new URL(r).href;let n=yield Dr(t);if(!n.ok)return{};e=yield n.json()}else if(Ue(r))e=r;else return{};if(!Ls(e))return{};let i=e.metadata.media;if(wt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Dr(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return hu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Fs(r){return O(this,null,function*(){let{manifest:e,manifestURL:t}=yield lu(r);if(!e)throw new Error("Failed on fetch");let i=Ns(e);return i.media=uu(i.media,t),delete i.metadata.media,i})}function _t(r,e){if(e)return r.find(t=>t.id===e)}function Ur(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 Gr(r,e){return r.videos.find(t=>t.id===e)}function uu(r,e){return E(f({},r),{videos:r.videos.map(t=>E(f({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=pu(n,e);return E(f({},i),{url:s||n})})}))})}function pu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function hu(r){return Hr(r,"3.2.0")>=0}var Ft=r=>At(r)&&!qr(r),Z=r=>r.order==="end",qt=r=>At(r.containers)&&!qr(r.containers)&&Z(r),qs=(r,e)=>{var i;let t=r*1e3;return Ft(e.controls)&&t<((i=e.startTime)!=null?i:0)},zr=(r,e)=>{var i,n;let t=r*1e3;return Ft(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var de=(r=[])=>r.some(e=>e.action.type==="expect"),Wr=(r=[])=>r.find(e=>e.action.type==="expect"),du=r=>(r==null?void 0:r.length)===1,we=r=>du(r)&&Ot(r[0]);function Bs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(f(f({},e[0]),t)):r(...e,...t)}var Ds=(r,e)=>{let t=d=>{let b=e.find(({container:x})=>x.container.id===d);return b==null?void 0:b.container.isRemoved},i=de(r.events)&&!t(r.id),n=(d,b=!1,x=!1)=>{let R=x?"every":"some";return d.controls[R](y=>{var L;let M=b?d.endTime===r.endTime:!0;return((L=y.events)==null?void 0:L[R](u=>{var h;return((h=u.action)==null?void 0:h.type)===$s.openURI}))&&M})},s=d=>d.some(({container:b})=>n(b.container,!0,!1)&&!b.isRemoved),o=d=>d.every(({container:b})=>b.isRemoved?!0:n(b.container,!0,!0)),c=e.filter(({container:d})=>d.container.id!==r.id&&de(d.container.events)&&d.container.endTime===r.endTime&&!d.isRemoved).length,a=i||c>0,l=s(e),m=n(r),v=o(e);return{isExpectTime:a,hasOtherExpect:c>0,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:v}};var Ae=class extends jt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new fu(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return O(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ke},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield Fs((n=i.result)!=null?n:t),this})}setInitial(){return O(this,null,function*(){return this.setNext()})}setNext(){return O(this,arguments,function*(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=yield this.exec("chapterLoaders",Lt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Ur,getChapter:_t,getMedia:Gr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ke},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=_t(this.manifest.chapters,t);if(n){let s=Gr(this.manifest.media,n.videoId),o=Ur(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=_t(((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?Z(this.chapter):!1}};var Pa=te(Bt(),1);import{Player as rp}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Jr,Tracer as ip,ValueSubject as np}from"@vkontakte/videoplayer-shared/es2015";var Ia=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 Ta=te(Bt(),1);function Xr(){let r=new Map;function e(a){var l=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=l,c=Y(l,["listId","itemId"]);let m=r.get(s),v=f({},c);return m?m[o]=v:r.set(s,{[o]:v}),f({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,Ta.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 Re=te(Dt(),1);function Zr(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,Re.default)(e,"mp4"))&&(t.MPEG=E(f({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||(0,Re.default)(e,"mpeg"))&&(t.MPEG=E(f({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(n||(0,Re.default)(e,"hls"))&&(t=E(f({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||(0,Re.default)(e,"dash"))&&(t=E(f({},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 Xe=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Re.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var sp=2;function ei(r){let e=Xr(),t=new Jr,i={},n=null,s=!1,o,c=new np(null);r&&a(r);function a(y){n=y}function l(y,M,L){var g;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let h=((g=e.map.get(y))!=null?g:{})[M];if(h){i=f({chapterId:L,listId:y,itemId:M},h);let I=i.player;i.subscription.add(I.info.currentQuality$.subscribe(T=>{let j=I.info.position$.getValue(),P=I.info.isAutoQualityEnabled$.getValue();if(!(!T||!j||P))for(let C of e.map)(0,Pa.default)(C[1]).forEach(({player:S})=>{Xe(S,T)})})).add(I.events.started$.subscribe(()=>{m(M)})),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.")}function m(y){return O(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(he(i)||y!==i.itemId)return;let M=n.getChapterBranches(),L=new Set;for(let u of M)L.has(u.media.id)||(yield d({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),L.add(u.media.id))})}function v(L){return O(this,arguments,function*({chapter:{id:y},manifestVideo:M}){if(he(i)||!n)return;let u=i.player.info.muted$.getValue(),h=i.player.info.currentQuality$.getValue(),g=i.player.info.isAutoQualityEnabled$.getValue(),I=i.player.info.volume$.getValue(),T=i.player.info.currentPlaybackRate$.getValue(),j=!g,P=!1;for(let C of e.map)if(C[0]===M.id&&!n.state.isReplay$.getValue()){let S=Object.keys(C[1]);for(let N of S)N===i.itemId?(S.length<sp||(P=!0),e.removePlayer(C[0],N)):(P=!0,l(C[0],N,y),j?Xe(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(I),i.player.setMuted(u),i.player.setPlaybackRate(T))}else e.removePlayer(C[0]);P||(yield d({media:M,chapterId:y,setAsActive:!0,playbackRate:T}),j?Xe(i.player,h):i.player.setAutoQuality(!0),i.player.setVolume(I),i.player.setMuted(u))})}function d(j){return O(this,arguments,function*({media:y,chapterId:M,prefetch:L=!0,setAsActive:u=!0,autoplay:h=!1,preferredExt:g,title:I,playbackRate:T}){var ui,pi,hi,di,fi;let P=Math.random().toString(),C=document.createElement("div");o.append(C);let S;if((ui=n==null?void 0:n.options)!=null&&ui.vkVideoLoader){let st=Ia(y);st.length&&(S=yield n.options.vkVideoLoader(...st))}let N=((pi=n==null?void 0:n.options)==null?void 0:pi.coreConfig)||void 0,ae=E(f({},N),{configName:[...(hi=N==null?void 0:N.configName)!=null?hi:[],"interactive"]}),ee=E(f({container:C},((di=S==null?void 0:S.videos)==null?void 0:di[0])||{sources:Zr(y,g).sources}),{title:I,failoverHosts:(S==null?void 0:S.failoverHosts)||[]}),F=new rp(ae,ip.createRootTracer());F.initVideo(ee);let ce=null;if(S!=null&&S.videos&&(n!=null&&n.options.createOneStat)){let st=S.videos[0],Zt=n.options.createOneStat(st),mi=new Jr;Zt&&(mi.add(Zt.attachTo(F)),ce={oneStat:Zt,statSubscription:mi})}let nt=new Jr,ke=(fi=i==null?void 0:i.player)==null?void 0:fi.info.isAutoQualityEnabled$.getValue();nt.add(F.events.canplay$.subscribe(function(){ke||Xe(F,i.player.info.currentQuality$.getValue()),T&&F.setPlaybackRate(T)}));let oe=e.createPlayer({listId:y.id,itemId:P,player:F,container:C,sources:Zr(y,g).sources,config:ee,subscription:nt,statistics:ce});return u&&l(y.id,oe.itemId,M),h&&oe.player.play(),L&&!h&&oe.player.prepare(),{player:oe.player,config:oe.config,statistics:oe.statistics}})}function b(){x(),n=null,o.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function R(){return O(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),o=document.createElement("div");let{media:y,chapter:M}=n.getCurrentChapter();y&&M?(t.add(n.events.chapterChanged$.subscribe(v)),yield d({media:y,chapterId:M.id,title:M.label})):console.error("not found")})}return E(f({},e),{init:R,setInteractiveController:a,createPlayer:d,removeAll:b,getActivePlayer:function(){return i},activePlayerChanged:c})}var A={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ze={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},V={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",containerFakeRemoved:"container-fake-removed",rangeEnded:"range-ended"};var Ma=te(Dt(),1);import{Subscription as ap}from"@vkontakte/videoplayer-shared/es2015";var Ht=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEvents:o,globalEventEmitter:c,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:m,disabledControls$:v,onRemove:d}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(de(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=Bs(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:v,hasOpenURIEventInCurrentContainer:d,isAllOpenURIEventsValid:b}=this.getContainerEventState(),x=this.interactiveTimeOpenUri&&!d,R=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||x)&&(this.isSelectedControlEvent=!0),c!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||x)){if(this.interactiveTimeOpenUri){let y=!m&&!b&&d;y&&this.globalEventEmitter.emit(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.containerFakeRemoved,visibility:!1,removeAllOpenURI:y})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&v&&this.gameState!==5){if(R){let M=((L,u,h,g)=>!L&&!u&&h||L&&!u&&h&&!g||L&&!u&&h&&g)(l,m,b,this.isSelectedContainerEvent);this.fakeRemoveView(M)}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,v;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,Ma.default)(n,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(qs(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(zr(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(),b=this.selectBranches.state.isExpect;if(this.interactiveTimeOpenUri&&d&&!b){let R=this.container.getElement();if(R){if(R.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=zr(s,this.container.container),c=this.container.container.startTime?[this.container.container.startTime,(v=this.container.container.endTime)!=null?v:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:c,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(A.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new ap,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&we(t.container.controls),this.interactiveTimeOpenUri=m,this.disabledControls$=v,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(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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:de(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(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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 Va=(r=[])=>r.reduce((e,t,i)=>{var s,o,c;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!Ot(a));if(Ft(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=[],v=-1/0,d=1/0,b=[],x=[];for(let R=0;R<e.length;R++){let y=e[R];if(x.push(...y.subjects),y.range[0]<d&&(d=y.range[0]),y.range[1]>v&&(v=y.range[1]),a[0]>=y.range[0]&&a[1]<=y.range[1])return e[R].subjects.push(l),e;a[0]<y.range[0]&&a[1]>y.range[0]&&(m.push(R),b=b.concat(y.subjects)),a[0]>=y.range[0]&&a[0]<=y.range[1]&&(m.push(R),b=b.concat(y.subjects),a[0]=y.range[0]),a[1]>=y.range[0]&&a[1]<=y.range[1]&&(m.push(R),b=b.concat(y.subjects),a[1]=y.range[1])}if(x.push(l),a[0]<=d&&a[1]>=v)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(R=>{e.splice(R,1)}),e.push({subjects:b.concat([l]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var mo=te(Dt(),1),ni=te(Bt(),1),vo=te(ho(),1);function fo(){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(Fr(c)){let v=(m=r[c])!=null?m:null;if(v&&a&&Ge(a,!0)){let d={},b=v[a];if(b&&(d=f(f({},d),b)),d=he(d)?null:d,d&&Ge(l,!0)){let x=d[l];return x!=null?x:null}return d}return v}return null}function s({timestamp:c,priority:a,initiator:l}){if(Fr(c))if(r[c]){if(a&&Ge(a,!0))if(r[c][a]){if(l&&Ge(l,!0))if(r[c][a][l]){if(delete r[c][a][l],!he(r[c][a]))return!0}else return!1;if(delete r[c][a],!he(r[c]))return!0}else return!1;return delete r[c]}else return!1;return!1}function o(v){var d=v,{timestamp:c,priority:a,initiator:l}=d,m=Y(d,["timestamp","priority","initiator"]);var b,x,R;(x=(b=r[c])==null?void 0:b[a])!=null&&x[l]?r[c][a][l].push(f({},m)):(R=r[c])!=null&&R[a]?r[c][a]=E(f({},r[c][a]),{[l]:[f({},m)]}):r[c]?r[c]=E(f({},r[c]),{[a]:{[l]:[f({},m)]}}):r[c]={[a]:{[l]:[f({},m)]}}}return{map:r,remove:s,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var Kp=[k.expect,k.setNextBranch],Qp=1/0;function yo(r,e){let t=r,i,n=Yp(e),s=fo(),o,c=()=>{b(),L()},a=u=>{s.add.call(void 0,u),R()},l=(u=[])=>{for(let h of u)if(h.action(),(0,mo.default)(Kp,h.actionType))break},m=(u=1/0)=>{var T,j,P;let h=Gt((T=s.get({timestamp:u,priority:"control"}))!=null?T:{}),g=Gt((j=s.get({timestamp:u,priority:"container"}))!=null?j:{}),I=Gt((P=s.get({timestamp:u,priority:"chapter"}))!=null?P:{});return[...h,...g,...I]},v=u=>{n.isReady(u)&&l(m(u))},d=()=>{var u;l([...Gt((u=s.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},b=()=>{i&&(o==null||o.unsubscribe(),i=void 0)},x=u=>{},R=()=>{i||(i=()=>setTimeout(()=>{v(1/0)}),o=t.events.ended$.subscribe(i))},y=u=>{b(),t=u},M=u=>{u.priority==="container"&&n.resetCalled(u.timestamp),s.remove(u)},L=()=>{n.release(),s.removeAll()};return{setPlayer:y,add:a,remove:M,exec:v,execEndOfVideo:d,listen:R,unlisten:b,release:c,containersEventsCallState:n,getPreparedToExecActions:m}}function Yp(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 v=(a=m.endTime)!=null?a:Qp,d=(l=e.get(v))!=null?l:{};e.set(v,E(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,ni.default)(a);return r?l.some(v=>v):!l.some(v=>!v)},release:()=>e.clear()}}function Gt(r){return(0,vo.default)((0,ni.default)(r)).sort(e=>e.actionType===k.expect?-1:1)}var bo={videoContentHeight:0,videoContentWidth:0},go=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return bo;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return bo;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 Xp=250;function Co(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:v}=go(a,l);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${v}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=He(c=>{let{fns:a=[]}=r();i(c);for(let l of a)l()},Xp);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var et=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 Zp=r=>Math.floor(Math.random()*r),Io=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},To=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 xo=r=>{let e=r.length,t=Zp(e);return r[t]},Eo=1,So=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:Eo;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:Eo,e>=t)return r[s];return r[r.length-1]};var wo={shouldOpenNow:!0,isDetachContainer:!0},Ao="after-expect";var si=(r,e=!1)=>E(f({},r),{args:e?f(f({},r.args),wo):f(f({},wo),r.args)}),Po=({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:g,containerId:I,branches:T=[],onEvent:j,isEOV:P=()=>!1,isDisabled:C=()=>!1})=>{let S=si(u,P()),N={timestamp:1/0,priority:"control",initiator:g,actionType:S.type},ae=C(),ee=r.emit.bind(r,A.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:ae?V.actionChoiceCanceled:V.actionChoice,actionType:u.type,payload:f({containerId:I},S.args)}),F=()=>{e.interactiveActionChoice$.next({subjectId:g,subjectType:h,subjectName:"control",type:ae?"action-choice-canceled":"action-choice",actionType:u.type,payload:f({containerId:I},S.args)})};if(ae){ee(),F();return}switch(S.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let ke=T.find(oe=>oe.id===S.args.branchId);if(!ke)return;j(S.args.isDetachContainer,x.bind(null,{subjectId:g,subjectName:"control"})),ee(),F(),S.args.shouldOpenNow?y({subjectId:g,subjectName:"control",subjectType:h,action:S,payload:{chapterId:ke.chapterId,autoSelect:!1}}):(i.add(E(f({},N),{action:y.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:S,payload:{chapterId:ke.chapterId,autoSelect:!1}})})),n==null||n());return}case k.continuePlayback.trim().toLowerCase():{j(S.args.isDetachContainer,x.bind(null,{subjectId:g,subjectName:"control"})),ee(),F(),S.args.shouldOpenNow?R({subjectId:g,subjectName:"control",subjectType:h,action:u}):i.add(E(f({},N),{action:R.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:u})}));return}case k.openURI.trim().toLowerCase():{j(S.args.isDetachContainer,x.bind(null,{subjectId:g,subjectName:"control"})),ee(),F(),S.args.shouldOpenNow?L({subjectId:g,subjectName:"control",subjectType:h,action:S,payload:{URI:u.args.uri}}):(i.add(E(f({},N),{action:L.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:S,payload:{URI:u.args.uri}})})),n==null||n());return}default:let ce="Unexpected control event",nt=new _(1,1,{message:ce});v(nt,ce);return}},a=({action:u,container:{id:h,endTime:g},branches:I=[],isEOV:T=!1,autoSelected:j=!1})=>{let P=si(u,T),C={timestamp:!P.args.shouldOpenNow||T?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:P.type},S=r.emit.bind(r,A.interactives,{subjectId:h,subjectName:"container",type:V.actionChoice,actionType:P.type,payload:P.args}),N=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:P.type,payload:P.args})};switch(P.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let F=I.find(ce=>ce.id===P.args.branchId);if(!F)return;S(),N(),i.add(E(f({},C),{action:y.bind(null,{subjectId:h,subjectName:"container",action:P,payload:{chapterId:F.chapterId,autoSelect:j}})})),n==null||n();return}case k.setMaxWeightBranch.trim().toLowerCase():return;case k.setMinWeightBranch.trim().toLowerCase():return;case k.setRandomBranch.trim().toLowerCase():return;case k.setWeightlessRandomBranch.trim().toLowerCase():return;case k.continuePlayback.trim().toLowerCase():{S(),N(),i.add(E(f({},C),{action:R.bind(null,{subjectId:h,subjectName:"container",action:P})}));return}case k.openURI.trim().toLowerCase():{S(),N(),i.add(E(f({},C),{action:L.bind(null,{subjectId:h,subjectName:"container",action:P,payload:{URI:u.args.uri}})})),n==null||n();return}default:let ae="Unexpected container event",ee=new _(1,1,{message:ae});v(ee,ae);return}};function l({container:u,branches:h,isEOV:g=!1}){var T,j;let I=Wr(u.events);if(I){let P=si(I.action,g);r.emit(A.interactives,{subjectId:u.id,subjectName:"container",type:V.actionChoice,actionType:P.type,payload:P.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:P.type,payload:P.args}),i.add({timestamp:g?1/0:(T=u.endTime)!=null?T:1/0,priority:"container",initiator:u.id,actionType:k.expect,action:b.bind(null,{subjectId:u.id,subjectName:"container"})}),s.isExpect=!0}else for(let P of(j=u.events)!=null?j:[])a({action:P.action,container:u,branches:h,isEOV:g})}let m=({chapterId:u,action:h,branches:g=[]})=>{let I=r.emit.bind(r,A.interactives,{subjectId:u,subjectName:"chapter",type:V.actionChoice,actionType:h.type,payload:h.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let C=g.find(S=>S.id===h.args.branchId);return C!=null&&C.chapterId?(I(),T(),y.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case k.setWeightlessRandomBranch.trim().toLowerCase():{let C=xo(g);return C!=null&&C.chapterId?(I(),T(),y.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case k.setRandomBranch.trim().toLowerCase():{let C=So(g);return C!=null&&C.chapterId?(I(),T(),y.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case k.setMaxWeightBranch.trim().toLowerCase():{let C=To(g);return C!=null&&C.chapterId?(I(),T(),y.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case k.setMinWeightBranch.trim().toLowerCase():{let C=Io(g);return C!=null&&C.chapterId?(I(),T(),y.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case k.continuePlayback.trim().toLowerCase():return I(),T(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h});case k.openURI.trim().toLowerCase():return I(),T(),L.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:let j="Unexpected chapter event",P=new _(1,1,{message:j});v(P,j);return}};function v(u,h){console.error(h),e.error$.next(u),r.emit(A.errors,u)}function d(u){var g;let h=Wr(u.events);if(h){if(Z(u))return;r.emit(A.interactives,{subjectId:u.id,subjectName:"chapter",type:V.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:k.expect,action:b.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(g=u.events)==null||g.forEach(I=>{let T=m({chapterId:u.id,action:I.action,branches:u.branches});T&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:I.action.type,action:T})})}let b=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:V.actionExecution,actionType:k.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:k.expect})},x=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:V.actionExecution,actionType:Ao}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:Ao})},R=({subjectId:u,subjectName:h,subjectType:g,action:I})=>{r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:g,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:g,type:"action-execution",actionType:I.type})},y=({subjectId:u,subjectName:h,subjectType:g,action:I,payload:T})=>{T.behaviour="change-chapter",r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:g,type:V.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:g,type:"action-execution",actionType:I.type,payload:T})},M=({subjectId:u,subjectName:h,subjectType:g,action:I,payload:T})=>{T.behaviour="change-manifest",r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:g,type:V.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:g,type:"action-execution",actionType:I.type,payload:T})},L=({subjectId:u,subjectName:h,subjectType:g,action:I,payload:T})=>{if(!T.URI)return;let j=window.open(T.URI,"_blank","noopener,noreferrer");j&&(j.opener=null),r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:g,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:g,type:"action-execution",actionType:I.type})};return{onControlEvent:c,onContainerEvent:a,onChapterEvent:m,onExpectEvent:b,expectEventHandler:x,setManifestChapterEvents:d,setManifestContainerEvents:l,stopExpect:o,state:s}};var ci=te(_r(),1);import{Subscription as ih,Subject as oi,ValueSubject as tt}from"@vkontakte/videoplayer-shared/es2015";var ai=(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]=ko(s)}return t[i]}).filter(Boolean)},eh=r=>{for(let e of r.variants)if(th(e)&&e.payload)return e.payload.id},th=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ko=r=>{let e=eh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},rh=(r,e)=>{for(let t of r.media.videos)if(e===ko(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Mo=(r,e)=>r.reduce((t,i)=>{let n=rh(e,i);return n?[...t,n]:t},[]);var ie,fe,me,W,zt,ne,se,J,ve,Oe,Pe,rt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new tt([]),hasPrevChapter$:new tt(!1),prevChapter$:new tt(null),isInitialChapter$:new tt(!1),isGoBackLimited$:new tt(!1)};U(this,ie,null);U(this,fe);U(this,me,!1);U(this,W,null);U(this,zt,null);this.events={inited$:new oi,destroyed$:new oi,error$:new oi};U(this,ne,null);U(this,se,null);U(this,J,null);U(this,ve,new ih);U(this,Oe,!1);U(this,Pe,0);var o;$(this,ne,t),$(this,J,e),$(this,se,i),$(this,ie,n),$(this,fe,s),this.state.history$&&w(this,ve)&&((o=w(this,ve))==null||o.add(this.state.history$.subscribe(c=>{var a,l;this.state.prevChapter$.next((0,ci.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((l=(a=w(this,W))==null?void 0:a.metadata)==null?void 0:l.initChapterId)),this.state.isGoBackLimited$.next(w(this,Pe)===w(this,fe).maxLength-1)})))}setManifest(e){return O(this,null,function*(){if(!w(this,se)||!w(this,J))return;$(this,W,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield w(this,se).setChapter({chapterId:t,pushToHistory:!1}),w(this,me)||($(this,me,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return w(this,me)}updateHistory(e,t=!0){return O(this,null,function*(){var c;if(!w(this,W))return;w(this,Oe)?($(this,Oe,!1),Ci(this,Pe)._++):$(this,Pe,0);let i=w(this,W),n=e.length-w(this,fe).maxLength,s=n>0?e.slice(n):e,o=ai(s,i);if($(this,zt,o),this.state.history$.next(s),!(!t||!w(this,ie)||!w(this,ne)))try{yield w(this,ie).save(w(this,ne),o)}catch(a){let l=new _(1,5,"Unable to save interactive history");this.events.error$.next(l),(c=w(this,J))==null||c.emit(A.errors,l)}})}goBack(){return O(this,null,function*(){var i;if(!this.state||!w(this,se)){let n=new _(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,J))==null?void 0:i.emit(A.errors,n)}$(this,Oe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield w(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return O(this,null,function*(){var n;if(!w(this,W)||!w(this,ne))return;let e=w(this,W),t=[this.getInitialVideoId()];if(w(this,ie))try{let s=yield w(this,ie).get(w(this,ne));s.length&&(t=s)}catch(s){let o=new _(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=w(this,J))==null||n.emit(A.errors,o)}let i=Mo(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,ci.default)(e,-1)||w(this,fe).initChapterId||((t=w(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,W)){let e=this.getInitialChapterId();return ai([e],w(this,W)).pop()}return null}destroy(){var e,t;$(this,ne,null),$(this,ie,null),$(this,se,null),(e=w(this,ve))==null||e.unsubscribe(),$(this,ve,null),$(this,me,!1),(t=w(this,J))==null||t.emit(A.historyDestroyed),this.events.destroyed$.next(),$(this,J,null)}};ie=new WeakMap,fe=new WeakMap,me=new WeakMap,W=new WeakMap,zt=new WeakMap,ne=new WeakMap,se=new WeakMap,J=new WeakMap,ve=new WeakMap,Oe=new WeakMap,Pe=new WeakMap;var ye=class ye{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=ye._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(",")),ye._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=ye._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}ye._supportsObject=t}return t||!1}};ye._supportsObject=void 0;var Wt=ye;var Kt=class{constructor(){this.bindingMap=new et}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new Wt(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 Qt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let s=3;s<i;s+=40)if(t[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return O(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i})}save(){return O(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Yt=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,204 +11,13 @@ var Ks=Object.create;var Jt=Object.defineProperty,Qs=Object.defineProperties,Xs=
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new Kt,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new Qt,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
15
15
  position: absolute;
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return R(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseFloat(t.getPropertyValue("--interactive-content-width")),height:parseFloat(t.getPropertyValue("--interactive-content-height"))};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,o;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((o=t.endTime)!=null?o: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 Fs(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var vp=`
20
- .interactive-control {
21
- display: flex;
22
- width: 100%;
23
- height: 100%;
24
- font-family: inherit;
25
- }
26
-
27
- .interactive-control-button {
28
- cursor: pointer;
29
- transform-origin: center;
30
- position: relative;
31
- isolation: isolate;
32
- transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1);
33
- opacity: 1;
34
- }
35
-
36
- .interactive-container:not(.interactive-container-disabled) .interactive-control-button:not(.interactive-control-selected):hover,
37
- .interactive-container:not(.interactive-container-disabled) .interactive-control-button:not(.interactive-control-selected):focus-visible {
38
- transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1);
39
- opacity: 0.8;
40
- animation: none;
41
- }
42
-
43
- .interactive-control-button.interactive-control-selected {
44
- transition: opacity 100ms ease-in-out;
45
- opacity: 0.5;
46
- pointer-events: none;
47
- }
48
-
49
- .interactive-control-area {
50
- cursor: pointer;
51
- opacity: 1;
52
- box-shadow: none;
53
- transition: border-color 100ms ease-in-out, box-shadow 100ms ease-in-out, opacity 400ms cubic-bezier(0.4, 0, 0.2, 1);
54
- }
55
-
56
- .interactive-container:not(.interactive-container-disabled) .interactive-control-area:not(.interactive-control-selected):hover,
57
- .interactive-container:not(.interactive-container-disabled) .interactive-control-area:not(.interactive-control-selected):focus-visible {
58
- transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1);
59
- opacity: 0;
60
- animation: none;
61
- }
62
-
63
- .interactive-control-area.interactive-control-selected {
64
- transition: opacity 100ms ease-in-out;
65
- opacity: 0;
66
- pointer-events: none;
67
- }
68
-
69
- .interactive-container.interactive-container-disabled .interactive-control-button,
70
- .interactive-container.interactive-container-disabled .interactive-control-area {
71
- animation: none;
72
- }
73
-
74
- .interactive-container.interactive-container-before-remove-delay {
75
- transition-delay: 300ms;
76
- }
77
-
78
- .interactive-control-before-remove,
79
- .interactive-container.interactive-container-before-remove {
80
- transition-property: opacity;
81
- transition-duration: 100ms;
82
- transition-timing-function: ease-in-out;
83
- opacity: 0;
84
- pointer-events: none;
85
- }
86
-
87
- .interactive-fillAnimationElement {
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return O(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,s;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((s=t.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function Vo(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Lo=Object.freeze({lang:ah.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function ch(){let r=document.createElement("div");return r.style.cssText=`
88
20
  position: absolute;
89
- overflow: hidden;
90
- z-index: -1;
91
- pointer-events: none;
92
- }
93
-
94
- .interactive-fillAnimationElement-filler {
95
- position: absolute;
96
- background-color: rgba(173, 211, 255, 0.32);
97
- }
98
-
99
- .interactive-fillWidth {
100
- width: 0;
101
- height: 100%;
102
- }
103
-
104
- .interactive-fillHeight {
105
- width: 100%;
106
- height: 0;
107
- }
108
-
109
- .interactive-fromTop {
110
- top: 0;
111
- right: 0;
112
- }
113
-
114
- .interactive-fromBottom {
115
- bottom: 0;
116
- right: 0;
117
- }
118
-
119
- .interactive-tap {
120
- position: absolute;
121
- aspect-ratio: 1;
122
- background-color: rgba(255, 255, 255, 0.08);
123
- border: 1px solid #fff;
124
- border-radius: 50%;
125
- transition: opacity 100ms ease-in-out;
126
- opacity: 0;
127
- pointer-events: none;
128
- z-index: 1;
129
- }
130
-
131
- .interactive-tap-animation {
132
- animation-duration: 300ms;
133
- animation-iteration-count: 1;
134
- animation-timing-function: ease;
135
- animation-name: bounce;
136
- }
137
-
138
- @keyframes bounce {
139
- 0%, 100% {
140
- transform: scale(1);
141
- }
142
- 50% {
143
- transform: scale(0.3);
144
- }
145
- }
146
-
147
- .interactive-container:not(.interactive-container-disabled) .interactive-tap-visible {
148
- opacity: 1;
149
- }
150
-
151
- .interactive-control-cta-area {
152
- animation-duration: 2001ms;
153
- animation-iteration-count: infinite;
154
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
155
- animation-name: blinking-1;
156
- }
157
-
158
- @keyframes blinking-1 {
159
- 0%, 100% {
160
- opacity: 1;
161
- }
162
- 50% {
163
- opacity: 0;
164
- }
165
- }
166
-
167
- .interactive-control-cta-button {
168
- animation-duration: 2001ms;
169
- animation-iteration-count: infinite;
170
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
171
- animation-name: blinking-2;
172
- }
173
-
174
- @keyframes blinking-2 {
175
- 0%, 100% {
176
- opacity: 1;
177
- }
178
- 50% {
179
- opacity: 0.8;
180
- }
181
- }
182
-
183
- .interactive-container {
184
- opacity: 1;
185
- }
186
-
187
- .interactive-container * {
188
- box-sizing: border-box;
189
- }
190
-
191
- .interactive-container-before-show {
192
- transition: opacity 100ms ease-in-out;
193
- opacity: 0.5;
194
- pointer-events: none;
195
- }
196
-
197
- .interactive-container-disabled {
198
- transition: opacity 100ms ease-in-out;
199
- opacity: 0.5;
200
- }
201
-
202
- .interactive-blink-reference-animation {
203
- position: absolute;
204
- height: 0;
205
- width: 0;
206
21
  top: 0;
207
22
  left: 0;
208
- pointer-events: none;
209
- }
210
-
211
- .interactive-blink-reference-disable-animation {
212
- animation: none;
213
- }
214
- `,$s=r=>{let e=document.createElement("style");e.textContent=vp,r.prepend(e)};var yp=typeof window=="undefined",bp=typeof OffscreenCanvas!="undefined";function js(){return yp?bp?new OffscreenCanvas(1,1):null:document.createElement("canvas")}function Ns(r){return(r[0]*299+r[1]*587+r[2]*114)/1e3<128}var li=[0,0,0,0],_s=1,gp="AverageColor: ";function ci(r){return Error(gp+r)}function ui(r){let e=window.getComputedStyle(r),t=parseFloat(e.getPropertyValue("--interactive-content-width"))||0,i=parseFloat(e.getPropertyValue("--interactive-content-height"))||0;return{width:t,height:i}}var ot=class{constructor(){this.canvas=null;this.ctx=null}getColorAsync(e,t){let i=this.getColor(e,t);return i.error?Promise.reject(i.error):Promise.resolve(i)}getColor(e,t){var n,o;let i=C(m({},t),{step:t.step||_s,defaultColor:(n=t.defaultColor)!=null?n:li,debug:(o=t.debug)!=null?o:!1});if(!this.canvas&&(this.canvas=js(),!this.canvas))return this.prepareResult(i.defaultColor,ci("Failed to create canvas"));if(!this.ctx){if(this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),!this.ctx)return this.prepareResult(i.defaultColor,ci("Failed to create context of the canvas"));this.ctx.imageSmoothingEnabled=!1}this.canvas.width=i.width,this.canvas.height=i.height;try{this.ctx.clearRect(0,0,i.width,i.height),this.ctx.drawImage(e,0,0,i.width,i.height);let s=this.ctx.getImageData(0,0,i.width,i.height).data,a=this.getColorFromArray(s,i);return this.prepareResult(a)}catch(s){return i.debug&&console.error(s),this.prepareResult(i.defaultColor,new Error("Failed on getting average color"))}}getColorFromArray(e,t){let n=e.length;if(n<4)return li;let o=n-n%4,s=t.step*4;return this.sqrtAlgorithm(e,o,{defaultColor:t.defaultColor,step:s})}sqrtAlgorithm(e,t,i){let n=0,o=0,s=0,a=0,l=0,c=i.step;for(let p=0;p<t;p+=c){let v=e[p],f=e[p+1],E=e[p+2],w=e[p+3];n+=v*v*w,o+=f*f*w,s+=E*E*w,a+=w,l++}return a?[Math.round(Math.sqrt(n/a)),Math.round(Math.sqrt(o/a)),Math.round(Math.sqrt(s/a)),Math.round(a/l)]:i.defaultColor}prepareResult(e,t){let i=[e[0],e[1],e[2],e[3]/255],n=Ns(e);return{rgba:"rgba("+i.join(",")+")",isDark:n,error:t}}destroy(){this.canvas&&(this.canvas.width=1,this.canvas.height=1,this.canvas=null),this.ctx=null}};var qs=()=>{let r=document.createElement("div");return r.classList.add("interactive-blink-reference-animation","interactive-control-cta-button"),r},Bs=r=>{r.classList.add("interactive-blink-reference-disable-animation"),requestAnimationFrame(()=>{r.classList.remove("interactive-blink-reference-disable-animation")})};var Gs=Object.freeze({lang:Tp.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},buttonControlInteractiveTimeTimer:!0,areaControlFrameBasedShadow:!0,tapPlaceShow:!0,controlsCTAAnimation:!0,controlsShowAnimation:!0,controlsHideAnimation:!0});function xp(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Yt=class{constructor(e){this.playerSubscriptions=new Xt;this.subscriptions=new Xt;this.globalEventEmitter=new Vt;this.eventsSubs=new Xt;this.animation=new Ft;this.seekToInteractiveController=new Xe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=xp();this.factories=new Map([["choice",It]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Xt;this.graph=null;this.lastFrame=null;this.frameAverageColor=null;this.appState=0;this.state={prevChapter$:new H(null),isInitialChapter$:new H(!1),isFirstChapter$:new H(!0),isEndChapter$:new H(!1),isInteractiveExpectation$:new H(!1),isReplay$:new H(!1),calledByInteractive$:new H(!1),lastChapterChangeWasInitiatedByInteractive$:new H(!1),disabledControls$:new H(!1),interactiveRanges$:new H([]),isInteractiveTime$:new H(!1),statistics$:new H(null),isSeekable$:new H(!1)};this.events={noInteraction$:new D,graphVisibilityChanged$:new D,watchAgainIsClicked$:new D,chapterChanged$:new D,playerChanged$:new D,error$:new D,eachTick$:new D,manifestChanged$:new D,interactiveRangeEnded$:new D,interactiveContainerRemoved$:new D,interactiveActionExecution$:new D,interactiveActionChoice$:new D,interactiveVisibilityChanged$:new D};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(O.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&&J(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=K(n,["statistics"]);if(t){let{statSubscription:o,oneStat:s}=t;o.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(O.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeGameControllersViews=({includeTextControls:e=!0}={})=>{for(let t of this.gameControllers)!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.removeView())};this.destroyGameControllers=({includeTextControls:e=!0}={})=>{for(let t of this.gameControllers)!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>C(m({},o),{subjects:o.subjects.filter(s=>s!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var i;this._options=C(m(m({},Gs),e),{config:m(m({},Gs.config),e.config)}),this._options.controlsCTAAnimation&&this.rootElement.append(qs()),this._options.parentElement.append(this.rootElement),this.historyController=new nt({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(i=this._options.projectInfo)==null?void 0:i.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Qt({parentElement:this._options.parentElement,onError:n=>{let o=new _(1,6,n);this.emitErrorEvent(o)}})),$s(this._options.parentElement),this.subscriptions.add(Hs(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add(Hs(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new Re(this._options.loaders,n=>{let o=new _(1,3,n);this.emitErrorEvent(o)});let t=[];this._options.lastFrame&&t.push(()=>{var n;(n=this.lastFrame)==null||n.updateCanvasDimensions(!0)}),this._options.buttonControlInteractiveTimeTimer&&t.push(()=>{if(this.state.isInteractiveTime$.getValue())for(let n of this.gameControllers)n.container.onResize()}),this.resizeManager=Ts(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Qe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(O.graph,{type:tt.watchAgainClicked,chapterId:n}),this.events.watchAgainIsClicked$.next(n)},onError:n=>{let o=new _(1,4,{message:n});this.emitErrorEvent(o)}})),this._options.areaControlFrameBasedShadow&&(this.frameAverageColor=new ot),this.initSubscriptions()}getVideoFrameAverageColorInfo(){return R(this,null,function*(){if(!this.frameAverageColor||!this.player)return;let e=this.player.experimental.element$.getValue();if(!e||!e.readyState)return;let t=ui(this.rootElement);if(!(!t.width||!t.height))try{return yield this.frameAverageColor.getColorAsync(e,{width:t.width,height:t.height})}catch(i){return console.error(i),{error:"Getting video frame average color failed"}}})}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>R(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))}))),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.toggleControlsCTAAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.toggleControlsCTAAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.removeGameControllersViews({includeTextControls:!1})}))}getGameControllerContainersWithExpect(e,t=[]){return this.gameControllers.filter(({container:i})=>!(0,zs.default)(t,i.container.id)&&ae(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}execForAllExpectContainers({subjectName:e,subjectId:t,isExpect:i,execFnName:n}){for(let o of this.gameControllers)if(e==="container"&&o.container.container.id===t){o[n](i),this.getGameControllerContainersWithExpect(o.container.container.endTime,[o.container.container.id]).forEach(a=>{a[n](i)});break}}updateControlsShadowStyles(i){var n=i,{isExpect:e}=n,t=K(n,["isExpect"]);this._options.areaControlFrameBasedShadow&&(e?this.getVideoFrameAverageColorInfo().then(o=>{o&&!o.error&&"isDark"in o&&(this._options.parentElement.style.setProperty("--interactive-frame-tone",`${o.isDark?"dark":"light"}`),this.execForAllExpectContainers(C(m({},t),{isExpect:e,execFnName:"updateControlsShadowStyles"})))}):this.execForAllExpectContainers(C(m({},t),{isExpect:e,execFnName:"updateControlsShadowStyles"})))}toggleControlsCTAAnimation(e){if(this._options.controlsCTAAnimation){if(e.isExpect){let i=this.rootElement.querySelector(".interactive-blink-reference-animation");i&&Bs(i)}this.execForAllExpectContainers(C(m({},e),{execFnName:"toggleControlsCTAAnimation"}))}}initSeamless(){return R(this,null,function*(){this.seamlessController=Jr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(O.interactives,{type:V.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(Ip()).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(Ep({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var l;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[v,f],subjects:E})=>v<c&&c<f&&E.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,a=((l=this.player)==null?void 0:l.info.playbackState$.getValue())==="playing"||i;n&&!o&&a?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!a&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.addGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Ae(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)}addGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n),s=o==null?void 0:o(i,this.rootElement,{features:{buttonControlInteractiveTimeTimer:this._options.buttonControlInteractiveTimeTimer,areaControlFrameBasedShadow:this._options.areaControlFrameBasedShadow,tapPlaceShow:this._options.tapPlaceShow,controlsShowAnimation:this._options.controlsShowAnimation,controlsCTAAnimation:this._options.controlsCTAAnimation}});if(s&&this.selectBranches&&this.interactiveEvents&&this.player){let a=new Gt({player:this.player,container:s,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>ra(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},features:{controlsHideAnimation:this._options.controlsHideAnimation}});this.animation.addFn(a.whilePlaying,!0),t.push(a)}}),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 a,l;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(a=i&&J(i)&&Dt(i))!=null?a:!1,o=((l=this.manifestController.manifest)==null?void 0:l.metadata.initChapterId)===e,s=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,Us.default)(s,-1)!==e&&this.historyController.updateHistory([...s,e])}reset(){var e;this.appState===2&&(this.destroyGameControllers({includeTextControls:!0}),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}setManifest(e){return R(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),yield this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(O.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=gs(this.player),this.selectBranches=Ls({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return R(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var l,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Cp.isSafari&&(yield Fs(35));let n=!i&&this.state.isEndChapter$.getValue()&&((l=this.getCurrentManifest())==null?void 0:l.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:o,media:s,graph:a}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!s)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:s}),this.globalEventEmitter.emit(O.chapterChanged,{chapter:o,media:s,graph:a}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new Ds(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?at.GRAPH_SHOW:at.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(at.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(at.NEXT_BUTTON),n==="Area"&&e.next(at.NEXT_AREA))}))}),nextMovie$:new Ds(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(O.graph,{type:tt.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===L.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(i=>{let n=e&&this._options.controlsHideAnimation?i.container.willRemoved:!0;return!i.container.isRemoved||!n})}isEndedExpectation(){if(!this.player)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&&!i.container.willRemoved&&n.endTime===null&&ae(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&Tt(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 $a((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,o,s;this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],(e=this.frameAverageColor)==null||e.destroy(),(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(i=this.seamlessController)==null||i.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var wp={Container:Ce,createChoiceContainer:It,createAreaControl:mt,createButtonControl:vt,classnamesPrefix:N};var xb={version:Ii};export{Ad as ContainerTypes,he as ControlTypes,_ as CustomError,O as EVENT_NAMES,L as EventActionTypes,Rd as EventTypes,Yt as Interactives,Re as ManifestController,xb as SDKInfo,oi as chapterIdsToVKVideoIds,Hr as compareVersions,Cd as containerTypes,Ed as controlTypes,Id as eventActionTypes,Td as eventTypes,mp as getChapterIdByVkVideoId,Ms as getVKVideoIdByMedia,pp as getVideoRawIdByMedia,tt as graphEventTypes,Dt as hasEndTemplate,V as interactivesEventTypes,gd as isAreaControl,bd as isButtonControl,J as isLastChapter,Ae as isOneTextCtrlContainer,Tt as isSupportedManifest,Et as isTextControl,dp as isVKVariantItem,Mi as isValidManifest,Vi as migrateManifestToLatestVersion,wp as utils,Vs as vkVideoIdsToChapterIds};
23
+ `,r}var Xt=class{constructor(e){this.subscription=new li;this.globalEventEmitter=new Mt;this.eventsSubs=new li;this.animation=new Vt;this.eventManager=new Kt;this.seekToInteractiveController=new We;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ch();this.factories=new Map([["choice",vt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new li;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new H(null),isInitialChapter$:new H(!1),isFirstChapter$:new H(!0),isEndChapter$:new H(!1),isInteractiveExpectation$:new H(!1),isReplay$:new H(!1),calledByInteractive$:new H(!1),lastChapterChangeWasInitiatedByInteractive$:new H(!1),disabledControls$:new H(!1),interactiveRanges$:new H([]),isInteractiveTime$:new H(!1),statistics$:new H(null),isSeekable$:new H(!1)};this.events={noInteraction$:new D,graphVisibilityChanged$:new D,watchAgainIsClicked$:new D,chapterChanged$:new D,playerChanged$:new D,error$:new D,eachTick$:new D,manifestChanged$:new D,interactiveRangeEnded$:new D,interactiveContainerRemoved$:new D,interactiveActionExecution$:new D,interactiveActionChoice$:new D,interactiveVisibilityChanged$:new D};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(A.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&&Z(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=Y(n,["statistics"]);if(t){let{statSubscription:s,oneStat:o}=t;s.add(o.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(A.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(s=>E(f({},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=E(f(f({},Lo),e),{config:f(f({},Lo.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new rt({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 Yt({parentElement:this._options.parentElement,onError:i=>{let n=new _(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 Ae(this._options.loaders,i=>{let n=new _(1,3,i);this.emitErrorEvent(n)}),this.resizeManager=Co(()=>{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 ze({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(A.graph,{type:Ze.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let n=new _(1,4,{message:i});this.emitErrorEvent(n)}})),this.initSubscriptions()}initSubscriptions(){this.subscription.add(this.historyController.events.inited$.subscribe(t=>O(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))}))),this.globalEventEmitter.on(A.interactives,e=>O(this,null,function*(){e.type===V.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)}))}initSeamless(){return O(this,null,function*(){this.seamlessController=ei(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(n){let s=n.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(A.interactives,{type:V.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(oh()).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(sh({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:[v,d],subjects:b})=>v<l&&l<d&&b.some(x=>!x.isRemoved)&&b.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=>!we(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 Ht({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Ds(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&&Z(i)&&qt(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,$o.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?E(f({},l),{isRemoved:!0}):l);return E(f({},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())}setManifest(e){return O(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),yield this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(A.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=yo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Po({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,removeControllers:()=>this.removeControllers(!1)}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return O(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var a,l;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),nh.isSafari&&(yield Vo(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}=yield 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(A.chapterChanged,{chapter:s,media:o,graph:c}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new jo(e=>{this.eventsSubs.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?it.GRAPH_SHOW:it.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(it.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(it.NEXT_BUTTON),n==="Area"&&e.next(it.NEXT_AREA))}))}),nextMovie$:new jo(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(A.graph,{type:Ze.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===k.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&&de(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&Pt(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 Va((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 lh={Container:ge,createChoiceContainer:vt,createAreaControl:ht,createButtonControl:ft,getRootEl:ot,classnamesPrefix:B};var Dy={version:Ei};export{Pf as ContainerTypes,kt as ControlTypes,_ as CustomError,A as EVENT_NAMES,k as EventActionTypes,kf as EventTypes,Xt as Interactives,Ae as ManifestController,Dy as SDKInfo,ai as chapterIdsToVKVideoIds,Hr as compareVersions,xf as containerTypes,Sf as controlTypes,$s as eventActionTypes,wf as eventTypes,rh as getChapterIdByVkVideoId,ko as getVKVideoIdByMedia,eh as getVideoRawIdByMedia,Ze as graphEventTypes,qt as hasEndTemplate,V as interactivesEventTypes,Tf as isAreaControl,If as isButtonControl,Z as isLastChapter,we as isOneTextCtrlContainer,Pt as isSupportedManifest,Ot as isTextControl,th as isVKVariantItem,Ls as isValidManifest,Ns as migrateManifestToLatestVersion,lh as utils,Mo as vkVideoIdsToChapterIds};