@vkontakte/videoplayer-interactive 1.0.8-dev.e22781d9.0 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -6
- package/es2015.esm.js +6 -6
- package/es2018.cjs.js +6 -6
- package/es2018.esm.js +6 -6
- package/esnext.cjs.js +6 -6
- package/esnext.esm.js +6 -6
- package/evergreen.esm.js +6 -6
- package/index.d.ts +24 -21
- package/package.json +3 -3
package/es2015.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.8
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.8
|
|
3
|
+
* Mon, 08 Apr 2024 01:41:21 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-8/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var Cn=Object.create;var jt=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var On=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of In(e))!Sn.call(t,r)&&r!==i&&jt(t,r,{get:()=>e[r],enumerable:!(n=_n(e,r))||n.enumerable});return t};var Tn=(t,e,i)=>(i=t!=null?Cn(wn(t)):{},On(e||!t||!t.__esModule?jt(i,"default",{value:t,enumerable:!0}):i,t));var L=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),jn=require("uuid"),$n=require("@vkontakte/videoplayer-core/es2015.cjs.js");const Rn="1.0.8-dev.e22781d9.0";function bi(t,e=1){let i="0",n="0",r="0";return t.length===4?(i="0x"+t[1]+t[1],n="0x"+t[2]+t[2],r="0x"+t[3]+t[3]):t.length===7&&(i="0x"+t[1]+t[2],n="0x"+t[3]+t[4],r="0x"+t[5]+t[6]),`rgba(${+i},${+n},${+r},${e})`}const z="SDK_NAME",An="SDK_NAME-controls-container",gi=()=>document.querySelector(`.${An}`),xn=.4,K={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},$t={top:"flex-start",bottom:"flex-end",center:"center"},Rt={start:"flex-start",end:"flex-end",center:"center"},At={start:"left",end:"right",center:"center"},Ei=({target:t,props:e})=>{var i,n,r,s,c,a;t.style.alignItems=(n=$t[(i=e==null?void 0:e.text)===null||i===void 0?void 0:i.gravityVertical])!==null&&n!==void 0?n:$t.center,t.style.justifyContent=(s=Rt[(r=e==null?void 0:e.text)===null||r===void 0?void 0:r.gravityHorizontal])!==null&&s!==void 0?s:Rt.center,t.style.textAlign=(a=At[(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.alignment])!==null&&a!==void 0?a:At.start},Ci=({target:t,props:e,fallback:i,dependsOn:n})=>{var r,s,c,a,l,d;t.style.color=(s=(r=e==null?void 0:e.text)===null||r===void 0?void 0:r.color)!==null&&s!==void 0?s:i.textColor,t.style.fontSize=`calc(${n.height} * ${(a=(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.size)!==null&&a!==void 0?a:i.textSize})`,t.textContent=(d=(l=e==null?void 0:e.text)===null||l===void 0?void 0:l.value)!==null&&d!==void 0?d:i.textContent},_i=({target:t,props:e,fallback:i})=>{var n,r,s,c;t.style.backgroundColor=bi((r=(n=e==null?void 0:e.background)===null||n===void 0?void 0:n.color)!==null&&r!==void 0?r:i.backgroundColor,(c=(s=e==null?void 0:e.background)===null||s===void 0?void 0:s.alpha)!==null&&c!==void 0?c:i.backgroundAlpha)},Ii=({target:t,props:e,fallback:i,dependsOn:n})=>{var r,s,c,a,l,d,f,u,v,m,g;t.style.border=`calc(${n.height} * ${(c=(s=(r=e==null?void 0:e.shape)===null||r===void 0?void 0:r.border)===null||s===void 0?void 0:s.width)!==null&&c!==void 0?c:i.borderWidth}) solid ${bi((d=(l=(a=e==null?void 0:e.shape)===null||a===void 0?void 0:a.border)===null||l===void 0?void 0:l.color)!==null&&d!==void 0?d:i.borderColor,(v=(u=(f=e==null?void 0:e.shape)===null||f===void 0?void 0:f.border)===null||u===void 0?void 0:u.alpha)!==null&&v!==void 0?v:i.borderAlpha)}`,t.style.borderRadius=`calc(${n.height} * ${(g=(m=e==null?void 0:e.shape)===null||m===void 0?void 0:m.roundCorners)!==null&&g!==void 0?g:i.roundCorners})`},pt=({target:t,layoutParams:e,fallback:i})=>{var n;t.style.transform=`rotate(${(n=-e.angle)!==null&&n!==void 0?n:i.angle}rad)`};class yt{constructor(e){this.control=e}createView(e){var i;const n=document.createElement("div");n.classList.add(`${z}-control-container-${this.control.id}`),e(n,this.control.layoutParams);const r=((i=this.control.layoutParams.innerSizesDependOn)!==null&&i!==void 0?i:K.innerSizesDependOn)==="self"?{height:n.style.height,width:n.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:n,dependsOn:r}}setEvents(e,i){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),i&&i({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${z}-control-container-${this.control.id}`)}}const wi=t=>{if(t.type.trim().toLowerCase()==="area")return new Pn(t)};class Pn extends yt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("button");return s.classList.add(`${z}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",_i({target:s,props:this.control.props,fallback:Object.assign(Object.assign({},K),{backgroundColor:"transparent"})}),Ii({target:s,props:this.control.props,fallback:Object.assign(Object.assign({},K),{borderAlpha:0}),dependsOn:n}),pt({target:s,layoutParams:this.control.layoutParams,fallback:K}),r.append(s),e.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${z}-${this.control.id}`)}}const Si=t=>{if(t.type.trim().toLowerCase()==="button")return new Ln(t)};class Ln extends yt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("button");s.type="button",s.classList.add(`${z}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";const c=document.createElement("span");return c.style.display="inline-block",c.style.whiteSpace="pre",c.style.overflow="hidden",c.style.textOverflow="ellipsis",pt({target:s,layoutParams:this.control.layoutParams,fallback:K}),_i({target:s,props:this.control.props,fallback:K}),Ii({target:s,props:this.control.props,fallback:K,dependsOn:n}),Ei({target:s,props:this.control.props}),Ci({target:c,props:this.control.props,fallback:K,dependsOn:n}),s.append(c),r.append(s),e.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${z}-${this.control.id}`)}}const Nn=t=>{if(t.type.trim().toLowerCase()==="text")return new Mn(t)};class Mn extends yt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("div");s.classList.add(`${z}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";const c=document.createElement("span");return c.style.whiteSpace="pre",pt({target:s,layoutParams:this.control.layoutParams,fallback:K}),Ei({target:s,props:this.control.props}),Ci({target:c,props:this.control.props,fallback:K,dependsOn:n}),s.append(c),r.append(s),e.append(r),this.controlEl=s,r}disable(){}enable(){}getElement(){return document.querySelector(`.${z}-${this.control.id}`)}}class Vn{constructor(e){this.layout=e}}const Fn=t=>{if(t.type.trim().toLowerCase()==="relative")return new Oi(t)};class Oi extends Vn{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,i){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${i.width})`,e.style.height=`calc(var(--interactive-content-height) * ${i.height})`,e.style.left=`calc(var(--interactive-content-width) * ${i.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${i.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}function ee(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(i[n[r]]=t[n[r]]);return i}function N(t,e,i,n){function r(s){return s instanceof i?s:new i(function(c){c(s)})}return new(i||(i=Promise))(function(s,c){function a(f){try{d(n.next(f))}catch(u){c(u)}}function l(f){try{d(n.throw(f))}catch(u){c(u)}}function d(f){f.done?s(f.value):r(f.value).then(a,l)}d((n=n.apply(t,e||[])).next())})}function o(t,e,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function w(t,e,i,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(t,i):r?r.value=i:e.set(t,i),i}var ue,Me,xt;class Ti{constructor(e){ue.add(this),this.container=e,this.factories=new Map,o(this,ue,"m",Me).call(this)}addControlFactory(e,i){this.factories.set(e.trim().toLowerCase(),i),o(this,ue,"m",Me).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),o(this,ue,"m",Me).call(this)}}ue=new WeakSet,Me=function(){this.controls=o(this,ue,"m",xt).call(this)},xt=function(){var e;return(e=this.container.controls)===null||e===void 0?void 0:e.reduce((i,n)=>{const r=n.type.trim().toLowerCase(),s=this.factories.get(r);return s?[...i,s(n)]:[...i]},[])};const ji=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new kn(t,e)};class kn extends Ti{constructor(e,i){super(e),this.rootElement=i!=null?i:gi(),this.layout=new Oi(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Si),this.addControlFactory("text",Nn),this.addControlFactory("area",wi)}createView(e){const i=document.createElement("div");return i.classList.add(`${z}-${this.container.id}`),this.layout.setContainerLayout(i),this.controls.forEach(n=>{const r=n.createView({parent:i,layoutFn:this.layout.setControlLayout});n.setEvents(r,e)}),this.rootElement.append(i),this.isRemoved=!1,i}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}enable(){const e=this.getElement();e&&(this.controls.forEach(i=>i.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){const e=this.getElement();e&&(this.controls.forEach(i=>i.disable()),e.style.opacity=xn,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())===null||e===void 0||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${z}-${this.container.id}`)}}var Ge=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Bn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $e=function(t){return t&&t.Math==Math&&t},te=$e(typeof globalThis=="object"&&globalThis)||$e(typeof window=="object"&&window)||$e(typeof self=="object"&&self)||$e(typeof Ge=="object"&&Ge)||function(){return this}()||Ge||Function("return this")(),ae=function(t){try{return!!t()}catch(e){return!0}},Dn=ae,We=!Dn(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),Wn=We,$i=Function.prototype,Pt=$i.apply,Lt=$i.call,Un=typeof Reflect=="object"&&Reflect.apply||(Wn?Lt.bind(Pt):function(){return Lt.apply(Pt,arguments)}),Ri=We,Ai=Function.prototype,st=Ai.call,Gn=Ri&&Ai.bind.bind(st,st),ye=Ri?Gn:function(t){return function(){return st.apply(t,arguments)}},xi=ye,zn=xi({}.toString),Hn=xi("".slice),Pi=function(t){return Hn(zn(t),8,-1)},qn=Pi,Kn=ye,Li=function(t){if(qn(t)==="Function")return Kn(t)},at=typeof document=="object"&&document.all,Qn=typeof at=="undefined"&&at!==void 0,Ni={all:at,IS_HTMLDDA:Qn},Mi=Ni,Yn=Mi.all,oe=Mi.IS_HTMLDDA?function(t){return typeof t=="function"||t===Yn}:function(t){return typeof t=="function"},Vi={},Xn=ae,we=!Xn(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Zn=We,Re=Function.prototype.call,mt=Zn?Re.bind(Re):function(){return Re.apply(Re,arguments)},Fi={},ki={}.propertyIsEnumerable,Bi=Object.getOwnPropertyDescriptor,Jn=Bi&&!ki.call({1:2},1);Fi.f=Jn?function(e){var i=Bi(this,e);return!!i&&i.enumerable}:ki;var Di=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},er=ye,tr=ae,ir=Pi,ze=Object,nr=er("".split),rr=tr(function(){return!ze("z").propertyIsEnumerable(0)})?function(t){return ir(t)=="String"?nr(t,""):ze(t)}:ze,Wi=function(t){return t==null},sr=Wi,ar=TypeError,Ui=function(t){if(sr(t))throw ar("Can't call method on "+t);return t},or=rr,lr=Ui,cr=function(t){return or(lr(t))},Nt=oe,Gi=Ni,dr=Gi.all,Ue=Gi.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:Nt(t)||t===dr}:function(t){return typeof t=="object"?t!==null:Nt(t)},zi={},He=zi,qe=te,hr=oe,Mt=function(t){return hr(t)?t:void 0},Hi=function(t,e){return arguments.length<2?Mt(He[t])||Mt(qe[t]):He[t]&&He[t][e]||qe[t]&&qe[t][e]},ur=ye,fr=ur({}.isPrototypeOf),vr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",qi=te,Ke=vr,Vt=qi.process,Ft=qi.Deno,kt=Vt&&Vt.versions||Ft&&Ft.version,Bt=kt&&kt.v8,G,ke;Bt&&(G=Bt.split("."),ke=G[0]>0&&G[0]<4?1:+(G[0]+G[1]));!ke&&Ke&&(G=Ke.match(/Edge\/(\d+)/),(!G||G[1]>=74)&&(G=Ke.match(/Chrome\/(\d+)/),G&&(ke=+G[1])));var pr=ke,Dt=pr,yr=ae,mr=te,br=mr.String,Ki=!!Object.getOwnPropertySymbols&&!yr(function(){var t=Symbol();return!br(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Dt&&Dt<41}),gr=Ki,Qi=gr&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Er=Hi,Cr=oe,_r=fr,Ir=Qi,wr=Object,Yi=Ir?function(t){return typeof t=="symbol"}:function(t){var e=Er("Symbol");return Cr(e)&&_r(e.prototype,wr(t))},Sr=String,Or=function(t){try{return Sr(t)}catch(e){return"Object"}},Tr=oe,jr=Or,$r=TypeError,Xi=function(t){if(Tr(t))return t;throw $r(jr(t)+" is not a function")},Rr=Xi,Ar=Wi,xr=function(t,e){var i=t[e];return Ar(i)?void 0:Rr(i)},Qe=mt,Ye=oe,Xe=Ue,Pr=TypeError,Lr=function(t,e){var i,n;if(e==="string"&&Ye(i=t.toString)&&!Xe(n=Qe(i,t))||Ye(i=t.valueOf)&&!Xe(n=Qe(i,t))||e!=="string"&&Ye(i=t.toString)&&!Xe(n=Qe(i,t)))return n;throw Pr("Can't convert object to primitive value")},Zi={exports:{}},Wt=te,Nr=Object.defineProperty,Mr=function(t,e){try{Nr(Wt,t,{value:e,configurable:!0,writable:!0})}catch(i){Wt[t]=e}return e},Vr=te,Fr=Mr,Ut="__core-js_shared__",kr=Vr[Ut]||Fr(Ut,{}),Br=kr,Gt=Br;(Zi.exports=function(t,e){return Gt[t]||(Gt[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Dr=Zi.exports,Wr=Ui,Ur=Object,Ji=function(t){return Ur(Wr(t))},Gr=ye,zr=Ji,Hr=Gr({}.hasOwnProperty),bt=Object.hasOwn||function(e,i){return Hr(zr(e),i)},qr=ye,Kr=0,Qr=Math.random(),Yr=qr(1 .toString),Xr=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Yr(++Kr+Qr,36)},Zr=te,Jr=Dr,zt=bt,es=Xr,ts=Ki,is=Qi,fe=Zr.Symbol,Ze=Jr("wks"),ns=is?fe.for||fe:fe&&fe.withoutSetter||es,rs=function(t){return zt(Ze,t)||(Ze[t]=ts&&zt(fe,t)?fe[t]:ns("Symbol."+t)),Ze[t]},ss=mt,Ht=Ue,qt=Yi,as=xr,os=Lr,ls=rs,cs=TypeError,ds=ls("toPrimitive"),hs=function(t,e){if(!Ht(t)||qt(t))return t;var i=as(t,ds),n;if(i){if(e===void 0&&(e="default"),n=ss(i,t,e),!Ht(n)||qt(n))return n;throw cs("Can't convert object to primitive value")}return e===void 0&&(e="number"),os(t,e)},us=hs,fs=Yi,en=function(t){var e=us(t,"string");return fs(e)?e:e+""},vs=te,Kt=Ue,ot=vs.document,ps=Kt(ot)&&Kt(ot.createElement),ys=function(t){return ps?ot.createElement(t):{}},ms=we,bs=ae,gs=ys,tn=!ms&&!bs(function(){return Object.defineProperty(gs("div"),"a",{get:function(){return 7}}).a!=7}),Es=we,Cs=mt,_s=Fi,Is=Di,ws=cr,Ss=en,Os=bt,Ts=tn,Qt=Object.getOwnPropertyDescriptor;Vi.f=Es?Qt:function(e,i){if(e=ws(e),i=Ss(i),Ts)try{return Qt(e,i)}catch(n){}if(Os(e,i))return Is(!Cs(_s.f,e,i),e[i])};var js=ae,$s=oe,Rs=/#|\.prototype\./,Se=function(t,e){var i=xs[As(t)];return i==Ls?!0:i==Ps?!1:$s(e)?js(e):!!e},As=Se.normalize=function(t){return String(t).replace(Rs,".").toLowerCase()},xs=Se.data={},Ps=Se.NATIVE="N",Ls=Se.POLYFILL="P",Ns=Se,Yt=Li,Ms=Xi,Vs=We,Fs=Yt(Yt.bind),ks=function(t,e){return Ms(t),e===void 0?t:Vs?Fs(t,e):function(){return t.apply(e,arguments)}},nn={},Bs=we,Ds=ae,Ws=Bs&&Ds(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Us=Ue,Gs=String,zs=TypeError,Hs=function(t){if(Us(t))return t;throw zs(Gs(t)+" is not an object")},qs=we,Ks=tn,Qs=Ws,Ae=Hs,Xt=en,Ys=TypeError,Je=Object.defineProperty,Xs=Object.getOwnPropertyDescriptor,et="enumerable",tt="configurable",it="writable";nn.f=qs?Qs?function(e,i,n){if(Ae(e),i=Xt(i),Ae(n),typeof e=="function"&&i==="prototype"&&"value"in n&&it in n&&!n[it]){var r=Xs(e,i);r&&r[it]&&(e[i]=n.value,n={configurable:tt in n?n[tt]:r[tt],enumerable:et in n?n[et]:r[et],writable:!1})}return Je(e,i,n)}:Je:function(e,i,n){if(Ae(e),i=Xt(i),Ae(n),Ks)try{return Je(e,i,n)}catch(r){}if("get"in n||"set"in n)throw Ys("Accessors not supported");return"value"in n&&(e[i]=n.value),e};var Zs=we,Js=nn,ea=Di,ta=Zs?function(t,e,i){return Js.f(t,e,ea(1,i))}:function(t,e,i){return t[e]=i,t},xe=te,ia=Un,na=Li,ra=oe,sa=Vi.f,aa=Ns,de=zi,oa=ks,he=ta,Zt=bt,la=function(t){var e=function(i,n,r){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(i);case 2:return new t(i,n)}return new t(i,n,r)}return ia(t,this,arguments)};return e.prototype=t.prototype,e},ca=function(t,e){var i=t.target,n=t.global,r=t.stat,s=t.proto,c=n?xe:r?xe[i]:(xe[i]||{}).prototype,a=n?de:de[i]||he(de,i,{})[i],l=a.prototype,d,f,u,v,m,g,I,h,y;for(v in e)d=aa(n?v:i+(r?".":"#")+v,t.forced),f=!d&&c&&Zt(c,v),g=a[v],f&&(t.dontCallGetSet?(y=sa(c,v),I=y&&y.value):I=c[v]),m=f&&I?I:e[v],!(f&&typeof g==typeof m)&&(t.bind&&f?h=oa(m,xe):t.wrap&&f?h=la(m):s&&ra(m)?h=na(m):h=m,(t.sham||m&&m.sham||g&&g.sham)&&he(h,"sham",!0),he(a,v,h),s&&(u=i+"Prototype",Zt(de,u)||he(de,u,{}),he(de[u],v,m),t.real&&l&&(d||!l[v])&&he(l,v,m)))},da=Math.ceil,ha=Math.floor,ua=Math.trunc||function(e){var i=+e;return(i>0?ha:da)(i)},fa=ua,rn=function(t){var e=+t;return e!==e||e===0?0:fa(e)},va=rn,pa=Math.min,ya=function(t){return t>0?pa(va(t),9007199254740991):0},ma=ya,ba=function(t){return ma(t.length)},ga=ca,Ea=Ji,Ca=ba,_a=rn;ga({target:"Array",proto:!0},{at:function(e){var i=Ea(this),n=Ca(i),r=_a(e),s=r>=0?r:n+r;return s<0||s>=n?void 0:i[s]}});var Ia=Hi,wa=Ia,Sa=wa,Oa=Sa("Array","at"),Ta=Oa,ja=Ta,$a=ja,Ra=$a,sn=Bn(Ra);function an(t,e){let i;return(...n)=>{clearTimeout(i),i=setTimeout(()=>t(...n),e)}}const Oe={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},me=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,gt=t=>me(t,Oe.Object),lt=t=>me(t,Oe.String),Et=t=>me(t,Oe.Array),on=t=>me(t,Oe.Number),Aa=t=>me(t,Oe.Function),Jt=t=>on(t)&&!isNaN(t),Ce=t=>gt(t)&&Object.keys(t).length===0,Ct=t=>Et(t)&&!t.length,Pe=(t,e)=>lt(t)&&(e?t.trim():t).length,ln=window.navigator.userAgent.toLowerCase(),xa=/mobi/i.test(ln);ln.indexOf("android")>-1;const Pa="video_interactive",La="videoint",Na=250;class Ma{constructor(e){this.onResize=i=>{this.isReady&&(!i[0].contentRect.width||!i[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:i[0].contentRect.width,height:i[0].contentRect.height}))},this.handleChapterChange=i=>{var n;if(this.isReady){if(this.isHidden||this.hide(),!(i!=null&&i.id)){(n=this.onError)===null||n===void 0||n.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(i.id),this.ngEditor.selectChapter(i.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=i.id,this.lastZoomInfo=void 0}},this.handleManifestChange=(i,n=[])=>N(this,void 0,void 0,function*(){var r;if(!on(i.graph.edit.chapters[0].x)){this.isReady=!1,(r=this.onError)===null||r===void 0||r.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let s;try{s=yield L.loadVKLangPack(this.lang,Pa,La)}catch(a){console.log("Unable to load graph language pack")}const{GraphEditor:c}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new c(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:s}),this.ngEditor.on("control",({name:a,chapterId:l})=>{a==="openPreview"&&this.onOpenPreviewClick(l)}),this.ngEditor.on("zoomEnd",a=>{this.lastZoomInfo=Object.assign({},a)})}this.visitedChapterIds=new Set(n),i.metadata.id!==this.currentManifestId?(this.ngEditor.update(i),this.currentManifestId=i.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}),this.init(e)}init({root:e,onOpenPreviewClick:i,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=i,this.onError=n,this.lang=r!=null?r:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=Va(e),this.resizeObserver=new ResizeObserver(an(this.onResize,Na)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(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)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,i;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)===null||e===void 0||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(i=this.ngEditor)===null||i===void 0||i.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function Va(t){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",t.append(e),e}const Ie=(t="",e="")=>{t=t.split("."),e=e.split(".");let i=0;for(let n=0;n<Math.max(t.length,e.length)&&!i;n++)t[n]>e[n]?i=1:t[n]<e[n]?i=-1:i=0;return i},Fa="3.1",ei={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},ka={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ba=t=>{const e=[];for(const i of t.chapters){let n;const r=[];for(let a of i.branches){const{isDefault:l}=a,d=ee(a,["isDefault"]);l&&(n=d.id),r.push(d)}let s=[];const c=[];for(let a of i.containers){const{fallbackStrategy:l}=a,d=ee(a,["fallbackStrategy"]),f=!!d.endTime;let u=[ka];switch(l){case"await":f?u=[]:s=[];break;case"default":{const v={type:"onSuspense",action:{type:ei.default,args:{branchId:n,shouldOpenNow:!f,isDetachContainer:!0}}};f?u=[v]:s=[v];break}case"random":case"weightlessRandom":case"max":case"min":{const v={type:"onSuspense",action:{type:ei[l],args:{}}};f?u=[v]:s=[v];break}}for(const v of d.controls)c.push(Object.assign(Object.assign({},d),{controls:[Object.assign({},v)],id:jn.v4(),events:u}))}e.push(Object.assign(Object.assign({},i),{containers:c,events:s,branches:r}))}return t.metadata.version=Fa,t.metadata.updated=new Date().toISOString(),Object.assign(Object.assign({},t),{chapters:e})},Da="3.2",Wa=t=>{if(!t.media){const e=t.metadata,{media:i}=e,n=ee(e,["media"]);return Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},n),{version:Da}),media:i})}return t},Ua="3.3",Ga=(t=[])=>({edit:{chapters:t},view:{}}),ti={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},za=t=>{var e;const i=[],n=[];for(const r of t.chapters){const{id:s,x:c,y:a}=r,l=ee(r,["id","x","y"]),d=l.containers.map(f=>{var u;return Object.assign(Object.assign({},f),{controls:f.controls.map(v=>{var{subtype:m,type:g}=v,I=ee(v,["subtype","type"]);return Object.assign(Object.assign({},I),{type:m!=null?m:g})}),events:!((u=f.events)===null||u===void 0)&&u.length?f.events:[ti]})});i.push(Object.assign(Object.assign({id:s},l),{containers:d,events:!((e=l.events)===null||e===void 0)&&e.length?l.events:[ti]})),n.push({id:s,x:c,y:a})}return Object.assign(Object.assign({},t),{chapters:i,graph:Ga(n),metadata:Object.assign(Object.assign({},t.metadata),{version:Ua})})},Ha=[{version:"3.0",migrate:Ba},{version:"3.1",migrate:Wa},{version:"3.2",migrate:za}],qa=t=>Ha.reduce((e,i)=>Ie(e.metadata.version,i.version)?e:i.migrate(e),t),Ka=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),R=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});exports.INTERACTIVE_CLICK_ACTIONS=void 0;(function(t){t.GO_NEXT_BUTTON="GO_NEXT_BUTTON",t.GO_NEXT_AREA="GO_NEXT_AREA",t.WATCH_AGAIN="WATCH_AGAIN",t.OPEN_GRAPH="OPEN_GRAPH",t.CLOSE_GRAPH="CLOSE_GRAPH"})(exports.INTERACTIVE_CLICK_ACTIONS||(exports.INTERACTIVE_CLICK_ACTIONS={}));const ii={metadata:"Object",chapters:"Array"},Qa="3.0.0",Ya="3.3.0",_t=t=>{const e=Ie(t,Qa);return e===-1?!1:e===0?!0:Ie(t,Ya)!==1},Xa=t=>{if(!gt(t))return!1;for(const e in ii)if(!t[e]||!me(t[e],ii[e]))return!1;return _t(t.metadata.version)},cn=t=>t.type===Ka.Text;class ${constructor(e,i,...n){this.severity=e,this.category=i,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}}$.Severity={RECOVERABLE:1,CRITICAL:2};$.Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6};class dn{constructor(){this.listeners={}}addListener(e,i){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(i),this}on(e,i){return this.addListener(e,i)}once(e,i){this.listeners[e]=this.listeners[e]||[];const n=()=>{i(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,i){return this.removeListener(e,i)}reset(){this.listeners={}}removeListener(e,i){const n=this.listeners[e];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===i){n.splice(r,1);break}return this}emit(e,...i){const n=this.listeners[e];return n?(n.forEach(r=>{r(...i)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Za{constructor(e){this.addFn=(i,n=!1)=>{Aa(i)&&(this.fns.push(i),n&&this.updateFn())},this.removeFn=(i,n=!1)=>{this.fns=this.fns.filter(r=>r!==i),n&&this.updateFn()},this.updateFn=()=>{this.fn=()=>{this.fns.forEach(i=>i()),this.raf&&this.forceRequestAnimation()}},this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))},this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()},this.cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0},this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Ja{constructor(e){var i,n;this.loaders={chapterLoaders:(i=e==null?void 0:e.chapterLoaders)!==null&&i!==void 0?i:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!==null&&n!==void 0?n:[]}}exec(e,i){return N(this,void 0,void 0,function*(){return eo(...this.loaders[e])(i)})}}function eo(...t){return function(i){return N(this,void 0,void 0,function*(){const n=[...t];for(;n.length>0;)i=yield n.shift()(i);return i})}}function Be(t,e,i){return t?Object.assign(Object.assign({},t),{[e]:t[e]?[i,...t[e]]:[i]}):{[e]:[i]}}function ct(t){var{actions:e,errors:i,chapterId:n}=t,r=ee(t,["actions","errors","chapterId"]);if(n){const s=e.getManifest(),c=e.getChapter(s.chapters,n);if(c){const a=e.getMedia(s.media,c.videoId),l=e.getGraph(s.graph,c.id);return a?Object.assign(Object.assign({},r),{actions:e,errors:i,result:{chapter:c,media:a,graph:l}}):Object.assign(Object.assign({},r),{errors:Be(i,ct.name,"Could not find media"),actions:e})}}return Object.assign(Object.assign({},r),{errors:Be(i,ct.name,"Could not find chapter"),actions:e})}class ni{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,i,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:i,options:n})}removeEventListener(e,i){if(!(e in this.listeners))return;const n=this.listeners[e];for(let r=0,s=n.length;r<s;r++)if(n[r].callback===i){n.splice(r,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const n=this.listeners[e.type].slice();for(let r=0,s=n.length;r<s;r++){const c=n[r];try{c.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}}class hn extends ni{constructor(){super(),this.listeners||ni.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)}}class to{constructor(){Object.defineProperty(this,"signal",{value:new hn,writable:!0,configurable:!0})}abort(e){let i;try{i=new Event("abort")}catch(r){typeof document!="undefined"?document.createEvent?(i=document.createEvent("Event"),i.initEvent("abort",!1,!1)):(i=document.createEventObject(),i.type="abort"):i={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(r){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(to.prototype[Symbol.toStringTag]="AbortController",hn.prototype[Symbol.toStringTag]="AbortSignal");function un(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function io(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:i=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!un({fetch:e,Request:i,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:s};let s=i;(s&&!s.prototype.hasOwnProperty("signal")||r)&&(s=function(d,f){let u;f&&f.signal&&(u=f.signal,delete f.signal);const v=new i(d,f);return u&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:u}),v},s.prototype=i.prototype);const c=e;return{fetch:(l,d)=>{const f=s&&s.prototype.isPrototypeOf(l)?l.signal:d?d.signal:void 0;if(f){let u;try{u=new DOMException("Aborted","AbortError")}catch(m){u=new Error("Aborted"),u.name="AbortError"}if(f.aborted)return Promise.reject(u);const v=new Promise((m,g)=>{f.addEventListener("abort",()=>g(u),{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([v,c(l,d)])}return c(l,d)},Request:s}}const It=un({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),fn=It?io({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ri=It?fn.fetch:window.fetch;It?fn.Request:window.Request;const no=t=>N(void 0,void 0,void 0,function*(){try{let e,i;if(gt(t))e=t;else if(lt(t)){i=new URL(t).href;const r=yield ri(i);if(!r.ok)return{};e=yield r.json()}else return{};if(!Xa(e))return{};const n=e.metadata.media;if(lt(n)&&!e.media)try{let r;i?r=new URL(n,i).href:(r=new URL(n).href,i=r);const s=yield ri(r);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(r){return oo(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:i}}catch(e){return{}}});function ro(t){return N(this,void 0,void 0,function*(){const{manifest:e,manifestURL:i}=yield no(t),n=qa(e);return n.media=so(n.media,i),delete n.metadata.media,n})}function nt(t,e){return t.find(i=>i.id===e)}function si(t,e){var i,n;return!((i=t.edit)===null||i===void 0)&&i.chapters?t.edit.chapters.find(r=>r.id===e):!((n=t.view)===null||n===void 0)&&n.chapters?t.view.chapters.find(r=>r.id===e):void 0}function ai(t,e){return t.videos.find(i=>i.id===e)}function so(t,e){return Object.assign(Object.assign({},t),{videos:t.videos.map(i=>Object.assign(Object.assign({},i),{variants:i.variants.map(n=>{const r=ao(n.url,e);return Object.assign(Object.assign({},n),{url:r||n.url})})}))})}function ao(t,e){try{return new URL(t,e).href}catch(i){return""}}function oo(t){return Ie(t,"3.2.0")>=0}const A=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),wt=t=>Et(t)&&!Ct(t),St=t=>Ct(t.branches)||t.order==="end",lo=t=>Et(t.branches)&&!Ct(t.branches),co=(t,e)=>{var i;const n=t*1e3;return wt(e.controls)&&n<((i=e.startTime)!==null&&i!==void 0?i:0)},oi=(t,e)=>{var i,n;const r=t*1e3;return wt(e.controls)&&r>=((i=e.startTime)!==null&&i!==void 0?i:0)&&r<=((n=e.endTime)!==null&&n!==void 0?n:1/0)},De=t=>t.some(e=>e.action.type==="expect"),li=t=>t.find(e=>e.action.type==="expect"),ho=t=>(t==null?void 0:t.length)===1,vn=t=>ho(t)&&cn(t[0]),uo=({fn:t,type:e=1},...i)=>(...n)=>e?t(...n,...i):t(Object.assign(Object.assign({},n[e]),i[e])),fo=(t=[])=>t.reduce((e,i,n)=>{var r,s,c;const a=((r=i==null?void 0:i.controls)!==null&&r!==void 0?r:[]).filter(l=>!cn(l));if(wt(a)){const l=[(s=i.startTime)!==null&&s!==void 0?s:0,(c=i.endTime)!==null&&c!==void 0?c:1/0],d=i.id;if(!n)e.push({subjects:[d],range:l});else{const f=[];let u=-1/0,v=1/0,m=[];const g=[];for(let I=0;I<e.length;I++){const h=e[I];if(g.push(...h.subjects),h.range[0]<v&&(v=h.range[0]),h.range[1]>u&&(u=h.range[1]),h.range[0]<=l[0]&&h.range[1]>=l[1])return e[I].subjects.push(d),e;l[0]>=h.range[0]&&l[0]<=h.range[1]&&(f.push(I),m=m.concat(h.subjects),l[0]=h.range[0]),l[1]>=h.range[0]&&l[1]<=h.range[1]&&(f.push(I),m=m.concat(h.subjects),l[1]=h.range[1])}if(g.push(d),l[0]<=v&&l[1]>=u)return[{subjects:g,range:l}];f.length&&f.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:m.concat([d]),range:l})}}return e},[]).sort((e,i)=>e.range[0]-i.range[0]),vo=(t,e)=>De(t.events)?!1:e.some(({container:i})=>i.container.id!==t.id&&De(i.container.events)&&i.container.endTime===t.endTime&&!i.isRemoved);class pn extends Ja{constructor(e,i){super(e),this.onError=i,this.prevChapter$=new L.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(e){var i;return N(this,void 0,void 0,function*(){this.release();const n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Be},result:null,errors:null,source:e});n.errors&&this.errorHandler(n.errors);const r=yield ro((i=n.result)!==null&&i!==void 0?i:e);return this.manifest=r,this})}setInitial(){return N(this,void 0,void 0,function*(){return this.setNext()})}setNext(e=this.manifest.metadata.initChapterId){return N(this,void 0,void 0,function*(){this.prevChapter$.next(this.chapter);const i=yield this.exec("chapterLoaders",ct({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:si,getChapter:nt,getMedia:ai,getByBranches:this.getByBranches.bind(this),addErrorMessage:Be},result:null,errors:null,chapterId:e}));return i.errors&&this.errorHandler(i.errors),this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.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){const i=nt(this.manifest.chapters,e);if(i){const n=ai(this.manifest.media,i.videoId),r=si(this.manifest.graph,i.id);if(n)return{chapter:i,media:n,graph:r}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const i=nt(this.manifest.chapters,e);return this.getByBranches(i==null?void 0:i.branches)}}getByBranches(e=[]){return e.reduce((i,n)=>{const r=this.getByChapterId(n.chapterId);return r&&i.push(r),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return St(this.chapter)}}const C={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},dt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},x={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function po(){const t=new Map;function e(r){var{listId:s=Math.random().toString(),itemId:c=Math.random().toString()}=r,a=ee(r,["listId","itemId"]);const l=t.get(s),d=Object.assign({},a);return l?l[c]=d:t.set(s,{[c]:d}),Object.assign({listId:s,itemId:c},a)}function i(r,s){var c,a,l;const d=t.get(r);if(d){if(s)return(c=d[s])===null||c===void 0||c.player.destroy(),(a=d[s])===null||a===void 0||a.container.remove(),(l=d[s])===null||l===void 0||l.subscription.unsubscribe(),delete d[s],Object.keys(d).length||t.delete(r),!0;for(const f of Object.values(d))f.player.destroy(),f.container.remove();return t.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(const r of t)i(r[0])}return{createPlayer:e,removePlayer:i,map:t,removeAll:n}}function ci(t,e=[]){var i,n,r;let s={},c;const a=!e.length;for(const l of t.variants)if(!c&&"cover"in l&&(c=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(a||e.includes("mp4"))&&(s.MPEG=Object.assign(Object.assign({},s.MPEG),{[(i=l.standard)!==null&&i!==void 0?i:"Invariant quality"]:l.url}));break;case"mpeg":(a||e.includes("mpeg"))&&(s.MPEG=Object.assign(Object.assign({},s.MPEG),{[(n=l.standard)!==null&&n!==void 0?n:"Invariant quality"]:l.url}));break;case"hls":(a||e.includes("hls"))&&(s=Object.assign(Object.assign({},s),{HLS:{type:"url",url:l.url}}));break;case"dash":(a||e.includes("dash"))&&(s=Object.assign(Object.assign({},s),{DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}}));break}return{sources:s,thumbUrl:c,title:(r=t.title)!==null&&r!==void 0?r:""}}const Le=(t,e)=>{const i=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();i!==e&&n.includes(e)&&(t.setQuality(e),t.setAutoQuality(!1))},yo=t=>{const e=t.variants.find(i=>{var n;return((n=i.payload)===null||n===void 0?void 0:n.type)==="vk"});if(e&&"payload"in e){const[i,n]=e.payload.id.split("_");return[i,n]}return[]},Ve={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},mo=2;function bo(t){const e=po();let i,n;const r=new dn;let s={},c=!1,a=null,l=!1,d;t&&f(t);function f(p){a=p}function u(p,E,b){var S;if(!a)throw Error("need to set interactive controller");const P=((S=e.map.get(p))!==null&&S!==void 0?S:{})[E];if(P){s=Object.assign({chapterId:b,listId:p,itemId:E},P);const _=s.player;n=_.info.currentQuality$.subscribe(k=>{if(!(!k||!_.info.position$.getValue())){i=k;for(const W of e.map)Object.values(W[1]).forEach(({player:M})=>{_.info.isAutoQualityEnabled$.getValue()||Le(M,k)})}}),P.container.remove(),c=!1,a.setPlayer(P.player),l||(a.init(),l=!0),r.emit(Ve.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function v(p,E,b){return N(this,void 0,void 0,function*(){if(!a)throw Error("need to set interactive controller");if(Ce(s)||p!==s.itemId)return;if(b>=0&&!c){const T=a.getChapterBranches();c=!0;const P=new Set;for(const _ of T)P.has(_.media.id)||(yield g({media:_.media,chapterId:_.chapter.id,setAsActive:!1,title:_.chapter.label}),P.add(_.media.id))}})}function m({chapter:{id:p},media:E}){return N(this,void 0,void 0,function*(){if(Ce(s))return;n==null||n.unsubscribe();const b=s.player.info.muted$.getValue(),S=s.player.info.currentQuality$.getValue(),T=s.player.info.isAutoQualityEnabled$.getValue(),P=s.player.info.volume$.getValue(),_=s.player.info.currentPlaybackRate$.getValue(),k=!T;let W=!1;for(const M of e.map)if(M[0]===E.id){const H=Object.keys(M[1]);for(const Q of H)Q===s.itemId?(H.length<mo||(W=!0),e.removePlayer(M[0],Q)):(W=!0,u(M[0],Q,p),k?Le(s.player,S):s.player.setAutoQuality(!0),s.player.setVolume(P),s.player.setMuted(b),s.player.setPlaybackRate(_))}else e.removePlayer(M[0]);W||(yield g({media:E,chapterId:p,setAsActive:!0,playbackRate:_}),k?Le(s.player,S):s.player.setAutoQuality(!0),s.player.setVolume(P),s.player.setMuted(b))})}function g({media:p,chapterId:E,prefetch:b=!0,setAsActive:S=!0,autoplay:T=!1,preferredExt:P,title:_,playbackRate:k}){var W,M,H;return N(this,void 0,void 0,function*(){const Q=Math.random().toString(),le=document.createElement("div");d.append(le);const gn=(W=s==null?void 0:s.player)===null||W===void 0?void 0:W.info.isAutoQualityEnabled$.getValue();let Te;if(!((M=a==null?void 0:a.options)===null||M===void 0)&&M.vkVideoLoader){const je=yo(p);je.length&&(Te=yield a.options.vkVideoLoader(...je))}const Ot=Object.assign(Object.assign({container:le},((H=Te==null?void 0:Te.videos)===null||H===void 0?void 0:H[0])||{sources:ci(p,P).sources}),{title:_}),ie=new $n.Player;ie.initVideo(Ot);const En=le.lastChild,Tt=new L.Subscription;Tt.add(ie.info.position$.subscribe(function(je){v(Q,ie.info.duration$.getValue(),je)})).add(ie.events.canplay$.subscribe(function(){gn||Le(ie,i),k&&ie.setPlaybackRate(k)})),En&&(le.style.display="none",le.classList.add(E));const ce=e.createPlayer({listId:p.id,itemId:Q,player:ie,container:le,sources:ci(p,P).sources,config:Ot,subscription:Tt});return S&&u(p.id,ce.itemId,E),T&&ce.player.play(),b&&!T&&ce.player.prepare(),r.emit(Ve.playerCreated,ce.player),{player:ce.player,config:ce.config}})}function I(){h(),a=null}function h(){a==null||a.off(C.chapterChanged,m),e.removeAll(),s={},l=!1,c=!1}function y({source:p,initialChapter:E,container:b}){return N(this,void 0,void 0,function*(){if(!a)throw Error("need to set interactive controller");yield a.setManifest(p),h(),d=b;const{media:S,chapter:T}=yield a.setChapter({chapterId:E});if(S){a.on(C.chapterChanged,m);const{player:P,config:_}=yield g({media:S,chapterId:T.id,title:T.label});return r.emit(Ve.initiated,{container:b,media:S,chapterId:T.id}),{player:P,config:_}}else console.error("not found")})}return Object.assign(Object.assign({},e),{on:r.on.bind(r),off:r.off.bind(r),init:y,setInteractiveController:f,createPlayer:g,removeAll:I,getActivePlayer:function(){return s}})}const go=3e3,Eo=()=>{let t=[],e=null;return{setPlayer:c=>{e=c},setContainers:c=>{t=c},deleteContainer:c=>{t=t.filter(a=>a.id!==c)},getNextInteractiveTime:(c=go)=>{if(!t.length||e===null)return null;let a=-1,l=!1;const d=Math.round(e.info.position$.getValue()*1e3);for(const f of t){const u=f.startTime-c;if(u<=d&&(d<=f.endTime||f.endTime===null)){l=!0;break}d<u&&(a=a===-1?u:Math.min(a,u))}return!l&&a!==-1?a:null}}},pe=Eo();class Co{constructor({player:e,container:i,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:c,ignoreContainerEvent:a,permanentTextControls:l,disabledControls:d}){this.hide=()=>{setTimeout(()=>{var f,u,v,m;this.gameState!==A.end&&(De(this.container.container.events)&&this.gameState===A.afterInteractive||this.selectBranches.state.isExpect||(this.gameState===A.interactive?this.disabledControls||(u=(f=this.container).disable)===null||u===void 0||u.call(f):(m=(v=this.container).hide)===null||m===void 0||m.call(v),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})))})},this.show=()=>{var f,u,v,m;if(this.gameState===A.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(u=(f=this.container).show)===null||u===void 0||u.call(f),this.disabledControls||(m=(v=this.container).enable)===null||m===void 0||m.call(v),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!0,isFirst:!1});else{const I=uo({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})},onEvent:(h,y)=>{this.isSelectedControlEvent=!0,h!==!1&&(this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})),(this.gameState===A.end||this.gameState===A.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),y(),this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})),pe.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===A.end});this.container.createView(I),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!0,isFirst:!0})}},this.onEndOfVideo=()=>{this.gameState=A.end,this.selectContainerEvent(!0)},this.whilePlaying=()=>{var f,u,v,m;if(((f=this.player.experimental.element$.getValue())===null||f===void 0?void 0:f.readyState)<1||[A.destroyed,A.removed].includes(this.gameState)&&!this.isPermanentText)return;const I=this.player.getExactTime();if(co(I,this.container.container))this.gameState!==A.beforeInteractive&&(this.gameState=A.beforeInteractive,this.onBeforeStartTime());else if(oi(I,this.container.container))this.gameState!==A.interactive&&(this.gameState=A.interactive,this.onStartTime());else if(this.gameState!==A.afterInteractive){const p=this.gameState;this.gameState=A.afterInteractive,p===A.interactive&&this.onEndTime()}else this.gameState!==A.destroyed&&this.removeView();const h=oi(I,this.container.container),y=this.container.container.startTime?[this.container.container.startTime,(u=this.container.container.endTime)!==null&&u!==void 0?u:1/0]:[];(m=(v=this.container).onProgress)===null||m===void 0||m.call(v,I,h),this.globalEventEmitter.emit(C.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:y,currentTime:I,isInteractiveTime:h})},this.container=i,this.branches=n,this.selectBranches=r,this.subscription=new L.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=l&&vn(i.container.controls),this.disabledControls=d,this.globalEventEmitter=c,this.gameState=A.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)),this.disabledControls&&this.subscription.add(this.disabledControls.subscribe(e=>{var i,n,r,s;e?(n=(i=this.container).disable)===null||n===void 0||n.call(i):(s=(r=this.container).enable)===null||s===void 0||s.call(r)}))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=De(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,i;(i=(e=this.container).hide)===null||i===void 0||i.call(e),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=A.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.containerRemoved,visibility:!1}),this.gameState=A.removed}destroy(){var e;this.reset(),this.removeView(),this.gameState=A.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!==null&&e!==void 0?e:1/0,id:this.container.container.id}),pe.deleteContainer(this.container.container.id)}}function _o(){const t={};function e(){for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&delete t[a];return!0}function i(a){const l={};for(const d in t)+d<=a&&(l[d]=t[d]);return l}function n(a){const l={};for(const d in t)+d>=a&&(l[d]=t[d]);return l}function r({timestamp:a,priority:l,initiator:d}){var f;if(Jt(a)){const u=(f=t[a])!==null&&f!==void 0?f:null;if(u&&Pe(l,!0)){let v={};const m=u[l];if(m&&(v=Object.assign(Object.assign({},v),m)),v=Ce(v)?null:v,v&&Pe(d,!0)){const g=v[d];return g!=null?g:null}return v}return u}return null}function s({timestamp:a,priority:l,initiator:d}){if(Jt(a))if(t[a]){if(Pe(l,!0))if(t[a][l]){if(Pe(d,!0))if(t[a][l][d]){if(delete t[a][l][d],!Ce(t[a][l]))return!0}else return!1;if(delete t[a][l],!Ce(t[a]))return!0}else return!1;return delete t[a]}else return!1}function c(a){var l,d,f,{timestamp:u,priority:v,initiator:m}=a,g=ee(a,["timestamp","priority","initiator"]);!((d=(l=t[u])===null||l===void 0?void 0:l[v])===null||d===void 0)&&d[m]?t[u][v][m].push(Object.assign({},g)):!((f=t[u])===null||f===void 0)&&f[v]?t[u][v]=Object.assign(Object.assign({},t[u][v]),{[m]:[Object.assign({},g)]}):t[u]?t[u]=Object.assign(Object.assign({},t[u]),{[v]:{[m]:[Object.assign({},g)]}}):t[u]={[v]:{[m]:[Object.assign({},g)]}}}return{map:t,remove:s,add:c,removeAll:e,get:r,getLte:i,getGte:n}}const Io=[R.expect,R.setNextBranch],wo=1/0;function di(t){let e=t,i;const n=So(),r=new _o;let s;const c=()=>{u(),I()},a=h=>{r.add.call(void 0,h),v()},l=(h=[])=>{for(const y of h)if(y.action(),Io.includes(y.actionType))break},d=h=>{var y,p,E;if(!n.isReady(h))return;const b=Ne((y=r.get({timestamp:h,priority:"control"}))!==null&&y!==void 0?y:{}),S=Ne((p=r.get({timestamp:h,priority:"container"}))!==null&&p!==void 0?p:{}),T=Ne((E=r.get({timestamp:h,priority:"chapter"}))!==null&&E!==void 0?E:{});l([...b,...S,...T])},f=()=>{var h;l([...Ne((h=r.get({timestamp:1/0,priority:"chapter"}))!==null&&h!==void 0?h:{})])},u=()=>{i&&(s==null||s.unsubscribe(),i=void 0)},v=()=>{i||(i=()=>setTimeout(()=>{d(1/0)}),s=e.events.ended$.subscribe(i))},m=h=>{u(),e=h},g=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),r.remove(h)},I=()=>{n.release(),r.removeAll()};return{setPlayer:m,add:a,remove:g,exec:d,execEndOfVideo:f,listen:v,unlisten:u,release:c,containersEventsCallState:n}}function So(){const t=new Map;return{setCalled:({timestamp:c,id:a})=>{const l=t.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a,l;for(const d of c){const f=(a=d.endTime)!==null&&a!==void 0?a:wo,u=(l=t.get(f))!==null&&l!==void 0?l:{};t.set(f,Object.assign(Object.assign({},u),{[d.id]:!1}))}},resetCalled:c=>{const a=t.get(c);if(a)for(const l in a)a[l]=!1},isReady:c=>{const a=t.get(c);return a?!Object.values(a).some(l=>!l):!0},release:()=>t.clear()}}function Ne(t){return Object.values(t).flat().sort(e=>e.actionType===R.expect?-1:1)}const Oo=(t,e)=>{const{height:i,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(i&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:r,clientWidth:s}=e.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};const c=i/n,a=r/s;let l,d;return a>c?(d=s,l=s*c):a<c?(d=r/c,l=r):(d=s,l=r),{videoContentWidth:d,videoContentHeight:l}},To=250;function jo(t){let e=()=>{};const i=new ResizeObserver(a=>{s(a),e=s.bind(null,a)});function n(a){const{parentElement:l,player:d}=t();if(l&&d){const{videoContentWidth:f,videoContentHeight:u}=Oo(l,d);l.style.setProperty("--interactive-content-width",`${f}px`),l.style.setProperty("--interactive-content-height",`${u}px`),l.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function r(){const{parentElement:a}=t();a.removeAttribute("style")}const s=an(a=>{const{fns:l=[]}=t();n(a);for(const d of l)d()},To);function c(){e=void 0,i.disconnect(),r()}return{resizeObserver:i,calc:()=>{e()},release:c}}class $o{constructor(){this.map={}}push(e,i){e in this.map?this.map[e].push(i):this.map[e]=[i]}get(e){const i=this.map[e];return i?i.slice():null}getAll(){const e=[];for(const i in this.map)e.push(...this.map[i]);return e}remove(e,i){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==i),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const Ro=t=>Math.floor(Math.random()*t),Ao=t=>{let e=t.length,i=1/0,n=null;for(;e--;)t[e].weight<i&&(i=t[e].weight,n=t[e]);return n},xo=t=>{let e=t.length,i=-1/0,n=null;for(;e--;)t[e].weight>i&&(i=t[e].weight,n=t[e]);return n},Po=t=>{const e=t.length,i=Ro(e);return t[i]},hi=1,Lo=t=>{var e,i;let n=0;for(let s=0;s<t.length;++s)n+=(e=t[s].weight)!==null&&e!==void 0?e:hi;const r=Math.random()*n;n=0;for(let s=0;s<t.length-1;++s)if(n+=(i=t[s].weight)!==null&&i!==void 0?i:hi,n>=r)return t[s];return t[t.length-1]},ui=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),rt=(t,e=!1)=>Object.assign(Object.assign({},t),{args:e?Object.assign(Object.assign({},t.args),ui):Object.assign(Object.assign({},ui),t.args)}),fi=({globalEventEmitter:t,player:e,interactiveEvents:i,removeControllers:n})=>{const r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},c=({action:h,controlType:y,controlId:p,containerId:E,branches:b=[],onEvent:S,isEOV:T=()=>!1,isDisabled:P=()=>!1})=>{const _=rt(h,T()),k={timestamp:1/0,priority:"control",initiator:p,actionType:_.type},W=P(),M=t.emit.bind(t,C.interactives,{subjectId:p,subjectType:y,subjectName:"control",type:W?x.actionChoiceCanceled:x.actionChoice,actionType:h.type,payload:Object.assign({containerId:E},_.args)});if(W){M();return}switch(_.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{const H=b.find(Q=>Q.id===_.args.branchId);if(!H)return;S(_.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),M(),_.args.shouldOpenNow?g({subjectId:p,subjectName:"control",subjectType:y,action:_,payload:{chapterId:H.chapterId,autoSelect:!1}}):(i.add(Object.assign(Object.assign({},k),{action:g.bind(null,{subjectId:p,subjectName:"control",subjectType:y,action:_,payload:{chapterId:H.chapterId,autoSelect:!1}})})),n==null||n());return}case R.continuePlayback.trim().toLowerCase():{S(_.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),M(),_.args.shouldOpenNow?m({subjectId:p,subjectName:"control",subjectType:y,action:h}):i.add(Object.assign(Object.assign({},k),{action:m.bind(null,{subjectId:p,subjectName:"control",subjectType:y,action:h})}));return}case R.openURI.trim().toLowerCase():{S(_.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),M(),_.args.shouldOpenNow?I({subjectId:p,subjectName:"control",subjectType:y,action:_,payload:{URI:h.args.uri}}):(i.add(Object.assign(Object.assign({},k),{action:I.bind(null,{subjectId:p,subjectName:"control",subjectType:y,action:_,payload:{URI:h.args.uri}})})),n==null||n());return}default:console.error("Unexpected control event"),t.emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},a=({action:h,container:{id:y,endTime:p},branches:E=[],isEOV:b=!1,autoSelected:S=!1})=>{const T=rt(h,b),P={timestamp:!T.args.shouldOpenNow||b?1/0:p,priority:"container",initiator:y,actionType:T.type},_=t.emit.bind(t,C.interactives,{subjectId:y,subjectName:"container",type:x.actionChoice,actionType:T.type,payload:T.args});switch(T.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{const k=E.find(W=>W.id===T.args.branchId);if(!k)return;_(),i.add(Object.assign(Object.assign({},P),{action:g.bind(null,{subjectId:y,subjectName:"container",action:T,payload:{chapterId:k.chapterId,autoSelect:S}})})),n==null||n();return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{_(),i.add(Object.assign(Object.assign({},P),{action:m.bind(null,{subjectId:y,subjectName:"container",action:T})}));return}case R.openURI.trim().toLowerCase():{_(),i.add(Object.assign(Object.assign({},P),{action:I.bind(null,{subjectId:y,subjectName:"container",action:T,payload:{URI:h.args.uri}})})),n==null||n();return}default:console.error("Unexpected container event"),t.emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function l({container:h,branches:y,isEOV:p=!1}){const E=li(h.events);if(E){const b=rt(E.action,p);t.emit(C.interactives,{subjectId:h.id,subjectName:"container",type:x.actionChoice,actionType:b.type,payload:b.args}),i.add({timestamp:p?1/0:h.endTime,priority:"container",initiator:h.id,actionType:R.expect,action:u.bind(null,{subjectId:h.id,subjectName:"container"})}),r.isExpect=!0}else for(const b of h.events)a({action:b.action,container:h,branches:y,isEOV:p})}const d=({chapterId:h,action:y,branches:p=[]})=>{const E=t.emit.bind(t,C.interactives,{subjectId:h,subjectName:"chapter",type:x.actionChoice,actionType:y.type,payload:y.args});switch(y.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{const b=p.find(S=>S.id===y.args.branchId);return b!=null&&b.chapterId?(E(),g.bind(null,{subjectId:h,subjectName:"chapter",action:y,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{const b=Po(p);return b!=null&&b.chapterId?(E(),g.bind(null,{subjectId:h,subjectName:"chapter",action:y,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{const b=Lo(p);return b!=null&&b.chapterId?(E(),g.bind(null,{subjectId:h,subjectName:"chapter",action:y,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{const b=xo(p);return b!=null&&b.chapterId?(E(),g.bind(null,{subjectId:h,subjectName:"chapter",action:y,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{const b=Ao(p);return b!=null&&b.chapterId?(E(),g.bind(null,{subjectId:h,subjectName:"chapter",action:y,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return E(),m.bind(null,{subjectId:h,subjectName:"chapter",action:y});case R.openURI.trim().toLowerCase():return E(),I.bind(null,{subjectId:h,subjectName:"chapter",action:y,payload:{URI:y.args.uri}});default:console.error("Unexpected chapter event"),t.emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function f(h){const y=li(h.events);if(y){if(St(h))return;t.emit(C.interactives,{subjectId:h.id,subjectName:"chapter",type:x.actionChoice,actionType:y.action.type,payload:y.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:R.expect,action:u.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events.forEach(p=>{const E=d({chapterId:h.id,action:p.action,branches:h.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:p.action.type,action:E})})}const u=({subjectId:h,subjectName:y,action:p})=>{var E;e.pause(),t.emit(C.interactives,{subjectId:h,subjectName:y,type:x.actionExecution,actionType:(E=p==null?void 0:p.type)!==null&&E!==void 0?E:R.expect})},v=({subjectId:h,subjectName:y})=>{e.info.isEnded$.getValue()?i.execEndOfVideo():e.play(),t.emit(C.interactives,{subjectId:h,subjectName:y,type:x.actionExecution,actionType:"after-expect"})},m=({subjectId:h,subjectName:y,subjectType:p,action:E})=>{t.emit(C.interactives,{subjectId:h,subjectName:y,subjectType:p,type:x.actionExecution,actionType:E.type})},g=({subjectId:h,subjectName:y,subjectType:p,action:E,payload:b})=>{b.behaviour="change-chapter",t.emit(C.interactives,{subjectId:h,subjectName:y,subjectType:p,type:x.actionExecution,actionType:E.type,payload:b})},I=({subjectId:h,subjectName:y,subjectType:p,action:E,payload:b})=>{if(!b.URI)return;const S=window.open(b.URI,"_blank","noopener,noreferrer");S&&(S.opener=null),t.emit(C.interactives,{subjectId:h,subjectName:y,subjectType:p,type:x.actionExecution,actionType:E.type})};return{onControlEvent:c,onContainerEvent:a,onChapterEvent:d,onExpectEvent:u,expectEventHandler:v,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:s,state:r}};var be,yn,ht,vi;class Y{constructor(e,i,n,r){this.target=e,this.type=i,this.listener=n,this.options=o(Y,be,"m",yn).call(Y,e,r),this.target.addEventListener(i,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}}be=Y,yn=function(e,i){if(i===void 0)return!1;if(typeof i=="boolean")return i;{const n=new Set(["passive","capture"]),r=Object.keys(i).filter(c=>!n.has(c));return r.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+r.join(",")),o(Y,be,"m",vi).call(Y,e)?i:i.capture||!1}},vi=function(e){let i=o(Y,be,"f",ht);if(i===void 0){i=!1;try{const n={},r={get:()=>(i=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);const s=()=>{};e.addEventListener("test",s,n),e.removeEventListener("test",s,n)}catch(n){i=!1}w(Y,be,i,"f",ht)}return i||!1};ht={value:void 0};class No{constructor(){this.bindingMap=new $o}release(){this.removeAll(),this.bindingMap=null}listen(e,i,n,r){if(!this.bindingMap)return;const s=new Y(e,i,n,r);this.bindingMap.push(i,s)}listenOnce(e,i,n,r){const s=c=>{this.unlisten(e,i,s),n(c)};this.listen(e,i,s,r)}unlisten(e,i,n){if(!this.bindingMap)return;const r=this.bindingMap.get(i)||[];for(const s of r)s.target===e&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(i,s))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const i of e)i.unlisten();this.bindingMap.clear()}}class Mo{constructor(){this._prevSizeId=0,this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))===null||e===void 0||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var e;const i=(e=this.rootElement.getContext("2d"))===null||e===void 0?void 0:e.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!i)return!1;const n=i.data,r=n.length;for(let s=3;s<r;s+=40)if(n[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))===null||e===void 0||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,i=!1){return N(this,void 0,void 0,function*(){const n=e.width+e.height;if(this._prevSizeId===n)return;let r;i&&(r=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,i&&r&&this.restore(r),this._prevSizeId=n})}save(){return N(this,void 0,void 0,function*(){const e=this.rootElement.toDataURL("image/jpeg",1),i=new Image;return i.crossOrigin="anonymous",i.src=e,yield i.decode(),i})}restore(e){var i;this.rootElement&&((i=this.rootElement.getContext("2d"))===null||i===void 0||i.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}}class Vo{constructor({parentElement:e,endOffsetMs:i=250,onError:n}){this.currentVideoDurationMs=1/0,this._containerTimeFrameShouldReceived=!1,this._endTimeFrameReceived=!1,this._shouldCallSkip=!1,this.onEachTick=r=>{const s=r!=null?r:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,c=this.isChapterEndTime(s);if(this.isContainerTime(s))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(c)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}},this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())},this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
"use strict";var Dn=Object.create;var De=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var Un=Object.getOwnPropertyNames;var Hn=Object.getPrototypeOf,Gn=Object.prototype.hasOwnProperty;var zn=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Un(t))!Gn.call(i,r)&&r!==e&&De(i,r,{get:()=>t[r],enumerable:!(n=Wn(t,r))||n.enumerable});return i};var qn=(i,t,e)=>(e=i!=null?Dn(Hn(i)):{},zn(t||!i||!i.__esModule?De(e,"default",{value:i,enumerable:!0}):e,i));var P=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),Kn=require("uuid"),Qn=require("@vkontakte/videoplayer-core/es2015.cjs.js");const Yn="1.0.8";function xi(i,t=1){let e="0",n="0",r="0";return i.length===4?(e="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(e="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+e},${+n},${+r},${t})`}const K="SDK_NAME",Xn="SDK_NAME-controls-container",Pi=()=>document.querySelector(`.${Xn}`),Zn=.4,Y={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},We={top:"flex-start",bottom:"flex-end",center:"center"},Ue={start:"flex-start",end:"flex-end",center:"center"},He={start:"left",end:"right",center:"center"},Li=({target:i,props:t})=>{var e,n,r,s,l,o;i.style.alignItems=(n=We[(e=t==null?void 0:t.text)===null||e===void 0?void 0:e.gravityVertical])!==null&&n!==void 0?n:We.center,i.style.justifyContent=(s=Ue[(r=t==null?void 0:t.text)===null||r===void 0?void 0:r.gravityHorizontal])!==null&&s!==void 0?s:Ue.center,i.style.textAlign=(o=He[(l=t==null?void 0:t.text)===null||l===void 0?void 0:l.alignment])!==null&&o!==void 0?o:He.start},Vi=({target:i,props:t,fallback:e,dependsOn:n})=>{var r,s,l,o,c,d;i.style.color=(s=(r=t==null?void 0:t.text)===null||r===void 0?void 0:r.color)!==null&&s!==void 0?s:e.textColor,i.style.fontSize=`calc(${n.height} * ${(o=(l=t==null?void 0:t.text)===null||l===void 0?void 0:l.size)!==null&&o!==void 0?o:e.textSize})`,i.textContent=(d=(c=t==null?void 0:t.text)===null||c===void 0?void 0:c.value)!==null&&d!==void 0?d:e.textContent},Ni=({target:i,props:t,fallback:e})=>{var n,r,s,l;i.style.backgroundColor=xi((r=(n=t==null?void 0:t.background)===null||n===void 0?void 0:n.color)!==null&&r!==void 0?r:e.backgroundColor,(l=(s=t==null?void 0:t.background)===null||s===void 0?void 0:s.alpha)!==null&&l!==void 0?l:e.backgroundAlpha)},Mi=({target:i,props:t,fallback:e,dependsOn:n})=>{var r,s,l,o,c,d,h,u,v,m,g;i.style.border=`calc(${n.height} * ${(l=(s=(r=t==null?void 0:t.shape)===null||r===void 0?void 0:r.border)===null||s===void 0?void 0:s.width)!==null&&l!==void 0?l:e.borderWidth}) solid ${xi((d=(c=(o=t==null?void 0:t.shape)===null||o===void 0?void 0:o.border)===null||c===void 0?void 0:c.color)!==null&&d!==void 0?d:e.borderColor,(v=(u=(h=t==null?void 0:t.shape)===null||h===void 0?void 0:h.border)===null||u===void 0?void 0:u.alpha)!==null&&v!==void 0?v:e.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${(g=(m=t==null?void 0:t.shape)===null||m===void 0?void 0:m.roundCorners)!==null&&g!==void 0?g:e.roundCorners})`},je=({target:i,layoutParams:t,fallback:e})=>{var n;i.style.transform=`rotate(${(n=-t.angle)!==null&&n!==void 0?n:e.angle}rad)`},Jt="int",$e={AREA:`${Jt}_area`,TEXT:`${Jt}_text`,BUTTON:`${Jt}_bttn`};class Re{constructor(t){this.control=t}createView(t){var e;const n=document.createElement("div");n.classList.add(`${K}-control-container-${this.control.id}`),t(n,this.control.layoutParams);const r=((e=this.control.layoutParams.innerSizesDependOn)!==null&&e!==void 0?e:Y.innerSizesDependOn)==="self"?{height:n.style.height,width:n.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:n,dependsOn:r}}setEvents(t,e){t&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":t.addEventListener("click",s=>{s.stopPropagation(),e&&e({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${K}-control-container-${this.control.id}`)}}const ki=i=>{if(i.type.trim().toLowerCase()==="area")return new Jn(i)};class Jn extends Re{constructor(t){super(t)}createView({parent:t,layoutFn:e}){const{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("button");return s.classList.add(`${K}-${this.control.id}`),s.setAttribute("data-testid",$e.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",Ni({target:s,props:this.control.props,fallback:Object.assign(Object.assign({},Y),{backgroundColor:"transparent"})}),Mi({target:s,props:this.control.props,fallback:Object.assign(Object.assign({},Y),{borderAlpha:0}),dependsOn:n}),je({target:s,layoutParams:this.control.layoutParams,fallback:Y}),r.append(s),t.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${K}-${this.control.id}`)}}const Fi=i=>{if(i.type.trim().toLowerCase()==="button")return new tr(i)};class tr extends Re{constructor(t){super(t)}createView({parent:t,layoutFn:e}){const{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("button");s.type="button",s.classList.add(`${K}-${this.control.id}`),s.setAttribute("data-testid",$e.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";const l=document.createElement("span");return l.style.display="inline-block",l.style.whiteSpace="pre",l.style.overflow="hidden",l.style.textOverflow="ellipsis",je({target:s,layoutParams:this.control.layoutParams,fallback:Y}),Ni({target:s,props:this.control.props,fallback:Y}),Mi({target:s,props:this.control.props,fallback:Y,dependsOn:n}),Li({target:s,props:this.control.props}),Vi({target:l,props:this.control.props,fallback:Y,dependsOn:n}),s.append(l),r.append(s),t.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${K}-${this.control.id}`)}}const er=i=>{if(i.type.trim().toLowerCase()==="text")return new ir(i)};class ir extends Re{constructor(t){super(t)}createView({parent:t,layoutFn:e}){const{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("div");s.classList.add(`${K}-${this.control.id}`),s.setAttribute("data-testid",$e.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";const l=document.createElement("span");return l.style.whiteSpace="pre",je({target:s,layoutParams:this.control.layoutParams,fallback:Y}),Li({target:s,props:this.control.props}),Vi({target:l,props:this.control.props,fallback:Y,dependsOn:n}),s.append(l),r.append(s),t.append(r),this.controlEl=s,r}disable(){}enable(){}getElement(){return document.querySelector(`.${K}-${this.control.id}`)}}class nr{constructor(t){this.layout=t}}const rr=i=>{if(i.type.trim().toLowerCase()==="relative")return new Bi(i)};class Bi extends nr{constructor(t){super(t)}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,e){t.style.position="absolute",t.style.width=`calc(var(--interactive-content-width) * ${e.width})`,t.style.height=`calc(var(--interactive-content-height) * ${e.height})`,t.style.left=`calc(var(--interactive-content-width) * ${e.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,t.style.top=`calc(var(--interactive-content-height) * ${e.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}function st(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]]);return e}function A(i,t,e,n){function r(s){return s instanceof e?s:new e(function(l){l(s)})}return new(e||(e=Promise))(function(s,l){function o(h){try{d(n.next(h))}catch(u){l(u)}}function c(h){try{d(n.throw(h))}catch(u){l(u)}}function d(h){h.done?s(h.value):r(h.value).then(o,c)}d((n=n.apply(i,t||[])).next())})}function a(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)}function I(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e}var Ct,Gt,Ge;class Di{constructor(t){Ct.add(this),this.container=t,this.factories=new Map,a(this,Ct,"m",Gt).call(this)}addControlFactory(t,e){this.factories.set(t.trim().toLowerCase(),e),a(this,Ct,"m",Gt).call(this)}removeControlFactory(t){this.factories.delete(t.trim().toLowerCase()),a(this,Ct,"m",Gt).call(this)}}Ct=new WeakSet,Gt=function(){this.controls=a(this,Ct,"m",Ge).call(this)},Ge=function(){var t;return(t=this.container.controls)===null||t===void 0?void 0:t.reduce((e,n)=>{const r=n.type.trim().toLowerCase(),s=this.factories.get(r);return s?[...e,s(n)]:[...e]},[])};const Wi=(i,t)=>{if(i.type.trim().toLowerCase()==="choice")return new sr(i,t)};class sr extends Di{constructor(t,e){super(t),this.rootElement=e!=null?e:Pi(),this.layout=new Bi(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Fi),this.addControlFactory("text",er),this.addControlFactory("area",ki)}createView(t){const e=document.createElement("div");return e.classList.add(`${K}-${this.container.id}`),this.layout.setContainerLayout(e),this.controls.forEach(n=>{const r=n.createView({parent:e,layoutFn:this.layout.setControlLayout});n.setEvents(r,t)}),this.rootElement.append(e),this.isRemoved=!1,e}hide(){const t=this.getElement();t&&(t.style.visibility="hidden")}show(){const t=this.getElement();t&&(t.style.visibility="visible")}enable(){const t=this.getElement();t&&(this.controls.forEach(e=>e.enable()),t.style.opacity=1,this.isDisabled=!1)}disable(){const t=this.getElement();t&&(this.controls.forEach(e=>e.disable()),t.style.opacity=Zn,this.isDisabled=!0)}removeView(){var t;this.isRemoved||((t=this.getElement())===null||t===void 0||t.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${K}-${this.container.id}`)}}var te=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ar(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var kt=function(i){return i&&i.Math==Math&&i},at=kt(typeof globalThis=="object"&&globalThis)||kt(typeof window=="object"&&window)||kt(typeof self=="object"&&self)||kt(typeof te=="object"&&te)||function(){return this}()||te||Function("return this")(),ht=function(i){try{return!!i()}catch(t){return!0}},or=ht,Xt=!or(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),lr=Xt,Ui=Function.prototype,ze=Ui.apply,qe=Ui.call,cr=typeof Reflect=="object"&&Reflect.apply||(lr?qe.bind(ze):function(){return qe.apply(ze,arguments)}),Hi=Xt,Gi=Function.prototype,pe=Gi.call,dr=Hi&&Gi.bind.bind(pe,pe),wt=Hi?dr:function(i){return function(){return pe.apply(i,arguments)}},zi=wt,hr=zi({}.toString),ur=zi("".slice),qi=function(i){return ur(hr(i),8,-1)},fr=qi,vr=wt,Ki=function(i){if(fr(i)==="Function")return vr(i)},ye=typeof document=="object"&&document.all,pr=typeof ye=="undefined"&&ye!==void 0,Qi={all:ye,IS_HTMLDDA:pr},Yi=Qi,yr=Yi.all,ut=Yi.IS_HTMLDDA?function(i){return typeof i=="function"||i===yr}:function(i){return typeof i=="function"},Xi={},mr=ht,xt=!mr(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),br=Xt,Ft=Function.prototype.call,Ae=br?Ft.bind(Ft):function(){return Ft.apply(Ft,arguments)},Zi={},Ji={}.propertyIsEnumerable,tn=Object.getOwnPropertyDescriptor,gr=tn&&!Ji.call({1:2},1);Zi.f=gr?function(t){var e=tn(this,t);return!!e&&e.enumerable}:Ji;var en=function(i,t){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:t}},Cr=wt,Er=ht,Ir=qi,ee=Object,_r=Cr("".split),wr=Er(function(){return!ee("z").propertyIsEnumerable(0)})?function(i){return Ir(i)=="String"?_r(i,""):ee(i)}:ee,nn=function(i){return i==null},Sr=nn,Or=TypeError,rn=function(i){if(Sr(i))throw Or("Can't call method on "+i);return i},Tr=wr,jr=rn,$r=function(i){return Tr(jr(i))},Ke=ut,sn=Qi,Rr=sn.all,Zt=sn.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Ke(i)||i===Rr}:function(i){return typeof i=="object"?i!==null:Ke(i)},an={},ie=an,ne=at,Ar=ut,Qe=function(i){return Ar(i)?i:void 0},on=function(i,t){return arguments.length<2?Qe(ie[i])||Qe(ne[i]):ie[i]&&ie[i][t]||ne[i]&&ne[i][t]},xr=wt,Pr=xr({}.isPrototypeOf),Lr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",ln=at,re=Lr,Ye=ln.process,Xe=ln.Deno,Ze=Ye&&Ye.versions||Xe&&Xe.version,Je=Ze&&Ze.v8,z,Kt;Je&&(z=Je.split("."),Kt=z[0]>0&&z[0]<4?1:+(z[0]+z[1]));!Kt&&re&&(z=re.match(/Edge\/(\d+)/),(!z||z[1]>=74)&&(z=re.match(/Chrome\/(\d+)/),z&&(Kt=+z[1])));var Vr=Kt,ti=Vr,Nr=ht,Mr=at,kr=Mr.String,cn=!!Object.getOwnPropertySymbols&&!Nr(function(){var i=Symbol();return!kr(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&ti&&ti<41}),Fr=cn,dn=Fr&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Br=on,Dr=ut,Wr=Pr,Ur=dn,Hr=Object,hn=Ur?function(i){return typeof i=="symbol"}:function(i){var t=Br("Symbol");return Dr(t)&&Wr(t.prototype,Hr(i))},Gr=String,zr=function(i){try{return Gr(i)}catch(t){return"Object"}},qr=ut,Kr=zr,Qr=TypeError,un=function(i){if(qr(i))return i;throw Qr(Kr(i)+" is not a function")},Yr=un,Xr=nn,Zr=function(i,t){var e=i[t];return Xr(e)?void 0:Yr(e)},se=Ae,ae=ut,oe=Zt,Jr=TypeError,ts=function(i,t){var e,n;if(t==="string"&&ae(e=i.toString)&&!oe(n=se(e,i))||ae(e=i.valueOf)&&!oe(n=se(e,i))||t!=="string"&&ae(e=i.toString)&&!oe(n=se(e,i)))return n;throw Jr("Can't convert object to primitive value")},fn={exports:{}},ei=at,es=Object.defineProperty,is=function(i,t){try{es(ei,i,{value:t,configurable:!0,writable:!0})}catch(e){ei[i]=t}return t},ns=at,rs=is,ii="__core-js_shared__",ss=ns[ii]||rs(ii,{}),as=ss,ni=as;(fn.exports=function(i,t){return ni[i]||(ni[i]=t!==void 0?t:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var os=fn.exports,ls=rn,cs=Object,vn=function(i){return cs(ls(i))},ds=wt,hs=vn,us=ds({}.hasOwnProperty),xe=Object.hasOwn||function(t,e){return us(hs(t),e)},fs=wt,vs=0,ps=Math.random(),ys=fs(1 .toString),ms=function(i){return"Symbol("+(i===void 0?"":i)+")_"+ys(++vs+ps,36)},bs=at,gs=os,ri=xe,Cs=ms,Es=cn,Is=dn,Et=bs.Symbol,le=gs("wks"),_s=Is?Et.for||Et:Et&&Et.withoutSetter||Cs,ws=function(i){return ri(le,i)||(le[i]=Es&&ri(Et,i)?Et[i]:_s("Symbol."+i)),le[i]},Ss=Ae,si=Zt,ai=hn,Os=Zr,Ts=ts,js=ws,$s=TypeError,Rs=js("toPrimitive"),As=function(i,t){if(!si(i)||ai(i))return i;var e=Os(i,Rs),n;if(e){if(t===void 0&&(t="default"),n=Ss(e,i,t),!si(n)||ai(n))return n;throw $s("Can't convert object to primitive value")}return t===void 0&&(t="number"),Ts(i,t)},xs=As,Ps=hn,pn=function(i){var t=xs(i,"string");return Ps(t)?t:t+""},Ls=at,oi=Zt,me=Ls.document,Vs=oi(me)&&oi(me.createElement),Ns=function(i){return Vs?me.createElement(i):{}},Ms=xt,ks=ht,Fs=Ns,yn=!Ms&&!ks(function(){return Object.defineProperty(Fs("div"),"a",{get:function(){return 7}}).a!=7}),Bs=xt,Ds=Ae,Ws=Zi,Us=en,Hs=$r,Gs=pn,zs=xe,qs=yn,li=Object.getOwnPropertyDescriptor;Xi.f=Bs?li:function(t,e){if(t=Hs(t),e=Gs(e),qs)try{return li(t,e)}catch(n){}if(zs(t,e))return Us(!Ds(Ws.f,t,e),t[e])};var Ks=ht,Qs=ut,Ys=/#|\.prototype\./,Pt=function(i,t){var e=Zs[Xs(i)];return e==ta?!0:e==Js?!1:Qs(t)?Ks(t):!!t},Xs=Pt.normalize=function(i){return String(i).replace(Ys,".").toLowerCase()},Zs=Pt.data={},Js=Pt.NATIVE="N",ta=Pt.POLYFILL="P",ea=Pt,ci=Ki,ia=un,na=Xt,ra=ci(ci.bind),sa=function(i,t){return ia(i),t===void 0?i:na?ra(i,t):function(){return i.apply(t,arguments)}},mn={},aa=xt,oa=ht,la=aa&&oa(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),ca=Zt,da=String,ha=TypeError,ua=function(i){if(ca(i))return i;throw ha(da(i)+" is not an object")},fa=xt,va=yn,pa=la,Bt=ua,di=pn,ya=TypeError,ce=Object.defineProperty,ma=Object.getOwnPropertyDescriptor,de="enumerable",he="configurable",ue="writable";mn.f=fa?pa?function(t,e,n){if(Bt(t),e=di(e),Bt(n),typeof t=="function"&&e==="prototype"&&"value"in n&&ue in n&&!n[ue]){var r=ma(t,e);r&&r[ue]&&(t[e]=n.value,n={configurable:he in n?n[he]:r[he],enumerable:de in n?n[de]:r[de],writable:!1})}return ce(t,e,n)}:ce:function(t,e,n){if(Bt(t),e=di(e),Bt(n),va)try{return ce(t,e,n)}catch(r){}if("get"in n||"set"in n)throw ya("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var ba=xt,ga=mn,Ca=en,Ea=ba?function(i,t,e){return ga.f(i,t,Ca(1,e))}:function(i,t,e){return i[t]=e,i},Dt=at,Ia=cr,_a=Ki,wa=ut,Sa=Xi.f,Oa=ea,pt=an,Ta=sa,yt=Ea,hi=xe,ja=function(i){var t=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new i;case 1:return new i(e);case 2:return new i(e,n)}return new i(e,n,r)}return Ia(i,this,arguments)};return t.prototype=i.prototype,t},$a=function(i,t){var e=i.target,n=i.global,r=i.stat,s=i.proto,l=n?Dt:r?Dt[e]:(Dt[e]||{}).prototype,o=n?pt:pt[e]||yt(pt,e,{})[e],c=o.prototype,d,h,u,v,m,g,w,f,p;for(v in t)d=Oa(n?v:e+(r?".":"#")+v,i.forced),h=!d&&l&&hi(l,v),g=o[v],h&&(i.dontCallGetSet?(p=Sa(l,v),w=p&&p.value):w=l[v]),m=h&&w?w:t[v],!(h&&typeof g==typeof m)&&(i.bind&&h?f=Ta(m,Dt):i.wrap&&h?f=ja(m):s&&wa(m)?f=_a(m):f=m,(i.sham||m&&m.sham||g&&g.sham)&&yt(f,"sham",!0),yt(o,v,f),s&&(u=e+"Prototype",hi(pt,u)||yt(pt,u,{}),yt(pt[u],v,m),i.real&&c&&(d||!c[v])&&yt(c,v,m)))},Ra=Math.ceil,Aa=Math.floor,xa=Math.trunc||function(t){var e=+t;return(e>0?Aa:Ra)(e)},Pa=xa,bn=function(i){var t=+i;return t!==t||t===0?0:Pa(t)},La=bn,Va=Math.min,Na=function(i){return i>0?Va(La(i),9007199254740991):0},Ma=Na,ka=function(i){return Ma(i.length)},Fa=$a,Ba=vn,Da=ka,Wa=bn;Fa({target:"Array",proto:!0},{at:function(t){var e=Ba(this),n=Da(e),r=Wa(t),s=r>=0?r:n+r;return s<0||s>=n?void 0:e[s]}});var Ua=on,Ha=Ua,Ga=Ha,za=Ga("Array","at"),qa=za,Ka=qa,Qa=Ka,Ya=Qa,be=ar(Ya);function gn(i,t){let e;return(...n)=>{clearTimeout(e),e=setTimeout(()=>i(...n),t)}}const Lt={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},St=(i,t)=>Object.prototype.toString.call(i)===`[object ${t}]`,Pe=i=>St(i,Lt.Object),ge=i=>St(i,Lt.String),Le=i=>St(i,Lt.Array),Cn=i=>St(i,Lt.Number),Xa=i=>St(i,Lt.Function),ui=i=>Cn(i)&&!isNaN(i),$t=i=>Pe(i)&&Object.keys(i).length===0,En=i=>Le(i)&&!i.length,Wt=(i,t)=>ge(i)&&(t?i.trim():i).length,In=window.navigator.userAgent.toLowerCase(),Za=/mobi/i.test(In);In.indexOf("android")>-1;const Ja="video_interactive",to="videoint",eo=250;class io{constructor(t){this.onResize=e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))},this.handleChapterChange=e=>{var n;if(this.isReady){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(n=this.onError)===null||n===void 0||n.call(this,"Id is not found"),console.error("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=void 0}},this.handleManifestChange=(e,n=[])=>A(this,void 0,void 0,function*(){var r;if(!Cn(e.graph.edit.chapters[0].x)){this.isReady=!1,(r=this.onError)===null||r===void 0||r.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let s;try{s=yield P.loadVKLangPack(this.lang,Ja,to)}catch(o){console.log("Unable to load graph language pack")}const{GraphEditor:l}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new l(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:s}),this.ngEditor.on("control",({name:o,chapterId:c})=>{o==="openPreview"&&this.onOpenPreviewClick(c)}),this.ngEditor.on("zoomEnd",o=>{this.lastZoomInfo=Object.assign({},o)})}this.visitedChapterIds=new Set(n),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}),this.init(t)}init({root:t,onOpenPreviewClick:e,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=e,this.onError=n,this.lang=r!=null?r:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=no(t),this.resizeObserver=new ResizeObserver(gn(this.onResize,eo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(t=this.ngEditorSize){return[(this.lastZoomInfo.x-t.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-t.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(t){this.visitedChapterIds=new Set([...this.visitedChapterIds,...t]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(t){this.ngEditor.updateVideosInfo(t)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var t,e;this.hide(),this.resizeObserver.disconnect(),(t=this.ngEditor)===null||t===void 0||t.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(e=this.ngEditor)===null||e===void 0||e.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function no(i){const 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",i.append(t),t}const At=(i="",t="")=>{i=i.split("."),t=t.split(".");let e=0;for(let n=0;n<Math.max(i.length,t.length)&&!e;n++)i[n]>t[n]?e=1:i[n]<t[n]?e=-1:e=0;return e},ro="3.1",fi={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},so={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},ao=i=>{const t=[];for(const e of i.chapters){let n;const r=[];for(let o of e.branches){const{isDefault:c}=o,d=st(o,["isDefault"]);c&&(n=d.id),r.push(d)}let s=[];const l=[];for(let o of e.containers){const{fallbackStrategy:c}=o,d=st(o,["fallbackStrategy"]),h=!!d.endTime;let u=[so];switch(c){case"await":h?u=[]:s=[];break;case"default":{const v={type:"onSuspense",action:{type:fi.default,args:{branchId:n,shouldOpenNow:!h,isDetachContainer:!0}}};h?u=[v]:s=[v];break}case"random":case"weightlessRandom":case"max":case"min":{const v={type:"onSuspense",action:{type:fi[c],args:{}}};h?u=[v]:s=[v];break}}for(const v of d.controls)l.push(Object.assign(Object.assign({},d),{controls:[Object.assign({},v)],id:Kn.v4(),events:u}))}t.push(Object.assign(Object.assign({},e),{containers:l,events:s,branches:r}))}return i.metadata.version=ro,i.metadata.updated=new Date().toISOString(),Object.assign(Object.assign({},i),{chapters:t})},oo="3.2",lo=i=>{if(!i.media){const t=i.metadata,{media:e}=t,n=st(t,["media"]);return Object.assign(Object.assign({},i),{metadata:Object.assign(Object.assign({},n),{version:oo}),media:e})}return i},co="3.3",ho=(i=[])=>({edit:{chapters:i},view:{}}),vi={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},uo=i=>{var t;const e=[],n=[];for(const r of i.chapters){const{id:s,x:l,y:o}=r,c=st(r,["id","x","y"]),d=c.containers.map(h=>{var u;return Object.assign(Object.assign({},h),{controls:h.controls.map(v=>{var{subtype:m,type:g}=v,w=st(v,["subtype","type"]);return Object.assign(Object.assign({},w),{type:m!=null?m:g})}),events:!((u=h.events)===null||u===void 0)&&u.length?h.events:[vi]})});e.push(Object.assign(Object.assign({id:s},c),{containers:d,events:!((t=c.events)===null||t===void 0)&&t.length?c.events:[vi]})),n.push({id:s,x:l,y:o})}return Object.assign(Object.assign({},i),{chapters:e,graph:ho(n),metadata:Object.assign(Object.assign({},i.metadata),{version:co})})},fo=[{version:"3.0",migrate:ao},{version:"3.1",migrate:lo},{version:"3.2",migrate:uo}],vo=i=>fo.reduce((t,e)=>At(t.metadata.version,e.version)?t:e.migrate(t),i),po=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),j=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});exports.INTERACTIVE_CLICK_ACTIONS=void 0;(function(i){i.GO_NEXT_BUTTON="GO_NEXT_BUTTON",i.GO_NEXT_AREA="GO_NEXT_AREA",i.WATCH_AGAIN="WATCH_AGAIN",i.OPEN_GRAPH="OPEN_GRAPH",i.CLOSE_GRAPH="CLOSE_GRAPH"})(exports.INTERACTIVE_CLICK_ACTIONS||(exports.INTERACTIVE_CLICK_ACTIONS={}));const pi={metadata:"Object",chapters:"Array"},yo="3.0.0",mo="3.3.0",Ve=i=>{const t=At(i,yo);return t===-1?!1:t===0?!0:At(i,mo)!==1},bo=i=>{if(!Pe(i))return!1;for(const t in pi)if(!i[t]||!St(i[t],pi[t]))return!1;return Ve(i.metadata.version)},_n=i=>i.type===po.Text;class S{constructor(t,e,...n){this.severity=t,this.category=e,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}}S.Severity={RECOVERABLE:1,CRITICAL:2};S.Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6};class wn{constructor(){this.listeners={}}addListener(t,e){return this.listeners[t]=this.listeners[t]||[],this.listeners[t].push(e),this}on(t,e){return this.addListener(t,e)}once(t,e){this.listeners[t]=this.listeners[t]||[];const n=()=>{e(),this.off(t,n)};return this.listeners[t].push(n),this}off(t,e){return this.removeListener(t,e)}reset(){this.listeners={}}removeListener(t,e){const n=this.listeners[t];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===e){n.splice(r,1);break}return this}emit(t,...e){const n=this.listeners[t];return n?(n.forEach(r=>{r(...e)}),!0):!1}listenerCount(t){return(this.listeners[t]||[]).length}rawListeners(t){return this.listeners[t]}}class go{constructor(t){this.addFn=(e,n=!1)=>{Xa(e)&&(this.fns.push(e),n&&this.updateFn())},this.removeFn=(e,n=!1)=>{this.fns=this.fns.filter(r=>r!==e),n&&this.updateFn()},this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}},this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))},this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()},this.cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0},this.raf,this.fn,this.fns=[],this.addFn(t)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Co{constructor(t){var e,n;this.loaders={chapterLoaders:(e=t==null?void 0:t.chapterLoaders)!==null&&e!==void 0?e:[],manifestLoaders:(n=t==null?void 0:t.manifestLoaders)!==null&&n!==void 0?n:[]}}exec(t,e){return A(this,void 0,void 0,function*(){return Eo(...this.loaders[t])(e)})}}function Eo(...i){return function(e){return A(this,void 0,void 0,function*(){const n=[...i];for(;n.length>0;)e=yield n.shift()(e);return e})}}function Qt(i,t,e){return i?Object.assign(Object.assign({},i),{[t]:i[t]?[e,...i[t]]:[e]}):{[t]:[e]}}function Ce(i){var{actions:t,errors:e,chapterId:n}=i,r=st(i,["actions","errors","chapterId"]);if(n){const s=t.getManifest(),l=t.getChapter(s.chapters,n);if(l){const o=t.getMedia(s.media,l.videoId),c=t.getGraph(s.graph,l.id);return o?Object.assign(Object.assign({},r),{actions:t,errors:e,result:{chapter:l,media:o,graph:c}}):Object.assign(Object.assign({},r),{errors:Qt(e,Ce.name,"Could not find media"),actions:t})}}return Object.assign(Object.assign({},r),{errors:Qt(e,Ce.name,"Could not find chapter"),actions:t})}class yi{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(t,e,n){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:n})}removeEventListener(t,e){if(!(t in this.listeners))return;const n=this.listeners[t];for(let r=0,s=n.length;r<s;r++)if(n[r].callback===e){n.splice(r,1);return}}dispatchEvent(t){if(!(t.type in this.listeners))return;const n=this.listeners[t.type].slice();for(let r=0,s=n.length;r<s;r++){const l=n[r];try{l.callback.call(this,t)}catch(o){Promise.resolve().then(()=>{throw o})}l.options&&l.options.once&&this.removeEventListener(t.type,l.callback)}return!t.defaultPrevented}}class Sn extends yi{constructor(){super(),this.listeners||yi.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(t){t.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,t)),super.dispatchEvent(t)}}class Io{constructor(){Object.defineProperty(this,"signal",{value:new Sn,writable:!0,configurable:!0})}abort(t){let e;try{e=new Event("abort")}catch(r){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}let n=t;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(r){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(e)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(Io.prototype[Symbol.toStringTag]="AbortController",Sn.prototype[Symbol.toStringTag]="AbortSignal");function On(i){return i.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof i.Request=="function"&&!i.Request.prototype.hasOwnProperty("signal")||!i.AbortController}function _o(i){typeof i=="function"&&(i={fetch:i});const{fetch:t,Request:e=t.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=i;if(!On({fetch:t,Request:e,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:t,Request:s};let s=e;(s&&!s.prototype.hasOwnProperty("signal")||r)&&(s=function(d,h){let u;h&&h.signal&&(u=h.signal,delete h.signal);const v=new e(d,h);return u&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:u}),v},s.prototype=e.prototype);const l=t;return{fetch:(c,d)=>{const h=s&&s.prototype.isPrototypeOf(c)?c.signal:d?d.signal:void 0;if(h){let u;try{u=new DOMException("Aborted","AbortError")}catch(m){u=new Error("Aborted"),u.name="AbortError"}if(h.aborted)return Promise.reject(u);const v=new Promise((m,g)=>{h.addEventListener("abort",()=>g(u),{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([v,l(c,d)])}return l(c,d)},Request:s}}const Ne=On({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Tn=Ne?_o({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,mi=Ne?Tn.fetch:window.fetch;Ne?Tn.Request:window.Request;const wo=i=>A(void 0,void 0,void 0,function*(){try{let t,e;if(Pe(i))t=i;else if(ge(i)){e=new URL(i).href;const r=yield mi(e);if(!r.ok)return{};t=yield r.json()}else return{};if(!bo(t))return{};const n=t.metadata.media;if(ge(n)&&!t.media)try{let r;e?r=new URL(n,e).href:(r=new URL(n).href,e=r);const s=yield mi(r);if(!s.ok)throw new Error;t.metadata.media=yield s.json()}catch(r){return jo(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:e}}catch(t){return{}}});function So(i){return A(this,void 0,void 0,function*(){const{manifest:t,manifestURL:e}=yield wo(i),n=vo(t);return n.media=Oo(n.media,e),delete n.metadata.media,n})}function fe(i,t){return i.find(e=>e.id===t)}function bi(i,t){var e,n;return!((e=i.edit)===null||e===void 0)&&e.chapters?i.edit.chapters.find(r=>r.id===t):!((n=i.view)===null||n===void 0)&&n.chapters?i.view.chapters.find(r=>r.id===t):void 0}function gi(i,t){return i.videos.find(e=>e.id===t)}function Oo(i,t){return Object.assign(Object.assign({},i),{videos:i.videos.map(e=>Object.assign(Object.assign({},e),{variants:e.variants.map(n=>{const r=To(n.url,t);return Object.assign(Object.assign({},n),{url:r||n.url})})}))})}function To(i,t){try{return new URL(i,t).href}catch(e){return""}}function jo(i){return At(i,"3.2.0")>=0}const x=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Me=i=>Le(i)&&!En(i),Vt=i=>i.order==="end",jn=i=>Le(i.containers)&&!En(i.containers)&&Vt(i),$o=(i,t)=>{var e;const n=i*1e3;return Me(t.controls)&&n<((e=t.startTime)!==null&&e!==void 0?e:0)},Ci=(i,t)=>{var e,n;const r=i*1e3;return Me(t.controls)&&r>=((e=t.startTime)!==null&&e!==void 0?e:0)&&r<=((n=t.endTime)!==null&&n!==void 0?n:1/0)},Yt=i=>i.some(t=>t.action.type==="expect"),Ei=i=>i.find(t=>t.action.type==="expect"),Ro=i=>(i==null?void 0:i.length)===1,$n=i=>Ro(i)&&_n(i[0]),Ao=({fn:i,type:t=1},...e)=>(...n)=>t?i(...n,...e):i(Object.assign(Object.assign({},n[t]),e[t])),xo=(i=[])=>i.reduce((t,e,n)=>{var r,s,l;const o=((r=e==null?void 0:e.controls)!==null&&r!==void 0?r:[]).filter(c=>!_n(c));if(Me(o)){const c=[(s=e.startTime)!==null&&s!==void 0?s:0,(l=e.endTime)!==null&&l!==void 0?l:1/0],d=e.id;if(!n)t.push({subjects:[d],range:c});else{const h=[];let u=-1/0,v=1/0,m=[];const g=[];for(let w=0;w<t.length;w++){const f=t[w];if(g.push(...f.subjects),f.range[0]<v&&(v=f.range[0]),f.range[1]>u&&(u=f.range[1]),f.range[0]<=c[0]&&f.range[1]>=c[1])return t[w].subjects.push(d),t;c[0]>=f.range[0]&&c[0]<=f.range[1]&&(h.push(w),m=m.concat(f.subjects),c[0]=f.range[0]),c[1]>=f.range[0]&&c[1]<=f.range[1]&&(h.push(w),m=m.concat(f.subjects),c[1]=f.range[1])}if(g.push(d),c[0]<=v&&c[1]>=u)return[{subjects:g,range:c}];h.length&&h.reverse().forEach(w=>{t.splice(w,1)}),t.push({subjects:m.concat([d]),range:c})}}return t},[]).sort((t,e)=>t.range[0]-e.range[0]),Po=(i,t)=>Yt(i.events)?!1:t.some(({container:e})=>e.container.id!==i.id&&Yt(e.container.events)&&e.container.endTime===i.endTime&&!e.isRemoved);class Rn extends Co{constructor(t,e){super(t),this.onError=e,this.prevChapter$=new P.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){var e;return A(this,void 0,void 0,function*(){this.release();const n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Qt},result:null,errors:null,source:t});n.errors&&this.errorHandler(n.errors);const r=yield So((e=n.result)!==null&&e!==void 0?e:t);return this.manifest=r,this})}setInitial(){return A(this,void 0,void 0,function*(){return this.setNext()})}setNext(t=this.manifest.metadata.initChapterId){return A(this,void 0,void 0,function*(){this.prevChapter$.next(this.chapter);const e=yield this.exec("chapterLoaders",Ce({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:bi,getChapter:fe,getMedia:gi,getByBranches:this.getByBranches.bind(this),addErrorMessage:Qt},result:null,errors:null,chapterId:t}));return e.errors&&this.errorHandler(e.errors),this.chapter=e.result.chapter,this.media=e.result.media,this.graph=e.result.graph,this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(t=this.manifest.metadata.initChapterId){const e=fe(this.manifest.chapters,t);if(e){const n=gi(this.manifest.media,e.videoId),r=bi(this.manifest.graph,e.id);if(n)return{chapter:e,media:n,graph:r}}return null}getBranches(t=this.chapter.id){if(t===this.chapter.id)return this.getByBranches(this.chapter.branches);{const e=fe(this.manifest.chapters,t);return this.getByBranches(e==null?void 0:e.branches)}}getByBranches(t=[]){return t.reduce((e,n)=>{const r=this.getByChapterId(n.chapterId);return r&&e.push(r),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return Vt(this.chapter)}}const Lo=i=>{const t=i.variants.find(e=>{var n;return((n=e.payload)===null||n===void 0?void 0:n.type)==="vk"});if(t&&"payload"in t){const[e,n]=t.payload.id.split("_");return[e,n]}return[]},E={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ee={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Vo(){const i=new Map;function t(r){var{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=r,o=st(r,["listId","itemId"]);const c=i.get(s),d=Object.assign({},o);return c?c[l]=d:i.set(s,{[l]:d}),Object.assign({listId:s,itemId:l},o)}function e(r,s){var l,o,c;const d=i.get(r);if(d){if(s)return(l=d[s])===null||l===void 0||l.player.destroy(),(o=d[s])===null||o===void 0||o.container.remove(),(c=d[s])===null||c===void 0||c.subscription.unsubscribe(),delete d[s],Object.keys(d).length||i.delete(r),!0;for(const h of Object.values(d))h.player.destroy(),h.container.remove();return i.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(const r of i)e(r[0])}return{createPlayer:t,removePlayer:e,map:i,removeAll:n}}function Ii(i,t=[]){var e,n,r;let s={},l;const o=!t.length;for(const c of i.variants)if(!l&&"cover"in c&&(l=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(o||t.includes("mp4"))&&(s.MPEG=Object.assign(Object.assign({},s.MPEG),{[(e=c.standard)!==null&&e!==void 0?e:"Invariant quality"]:c.url}));break;case"mpeg":(o||t.includes("mpeg"))&&(s.MPEG=Object.assign(Object.assign({},s.MPEG),{[(n=c.standard)!==null&&n!==void 0?n:"Invariant quality"]:c.url}));break;case"hls":(o||t.includes("hls"))&&(s=Object.assign(Object.assign({},s),{HLS:{type:"url",url:c.url}}));break;case"dash":(o||t.includes("dash"))&&(s=Object.assign(Object.assign({},s),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break}return{sources:s,thumbUrl:l,title:(r=i.title)!==null&&r!==void 0?r:""}}const Ut=(i,t)=>{const e=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();e!==t&&n.includes(t)&&(i.setQuality(t),i.setAutoQuality(!1))},zt={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},No=2;function Mo(i){const t=Vo();let e,n;const r=new wn;let s={},l=!1,o=null,c=!1,d;i&&h(i);function h(y){o=y}function u(y,C,b){var T;if(!o)throw Error("need to set interactive controller");const V=((T=t.map.get(y))!==null&&T!==void 0?T:{})[C];if(V){s=Object.assign({chapterId:b,listId:y,itemId:C},V);const _=s.player;n=_.info.currentQuality$.subscribe(F=>{if(!(!F||!_.info.position$.getValue())){e=F;for(const U of t.map)Object.values(U[1]).forEach(({player:M})=>{_.info.isAutoQualityEnabled$.getValue()||Ut(M,F)})}}),V.container.remove(),l=!1,o.setPlayer(V.player),c||(o.init(),c=!0),r.emit(zt.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function v(y,C,b){return A(this,void 0,void 0,function*(){if(!o)throw Error("need to set interactive controller");if($t(s)||y!==s.itemId)return;if(b>=0&&!l){const R=o.getChapterBranches();l=!0;const V=new Set;for(const _ of R)V.has(_.media.id)||(yield g({media:_.media,chapterId:_.chapter.id,setAsActive:!1,title:_.chapter.label}),V.add(_.media.id))}})}function m({chapter:{id:y},media:C}){return A(this,void 0,void 0,function*(){if($t(s))return;n==null||n.unsubscribe();const b=s.player.info.muted$.getValue(),T=s.player.info.currentQuality$.getValue(),R=s.player.info.isAutoQualityEnabled$.getValue(),V=s.player.info.volume$.getValue(),_=s.player.info.currentPlaybackRate$.getValue(),F=!R;let U=!1;for(const M of t.map)if(M[0]===C.id){const Q=Object.keys(M[1]);for(const X of Q)X===s.itemId?(Q.length<No||(U=!0),t.removePlayer(M[0],X)):(U=!0,u(M[0],X,y),F?Ut(s.player,T):s.player.setAutoQuality(!0),s.player.setVolume(V),s.player.setMuted(b),s.player.setPlaybackRate(_))}else t.removePlayer(M[0]);U||(yield g({media:C,chapterId:y,setAsActive:!0,playbackRate:_}),F?Ut(s.player,T):s.player.setAutoQuality(!0),s.player.setVolume(V),s.player.setMuted(b))})}function g({media:y,chapterId:C,prefetch:b=!0,setAsActive:T=!0,autoplay:R=!1,preferredExt:V,title:_,playbackRate:F}){var U,M,Q;return A(this,void 0,void 0,function*(){const X=Math.random().toString(),ft=document.createElement("div");d.append(ft);const Fn=(U=s==null?void 0:s.player)===null||U===void 0?void 0:U.info.isAutoQualityEnabled$.getValue();let Nt;if(!((M=o==null?void 0:o.options)===null||M===void 0)&&M.vkVideoLoader){const Mt=Lo(y);Mt.length&&(Nt=yield o.options.vkVideoLoader(...Mt))}const Fe=Object.assign(Object.assign({container:ft},((Q=Nt==null?void 0:Nt.videos)===null||Q===void 0?void 0:Q[0])||{sources:Ii(y,V).sources}),{title:_}),ot=new Qn.Player;ot.initVideo(Fe);const Bn=ft.lastChild,Be=new P.Subscription;Be.add(ot.info.position$.subscribe(function(Mt){v(X,ot.info.duration$.getValue(),Mt)})).add(ot.events.canplay$.subscribe(function(){Fn||Ut(ot,e),F&&ot.setPlaybackRate(F)})),Bn&&(ft.style.display="none",ft.classList.add(C));const vt=t.createPlayer({listId:y.id,itemId:X,player:ot,container:ft,sources:Ii(y,V).sources,config:Fe,subscription:Be});return T&&u(y.id,vt.itemId,C),R&&vt.player.play(),b&&!R&&vt.player.prepare(),r.emit(zt.playerCreated,vt.player),{player:vt.player,config:vt.config}})}function w(){f(),o=null}function f(){o==null||o.off(E.chapterChanged,m),t.removeAll(),s={},c=!1,l=!1}function p({container:y}){return A(this,void 0,void 0,function*(){if(!o)throw Error("need to set interactive controller");f(),d=y;const{media:C,chapter:b}=o.getCurrentChapter();if(C){o.on(E.chapterChanged,m);const{player:T,config:R}=yield g({media:C,chapterId:b.id,title:b.label});return r.emit(zt.initiated,{container:y,media:C,chapterId:b.id}),{player:T,config:R}}else console.error("not found")})}return Object.assign(Object.assign({},t),{on:r.on.bind(r),off:r.off.bind(r),init:p,setInteractiveController:h,createPlayer:g,removeAll:w,getActivePlayer:function(){return s}})}const ko=3e3,Fo=()=>{let i=[],t=null;return{setPlayer:l=>{t=l},setContainers:l=>{i=l},deleteContainer:l=>{i=i.filter(o=>o.id!==l)},getNextInteractiveTime:(l=ko)=>{if(!i.length||t===null)return null;let o=-1,c=!1;const d=Math.round(t.info.position$.getValue()*1e3);for(const h of i){const u=h.startTime-l;if(u<=d&&(d<=h.endTime||h.endTime===null)){c=!0;break}d<u&&(o=o===-1?u:Math.min(o,u))}return!c&&o!==-1?o:null}}},_t=Fo();class Bo{constructor({player:t,container:e,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:d}){this.hide=()=>{setTimeout(()=>{var h,u,v,m;this.gameState!==x.end&&(Yt(this.container.container.events)&&this.gameState===x.afterInteractive||this.selectBranches.state.isExpect||(this.gameState===x.interactive?this.disabledControls$||(u=(h=this.container).disable)===null||u===void 0||u.call(h):(m=(v=this.container).hide)===null||m===void 0||m.call(v),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})))})},this.show=()=>{var h,u,v,m,g;if(this.gameState===x.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(v=(u=this.container).show)===null||v===void 0||v.call(u),this.disabledControls$||(g=(m=this.container).enable)===null||g===void 0||g.call(m),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!1});else{const f=Ao({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})},onEvent:(p,y)=>{this.isSelectedControlEvent=!0,p!==!1&&(this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})),(this.gameState===x.end||this.gameState===x.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),y(),this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})),_t.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===x.end});this.container.createView(f),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!0}),!((h=this.disabledControls$)===null||h===void 0)&&h.getValue()&&this.container.disable()}},this.onEndOfVideo=()=>{this.gameState=x.end,this.selectContainerEvent(!0)},this.whilePlaying=()=>{var h,u,v,m;if(((h=this.player.experimental.element$.getValue())===null||h===void 0?void 0:h.readyState)<1||[x.destroyed,x.removed].includes(this.gameState)&&!this.isPermanentText)return;const w=this.player.getExactTime();if($o(w,this.container.container))this.gameState!==x.beforeInteractive&&(this.gameState=x.beforeInteractive,this.onBeforeStartTime());else if(Ci(w,this.container.container))this.gameState!==x.interactive&&(this.gameState=x.interactive,this.onStartTime());else if(this.gameState!==x.afterInteractive){const y=this.gameState;this.gameState=x.afterInteractive,y===x.interactive&&this.onEndTime()}else this.gameState!==x.destroyed&&this.removeView();const f=Ci(w,this.container.container),p=this.container.container.startTime?[this.container.container.startTime,(u=this.container.container.endTime)!==null&&u!==void 0?u:1/0]:[];(m=(v=this.container).onProgress)===null||m===void 0||m.call(v,w,f),this.globalEventEmitter.emit(E.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:p,currentTime:w,isInteractiveTime:f})},this.container=e,this.branches=n,this.selectBranches=r,this.subscription=new P.Subscription,this.player=t,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&$n(e.container.controls),this.disabledControls$=d,this.globalEventEmitter=l,this.gameState=x.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)),this.disabledControls$&&this.subscription.add(this.disabledControls$.subscribe(t=>{var e,n,r,s;t?(n=(e=this.container).disable)===null||n===void 0||n.call(e):(s=(r=this.container).enable)===null||s===void 0||s.call(r)}))}selectContainerEvent(t=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:t?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:t}),!t&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const t=Yt(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!t)&&this.removeView()}onBeforeStartTime(){var t,e;(e=(t=this.container).hide)===null||e===void 0||e.call(t),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=x.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.containerRemoved,visibility:!1}),this.gameState=x.removed}destroy(){var t;this.reset(),this.removeView(),this.gameState=x.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!==null&&t!==void 0?t:1/0,id:this.container.container.id}),_t.deleteContainer(this.container.container.id)}}function Do(){const i={};function t(){for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&delete i[o];return!0}function e(o){const c={};for(const d in i)+d<=o&&(c[d]=i[d]);return c}function n(o){const c={};for(const d in i)+d>=o&&(c[d]=i[d]);return c}function r({timestamp:o,priority:c,initiator:d}){var h;if(ui(o)){const u=(h=i[o])!==null&&h!==void 0?h:null;if(u&&Wt(c,!0)){let v={};const m=u[c];if(m&&(v=Object.assign(Object.assign({},v),m)),v=$t(v)?null:v,v&&Wt(d,!0)){const g=v[d];return g!=null?g:null}return v}return u}return null}function s({timestamp:o,priority:c,initiator:d}){if(ui(o))if(i[o]){if(Wt(c,!0))if(i[o][c]){if(Wt(d,!0))if(i[o][c][d]){if(delete i[o][c][d],!$t(i[o][c]))return!0}else return!1;if(delete i[o][c],!$t(i[o]))return!0}else return!1;return delete i[o]}else return!1}function l(o){var c,d,h,{timestamp:u,priority:v,initiator:m}=o,g=st(o,["timestamp","priority","initiator"]);!((d=(c=i[u])===null||c===void 0?void 0:c[v])===null||d===void 0)&&d[m]?i[u][v][m].push(Object.assign({},g)):!((h=i[u])===null||h===void 0)&&h[v]?i[u][v]=Object.assign(Object.assign({},i[u][v]),{[m]:[Object.assign({},g)]}):i[u]?i[u]=Object.assign(Object.assign({},i[u]),{[v]:{[m]:[Object.assign({},g)]}}):i[u]={[v]:{[m]:[Object.assign({},g)]}}}return{map:i,remove:s,add:l,removeAll:t,get:r,getLte:e,getGte:n}}const Wo=[j.expect,j.setNextBranch],Uo=1/0;function _i(i){let t=i,e;const n=Ho(),r=new Do;let s;const l=()=>{v(),f()},o=p=>{r.add.call(void 0,p),m()},c=(p=[])=>{for(const y of p)if(y.action(),Wo.includes(y.actionType))break},d=(p=1/0)=>{var y,C,b;const T=Ht((y=r.get({timestamp:p,priority:"control"}))!==null&&y!==void 0?y:{}),R=Ht((C=r.get({timestamp:p,priority:"container"}))!==null&&C!==void 0?C:{}),V=Ht((b=r.get({timestamp:p,priority:"chapter"}))!==null&&b!==void 0?b:{});return[...T,...R,...V]},h=p=>{n.isReady(p)&&c(d(p))},u=()=>{var p;c([...Ht((p=r.get({timestamp:1/0,priority:"chapter"}))!==null&&p!==void 0?p:{})])},v=()=>{e&&(s==null||s.unsubscribe(),e=void 0)},m=()=>{e||(e=()=>setTimeout(()=>{h(1/0)}),s=t.events.ended$.subscribe(e))},g=p=>{v(),t=p},w=p=>{p.priority==="container"&&n.resetCalled(p.timestamp),r.remove(p)},f=()=>{n.release(),r.removeAll()};return{setPlayer:g,add:o,remove:w,exec:h,execEndOfVideo:u,listen:m,unlisten:v,release:l,containersEventsCallState:n,getPreparedToExecActions:d}}function Ho(){const i=new Map;return{setCalled:({timestamp:l,id:o})=>{const c=i.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(const d of l){const h=(o=d.endTime)!==null&&o!==void 0?o:Uo,u=(c=i.get(h))!==null&&c!==void 0?c:{};i.set(h,Object.assign(Object.assign({},u),{[d.id]:!1}))}},resetCalled:l=>{const o=i.get(l);if(o)for(const c in o)o[c]=!1},isReady:l=>{const o=i.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>i.clear()}}function Ht(i){return Object.values(i).flat().sort(t=>t.actionType===j.expect?-1:1)}const Go=(i,t)=>{const{height:e,width:n}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:r,clientWidth:s}=t.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};const l=e/n,o=r/s;let c,d;return o>l?(d=s,c=s*l):o<l?(d=r/l,c=r):(d=s,c=r),{videoContentWidth:d,videoContentHeight:c}},zo=250;function qo(i){let t=()=>{};const e=new ResizeObserver(o=>{s(o),t=s.bind(null,o)});function n(o){const{parentElement:c,player:d}=i();if(c&&d){const{videoContentWidth:h,videoContentHeight:u}=Go(c,d);c.style.setProperty("--interactive-content-width",`${h}px`),c.style.setProperty("--interactive-content-height",`${u}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function r(){const{parentElement:o}=i();o.removeAttribute("style")}const s=gn(o=>{const{fns:c=[]}=i();n(o);for(const d of c)d()},zo);function l(){t=void 0,e.disconnect(),r()}return{resizeObserver:e,calc:()=>{t()},release:l}}class Ko{constructor(){this.map={}}push(t,e){t in this.map?this.map[t].push(e):this.map[t]=[e]}get(t){const e=this.map[t];return e?e.slice():null}getAll(){const t=[];for(const e in this.map)t.push(...this.map[e]);return t}remove(t,e){t in this.map&&(this.map[t]=this.map[t].filter(n=>n!==e),this.map[t].length===0&&delete this.map[t])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const Qo=i=>Math.floor(Math.random()*i),Yo=i=>{let t=i.length,e=1/0,n=null;for(;t--;)i[t].weight<e&&(e=i[t].weight,n=i[t]);return n},Xo=i=>{let t=i.length,e=-1/0,n=null;for(;t--;)i[t].weight>e&&(e=i[t].weight,n=i[t]);return n},Zo=i=>{const t=i.length,e=Qo(t);return i[e]},wi=1,Jo=i=>{var t,e;let n=0;for(let s=0;s<i.length;++s)n+=(t=i[s].weight)!==null&&t!==void 0?t:wi;const r=Math.random()*n;n=0;for(let s=0;s<i.length-1;++s)if(n+=(e=i[s].weight)!==null&&e!==void 0?e:wi,n>=r)return i[s];return i[i.length-1]},Si=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),ve=(i,t=!1)=>Object.assign(Object.assign({},i),{args:t?Object.assign(Object.assign({},i.args),Si):Object.assign(Object.assign({},Si),i.args)}),Oi=({globalEventEmitter:i,player:t,interactiveEvents:e,removeControllers:n})=>{const r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},l=({action:f,controlType:p,controlId:y,containerId:C,branches:b=[],onEvent:T,isEOV:R=()=>!1,isDisabled:V=()=>!1})=>{const _=ve(f,R()),F={timestamp:1/0,priority:"control",initiator:y,actionType:_.type},U=V(),M=i.emit.bind(i,E.interactives,{subjectId:y,subjectType:p,subjectName:"control",type:U?L.actionChoiceCanceled:L.actionChoice,actionType:f.type,payload:Object.assign({containerId:C},_.args)});if(U){M();return}switch(_.type.trim().toLowerCase()){case j.setNextBranch.trim().toLowerCase():{const Q=b.find(X=>X.id===_.args.branchId);if(!Q)return;T(_.args.isDetachContainer,v.bind(null,{subjectId:y,subjectName:"control"})),M(),_.args.shouldOpenNow?g({subjectId:y,subjectName:"control",subjectType:p,action:_,payload:{chapterId:Q.chapterId,autoSelect:!1}}):(e.add(Object.assign(Object.assign({},F),{action:g.bind(null,{subjectId:y,subjectName:"control",subjectType:p,action:_,payload:{chapterId:Q.chapterId,autoSelect:!1}})})),n==null||n());return}case j.continuePlayback.trim().toLowerCase():{T(_.args.isDetachContainer,v.bind(null,{subjectId:y,subjectName:"control"})),M(),_.args.shouldOpenNow?m({subjectId:y,subjectName:"control",subjectType:p,action:f}):e.add(Object.assign(Object.assign({},F),{action:m.bind(null,{subjectId:y,subjectName:"control",subjectType:p,action:f})}));return}case j.openURI.trim().toLowerCase():{T(_.args.isDetachContainer,v.bind(null,{subjectId:y,subjectName:"control"})),M(),_.args.shouldOpenNow?w({subjectId:y,subjectName:"control",subjectType:p,action:_,payload:{URI:f.args.uri}}):(e.add(Object.assign(Object.assign({},F),{action:w.bind(null,{subjectId:y,subjectName:"control",subjectType:p,action:_,payload:{URI:f.args.uri}})})),n==null||n());return}default:console.error("Unexpected control event"),i.emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:f,container:{id:p,endTime:y},branches:C=[],isEOV:b=!1,autoSelected:T=!1})=>{const R=ve(f,b),V={timestamp:!R.args.shouldOpenNow||b?1/0:y,priority:"container",initiator:p,actionType:R.type},_=i.emit.bind(i,E.interactives,{subjectId:p,subjectName:"container",type:L.actionChoice,actionType:R.type,payload:R.args});switch(R.type.trim().toLowerCase()){case j.setNextBranch.trim().toLowerCase():{const F=C.find(U=>U.id===R.args.branchId);if(!F)return;_(),e.add(Object.assign(Object.assign({},V),{action:g.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{chapterId:F.chapterId,autoSelect:T}})})),n==null||n();return}case j.setMaxWeightBranch.trim().toLowerCase():return;case j.setMinWeightBranch.trim().toLowerCase():return;case j.setRandomBranch.trim().toLowerCase():return;case j.setWeightlessRandomBranch.trim().toLowerCase():return;case j.continuePlayback.trim().toLowerCase():{_(),e.add(Object.assign(Object.assign({},V),{action:m.bind(null,{subjectId:p,subjectName:"container",action:R})}));return}case j.openURI.trim().toLowerCase():{_(),e.add(Object.assign(Object.assign({},V),{action:w.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{URI:f.args.uri}})})),n==null||n();return}default:console.error("Unexpected container event"),i.emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:f,branches:p,isEOV:y=!1}){const C=Ei(f.events);if(C){const b=ve(C.action,y);i.emit(E.interactives,{subjectId:f.id,subjectName:"container",type:L.actionChoice,actionType:b.type,payload:b.args}),e.add({timestamp:y?1/0:f.endTime,priority:"container",initiator:f.id,actionType:j.expect,action:u.bind(null,{subjectId:f.id,subjectName:"container"})}),r.isExpect=!0}else for(const b of f.events)o({action:b.action,container:f,branches:p,isEOV:y})}const d=({chapterId:f,action:p,branches:y=[]})=>{const C=i.emit.bind(i,E.interactives,{subjectId:f,subjectName:"chapter",type:L.actionChoice,actionType:p.type,payload:p.args});switch(p.type.trim().toLowerCase()){case j.setNextBranch.trim().toLowerCase():{const b=y.find(T=>T.id===p.args.branchId);return b!=null&&b.chapterId?(C(),g.bind(null,{subjectId:f,subjectName:"chapter",action:p,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case j.setWeightlessRandomBranch.trim().toLowerCase():{const b=Zo(y);return b!=null&&b.chapterId?(C(),g.bind(null,{subjectId:f,subjectName:"chapter",action:p,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case j.setRandomBranch.trim().toLowerCase():{const b=Jo(y);return b!=null&&b.chapterId?(C(),g.bind(null,{subjectId:f,subjectName:"chapter",action:p,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case j.setMaxWeightBranch.trim().toLowerCase():{const b=Xo(y);return b!=null&&b.chapterId?(C(),g.bind(null,{subjectId:f,subjectName:"chapter",action:p,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case j.setMinWeightBranch.trim().toLowerCase():{const b=Yo(y);return b!=null&&b.chapterId?(C(),g.bind(null,{subjectId:f,subjectName:"chapter",action:p,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case j.continuePlayback.trim().toLowerCase():return C(),m.bind(null,{subjectId:f,subjectName:"chapter",action:p});case j.openURI.trim().toLowerCase():return C(),w.bind(null,{subjectId:f,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:console.error("Unexpected chapter event"),i.emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function h(f){const p=Ei(f.events);if(p){if(Vt(f))return;i.emit(E.interactives,{subjectId:f.id,subjectName:"chapter",type:L.actionChoice,actionType:p.action.type,payload:p.action.args}),e.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:j.expect,action:u.bind(null,{subjectId:f.id,subjectName:"chapter"})})}else f.events.forEach(y=>{const C=d({chapterId:f.id,action:y.action,branches:f.branches});C&&e.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:y.action.type,action:C})})}const u=({subjectId:f,subjectName:p,action:y})=>{var C;t.pause(),i.emit(E.interactives,{subjectId:f,subjectName:p,type:L.actionExecution,actionType:(C=y==null?void 0:y.type)!==null&&C!==void 0?C:j.expect})},v=({subjectId:f,subjectName:p})=>{t.info.isEnded$.getValue()?e.execEndOfVideo():t.play(),i.emit(E.interactives,{subjectId:f,subjectName:p,type:L.actionExecution,actionType:"after-expect"})},m=({subjectId:f,subjectName:p,subjectType:y,action:C})=>{i.emit(E.interactives,{subjectId:f,subjectName:p,subjectType:y,type:L.actionExecution,actionType:C.type})},g=({subjectId:f,subjectName:p,subjectType:y,action:C,payload:b})=>{b.behaviour="change-chapter",i.emit(E.interactives,{subjectId:f,subjectName:p,subjectType:y,type:L.actionExecution,actionType:C.type,payload:b})},w=({subjectId:f,subjectName:p,subjectType:y,action:C,payload:b})=>{if(!b.URI)return;const T=window.open(b.URI,"_blank","noopener,noreferrer");T&&(T.opener=null),i.emit(E.interactives,{subjectId:f,subjectName:p,subjectType:y,type:L.actionExecution,actionType:C.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:d,onExpectEvent:u,expectEventHandler:v,setManifestChapterEvents:h,setManifestContainerEvents:c,stopExpect:s,state:r}},Ie=(i,t)=>{const e={};return i.map(n=>{if(!e[n]){const r=t.chapters.find(l=>l.id===n);if(!r)return null;const s=t.media.videos.find(l=>r.videoId===l.id);if(!s)return null;e[n]=ke(s)}return e[n]}).filter(Boolean)},An=i=>{for(const t of i.variants)if(xn(t)&&"payload"in t)return t.payload.id},xn=i=>i.type==="custom"&&"payload"in i&&i.payload.type==="vk",ke=i=>{const t=An(i);if(!t)return null;const e=t.split("_").pop();return e?parseInt(e,10):null},Pn=(i,t)=>{for(const e of i.media.videos)if(t===ke(e)){for(const n of i.chapters)if(n.videoId===e.id)return n.id;return}},Ln=(i,t)=>i.reduce((e,n)=>{const r=Pn(t,n);return r?[...e,r]:e},[]);var et,mt,G,_e,it,bt,Z,gt;class tl{constructor({globalEventEmitter:t,videoId:e,interactiveController:n,historyApi:r}){var s,l,o;this.state={history$:new P.ValueSubject([]),hasPrevChapter$:new P.ValueSubject(!1),prevChapter$:new P.ValueSubject(null),isInitialChapter$:new P.ValueSubject(!1)},et.set(this,null),mt.set(this,!1),G.set(this,null),_e.set(this,null),it.set(this,null),bt.set(this,null),Z.set(this,null),gt.set(this,new P.Subscription),I(this,it,e,"f"),I(this,Z,t,"f"),I(this,bt,n,"f"),I(this,et,r,"f"),!((s=this.state)===null||s===void 0)&&s.history$&&a(this,gt,"f")&&((l=a(this,gt,"f"))===null||l===void 0||l.add((o=this.state)===null||o===void 0?void 0:o.history$.subscribe(c=>{var d,h,u,v,m;(d=this.state)===null||d===void 0||d.prevChapter$.next(be(c,-2)||null),(h=this.state)===null||h===void 0||h.hasPrevChapter$.next(c.length>1),(u=this.state)===null||u===void 0||u.isInitialChapter$.next(this.getInitialChapterId()===((m=(v=a(this,G,"f"))===null||v===void 0?void 0:v.metadata)===null||m===void 0?void 0:m.initChapterId))})))}setManifest(t){return A(this,void 0,void 0,function*(){!a(this,bt,"f")||!a(this,Z,"f")||(I(this,G,t,"f"),yield this.getProjectHistory(),yield a(this,bt,"f").setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,mt,"f")||(I(this,mt,!0,"f"),a(this,Z,"f").emit(E.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,mt,"f")}updateHistory(t,e=!0){var n,r;return A(this,void 0,void 0,function*(){if(!a(this,G,"f")||!a(this,it,"f"))return;const s=a(this,G,"f"),l=Ie(t,s);if(I(this,_e,l,"f"),(n=this===null||this===void 0?void 0:this.state)===null||n===void 0||n.history$.next(t),!(!e||!a(this,et,"f")))try{yield a(this,et,"f").save(a(this,it,"f"),l)}catch(o){(r=a(this,Z,"f"))===null||r===void 0||r.emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.HISTORY,"Unable to save interactive history"))}})}getProjectHistory(){var t,e;return A(this,void 0,void 0,function*(){if(!a(this,G,"f")||!a(this,it,"f"))return;const n=a(this,G,"f");let r=[this.getInitialVideoId()];if(a(this,et,"f"))try{const l=yield a(this,et,"f").get(a(this,it,"f"));l.length&&(r=l)}catch(l){(t=a(this,Z,"f"))===null||t===void 0||t.emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.HISTORY,"Error while trying to fetch data"))}const s=Ln(r,n);(e=this===null||this===void 0?void 0:this.state)===null||e===void 0||e.history$.next(s)})}getInitialChapterId(){var t,e;const n=(t=this.state)===null||t===void 0?void 0:t.history$.getValue();return be(n,-1)||((e=a(this,G,"f"))===null||e===void 0?void 0:e.metadata.initChapterId)}getInitialVideoId(){if(a(this,G,"f")){const t=this.getInitialChapterId();return Ie([t],a(this,G,"f")).pop()}return null}destroy(){var t,e;this.state=null,I(this,it,null,"f"),I(this,et,null,"f"),I(this,bt,null,"f"),(t=a(this,gt,"f"))===null||t===void 0||t.unsubscribe(),I(this,gt,null,"f"),I(this,mt,!1,"f"),(e=a(this,Z,"f"))===null||e===void 0||e.emit(E.historyDestroyed),I(this,Z,null,"f")}}et=new WeakMap,mt=new WeakMap,G=new WeakMap,_e=new WeakMap,it=new WeakMap,bt=new WeakMap,Z=new WeakMap,gt=new WeakMap;var Ot,Vn,we,Ti;class J{constructor(t,e,n,r){this.target=t,this.type=e,this.listener=n,this.options=a(J,Ot,"m",Vn).call(J,t,r),this.target.addEventListener(e,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}}Ot=J,Vn=function(t,e){if(e===void 0)return!1;if(typeof e=="boolean")return e;{const n=new Set(["passive","capture"]),r=Object.keys(e).filter(l=>!n.has(l));return r.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+r.join(",")),a(J,Ot,"m",Ti).call(J,t)?e:e.capture||!1}},Ti=function(t){let e=a(J,Ot,"f",we);if(e===void 0){e=!1;try{const n={},r={get:()=>(e=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);const s=()=>{};t.addEventListener("test",s,n),t.removeEventListener("test",s,n)}catch(n){e=!1}I(J,Ot,e,"f",we)}return e||!1};we={value:void 0};class el{constructor(){this.bindingMap=new Ko}release(){this.removeAll(),this.bindingMap=null}listen(t,e,n,r){if(!this.bindingMap)return;const s=new J(t,e,n,r);this.bindingMap.push(e,s)}listenOnce(t,e,n,r){const s=l=>{this.unlisten(t,e,s),n(l)};this.listen(t,e,s,r)}unlisten(t,e,n){if(!this.bindingMap)return;const r=this.bindingMap.get(e)||[];for(const s of r)s.target===t&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(e,s))}removeAll(){if(!this.bindingMap)return;const t=this.bindingMap.getAll();for(const e of t)e.unlisten();this.bindingMap.clear()}}class il{constructor(){this._prevSizeId=0,this.rootElement=document.createElement("canvas")}clear(){var t;(t=this.rootElement.getContext("2d"))===null||t===void 0||t.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var t;const e=(t=this.rootElement.getContext("2d"))===null||t===void 0?void 0:t.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;const n=e.data,r=n.length;for(let s=3;s<r;s+=40)if(n[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(t){this.canvasImgSrc=t}draw(){var t;this.canvasImgSrc&&((t=this.rootElement.getContext("2d"))===null||t===void 0||t.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(t,e=!1){return A(this,void 0,void 0,function*(){const n=t.width+t.height;if(this._prevSizeId===n)return;let r;e&&(r=yield this.save()),this.rootElement.width=t.width,this.rootElement.height=t.height,e&&r&&this.restore(r),this._prevSizeId=n})}save(){return A(this,void 0,void 0,function*(){const t=this.rootElement.toDataURL("image/jpeg",1),e=new Image;return e.crossOrigin="anonymous",e.src=t,yield e.decode(),e})}restore(t){var e;this.rootElement&&((e=this.rootElement.getContext("2d"))===null||e===void 0||e.drawImage(t,0,0,this.rootElement.width,this.rootElement.height))}}class nl{constructor({parentElement:t,endOffsetMs:e=250,onError:n}){this.currentVideoDurationMs=1/0,this._containerTimeFrameShouldReceived=!1,this._endTimeFrameReceived=!1,this._shouldCallSkip=!1,this.onEachTick=r=>{const s=r!=null?r:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,l=this.isChapterEndTime(s);if(this.isContainerTime(s))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(l)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}},this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())},this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new il,this.endOffsetMs=e,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),
|
|
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(t){this.currentVideoDurationMs=t}setVideoElement(t){this.lastFrameCanvas.setCanvasImageSource(t)}setCurrentChapter(t){this.currentChapter=t}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(t=!1){return A(this,void 0,void 0,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(t=!1);const e=getComputedStyle(this.rootElement),n={width:parseInt(e.getPropertyValue("--interactive-content-width"),10),height:parseInt(e.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,t)}catch(r){this._onError(r)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(t){return this.currentVideoDurationMs&&t>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(t){if(this.currentChapter)return this.currentChapter.containers.some(e=>{var n,r,s;return((n=e.controls)===null||n===void 0?void 0:n.length)&&t>=((r=e.startTime)!==null&&r!==void 0?r:0)&&t<=Math.min((s=e.endTime)!==null&&s!==void 0?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(t){var e,n;(n=(e=this._callbacks)===null||e===void 0?void 0:e.onError)===null||n===void 0||n.call(e,t)}}function rl(i=0){return new Promise(t=>{setTimeout(()=>{t(0)},i)})}var N,lt,q,ct,W,rt,D,H,nt,$,dt,Rt,B,Tt,k,O,Nn,ji,qt,Mn,Se,$i,Oe,It,jt,Ri,Te,Ai,kn;const sl=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,historyApi:null,projectInfo:{},initSeamless:!1,lastFrame:!1,permanentTextControls:!0,disableControlsOnPause:!0}),tt=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function al(){const i=document.createElement("div");return i.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,t}class Do{constructor(e){V.add(this),ne.set(this,null),q.set(this,null),re.set(this,null),J.set(this,null),D.set(this,null),U.set(this,null),Z.set(this,null),j.set(this,null),se.set(this,new L.ValueSubject(!1)),_e.set(this,new Set),B.set(this,null),ge.set(this,null),F.set(this,null),O.set(this,null),this.state={history$:new L.ValueSubject([]),hasPrevChapter$:new L.ValueSubject(!1),prevChapter$:new L.ValueSubject(null),isInitialChapter$:new L.ValueSubject(!1),isEndChapter$:new L.ValueSubject(!1),calledByInteractive$:new L.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new L.ValueSubject(!1),disabledControls$:new L.ValueSubject(!1)},this.emitPlayerChanged=i=>{o(this,O,"f").emit(C.playerChanged,i)},mn.set(this,()=>{o(this,U,"f").fns.forEach(r=>r());const i=this.options.player.info.position$.getValue()*1e3,n=(o(this,j,"f").chapter.containers||[]).filter(r=>r.startTime>=Math.floor(i));for(const r of n){o(this,D,"f").remove({timestamp:1/0,priority:"container",initiator:r.id});for(const s of r.controls)o(this,D,"f").remove({timestamp:1/0,priority:"control",initiator:s.id});o(this,q,"f").find(s=>s.container.container.id===r.id).reset()}}),ut.set(this,()=>{o(this,ne,"f").calc(),o(this,U,"f").requestAnimation()}),ve.set(this,(i=!0)=>{o(this,q,"f").forEach(n=>{!i&&n.isPermanentText||(o(this,U,"f").removeFn(n.whilePlaying),n.destroy())})}),this.options=Object.assign(Object.assign({},ko),e),w(this,q,[],"f"),this.factories=new Map([["choice",ji]]),this.rootElement=Bo(),this.options.parentElement.append(this.rootElement),w(this,O,new dn,"f"),w(this,J,new L.Subscription,"f"),w(this,re,new No,"f"),this.options.lastFrame&&w(this,F,new Vo({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:i=>o(this,O,"f").emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.SEAMLESS,i))}),"f"),o(this,re,"f").listen(this.rootElement,"mousedown",i=>i.stopPropagation()),o(this,re,"f").listen(this.rootElement,"mouseup",i=>i.stopPropagation()),w(this,j,new pn(this.options.loaders,i=>o(this,O,"f").emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.MANIFEST,i))),"f"),w(this,D,di(this.options.player),"f"),w(this,U,new Za,"f"),w(this,Z,fi({player:this.options.player,interactiveEvents:o(this,D,"f"),globalEventEmitter:o(this,O,"f"),removeControllers:o(this,ve,"f")}),"f"),w(this,ne,jo(()=>{var i;return{player:(i=this.options)===null||i===void 0?void 0:i.player,parentElement:this.options.parentElement,fns:this.options.lastFrame?[()=>{o(this,F,"f").updateCanvasDimensions(!0)}]:[]}}),"f"),this.options.graph&&w(this,B,new Ma({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),o(this,O,"f").emit(C.graph,{type:dt.watchAgainClicked,chapterId:i})},onError:i=>o(this,O,"f").emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.LOADERS,{message:i}))}),"f"),o(this,O,"f").on(C.interactives,i=>{var n,r;if(i.type===x.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((n=i.payload)===null||n===void 0?void 0:n.behaviour)==="change-chapter"){const{chapterId:s}=i.payload;this.setChapter({chapterId:s})}if(((r=i.payload)===null||r===void 0?void 0:r.behaviour)==="change-manifest"){const{manifestURL:s}=i.payload;this.setManifest(s)}}}),o(this,O,"f").on(C.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}),this.isFirstChapterFetched=!1,this.appState=X.created}initSeamless({source:e,initialChapter:i,visitedChapters:n=[],videosInfo:r}){return N(this,void 0,void 0,function*(){w(this,ge,bo(this),"f");const s=document.createElement("div");this.state.history$.next(n),o(this,ge,"f").on(Ve.activePlayerChanged,this.emitPlayerChanged);const{player:c,config:a}=yield o(this,ge,"f").init({source:e,initialChapter:i,container:s});return this.setVisitedChapters(n),this.updateGraphVideosInfo(r),{player:c,config:a}})}getStatEvents(){return{click$:new L.Observable(e=>{o(this,O,"f").on(C.graph,({type:i,visibility:n})=>{i==="visibility"&&e.next(n?exports.INTERACTIVE_CLICK_ACTIONS.OPEN_GRAPH:exports.INTERACTIVE_CLICK_ACTIONS.CLOSE_GRAPH),i==="watchAgainClicked"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.WATCH_AGAIN)}),o(this,O,"f").on(C.interactives,({type:i,subjectName:n,subjectType:r})=>{i!=="action-choice"||n!=="control"||(r==="Button"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_BUTTON),r==="Area"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_AREA))})}),nextMovie$:new L.Observable(e=>{o(this,O,"f").on(C.playerChanged,({config:i})=>{i!=null&&i.unitedVideoId&&e.next(i.unitedVideoId)})})}}setPlayer(e){o(this,V,"m",Fe).call(this),this.options.player=e,pe.setPlayer(this.options.player),o(this,D,"f")?o(this,D,"f").setPlayer(this.options.player):w(this,D,di(this.options.player),"f"),w(this,Z,fi({player:this.options.player,interactiveEvents:o(this,D,"f"),globalEventEmitter:o(this,O,"f"),removeControllers:()=>o(this,ve,"f").call(this,!1)}),"f"),this.appState===X.initiated&&(o(this,V,"m",ft).call(this),o(this,V,"m",Ee).call(this,o(this,j,"f").chapter))}setManifest(e){return N(this,void 0,void 0,function*(){o(this,V,"m",Fe).call(this),this.isFirstChapterFetched=!1;const i=yield o(this,j,"f").setManifest(e);return o(this,B,"f")&&(yield o(this,B,"f").handleManifestChange(i.manifest)),o(this,O,"f").emit(C.manifestChanged,{manifest:i.manifest}),o(this,V,"m",Ee).call(this,o(this,j,"f").chapter),i.manifest})}setVisitedChapters(e){var i;Array.isArray(e)&&((i=o(this,B,"f"))===null||i===void 0||i.setVisitedChapters(e))}updateGraphVideosInfo(e){var i;Array.isArray(e)&&((i=o(this,B,"f"))===null||i===void 0||i.updateVideosInfo(e))}setChapter({chapterId:e}={}){var i;return N(this,void 0,void 0,function*(){o(this,V,"m",Fe).call(this),o(this,F,"f")&&this.isFirstChapterFetched&&(o(this,F,"f").draw(),o(this,F,"f").show()),L.getCurrentBrowser().browser===L.CurrentClientBrowser.Safari&&(yield Fo(35));const r=yield e?o(this,j,"f").setNext(e):o(this,j,"f").setInitial(),{chapter:s,media:c,graph:a}=r;return o(this,V,"m",bn).call(this,s.id),this.state.isInitialChapter$.next(o(this,j,"f").isInitialChapter()),this.state.isEndChapter$.next(o(this,j,"f").isEndChapter()),o(this,B,"f")&&o(this,B,"f").handleChapterChange(a),(i=o(this,F,"f"))===null||i===void 0||i.setCurrentChapter(this.getCurrentChapter().chapter),o(this,O,"f").emit(C.chapterChanged,{chapter:s,media:c,graph:a}),o(this,V,"m",Ee).call(this,o(this,j,"f").chapter),w(this,_e,new Set,"f"),this.isFirstChapterFetched=!0,{chapter:s,media:c,graph:a}})}toggleGraphView(e=!0){o(this,B,"f")&&(e?(o(this,B,"f").show(),o(this,se,"f").next(!1)):(o(this,B,"f").hide(),o(this,V,"m",vt).call(this)),o(this,O,"f").emit(C.graph,{type:dt.visibility,visibility:e}))}init(){o(this,j,"f").chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===X.created&&(o(this,ne,"f").resizeObserver.observe(this.options.fullscreenTargetElement),o(this,V,"m",ft).call(this),this.appState=X.initiated,o(this,V,"m",Ee).call(this,o(this,j,"f").chapter))}playPrevChapter(){const e=this.state.history$.getValue();if(e.length>1){e.pop();const i=sn(e,-1);this.state.history$.next(e),this.setChapter({chapterId:i})}}setDisabledControls(e){this.options.disableControlsOnPause?o(this,O,"f").emit(C.errors,new $($.Severity.RECOVERABLE,$.Category.INTERACTIVES,"To disable controls set disableControlsOnPause option to false")):this.state.disabledControls$.next(e)}isSupport(e=o(this,j,"f").manifest){return _t(e.metadata.version)}getIsSeekable(){return o(this,se,"f")}getInteractiveRanges(){var e;return fo((e=o(this,j,"f").chapter)===null||e===void 0?void 0:e.containers)}getNextInteractiveStartTime(e){return pe.getNextInteractiveTime(e)}getChapterBranches(e){return o(this,j,"f").getBranches(e)}getCurrentChapter(){return o(this,j,"f").getCurrent()}getCurrentManifest(){return o(this,j,"f").manifest}addFactory(e,i){this.factories.set(e.trim().toLowerCase(),i)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return o(this,O,"f").on(...e),this}off(...e){return o(this,O,"f").off(...e),this}once(...e){return o(this,O,"f").once(...e),this}destroy(){var e,i;o(this,ve,"f").call(this),w(this,q,void 0,"f"),this.state=void 0,(e=o(this,B,"f"))===null||e===void 0||e.destroy(),w(this,B,void 0,"f"),o(this,ne,"f").release(),w(this,ne,void 0,"f"),w(this,Z,void 0,"f"),o(this,U,"f").release(),w(this,U,void 0,"f"),o(this,D,"f").release(),w(this,D,void 0,"f"),o(this,j,"f").release(),w(this,Z,void 0,"f"),o(this,re,"f").release(),w(this,re,void 0,"f"),o(this,J,"f").unsubscribe(),w(this,J,void 0,"f"),o(this,O,"f").reset(),w(this,O,void 0,"f"),(i=o(this,F,"f"))===null||i===void 0||i.destroy(),w(this,F,void 0,"f"),this.rootElement.remove(),this.rootElement=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=X.destroyed}}ne=new WeakMap,q=new WeakMap,re=new WeakMap,J=new WeakMap,D=new WeakMap,U=new WeakMap,Z=new WeakMap,j=new WeakMap,se=new WeakMap,_e=new WeakMap,B=new WeakMap,ge=new WeakMap,F=new WeakMap,O=new WeakMap,mn=new WeakMap,ut=new WeakMap,ve=new WeakMap,V=new WeakSet,Fe=function(){var e;this.appState===X.ready&&(o(this,ve,"f").call(this),w(this,q,[],"f"),o(this,U,"f").release(),(e=o(this,D,"f"))===null||e===void 0||e.release(),this.appState=X.initiated,o(this,se,"f").next(!1))},pi=function(e){(!o(this,B,"f")||o(this,B,"f").isHidden)&&o(this,V,"m",vt).call(this);const i=e*1e3,r=this.getInteractiveRanges().findLast(({range:s})=>i>=s[1]);if(r){const s=r.range.join("-");o(this,_e,"f").has(s)||(o(this,_e,"f").add(s),o(this,O,"f").emit(C.interactives,{type:x.rangeEnded,payload:r,visibility:!0}))}},ft=function(){o(this,J,"f").unsubscribe(),o(this,J,"f").add(this.options.player.events.started$.pipe(L.once()).subscribe(o(this,ut,"f"))).add(this.options.player.events.playing$.subscribe(o(this,U,"f").requestAnimation)).add(this.options.player.events.willPause$.subscribe(o(this,U,"f").cancelAnimation)).add(this.options.player.info.position$.subscribe(o(this,V,"m",pi).bind(this))).add(this.state.history$.subscribe(e=>{this.state.hasPrevChapter$.next(e.length>1)})).add(o(this,j,"f").prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))),this.options.lastFrame&&o(this,J,"f").add(this.options.player.info.duration$.subscribe(e=>{o(this,F,"f").setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&o(this,F,"f").setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{o(this,F,"f").reset(),setTimeout(()=>{o(this,F,"f").hide(),o(this,F,"f").lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(o(this,F,"f").onSeek))},Ee=function(e){o(this,j,"f").chapter&&this.appState===X.initiated&&(o(this,Z,"f").setManifestChapterEvents(e),w(this,q,o(this,V,"m",yi).call(this,e),"f"),o(this,D,"f").containersEventsCallState.setData(e.containers),pe.setContainers(o(this,q,"f").map(i=>i.container.container).filter(i=>!vn(i.controls))),this.options.lastFrame&&o(this,U,"f").addFn(()=>{o(this,F,"f").onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.appState=X.ready)},yi=function(e){var i,n;return(n=(i=e==null?void 0:e.containers)===null||i===void 0?void 0:i.reduce((r,s)=>{const c=s.type.trim().toLowerCase(),a=this.factories.get(c);if(a){const l=new Co({player:this.options.player,container:a(s,this.rootElement),branches:o(this,j,"f").chapter.branches,selectBranches:o(this,Z,"f"),interactiveEvents:o(this,D,"f"),globalEventEmitter:o(this,O,"f"),ignoreContainerEvent:()=>vo(s,o(this,q,"f")),permanentTextControls:this.options.permanentTextControls,disabledControls:this.options.disableControlsOnPause?void 0:this.state.disabledControls$});return o(this,U,"f").addFn(l.whilePlaying,!0),[...r,l]}return[...r]},[]))!==null&&n!==void 0?n:[]},vt=function(){const e=o(this,se,"f").getValue(),i=!!pe.getNextInteractiveTime();(i&&!e||!i&&e)&&o(this,se,"f").next(!e)},mi=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},bn=function(e){var i;o(this,V,"m",mi).call(this);const n=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),r=this.state.prevChapter$.getValue(),s=(i=r&&St(r)&&lo(r))!==null&&i!==void 0?i:!1;if(o(this,j,"f").manifest.metadata.initChapterId===e||s&&n){this.state.history$.next([e]);return}const a=this.state.history$.getValue();sn(a,-1)!==e&&this.state.history$.next([...a,e])};const Wo={Container:Ti,createChoiceContainer:ji,createAreaControl:wi,createButtonControl:Si,createRelativeLayout:Fn,getRootEl:gi,classnamesPrefix:z},Uo={version:Rn};exports.CustomError=$;exports.EVENT_NAMES=C;exports.Interactives=Do;exports.ManifestController=pn;exports.SDKInfo=Uo;exports.compareVersions=Ie;exports.graphEventTypes=dt;exports.interactivesEventTypes=x;exports.isSupportedManifest=_t;exports.utils=Wo;
|
|
23
|
+
`,i}class ol{constructor(t){N.add(this),lt.set(this,null),q.set(this,null),ct.set(this,null),W.set(this,null),rt.set(this,null),D.set(this,null),H.set(this,null),nt.set(this,null),$.set(this,null),dt.set(this,new P.ValueSubject(!1)),Rt.set(this,new Set),B.set(this,null),Tt.set(this,null),k.set(this,null),O.set(this,null),this.state={prevChapter$:new P.ValueSubject(null),isInitialChapter$:new P.ValueSubject(!1),isEndChapter$:new P.ValueSubject(!1),calledByInteractive$:new P.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new P.ValueSubject(!1),disabledControls$:new P.ValueSubject(!1)},this.emitPlayerChanged=e=>{a(this,O,"f").emit(E.playerChanged,e)},Mn.set(this,()=>{a(this,H,"f").fns.forEach(r=>r());const e=this.options.player.info.position$.getValue()*1e3,n=(a(this,$,"f").chapter.containers||[]).filter(r=>r.startTime>=Math.floor(e));for(const r of n){a(this,D,"f").remove({timestamp:1/0,priority:"container",initiator:r.id});for(const s of r.controls)a(this,D,"f").remove({timestamp:1/0,priority:"control",initiator:s.id});a(this,q,"f").find(s=>s.container.container.id===r.id).reset()}}),Se.set(this,()=>{a(this,lt,"f").calc(),a(this,H,"f").requestAnimation()}),It.set(this,(e=!0)=>{a(this,q,"f").forEach(n=>{!e&&n.isPermanentText||(a(this,H,"f").removeFn(n.whilePlaying),n.destroy())})}),this.options=Object.assign(Object.assign({},sl),t),I(this,q,[],"f"),this.factories=new Map([["choice",Wi]]),this.rootElement=al(),this.options.parentElement.append(this.rootElement),I(this,O,new wn,"f"),I(this,rt,new P.Subscription,"f"),I(this,ct,new el,"f"),I(this,W,new tl({interactiveController:this,globalEventEmitter:a(this,O,"f"),videoId:this.options.projectInfo.videoId,historyApi:this.options.historyApi}),"f"),this.options.lastFrame&&I(this,k,new nl({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:e=>a(this,O,"f").emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.SEAMLESS,e))}),"f"),a(this,ct,"f").listen(this.rootElement,"mousedown",e=>e.stopPropagation()),a(this,ct,"f").listen(this.rootElement,"mouseup",e=>e.stopPropagation()),I(this,$,new Rn(this.options.loaders,e=>a(this,O,"f").emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.MANIFEST,e))),"f"),I(this,D,_i(this.options.player),"f"),I(this,H,new go,"f"),I(this,nt,Oi({player:this.options.player,interactiveEvents:a(this,D,"f"),globalEventEmitter:a(this,O,"f"),removeControllers:a(this,It,"f")}),"f"),I(this,lt,qo(()=>{var e;return{player:(e=this.options)===null||e===void 0?void 0:e.player,parentElement:this.options.parentElement,fns:this.options.lastFrame?[()=>{a(this,k,"f").updateCanvasDimensions(!0)}]:[]}}),"f"),this.options.graph&&I(this,B,new io({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:e=>{this.setChapter({chapterId:e}),a(this,O,"f").emit(E.graph,{type:Ee.watchAgainClicked,chapterId:e})},onError:e=>a(this,O,"f").emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.LOADERS,{message:e}))}),"f"),a(this,N,"m",Nn).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=tt.created}getStatEvents(){return{click$:new P.Observable(t=>{a(this,O,"f").on(E.graph,({type:e,visibility:n})=>{e==="visibility"&&t.next(n?exports.INTERACTIVE_CLICK_ACTIONS.OPEN_GRAPH:exports.INTERACTIVE_CLICK_ACTIONS.CLOSE_GRAPH),e==="watchAgainClicked"&&t.next(exports.INTERACTIVE_CLICK_ACTIONS.WATCH_AGAIN)}),a(this,O,"f").on(E.interactives,({type:e,subjectName:n,subjectType:r})=>{e!=="action-choice"||n!=="control"||(r==="Button"&&t.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_BUTTON),r==="Area"&&t.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_AREA))})}),nextMovie$:new P.Observable(t=>{a(this,O,"f").on(E.playerChanged,({config:e})=>{e!=null&&e.unitedVideoId&&t.next(e.unitedVideoId)})})}}setPlayer(t){a(this,N,"m",qt).call(this),this.options.player=t,_t.setPlayer(this.options.player),a(this,D,"f")?a(this,D,"f").setPlayer(this.options.player):I(this,D,_i(this.options.player),"f"),I(this,nt,Oi({player:this.options.player,interactiveEvents:a(this,D,"f"),globalEventEmitter:a(this,O,"f"),removeControllers:()=>a(this,It,"f").call(this,!1)}),"f"),this.appState===tt.initiated&&(a(this,N,"m",Oe).call(this),a(this,N,"m",jt).call(this,a(this,$,"f").chapter))}setManifest(t){return A(this,void 0,void 0,function*(){a(this,N,"m",qt).call(this),this.isFirstChapterFetched=!1;const e=yield a(this,$,"f").setManifest(t);return a(this,B,"f")&&(yield a(this,B,"f").handleManifestChange(e.manifest)),yield a(this,W,"f").setManifest(e.manifest),a(this,O,"f").emit(E.manifestChanged,{manifest:e.manifest}),a(this,N,"m",jt).call(this,a(this,$,"f").chapter),e.manifest})}setVisitedChapters(t){var e;Array.isArray(t)&&((e=a(this,B,"f"))===null||e===void 0||e.setVisitedChapters(t))}updateGraphVideosInfo(t){var e;Array.isArray(t)&&((e=a(this,B,"f"))===null||e===void 0||e.updateVideosInfo(t))}setChapter({chapterId:t,pushToHistory:e=!0}={}){var n;return A(this,void 0,void 0,function*(){a(this,N,"m",qt).call(this),a(this,k,"f")&&this.isFirstChapterFetched&&(a(this,k,"f").draw(),a(this,k,"f").show()),P.getCurrentBrowser().browser===P.CurrentClientBrowser.Safari&&(yield rl(35));const s=yield t?a(this,$,"f").setNext(t):a(this,$,"f").setInitial(),{chapter:l,media:o,graph:c}=s;return e&&a(this,N,"m",kn).call(this,l.id),this.state.isInitialChapter$.next(a(this,$,"f").isInitialChapter()),this.state.isEndChapter$.next(a(this,$,"f").isEndChapter()),a(this,B,"f")&&a(this,B,"f").handleChapterChange(c),(n=a(this,k,"f"))===null||n===void 0||n.setCurrentChapter(this.getCurrentChapter().chapter),a(this,O,"f").emit(E.chapterChanged,{chapter:l,media:o,graph:c}),a(this,N,"m",jt).call(this,a(this,$,"f").chapter),I(this,Rt,new Set,"f"),this.isFirstChapterFetched=!0,{chapter:l,media:o,graph:c}})}toggleGraphView(t=!0){a(this,B,"f")&&(t?(a(this,B,"f").show(),a(this,dt,"f").next(!1)):(a(this,B,"f").hide(),a(this,N,"m",Te).call(this)),a(this,O,"f").emit(E.graph,{type:Ee.visibility,visibility:t}))}init(){a(this,$,"f").chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===tt.created&&(a(this,lt,"f").resizeObserver.observe(this.options.fullscreenTargetElement),a(this,N,"m",Oe).call(this),this.appState=tt.initiated,a(this,N,"m",jt).call(this,a(this,$,"f").chapter))}deadEndCheck(){var t,e;return!((e=(t=a(this,D,"f"))===null||t===void 0?void 0:t.getPreparedToExecActions())!==null&&e!==void 0?e:[]).some(s=>s.actionType===j.setNextBranch)}allControlsAreRemoved(){return!a(this,q,"f").some(e=>!e.container.isRemoved)}playPrevChapter(){const t=[...a(this,W,"f").state.history$.getValue()];if(t.length>1){t.pop();const e=be(t,-1);a(this,W,"f").updateHistory(t),this.setChapter({chapterId:e})}}setDisabledControls(t){this.options.disableControlsOnPause?a(this,O,"f").emit(E.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,"To disable controls set disableControlsOnPause option to false")):this.state.disabledControls$.next(t)}isSupport(t=a(this,$,"f").manifest){return Ve(t.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,W,"f").getInitialVideoId(),chapterId:a(this,W,"f").getInitialChapterId()}}getHistoryState(){return a(this,W,"f").state}getIsSeekable(){return a(this,dt,"f")}getInteractiveRanges(){var t;return xo((t=a(this,$,"f").chapter)===null||t===void 0?void 0:t.containers)}getNextInteractiveStartTime(t){return _t.getNextInteractiveTime(t)}getChapterBranches(t){return a(this,$,"f").getBranches(t)}getCurrentChapter(){return a(this,$,"f").getCurrent()}getCurrentManifest(){return a(this,$,"f").manifest}addFactory(t,e){this.factories.set(t.trim().toLowerCase(),e)}removeFactory(t){this.factories.delete(t.trim().toLowerCase())}on(...t){return a(this,O,"f").on(...t),this}off(...t){return a(this,O,"f").off(...t),this}once(...t){return a(this,O,"f").once(...t),this}destroy(){var t,e;a(this,It,"f").call(this),I(this,q,void 0,"f"),this.state=void 0,(t=a(this,B,"f"))===null||t===void 0||t.destroy(),I(this,B,void 0,"f"),a(this,lt,"f").release(),I(this,lt,void 0,"f"),I(this,nt,void 0,"f"),a(this,H,"f").release(),I(this,H,void 0,"f"),a(this,D,"f").release(),I(this,D,void 0,"f"),a(this,$,"f").release(),I(this,nt,void 0,"f"),a(this,ct,"f").release(),I(this,ct,void 0,"f"),a(this,rt,"f").unsubscribe(),I(this,rt,void 0,"f"),a(this,O,"f").reset(),I(this,O,void 0,"f"),(e=a(this,k,"f"))===null||e===void 0||e.destroy(),I(this,k,void 0,"f"),this.rootElement.remove(),this.rootElement=void 0,a(this,W,"f").destroy(),I(this,W,void 0,"f"),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=tt.destroyed}}lt=new WeakMap,q=new WeakMap,ct=new WeakMap,W=new WeakMap,rt=new WeakMap,D=new WeakMap,H=new WeakMap,nt=new WeakMap,$=new WeakMap,dt=new WeakMap,Rt=new WeakMap,B=new WeakMap,Tt=new WeakMap,k=new WeakMap,O=new WeakMap,Mn=new WeakMap,Se=new WeakMap,It=new WeakMap,N=new WeakSet,Nn=function(t=!1){a(this,O,"f").on(E.historyInited,({initChapterId:e,videosInfo:n=[]})=>A(this,void 0,void 0,function*(){t&&(yield a(this,N,"m",ji).call(this,{initialChapter:e,videosInfo:n}))})),a(this,O,"f").on(E.interactives,e=>A(this,void 0,void 0,function*(){var n,r;if(e.type===L.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((n=e.payload)===null||n===void 0?void 0:n.behaviour)==="change-chapter"){const{chapterId:s}=e.payload;this.setChapter({chapterId:s})}if(((r=e.payload)===null||r===void 0?void 0:r.behaviour)==="change-manifest"){const{manifestURL:s}=e.payload;this.setManifest(s)}}})),a(this,O,"f").on(E.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},ji=function({source:t,videosInfo:e=[]}){return A(this,void 0,void 0,function*(){I(this,Tt,Mo(this),"f");const n=document.createElement("div");a(this,Tt,"f").on(zt.activePlayerChanged,this.emitPlayerChanged);const{player:r,config:s}=yield a(this,Tt,"f").init({source:t,initialChapter:a(this,W,"f").getInitialChapterId(),container:n});return this.updateGraphVideosInfo(e),{player:r,config:s}})},qt=function(){var t;this.appState===tt.ready&&(a(this,It,"f").call(this),I(this,q,[],"f"),a(this,H,"f").release(),(t=a(this,D,"f"))===null||t===void 0||t.release(),this.appState=tt.initiated,a(this,dt,"f").next(!1))},$i=function(t){(!a(this,B,"f")||a(this,B,"f").isHidden)&&a(this,N,"m",Te).call(this);const e=t*1e3,r=this.getInteractiveRanges().findLast(({range:s})=>e>=s[1]);if(r){const s=r.range.join("-");a(this,Rt,"f").has(s)||(a(this,Rt,"f").add(s),a(this,O,"f").emit(E.interactives,{type:L.rangeEnded,payload:r,visibility:!0}))}},Oe=function(){a(this,rt,"f").unsubscribe(),a(this,rt,"f").add(this.options.player.events.started$.pipe(P.once()).subscribe(a(this,Se,"f"))).add(this.options.player.events.playing$.subscribe(a(this,H,"f").requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,H,"f").cancelAnimation)).add(this.options.player.info.position$.subscribe(a(this,N,"m",$i).bind(this))).add(a(this,$,"f").prevChapter$.subscribe(t=>this.state.prevChapter$.next(t))),this.options.lastFrame&&a(this,rt,"f").add(this.options.player.info.duration$.subscribe(t=>{a(this,k,"f").setVideoDuration(t*1e3)})).add(this.options.player.experimental.element$.subscribe(t=>{t&&a(this,k,"f").setVideoElement(t)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,k,"f").reset(),setTimeout(()=>{a(this,k,"f").hide(),a(this,k,"f").lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,k,"f").onSeek))},jt=function(t){a(this,$,"f").chapter&&this.appState===tt.initiated&&(a(this,nt,"f").setManifestChapterEvents(t),I(this,q,a(this,N,"m",Ri).call(this,t),"f"),a(this,D,"f").containersEventsCallState.setData(t.containers),_t.setContainers(a(this,q,"f").map(e=>e.container.container).filter(e=>!$n(e.controls))),this.options.lastFrame&&a(this,H,"f").addFn(()=>{a(this,k,"f").onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.appState=tt.ready)},Ri=function(t){var e,n;return(n=(e=t==null?void 0:t.containers)===null||e===void 0?void 0:e.reduce((r,s)=>{const l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){const c=new Bo({player:this.options.player,container:o(s,this.rootElement),branches:a(this,$,"f").chapter.branches,selectBranches:a(this,nt,"f"),interactiveEvents:a(this,D,"f"),globalEventEmitter:a(this,O,"f"),ignoreContainerEvent:()=>Po(s,a(this,q,"f")),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.options.disableControlsOnPause?void 0:this.state.disabledControls$});return a(this,H,"f").addFn(c.whilePlaying,!0),[...r,c]}return[...r]},[]))!==null&&n!==void 0?n:[]},Te=function(){const t=a(this,dt,"f").getValue(),e=!!_t.getNextInteractiveTime();(e&&!t||!e&&t)&&a(this,dt,"f").next(!t)},Ai=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},kn=function(t){var e;if(a(this,N,"m",Ai).call(this),!a(this,W,"f").inited)return;const n=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),r=this.state.prevChapter$.getValue(),s=(e=r&&Vt(r)&&jn(r))!==null&&e!==void 0?e:!1,l=a(this,$,"f").manifest.metadata.initChapterId===t,o=a(this,W,"f").state.history$.getValue();if(l||s&&n){a(this,W,"f").updateHistory([t]);return}o.at(-1)!==t&&a(this,W,"f").updateHistory([...o,t])};const ll={Container:Di,createChoiceContainer:Wi,createAreaControl:ki,createButtonControl:Fi,createRelativeLayout:rr,getRootEl:Pi,classnamesPrefix:K},cl={version:Yn};exports.CustomError=S;exports.EVENT_NAMES=E;exports.Interactives=ol;exports.ManifestController=Rn;exports.SDKInfo=cl;exports.chapterIdsToVKVideoIds=Ie;exports.compareVersions=At;exports.getChapterIdByVkVideoId=Pn;exports.getVKVideoIdByMedia=ke;exports.getVideoRawIdByMedia=An;exports.graphEventTypes=Ee;exports.hasEndTemplate=jn;exports.interactivesEventTypes=L;exports.isLastChapter=Vt;exports.isSupportedManifest=Ve;exports.isVKVariantItem=xn;exports.utils=ll;exports.vkVideoIdsToChapterIds=Ln;
|