@vkontakte/videoplayer-interactive 1.0.37-dev.cffc5829.0 → 1.0.37-dev.ecd6447c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/evergreen.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.37-dev.cffc5829.0
3
- * Fri, 30 May 2025 06:54:35 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.37-dev.ecd6447c.0
3
+ * Fri, 30 May 2025 07:01:08 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-37/doc/
5
5
  */
6
- var Et="1.0.37-dev.cffc5829.0";import{Subject as gn,Subscription as En}from"@vkontakte/videoplayer-shared/evergreen";var Xe=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},Ce=class extends Xe{constructor(e,t){super(e,t)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),r=this.cssVarsManager.getPropValue("--interactive-content-height"),o=this.cssVarsManager.getPropValue("--interactive-width"),p=this.cssVarsManager.getPropValue("--interactive-height");e.style.position="absolute",e.style.width=`calc(${n} * ${t.width})`,e.style.height=`calc(${r} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${o} - ${n}) / 2))`,e.style.top=`calc(${r} * ${t.y} + ((${p} - ${r}) / 2))`}};function It(i){return"features"in i}var Z=class{constructor(e,t,n){this.container=e,this.options=n,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&It(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),r=this.factories.get(n);if(r){let o=r(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};import{fromEvent as Se,once as bn}from"@vkontakte/videoplayer-shared/evergreen";function te(i,e=1){let t="0",n="0",r="0";return i.length===4?(t="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+t},${+n},${+r},${e})`}var xt="interactive",R={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Tt=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Tt||{}),St=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(St||{}),At=(n=>(n.start="left",n.end="right",n.center="center",n))(At||{}),be=({target:i,props:e})=>{i.style.alignItems=(e?.gravityVertical&&Tt[e.gravityVertical])??"center",i.style.justifyContent=(e?.gravityHorizontal&&St[e.gravityHorizontal])??"center",i.style.textAlign=(e?.alignment&&At[e.alignment])??"center"},ve=({target:i,props:e,fallback:t,dependsOn:n})=>{i.style.color=e?.text?.color??t.textColor,i.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,i.textContent=e?.text?.value??t.textContent},ge=({target:i,props:e,fallback:t})=>{i.style.backgroundColor=te(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},ne=({target:i,props:e,fallback:t,dependsOn:n,useRawValues:r=!1})=>{let o=r?t.borderWidthRawValue:`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth})`,p=r?t.roundCornersRawValue:`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`;i.style.borderWidth=o,i.style.borderStyle="solid",i.style.borderColor=te(r?t.borderColor:e?.shape?.border?.color??t.borderColor,r?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),i.style.borderRadius=p},wt=({target:i,isDark:e,baseDimension:t,fallback:n})=>{let p=te(n.shadowColorLight,n.shadowColorAlpha),s=te(n.shadowColorDark,n.shadowColorAlpha),l=`calc(${t} * ${.25})`,h=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${h} ${e?s:p}`;i.style.boxShadow=d},Y=({target:i,layoutParams:e,fallback:t})=>{let n=e.angle??t.angle;n=n&&n*-1,i.style.transform=`rotate(${n}rad)`};import{fromEvent as fn,Subject as yn,Subscription as Cn}from"@vkontakte/videoplayer-shared/evergreen";var qe="int",W=(n=>(n.AREA=`${qe}_area`,n.TEXT=`${qe}_text`,n.BUTTON=`${qe}_bttn`,n))(W||{});function kt(i){return"features"in i}var _="interactive-control",S={common:_,selected:`${_}-selected`,wrapper:`${_}-wrapper`,disabled:`${_}-disabled`,button:`${_}-button`,area:`${_}-area`,text:`${_}-text`,blinkAnim:`${_}-blink-anim`,blinkAnimButton:`${_}-blink-anim-button`,blinkAnimArea:`${_}-blink-anim-area`};var w=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var D=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Cn;this.error$=new yn;this.cssVarsManager=null}setCssVarsManager(e){this.cssVarsManager=e}createContainerElement(e){let t=document.createElement("div");t.classList.add(S.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??R.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue("--interactive-content-height)")??0,width:this.cssVarsManager?.getPropValue("--interactive-content-width")??0};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&kt(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(fn(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),r=>{let o=new w(1,1,{message:"Error happened on control interaction",error:r});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var U=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,G=i=>U(i,"Object"),Ee=i=>U(i,"String"),Ie=i=>U(i,"Array"),xe=i=>U(i,"Number"),Rt=i=>U(i,"Function"),Vt=i=>U(i,"Boolean"),Ze=i=>xe(i)&&!isNaN(i);var K=i=>G(i)&&Object.keys(i).length===0,Ye=i=>Ie(i)&&!i.length;var oe=(i,e)=>Ee(i)&&(e?i.trim():i).length;var Je="interactive-blink-anim-reference",O={common:Je,animation:`${Je}-animation`,disabled:`${Je}-disabled`},Te=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(O.common,O.animation),this._element=e}restart(){this._element&&(this._element.classList.add(O.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(O.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var et="interactive-container",N={common:et,hidden:`${et}-hidden`,disabled:`${et}-disabled`};var Ae=(i,e)=>{if(i.type.trim().toLowerCase()==="area")return new tt(i,e)},tt=class extends D{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(S.common,S.area),n.setAttribute("data-testid",W.AREA),ge({target:n,props:this.control.props,fallback:{...R,backgroundColor:"transparent"}}),Y({target:n,layoutParams:this.control.layoutParams,fallback:R}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Se(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${O.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add(Se(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add(Se(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(S.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(S.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(Vt(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";wt({target:this.controlElement,props:this.control.props,fallback:R,isDark:e,baseDimension:t}),ne({target:this.controlElement,props:this.control.props,fallback:{...R,borderColor:e?R.shadowColorDark:R.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??R.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else ne({target:this.controlElement,props:this.control.props,fallback:{...R,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(S.blinkAnim,e),this.controlElement?.classList.toggle(S.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${S.blinkAnimArea}`)||this.controlElement.classList.contains(S.selected)||this.controlElement.classList.contains(O.disabled)||(this.controlElement.classList.add(O.disabled),this.subscriptions.add(Se(e,"animationiteration").pipe(bn()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(O.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${S.blinkAnimArea}`)||this.controlElement.classList.contains(S.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new w(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};import{fromEvent as ke,once as vn}from"@vkontakte/videoplayer-shared/evergreen";var we=i=>{let e=document.createElement("span");switch(i){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let r={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,r),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var Re=(i,e)=>{if(i.type.trim().toLowerCase()==="button")return new nt(i,e)},nt=class extends D{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(S.common,S.button),n.setAttribute("data-testid",W.BUTTON),Y({target:n,layoutParams:this.control.layoutParams,fallback:R}),ge({target:n,props:this.control.props,fallback:R}),ne({target:n,props:this.control.props,fallback:R,dependsOn:this.container.dimensions}),be({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=we(this.control.type.trim().toLowerCase()),o=r.firstElementChild??r;ve({target:o,props:this.control.props,fallback:R,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(ke(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${O.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add(ke(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add(ke(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(S.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(S.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(S.blinkAnim,e),this.controlElement?.classList.toggle(S.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${S.blinkAnimButton}`)||this.controlElement.classList.contains(S.selected)||this.controlElement.classList.contains(O.disabled)||(this.controlElement.classList.add(O.disabled),this.subscriptions.add(ke(e,"animationiteration").pipe(vn()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(O.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${S.blinkAnimButton}`)||this.controlElement.classList.contains(S.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new w(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var Mt=(i,e)=>{if(i.type.trim().toLowerCase()==="text")return new it(i,e)},it=class extends D{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(S.common,S.text),n.setAttribute("data-testid",W.TEXT),Y({target:n,layoutParams:this.control.layoutParams,fallback:R}),be({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=we(this.control.type.trim().toLowerCase()),o=r.firstElementChild??r;ve({target:o,props:this.control.props,fallback:R,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}onError(){}};var Ve=(i,e,t,n)=>{if(i.type.trim().toLowerCase()==="choice")return new rt(i,e,t,n)},rt=class extends Z{constructor(t,n,r,o){super(t,r,o);this.containerElement=null;this.controlSubscriptions=new En;this.error$=new gn;this.rootElement=n,this.layout=new Ce(this.container.layout,r),this.cssVarsManager=r,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Re),this.addControlFactory("text",Mt),this.addControlFactory("area",Ae)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(N.common,N.disabled),requestAnimationFrame(()=>{n.classList.remove(N.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(r=>{r.setCssVarsManager(this.cssVarsManager),r.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),r.setEvents(t),this.controlSubscriptions.add(r.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(N.hidden)}show(){let t=this.getElement();t&&t.classList.remove(N.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(N.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(N.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(r=>{r.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};import{combine as Kn,InterfaceLanguage as Qn,Observable as hn,once as Xn,Subject as $,Subscription as bt,ValueSubject as j,fromEvent as un}from"@vkontakte/videoplayer-shared/evergreen";import{InteractiveInterfaceClick as fe}from"@vkontakte/videoplayer-statistics/evergreen";import{loadVKLangPack as In}from"@vkontakte/videoplayer-shared/evergreen";function se(i,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>i(...n),e)}}var Pt="video_interactive",Ot="videoint";var Nt=250,ae=class{constructor(e){this.handleZoomChange=se(e=>{this.lastZoomInfo=e},Nt);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.("Chapter id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor?.selectChapter(e.id),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{if(this.isReady=!1,!xe(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=xn(e),this.resizeObserver=new ResizeObserver(se(this.onResize,Nt)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await In(this.lang,Pt,Ot)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...r})=>{n==="openPreview"&&"chapterId"in r&&this.onOpenPreviewClick?.(r.chapterId)}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function xn(i){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",i.append(e),e}var le=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,r=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let p=o.startTime-e;if(p<=r&&(o.endTime&&r<=o.endTime||o.endTime===null)){n=!0;break}r<p&&(t=t===-1?p:Math.min(t,p))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as Pe,ContainerTypes as Hr,ControlTypes as Oe,EventActionTypes as x,EventTypes as Dr,migrateManifestToLatestVersion as jt,compareVersions as Ur}from"@interactiveplatform/movika-manifest";var $t={metadata:"Object",chapters:"Array"},Lt=i=>{if(!G(i))return!1;for(let e in $t)if(!i[e]||!U(i[e],$t[e]))return!1;return Pe(i.metadata.version)},Me=i=>i.type===Oe.Text,Or=i=>i.type===Oe.Button,Nr=i=>i.type===Oe.Area,$r={Choice:"Choice",TextInput:"TextInput"},Lr={Button:"Button",Area:"Area",Text:"Text"},Fr={onClick:"onClick",onSuspense:"onSuspense"},Ft={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ne=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let r=n.length;r>0;r--)if(n[r]===t){n.splice(r,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(r=>{r(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var $e=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Rt(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Le=class i{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=i.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",n="test";e.style.setProperty(t,n);let r=e.style.getPropertyValue(t)===n;return r&&e.style.removeProperty(t),r}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,n]of Object.entries(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as Vn}from"@vkontakte/videoplayer-shared/evergreen";var Fe=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Tn(...this.loaders[e])(t)}};function Tn(...i){return async function(t){let n=[...i];for(;n.length>0;)t=await n.shift()(t);return t}}function ce(i,e,t){return i?{...i,[e]:i[e]?[t,...i[e]]:[t]}:{[e]:[t]}}function je({actions:i,errors:e,chapterId:t,...n}){if(t){let r=i.getManifest();if(r){let o=i.getChapter(r.chapters,t);if(o){let p=i.getMedia(r.media,o.videoId),s=i.getGraph(r.graph,o.id);return p?{...n,actions:i,errors:e,result:{chapter:o,media:p,graph:s}}:{...n,errors:ce(e,je.name,"Could not find media"),actions:i}}}}return{...n,errors:ce(e,je.name,"Could not find chapter"),actions:i}}var ot=(i="",e="")=>{let t=i.split("."),n=e.split("."),r=0;for(let o=0;o<Math.max(t.length,n.length)&&!r;o++)t[o]>n[o]?r=1:t[o]<n[o]?r=-1:r=0;return r};var Sn=async i=>{try{let e={},t;if(Ee(i)){t=new URL(i).href;let r=await fetch(t);if(!r.ok)return{};e=await r.json()}else if(G(i))e=i;else return{};if(!Lt(e))return{};let n=e.metadata.media;if(Ee(n)&&!("media"in e))try{let r;t?r=new URL(n,t).href:(r=new URL(n).href,t=r);let o=await fetch(r);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return kn(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Bt(i){let{manifest:e,manifestURL:t}=await Sn(i);if(!e)throw new Error("Failed on fetch");let n=jt(e);return n.media=An(n.media,t),delete n.metadata.media,n}function Be(i,e){if(e)return i.find(t=>t.id===e)}function st(i,e){return i.edit?.chapters?i.edit.chapters.find(t=>t.id===e):i.view?.chapters?i.view.chapters.find(t=>t.id===e):void 0}function at(i,e){return i.videos.find(t=>t.id===e)}function An(i,e){return{...i,videos:i.videos.map(t=>({...t,variants:t.variants.map(n=>{let r="url"in n?n.url:"",o=wn(r,e);return{...n,url:o||r}})}))}}function wn(i="",e){try{return new URL(i,e).href}catch{return""}}function kn(i){return ot(i,"3.2.0")>=0}var _e=i=>Ie(i)&&!Ye(i),H=i=>i.order==="end",He=i=>Ie(i.containers)&&!Ye(i.containers)&&H(i),_t=(i,e)=>{let t=i*1e3;return _e(e.controls)&&t<(e.startTime??0)},lt=(i,e)=>{let t=i*1e3;return _e(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var Q=(i=[])=>i.some(e=>e.action.type==="expect"),ct=(i=[])=>i.find(e=>e.action.type==="expect"),Rn=i=>i?.length===1,J=i=>Rn(i)&&Me(i[0]);function Ht(i=[],e=1/0,t=[]){return i.filter(({container:n})=>!t.includes(n.container.id)&&Q(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function De({gameControllers:i=[],subjectName:e,subjectId:t,execFn:n}){for(let r of i)if(e==="container"&&r.container.container.id===t){n(r),Ht(i,r.container.container.endTime,[r.container.container.id]).forEach(p=>{n(p)});break}}var Dt=(i,e)=>{let t=A=>e.find(({container:c})=>c.container.id===A)?.container.isRemoved,n=Q(i.events)&&!t(i.id),r=(A,y=!1,c=!1)=>{let a=c?"every":"some";return A.controls[a](u=>{let f=y?A.endTime===i.endTime:!0;return u.events?.[a](m=>m.action?.type===Ft.openURI)&&f})},o=A=>A.some(({container:y})=>r(y.container,!0,!1)&&!y.isRemoved),p=A=>A.every(({container:y})=>y.isRemoved?!0:r(y.container,!0,!0)),s=Ht(e,i.endTime,[i.id]).length,l=A=>A.controls.some(y=>y.events?.some(c=>c.action?.args?.shouldOpenNow)),h=n||s>0,d=o(e),v=r(i),C=p(e),b=n?!1:s>0,P=l(i);return{isExpectTime:h,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:C,isExpectEventForCurrentContainer:b,hasShouldOpenNowEvent:P}};var ee=class extends Fe{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Vn(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:ce},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await Bt(n.result??t),this}async setInitial(){return this.setNext()}async setNext(t=this.manifest?.metadata.initChapterId){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",je({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:st,getChapter:Be,getMedia:at,getByBranches:this.getByBranches.bind(this),addErrorMessage:ce},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(t=this.manifest?.metadata.initChapterId){if(!t||!this.manifest)return null;let n=Be(this.manifest.chapters,t);if(n){let r=at(this.manifest.media,n.videoId),o=st(this.manifest.graph,n.id);if(r)return{chapter:n,media:r,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Be(this.manifest?.chapters||[],t);return this.getByBranches(n?.branches)}}getByBranches(t=[]){return t.reduce((n,r)=>{let o=this.getByChapterId(r.chapterId);return o&&n.push(o),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?H(this.chapter):!1}};import{Player as Mn}from"@vkontakte/videoplayer-core/evergreen";import{Subscription as ut,Tracer as Pn,ValueSubject as On}from"@vkontakte/videoplayer-shared/evergreen";var Ut=i=>{let e=i.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};function pt(){let i=new Map;function e({listId:o=Math.random().toString(),itemId:p=Math.random().toString(),...s}){let l=i.get(o),h={...s};return l?l[p]=h:i.set(o,{[p]:h}),{listId:o,itemId:p,...s}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function n(o,p){let s=i.get(o);if(!s)throw Error("Can't remove. Not find.");if(p){let l=s[p];l&&t(l),delete s[p],Object.keys(s).length||i.delete(o)}else{for(let l of Object.values(s))t(l);i.delete(o)}}function r(){for(let o of i)n(o[0])}return{createPlayer:e,removePlayer:n,map:i,removeAll:r}}function ht(i,e=[]){let t={},n,r=!e.length;for(let o of i.variants)if(!n&&"cover"in o&&(n=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(r||e.includes("mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(r||e.includes("mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(r||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(r||e.includes("dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:n,title:i.title??""}}var pe=(i,e)=>{let t=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();t!==e&&n.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))};var Nn=2;function dt(i){let e=pt(),t=new ut,n={},r=null,o=!1,p,s=new On(null);i&&l(i);function l(y){r=y}function h(y,c,a){if(!r)throw Error("need to set interactive controller");if(!r.options)return;let f=(e.map.get(y)??{})[c];if(f){n={chapterId:a,listId:y,itemId:c,...f};let m=n.player;n.subscription.add(m.info.currentQuality$.subscribe(g=>{let T=m.info.position$.getValue(),L=m.info.isAutoQualityEnabled$.getValue();if(!(!g||!T||L))for(let E of e.map)Object.values(E[1]).forEach(({player:V})=>{pe(V,g)})})).add(m.events.started$.subscribe(()=>{d(c)})),f.container.remove(),r.setPlayer(f.player),o||(r.init(),o=!0),s.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(y){if(!r)throw Error("need to set interactive controller");if(K(n)||y!==n.itemId)return;let c=r.getChapterBranches(),a=new Set;for(let u of c)a.has(u.media.id)||(await C({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),a.add(u.media.id))}async function v({chapter:{id:y},manifestVideo:c}){if(K(n)||!r)return;let a=n.player.info.muted$.getValue(),u=n.player.info.currentQuality$.getValue(),f=n.player.info.isAutoQualityEnabled$.getValue(),m=n.player.info.volume$.getValue(),g=n.player.info.currentPlaybackRate$.getValue(),T=!f,L=!1;for(let E of e.map)if(E[0]===c.id&&!r.state.isReplay$.getValue()){let V=Object.keys(E[1]);for(let M of V)M===n.itemId?(V.length<Nn||(L=!0),e.removePlayer(E[0],M)):(L=!0,h(E[0],M,y),T?pe(n.player,u):n.player.setAutoQuality(!0),n.player.setVolume(m),n.player.setMuted(a),n.player.setPlaybackRate(g))}else e.removePlayer(E[0]);L||(await C({media:c,chapterId:y,setAsActive:!0,playbackRate:g}),T?pe(n.player,u):n.player.setAutoQuality(!0),n.player.setVolume(m),n.player.setMuted(a))}async function C({media:y,chapterId:c,prefetch:a=!0,setAsActive:u=!0,autoplay:f=!1,preferredExt:m,title:g,playbackRate:T}){let L=Math.random().toString(),E=document.createElement("div");p.append(E);let V;if(r?.options?.vkVideoLoader){let ye=Ut(y);ye.length&&(V=await r.options.vkVideoLoader(...ye))}let M=r?.options?.coreConfig||void 0,B={...M,configName:[...M?.configName??[],"interactive"]},z={container:E,...V?.videos?.[0]||{sources:ht(y,m).sources},title:g,failoverHosts:V?.failoverHosts||[]},F=new Mn(B,Pn.createRootTracer());F.initVideo(z);let X=null;if(V?.videos&&r?.options.createOneStat){let ye=V.videos[0],Qe=r.options.createOneStat(ye),gt=new ut;Qe&&(gt.add(Qe.attachTo(F)),X={oneStat:Qe,statSubscription:gt})}let vt=new ut,mn=n?.player?.info.isAutoQualityEnabled$.getValue();vt.add(F.events.canplay$.subscribe(function(){mn||pe(F,n.player.info.currentQuality$.getValue()),T&&F.setPlaybackRate(T)}));let q=e.createPlayer({listId:y.id,itemId:L,player:F,container:E,sources:ht(y,m).sources,config:z,subscription:vt,statistics:X});return u&&h(y.id,q.itemId,c),f&&q.player.play(),a&&!f&&q.player.prepare(),{player:q.player,config:q.config,statistics:q.statistics}}function b(){P(),r=null,p.remove()}function P(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function A(){if(!r)throw Error("need to set interactive controller");P(),p=document.createElement("div");let{media:y,chapter:c}=r.getCurrentChapter();y&&c?(t.add(r.events.chapterChanged$.subscribe(v)),await C({media:y,chapterId:c.id,title:c.label})):console.error("not found")}return{...e,init:A,setInteractiveController:l,createPlayer:C,removeAll:b,getActivePlayer:function(){return n},activePlayerChanged:s}}var I={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},he={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},k={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as $n}from"@vkontakte/videoplayer-shared/evergreen";function mt(i){return function(...t){return i(...t.reverse())}}function ue(i,...e){return(...t)=>G(e[0])&&G(t[0])?i({...e[0],...t[0]}):i(...e,...t)}var Ue=class{constructor({player:e,container:t,branches:n,selectBranches:r,interactiveEvents:o,globalEvents:p,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:h,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:C,onError:b}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(Q(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&this.container.hide?.(),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&t)return;this.emitContainerVisibilityEvent(!0,!1)}else{let t={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(r,o)=>{let{isExpectTime:p,hasOtherExpect:s,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:h,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:v}=this.getContainerEventState(),C=this.interactiveTimeOpenUri&&!h,b=this.interactiveTimeOpenUri&&h;if((!this.interactiveTimeOpenUri||C)&&(this.isSelectedControlEvent=!0),r!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||C)){if(this.interactiveTimeOpenUri){let P=!s&&!d&&h;P&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:P})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&l&&this.gameState!==5){if(b){let A=((y,c,a,u)=>!y&&!c&&a||y&&!c&&a&&!u||y&&!c&&a&&u)(p,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(A)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!p||!s||!v)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=ue(this.selectBranches.onControlEvent,t);this.container.createView({eventCallback:n}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&this.container.disable?.()}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,r=[6,5];if(!n||r.includes(this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(_t(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(lt(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let h=this.gameState;this.gameState=3,h===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:h}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,v=this.interactiveTimeOpenUri&&h;if(v&&!d){let C=this.container.getElement();C&&(C.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!v&&this.removeView()}let p=lt(o,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:o,isInteractiveTime:p};this.container.onProgress(o*1e3,p),this.globalEventEmitter.emit(I.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=n,this.selectBranches=r,this.subscription=new $n,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l,this.isPermanentText=h&&J(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=C,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=p,this.onError=b,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{e?this.container.disable?.():this.container.enable?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:Q(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){this.container.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var zt=(i=[])=>i.reduce((e,t,n)=>{let r=(t?.controls??[]).filter(o=>!Me(o));if(_e(r)){let o=[t.startTime??0,t.endTime??1/0],p={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[p],range:o});else{let s=[],l=-1/0,h=1/0,d=[],v=[];for(let C=0;C<e.length;C++){let b=e[C];if(v.push(...b.subjects),b.range[0]<h&&(h=b.range[0]),b.range[1]>l&&(l=b.range[1]),o[0]>=b.range[0]&&o[1]<=b.range[1])return e[C].subjects.push(p),e;o[0]<b.range[0]&&o[1]>b.range[0]&&(s.push(C),d=d.concat(b.subjects)),o[0]>=b.range[0]&&o[0]<=b.range[1]&&(s.push(C),d=d.concat(b.subjects),o[0]=b.range[0]),o[1]>=b.range[0]&&o[1]<=b.range[1]&&(s.push(C),d=d.concat(b.subjects),o[1]=b.range[1])}if(v.push(p),o[0]<=h&&o[1]>=l)return[{subjects:v,range:o}];s.length&&s.reverse().forEach(C=>{e.splice(C,1)}),e.push({subjects:d.concat([p]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function Wt(){let i={};function e(){for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&delete i[s]}function t(s){let l={};for(let h in i)+h<=s&&(l[h]=i[h]);return l}function n(s){let l={};for(let h in i)+h>=s&&(l[h]=i[h]);return l}function r({timestamp:s,priority:l,initiator:h}){if(Ze(s)){let d=i[s]??null;if(d&&l&&oe(l,!0)){let v={},C=d[l];return C&&(v={...v,...C}),v=K(v)?null:v,v&&oe(h,!0)?v[h]??null:v}return d}return null}function o({timestamp:s,priority:l,initiator:h}){if(Ze(s))if(i[s]){if(l&&oe(l,!0))if(i[s][l]){if(h&&oe(h,!0))if(i[s][l][h]){if(delete i[s][l][h],!K(i[s][l]))return!0}else return!1;if(delete i[s][l],!K(i[s]))return!0}else return!1;return delete i[s]}else return!1;return!1}function p({timestamp:s,priority:l,initiator:h,...d}){i[s]?.[l]?.[h]?i[s][l][h].push({...d}):i[s]?.[l]?i[s][l]={...i[s][l],[h]:[{...d}]}:i[s]?i[s]={...i[s],[l]:{[h]:[{...d}]}}:i[s]={[l]:{[h]:[{...d}]}}}return{map:i,remove:o,add:p,removeAll:e,get:r,getLte:t,getGte:n}}var Ln=[x.expect,x.setNextBranch],Fn=1/0;function Kt(i,e){let t=i,n,r=jn(e),o=Wt(),p,s=()=>{b(),c()},l=a=>{o.add.call(void 0,a),P()},h=(a=[])=>{for(let u of a)if(u.action(),Ln.includes(u.actionType))break},d=(a=1/0)=>{let u=Ge(o.get({timestamp:a,priority:"control"})??{}),f=Ge(o.get({timestamp:a,priority:"container"})??{}),m=Ge(o.get({timestamp:a,priority:"chapter"})??{});return[...u,...f,...m]},v=a=>{r.isReady(a)&&h(d(a))},C=()=>{h([...Ge(o.get({timestamp:1/0,priority:"chapter"})??{})])},b=()=>{n&&(p?.unsubscribe(),n=void 0)},P=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),p=t.events.ended$.subscribe(n))},A=a=>{b(),t=a},y=a=>{a.priority==="container"&&r.resetCalled(a.timestamp),o.remove(a)},c=()=>{r.release(),o.removeAll()};return{setPlayer:A,add:l,remove:y,exec:v,execEndOfVideo:C,listen:P,unlisten:b,release:s,containersEventsCallState:r,getPreparedToExecActions:d}}function jn(i){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let h=e.get(s);h&&h[l]!==void 0&&(h[l]=!0)},setData:(s=[])=>{for(let l of s){let h=l.endTime??Fn,d=e.get(h);e.set(h,{...d,[l.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let h in l)l[h]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let h=Object.values(l);return i?h.some(v=>v):!h.some(v=>!v)},release:()=>e.clear()}}function Ge(i){return Object.values(i).flat().sort(e=>e.actionType===x.expect?-1:1)}var Qt={videoContentHeight:0,videoContentWidth:0},Xt=i=>{let{height:e,width:t}=i.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Qt;let{clientHeight:n,clientWidth:r}=i.experimental.element$.getValue()||{};if(!(n&&r))return Qt;let o=e/t,p=n/r,s,l;return p>o?(l=r,s=r*o):p<o?(l=n/o,s=n):(l=r,s=n),{videoContentWidth:l,videoContentHeight:s}};var Bn=250;function qt(i){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:l,player:h,cssVarsManager:d}=i();if(!l||!h)return;let{videoContentWidth:v,videoContentHeight:C}=Xt(h);d.setup({"--interactive-content-width":`${v}px`,"--interactive-content-height":`${C}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function r(){let{parentElement:s}=i();s.removeAttribute("style")}let o=se(s=>{let{fns:l=[]}=i();n(s);for(let h of l)h()},Bn);function p(){e=void 0,t.disconnect(),r()}return{resizeObserver:t,calc:()=>{e?.()},release:p}}var _n=i=>Math.floor(Math.random()*i),Yt=i=>{let e=i.length,t=1/0,n=null;for(;e--;){let r=i[e],o=r.weight??1;o<t&&(t=o,n=r)}return n},Jt=i=>{let e=i.length,t=-1/0,n=null;for(;e--;){let r=i[e],o=r.weight??0;o>t&&(t=o,n=r)}return n};var en=i=>{let e=i.length,t=_n(e);return i[t]},Zt=1,tn=i=>{let e=0;for(let n=0;n<i.length;++n)e+=i[n].weight??Zt;let t=Math.random()*e;e=0;for(let n=0;n<i.length-1;++n)if(e+=i[n].weight??Zt,e>=t)return i[n];return i[i.length-1]};var nn={shouldOpenNow:!0,isDetachContainer:!0},rn="after-expect",ft=(i,e=!1)=>({...i,args:e?{...i.args,...nn}:{...nn,...i.args}}),on=({globalEventEmitter:i,globalEvents:e,player:t,interactiveEvents:n})=>{let r={isExpect:!1},o=()=>{r.isExpect&&(r.isExpect=!1)},p=({action:c,controlType:a,controlId:u,containerId:f,branches:m=[],onEvent:g,isEOV:T=()=>!1,isDisabled:L=()=>!1})=>{let E=ft(c,T()),V={timestamp:1/0,priority:"control",initiator:u,actionType:E.type},M=L(),B=i.emit.bind(i,I.interactives,{subjectId:u,subjectType:a,subjectName:"control",type:M?k.actionChoiceCanceled:k.actionChoice,actionType:c.type,payload:{invokeImmediately:E.args.shouldOpenNow,containerId:f,...E.args}}),z=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectType:a,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:c.type,payload:{invokeImmediately:E.args.shouldOpenNow,containerId:f,...E.args}})};if(M){B(),z();return}switch(E.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let F=m.find(X=>X.id===E.args.branchId);if(!F)return;g(E.args.isDetachContainer,b.bind(null,{subjectId:u,subjectName:"control"})),B(),z(),E.args.shouldOpenNow?A({subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{chapterId:F.chapterId,autoSelect:!1}}):n.add({...V,action:A.bind(null,{subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{chapterId:F.chapterId,autoSelect:!1}})});return}case x.continuePlayback.trim().toLowerCase():{g(E.args.isDetachContainer,b.bind(null,{subjectId:u,subjectName:"control"})),B(),z(),E.args.shouldOpenNow?P({subjectId:u,subjectName:"control",subjectType:a,action:c}):n.add({...V,action:P.bind(null,{subjectId:u,subjectName:"control",subjectType:a,action:c})});return}case x.openURI.trim().toLowerCase():{g(E.args.isDetachContainer,b.bind(null,{subjectId:u,subjectName:"control"})),B(),z(),E.args.shouldOpenNow?y({subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{URI:c.args.uri}}):n.add({...V,action:y.bind(null,{subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{URI:c.args.uri}})});return}default:{let F="Unexpected control event",X=new w(1,1,{message:F});d(X,F);return}}},s=({action:c,container:{id:a,endTime:u},branches:f=[],isEOV:m=!1,autoSelected:g=!1})=>{let T=ft(c,m),L={timestamp:!T.args.shouldOpenNow||m?1/0:u??1/0,priority:"container",initiator:a,actionType:T.type},E=i.emit.bind(i,I.interactives,{subjectId:a,subjectName:"container",type:k.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),V=()=>{e.interactiveActionChoice$.next({subjectId:a,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let M=f.find(B=>B.id===T.args.branchId);if(!M)return;E(),V(),n.add({...L,action:A.bind(null,{subjectId:a,subjectName:"container",action:T,payload:{chapterId:M.chapterId,autoSelect:g}})});return}case x.setMaxWeightBranch.trim().toLowerCase():return;case x.setMinWeightBranch.trim().toLowerCase():return;case x.setRandomBranch.trim().toLowerCase():return;case x.setWeightlessRandomBranch.trim().toLowerCase():return;case x.continuePlayback.trim().toLowerCase():{E(),V(),n.add({...L,action:P.bind(null,{subjectId:a,subjectName:"container",action:T})});return}case x.openURI.trim().toLowerCase():{E(),V(),n.add({...L,action:y.bind(null,{subjectId:a,subjectName:"container",action:T,payload:{URI:c.args.uri}})});return}default:{let M="Unexpected container event",B=new w(1,1,{message:M});d(B,M);return}}};function l({container:c,branches:a,isEOV:u=!1}){let f=ct(c.events);if(f){let m=ft(f.action,u);i.emit(I.interactives,{subjectId:c.id,subjectName:"container",type:k.actionChoice,actionType:m.type,payload:{invokeImmediately:m.args.shouldOpenNow,...m.args}}),e.interactiveActionChoice$.next({subjectId:c.id,subjectName:"container",type:"action-choice",actionType:m.type,payload:{invokeImmediately:m.args.shouldOpenNow,...m.args}}),n.add({timestamp:u?1/0:c.endTime??1/0,priority:"container",initiator:c.id,actionType:x.expect,action:C.bind(null,{subjectId:c.id,subjectName:"container"})}),r.isExpect=!0}else for(let m of c.events??[])s({action:m.action,container:c,branches:a,isEOV:u})}let h=({chapterId:c,action:a,branches:u=[]})=>{let f=i.emit.bind(i,I.interactives,{subjectId:c,subjectName:"chapter",type:k.actionChoice,actionType:a.type,payload:a.args}),m=()=>{e.interactiveActionChoice$.next({subjectId:c,subjectName:"chapter",type:"action-choice",actionType:a.type,payload:a.args})};switch(a.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let g=u.find(T=>T.id===a.args.branchId);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setWeightlessRandomBranch.trim().toLowerCase():{let g=en(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setRandomBranch.trim().toLowerCase():{let g=tn(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setMaxWeightBranch.trim().toLowerCase():{let g=Jt(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setMinWeightBranch.trim().toLowerCase():{let g=Yt(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.continuePlayback.trim().toLowerCase():return f(),m(),P.bind(null,{subjectId:c,subjectName:"chapter",action:a});case x.openURI.trim().toLowerCase():return f(),m(),y.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{URI:a.args.uri}});default:{let g="Unexpected chapter event",T=new w(1,1,{message:g});d(T,g);return}}};function d(c,a){console.error(a),e.error$.next(c),i.emit(I.errors,c)}function v(c){let a=ct(c.events);if(a){if(H(c))return;i.emit(I.interactives,{subjectId:c.id,subjectName:"chapter",type:k.actionChoice,actionType:a.action.type,payload:a.action.args}),e.interactiveActionChoice$.next({subjectId:c.id,subjectName:"chapter",type:"action-choice",actionType:a.action.type,payload:a.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:c.id,actionType:x.expect,action:C.bind(null,{subjectId:c.id,subjectName:"chapter"})})}else c.events?.forEach(u=>{let f=h({chapterId:c.id,action:u.action,branches:c.branches});f&&n.add({timestamp:1/0,priority:"chapter",initiator:c.id,actionType:u.action.type,action:f})})}let C=({subjectId:c,subjectName:a})=>{t.pause(),i.emit(I.interactives,{subjectId:c,subjectName:a,type:k.actionExecution,actionType:x.expect}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,type:"action-execution",actionType:x.expect})},b=({subjectId:c,subjectName:a})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),i.emit(I.interactives,{subjectId:c,subjectName:a,type:k.actionExecution,actionType:rn}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,type:"action-execution",actionType:rn})},P=({subjectId:c,subjectName:a,subjectType:u,action:f})=>{i.emit(I.interactives,{subjectId:c,subjectName:a,subjectType:u,type:k.actionExecution,actionType:f.type}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,subjectType:u,type:"action-execution",actionType:f.type})},A=({subjectId:c,subjectName:a,subjectType:u,action:f,payload:m})=>{m.behaviour="change-chapter",i.emit(I.interactives,{subjectId:c,subjectName:a,subjectType:u,type:k.actionExecution,actionType:f.type,payload:m}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,subjectType:u,type:"action-execution",actionType:f.type,payload:m})},y=({subjectId:c,subjectName:a,subjectType:u,action:f,payload:m})=>{if(!m.URI)return;let g=window.open(m.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),i.emit(I.interactives,{subjectId:c,subjectName:a,subjectType:u,type:k.actionExecution,actionType:f.type}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,subjectType:u,type:"action-execution",actionType:f.type})};return{onControlEvent:p,onContainerEvent:s,onChapterEvent:h,onExpectEvent:C,expectEventHandler:b,setManifestChapterEvents:v,setManifestContainerEvents:l,stopExpect:o,state:r}};import{Subscription as zn,Subject as Ct,ValueSubject as de}from"@vkontakte/videoplayer-shared/evergreen";var yt=(i,e)=>{let t={};return i.map(n=>{if(!t[n]){let r=e.chapters.find(p=>p.id===n);if(!r)return null;let o=e.media.videos.find(p=>r.videoId===p.id);if(!o)return null;t[n]=sn(o)}return t[n]}).filter(Boolean)},Dn=i=>{for(let e of i.variants)if(Un(e)&&e.payload)return e.payload.id},Un=i=>!!(i.type==="custom"&&i.payload&&i.payload.type==="vk"),sn=i=>{let e=Dn(i);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Gn=(i,e)=>{for(let t of i.media.videos)if(e===sn(t)){for(let n of i.chapters)if(n.videoId===t.id)return n.id;return}},an=(i,e)=>i.reduce((t,n)=>{let r=Gn(e,n);return r?[...t,r]:t},[]);var me=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:r,settings:o}){this.state={history$:new de([]),hasPrevChapter$:new de(!1),prevChapter$:new de(null),isInitialChapter$:new de(!1),isGoBackLimited$:new de(!1)};this.#n=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new Ct,destroyed$:new Ct,error$:new Ct};this.#i=null;this.#r=null;this.#t=null;this.#a=new zn;this.#l=!1;this.#c=0;this.#i=t,this.#t=e,this.#r=n,this.#n=r,this.#o=o,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(p=>{this.state.prevChapter$.next(p.at(-2)||null),this.state.hasPrevChapter$.next(p.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#o.maxLength-1)}))}#n;#o;#s;#e;#p;#i;#r;#t;#a;#l;#c;async setManifest(e){if(!this.#r||!this.#t)return;this.#e=e,await this.getProjectHistory();let t=this.getInitialChapterId();await this.#r.setChapter({chapterId:t,pushToHistory:!1}),this.#s||(this.#s=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#s}async updateHistory(e,t=!0){if(!this.#e)return;this.#l?(this.#l=!1,this.#c++):this.#c=0;let n=this.#e,r=e.length-this.#o.maxLength,o=r>0?e.slice(r):e,p=yt(o,n);if(this.#p=p,this.state.history$.next(o),!(!t||!this.#n||!this.#i))try{await this.#n.save(this.#i,p)}catch{let l=new w(1,5,"Unable to save interactive history");this.events.error$.next(l),this.#t?.emit(I.errors,l)}}async goBack(){if(!this.state||!this.#r){let n=new w(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(I.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#r.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#i)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#n)try{let r=await this.#n.get(this.#i);r.length&&(t=r)}catch{let o=new w(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(I.errors,o)}let n=an(t,e);this.state.history$.next(n)}getInitialChapterId(){return this.state.history$.getValue()?.at(-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return yt([e],this.#e).pop()}return null}destroy(){this.#i=null,this.#n=null,this.#r=null,this.#a?.unsubscribe(),this.#a=null,this.#s=!1,this.#t?.emit(I.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var ze=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){this.rootElement.getContext("2d")?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let r=3;r<n;r+=40)if(t[r]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let r;t&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&r&&this.restore(r),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var We=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
6
+ var Et="1.0.37-dev.ecd6447c.0";import{Subject as gn,Subscription as En}from"@vkontakte/videoplayer-shared/evergreen";var Xe=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},Ce=class extends Xe{constructor(e,t){super(e,t)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),r=this.cssVarsManager.getPropValue("--interactive-content-height"),o=this.cssVarsManager.getPropValue("--interactive-width"),p=this.cssVarsManager.getPropValue("--interactive-height");e.style.position="absolute",e.style.width=`calc(${n} * ${t.width})`,e.style.height=`calc(${r} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${o} - ${n}) / 2))`,e.style.top=`calc(${r} * ${t.y} + ((${p} - ${r}) / 2))`}};function It(i){return"features"in i}var Z=class{constructor(e,t,n){this.container=e,this.options=n,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&It(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),r=this.factories.get(n);if(r){let o=r(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};import{fromEvent as Se,once as bn}from"@vkontakte/videoplayer-shared/evergreen";function te(i,e=1){let t="0",n="0",r="0";return i.length===4?(t="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+t},${+n},${+r},${e})`}var xt="interactive",R={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Tt=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Tt||{}),St=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(St||{}),At=(n=>(n.start="left",n.end="right",n.center="center",n))(At||{}),be=({target:i,props:e})=>{i.style.alignItems=(e?.gravityVertical&&Tt[e.gravityVertical])??"center",i.style.justifyContent=(e?.gravityHorizontal&&St[e.gravityHorizontal])??"center",i.style.textAlign=(e?.alignment&&At[e.alignment])??"center"},ve=({target:i,props:e,fallback:t,dependsOn:n})=>{i.style.color=e?.text?.color??t.textColor,i.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,i.textContent=e?.text?.value??t.textContent},ge=({target:i,props:e,fallback:t})=>{i.style.backgroundColor=te(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},ne=({target:i,props:e,fallback:t,dependsOn:n,useRawValues:r=!1})=>{let o=r?t.borderWidthRawValue:`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth})`,p=r?t.roundCornersRawValue:`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`;i.style.borderWidth=o,i.style.borderStyle="solid",i.style.borderColor=te(r?t.borderColor:e?.shape?.border?.color??t.borderColor,r?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),i.style.borderRadius=p},wt=({target:i,isDark:e,baseDimension:t,fallback:n})=>{let p=te(n.shadowColorLight,n.shadowColorAlpha),s=te(n.shadowColorDark,n.shadowColorAlpha),l=`calc(${t} * ${.25})`,h=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${h} ${e?s:p}`;i.style.boxShadow=d},Y=({target:i,layoutParams:e,fallback:t})=>{let n=e.angle??t.angle;n=n&&n*-1,i.style.transform=`rotate(${n}rad)`};import{fromEvent as fn,Subject as yn,Subscription as Cn}from"@vkontakte/videoplayer-shared/evergreen";var qe="int",W=(n=>(n.AREA=`${qe}_area`,n.TEXT=`${qe}_text`,n.BUTTON=`${qe}_bttn`,n))(W||{});function kt(i){return"features"in i}var _="interactive-control",S={common:_,selected:`${_}-selected`,wrapper:`${_}-wrapper`,disabled:`${_}-disabled`,button:`${_}-button`,area:`${_}-area`,text:`${_}-text`,blinkAnim:`${_}-blink-anim`,blinkAnimButton:`${_}-blink-anim-button`,blinkAnimArea:`${_}-blink-anim-area`};var w=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var D=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Cn;this.error$=new yn;this.cssVarsManager=null}setCssVarsManager(e){this.cssVarsManager=e}createContainerElement(e){let t=document.createElement("div");t.classList.add(S.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??R.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue("--interactive-content-height)")??0,width:this.cssVarsManager?.getPropValue("--interactive-content-width")??0};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&kt(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(fn(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),r=>{let o=new w(1,1,{message:"Error happened on control interaction",error:r});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var U=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,G=i=>U(i,"Object"),Ee=i=>U(i,"String"),Ie=i=>U(i,"Array"),xe=i=>U(i,"Number"),Rt=i=>U(i,"Function"),Vt=i=>U(i,"Boolean"),Ze=i=>xe(i)&&!isNaN(i);var K=i=>G(i)&&Object.keys(i).length===0,Ye=i=>Ie(i)&&!i.length;var oe=(i,e)=>Ee(i)&&(e?i.trim():i).length;var Je="interactive-blink-anim-reference",O={common:Je,animation:`${Je}-animation`,disabled:`${Je}-disabled`},Te=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(O.common,O.animation),this._element=e}restart(){this._element&&(this._element.classList.add(O.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(O.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var et="interactive-container",N={common:et,hidden:`${et}-hidden`,disabled:`${et}-disabled`};var Ae=(i,e)=>{if(i.type.trim().toLowerCase()==="area")return new tt(i,e)},tt=class extends D{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(S.common,S.area),n.setAttribute("data-testid",W.AREA),ge({target:n,props:this.control.props,fallback:{...R,backgroundColor:"transparent"}}),Y({target:n,layoutParams:this.control.layoutParams,fallback:R}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Se(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${O.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add(Se(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add(Se(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(S.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(S.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(Vt(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";wt({target:this.controlElement,props:this.control.props,fallback:R,isDark:e,baseDimension:t}),ne({target:this.controlElement,props:this.control.props,fallback:{...R,borderColor:e?R.shadowColorDark:R.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??R.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else ne({target:this.controlElement,props:this.control.props,fallback:{...R,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(S.blinkAnim,e),this.controlElement?.classList.toggle(S.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${S.blinkAnimArea}`)||this.controlElement.classList.contains(S.selected)||this.controlElement.classList.contains(O.disabled)||(this.controlElement.classList.add(O.disabled),this.subscriptions.add(Se(e,"animationiteration").pipe(bn()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(O.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${S.blinkAnimArea}`)||this.controlElement.classList.contains(S.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new w(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};import{fromEvent as ke,once as vn}from"@vkontakte/videoplayer-shared/evergreen";var we=i=>{let e=document.createElement("span");switch(i){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let r={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,r),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var Re=(i,e)=>{if(i.type.trim().toLowerCase()==="button")return new nt(i,e)},nt=class extends D{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(S.common,S.button),n.setAttribute("data-testid",W.BUTTON),Y({target:n,layoutParams:this.control.layoutParams,fallback:R}),ge({target:n,props:this.control.props,fallback:R}),ne({target:n,props:this.control.props,fallback:R,dependsOn:this.container.dimensions}),be({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=we(this.control.type.trim().toLowerCase()),o=r.firstElementChild??r;ve({target:o,props:this.control.props,fallback:R,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(ke(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${O.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add(ke(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add(ke(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(S.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(S.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(S.blinkAnim,e),this.controlElement?.classList.toggle(S.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${S.blinkAnimButton}`)||this.controlElement.classList.contains(S.selected)||this.controlElement.classList.contains(O.disabled)||(this.controlElement.classList.add(O.disabled),this.subscriptions.add(ke(e,"animationiteration").pipe(vn()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(O.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${S.blinkAnimButton}`)||this.controlElement.classList.contains(S.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new w(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var Mt=(i,e)=>{if(i.type.trim().toLowerCase()==="text")return new it(i,e)},it=class extends D{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(S.common,S.text),n.setAttribute("data-testid",W.TEXT),Y({target:n,layoutParams:this.control.layoutParams,fallback:R}),be({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=we(this.control.type.trim().toLowerCase()),o=r.firstElementChild??r;ve({target:o,props:this.control.props,fallback:R,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}onError(){}};var Ve=(i,e,t,n)=>{if(i.type.trim().toLowerCase()==="choice")return new rt(i,e,t,n)},rt=class extends Z{constructor(t,n,r,o){super(t,r,o);this.containerElement=null;this.controlSubscriptions=new En;this.error$=new gn;this.rootElement=n,this.layout=new Ce(this.container.layout,r),this.cssVarsManager=r,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Re),this.addControlFactory("text",Mt),this.addControlFactory("area",Ae)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(N.common,N.disabled),requestAnimationFrame(()=>{n.classList.remove(N.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(r=>{r.setCssVarsManager(this.cssVarsManager),r.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),r.setEvents(t),this.controlSubscriptions.add(r.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(N.hidden)}show(){let t=this.getElement();t&&t.classList.remove(N.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(N.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(N.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(r=>{r.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};import{combine as Kn,InterfaceLanguage as Qn,Observable as hn,once as Xn,Subject as $,Subscription as bt,ValueSubject as j,fromEvent as un}from"@vkontakte/videoplayer-shared/evergreen";import{InteractiveInterfaceClick as fe}from"@vkontakte/videoplayer-statistics/evergreen";import{loadVKLangPack as In}from"@vkontakte/videoplayer-shared/evergreen";function se(i,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>i(...n),e)}}var Pt="video_interactive",Ot="videoint";var Nt=250,ae=class{constructor(e){this.handleZoomChange=se(e=>{this.lastZoomInfo=e},Nt);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.("Chapter id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor?.selectChapter(e.id),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{if(this.isReady=!1,!xe(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=xn(e),this.resizeObserver=new ResizeObserver(se(this.onResize,Nt)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await In(this.lang,Pt,Ot)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...r})=>{n==="openPreview"&&"chapterId"in r&&this.onOpenPreviewClick?.(r.chapterId)}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function xn(i){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",i.append(e),e}var le=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,r=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let p=o.startTime-e;if(p<=r&&(o.endTime&&r<=o.endTime||o.endTime===null)){n=!0;break}r<p&&(t=t===-1?p:Math.min(t,p))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as Pe,ContainerTypes as Hr,ControlTypes as Oe,EventActionTypes as x,EventTypes as Dr,migrateManifestToLatestVersion as jt,compareVersions as Ur}from"@interactiveplatform/movika-manifest";var $t={metadata:"Object",chapters:"Array"},Lt=i=>{if(!G(i))return!1;for(let e in $t)if(!i[e]||!U(i[e],$t[e]))return!1;return Pe(i.metadata.version)},Me=i=>i.type===Oe.Text,Or=i=>i.type===Oe.Button,Nr=i=>i.type===Oe.Area,$r={Choice:"Choice",TextInput:"TextInput"},Lr={Button:"Button",Area:"Area",Text:"Text"},Fr={onClick:"onClick",onSuspense:"onSuspense"},Ft={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ne=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let r=n.length;r>0;r--)if(n[r]===t){n.splice(r,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(r=>{r(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var $e=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Rt(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Le=class i{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=i.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",n="test";e.style.setProperty(t,n);let r=e.style.getPropertyValue(t)===n;return r&&e.style.removeProperty(t),r}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,n]of Object.entries(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as Vn}from"@vkontakte/videoplayer-shared/evergreen";var Fe=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Tn(...this.loaders[e])(t)}};function Tn(...i){return async function(t){let n=[...i];for(;n.length>0;)t=await n.shift()(t);return t}}function ce(i,e,t){return i?{...i,[e]:i[e]?[t,...i[e]]:[t]}:{[e]:[t]}}function je({actions:i,errors:e,chapterId:t,...n}){if(t){let r=i.getManifest();if(r){let o=i.getChapter(r.chapters,t);if(o){let p=i.getMedia(r.media,o.videoId),s=i.getGraph(r.graph,o.id);return p?{...n,actions:i,errors:e,result:{chapter:o,media:p,graph:s}}:{...n,errors:ce(e,je.name,"Could not find media"),actions:i}}}}return{...n,errors:ce(e,je.name,"Could not find chapter"),actions:i}}var ot=(i="",e="")=>{let t=i.split("."),n=e.split("."),r=0;for(let o=0;o<Math.max(t.length,n.length)&&!r;o++)t[o]>n[o]?r=1:t[o]<n[o]?r=-1:r=0;return r};var Sn=async i=>{try{let e={},t;if(Ee(i)){t=new URL(i).href;let r=await fetch(t);if(!r.ok)return{};e=await r.json()}else if(G(i))e=i;else return{};if(!Lt(e))return{};let n=e.metadata.media;if(Ee(n)&&!("media"in e))try{let r;t?r=new URL(n,t).href:(r=new URL(n).href,t=r);let o=await fetch(r);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return kn(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Bt(i){let{manifest:e,manifestURL:t}=await Sn(i);if(!e)throw new Error("Failed on fetch");let n=jt(e);return n.media=An(n.media,t),delete n.metadata.media,n}function Be(i,e){if(e)return i.find(t=>t.id===e)}function st(i,e){return i.edit?.chapters?i.edit.chapters.find(t=>t.id===e):i.view?.chapters?i.view.chapters.find(t=>t.id===e):void 0}function at(i,e){return i.videos.find(t=>t.id===e)}function An(i,e){return{...i,videos:i.videos.map(t=>({...t,variants:t.variants.map(n=>{let r="url"in n?n.url:"",o=wn(r,e);return{...n,url:o||r}})}))}}function wn(i="",e){try{return new URL(i,e).href}catch{return""}}function kn(i){return ot(i,"3.2.0")>=0}var _e=i=>Ie(i)&&!Ye(i),H=i=>i.order==="end",He=i=>Ie(i.containers)&&!Ye(i.containers)&&H(i),_t=(i,e)=>{let t=i*1e3;return _e(e.controls)&&t<(e.startTime??0)},lt=(i,e)=>{let t=i*1e3;return _e(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var Q=(i=[])=>i.some(e=>e.action.type==="expect"),ct=(i=[])=>i.find(e=>e.action.type==="expect"),Rn=i=>i?.length===1,J=i=>Rn(i)&&Me(i[0]);function Ht(i=[],e=1/0,t=[]){return i.filter(({container:n})=>!t.includes(n.container.id)&&Q(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function De({gameControllers:i=[],subjectName:e,subjectId:t,execFn:n}){for(let r of i)if(e==="container"&&r.container.container.id===t){n(r),Ht(i,r.container.container.endTime,[r.container.container.id]).forEach(p=>{n(p)});break}}var Dt=(i,e)=>{let t=A=>e.find(({container:c})=>c.container.id===A)?.container.isRemoved,n=Q(i.events)&&!t(i.id),r=(A,y=!1,c=!1)=>{let a=c?"every":"some";return A.controls[a](u=>{let f=y?A.endTime===i.endTime:!0;return u.events?.[a](m=>m.action?.type===Ft.openURI)&&f})},o=A=>A.some(({container:y})=>r(y.container,!0,!1)&&!y.isRemoved),p=A=>A.every(({container:y})=>y.isRemoved?!0:r(y.container,!0,!0)),s=Ht(e,i.endTime,[i.id]).length,l=A=>A.controls.some(y=>y.events?.some(c=>c.action?.args?.shouldOpenNow)),h=n||s>0,d=o(e),v=r(i),C=p(e),b=n?!1:s>0,P=l(i);return{isExpectTime:h,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:C,isExpectEventForCurrentContainer:b,hasShouldOpenNowEvent:P}};var ee=class extends Fe{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Vn(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:ce},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await Bt(n.result??t),this}async setInitial(){return this.setNext()}async setNext(t=this.manifest?.metadata.initChapterId){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",je({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:st,getChapter:Be,getMedia:at,getByBranches:this.getByBranches.bind(this),addErrorMessage:ce},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(t=this.manifest?.metadata.initChapterId){if(!t||!this.manifest)return null;let n=Be(this.manifest.chapters,t);if(n){let r=at(this.manifest.media,n.videoId),o=st(this.manifest.graph,n.id);if(r)return{chapter:n,media:r,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Be(this.manifest?.chapters||[],t);return this.getByBranches(n?.branches)}}getByBranches(t=[]){return t.reduce((n,r)=>{let o=this.getByChapterId(r.chapterId);return o&&n.push(o),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?H(this.chapter):!1}};import{Player as Mn}from"@vkontakte/videoplayer-core/evergreen";import{Subscription as ut,Tracer as Pn,ValueSubject as On}from"@vkontakte/videoplayer-shared/evergreen";var Ut=i=>{let e=i.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};function pt(){let i=new Map;function e({listId:o=Math.random().toString(),itemId:p=Math.random().toString(),...s}){let l=i.get(o),h={...s};return l?l[p]=h:i.set(o,{[p]:h}),{listId:o,itemId:p,...s}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function n(o,p){let s=i.get(o);if(!s)throw Error("Can't remove. Not find.");if(p){let l=s[p];l&&t(l),delete s[p],Object.keys(s).length||i.delete(o)}else{for(let l of Object.values(s))t(l);i.delete(o)}}function r(){for(let o of i)n(o[0])}return{createPlayer:e,removePlayer:n,map:i,removeAll:r}}function ht(i,e=[]){let t={},n,r=!e.length;for(let o of i.variants)if(!n&&"cover"in o&&(n=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(r||e.includes("mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(r||e.includes("mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(r||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(r||e.includes("dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:n,title:i.title??""}}var pe=(i,e)=>{let t=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();t!==e&&n.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))};var Nn=2;function dt(i){let e=pt(),t=new ut,n={},r=null,o=!1,p,s=new On(null);i&&l(i);function l(y){r=y}function h(y,c,a){if(!r)throw Error("need to set interactive controller");if(!r.options)return;let f=(e.map.get(y)??{})[c];if(f){n={chapterId:a,listId:y,itemId:c,...f};let m=n.player;n.subscription.add(m.info.currentQuality$.subscribe(g=>{let T=m.info.position$.getValue(),L=m.info.isAutoQualityEnabled$.getValue();if(!(!g||!T||L))for(let E of e.map)Object.values(E[1]).forEach(({player:V})=>{pe(V,g)})})).add(m.events.started$.subscribe(()=>{d(c)})),f.container.remove(),r.setPlayer(f.player),o||(r.init(),o=!0),s.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(y){if(!r)throw Error("need to set interactive controller");if(K(n)||y!==n.itemId)return;let c=r.getChapterBranches(),a=new Set;for(let u of c)a.has(u.media.id)||(await C({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),a.add(u.media.id))}async function v({chapter:{id:y},manifestVideo:c}){if(K(n)||!r)return;let a=n.player.info.muted$.getValue(),u=n.player.info.currentQuality$.getValue(),f=n.player.info.isAutoQualityEnabled$.getValue(),m=n.player.info.volume$.getValue(),g=n.player.info.currentPlaybackRate$.getValue(),T=!f,L=!1;for(let E of e.map)if(E[0]===c.id&&!r.state.isReplay$.getValue()){let V=Object.keys(E[1]);for(let M of V)M===n.itemId?(V.length<Nn||(L=!0),e.removePlayer(E[0],M)):(L=!0,h(E[0],M,y),T?pe(n.player,u):n.player.setAutoQuality(!0),n.player.setVolume(m),n.player.setMuted(a),n.player.setPlaybackRate(g))}else e.removePlayer(E[0]);L||(await C({media:c,chapterId:y,setAsActive:!0,playbackRate:g}),T?pe(n.player,u):n.player.setAutoQuality(!0),n.player.setVolume(m),n.player.setMuted(a))}async function C({media:y,chapterId:c,prefetch:a=!0,setAsActive:u=!0,autoplay:f=!1,preferredExt:m,title:g,playbackRate:T}){let L=Math.random().toString(),E=document.createElement("div");p.append(E);let V;if(r?.options?.vkVideoLoader){let ye=Ut(y);ye.length&&(V=await r.options.vkVideoLoader(...ye))}let M=r?.options?.coreConfig||void 0,B={...M,configName:[...M?.configName??[],"interactive"]},z={container:E,...V?.videos?.[0]||{sources:ht(y,m).sources},title:g,failoverHosts:V?.failoverHosts||[]},F=new Mn(B,Pn.createRootTracer());F.initVideo(z);let X=null;if(V?.videos&&r?.options.createOneStat){let ye=V.videos[0],Qe=r.options.createOneStat(ye),gt=new ut;Qe&&(gt.add(Qe.attachTo(F)),X={oneStat:Qe,statSubscription:gt})}let vt=new ut,mn=n?.player?.info.isAutoQualityEnabled$.getValue();vt.add(F.events.canplay$.subscribe(function(){mn||pe(F,n.player.info.currentQuality$.getValue()),T&&F.setPlaybackRate(T)}));let q=e.createPlayer({listId:y.id,itemId:L,player:F,container:E,sources:ht(y,m).sources,config:z,subscription:vt,statistics:X});return u&&h(y.id,q.itemId,c),f&&q.player.play(),a&&!f&&q.player.prepare(),{player:q.player,config:q.config,statistics:q.statistics}}function b(){P(),r=null,p.remove()}function P(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function A(){if(!r)throw Error("need to set interactive controller");P(),p=document.createElement("div");let{media:y,chapter:c}=r.getCurrentChapter();y&&c?(t.add(r.events.chapterChanged$.subscribe(v)),await C({media:y,chapterId:c.id,title:c.label})):console.error("not found")}return{...e,init:A,setInteractiveController:l,createPlayer:C,removeAll:b,getActivePlayer:function(){return n},activePlayerChanged:s}}var I={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},he={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},k={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as $n}from"@vkontakte/videoplayer-shared/evergreen";function mt(i){return function(...t){return i(...t.reverse())}}function ue(i,...e){return(...t)=>G(e[0])&&G(t[0])?i({...e[0],...t[0]}):i(...e,...t)}var Ue=class{constructor({player:e,container:t,branches:n,selectBranches:r,interactiveEvents:o,globalEvents:p,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:h,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:C,onError:b}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(Q(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&this.container.hide?.(),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&t)return;this.emitContainerVisibilityEvent(!0,!1)}else{let t={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(r,o)=>{let{isExpectTime:p,hasOtherExpect:s,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:h,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:v}=this.getContainerEventState(),C=this.interactiveTimeOpenUri&&!h,b=this.interactiveTimeOpenUri&&h;if((!this.interactiveTimeOpenUri||C)&&(this.isSelectedControlEvent=!0),r!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||C)){if(this.interactiveTimeOpenUri){let P=!s&&!d&&h;P&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:P})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&l&&this.gameState!==5){if(b){let A=((y,c,a,u)=>!y&&!c&&a||y&&!c&&a&&!u||y&&!c&&a&&u)(p,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(A)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!p||!s||!v)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=ue(this.selectBranches.onControlEvent,t);this.container.createView({eventCallback:n}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&this.container.disable?.()}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,r=[6,5];if(!n||r.includes(this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(_t(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(lt(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let h=this.gameState;this.gameState=3,h===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:h}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,v=this.interactiveTimeOpenUri&&h;if(v&&!d){let C=this.container.getElement();C&&(C.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!v&&this.removeView()}let p=lt(o,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:o,isInteractiveTime:p};this.container.onProgress(o*1e3,p),this.globalEventEmitter.emit(I.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=n,this.selectBranches=r,this.subscription=new $n,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l,this.isPermanentText=h&&J(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=C,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=p,this.onError=b,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{e?this.container.disable?.():this.container.enable?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:Q(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){this.container.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var zt=(i=[])=>i.reduce((e,t,n)=>{let r=(t?.controls??[]).filter(o=>!Me(o));if(_e(r)){let o=[t.startTime??0,t.endTime??1/0],p={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[p],range:o});else{let s=[],l=-1/0,h=1/0,d=[],v=[];for(let C=0;C<e.length;C++){let b=e[C];if(v.push(...b.subjects),b.range[0]<h&&(h=b.range[0]),b.range[1]>l&&(l=b.range[1]),o[0]>=b.range[0]&&o[1]<=b.range[1])return e[C].subjects.push(p),e;o[0]<b.range[0]&&o[1]>b.range[0]&&(s.push(C),d=d.concat(b.subjects)),o[0]>=b.range[0]&&o[0]<=b.range[1]&&(s.push(C),d=d.concat(b.subjects),o[0]=b.range[0]),o[1]>=b.range[0]&&o[1]<=b.range[1]&&(s.push(C),d=d.concat(b.subjects),o[1]=b.range[1])}if(v.push(p),o[0]<=h&&o[1]>=l)return[{subjects:v,range:o}];s.length&&s.reverse().forEach(C=>{e.splice(C,1)}),e.push({subjects:d.concat([p]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function Wt(){let i={};function e(){for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&delete i[s]}function t(s){let l={};for(let h in i)+h<=s&&(l[h]=i[h]);return l}function n(s){let l={};for(let h in i)+h>=s&&(l[h]=i[h]);return l}function r({timestamp:s,priority:l,initiator:h}){if(Ze(s)){let d=i[s]??null;if(d&&l&&oe(l,!0)){let v={},C=d[l];return C&&(v={...v,...C}),v=K(v)?null:v,v&&oe(h,!0)?v[h]??null:v}return d}return null}function o({timestamp:s,priority:l,initiator:h}){if(Ze(s))if(i[s]){if(l&&oe(l,!0))if(i[s][l]){if(h&&oe(h,!0))if(i[s][l][h]){if(delete i[s][l][h],!K(i[s][l]))return!0}else return!1;if(delete i[s][l],!K(i[s]))return!0}else return!1;return delete i[s]}else return!1;return!1}function p({timestamp:s,priority:l,initiator:h,...d}){i[s]?.[l]?.[h]?i[s][l][h].push({...d}):i[s]?.[l]?i[s][l]={...i[s][l],[h]:[{...d}]}:i[s]?i[s]={...i[s],[l]:{[h]:[{...d}]}}:i[s]={[l]:{[h]:[{...d}]}}}return{map:i,remove:o,add:p,removeAll:e,get:r,getLte:t,getGte:n}}var Ln=[x.expect,x.setNextBranch],Fn=1/0;function Kt(i,e){let t=i,n,r=jn(e),o=Wt(),p,s=()=>{b(),c()},l=a=>{o.add.call(void 0,a),P()},h=(a=[])=>{for(let u of a)if(u.action(),Ln.includes(u.actionType))break},d=(a=1/0)=>{let u=Ge(o.get({timestamp:a,priority:"control"})??{}),f=Ge(o.get({timestamp:a,priority:"container"})??{}),m=Ge(o.get({timestamp:a,priority:"chapter"})??{});return[...u,...f,...m]},v=a=>{r.isReady(a)&&h(d(a))},C=()=>{h([...Ge(o.get({timestamp:1/0,priority:"chapter"})??{})])},b=()=>{n&&(p?.unsubscribe(),n=void 0)},P=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),p=t.events.ended$.subscribe(n))},A=a=>{b(),t=a},y=a=>{a.priority==="container"&&r.resetCalled(a.timestamp),o.remove(a)},c=()=>{r.release(),o.removeAll()};return{setPlayer:A,add:l,remove:y,exec:v,execEndOfVideo:C,listen:P,unlisten:b,release:s,containersEventsCallState:r,getPreparedToExecActions:d}}function jn(i){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let h=e.get(s);h&&h[l]!==void 0&&(h[l]=!0)},setData:(s=[])=>{for(let l of s){let h=l.endTime??Fn,d=e.get(h);e.set(h,{...d,[l.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let h in l)l[h]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let h=Object.values(l);return i?h.some(v=>v):!h.some(v=>!v)},release:()=>e.clear()}}function Ge(i){return Object.values(i).flat().sort(e=>e.actionType===x.expect?-1:1)}var Qt={videoContentHeight:0,videoContentWidth:0},Xt=i=>{let{height:e,width:t}=i.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Qt;let{clientHeight:n,clientWidth:r}=i.experimental.element$.getValue()||{};if(!(n&&r))return Qt;let o=e/t,p=n/r,s,l;return p>o?(l=r,s=r*o):p<o?(l=n/o,s=n):(l=r,s=n),{videoContentWidth:l,videoContentHeight:s}};var Bn=250;function qt(i){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:l,player:h,cssVarsManager:d}=i();if(!l||!h)return;let{videoContentWidth:v,videoContentHeight:C}=Xt(h);d.setup({"--interactive-content-width":`${v}px`,"--interactive-content-height":`${C}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function r(){let{parentElement:s}=i();s.removeAttribute("style")}let o=se(s=>{let{fns:l=[]}=i();n(s);for(let h of l)h()},Bn);function p(){e=void 0,t.disconnect(),r()}return{resizeObserver:t,calc:()=>{e?.()},release:p}}var _n=i=>Math.floor(Math.random()*i),Yt=i=>{let e=i.length,t=1/0,n=null;for(;e--;){let r=i[e],o=r.weight??1;o<t&&(t=o,n=r)}return n},Jt=i=>{let e=i.length,t=-1/0,n=null;for(;e--;){let r=i[e],o=r.weight??0;o>t&&(t=o,n=r)}return n};var en=i=>{let e=i.length,t=_n(e);return i[t]},Zt=1,tn=i=>{let e=0;for(let n=0;n<i.length;++n)e+=i[n].weight??Zt;let t=Math.random()*e;e=0;for(let n=0;n<i.length-1;++n)if(e+=i[n].weight??Zt,e>=t)return i[n];return i[i.length-1]};var nn={shouldOpenNow:!0,isDetachContainer:!0},rn="after-expect",ft=(i,e=!1)=>({...i,args:e?{...i.args,...nn}:{...nn,...i.args}}),on=({globalEventEmitter:i,globalEvents:e,player:t,interactiveEvents:n})=>{let r={isExpect:!1},o=()=>{r.isExpect&&(r.isExpect=!1)},p=({action:c,controlType:a,controlId:u,containerId:f,branches:m=[],onEvent:g,isEOV:T=()=>!1,isDisabled:L=()=>!1})=>{let E=ft(c,T()),V={timestamp:1/0,priority:"control",initiator:u,actionType:E.type},M=L(),B=i.emit.bind(i,I.interactives,{subjectId:u,subjectType:a,subjectName:"control",type:M?k.actionChoiceCanceled:k.actionChoice,actionType:c.type,payload:{invokeImmediately:E.args.shouldOpenNow,containerId:f,...E.args}}),z=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectType:a,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:c.type,payload:{invokeImmediately:E.args.shouldOpenNow,containerId:f,...E.args}})};if(M){B(),z();return}switch(E.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let F=m.find(X=>X.id===E.args.branchId);if(!F)return;g(E.args.isDetachContainer,b.bind(null,{subjectId:u,subjectName:"control"})),B(),z(),E.args.shouldOpenNow?A({subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{chapterId:F.chapterId,autoSelect:!1}}):n.add({...V,action:A.bind(null,{subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{chapterId:F.chapterId,autoSelect:!1}})});return}case x.continuePlayback.trim().toLowerCase():{g(E.args.isDetachContainer,b.bind(null,{subjectId:u,subjectName:"control"})),B(),z(),E.args.shouldOpenNow?P({subjectId:u,subjectName:"control",subjectType:a,action:c}):n.add({...V,action:P.bind(null,{subjectId:u,subjectName:"control",subjectType:a,action:c})});return}case x.openURI.trim().toLowerCase():{g(E.args.isDetachContainer,b.bind(null,{subjectId:u,subjectName:"control"})),B(),z(),E.args.shouldOpenNow?y({subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{URI:c.args.uri}}):n.add({...V,action:y.bind(null,{subjectId:u,subjectName:"control",subjectType:a,action:E,payload:{URI:c.args.uri}})});return}default:{let F="Unexpected control event",X=new w(1,1,{message:F});d(X,F);return}}},s=({action:c,container:{id:a,endTime:u},branches:f=[],isEOV:m=!1,autoSelected:g=!1})=>{let T=ft(c,m),L={timestamp:!T.args.shouldOpenNow||m?1/0:u??1/0,priority:"container",initiator:a,actionType:T.type},E=i.emit.bind(i,I.interactives,{subjectId:a,subjectName:"container",type:k.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),V=()=>{e.interactiveActionChoice$.next({subjectId:a,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let M=f.find(B=>B.id===T.args.branchId);if(!M)return;E(),V(),n.add({...L,action:A.bind(null,{subjectId:a,subjectName:"container",action:T,payload:{chapterId:M.chapterId,autoSelect:g}})});return}case x.setMaxWeightBranch.trim().toLowerCase():return;case x.setMinWeightBranch.trim().toLowerCase():return;case x.setRandomBranch.trim().toLowerCase():return;case x.setWeightlessRandomBranch.trim().toLowerCase():return;case x.continuePlayback.trim().toLowerCase():{E(),V(),n.add({...L,action:P.bind(null,{subjectId:a,subjectName:"container",action:T})});return}case x.openURI.trim().toLowerCase():{E(),V(),n.add({...L,action:y.bind(null,{subjectId:a,subjectName:"container",action:T,payload:{URI:c.args.uri}})});return}default:{let M="Unexpected container event",B=new w(1,1,{message:M});d(B,M);return}}};function l({container:c,branches:a,isEOV:u=!1}){let f=ct(c.events);if(f){let m=ft(f.action,u);i.emit(I.interactives,{subjectId:c.id,subjectName:"container",type:k.actionChoice,actionType:m.type,payload:{invokeImmediately:m.args.shouldOpenNow,...m.args}}),e.interactiveActionChoice$.next({subjectId:c.id,subjectName:"container",type:"action-choice",actionType:m.type,payload:{invokeImmediately:m.args.shouldOpenNow,...m.args}}),n.add({timestamp:u?1/0:c.endTime??1/0,priority:"container",initiator:c.id,actionType:x.expect,action:C.bind(null,{subjectId:c.id,subjectName:"container"})}),r.isExpect=!0}else for(let m of c.events??[])s({action:m.action,container:c,branches:a,isEOV:u})}let h=({chapterId:c,action:a,branches:u=[]})=>{let f=i.emit.bind(i,I.interactives,{subjectId:c,subjectName:"chapter",type:k.actionChoice,actionType:a.type,payload:a.args}),m=()=>{e.interactiveActionChoice$.next({subjectId:c,subjectName:"chapter",type:"action-choice",actionType:a.type,payload:a.args})};switch(a.type.trim().toLowerCase()){case x.setNextBranch.trim().toLowerCase():{let g=u.find(T=>T.id===a.args.branchId);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setWeightlessRandomBranch.trim().toLowerCase():{let g=en(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setRandomBranch.trim().toLowerCase():{let g=tn(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setMaxWeightBranch.trim().toLowerCase():{let g=Jt(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.setMinWeightBranch.trim().toLowerCase():{let g=Yt(u);return g?.chapterId?(f(),m(),A.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case x.continuePlayback.trim().toLowerCase():return f(),m(),P.bind(null,{subjectId:c,subjectName:"chapter",action:a});case x.openURI.trim().toLowerCase():return f(),m(),y.bind(null,{subjectId:c,subjectName:"chapter",action:a,payload:{URI:a.args.uri}});default:{let g="Unexpected chapter event",T=new w(1,1,{message:g});d(T,g);return}}};function d(c,a){console.error(a),e.error$.next(c),i.emit(I.errors,c)}function v(c){let a=ct(c.events);if(a){if(H(c))return;i.emit(I.interactives,{subjectId:c.id,subjectName:"chapter",type:k.actionChoice,actionType:a.action.type,payload:a.action.args}),e.interactiveActionChoice$.next({subjectId:c.id,subjectName:"chapter",type:"action-choice",actionType:a.action.type,payload:a.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:c.id,actionType:x.expect,action:C.bind(null,{subjectId:c.id,subjectName:"chapter"})})}else c.events?.forEach(u=>{let f=h({chapterId:c.id,action:u.action,branches:c.branches});f&&n.add({timestamp:1/0,priority:"chapter",initiator:c.id,actionType:u.action.type,action:f})})}let C=({subjectId:c,subjectName:a})=>{t.pause(),i.emit(I.interactives,{subjectId:c,subjectName:a,type:k.actionExecution,actionType:x.expect}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,type:"action-execution",actionType:x.expect})},b=({subjectId:c,subjectName:a})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),i.emit(I.interactives,{subjectId:c,subjectName:a,type:k.actionExecution,actionType:rn}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,type:"action-execution",actionType:rn})},P=({subjectId:c,subjectName:a,subjectType:u,action:f})=>{i.emit(I.interactives,{subjectId:c,subjectName:a,subjectType:u,type:k.actionExecution,actionType:f.type}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,subjectType:u,type:"action-execution",actionType:f.type})},A=({subjectId:c,subjectName:a,subjectType:u,action:f,payload:m})=>{m.behaviour="change-chapter",i.emit(I.interactives,{subjectId:c,subjectName:a,subjectType:u,type:k.actionExecution,actionType:f.type,payload:m}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,subjectType:u,type:"action-execution",actionType:f.type,payload:m})},y=({subjectId:c,subjectName:a,subjectType:u,action:f,payload:m})=>{if(!m.URI)return;let g=window.open(m.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),i.emit(I.interactives,{subjectId:c,subjectName:a,subjectType:u,type:k.actionExecution,actionType:f.type}),e.interactiveActionExecution$.next({subjectId:c,subjectName:a,subjectType:u,type:"action-execution",actionType:f.type})};return{onControlEvent:p,onContainerEvent:s,onChapterEvent:h,onExpectEvent:C,expectEventHandler:b,setManifestChapterEvents:v,setManifestContainerEvents:l,stopExpect:o,state:r}};import{Subscription as zn,Subject as Ct,ValueSubject as de}from"@vkontakte/videoplayer-shared/evergreen";var yt=(i,e)=>{let t={};return i.map(n=>{if(!t[n]){let r=e.chapters.find(p=>p.id===n);if(!r)return null;let o=e.media.videos.find(p=>r.videoId===p.id);if(!o)return null;t[n]=sn(o)}return t[n]}).filter(Boolean)},Dn=i=>{for(let e of i.variants)if(Un(e)&&e.payload)return e.payload.id},Un=i=>!!(i.type==="custom"&&i.payload&&i.payload.type==="vk"),sn=i=>{let e=Dn(i);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Gn=(i,e)=>{for(let t of i.media.videos)if(e===sn(t)){for(let n of i.chapters)if(n.videoId===t.id)return n.id;return}},an=(i,e)=>i.reduce((t,n)=>{let r=Gn(e,n);return r?[...t,r]:t},[]);var me=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:r,settings:o}){this.state={history$:new de([]),hasPrevChapter$:new de(!1),prevChapter$:new de(null),isInitialChapter$:new de(!1),isGoBackLimited$:new de(!1)};this.#n=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new Ct,destroyed$:new Ct,error$:new Ct};this.#i=null;this.#r=null;this.#t=null;this.#a=new zn;this.#l=!1;this.#c=0;this.#i=t,this.#t=e,this.#r=n,this.#n=r,this.#o=o,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(p=>{this.state.prevChapter$.next(p.at(-2)||null),this.state.hasPrevChapter$.next(p.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#o.maxLength-1)}))}#n;#o;#s;#e;#p;#i;#r;#t;#a;#l;#c;async setManifest(e){if(!this.#r||!this.#t)return;this.#e=e,await this.getProjectHistory();let t=this.getInitialChapterId();await this.#r.setChapter({chapterId:t,pushToHistory:!1}),this.#s||(this.#s=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#s}async updateHistory(e,t=!0){if(!this.#e)return;this.#l?(this.#l=!1,this.#c++):this.#c=0;let n=this.#e,r=e.length-this.#o.maxLength,o=r>0?e.slice(r):e,p=yt(o,n);if(this.#p=p,this.state.history$.next(o),!(!t||!this.#n||!this.#i))try{await this.#n.save(this.#i,p)}catch{let l=new w(1,5,"Unable to save interactive history");this.events.error$.next(l),this.#t?.emit(I.errors,l)}}async goBack(){if(!this.state||!this.#r){let n=new w(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(I.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#r.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#i)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#n)try{let r=await this.#n.get(this.#i);r.length&&(t=r)}catch{let o=new w(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(I.errors,o)}let n=an(t,e);this.state.history$.next(n)}getInitialChapterId(){return this.state.history$.getValue()?.at(-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return yt([e],this.#e).pop()}return null}destroy(){this.#i=null,this.#n=null,this.#r=null,this.#a?.unsubscribe(),this.#a=null,this.#s=!1,this.#t?.emit(I.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var ze=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){this.rootElement.getContext("2d")?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let r=3;r<n;r+=40)if(t[r]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let r;t&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&r&&this.restore(r),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var We=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-interactive",
3
- "version": "1.0.37-dev.cffc5829.0",
3
+ "version": "1.0.37-dev.ecd6447c.0",
4
4
  "author": "vk.com",
5
5
  "description": "Movika interactive SDK",
6
6
  "homepage": "https://vk.com",
@@ -56,8 +56,8 @@
56
56
  "dependencies": {
57
57
  "@interactiveplatform/movika-graph-editor": "2.1.7",
58
58
  "@interactiveplatform/movika-manifest": "1.0.1",
59
- "@vkontakte/videoplayer-core": "2.0.131",
60
- "@vkontakte/videoplayer-shared": "1.0.59",
61
- "@vkontakte/videoplayer-statistics": "1.0.77"
59
+ "@vkontakte/videoplayer-core": "2.0.132-dev.92ef5045.0",
60
+ "@vkontakte/videoplayer-shared": "1.0.60-dev.cffc5829.0",
61
+ "@vkontakte/videoplayer-statistics": "1.0.78-dev.521e3633.0"
62
62
  }
63
63
  }