@vkontakte/videoplayer-interactive 1.0.63-dev.ef2fa986.0 → 1.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2018.esm.js ADDED
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @vkontakte/videoplayer-interactive v1.0.63
3
+ * Thu, 26 Mar 2026 11:38:58 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-63/doc/
5
+ */
6
+ import e from"@oxc-project/runtime/helpers/defineProperty";import t from"@oxc-project/runtime/helpers/classPrivateFieldInitSpec";import n from"@oxc-project/runtime/helpers/classPrivateFieldSet2";import r from"@oxc-project/runtime/helpers/classPrivateFieldGet2";var i=Object.create,a=Object.getPrototypeOf,o=Object.defineProperty,s=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty;function l(e){return this[e]}var u,d,f=(e,t,n)=>{var r=typeof e==`object`&&!!e;if(r){var f=t?u??=new WeakMap:d??=new WeakMap,p=f.get(e);if(p)return p}n=e==null?{}:i(a(e));let m=t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n;for(let t of s(e))c.call(m,t)||o(m,t,{get:l.bind(e,t),enumerable:!0});return r&&f.set(e,m),m},p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),m=p((e,t)=>{var n=function(e){return e&&e.Math===Math&&e};t.exports=n(typeof globalThis==`object`&&globalThis)||n(typeof window==`object`&&window)||n(typeof self==`object`&&self)||n(typeof global==`object`&&global)||n(typeof e==`object`&&e)||function(){return this}()||Function(`return this`)()}),h=p((e,t)=>{t.exports=function(e){try{return!!e()}catch{return!0}}}),g=p((e,t)=>{t.exports=!h()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),_=p((e,t)=>{var n=g(),r=Function.prototype,i=r.apply,a=r.call;t.exports=typeof Reflect==`object`&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})}),v=p((e,t)=>{var n=g(),r=Function.prototype,i=r.call,a=n&&r.bind.bind(i,i);t.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}}),y=p((e,t)=>{var n=v(),r=n({}.toString),i=n(``.slice);t.exports=function(e){return i(r(e),8,-1)}}),b=p((e,t)=>{var n=y(),r=v();t.exports=function(e){if(n(e)===`Function`)return r(e)}}),x=p((e,t)=>{var n=typeof document==`object`&&document.all;t.exports=n===void 0&&n!==void 0?function(e){return typeof e==`function`||e===n}:function(e){return typeof e==`function`}}),S=p((e,t)=>{t.exports=!h()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),C=p((e,t)=>{var n=g(),r=Function.prototype.call;t.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),w=p(e=>{var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor;e.f=n&&!t.call({1:2},1)?function(e){var t=n(this,e);return!!t&&t.enumerable}:t}),T=p((e,t)=>{t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),E=p((e,t)=>{var n=v(),r=h(),i=y(),a=Object,o=n(``.split);t.exports=r(function(){return!a(`z`).propertyIsEnumerable(0)})?function(e){return i(e)===`String`?o(e,``):a(e)}:a}),ee=p((e,t)=>{t.exports=function(e){return e==null}}),te=p((e,t)=>{var n=ee(),r=TypeError;t.exports=function(e){if(n(e))throw new r(`Can't call method on `+e);return e}}),ne=p((e,t)=>{var n=E(),r=te();t.exports=function(e){return n(r(e))}}),D=p((e,t)=>{var n=x();t.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),re=p((e,t)=>{t.exports={}}),ie=p((e,t)=>{var n=re(),r=m(),i=x(),a=function(e){return i(e)?e:void 0};t.exports=function(e,t){return arguments.length<2?a(n[e])||a(r[e]):n[e]&&n[e][t]||r[e]&&r[e][t]}}),ae=p((e,t)=>{t.exports=v()({}.isPrototypeOf)}),oe=p((e,t)=>{var n=m().navigator,r=n&&n.userAgent;t.exports=r?String(r):``}),se=p((e,t)=>{var n=m(),r=oe(),i=n.process,a=n.Deno,o=i&&i.versions||a&&a.version,s=o&&o.v8,c,l;s&&(c=s.split(`.`),l=c[0]>0&&c[0]<4?1:+(c[0]+c[1])),!l&&r&&(c=r.match(/Edge\/(\d+)/),(!c||c[1]>=74)&&(c=r.match(/Chrome\/(\d+)/),c&&(l=+c[1]))),t.exports=l}),ce=p((e,t)=>{var n=se(),r=h(),i=m().String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),le=p((e,t)=>{t.exports=ce()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),ue=p((e,t)=>{var n=ie(),r=x(),i=ae(),a=le(),o=Object;t.exports=a?function(e){return typeof e==`symbol`}:function(e){var t=n(`Symbol`);return r(t)&&i(t.prototype,o(e))}}),de=p((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch{return`Object`}}}),fe=p((e,t)=>{var n=x(),r=de(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),pe=p((e,t)=>{var n=fe(),r=ee();t.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),me=p((e,t)=>{var n=C(),r=x(),i=D(),a=TypeError;t.exports=function(e,t){var o,s;if(t===`string`&&r(o=e.toString)&&!i(s=n(o,e))||r(o=e.valueOf)&&!i(s=n(o,e))||t!==`string`&&r(o=e.toString)&&!i(s=n(o,e)))return s;throw new a(`Can't convert object to primitive value`)}}),he=p((e,t)=>{t.exports=!0}),ge=p((e,t)=>{var n=m(),r=Object.defineProperty;t.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),_e=p((e,t)=>{var n=he(),r=m(),i=ge(),a=`__core-js_shared__`,o=t.exports=r[a]||i(a,{});(o.versions||=[]).push({version:`3.43.0`,mode:n?`pure`:`global`,copyright:`© 2014-2025 Denis Pushkarev (zloirock.ru)`,license:`https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE`,source:`https://github.com/zloirock/core-js`})}),ve=p((e,t)=>{var n=_e();t.exports=function(e,t){return n[e]||(n[e]=t||{})}}),ye=p((e,t)=>{var n=te(),r=Object;t.exports=function(e){return r(n(e))}}),be=p((e,t)=>{var n=v(),r=ye(),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),xe=p((e,t)=>{var n=v(),r=0,i=Math.random(),a=n(1.1.toString);t.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),Se=p((e,t)=>{var n=m(),r=ve(),i=be(),a=xe(),o=ce(),s=le(),c=n.Symbol,l=r(`wks`),u=s?c.for||c:c&&c.withoutSetter||a;t.exports=function(e){return i(l,e)||(l[e]=o&&i(c,e)?c[e]:u(`Symbol.`+e)),l[e]}}),Ce=p((e,t)=>{var n=C(),r=D(),i=ue(),a=pe(),o=me(),s=Se(),c=TypeError,l=s(`toPrimitive`);t.exports=function(e,t){if(!r(e)||i(e))return e;var s=a(e,l),u;if(s){if(t===void 0&&(t=`default`),u=n(s,e,t),!r(u)||i(u))return u;throw new c(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),o(e,t)}}),we=p((e,t)=>{var n=Ce(),r=ue();t.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),Te=p((e,t)=>{var n=m(),r=D(),i=n.document,a=r(i)&&r(i.createElement);t.exports=function(e){return a?i.createElement(e):{}}}),Ee=p((e,t)=>{var n=S(),r=h(),i=Te();t.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),`a`,{get:function(){return 7}}).a!==7})}),De=p(e=>{var t=S(),n=C(),r=w(),i=T(),a=ne(),o=we(),s=be(),c=Ee(),l=Object.getOwnPropertyDescriptor;e.f=t?l:function(e,t){if(e=a(e),t=o(t),c)try{return l(e,t)}catch{}if(s(e,t))return i(!n(r.f,e,t),e[t])}}),Oe=p((e,t)=>{var n=h(),r=x(),i=/#|\.prototype\./,a=function(e,t){var i=s[o(e)];return i===l?!0:i===c?!1:r(t)?n(t):!!t},o=a.normalize=function(e){return String(e).replace(i,`.`).toLowerCase()},s=a.data={},c=a.NATIVE=`N`,l=a.POLYFILL=`P`;t.exports=a}),ke=p((e,t)=>{var n=b(),r=fe(),i=g(),a=n(n.bind);t.exports=function(e,t){return r(e),t===void 0?e:i?a(e,t):function(){return e.apply(t,arguments)}}}),Ae=p((e,t)=>{var n=S(),r=h();t.exports=n&&r(function(){return Object.defineProperty(function(){},`prototype`,{value:42,writable:!1}).prototype!==42})}),je=p((e,t)=>{var n=D(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),Me=p(e=>{var t=S(),n=Ee(),r=Ae(),i=je(),a=we(),o=TypeError,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=`enumerable`,u=`configurable`,d=`writable`;e.f=t?r?function(e,t,n){if(i(e),t=a(t),i(n),typeof e==`function`&&t===`prototype`&&`value`in n&&d in n&&!n[d]){var r=c(e,t);r&&r[d]&&(e[t]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:l in n?n[l]:r[l],writable:!1})}return s(e,t,n)}:s:function(e,t,r){if(i(e),t=a(t),i(r),n)try{return s(e,t,r)}catch{}if(`get`in r||`set`in r)throw new o(`Accessors not supported`);return`value`in r&&(e[t]=r.value),e}}),Ne=p((e,t)=>{var n=S(),r=Me(),i=T();t.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),O=p((e,t)=>{var n=m(),r=_(),i=b(),a=x(),o=De().f,s=Oe(),c=re(),l=ke(),u=Ne(),d=be();_e();var f=function(e){var t=function(n,i,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,i)}return new e(n,i,a)}return r(e,this,arguments)};return t.prototype=e.prototype,t};t.exports=function(e,t){var r=e.target,p=e.global,m=e.stat,h=e.proto,g=p?n:m?n[r]:n[r]&&n[r].prototype,_=p?c:c[r]||u(c,r,{})[r],v=_.prototype,y,b,x,S,C,w,T,E,ee;for(S in t)y=s(p?S:r+(m?`.`:`#`)+S,e.forced),b=!y&&g&&d(g,S),w=_[S],b&&(e.dontCallGetSet?(ee=o(g,S),T=ee&&ee.value):T=g[S]),C=b&&T?T:t[S],!(!y&&!h&&typeof w==typeof C)&&(E=e.bind&&b?l(C,n):e.wrap&&b?f(C):h&&a(C)?i(C):C,(e.sham||C&&C.sham||w&&w.sham)&&u(E,`sham`,!0),u(_,S,E),h&&(x=r+`Prototype`,d(c,x)||u(c,x,{}),u(c[x],S,C),e.real&&v&&(y||!v[S])&&u(v,S,C)))}}),Pe=p((e,t)=>{var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?r:n)(t)}}),Fe=p((e,t)=>{var n=Pe();t.exports=function(e){var t=+e;return t!==t||t===0?0:n(t)}}),Ie=p((e,t)=>{var n=Fe(),r=Math.max,i=Math.min;t.exports=function(e,t){var a=n(e);return a<0?r(a+t,0):i(a,t)}}),Le=p((e,t)=>{var n=Fe(),r=Math.min;t.exports=function(e){var t=n(e);return t>0?r(t,9007199254740991):0}}),Re=p((e,t)=>{var n=Le();t.exports=function(e){return n(e.length)}}),ze=p((e,t)=>{var n=ne(),r=Ie(),i=Re(),a=function(e){return function(t,a,o){var s=n(t),c=i(s);if(c===0)return!e&&-1;var l=r(o,c),u;if(e&&a!==a){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===a)return e||l||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}}),Be=p((e,t)=>{t.exports=function(){}}),Ve=p(()=>{var e=O(),t=ze().includes,n=h(),r=Be();e({target:`Array`,proto:!0,forced:n(function(){return![,].includes()})},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),r(`includes`)}),He=p((e,t)=>{t.exports=ie()}),Ue=p((e,t)=>{Ve(),t.exports=He()(`Array`,`includes`)}),We=p((e,t)=>{t.exports=Ue()}),Ge=p((e,t)=>{t.exports=We()}),Ke=p(()=>{var e=O(),t=ye(),n=Re(),r=Fe(),i=Be();e({target:`Array`,proto:!0},{at:function(e){var i=t(this),a=n(i),o=r(e),s=o>=0?o:a+o;return s<0||s>=a?void 0:i[s]}}),i(`at`)}),qe=p((e,t)=>{Ke(),t.exports=He()(`Array`,`at`)}),Je=p((e,t)=>{t.exports=qe()}),Ye=p((e,t)=>{t.exports=Je()}),Xe=p((e,t)=>{var n=Se()(`toStringTag`),r={};r[n]=`z`,t.exports=String(r)===`[object z]`}),Ze=p((e,t)=>{var n=Xe(),r=x(),i=y(),a=Se()(`toStringTag`),o=Object,s=i(function(){return arguments}())===`Arguments`,c=function(e,t){try{return e[t]}catch{}};t.exports=n?i:function(e){var t,n,l;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=c(t=o(e),a))==`string`?n:s?i(t):(l=i(t))===`Object`&&r(t.callee)?`Arguments`:l}}),Qe=p((e,t)=>{var n=Ze(),r=String;t.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),$e=p(()=>{var e=O(),t=v(),n=te(),r=Fe(),i=Qe(),a=h(),o=t(``.charAt);e({target:`String`,proto:!0,forced:a(function(){return`𠮷`.at(-2)!==`\ud842`})},{at:function(e){var t=i(n(this)),a=t.length,s=r(e),c=s>=0?s:a+s;return c<0||c>=a?void 0:o(t,c)}})}),et=p((e,t)=>{$e(),t.exports=He()(`String`,`at`)}),tt=p((e,t)=>{t.exports=et()}),nt=p((e,t)=>{t.exports=tt()}),rt=p((e,t)=>{var n=ve(),r=xe(),i=n(`keys`);t.exports=function(e){return i[e]||(i[e]=r(e))}}),it=p((e,t)=>{t.exports=!h()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),at=p((e,t)=>{var n=be(),r=x(),i=ye(),a=rt(),o=it(),s=a(`IE_PROTO`),c=Object,l=c.prototype;t.exports=o?c.getPrototypeOf:function(e){var t=i(e);if(n(t,s))return t[s];var a=t.constructor;return r(a)&&t instanceof a?a.prototype:t instanceof c?l:null}}),ot=p((e,t)=>{t.exports={}}),st=p((e,t)=>{var n=v(),r=be(),i=ne(),a=ze().indexOf,o=ot(),s=n([].push);t.exports=function(e,t){var n=i(e),c=0,l=[],u;for(u in n)!r(o,u)&&r(n,u)&&s(l,u);for(;t.length>c;)r(n,u=t[c++])&&(~a(l,u)||s(l,u));return l}}),ct=p((e,t)=>{t.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),lt=p((e,t)=>{var n=st(),r=ct();t.exports=Object.keys||function(e){return n(e,r)}}),ut=p((e,t)=>{var n=S(),r=h(),i=v(),a=at(),o=lt(),s=ne(),c=w().f,l=i(c),u=i([].push),d=n&&r(function(){var e=Object.create(null);return e[2]=2,!l(e,2)}),f=function(e){return function(t){for(var r=s(t),i=o(r),c=d&&a(r)===null,f=i.length,p=0,m=[],h;f>p;)h=i[p++],(!n||(c?h in r:l(r,h)))&&u(m,e?[h,r[h]]:r[h]);return m}};t.exports={entries:f(!0),values:f(!1)}}),dt=p(()=>{var e=O(),t=ut().entries;e({target:`Object`,stat:!0},{entries:function(e){return t(e)}})}),ft=p((e,t)=>{dt(),t.exports=re().Object.entries}),pt=p((e,t)=>{t.exports=ft()}),mt=p((e,t)=>{t.exports=pt()}),ht=p(()=>{var e=O(),t=ut().values;e({target:`Object`,stat:!0},{values:function(e){return t(e)}})}),gt=p((e,t)=>{ht(),t.exports=re().Object.values}),_t=p((e,t)=>{t.exports=gt()}),vt=p((e,t)=>{t.exports=_t()}),yt=p((e,t)=>{var n=y();t.exports=Array.isArray||function(e){return n(e)===`Array`}}),bt=p((e,t)=>{var n=TypeError,r=9007199254740991;t.exports=function(e){if(e>r)throw n(`Maximum allowed index exceeded`);return e}}),xt=p((e,t)=>{var n=yt(),r=Re(),i=bt(),a=ke(),o=function(e,t,s,c,l,u,d,f){for(var p=l,m=0,h=d?a(d,f):!1,g,_;m<c;)m in s&&(g=h?h(s[m],m,t):s[m],u>0&&n(g)?(_=r(g),p=o(e,t,g,_,p,u-1)-1):(i(p+1),e[p]=g),p++),m++;return p};t.exports=o}),St=p((e,t)=>{var n=v(),r=x(),i=_e(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),t.exports=i.inspectSource}),Ct=p((e,t)=>{var n=v(),r=h(),i=x(),a=Ze(),o=ie(),s=St(),c=function(){},l=o(`Reflect`,`construct`),u=/^\s*(?:class|function)\b/,d=n(u.exec),f=!u.test(c),p=function(e){if(!i(e))return!1;try{return l(c,[],e),!0}catch{return!1}},m=function(e){if(!i(e))return!1;switch(a(e)){case`AsyncFunction`:case`GeneratorFunction`:case`AsyncGeneratorFunction`:return!1}try{return f||!!d(u,s(e))}catch{return!0}};m.sham=!0,t.exports=!l||r(function(){var e;return p(p.call)||!p(Object)||!p(function(){e=!0})||e})?m:p}),wt=p((e,t)=>{var n=yt(),r=Ct(),i=D(),a=Se()(`species`),o=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,r(t)&&(t===o||n(t.prototype))?t=void 0:i(t)&&(t=t[a],t===null&&(t=void 0))),t===void 0?o:t}}),Tt=p((e,t)=>{var n=wt();t.exports=function(e,t){return new(n(e))(t===0?0:t)}}),Et=p(()=>{var e=O(),t=xt(),n=ye(),r=Re(),i=Fe(),a=Tt();e({target:`Array`,proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,o=n(this),s=r(o),c=a(o,0);return c.length=t(c,o,o,s,0,e===void 0?1:i(e)),c}})}),Dt=p(()=>{Be()(`flat`)}),Ot=p((e,t)=>{Et(),Dt(),t.exports=He()(`Array`,`flat`)}),kt=p((e,t)=>{t.exports=Ot()}),At=p((e,t)=>{t.exports=kt()}),jt=`1.0.63`;import{fromEvent as Mt,Subscription as Nt}from"@vkontakte/videoplayer-shared/es2018";class Pt{constructor(t,n){e(this,`layout`,void 0),e(this,`cssVarsManager`,void 0),this.layout=t,this.cssVarsManager=n}}class Ft extends Pt{constructor(t,n){super(t,n),e(this,`cssVarsManager`,void 0),this.cssVarsManager=n,this.cssVarsManager=n}setContainerLayout(e){e.style.position=`relative`}setControlLayout(e,t){let n=this.cssVarsManager.getPropValue(`--interactive-content-width`),r=this.cssVarsManager.getPropValue(`--interactive-content-height`),i=this.cssVarsManager.getPropValue(`--interactive-width`),a=this.cssVarsManager.getPropValue(`--interactive-height`);e.style.position=`absolute`,e.style.width=`calc(${n} * (${t.width} + 0.0002))`,e.style.height=`calc(${r} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${i} - ${n}) / 2))`,e.style.top=`calc(${r} * ${t.y} + ((${a} - ${r}) / 2))`}}import{Subject as It}from"@vkontakte/videoplayer-shared/es2018";function Lt(e){return`features`in e}class k{constructor(t,n,...r){e(this,`severity`,void 0),e(this,`category`,void 0),e(this,`data`,void 0),this.severity=t,this.category=n,this.data=r}toString(){return`Interactive SDK error ${JSON.stringify(this,null,` `)}`}}function Rt({emitter$:e,error:t,subjectId:n,message:r=``,severity:i=1,category:a=1}){let o=new k(i,a,{message:r,error:t,details:{id:n}});e.next(o)}class zt{constructor(t,n,r){e(this,`container`,void 0),e(this,`options`,void 0),e(this,`factories`,void 0),e(this,`controls`,void 0),e(this,`error$`,new It),e(this,`cssVarsManager`,void 0),this.container=t,this.options=r,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=n}featureIsEnabled(e){return!!(this.options&&this.options.features&&Lt(this.options)&&this.options.features[e])}onError(e=``,t){Rt({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}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(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),r=this.factories.get(n);if(r){let n=r(t,this.options);if(n)return[...e,n]}return[...e]},[])||[]}}import{fromEvent as A,once as Bt}from"@vkontakte/videoplayer-shared/es2018";var j=(e,t)=>Object.prototype.toString.call(e)===`[object ${t}]`,M=e=>j(e,`Object`),Vt=e=>j(e,`String`),Ht=e=>j(e,`Array`),Ut=e=>j(e,`Number`),Wt=e=>j(e,`Function`),Gt=e=>j(e,`Boolean`),Kt=e=>Ut(e)&&!isNaN(e),N=e=>M(e)&&Object.keys(e).length===0,qt=e=>Ht(e)&&!e.length,Jt=(e,t)=>Vt(e)&&!!(t?e.trim():e).length;function Yt(e,t=1){let n=`0`,r=`0`,i=`0`;return e.length===4?(n=`0x`+e[1]+e[1],r=`0x`+e[2]+e[2],i=`0x`+e[3]+e[3]):e.length===7&&(n=`0x`+e[1]+e[2],r=`0x`+e[3]+e[4],i=`0x`+e[5]+e[6]),`rgba(${+n},${+r},${+i},${t})`}var Xt=`interactive`,P={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},Zt;(e=>{e.top=`flex-start`,e.bottom=`flex-end`,e.center=`center`})(Zt||={});var Qt;(e=>{e.start=`flex-start`,e.end=`flex-end`,e.center=`center`})(Qt||={});var $t=({target:e,props:t})=>{e.style.alignItems=(t?.gravityVertical&&Zt[t.gravityVertical])??`center`,e.style.justifyContent=(t?.gravityHorizontal&&Qt[t.gravityHorizontal])??`center`,e.style.textAlign=t?.alignment??`center`},en=({target:e,props:t,fallback:n,dependsOn:r})=>{var i,a,o;e.style.color=(t==null||(i=t.text)==null?void 0:i.color)??n.textColor,e.style.fontSize=`calc(${r.height} * ${(t==null||(a=t.text)==null?void 0:a.size)??n.textSize})`,e.textContent=(t==null||(o=t.text)==null?void 0:o.value)??n.textContent},tn=({target:e,props:t,fallback:n})=>{var r,i;e.style.backgroundColor=Yt((t==null||(r=t.background)==null?void 0:r.color)??n.backgroundColor,(t==null||(i=t.background)==null?void 0:i.alpha)??n.backgroundAlpha)},nn=({target:e,props:t,fallback:n,dependsOn:r,useRawValues:i=!1})=>{var a,o,s,c;let l=i?n.borderWidthRawValue:`calc(${r.height} * ${(t==null||(a=t.shape)==null||(a=a.border)==null?void 0:a.width)??n.borderWidth})`,u=i?n.roundCornersRawValue:`calc(${r.height} * ${(t==null||(o=t.shape)==null?void 0:o.roundCorners)??n.roundCorners})`;e.style.borderWidth=l,e.style.borderStyle=`solid`,e.style.borderColor=Yt(i?n.borderColor:(t==null||(s=t.shape)==null||(s=s.border)==null?void 0:s.color)??n.borderColor,i?n.borderAlpha:(t==null||(c=t.shape)==null||(c=c.border)==null?void 0:c.alpha)??n.borderAlpha),e.style.borderRadius=u},rn=({target:e,isDark:t,baseDimension:n,fallback:r})=>{let i=Yt(r.shadowColorLight,r.shadowColorAlpha),a=Yt(r.shadowColorDark,r.shadowColorAlpha),o=`0px 0px ${`calc(${n} * 0.25)`} ${`calc(${n} * 0.11)`} ${t?a:i}`;e.style.boxShadow=o},an=({target:e,layoutParams:t,fallback:n})=>{let r=t.angle??n.angle;r&&=r*-1,e.style.transform=`rotate(${r}rad)`};import{fromEvent as on,Subject as sn,Subscription as cn}from"@vkontakte/videoplayer-shared/es2018";var ln=`interactive-control-tap`,un={common:ln,animation:`${ln}-animation`,visible:`${ln}-visible`},dn=60;class fn{constructor({controlRotateAngleRad:t,clickCancelCondition:n,circleDiameterPx:r=dn,useDimensionsBasedSize:i=!1}){e(this,`element`,void 0),e(this,`controlRotateAngleRad`,void 0),e(this,`clickCancelCondition`,void 0),e(this,`circleDiameterPx`,void 0),e(this,`useDimensionsBasedSize`,void 0),e(this,`onElementClick`,e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},i=Math.min(r.width,r.height),a=n.left+n.width/2,o=n.top+n.height/2,s=pn(e.clientX-a,e.clientY-o,this.controlRotateAngleRad);this.element.style.width=i+`px`,this.element.style.left=s.x+n.width/2-i/2+`px`,this.element.style.top=s.y+n.height/2-i/2+`px`,this.element.classList.add(un.visible,un.animation)}),e(this,`onAnimationEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(un.visible,un.animation)});let a=document.createElement(`div`);a.classList.add(un.common),this.controlRotateAngleRad=t,this.element=a,this.clickCancelCondition=n,this.circleDiameterPx=r,this.useDimensionsBasedSize=i}}function pn(e,t,n){return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}}function mn(e){return`features`in e}var F=`interactive-control`,I={common:F,selected:`${F}-selected`,wrapper:`${F}-wrapper`,disabled:`${F}-disabled`,button:`${F}-button`,area:`${F}-area`,text:`${F}-text`,blinkAnim:`${F}-blink-anim`,blinkAnimButton:`${F}-blink-anim-button`,blinkAnimArea:`${F}-blink-anim-area`},hn=40,gn=f(Ge(),1);import{isSupportedManifest as _n,ContainerTypes as vn,ControlTypes as yn,EventActionTypes as L,EventTypes as bn,migrateManifestToLatestVersion as xn}from"@interactiveplatform/movika-manifest";var Sn={metadata:`Object`,chapters:`Array`},Cn=e=>{if(!M(e))return!1;for(let t in Sn){let n=e[t];if(!n||!j(n,Sn[t]))return!1}return _n(e.metadata.version)};function wn(e){return e.type===yn.Text}function Tn(e){return e.type===yn.Button}function En(e){return e.type===yn.Area}var Dn={Choice:`Choice`,TextInput:`TextInput`},On={Button:`Button`,Area:`Area`,Text:`Text`},kn={onClick:`onClick`,onSuspense:`onSuspense`},An={openURI:`openURI`,setNextBranch:`setNextBranch`,setWeightlessRandomBranch:`setWeightlessRandomBranch`,setRandomBranch:`setRandomBranch`,setMaxWeightBranch:`setMaxWeightBranch`,setMinWeightBranch:`setMinWeightBranch`,setDefaultBranch:`setDefaultBranch`,continuePlayback:`continuePlayback`,expect:`expect`},jn=e=>Ht(e)&&!qt(e),R=e=>e.order===`end`,Mn=e=>Ht(e.containers)&&!qt(e.containers)&&R(e),Nn=(e,t)=>{let n=e*1e3;return jn(t.controls)&&n<(t.startTime??0)},Pn=(e,t)=>{let n=e*1e3;return jn(t.controls)&&n>=(t.startTime??0)&&n<=(t.endTime??1/0)},Fn=(e=[])=>e.some(e=>e.action.type===`expect`),In=(e=[])=>e.find(e=>e.action.type===`expect`),Ln=e=>e?.length===1,Rn=e=>Ln(e)&&wn(e[0]);function zn(e=[],t=1/0,n=[]){return e.filter(({container:e})=>!gn.default(n,e.container.id)&&Fn(e.container.events)&&e.container.endTime===t&&!e.isRemoved&&!e.willRemoved)}function Bn({gameControllers:e=[],subjectName:t,subjectId:n,execFn:r}){for(let i of e)if(t===`container`&&i.container.container.id===n){r(i),zn(e,i.container.container.endTime,[i.container.container.id]).forEach(e=>{r(e)});break}}function Vn(e){for(let t of e.events)if(t.action.type===`openURI`)return!0;return!1}var Hn=(e,t)=>{let n=Fn(e.events)&&!(e=>t.find(({container:t})=>t.container.id===e)?.container.isRemoved)(e.id),r=(t,n=!1,r=!1)=>{let i=r?`every`:`some`;return t.controls[i](r=>{let a=n?t.endTime===e.endTime:!0;return r.events?.[i](e=>e.action?.type===L.openURI)&&a})},i=e=>e.some(({container:e})=>r(e.container,!0,!1)&&!e.isRemoved),a=e=>e.every(({container:e})=>e.isRemoved||e.willRemoved?!0:r(e.container,!0,!0)),o=zn(t,e.endTime,[e.id]).length,s=e=>e.controls.some(e=>e.events?.some(e=>{var t;return(t=e.action)==null||(t=t.args)==null?void 0:t.shouldOpenNow})),c=n||o>0,l=i(t),u=r(e),d=a(t),f=n?!1:o>0,p=s(e);return{isExpectTime:c,hasOtherExpect:o>0,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:u,isAllOpenURIEventsValid:d,isExpectEventForCurrentContainer:f,hasShouldOpenNowEvent:p}};class z{constructor(t,n=void 0){e(this,`control`,void 0),e(this,`options`,void 0),e(this,`container`,null),e(this,`controlElement`,null),e(this,`subscriptions`,new cn),e(this,`error$`,new sn),e(this,`controlTap`,void 0),e(this,`isInteracted`,!1),e(this,`isRemoved`,!1),e(this,`cssVarsManager`,null),e(this,`onControlSelect`,()=>{var e;this.container?.isManifestContainerDisabled()||Vn(this.control)||(e=this.container)==null||(e=e.element)==null||e.classList.add(`interactive-control-wrapper-selected`)}),e(this,`onTransitionEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}),this.control=t,this.options=n}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains(`interactive-control-before-remove`))return;t.classList.add(`interactive-control-before-remove`),this.subscriptions.add(on(t,`transitionend`).subscribe(this.onTransitionEnd,e=>this.onError(`${z.name} remove view transition error`,e))).add(on(t,`transitioncancel`).subscribe(this.onTransitionEnd,e=>this.onError(`${z.name} remove view transition error`,e)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e=``,t){Rt({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){this.featureIsEnabled(`controlsTapPlace`)&&this.container&&(this.controlTap=new fn({controlRotateAngleRad:this.control.layoutParams.angle??P.angle,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?hn:void 0}),this.subscriptions.add(on(e,`click`).subscribe(this.controlTap.onElementClick,e=>this.onError(`Control click tap animation error`,e))).add(on(this.controlTap.element,`animationend`).subscribe(this.controlTap.onAnimationEnd,e=>this.onError(`Tap animationend error`,e))),this.container.element.append(this.controlTap.element))}createContainerElement(e){let t=document.createElement(`div`);t.classList.add(I.wrapper),e.setControlLayout(t,this.control.layoutParams),this.container={element:t,dimensions:(this.control.layoutParams.innerSizesDependOn??P.innerSizesDependOn)===`self`?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue(`--interactive-content-height`)??0,width:this.cssVarsManager?.getPropValue(`--interactive-content-width`)??0},isManifestContainerDisabled:()=>e.isContainerDisabled?.call(e)??!1}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return!!(this.options&&mn(this.options)&&this.options.features[e])}isTouch(){return!!(this.options&&mn(this.options)&&this.options.isTouch)}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case`onclick`:if(!this.container)break;this.subscriptions.add(on(this.container.element,`click`).subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),e=>this.onError(`Error happened on control interaction`,e)));break;default:break}})}removeListeners(){this.subscriptions.unsubscribe()}}var Un=`interactive-blink-anim-reference`,B={common:Un,animation:`${Un}-animation`,disabled:`${Un}-disabled`};class Wn{constructor(){e(this,`_RAFId`,0),e(this,`_element`,void 0)}get element(){return this._element}create(){if(this._element)return;let e=document.createElement(`div`);e.classList.add(B.common,B.animation),this._element=e}restart(){this._element&&(this._element.classList.add(B.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(B.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&=(cancelAnimationFrame(this._RAFId),0)}destroy(){this.cleanupRAF(),this._element=void 0}}var Gn=`interactive-container`,V={common:Gn,hidden:`${Gn}-hidden`,disabled:`${Gn}-disabled`},Kn=(e,t)=>{if(e.type.trim().toLowerCase()===`area`)return new qn(e,t)};class qn extends z{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`button`);n.type=`button`,n.classList.add(I.common,I.area),n.setAttribute(`data-testid`,`int_area`),tn({target:n,props:this.control.props,fallback:{...P,backgroundColor:`transparent`}}),an({target:n,layoutParams:this.control.layoutParams,fallback:P}),this.addControlTap(n),this.subscriptions.add(A(this.container.element,`click`).pipe(Bt()).subscribe(this.onControlSelect,e=>this.onError(`Control click handler error`,e))),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled(`controlsExpectTimeBlinkAnimation`))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(A(this.controlElement,`mouseleave`).subscribe(()=>{if(e.classList.contains(V.disabled))return;let t=e.parentElement;if(t){let e=t.querySelector(`.${B.common}`);e&&this.syncBlinkAnimation(e)}},e=>this.onError(`Error happened in mouseleave callback`,e))),this.subscriptions.add(A(this.controlElement,`mouseenter`).subscribe(()=>{e.classList.contains(V.disabled)||this.onBlinkHovering()},e=>this.onError(`Error happened in mouseenter callback`,e))).add(A(this.controlElement,`mouseleave`).subscribe(()=>{this.controlElement&&(this.controlElement.style.animation=``)},e=>this.onError(`Error happened in mouseleave callback`,e))))}disable(){this.controlElement&&this.controlElement.classList.add(I.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(I.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(Gt(e)){var t;let n=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+`px`;rn({target:this.controlElement,props:this.control.props,fallback:P,isDark:e,baseDimension:n}),nn({target:this.controlElement,props:this.control.props,fallback:{...P,borderColor:e?P.shadowColorDark:P.shadowColorLight,borderAlpha:1,borderWidthRawValue:`0.1px`,roundCornersRawValue:`calc(${this.container.dimensions.height} * ${((t=this.control.props)==null||(t=t.shape)==null?void 0:t.roundCorners)??P.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else nn({target:this.controlElement,props:this.control.props,fallback:{...P,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(I.blinkAnim,e),this.controlElement?.classList.toggle(I.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${I.blinkAnimArea}`)||this.controlElement.classList.contains(I.selected)||this.controlElement.classList.contains(B.disabled)||(this.controlElement.classList.add(B.disabled),this.subscriptions.add(A(e,`animationiteration`).pipe(Bt()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(B.disabled)},e=>this.onError(`Error happened in animationiteration callback`,e)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${I.blinkAnimArea}`)||this.controlElement.classList.contains(I.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue(`--interactive-area-hover-opacity`).trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation=`none`,requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}}import{fromEvent as Jn,once as Yn}from"@vkontakte/videoplayer-shared/es2018";var Xn=e=>{let t=document.createElement(`span`);switch(e){case`Button`:case`button`:{let e=document.createElement(`div`);return Object.assign(e.style,{overflow:`hidden`,display:`flex`,justifyContent:`center`,alignItems:`center`}),e.append(t),Object.assign(t.style,{display:`inline-block`,whiteSpace:`pre`,textOverflow:`ellipsis`,maxWidth:`initial`,maxHeight:`100%`,wordBreak:`normal`}),e}default:return Object.assign(t.style,{display:`inline-block`,whiteSpace:`break-spaces`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,maxHeight:`100%`,wordBreak:`break-all`}),t}},Zn=Math.PI,Qn=2*Zn,$n=Zn/2,er=3*$n,tr=[0,$n,Zn,er];function nr(e){return e===$n}function rr(e){return e===Zn}function ir(e){return e===er}function ar(e){return(e%Qn+Qn)%Qn}function or(e){for(let t of tr)if(e===t)return t}function sr(e){return or(e)?null:[1,2,3,4][Math.floor(e/$n)+1-1]}function cr(e){return e*180/Math.PI}var H=`interactive-control-fill-animation`,U={common:H,fillerWrapper:`${H}-filler-wrapper`,filler:`${H}-filler`,fillHeight:`${H}-fill-height`,fillWidth:`${H}-fill-width`,fromTop:`${H}-from-top`,fromBottom:`${H}-from-bottom`,fromLeft:`${H}-from-left`,fromRight:`${H}-from-right`};class lr{constructor(t){e(this,`fillAnimationElement`,void 0),e(this,`fillAnimationFillerElement`,void 0),e(this,`fillAnimationFillerWrapperElement`,void 0),e(this,`startTime`,void 0),e(this,`endTime`,void 0),e(this,`shouldFillHeight`,void 0),e(this,`widthExpansionCoef`,0),e(this,`isDebug`,void 0),e(this,`fromLeft`,void 0),e(this,`useSkew`,void 0),e(this,`rotateAngle`,void 0);let n=document.createElement(`div`);n.classList.add(U.common);let r=document.createElement(`div`);r.classList.add(U.fillerWrapper);let i=document.createElement(`div`);i.classList.add(U.filler),r.append(i),n.append(r);let a=ar(t.rotateAngle),o=sr(a),s=o!==null,c=o===2||!s&&rr(a)||o===3,l=!s&&nr(a),u=!s&&ir(a),d=!c&&!l&&!u,f=l||u,p=s&&!f,m=p?a:0;n.style.borderRadius=t.borderRadius,r.style.transform=`skew(${m*-1}rad)`,f?(i.classList.add(U.fillHeight,l?U.fromTop:U.fromBottom),r.classList.add(U.fillHeight,l?U.fromTop:U.fromBottom)):(i.classList.add(U.fillWidth,d?U.fromLeft:U.fromRight),r.classList.add(U.fillWidth)),t.debug&&console.log(`[interactive ${lr.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:t,shouldFillHeight:f,rotateAngleRad:a,rotateAngelDeg:cr(a),rotateAngleRaw:t.rotateAngle,fromRight:c,fromTop:l,fromBottom:u,fromLeft:d}),this.useSkew=p,this.fromLeft=d,this.rotateAngle=a,this.fillAnimationElement=n,this.fillAnimationFillerElement=i,this.fillAnimationFillerWrapperElement=r,this.startTime=t.startTime,this.endTime=t.endTime,this.shouldFillHeight=f,this.isDebug=t.debug??!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.fillAnimationFillerWrapperElement.style.width=100*t+100+`%`,this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?`left`:`right`}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((e=>e<this.startTime||e>this.endTime)(e))return;let t=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/t,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:n,initHeight:r}){return t?(n+r*Math.abs(Math.tan(e)))/n-1:0}}var ur=(e,t)=>{if(e.type.trim().toLowerCase()===`button`)return new dr(e,t)};class dr extends z{constructor(t,n){super(t,n),e(this,`startTime`,void 0),e(this,`endTime`,void 0),e(this,`controlFillAnimation`,void 0)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`button`);n.type=`button`,n.classList.add(I.common,I.button),n.setAttribute(`data-testid`,`int_bttn`),an({target:n,layoutParams:this.control.layoutParams,fallback:P}),tn({target:n,props:this.control.props,fallback:P}),nn({target:n,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),$t({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=Xn(this.control.type.trim().toLowerCase());en({target:r.firstElementChild??r,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),this.addControlTap(n),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled(`controlsFillAnimation`)&&(this.controlFillAnimation=new lr({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??P.angle,borderRadius:n.style.borderRadius})),this.subscriptions.add(Jn(n,`click`).pipe(Yn()).subscribe(this.onControlSelect,e=>this.onError(`Control click handler error`,e))),n.append(r,this.controlFillAnimation?.fillAnimationElement??``),this.container.element.append(this.controlTap?.element??``,n),e.append(this.container.element),this.controlElement=n,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled(`controlsExpectTimeBlinkAnimation`))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Jn(this.controlElement,`mouseleave`).subscribe(()=>{if(e.classList.contains(V.disabled))return;let t=e.parentElement;if(t){let e=t.querySelector(`.${B.common}`);e&&this.syncBlinkAnimation(e)}},e=>this.onError(`Error happened in mouseleave callback`,e))),this.subscriptions.add(Jn(this.controlElement,`mouseenter`).subscribe(()=>{e.classList.contains(V.disabled)||this.onBlinkHovering()},e=>this.onError(`Error happened in mouseenter callback`,e))).add(Jn(this.controlElement,`mouseleave`).subscribe(()=>{this.controlElement&&(this.controlElement.style.animation=``)},e=>this.onError(`Error happened in mouseleave callback`,e))))}disable(){this.controlElement&&this.controlElement.classList.add(I.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(I.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(I.blinkAnim,e),this.controlElement?.classList.toggle(I.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${I.blinkAnimButton}`)||this.controlElement.classList.contains(I.selected)||this.controlElement.classList.contains(B.disabled)||(this.controlElement.classList.add(B.disabled),this.subscriptions.add(Jn(e,`animationiteration`).pipe(Yn()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(B.disabled)},e=>this.onError(`Error happened in animationiteration callback`,e)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${I.blinkAnimButton}`)||this.controlElement.classList.contains(I.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue(`--interactive-button-hover-opacity`).trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation=`none`,requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){this.controlFillAnimation?.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}}var fr=(e,t)=>{if(e.type.trim().toLowerCase()===`text`)return new pr(e,t)};class pr extends z{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`div`);n.classList.add(I.common,I.text),n.setAttribute(`data-testid`,`int_text`),an({target:n,layoutParams:this.control.layoutParams,fallback:P}),$t({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=Xn(this.control.type.trim().toLowerCase());en({target:r.firstElementChild??r,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}}var mr=(e,t,n,r)=>{if(e.type.trim().toLowerCase()===`choice`)return new hr(e,t,n,r)};class hr extends zt{constructor(t,n,r,i){super(t,r,i),e(this,`rootElement`,void 0),e(this,`containerElement`,null),e(this,`layout`,void 0),e(this,`subscriptions`,new Nt),e(this,`isRemoved`,void 0),e(this,`isDisabled`,void 0),e(this,`willRemoved`,void 0),e(this,`cssVarsManager`,void 0),e(this,`onTransitionEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}),this.rootElement=n,this.layout=new Ft(this.container.layout,r),this.cssVarsManager=r,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory(`button`,ur),this.addControlFactory(`text`,fr),this.addControlFactory(`area`,Kn)}createView({eventCallback:e,videoDurationMs:t}){let n=document.createElement(`div`);return n.classList.add(V.common,V.disabled),n.setAttribute(`data-subjectId`,this.container.id),requestAnimationFrame(()=>{n.classList.remove(V.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(r=>{r.setShowTimeRange(this.container.startTime,this.container.endTime??t),r.setCssVarsManager(this.cssVarsManager),r.createView({parentElement:n,callbacks:{setControlLayout:(e,t)=>this.layout.setControlLayout(e,t),isContainerDisabled:()=>this.isDisabled}}),r.setEvents(e),this.subscriptions.add(r.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let e of this.controls)e.updateFillAnimationDimensions()}hide(){let e=this.getElement();e&&e.classList.add(V.hidden)}show(){let e=this.getElement();e&&e.classList.remove(V.hidden)}enable(){let e=this.getElement();e&&(e.classList.remove(V.disabled),this.controls.forEach(e=>e.enable()),this.isDisabled=!1)}disable(){let e=this.getElement();e&&(e.classList.add(V.disabled),this.controls.forEach(e=>e.disable()),this.isDisabled=!0)}removeView(e=!1,t=!1){let n=this.getElement();if(n){if(e){if(this.willRemoved)return;this.willRemoved=!0,t&&n.classList.add(`interactive-container-before-remove-delay`),n.classList.add(`interactive-container-before-remove`),this.subscriptions.add(Mt(n,`transitionend`).subscribe(this.onTransitionEnd,e=>this.onError(`${hr.name} remove view transition error`,e))).add(Mt(n,`transitioncancel`).subscribe(this.onTransitionEnd,e=>this.onError(`${hr.name} remove view transition error`,e)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(e=!1){this.controls.forEach(t=>t.removeView(e))}removeNonInteractedControls(e=!1){this.controls.forEach(t=>{t.isInteracted||t.removeView(e)})}isInteracted(){return this.controls.some(e=>e.isInteracted)}fakeRemove(){this.isRemoved||=!0}getElement(){return this.containerElement}onProgress(e,t){t&&this.controls.forEach(t=>{t.onProgress(e)})}onResize(e){e&&this.controls.forEach(e=>{e.onResize()})}updateControlsShadowStyles(e){this.controls.forEach(t=>t.updateShadowStyles(e))}toggleBlinkAnimation(e){this.controls.forEach(t=>t.toggleBlinkAnimation(e))}}var gr=f(Ye(),1),_r=f(nt(),1),vr=(e,t)=>typeof e==`string`?_r.default(e,t):gr.default(e,t);import{combine as yr,InterfaceLanguage as br,Observable as xr,once as Sr,Subject as W,Subscription as Cr,ValueSubject as G,fromEvent as wr}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as Tr}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as Er}from"@vkontakte/videoplayer-shared/es2018";function Dr(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}var Or=`video_interactive`,kr=`videoint`,Ar=250;class jr{constructor(t){e(this,`isHidden`,void 0),e(this,`currentManifestId`,void 0),e(this,`currentChapterId`,void 0),e(this,`visitedChapterIds`,void 0),e(this,`onOpenPreviewClick`,void 0),e(this,`onError`,void 0),e(this,`lang`,void 0),e(this,`zoom`,void 0),e(this,`lastZoomInfo`,void 0),e(this,`isReady`,void 0),e(this,`ngEditor`,void 0),e(this,`ngEditorSize`,void 0),e(this,`graphWrapperElement`,void 0),e(this,`resizeObserver`,void 0),e(this,`manifest`,void 0),e(this,`handleZoomChange`,Dr(e=>{this.lastZoomInfo=e},Ar)),e(this,`onResize`,e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}}),e(this,`handleChapterChange`,e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.call(this,`Chapter id is not found`);return}this.visitedChapterIds.add(e.id),this.ngEditor?.selectChapter(e.id),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}}),e(this,`handleManifestChange`,(e,t=[])=>{if(this.isReady=!1,!Ut(e.graph.edit.chapters[0].x)){this.onError?.call(this,`Can't show graph`);return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id===this.currentManifestId?this.ngEditor.setVisitedChapters(Array.from(t)):(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id),this.isReady=!0)}),this.init(t)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:i=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(i),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??`ru`,this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Mr(e),this.resizeObserver=new ResizeObserver(Dr(this.onResize,Ar)),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){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display=`block`,!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await Er(this.lang,Or,kr)}catch{this.onError?.call(this,`Unable to load graph language pack`)}let{GraphEditor:t}=await import(`@interactiveplatform/movika-graph-editor`);this.ngEditor=new t(this.graphWrapperElement,{mode:`view`,lang:this.lang===`ru`?`ru`:`en`,translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on(`control`,({name:e,...t})=>{e===`openPreview`&&`chapterId`in t&&this.onOpenPreviewClick?.call(this,t.chapterId)}),this.ngEditor.on(`zoom`,this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display=`none`,this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function Mr(e){let t=document.createElement(`div`);return t.style.position=`absolute`,t.style.top=`0`,t.style.left=`0`,t.style.height=`100%`,t.style.width=`100%`,t.style.display=`none`,e.append(t),t}var Nr=3e3;class Pr{constructor(){e(this,`_containers`,[]),e(this,`_player`,null),e(this,`setPlayer`,e=>{this._player=e}),e(this,`setContainers`,e=>{this._containers=e}),e(this,`deleteContainer`,e=>{this._containers=this._containers.filter(t=>t.id!==e)}),e(this,`getNextInteractiveTime`,(e=Nr)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,r=Math.round(this._player.info.position$.getValue()*1e3);for(let i of this._containers){let a=i.startTime-e;if(a<=r&&(i.endTime&&r<=i.endTime||i.endTime===null)){n=!0;break}r<a&&(t=t===-1?a:Math.min(t,a))}return!n&&t!==-1?t:null})}}class Fr{constructor(){e(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 n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let e=n.length;e>0;e--)if(n[e]===t){n.splice(e,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(e=>{e(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}}class Ir{constructor(t){e(this,`raf`,void 0),e(this,`fn`,void 0),e(this,`fns`,[]),e(this,`addFn`,(e,t=!1)=>{Wt(e)&&(this.fns.push(e),t&&this.updateFn())}),e(this,`removeFn`,(e,t=!1)=>{this.fns=this.fns.filter(t=>t!==e),t&&this.updateFn()}),e(this,`updateFn`,()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}}),e(this,`forceRequestAnimation`,()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))}),e(this,`requestAnimation`,()=>{this.raf||this.forceRequestAnimation()}),e(this,`cancelAnimation`,()=>{this.raf&&=(cancelAnimationFrame(this.raf),void 0)}),t&&(this.fn=t,this.addFn(t))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}var Lr=f(mt(),1);class Rr{constructor(t){e(this,`rootElement`,void 0),e(this,`isCssVarsSupported`,void 0),e(this,`rootElementProps`,{}),this.rootElement=t,this.isCssVarsSupported=Rr.checkCssVarsSupport(t)}static checkCssVarsSupport(e){let t=`--test-key`,n=`test`;e.style.setProperty(t,n);let r=e.style.getPropertyValue(t)===n;return r&&e.style.removeProperty(t),r}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??``}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,n]of Lr.default(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}}import{ValueSubject as zr}from"@vkontakte/videoplayer-shared/es2018";class Br{constructor(t){e(this,`loaders`,void 0),this.loaders={chapterLoaders:t?.chapterLoaders??[],manifestLoaders:t?.manifestLoaders??[]}}async exec(e,t){return Vr(...this.loaders[e])(t)}}function Vr(...e){return async function(t){let n=[...e];for(;n.length>0;)t=await n.shift()(t);return t}}function Hr(e,t,n){return e?{...e,[t]:e[t]?[n,...e[t]]:[n]}:{[t]:[n]}}function Ur({actions:e,errors:t,chapterId:n,...r}){if(n){let i=e.getManifest();if(i){let a=e.getChapter(i.chapters,n);if(a){let n=e.getMedia(i.media,a.videoId),o=e.getGraph(i.graph,a.id);return n?{...r,actions:e,errors:t,result:{chapter:a,media:n,graph:o}}:{...r,errors:Hr(t,Ur.name,`Could not find media`),actions:e}}}}return{...r,errors:Hr(t,Ur.name,`Could not find chapter`),actions:e}}var{NativeAbortSignal:Wr,NativeAbortController:Gr}=function(e){return{NativeAbortSignal:e.AbortSignal,NativeAbortController:e.AbortController}}(typeof self<`u`?self:global);function Kr(e){let t;try{t=new Event(`abort`)}catch{typeof document<`u`?document.createEvent?(t=document.createEvent(`Event`),t.initEvent(`abort`,!1,!1)):(t=document.createEventObject(),t.type=`abort`):t={type:`abort`,bubbles:!1,cancelable:!1}}return t.reason=e,t}function qr(e){if(e===void 0)if(typeof document>`u`)e=Error(`This operation was aborted`),e.name=`AbortError`;else try{e=new DOMException(`signal is aborted without reason`),Object.defineProperty(e,`name`,{value:`AbortError`})}catch{e=Error(`This operation was aborted`),e.name=`AbortError`}return e}class Jr{constructor(){Object.defineProperty(this,`listeners`,{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let e=0,r=n.length;e<r;e++)if(n[e].callback===t){n.splice(e,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let t=this.listeners[e.type].slice();for(let n=0,r=t.length;n<r;n++){let r=t[n];try{r.callback.call(this,e)}catch(e){Promise.resolve().then(()=>{throw e})}r.options&&r.options.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}}class Yr extends Jr{constructor(){super(),this.listeners||Jr.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)}throwIfAborted(){let{aborted:e,reason:t=`Aborted`}=this;if(e)throw t}static timeout(e){let t=new Xr;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,`TimeoutError`)),e),t.signal}static any(e){let t=new Xr;function n(){t.abort(this.reason),r()}function r(){for(let t of e)t.removeEventListener(`abort`,n)}for(let r of e)if(r.aborted){t.abort(r.reason);break}else r.addEventListener(`abort`,n);return t.signal}}class Xr{constructor(){Object.defineProperty(this,`signal`,{value:new Yr,writable:!0,configurable:!0})}abort(e){let t=qr(e),n=Kr(t);this.signal.reason=t,this.signal.dispatchEvent(n)}toString(){return`[object AbortController]`}}typeof Symbol<`u`&&Symbol.toStringTag&&(Xr.prototype[Symbol.toStringTag]=`AbortController`,Yr.prototype[Symbol.toStringTag]=`AbortSignal`);function Zr(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log(`__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill`),!0):typeof e.Request==`function`&&!e.Request.prototype.hasOwnProperty(`signal`)||!e.AbortController}function Qr(e){typeof e==`function`&&(e={fetch:e});let{fetch:t,Request:n=t.Request,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=e;if(!Zr({fetch:t,Request:n,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:t,Request:a};let a=n;(a&&!a.prototype.hasOwnProperty(`signal`)||i)&&(a=function(e,t){let r;t&&t.signal&&(r=t.signal,delete t.signal);let i=new n(e,t);return r&&Object.defineProperty(i,`signal`,{writable:!1,enumerable:!1,configurable:!0,value:r}),i},a.prototype=n.prototype);let o=t;return{fetch:(e,t)=>{let n=a&&a.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(n){let r;try{r=new DOMException(`Aborted`,`AbortError`)}catch{r=Error(`Aborted`),r.name=`AbortError`}if(n.aborted)return Promise.reject(r);let i=new Promise((e,t)=>{n.addEventListener(`abort`,()=>t(r),{once:!0})});return t&&t.signal&&delete t.signal,Promise.race([i,o(e,t)])}return o(e,t)},Request:a}}var K=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window,$r=`fetch`in K&&Zr({fetch:K.fetch,Request:K.Request,AbortController:K.AbortController}),ei=$r?Qr({fetch:K.fetch,Request:K.Request,AbortController:K.AbortController}):void 0,ti=$r?ei.fetch:K.fetch;$r?ei.Request:K.Request,$r||K.AbortController,$r||K.AbortSignal;var ni=(e=``,t=``)=>{let n=e.split(`.`),r=t.split(`.`),i=0;for(let e=0;e<Math.max(n.length,r.length)&&!i;e++)i=n[e]>r[e]?1:n[e]<r[e]?-1:0;return i},ri=async e=>{try{let t={},n;if(Vt(e)){n=new URL(e).href;let r=await ti(n);if(!r.ok)return{};t=await r.json()}else if(M(e))t=e;else return{};if(!Cn(t))return{};let r=t.metadata.media;if(Vt(r)&&!(`media`in t))try{let e;n?e=new URL(r,n).href:(e=new URL(r).href,n=e);let i=await ti(e);if(!i.ok)throw Error();t.metadata.media=await i.json()}catch{return ui(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:n}}catch{return{}}};async function ii(e){let{manifest:t,manifestURL:n}=await ri(e);if(!t)throw Error(`Failed on fetch`);let r=xn(t);return r.media=ci(r.media,n),delete r.metadata.media,r}function ai(e,t){if(t)return e.find(e=>e.id===t)}function oi(e,t){if(e.edit?.chapters)return e.edit.chapters.find(e=>e.id===t);if(e.view?.chapters)return e.view.chapters.find(e=>e.id===t)}function si(e,t){return e.videos.find(e=>e.id===t)}function ci(e,t){return{...e,videos:e.videos.map(e=>({...e,variants:e.variants.map(e=>{let n=`url`in e?e.url:``,r=li(n,t);return{...e,url:r||n}})}))}}function li(e=``,t){try{return new URL(e,t).href}catch{return``}}function ui(e){return ni(e,`3.2.0`)>=0}class di extends Br{constructor(t,n){super(t),e(this,`manifest`,null),e(this,`chapter`,null),e(this,`media`,null),e(this,`graph`,null),e(this,`prevChapter$`,new zr(null)),e(this,`onError`,void 0),this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(e){this.release();let t=await this.exec(`manifestLoaders`,{actions:{addErrorMessage:Hr},result:null,errors:null,source:e});return t.errors&&this.errorHandler(t.errors),this.manifest=await ii(t.result??e),this}async setInitial(){return this.setNext()}async setNext(e=this.manifest?.metadata.initChapterId){if(!e)return this;this.prevChapter$.next(this.chapter);let t=await this.exec(`chapterLoaders`,Ur({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:oi,getChapter:ai,getMedia:si,getByBranches:this.getByBranches.bind(this),addErrorMessage:Hr},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),t.result&&(this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph),this}errorHandler(e){this.onError(e),console.error(`Something went wrong with loaders`,{errors:e})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(e=this.manifest?.metadata.initChapterId){if(!e||!this.manifest)return null;let t=ai(this.manifest.chapters,e);if(t){let e=si(this.manifest.media,t.videoId),n=oi(this.manifest.graph,t.id);if(e)return{chapter:t,media:e,graph:n}}return null}getBranches(e=this.chapter?.id){if(e===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let t=ai(this.manifest?.chapters||[],e);return this.getByBranches(t?.branches)}}getByBranches(e=[]){return e.reduce((e,t)=>{let n=this.getByChapterId(t.chapterId);return n&&e.push(n),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?R(this.chapter):!1}}var fi=f(vt(),1);import{Player as pi}from"@vkontakte/videoplayer-core/es2018";import{Subscription as mi,TracerFactory as hi,ValueSubject as gi}from"@vkontakte/videoplayer-shared/es2018";var _i=e=>{let t=e.variants.find(e=>e.payload?.type===`vk`);if(t&&t.payload){let[e,n]=t.payload.id.split(`_`);return[e,n]}return[]},vi=f(vt(),1);function yi(){let e=new Map;function t({listId:t=Math.random().toString(),itemId:n=Math.random().toString(),...r}){let i=e.get(t),a={...r};return i?i[n]=a:e.set(t,{[n]:a}),{listId:t,itemId:n,...r}}function n(e){e.player.destroy(),e.container.remove(),e.subscription.unsubscribe(),e.statistics?.oneStat.destroy(),e.statistics?.statSubscription.unsubscribe()}function r(t,r){let i=e.get(t);if(!i)throw Error(`Can't remove. Not find.`);if(r){let a=i[r];a&&n(a),delete i[r],Object.keys(i).length||e.delete(t)}else{for(let e of vi.default(i))n(e);e.delete(t)}}function i(){for(let t of e)r(t[0])}return{createPlayer:t,removePlayer:r,map:e,removeAll:i}}var bi=f(Ge(),1),xi=f(Ge(),1),Si=(e,...t)=>typeof e==`string`?e.includes(...t):xi.default(e,...t);function Ci(e,t=[]){let n={},r,i=!t.length;for(let a of e.variants)if(!r&&`cover`in a&&(r=a.cover),`url`in a)switch(a.type.toLowerCase()){case`mp4`:(i||bi.default(t,`mp4`))&&(n.MPEG={...n.MPEG,[a.standard??`Invariant quality`]:a.url});break;case`mpeg`:(i||bi.default(t,`mpeg`))&&(n.MPEG={...n.MPEG,[a.standard??`Invariant quality`]:a.url});break;case`hls`:(i||bi.default(t,`hls`))&&(n={...n,HLS:{type:`url`,url:a.url}});break;case`dash`:(i||bi.default(t,`dash`))&&(n={...n,DASH_SEP:{compatibilityMode:!0,type:`url`,url:a.url}});break;default:break}return{sources:n,thumbUrl:r,title:e.title??``}}var wi=(e,t)=>{let n=e.info.currentQuality$.getValue(),r=e.info.availableQualities$.getValue();n!==t&&Si(r,t)&&(e.setQuality(t),e.setAutoQuality(!1))},Ti=2;function Ei(e){let t=yi(),n=new mi,r={},i=null,a=!1,o,s=new gi(null);e&&c(e);function c(e){i=e}function l(e,n,o){if(!i)throw Error(`need to set interactive controller`);if(!i.options)return;let c=(t.map.get(e)??{})[n];if(c){r={chapterId:o,listId:e,itemId:n,...c};let l=r.player;r.subscription.add(l.info.currentQuality$.subscribe(e=>{let n=l.info.position$.getValue(),r=l.info.isAutoQualityEnabled$.getValue();if(!(!e||!n||r))for(let n of t.map)fi.default(n[1]).forEach(({player:t})=>{wi(t,e)})})).add(l.events.started$.subscribe(()=>{u(n)})),c.container.remove(),i.setPlayer(c.player),a||=(i.init(),!0),s.next({player:r.player,config:r.config,statistics:r.statistics});return}throw Error(`Can't set. Not find.`)}async function u(e){if(!i)throw Error(`need to set interactive controller`);if(N(r)||e!==r.itemId)return;let t=i.getChapterBranches(),n=new Set;for(let e of t)n.has(e.media.id)||(await f({media:e.media,chapterId:e.chapter.id,setAsActive:!1,title:e.chapter.label}),n.add(e.media.id))}async function d({chapter:{id:e},manifestVideo:n}){if(N(r)||!i)return;let a=r.player.info.muted$.getValue(),o=r.player.info.currentQuality$.getValue(),s=r.player.info.isAutoQualityEnabled$.getValue(),c=r.player.info.volume$.getValue(),u=r.player.info.currentPlaybackRate$.getValue(),d=!s,p=!1;for(let s of t.map)if(s[0]===n.id&&!i.state.isReplay$.getValue()){let n=Object.keys(s[1]);for(let i of n)i===r.itemId?(n.length<Ti||(p=!0),t.removePlayer(s[0],i)):(p=!0,l(s[0],i,e),d?wi(r.player,o):r.player.setAutoQuality(!0),r.player.setVolume(c),r.player.setMuted(a),r.player.setPlaybackRate(u))}else t.removePlayer(s[0]);p||(await f({media:n,chapterId:e,setAsActive:!0,playbackRate:u}),d?wi(r.player,o):r.player.setAutoQuality(!0),r.player.setVolume(c),r.player.setMuted(a))}async function f({media:e,chapterId:n,prefetch:a=!0,setAsActive:s=!0,autoplay:c=!1,preferredExt:u,title:d,playbackRate:f}){var p,m,h,g;let _=Math.random().toString(),v=document.createElement(`div`);o.append(v);let y;if(!(i==null||(p=i.options)==null)&&p.vkVideoLoader){let t=_i(e);t.length&&(y=await i.options.vkVideoLoader(...t))}let b={...(i==null||(m=i.options)==null?void 0:m.coreConfig)||void 0},x={container:v,sources:Ci(e,u).sources,...y==null||(h=y.videos)==null?void 0:h[0],title:d,failoverHosts:y?.failoverHosts||[]},S=new pi(b,hi.createRootTracer());S.initVideo(x);let C=null;if(y?.videos&&i?.options.createOneStat){let e=y.videos[0],t=i.options.createOneStat(e),n=new mi;t&&(n.add(t.attachTo(S)),C={oneStat:t,statSubscription:n})}let w=new mi,T=r==null||(g=r.player)==null?void 0:g.info.isAutoQualityEnabled$.getValue();w.add(S.events.canplay$.subscribe(function(){T||wi(S,r.player.info.currentQuality$.getValue()),f&&S.setPlaybackRate(f)}));let E=t.createPlayer({listId:e.id,itemId:_,player:S,container:v,sources:Ci(e,u).sources,config:x,subscription:w,statistics:C});return s&&l(e.id,E.itemId,n),c&&E.player.play(),a&&!c&&E.player.prepare(),{player:E.player,config:E.config,statistics:E.statistics}}function p(){m(),i=null,o.remove()}function m(){n.unsubscribe(),t.removeAll(),r={},a=!1}async function h(){if(!i)throw Error(`need to set interactive controller`);m(),o=document.createElement(`div`);let{media:e,chapter:t}=i.getCurrentChapter();e&&t?(n.add(i.events.chapterChanged$.subscribe(d)),await f({media:e,chapterId:t.id,title:t.label})):console.error(`not found`)}return{map:t.map,removePlayer:t.removePlayer,init:h,setInteractiveController:c,createPlayer:f,removeAll:p,getActivePlayer:function(){return r},activePlayerChanged:s}}var q={graph:`graph`,interactives:`interactives`,chapterChanged:`chapter-changed`,playerChanged:`player-changed`,manifestChanged:`manifest-changed`,errors:`errors`,eachTick:`eachTick`,historyInited:`history-inited`,historyDestroyed:`history-destroyed`},Di={visibility:`visibility`,watchAgainClicked:`watchAgainClicked`},J={actionChoiceCanceled:`action-choice-canceled`,actionChoice:`action-choice`,actionExecution:`action-execution`,visibility:`visibility`,containerRemoved:`container-removed`,rangeEnded:`range-ended`};import{Subscription as Oi}from"@vkontakte/videoplayer-shared/es2018";function ki(e){return function(...t){return e(...t.reverse())}}function Ai(e,...t){return(...n)=>M(t[0])&&M(n[0])?e({...t[0],...n[0]}):e(...t,...n)}class ji{constructor({player:t,container:n,branches:r,selectBranches:i,interactiveEvents:a,globalEvents:o,globalEventEmitter:s,getContainerEventState:c,permanentTextControls:l,interactiveTimeOpenUri:u,disabledControls$:d,onRemove:f,onError:p,disableTextControlContainerVisibilityEvents:m=!1,features:h}){e(this,`container`,void 0),e(this,`branches`,void 0),e(this,`selectBranches`,void 0),e(this,`subscription`,void 0),e(this,`player`,void 0),e(this,`interactiveEvents`,void 0),e(this,`getContainerEventState`,void 0),e(this,`isPermanentText`,void 0),e(this,`interactiveTimeOpenUri`,void 0),e(this,`disabledControls$`,void 0),e(this,`onRemove`,void 0),e(this,`globalEventEmitter`,void 0),e(this,`gameState`,void 0),e(this,`isSelectedControlEvent`,void 0),e(this,`isSelectedContainerEvent`,void 0),e(this,`globalEvents`,void 0),e(this,`onError`,void 0),e(this,`disableTextControlContainerVisibilityEvents`,void 0),e(this,`features`,void 0),e(this,`hide`,()=>{setTimeout(()=>{if(this.gameState!==4&&!(Fn(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect)){if(this.gameState!==2){var e;(e=this.container).hide?.call(e)}this.emitContainerVisibilityEvent(!1)}})}),e(this,`show`,()=>{if(!(this.gameState!==2||this.isSelectedControlEvent))if(this.container.getElement()){var e;let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if((e=this.container).show?.call(e),this.interactiveTimeOpenUri&&t||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let e={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(e,t)=>{let{isExpectTime:n,hasOtherExpect:r,hasOpenURIEvent:i,hasOpenURIEventInCurrentContainer:a,isAllOpenURIEventsValid:o,hasShouldOpenNowEvent:s}=this.getContainerEventState(),c=this.interactiveTimeOpenUri&&!a,l=this.interactiveTimeOpenUri&&a;if((!this.interactiveTimeOpenUri||c)&&(this.isSelectedControlEvent=!0),e!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||c)){if(this.interactiveTimeOpenUri){let e=!r&&!o&&a;e&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-fake-removed`,removeAllOpenURI:e})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&i&&this.gameState!==5){if(l){let e=((e,t,n,r)=>!e&&!t&&n||e&&!t&&n&&!r||e&&!t&&n&&r)(n,r,o,this.isSelectedContainerEvent);this.fakeRemoveView(e)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!n||!r||!s)&&(this.selectBranches.stopExpect(),t())}},isEOV:()=>this.gameState===4},n=Ai(this.selectBranches.onControlEvent,e),r=(this.player?.info.duration$.getValue()??1/0)*1e3;if(this.container.createView({eventCallback:n,videoDurationMs:r}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()){var t;(t=this.container).disable?.call(t)}}}),e(this,`onEndOfVideo`,()=>{this.gameState=4,this.selectContainerEvent(!0)}),e(this,`whilePlaying`,()=>{let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||=e instanceof HTMLObjectElement&&e?.getAttribute(`type`)===`application/avplayer`),!(t&&e?.readyState)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(Nn(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Pn(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let e=this.gameState;this.gameState=3,e===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:e}=this.getContainerEventState(),t=this.selectBranches.state.isExpect,n=this.interactiveTimeOpenUri&&e;if(n&&!t){let e=this.container.getElement();if(e){if(e.style.visibility!==`hidden`){var r;(r=this.container).hide?.call(r)}this.container.isRemoved||this.fakeRemoveView()}}!this.isPermanentText&&!n&&this.removeView()}let i=Pn(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],o={subjectId:this.container.container.id,subjectName:`container`,range:a,currentTime:n,isInteractiveTime:i};this.container.onProgress(n*1e3,i),this.globalEventEmitter.emit(q.eachTick,o),this.globalEvents.eachTick$.next(o)}),this.container=n,this.branches=r,this.selectBranches=i,this.subscription=new Oi,this.player=t,this.interactiveEvents=a,this.getContainerEventState=c;let g=Rn(n.container.controls);this.isPermanentText=l&&g,this.disableTextControlContainerVisibilityEvents=m&&g,this.interactiveTimeOpenUri=u,this.disabledControls$=d,this.onRemove=f,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=o,this.onError=p,this.features=h,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(q.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:J.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(q.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:J.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=>{if(e){var t;(t=this.container).disable?.call(t)}else{var n;(n=this.container).enable?.call(n)}})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,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(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:Fn(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e;(e=this.container).hide?.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(q.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:J.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-removed`}),this.gameState=5,this.onRemove?.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-fake-removed`,removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}}var Mi=(e=[])=>e.reduce((e,t,n)=>{if(jn((t?.controls??[]).filter(e=>!wn(e)))){let r=[t.startTime??0,t.endTime??1/0],i={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[i],range:r});else{let t=[],n=-1/0,a=1/0,o=[],s=[];for(let c=0;c<e.length;c++){let l=e[c];if(s.push(...l.subjects),l.range[0]<a&&(a=l.range[0]),l.range[1]>n&&(n=l.range[1]),r[0]>=l.range[0]&&r[1]<=l.range[1])return e[c].subjects.push(i),e;r[0]<l.range[0]&&r[1]>l.range[0]&&(t.push(c),o=o.concat(l.subjects)),r[0]>=l.range[0]&&r[0]<=l.range[1]&&(t.push(c),o=o.concat(l.subjects),r[0]=l.range[0]),r[1]>=l.range[0]&&r[1]<=l.range[1]&&(t.push(c),o=o.concat(l.subjects),r[1]=l.range[1])}if(s.push(i),r[0]<=a&&r[1]>=n)return[{subjects:s,range:r}];t.length&&t.reverse().forEach(t=>{e.splice(t,1)}),e.push({subjects:o.concat([i]),range:r})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]),Ni=f(Ge(),1),Pi=f(vt(),1),Fi=f(At(),1);function Ii(){let e={};function t(){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t]}function n(t){let n={};for(let r in e)+r<=t&&(n[r]=e[r]);return n}function r(t){let n={};for(let r in e)+r>=t&&(n[r]=e[r]);return n}function i({timestamp:t,priority:n,initiator:r}){if(Kt(t)){let i=e[t]??null;if(i&&n&&Jt(n,!0)){let e={},t=i[n];return t&&(e={...e,...t}),e=N(e)?null:e,e&&Jt(r,!0)?e[r]??null:e}return i}return null}function a({timestamp:t,priority:n,initiator:r}){if(Kt(t))if(e[t]){if(n&&Jt(n,!0))if(e[t][n]){if(r&&Jt(r,!0))if(e[t][n][r]){if(delete e[t][n][r],!N(e[t][n]))return!0}else return!1;if(delete e[t][n],!N(e[t]))return!0}else return!1;return delete e[t]}else return!1;return!1}function o({timestamp:t,priority:n,initiator:r,...i}){var a;!((a=e[t])==null||(a=a[n])==null)&&a[r]?e[t][n][r].push({...i}):e[t]?.[n]?e[t][n]={...e[t][n],[r]:[{...i}]}:e[t]?e[t]={...e[t],[n]:{[r]:[{...i}]}}:e[t]={[n]:{[r]:[{...i}]}}}return{map:e,remove:a,add:o,removeAll:t,get:i,getLte:n,getGte:r}}var Li=[L.expect,L.setNextBranch],Ri=1/0;function zi(e,t){let n=e,r,i=Bi(t),a=Ii(),o,s=()=>{p(),_()},c=e=>{a.add.call(void 0,e),m()},l=(e=[])=>{for(let t of e)if(t.action(),Ni.default(Li,t.actionType))break},u=(e=1/0)=>{let t=Vi(a.get({timestamp:e,priority:`control`})??{}),n=Vi(a.get({timestamp:e,priority:`container`})??{}),r=Vi(a.get({timestamp:e,priority:`chapter`})??{});return[...t,...n,...r]},d=e=>{i.isReady(e)&&l(u(e))},f=()=>{l([...Vi(a.get({timestamp:1/0,priority:`chapter`})??{})])},p=()=>{r&&=(o?.unsubscribe(),void 0)},m=()=>{r||(r=()=>setTimeout(()=>{d(1/0)}),o=n.events.ended$.subscribe(r))},h=e=>{p(),n=e},g=e=>{e.priority===`container`&&i.resetCalled(e.timestamp),a.remove(e)},_=()=>{i.release(),a.removeAll()};return{setPlayer:h,add:c,remove:g,exec:d,execEndOfVideo:f,listen:m,unlisten:p,release:s,containersEventsCallState:i,getPreparedToExecActions:u}}function Bi(e){let t=new Map;return{setCalled:({timestamp:e,id:n})=>{let r=t.get(e);r&&r[n]!==void 0&&(r[n]=!0)},setData:(e=[])=>{for(let n of e){let e=n.endTime??Ri,r=t.get(e);t.set(e,{...r,[n.id]:!1})}},resetCalled:e=>{let n=t.get(e);if(n)for(let e in n)n[e]=!1},isReady:n=>{let r=t.get(n);if(!r)return!0;let i=Pi.default(r);return e?i.some(e=>e):!i.some(e=>!e)},release:()=>t.clear()}}function Vi(e){return Fi.default(Pi.default(e)).sort(e=>e.actionType===L.expect?-1:1)}var Hi={videoContentHeight:0,videoContentWidth:0},Ui=e=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return Hi;let{clientHeight:r,clientWidth:i}=e.experimental.element$.getValue()||{};if(!(r&&i))return Hi;let a=t/n,o=r/i,s,c;return o>a?(c=i,s=i*a):o<a?(c=r/a,s=r):(c=i,s=r),{videoContentWidth:c,videoContentHeight:s}},Wi=250;function Gi(e){let t,n=new ResizeObserver(e=>{a(e),t=a.bind(null,e)});function r(t){let{parentElement:n,player:r,cssVarsManager:i}=e();if(!n||!r)return;let{videoContentWidth:a,videoContentHeight:o}=Ui(r);i.setup({"--interactive-content-width":`${a}px`,"--interactive-content-height":`${o}px`,"--interactive-width":`${t[0].contentRect.width}px`,"--interactive-height":`${t[0].contentRect.height}px`})}function i(){let{parentElement:t}=e();t.removeAttribute(`style`)}let a=Dr(t=>{let{fns:n=[]}=e();r(t);for(let e of n)e()},Wi);function o(){t=void 0,n.disconnect(),i()}return{resizeObserver:n,calc:()=>{t?.()},release:o}}var Ki=e=>Math.floor(Math.random()*e),qi=e=>{let t=e.length,n=1/0,r=null;for(;t--;){let i=e[t],a=i.weight??1;a<n&&(n=a,r=i)}return r},Ji=e=>{let t=e.length,n=-1/0,r=null;for(;t--;){let i=e[t],a=i.weight??0;a>n&&(n=a,r=i)}return r},Yi=e=>{let t=e.length;return e[Ki(t)]},Xi=1,Zi=e=>{let t=0;for(let n=0;n<e.length;++n)t+=e[n].weight??Xi;let n=Math.random()*t;t=0;for(let r=0;r<e.length-1;++r)if(t+=e[r].weight??Xi,t>=n)return e[r];return e[e.length-1]},Qi={shouldOpenNow:!0,isDetachContainer:!0},$i=`after-expect`,ea=(e,t=!1)=>({...e,args:t?{...e.args,...Qi}:{...Qi,...e.args}}),ta=({globalEventEmitter:e,globalEvents:t,player:n,interactiveEvents:r})=>{let i={isExpect:!1},a=()=>{i.isExpect&&=!1},o=({action:n,controlType:i,controlId:a,containerId:o,branches:s=[],onEvent:c,isEOV:l=()=>!1,isDisabled:d=()=>!1})=>{let f=ea(n,l()),_={timestamp:1/0,priority:`control`,initiator:a,actionType:f.type},v=d(),y=e.emit.bind(e,q.interactives,{subjectId:a,subjectType:i,subjectName:`control`,type:v?J.actionChoiceCanceled:J.actionChoice,actionType:n.type,payload:{invokeImmediately:f.args.shouldOpenNow,containerId:o,...f.args}}),b=()=>{t.interactiveActionChoice$.next({subjectId:a,subjectType:i,subjectName:`control`,type:v?`action-choice-canceled`:`action-choice`,actionType:n.type,payload:{invokeImmediately:f.args.shouldOpenNow,containerId:o,...f.args}})};if(v){y(),b();return}switch(f.type.trim().toLowerCase()){case L.setNextBranch.trim().toLowerCase():{let e=s.find(e=>e.id===f.args.branchId);if(!e)return;c(f.args.isDetachContainer,p.bind(null,{subjectId:a,subjectName:`control`})),y(),b(),f.args.shouldOpenNow?h({subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{chapterId:e.chapterId,autoSelect:!1}}):r.add({..._,action:h.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{chapterId:e.chapterId,autoSelect:!1}})});return}case L.continuePlayback.trim().toLowerCase():c(f.args.isDetachContainer,p.bind(null,{subjectId:a,subjectName:`control`})),y(),b(),f.args.shouldOpenNow?m({subjectId:a,subjectName:`control`,subjectType:i,action:n}):r.add({..._,action:m.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:n})});return;case L.openURI.trim().toLowerCase():c(f.args.isDetachContainer,p.bind(null,{subjectId:a,subjectName:`control`})),y(),b(),f.args.shouldOpenNow?g({subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{URI:n.args.uri}}):r.add({..._,action:g.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{URI:n.args.uri}})});return;default:{let e=`Unexpected control event`;u(new k(1,1,{message:e}),e);return}}},s=({action:n,container:{id:i,endTime:a},branches:o=[],isEOV:s=!1,autoSelected:c=!1})=>{let l=ea(n,s),d={timestamp:!l.args.shouldOpenNow||s?1/0:a??1/0,priority:`container`,initiator:i,actionType:l.type},f=e.emit.bind(e,q.interactives,{subjectId:i,subjectName:`container`,type:J.actionChoice,actionType:l.type,payload:{invokeImmediately:l.args.shouldOpenNow,...l.args}}),p=()=>{t.interactiveActionChoice$.next({subjectId:i,subjectName:`container`,type:`action-choice`,actionType:l.type,payload:{invokeImmediately:l.args.shouldOpenNow,...l.args}})};switch(l.type.trim().toLowerCase()){case L.setNextBranch.trim().toLowerCase():{let e=o.find(e=>e.id===l.args.branchId);if(!e)return;f(),p(),r.add({...d,action:h.bind(null,{subjectId:i,subjectName:`container`,action:l,payload:{chapterId:e.chapterId,autoSelect:c}})});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():f(),p(),r.add({...d,action:m.bind(null,{subjectId:i,subjectName:`container`,action:l})});return;case L.openURI.trim().toLowerCase():f(),p(),r.add({...d,action:g.bind(null,{subjectId:i,subjectName:`container`,action:l,payload:{URI:n.args.uri}})});return;default:{let e=`Unexpected container event`;u(new k(1,1,{message:e}),e);return}}};function c({container:n,branches:a,isEOV:o=!1}){let c=In(n.events);if(c){let a=ea(c.action,o);e.emit(q.interactives,{subjectId:n.id,subjectName:`container`,type:J.actionChoice,actionType:a.type,payload:{invokeImmediately:a.args.shouldOpenNow,...a.args}}),t.interactiveActionChoice$.next({subjectId:n.id,subjectName:`container`,type:`action-choice`,actionType:a.type,payload:{invokeImmediately:a.args.shouldOpenNow,...a.args}}),r.add({timestamp:o?1/0:n.endTime??1/0,priority:`container`,initiator:n.id,actionType:L.expect,action:f.bind(null,{subjectId:n.id,subjectName:`container`})}),i.isExpect=!0}else for(let e of n.events??[])s({action:e.action,container:n,branches:a,isEOV:o})}let l=({chapterId:n,action:r,branches:i=[]})=>{let a=e.emit.bind(e,q.interactives,{subjectId:n,subjectName:`chapter`,type:J.actionChoice,actionType:r.type,payload:r.args}),o=()=>{t.interactiveActionChoice$.next({subjectId:n,subjectName:`chapter`,type:`action-choice`,actionType:r.type,payload:r.args})};switch(r.type.trim().toLowerCase()){case L.setNextBranch.trim().toLowerCase():{let e=i.find(e=>e.id===r.args.branchId);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.setWeightlessRandomBranch.trim().toLowerCase():{let e=Yi(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.setRandomBranch.trim().toLowerCase():{let e=Zi(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.setMaxWeightBranch.trim().toLowerCase():{let e=Ji(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.setMinWeightBranch.trim().toLowerCase():{let e=qi(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.continuePlayback.trim().toLowerCase():return a(),o(),m.bind(null,{subjectId:n,subjectName:`chapter`,action:r});case L.openURI.trim().toLowerCase():return a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{URI:r.args.uri}});default:{let e=`Unexpected chapter event`;u(new k(1,1,{message:e}),e);return}}};function u(n,r){console.error(r),t.error$.next(n),e.emit(q.errors,n)}function d(n){let i=In(n.events);if(i){if(R(n))return;e.emit(q.interactives,{subjectId:n.id,subjectName:`chapter`,type:J.actionChoice,actionType:i.action.type,payload:i.action.args}),t.interactiveActionChoice$.next({subjectId:n.id,subjectName:`chapter`,type:`action-choice`,actionType:i.action.type,payload:i.action.args}),r.add({timestamp:1/0,priority:`chapter`,initiator:n.id,actionType:L.expect,action:f.bind(null,{subjectId:n.id,subjectName:`chapter`})})}else n.events?.forEach(e=>{let t=l({chapterId:n.id,action:e.action,branches:n.branches});t&&r.add({timestamp:1/0,priority:`chapter`,initiator:n.id,actionType:e.action.type,action:t})})}let f=({subjectId:r,subjectName:i})=>{n.pause(),e.emit(q.interactives,{subjectId:r,subjectName:i,type:J.actionExecution,actionType:L.expect}),t.interactiveActionExecution$.next({subjectId:r,subjectName:i,type:`action-execution`,actionType:L.expect})},p=({subjectId:i,subjectName:a})=>{n.info.isEnded$.getValue()?r.execEndOfVideo():n.play(),e.emit(q.interactives,{subjectId:i,subjectName:a,type:J.actionExecution,actionType:$i}),t.interactiveActionExecution$.next({subjectId:i,subjectName:a,type:`action-execution`,actionType:$i})},m=({subjectId:n,subjectName:r,subjectType:i,action:a})=>{e.emit(q.interactives,{subjectId:n,subjectName:r,subjectType:i,type:J.actionExecution,actionType:a.type}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type})},h=({subjectId:n,subjectName:r,subjectType:i,action:a,payload:o})=>{o.behaviour=`change-chapter`,e.emit(q.interactives,{subjectId:n,subjectName:r,subjectType:i,type:J.actionExecution,actionType:a.type,payload:o}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type,payload:o})},g=({subjectId:n,subjectName:r,subjectType:i,action:a,payload:o})=>{if(!o.URI)return;let s=window.open(o.URI,`_blank`,`noopener,noreferrer`);s&&(s.opener=null),e.emit(q.interactives,{subjectId:n,subjectName:r,subjectType:i,type:J.actionExecution,actionType:a.type}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type})};return{onControlEvent:o,onContainerEvent:s,onChapterEvent:l,onExpectEvent:f,expectEventHandler:p,setManifestChapterEvents:d,setManifestContainerEvents:c,stopExpect:a,state:i}};import{Subscription as na,Subject as ra,ValueSubject as ia}from"@vkontakte/videoplayer-shared/es2018";var aa=(e,t)=>{let n={};return e.map(e=>{if(!n[e]){let r=t.chapters.find(t=>t.id===e);if(!r)return null;let i=t.media.videos.find(e=>r.videoId===e.id);if(!i)return null;n[e]=ca(i)}return n[e]}).filter(e=>e!==null)},oa=e=>{for(let t of e.variants)if(sa(t)&&t.payload)return t.payload.id},sa=e=>!!(e.type===`custom`&&e.payload&&e.payload.type===`vk`),ca=e=>{let t=oa(e);if(!t)return null;let n=t.split(`_`).pop();return n?parseInt(n,10):null},la=(e,t)=>{for(let n of e.media.videos)if(t===ca(n)){for(let t of e.chapters)if(t.videoId===n.id)return t.id;return}},ua=(e,t)=>e.reduce((e,n)=>{let r=la(t,n);return r?[...e,r]:e},[]),Y=new WeakMap,da=new WeakMap,fa=new WeakMap,X=new WeakMap,pa=new WeakMap,Z=new WeakMap,Q=new WeakMap,$=new WeakMap,ma=new WeakMap,ha=new WeakMap,ga=new WeakMap;class _a{constructor({globalEventEmitter:i,videoId:a,interactiveController:o,historyApi:s,settings:c}){e(this,`state`,{history$:new ia([]),hasPrevChapter$:new ia(!1),prevChapter$:new ia(null),isInitialChapter$:new ia(!1),isGoBackLimited$:new ia(!1)}),t(this,Y,null),t(this,da,void 0),t(this,fa,!1),t(this,X,null),t(this,pa,null),e(this,`events`,{inited$:new ra,destroyed$:new ra,error$:new ra}),t(this,Z,null),t(this,Q,null),t(this,$,null),t(this,ma,new na),t(this,ha,!1),t(this,ga,0),n(Z,this,a),n($,this,i),n(Q,this,o),n(Y,this,s),n(da,this,c),this.state.history$&&r(ma,this)&&r(ma,this)?.add(this.state.history$.subscribe(e=>{var t;this.state.prevChapter$.next(vr(e,-2)||null),this.state.hasPrevChapter$.next(e.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((t=r(X,this))==null||(t=t.metadata)==null?void 0:t.initChapterId)),this.state.isGoBackLimited$.next(r(ga,this)===r(da,this).maxLength-1)}))}async setManifest(e){if(!r(Q,this)||!r($,this))return;n(X,this,e),await this.getProjectHistory();let t=this.getInitialChapterId();await r(Q,this).setChapter({chapterId:t,pushToHistory:!1}),r(fa,this)||(n(fa,this,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return r(fa,this)}async updateHistory(e,t=!0){if(!r(X,this))return;if(r(ha,this)){var i;n(ha,this,!1),n(ga,this,(i=r(ga,this),i++,i))}else n(ga,this,0);let a=r(X,this),o=e.length-r(da,this).maxLength,s=o>0?e.slice(o):e,c=aa(s,a);if(n(pa,this,c),this.state.history$.next(s),!(!t||!r(Y,this)||!r(Z,this)))try{await r(Y,this).save(r(Z,this),c)}catch{let e=new k(1,5,`Unable to save interactive history`);this.events.error$.next(e),r($,this)?.emit(q.errors,e)}}async goBack(){if(!this.state||!r(Q,this)){let e=new k(1,5,`Unable to save interactive history`);this.events.error$.next(e),r($,this)?.emit(q.errors,e);return}n(ha,this,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await r(Q,this).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!r(X,this)||!r(Z,this))return;let e=r(X,this),t=[this.getInitialVideoId()];if(r(Y,this))try{let e=await r(Y,this).get(r(Z,this));e.length&&(t=e)}catch{let e=new k(1,5,`Error while trying to fetch data`);this.events.error$.next(e),r($,this)?.emit(q.errors,e)}let n=ua(t,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(e==null?void 0:vr(e,-1))||r(da,this).initChapterId||r(X,this)?.metadata.initChapterId}getInitialVideoId(){return r(X,this)?aa([this.getInitialChapterId()],r(X,this)).pop():null}destroy(){n(Z,this,null),n(Y,this,null),n(Q,this,null),r(ma,this)?.unsubscribe(),n(ma,this,null),n(fa,this,!1),r($,this)?.emit(q.historyDestroyed),this.events.destroyed$.next(),n($,this,null)}}class va{constructor(){e(this,`rootElement`,void 0),e(this,`canvasImgSrc`,void 0),e(this,`_prevSizeId`,0),this.rootElement=document.createElement(`canvas`)}clear(){this.rootElement.getContext(`2d`)?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext(`2d`)?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let e=3;e<n;e+=40)if(t[e]!==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(){this.canvasImgSrc&&this.rootElement.getContext(`2d`)?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let r;t&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&r&&this.restore(r),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL(`image/jpeg`,1),t=new Image;return t.crossOrigin=`anonymous`,t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext(`2d`)?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}}class ya{constructor({parentElement:t,endOffsetMs:n=250,onError:r}){e(this,`lastFrameCanvas`,void 0),e(this,`endOffsetMs`,void 0),e(this,`currentChapter`,void 0),e(this,`currentVideoDurationMs`,1/0),e(this,`rootElement`,void 0),e(this,`_containerTimeFrameShouldReceived`,!1),e(this,`_endTimeFrameReceived`,!1),e(this,`_shouldCallSkip`,!1),e(this,`_callbacks`,void 0),e(this,`onEachTick`,e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)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()}}),e(this,`onSeek`,()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())}),this.rootElement=document.createElement(`div`),this.rootElement.style.cssText=`
7
+ position: absolute;
8
+ top: 0;
9
+ left: 0;
10
+ width: var(--interactive-width);
11
+ height: var(--interactive-height);
12
+ background-color: var(--black);
13
+ visibility: hidden;
14
+ `,this.lastFrameCanvas=new va,this.endOffsetMs=n,this._callbacks={onError:r},this.lastFrameCanvas.rootElement.style.cssText=`
15
+ position: absolute;
16
+ top: 50%;
17
+ left: 50%;
18
+ transform: translate(-50%, -50%);
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),t.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility=`visible`}hide(){this.rootElement.style.visibility=`hidden`}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue(`--interactive-content-width`),10),height:parseInt(t.getPropertyValue(`--interactive-content-height`),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(e){this._onError(e)}}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=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(t=this._callbacks)==null||(n=t.onError)==null||n.call(t,e)}}function ba(e=0){return new Promise(t=>{setTimeout(()=>{t(0)},e)})}var xa=`/* interactive-container */
20
+ .interactive-container {
21
+ opacity: 1;
22
+ visibility: visible;
23
+ transition: opacity var(--interactive-transition-1);
24
+ }
25
+
26
+ .interactive-container-disabled {
27
+ opacity: 0.5;
28
+ }
29
+
30
+ .interactive-container-hidden {
31
+ visibility: hidden;
32
+ }
33
+
34
+ .interactive-container.interactive-container-before-remove.interactive-container-before-remove-delay {
35
+ transition-delay: var(--interactive-remove-delay);
36
+ }
37
+
38
+ .interactive-container.interactive-container-before-remove {
39
+ transition: opacity var(--interactive-transition-1);
40
+ opacity: 0;
41
+ pointer-events: none;
42
+ }
43
+
44
+ /* blink-anim */
45
+ .interactive-control-blink-anim {
46
+ animation-duration: 2001ms;
47
+ animation-iteration-count: infinite;
48
+ animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
49
+ }
50
+
51
+ .interactive-control-blink-anim-button {
52
+ animation-name: interactive-blinking-button;
53
+ }
54
+
55
+ .interactive-control-blink-anim-area {
56
+ animation-name: interactive-blinking-area;
57
+ }
58
+
59
+ @keyframes interactive-blinking-area {
60
+ 0%, 100% {
61
+ opacity: 1;
62
+ }
63
+ 50% {
64
+ opacity: var(--interactive-area-hover-opacity);
65
+ }
66
+ }
67
+
68
+ @keyframes interactive-blinking-button {
69
+ 0%, 100% {
70
+ opacity: 1;
71
+ }
72
+ 50% {
73
+ opacity: var(--interactive-button-hover-opacity);
74
+ }
75
+ }
76
+
77
+ /* blink-anim-reference */
78
+ .interactive-blink-anim-reference {
79
+ position: absolute;
80
+ height: 0;
81
+ width: 0;
82
+ top: 0;
83
+ left: 0;
84
+ pointer-events: none;
85
+ }
86
+
87
+ .interactive-blink-anim-reference-animation {
88
+ animation-duration: 2001ms;
89
+ animation-iteration-count: infinite;
90
+ animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
91
+ animation-name: interactive-blinking-button;
92
+ }
93
+
94
+ .interactive-blink-anim-reference-disabled {
95
+ animation: none;
96
+ }
97
+
98
+ /* control tap */
99
+ .interactive-control-tap {
100
+ position: absolute;
101
+ aspect-ratio: 1;
102
+ background-color: var(--interactive-bg-color-1);
103
+ border: 1px solid var(--interactive-color-1);
104
+ border-radius: 50%;
105
+ transition: opacity var(--interactive-transition-1);
106
+ opacity: 0;
107
+ pointer-events: none;
108
+ z-index: 1;
109
+ }
110
+
111
+ .interactive-control-tap-animation {
112
+ animation-duration: 300ms;
113
+ animation-iteration-count: 1;
114
+ animation-timing-function: ease;
115
+ animation-name: interactive-control-tap-bounce;
116
+ }
117
+
118
+ @keyframes interactive-control-tap-bounce {
119
+ 0%, 100% {
120
+ transform: scale(1);
121
+ }
122
+ 50% {
123
+ transform: scale(0.3);
124
+ }
125
+ }
126
+
127
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-tap-visible {
128
+ opacity: 1;
129
+ }
130
+
131
+ /* interactive-chapter */
132
+ .interactive-chapter {
133
+ position: absolute;
134
+ top: 0;
135
+ left: 0;
136
+ font-family: inherit;
137
+
138
+ --interactive-transition-1: 100ms ease-in-out;
139
+ --interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
140
+ --interactive-color-1: #fff;
141
+ --interactive-bg-color-1: rgba(255, 255, 255, 0.08);
142
+ --interactive-button-hover-opacity: 0.8;
143
+ --interactive-area-hover-opacity: 0;
144
+ --interactive-remove-delay: 300ms;
145
+ }
146
+
147
+ /* interactive-control */
148
+ .interactive-control-wrapper-selected {
149
+ pointer-events: none;
150
+ }
151
+
152
+ .interactive-control {
153
+ display: flex;
154
+ width: 100%;
155
+ height: 100%;
156
+ font-family: inherit;
157
+
158
+ position: relative;
159
+ isolation: isolate;
160
+ opacity: 1;
161
+
162
+ box-shadow: none;
163
+ border: none;
164
+ }
165
+
166
+ .interactive-control.interactive-control-disabled {
167
+ cursor: default;
168
+ }
169
+
170
+ .interactive-control-button,
171
+ .interactive-control-area {
172
+ cursor: pointer;
173
+ }
174
+
175
+ .interactive-control-button {
176
+ transition: opacity var(--interactive-transition-2);
177
+ }
178
+
179
+ .interactive-control-area {
180
+ transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
181
+ }
182
+
183
+ .interactive-control-wrapper-selected > .interactive-control-button {
184
+ transition: opacity var(--interactive-transition-1);
185
+ opacity: 0.5;
186
+ }
187
+
188
+ .interactive-control-wrapper-selected > .interactive-control-area {
189
+ transition: opacity var(--interactive-transition-1);
190
+ opacity: 0;
191
+ }
192
+
193
+
194
+ .interactive-control.interactive-control-before-remove {
195
+ transition: opacity var(--interactive-transition-1);
196
+ opacity: 0;
197
+ pointer-events: none;
198
+ }
199
+
200
+ .interactive-container.interactive-container-disabled .interactive-control-button,
201
+ .interactive-container.interactive-container-disabled .interactive-control-area {
202
+ animation: none;
203
+ }
204
+
205
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):hover,
206
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):focus-visible {
207
+ opacity: var(--interactive-button-hover-opacity);
208
+ animation: none;
209
+ }
210
+
211
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):hover,
212
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):focus-visible {
213
+ opacity: var(--interactive-area-hover-opacity);
214
+ animation: none;
215
+ }
216
+
217
+ /* fill animation */
218
+ .interactive-control-fill-animation {
219
+ position: absolute;
220
+ overflow: hidden;
221
+ z-index: -1;
222
+ pointer-events: none;
223
+ }
224
+
225
+ .interactive-control-fill-animation-filler-wrapper {
226
+ position: absolute;
227
+ width: 100%;
228
+ height: 100%;
229
+ transform-origin: center;
230
+ }
231
+
232
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-width {
233
+ top: 0;
234
+ }
235
+
236
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-height {
237
+ left: 0;
238
+ }
239
+
240
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-right {
241
+ right: 0;
242
+ }
243
+
244
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-left {
245
+ left: 0;
246
+ }
247
+
248
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-top {
249
+ top: 0;
250
+ }
251
+
252
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-bottom {
253
+ bottom: 0;
254
+ }
255
+
256
+ .interactive-control-fill-animation-filler {
257
+ width: 100%;
258
+ height: 100%;
259
+ background-color: rgba(173, 211, 255, 0.32);
260
+ }
261
+
262
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-width {
263
+ transform: scaleX(0);
264
+ }
265
+
266
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-height {
267
+ transform: scaleY(0);
268
+ }
269
+
270
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-right {
271
+ transform-origin: right;
272
+ }
273
+
274
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-left {
275
+ transform-origin: left;
276
+ }
277
+
278
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-top {
279
+ transform-origin: top;
280
+ }
281
+
282
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
283
+ transform-origin: bottom;
284
+ }
285
+ `,Sa=e=>{let t=document.createElement(`style`);t.textContent=xa,e.prepend(t)};import{clientChecker as Ca}from"@vkontakte/videoplayer-core/es2018";var wa=Object.freeze({lang:br.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1},enableAvPlayerSupport:!1});function Ta(){let e=document.createElement(`div`);return e.classList.add(`interactive-chapter`),e}class Ea{constructor(t){if(e(this,`playerSubscriptions`,new Cr),e(this,`subscriptions`,new Cr),e(this,`globalEventEmitter`,new Fr),e(this,`animation`,new Ir),e(this,`seekToInteractiveController`,new Pr),e(this,`endedRanges`,new Set),e(this,`gameControllers`,[]),e(this,`rootElement`,Ta()),e(this,`factories`,new Map([[`choice`,mr]])),e(this,`isFirstChapterFetched`,!1),e(this,`_options`,void 0),e(this,`manifestController`,void 0),e(this,`resizeManager`,void 0),e(this,`cssVarsManager`,void 0),e(this,`historyController`,void 0),e(this,`player`,null),e(this,`interactiveEvents`,null),e(this,`selectBranches`,null),e(this,`seamlessController`,null),e(this,`seamlessControllerSubs`,new Cr),e(this,`graph`,null),e(this,`lastFrame`,null),e(this,`noInteractionTimeout`,void 0),e(this,`blinkAnimationRef`,null),e(this,`appState`,0),e(this,`state`,{prevChapter$:new G(null),isInitialChapter$:new G(!1),isFirstChapter$:new G(!0),isEndChapter$:new G(!1),isInteractiveExpectation$:new G(!1),isReplay$:new G(!1),calledByInteractive$:new G(!1),lastChapterChangeWasInitiatedByInteractive$:new G(!1),disabledControls$:new G(!1),interactiveRanges$:new G([]),isInteractiveTime$:new G(!1),statistics$:new G(null),isSeekable$:new G(!1)}),e(this,`events`,{noInteraction$:new W,graphVisibilityChanged$:new W,watchAgainIsClicked$:new W,chapterChanged$:new W,playerChanged$:new W,error$:new W,eachTick$:new W,manifestChanged$:new W,interactiveRangeEnded$:new W,interactiveContainerRemoved$:new W,interactiveContainerFakeRemoved$:new W,interactiveActionExecution$:new W,interactiveActionChoice$:new W,interactiveVisibilityChanged$:new W}),e(this,`emitErrorEvent`,e=>{this.events.error$.next(e),this.globalEventEmitter.emit(q.errors,e)}),e(this,`clearHistoryIfEnded`,()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&R(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener(`beforeunload`,this.clearHistoryIfEnded)}),e(this,`handleSeamlessPlayerChanged`,e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:e,oneStat:n}=t;e.add(n.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(q.playerChanged,n)}),e(this,`onPlaybackStarted`,()=>{this.resizeManager?.calc(),this.animation.requestAnimation()}),e(this,`destroyGameControllers`,({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let n of this.gameControllers)!e&&n.isPermanentText||(this.animation.removeFn(n.whilePlaying),n.destroy(t))}),e(this,`completeInteractiveRange`,e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(t=>({...t,subjects:t.subjects.filter(t=>t.id!==e)}));t.next(n)}),e(this,`clearNoInteractionTimeout`,()=>{this.noInteractionTimeout&&=(clearTimeout(this.noInteractionTimeout),void 0)}),this._options={...wa,...t,config:{...wa.config,...t.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Wn,this.blinkAnimationRef.create();let e=this.blinkAnimationRef.element;e&&this.rootElement.append(e)}this._options.parentElement.append(this.rootElement),this.historyController=new _a({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new ya({parentElement:this._options.parentElement,onError:e=>{let t=new k(1,6,e);this.emitErrorEvent(t)}})),Sa(this._options.parentElement),this.subscriptions.add(wr(this.rootElement,`mousedown`).subscribe(e=>e.stopPropagation())).add(wr(this.rootElement,`mouseup`).subscribe(e=>e.stopPropagation())),this.manifestController=new di(this._options.loaders,e=>{let t=new k(1,3,e);this.emitErrorEvent(t)});let n=[];this._options.lastFrame&&n.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),n.push(()=>{let e=this.state.isInteractiveTime$.getValue();for(let t of this.gameControllers)t.onResize(e)}),this.cssVarsManager=new Rr(this._options?.parentElement),this.resizeManager=Gi(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new jr({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:e=>{this.setChapter({chapterId:e}),this.globalEventEmitter.emit(q.graph,{type:Di.watchAgainClicked,chapterId:e}),this.events.watchAgainIsClicked$.next(e)},onError:e=>{let t=new k(1,2,{message:e});this.emitErrorEvent(t)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),(e.actionType===`setNextBranch`||!this._options.endChapterHistoryFix)&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour===`change-chapter`){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour===`change-manifest`){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}e.actionType===`expect`?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType===`after-expect`&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({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:n})=>{e!==`action-choice`||t===`chapter`||`invokeImmediately`in n&&n.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:this._options.animationsFeatureToggles?.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=Ei(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:e})=>t>=e[1]);if(n){let e=n.range.join(`-`);this.endedRanges.has(e)||(this.endedRanges.add(e),this.globalEventEmitter.emit(q.interactives,{type:J.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(Sr()).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(yr({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{let r;if(n)r=!0;else{let n=e*1e3;r=!!t.find(({range:[e,t],subjects:r})=>e<n&&n<t&&r.some(e=>!e.isRemoved)&&r.length)}r!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(r);let i=!!this.noInteractionTimeout,a=this.player?.info.playbackState$.getValue()===`playing`||n;r&&!i&&a?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):i&&!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=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(e=>e.container.container).filter(e=>!Rn(e.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{let r=n.type.trim().toLowerCase(),i=this.factories.get(r)?.(n,this.rootElement,this.cssVarsManager,{isTouch:this._options?.isTouch??!1,features:{controlsExpectTimeBlinkAnimation:this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation,controlsTapPlace:this._options.animationsFeatureToggles?.controlsTapPlace,controlsFillAnimation:this._options.animationsFeatureToggles?.controlsFillAnimation}});if(i&&this.selectBranches&&this.interactiveEvents&&this.player){let r=new ji({player:this.player,container:i,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Hn(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:this.options.disableTextControlContainerVisibilityEvents??!1,features:{controlsHideAnimation:this._options.animationsFeatureToggles?.controlsHideAnimation,enableAvPlayerSupport:this._options.enableAvPlayerSupport}});this.animation.addFn(r.whilePlaying,!0),t.push(r)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let e=this.state.isSeekable$.getValue(),t=!!this.seekToInteractiveController.getNextInteractiveTime();(t&&!e||!t&&e)&&this.state.isSeekable$.next(!e)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),r=(n&&R(n)&&Mn(n))??!1,i=this.manifestController.manifest?.metadata.initChapterId===e,a=this.historyController.state.history$.getValue();if(i||r&&t){this.historyController.updateHistory([e]);return}vr(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,r=n.getValue().map(n=>{let r=n.subjects.some(t=>t.id===e),i=n.subjects.map(n=>t&&r||n.id===e?{...n,isRemoved:!0}:n);return{...n,subjects:i}});n.next(r)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this._options.endChapterHistoryFix&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){if(!this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation)return;let t=(e,t)=>{e.toggleBlinkAnimation(t)};Bn({...e,gameControllers:this.gameControllers,execFn:Ai(ki(t),e.isExpect)}),e.isExpect&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(e,t)=>{e.updateControlsShadowStyles(t)};e.isExpect?Bn({...e,gameControllers:this.gameControllers,execFn:Ai(ki(t),!1)}):Bn({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(q.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=zi(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ta({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Ca.browser.isSafari&&await ba(35);let r=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(r);let{chapter:i,media:a,graph:o}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||r)&&this.state.isFirstChapter$.next(!0),!(!i||!a)&&(t&&this.pushChapterToHistory(i.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(i),this.state.isInteractiveTime$.next(!1),this.state.isInteractiveExpectation$.next(!1),this.lastFrame?.setCurrentChapter(i),this.events.chapterChanged$.next({chapter:i,manifestVideo:a}),this.globalEventEmitter.emit(q.chapterChanged,{chapter:i,media:a,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new xr(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Tr.GRAPH_SHOW:Tr.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Tr.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:r})=>{t!==`action-choice`||n!==`control`||(r===`Button`&&e.next(Tr.NEXT_BUTTON),r===`Area`&&e.next(Tr.NEXT_AREA))}))}),nextMovie$:new xr(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(q.graph,{type:Di.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(e=>e.actionType===L.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(t=>{let n=e&&this._options.animationsFeatureToggles?.controlsHideAnimation?t.container.willRemoved:!0;return!t.container.isRemoved||!n})}isEndedExpectation(){return!this.player||!this.gameControllers?!1:this.player.info.position$.getValue()===this.player.info.duration$.getValue()&&this.gameControllers.some(e=>{let t=e.container.container;return!e.container.isRemoved&&!e.container.willRemoved&&t.endTime===null&&Fn(t.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&_n(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return Mi(this.manifestController.chapter?.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(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}}var Da={Container:zt,createChoiceContainer:mr,createAreaControl:Kn,createButtonControl:ur,classnamesPrefix:Xt},Oa={version:jt};export{ua as vkVideoIdsToChapterIds,Da as utils,xn as migrateManifestToLatestVersion,Cn as isValidManifest,sa as isVKVariantItem,wn as isTextControl,_n as isSupportedManifest,Rn as isOneTextCtrlContainer,R as isLastChapter,Tn as isButtonControl,En as isAreaControl,J as interactivesEventTypes,Mn as hasEndTemplate,Di as graphEventTypes,oa as getVideoRawIdByMedia,ca as getVKVideoIdByMedia,la as getChapterIdByVkVideoId,kn as eventTypes,An as eventActionTypes,On as controlTypes,Dn as containerTypes,ni as compareVersions,aa as chapterIdsToVKVideoIds,Oa as SDKInfo,di as ManifestController,Ea as Interactives,bn as EventTypes,L as EventActionTypes,q as EVENT_NAMES,k as CustomError,yn as ControlTypes,vn as ContainerTypes};
286
+ //# sourceMappingURL=es2018.esm.js.map