@vkontakte/videoplayer-interactive 1.0.16-dev.4720172e.0 → 1.0.16-dev.4f41c335.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -6
- package/es2015.esm.js +6 -6
- package/es2018.cjs.js +6 -6
- package/es2018.esm.js +6 -6
- package/esnext.cjs.js +6 -6
- package/esnext.esm.js +6 -6
- package/evergreen.esm.js +5 -5
- package/package.json +4 -3
- package/types/index.d.ts +1 -1
- package/types/modules/Interactives/Interactives.d.ts +1 -1
- package/types/modules/ManifestController/ManifestController.d.ts +29 -29
- package/types/modules/ManifestController/utils.d.ts +12 -15
- package/types/modules/SeamlessController/InstanceManager.d.ts +7 -1
- package/types/modules/SeamlessController/SeamlessController.d.ts +2 -10
- package/types/movika.core/manifest/index.d.ts +6 -2
- package/types/movika.core/manifest/types.d.ts +0 -7
package/evergreen.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.16-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.16-dev.4f41c335.0
|
|
3
|
+
* Wed, 04 Sep 2024 09:12:43 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-16/doc/
|
|
5
5
|
*/
|
|
6
|
-
var pe="1.0.16-dev.4720172e.0";function Ht(i,t=1){let e="0",n="0",s="0";return i.length===4?(e="0x"+i[1]+i[1],n="0x"+i[2]+i[2],s="0x"+i[3]+i[3]):i.length===7&&(e="0x"+i[1]+i[2],n="0x"+i[3]+i[4],s="0x"+i[5]+i[6]),`rgba(${+e},${+n},${+s},${t})`}var _="SDK_NAME",Ye="SDK_NAME-controls-container",dt=()=>document.querySelector(`.${Ye}`),me=.4,L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},de={top:"flex-start",bottom:"flex-end",center:"center"},ue={start:"flex-start",end:"flex-end",center:"center"},fe={start:"left",end:"right",center:"center"},ut=({target:i,props:t})=>{i.style.alignItems=de[t?.text?.gravityVertical]??de.center,i.style.justifyContent=ue[t?.text?.gravityHorizontal]??ue.center,i.style.textAlign=fe[t?.text?.alignment]??fe.start},ft=({target:i,props:t,fallback:e,dependsOn:n})=>{i.style.color=t?.text?.color??e.textColor,i.style.fontSize=`calc(${n.height} * ${t?.text?.size??e.textSize})`,i.textContent=t?.text?.value??e.textContent},mt=({target:i,props:t,fallback:e})=>{i.style.backgroundColor=Ht(t?.background?.color??e.backgroundColor,t?.background?.alpha??e.backgroundAlpha)},yt=({target:i,props:t,fallback:e,dependsOn:n})=>{i.style.border=`calc(${n.height} * ${t?.shape?.border?.width??e.borderWidth}) solid ${Ht(t?.shape?.border?.color??e.borderColor,t?.shape?.border?.alpha??e.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${t?.shape?.roundCorners??e.roundCorners})`},W=({target:i,layoutParams:t,fallback:e})=>{i.style.transform=`rotate(${-t.angle}rad)`};var Dt="int",Q={AREA:`${Dt}_area`,TEXT:`${Dt}_text`,BUTTON:`${Dt}_bttn`};var F=class{constructor(t){this.control=t}createView(t){let e=document.createElement("div");e.classList.add(`${_}-control-container-${this.control.id}`),t(e,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??L.innerSizesDependOn)==="self"?{height:e.style.height,width:e.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:e,dependsOn:n}}setEvents(t,e){t&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":t.addEventListener("click",r=>{r.stopPropagation(),e&&e({action:n.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${_}-control-container-${this.control.id}`)}};var gt=i=>{if(i.type.trim().toLowerCase()==="area")return new Gt(i)},Gt=class extends F{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:s}=super.createView(e),r=document.createElement("button");return r.classList.add(`${_}-${this.control.id}`),r.setAttribute("data-testid",Q.AREA),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.type="button",mt({target:r,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),yt({target:r,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:n}),W({target:r,layoutParams:this.control.layoutParams,fallback:L}),s.append(r),t.append(s),this.controlEl=r,s}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${_}-${this.control.id}`)}};var vt=()=>{let i=document.createElement("span");return i.style.display="inline-block",i.style.whiteSpace="pre",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.maxWidth="100%",i.style.maxHeight="100%",i};var bt=i=>{if(i.type.trim().toLowerCase()==="button")return new Ut(i)},Ut=class extends F{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:s}=super.createView(e),r=document.createElement("button");r.type="button",r.classList.add(`${_}-${this.control.id}`),r.setAttribute("data-testid",Q.BUTTON),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.style.fontFamily="inherit";let a=vt();return W({target:r,layoutParams:this.control.layoutParams,fallback:L}),mt({target:r,props:this.control.props,fallback:L}),yt({target:r,props:this.control.props,fallback:L,dependsOn:n}),ut({target:r,props:this.control.props}),ft({target:a,props:this.control.props,fallback:L,dependsOn:n}),r.append(a),s.append(r),t.append(s),this.controlEl=r,s}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${_}-${this.control.id}`)}};var ye=i=>{if(i.type.trim().toLowerCase()==="text")return new zt(i)},zt=class extends F{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:s}=super.createView(e),r=document.createElement("div");r.classList.add(`${_}-${this.control.id}`),r.setAttribute("data-testid",Q.TEXT),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.fontFamily="inherit";let a=vt();return W({target:r,layoutParams:this.control.layoutParams,fallback:L}),ut({target:r,props:this.control.props}),ft({target:a,props:this.control.props,fallback:L,dependsOn:n}),r.append(a),s.append(r),t.append(s),this.controlEl=r,s}disable(){}enable(){}getElement(){return document.querySelector(`.${_}-${this.control.id}`)}};var Wt=class{constructor(t){this.layout=t}},ge=i=>{if(i.type.trim().toLowerCase()==="relative")return new Z(i)},Z=class extends Wt{constructor(t){super(t)}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,e){t.style.position="absolute",t.style.width=`calc(var(--interactive-content-width) * ${e.width})`,t.style.height=`calc(var(--interactive-content-height) * ${e.height})`,t.style.left=`calc(var(--interactive-content-width) * ${e.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,t.style.top=`calc(var(--interactive-content-height) * ${e.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var K=class{constructor(t){this.container=t,this.factories=new Map,this.#o()}addControlFactory(t,e){this.factories.set(t.trim().toLowerCase(),e),this.#o()}removeControlFactory(t){this.factories.delete(t.trim().toLowerCase()),this.#o()}#o(){this.controls=this.#r()}#r(){return this.container.controls?.reduce((t,e)=>{let n=e.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...t,s(e)]:[...t]},[])}};var Ct=(i,t)=>{if(i.type.trim().toLowerCase()==="choice")return new Qt(i,t)},Qt=class extends K{constructor(t,e){super(t),this.rootElement=e??dt(),this.layout=new Z(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",bt),this.addControlFactory("text",ye),this.addControlFactory("area",gt)}createView(t){let e=document.createElement("div");return e.classList.add(`${_}-${this.container.id}`),this.layout.setContainerLayout(e),this.controls.forEach(n=>{let s=n.createView({parent:e,layoutFn:this.layout.setControlLayout});n.setEvents(s,t)}),this.rootElement.append(e),this.isRemoved=!1,e}hide(){let t=this.getElement();t&&(t.style.visibility="hidden")}show(){let t=this.getElement();t&&(t.style.visibility="visible")}enable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.enable()),t.style.opacity=1,this.isDisabled=!1)}disable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.disable()),t.style.opacity=me,this.isDisabled=!0)}removeView(){this.isRemoved||(this.getElement()?.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${_}-${this.container.id}`)}};import{Subject as Li,ValueSubject as N,Observable as Xe,once as ki,Subscription as Ni,clientChecker as ji,combine as Oi}from"@vkontakte/videoplayer-shared";import{loadVKLangPack as Je}from"@vkontakte/videoplayer-shared";function Et(i,t){let e;return(...n)=>{clearTimeout(e),e=setTimeout(()=>i(...n),t)}}var D=(i,t)=>Object.prototype.toString.call(i)===`[object ${t}]`,Y=i=>D(i,"Object"),xt=i=>D(i,"String"),It=i=>D(i,"Array"),Tt=i=>D(i,"Number"),ve=i=>D(i,"Function");var Kt=i=>Tt(i)&&!isNaN(i);var G=i=>Y(i)&&Object.keys(i).length===0,Xt=i=>It(i)&&!i.length;var J=(i,t)=>xt(i)&&(t?i.trim():i).length;var be="video_interactive",Ce="videoint";var ti=250,tt=class{constructor(t){this.init(t)}init({root:t,onOpenPreviewClick:e,onError:n,lang:s,visitedChapters:r=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(r),this.onOpenPreviewClick=e,this.onError=n,this.lang=s??"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=ei(t),this.resizeObserver=new ResizeObserver(Et(this.onResize,ti)),this.resizeObserver.observe(this.graphWrapperElement)}onResize=t=>{this.isReady&&(!t[0].contentRect.width||!t[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:t[0].contentRect.width,height:t[0].contentRect.height}))};getNextPoint(t=this.ngEditorSize){return[(this.lastZoomInfo.x-t.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-t.height/2)/this.lastZoomInfo.value*-1]}handleChapterChange=t=>{if(this.isReady){if(this.isHidden||this.hide(),!t?.id){this.onError?.("Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(t.id),this.ngEditor.selectChapter(t.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=t.id,this.lastZoomInfo=void 0}};handleManifestChange=async(t,e=[])=>{if(!Tt(t.graph.edit.chapters[0].x)){this.isReady=!1,this.onError?.("Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let n;try{n=await Je(this.lang,be,Ce)}catch{console.log("Unable to load graph language pack")}let{GraphEditor:s}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new s(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:n}),this.ngEditor.on("control",({name:r,chapterId:a})=>{r==="openPreview"&&this.onOpenPreviewClick(a)}),this.ngEditor.on("zoomEnd",r=>{this.lastZoomInfo={...r}})}this.visitedChapterIds=new Set(e),t.metadata.id!==this.currentManifestId?(this.ngEditor.update(t),this.currentManifestId=t.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0};setVisitedChapters(t){this.visitedChapterIds=new Set([...this.visitedChapterIds,...t]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(t){this.ngEditor.updateVideosInfo(t)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function ei(i){let t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.height="100%",t.style.width="100%",t.style.display="none",i.append(t),t}var et=class{constructor(){this._containers=[];this._player=null;this.setPlayer=t=>{this._player=t};this.setContainers=t=>{this._containers=t};this.deleteContainer=t=>{this._containers=this._containers.filter(e=>e.id!==t)};this.getNextInteractiveTime=(t=3e3)=>{if(!this._containers.length||this._player===null)return null;let e=-1,n=!1,s=Math.round(this._player.info.position$.getValue()*1e3);for(let r of this._containers){let a=r.startTime-t;if(a<=s&&(r.endTime&&s<=r.endTime||r.endTime===null)){n=!0;break}s<a&&(e=e===-1?a:Math.min(e,a))}return!n&&e!==-1?e:null}}};var B=(i="",t="")=>{let e=i.split("."),n=t.split("."),s=0;for(let r=0;r<Math.max(e.length,n.length)&&!s;r++)e[r]>n[r]?s=1:e[r]<n[r]?s=-1:s=0;return s};import{v4 as ii}from"uuid";var ni="3.1",Ee={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},ri={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},xe=i=>{let t=[];for(let e of i.chapters){let n,s=[];for(let{isDefault:o,...l}of e.branches)o&&(n=l.id),s.push(l);let r=[],a=[];for(let{fallbackStrategy:o,...l}of e.containers){let h=!!l.endTime,y=[ri];switch(o){case"await":h?y=[]:r=[];break;case"default":{let g={type:"onSuspense",action:{type:Ee.default,args:{branchId:n,shouldOpenNow:!h,isDetachContainer:!0}}};h?y=[g]:r=[g];break}case"random":case"weightlessRandom":case"max":case"min":{let g={type:"onSuspense",action:{type:Ee[o],args:{}}};h?y=[g]:r=[g];break}}for(let g of l.controls)a.push({...l,controls:[{...g}],id:ii(),events:y})}t.push({...e,containers:a,events:r,branches:s})}return i.metadata.version=ni,i.metadata.updated=new Date().toISOString(),{...i,chapters:t}};var si="3.2",Ie=i=>{if(!i.media){let{media:t,...e}=i.metadata;return{...i,metadata:{...e,version:si},media:t}}return i};var oi="3.3",ai=(i=[])=>({edit:{chapters:i},view:{}}),Te={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Se=i=>{let t=[],e=[];for(let n of i.chapters){let{id:s,x:r,y:a,...o}=n,l=o.containers.map(h=>({...h,controls:h.controls.map(({subtype:y,type:g,...C})=>({...C,type:y??g})),events:h.events?.length?h.events:[Te]}));t.push({id:s,...o,containers:l,events:o.events?.length?o.events:[Te]}),e.push({id:s,x:r,y:a})}return{...i,chapters:t,graph:ai(e),metadata:{...i.metadata,version:oi}}};var ci=[{version:"3.0",migrate:xe},{version:"3.1",migrate:Ie},{version:"3.2",migrate:Se}],qt=i=>ci.reduce((t,e)=>B(t.metadata.version,e.version)?t:e.migrate(t),i);var Xn=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),we=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),qn=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),E=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),Zt=(r=>(r.GO_NEXT_BUTTON="GO_NEXT_BUTTON",r.GO_NEXT_AREA="GO_NEXT_AREA",r.WATCH_AGAIN="WATCH_AGAIN",r.OPEN_GRAPH="OPEN_GRAPH",r.CLOSE_GRAPH="CLOSE_GRAPH",r))(Zt||{});var _e={metadata:"Object",chapters:"Array"},li="3.0.0",hi="3.3.0",St=i=>{let t=B(i,li);return t===-1?!1:t===0?!0:B(i,hi)!==1},Ve=i=>{if(!Y(i))return!1;for(let t in _e)if(!i[t]||!D(i[t],_e[t]))return!1;return St(i.metadata.version)},wt=i=>i.type===we.Text;var M=class{constructor(t,e,...n){this.severity=t;this.category=e;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var X=class{constructor(){this.listeners={}}addListener(t,e){return this.listeners[t]=this.listeners[t]||[],this.listeners[t].push(e),this}on(t,e){return this.addListener(t,e)}once(t,e){this.listeners[t]=this.listeners[t]||[];let n=()=>{e(),this.off(t,n)};return this.listeners[t].push(n),this}off(t,e){return this.removeListener(t,e)}reset(){this.listeners={}}removeListener(t,e){let n=this.listeners[t]||[];for(let s=n.length;s>0;s--)if(n[s]===e){n.splice(s,1);break}return this}emit(t,...e){let n=this.listeners[t];return n?(n.forEach(s=>{s(...e)}),!0):!1}listenerCount(t){return this.rawListeners(t).length}rawListeners(t){return this.listeners[t]||[]}};var _t=class{constructor(t){this.fns=[];this.addFn=(t,e=!1)=>{ve(t)&&(this.fns.push(t),e&&this.updateFn())};this.removeFn=(t,e=!1)=>{this.fns=this.fns.filter(n=>n!==t),e&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(t=>t()),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)};this.fn=t,this.addFn(t)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as gi}from"@vkontakte/videoplayer-shared";var Vt=class{constructor(t){this.loaders={chapterLoaders:t?.chapterLoaders??[],manifestLoaders:t?.manifestLoaders??[]}}async exec(t,e){return pi(...this.loaders[t])(e)}};function pi(...i){return async function(e){let n=[...i];for(;n.length>0;)e=await n.shift()(e);return e}}function it(i,t,e){return i?{...i,[t]:i[t]?[e,...i[t]]:[e]}:{[t]:[e]}}function Rt({actions:i,errors:t,chapterId:e,...n}){if(e){let s=i.getManifest(),r=i.getChapter(s.chapters,e);if(r){let a=i.getMedia(s.media,r.videoId),o=i.getGraph(s.graph,r.id);return a?{...n,actions:i,errors:t,result:{chapter:r,media:a,graph:o}}:{...n,errors:it(t,Rt.name,"Could not find media"),actions:i}}}return{...n,errors:it(t,Rt.name,"Could not find chapter"),actions:i}}var di=async i=>{try{let t,e;if(Y(i))t=i;else if(xt(i)){e=new URL(i).href;let s=await fetch(e);if(!s.ok)return{};t=await s.json()}else return{};if(!Ve(t))return{};let n=t.metadata.media;if(xt(n)&&!t.media)try{let s;e?s=new URL(n,e).href:(s=new URL(n).href,e=s);let r=await fetch(s);if(!r.ok)throw new Error;t.metadata.media=await r.json()}catch{return mi(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:e}}catch{return{}}};async function Re(i){let{manifest:t,manifestURL:e}=await di(i),n=qt(t);return n.media=ui(n.media,e),delete n.metadata.media,n}function At(i,t){return i.find(e=>e.id===t)}function Yt(i,t){return i.edit?.chapters?i.edit.chapters.find(e=>e.id===t):i.view?.chapters?i.view.chapters.find(e=>e.id===t):void 0}function Jt(i,t){return i.videos.find(e=>e.id===t)}function ui(i,t){return{...i,videos:i.videos.map(e=>({...e,variants:e.variants.map(n=>{let s=fi(n.url,t);return{...n,url:s||n.url}})}))}}function fi(i,t){try{return new URL(i,t).href}catch{return""}}function mi(i){return B(i,"3.2.0")>=0}var S=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Mt=i=>It(i)&&!Xt(i),P=i=>i.order==="end",Lt=i=>It(i.containers)&&!Xt(i.containers)&&P(i),Ae=(i,t)=>{let e=i*1e3;return Mt(t.controls)&&e<(t.startTime??0)},te=(i,t)=>{let e=i*1e3;return Mt(t.controls)&&e>=(t.startTime??0)&&e<=(t.endTime??1/0)};var U=i=>i.some(t=>t.action.type==="expect"),ee=i=>i.find(t=>t.action.type==="expect"),yi=i=>i?.length===1,kt=i=>yi(i)&&wt(i[0]);var Me=({fn:i,type:t=1},...e)=>(...n)=>t?i(...n,...e):i({...n[t],...e[t]}),Le=(i,t)=>U(i.events)?!1:t.some(({container:e})=>e.container.id!==i.id&&U(e.container.events)&&e.container.endTime===i.endTime&&!e.isRemoved);var q=class extends Vt{constructor(t,e){super(t),this.onError=e,this.prevChapter$=new gi(null),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 e=await this.exec("manifestLoaders",{actions:{addErrorMessage:it},result:null,errors:null,source:t});e.errors&&this.errorHandler(e.errors);let n=await Re(e.result??t);return this.manifest=n,this}async setInitial(){return this.setNext()}async setNext(t=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let e=await this.exec("chapterLoaders",Rt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Yt,getChapter:At,getMedia:Jt,getByBranches:this.getByBranches.bind(this),addErrorMessage:it},result:null,errors:null,chapterId:t}));return e.errors&&this.errorHandler(e.errors),this.chapter=e.result.chapter,this.media=e.result.media,this.graph=e.result.graph,this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(t=this.manifest.metadata.initChapterId){let e=At(this.manifest.chapters,t);if(e){let n=Jt(this.manifest.media,e.videoId),s=Yt(this.manifest.graph,e.id);if(n)return{chapter:e,media:n,graph:s}}return null}getBranches(t=this.chapter.id){if(t===this.chapter.id)return this.getByBranches(this.chapter.branches);{let e=At(this.manifest.chapters,t);return this.getByBranches(e?.branches)}}getByBranches(t=[]){return t.reduce((e,n)=>{let s=this.getByChapterId(n.chapterId);return s&&e.push(s),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return P(this.chapter)}};import{Player as vi}from"@vkontakte/videoplayer-core";import{Subscription as bi}from"@vkontakte/videoplayer-shared";var ke=i=>{let t=i.variants.find(e=>e.payload?.type==="vk");if(t&&"payload"in t){let[e,n]=t.payload.id.split("_");return[e,n]}return[]};var u={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},b={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function ie(){let i=new Map;function t({listId:s=Math.random().toString(),itemId:r=Math.random().toString(),...a}){let o=i.get(s),l={...a};return o?o[r]=l:i.set(s,{[r]:l}),{listId:s,itemId:r,...a}}function e(s,r){let a=i.get(s);if(a){if(r)return a[r]?.player.destroy(),a[r]?.container.remove(),a[r]?.subscription.unsubscribe(),delete a[r],Object.keys(a).length||i.delete(s),!0;for(let o of Object.values(a))o.player.destroy(),o.container.remove();return i.delete(s),!0}else throw Error("Can't remove. Not find.")}function n(){for(let s of i)e(s[0])}return{createPlayer:t,removePlayer:e,map:i,removeAll:n}}function ne(i,t=[]){let e={},n,s=!t.length;for(let r of i.variants)if(!n&&"cover"in r&&(n=r.cover),"url"in r)switch(r.type.toLowerCase()){case"mp4":(s||t.includes("mp4"))&&(e.MPEG={...e.MPEG,[r.standard??"Invariant quality"]:r.url});break;case"mpeg":(s||t.includes("mpeg"))&&(e.MPEG={...e.MPEG,[r.standard??"Invariant quality"]:r.url});break;case"hls":(s||t.includes("hls"))&&(e={...e,HLS:{type:"url",url:r.url}});break;case"dash":(s||t.includes("dash"))&&(e={...e,DASH_SEP:{compatibilityMode:!0,type:"url",url:r.url}});break;default:break}return{sources:e,thumbUrl:n,title:i.title??""}}var rt=(i,t)=>{let e=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();e!==t&&n.includes(t)&&(i.setQuality(t),i.setAutoQuality(!1))};var st={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},Ci=2;function re(i){let t=ie(),e,n,s=new X,r={},a=!1,o=null,l=!1,h;i&&y(i);function y(c){o=c}function g(c,p,m){if(!o)throw Error("need to set interactive controller");if(!o.options)return;let I=(t.map.get(c)??{})[p];if(I){r={chapterId:m,listId:c,itemId:p,...I};let T=r.player;n=T.info.currentQuality$.subscribe(w=>{if(!(!w||!T.info.position$.getValue())){e=w;for(let x of t.map)Object.values(x[1]).forEach(({player:R})=>{T.info.isAutoQualityEnabled$.getValue()||rt(R,w)})}}),I.container.remove(),a=!1,o.setPlayer(I.player),l||(o.init(),l=!0),s.emit(st.activePlayerChanged,{player:r.player,config:r.config});return}throw Error("Can't set. Not find.")}async function C(c,p,m){if(!o)throw Error("need to set interactive controller");if(G(r)||c!==r.itemId)return;if(m>=0&&!a){let I=o.getChapterBranches();a=!0;let T=new Set;for(let w of I)T.has(w.media.id)||(await V({media:w.media,chapterId:w.chapter.id,setAsActive:!1,title:w.chapter.label}),T.add(w.media.id))}}async function v({chapter:{id:c},media:p}){if(G(r))return;n?.unsubscribe();let m=r.player.info.muted$.getValue(),f=r.player.info.currentQuality$.getValue(),I=r.player.info.isAutoQualityEnabled$.getValue(),T=r.player.info.volume$.getValue(),w=r.player.info.currentPlaybackRate$.getValue(),x=!I,R=!1;for(let A of t.map)if(A[0]===p.id){let O=Object.keys(A[1]);for(let k of O)k===r.itemId?(O.length<Ci||(R=!0),t.removePlayer(A[0],k)):(R=!0,g(A[0],k,c),x?rt(r.player,f):r.player.setAutoQuality(!0),r.player.setVolume(T),r.player.setMuted(m),r.player.setPlaybackRate(w))}else t.removePlayer(A[0]);R||(await V({media:p,chapterId:c,setAsActive:!0,playbackRate:w}),x?rt(r.player,f):r.player.setAutoQuality(!0),r.player.setVolume(T),r.player.setMuted(m))}async function V({media:c,chapterId:p,prefetch:m=!0,setAsActive:f=!0,autoplay:I=!1,preferredExt:T,title:w,playbackRate:x}){let R=Math.random().toString(),A=document.createElement("div");h.append(A);let O=r?.player?.info.isAutoQualityEnabled$.getValue(),k;if(o?.options?.vkVideoLoader){let pt=ke(c);pt.length&&(k=await o.options.vkVideoLoader(...pt))}let ht=o?.options?.coreConfig||{},Ze={...ht,configName:[...ht.configName??[],"interactive"]},le={container:A,...k?.videos?.[0]||{sources:ne(c,T).sources},title:w,failoverHosts:k?.failoverHosts||[]},H=new vi(Ze);H.initVideo(le);let he=new bi;he.add(H.info.position$.subscribe(function(pt){C(R,H.info.duration$.getValue(),pt)})).add(H.events.canplay$.subscribe(function(){O||rt(H,e),x&&H.setPlaybackRate(x)}));let z=t.createPlayer({listId:c.id,itemId:R,player:H,container:A,sources:ne(c,T).sources,config:le,subscription:he});return f&&g(c.id,z.itemId,p),I&&z.player.play(),m&&!I&&z.player.prepare(),s.emit(st.playerCreated,z.player),{player:z.player,config:z.config}}function lt(){j(),o=null}function j(){o?.off(u.chapterChanged,v),t.removeAll(),r={},l=!1,a=!1}async function d({container:c}){if(!o)throw Error("need to set interactive controller");j(),h=c;let{media:p,chapter:m}=o.getCurrentChapter();if(p){o.on(u.chapterChanged,v);let{player:f,config:I}=await V({media:p,chapterId:m.id,title:m.label});return s.emit(st.initiated,{container:c,media:p,chapterId:m.id}),{player:f,config:I}}else console.error("not found")}return{...t,on:s.on.bind(s),off:s.off.bind(s),init:d,setInteractiveController:y,createPlayer:V,removeAll:lt,getActivePlayer:function(){return r}}}import{Subscription as Ei}from"@vkontakte/videoplayer-shared";var Nt=class{constructor({player:t,container:e,branches:n,selectBranches:s,interactiveEvents:r,globalEventEmitter:a,ignoreContainerEvent:o,permanentTextControls:l,disabledControls$:h,onRemove:y}){this.container=e,this.branches=n,this.selectBranches=s,this.subscription=new Ei,this.player=t,this.interactiveEvents=r,this.ignoreContainerEvent=o,this.isPermanentText=l&&kt(e.container.controls),this.disabledControls$=h,this.onRemove=y,this.globalEventEmitter=a,this.gameState=S.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(t=>{t?this.container.disable?.():this.container.enable?.()}))}hide=()=>{setTimeout(()=>{this.gameState!==S.end&&(U(this.container.container.events)&&this.gameState===S.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==S.interactive&&this.container.hide?.(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!1})))})};show=()=>{if(this.gameState===S.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())this.container.show?.(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!0,isFirst:!1});else{let e=Me({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!1})},onEvent:(n,s)=>{this.isSelectedControlEvent=!0,n!==!1&&(this.removeView(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!1})),(this.gameState===S.end||this.gameState===S.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),s(),this.removeView(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!1}))},isEOV:()=>this.gameState===S.end});this.container.createView(e),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&this.container.disable?.()}};selectContainerEvent(t=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:t?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:t}),!t&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let t=U(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!t)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.visibility,visibility:!1})}onEndOfVideo=()=>{this.gameState=S.end,this.selectContainerEvent(!0)};whilePlaying=()=>{if(this.player.experimental.element$.getValue()?.readyState<1||[S.destroyed,S.removed].includes(this.gameState)&&!this.isPermanentText)return;let e=this.player.getExactTime();if(Ae(e,this.container.container))this.gameState!==S.beforeInteractive&&(this.gameState=S.beforeInteractive,this.onBeforeStartTime());else if(te(e,this.container.container))this.gameState!==S.interactive&&(this.gameState=S.interactive,this.onStartTime());else if(this.gameState!==S.afterInteractive){let r=this.gameState;this.gameState=S.afterInteractive,r===S.interactive&&this.onEndTime()}else this.gameState!==S.destroyed&&!this.isPermanentText&&this.removeView();let n=te(e,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[];this.globalEventEmitter.emit(u.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:e,isInteractiveTime:n})};reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=S.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(u.interactives,{subjectId:this.container.container.id,subjectName:"container",type:b.containerRemoved,visibility:!1}),this.gameState=S.removed,this.onRemove?.()}destroy(){this.reset(),this.removeView(),this.gameState=S.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var Ne=(i=[])=>i.reduce((t,e,n)=>{let s=(e?.controls??[]).filter(r=>!wt(r));if(Mt(s)){let r=[e.startTime??0,e.endTime??1/0],a=e.id;if(!n)t.push({subjects:[a],range:r});else{let o=[],l=-1/0,h=1/0,y=[],g=[];for(let C=0;C<t.length;C++){let v=t[C];if(g.push(...v.subjects),v.range[0]<h&&(h=v.range[0]),v.range[1]>l&&(l=v.range[1]),r[0]>=v.range[0]&&r[1]<=v.range[1])return t[C].subjects.push(a),t;r[0]<v.range[0]&&r[1]>v.range[0]&&(o.push(C),y=y.concat(v.subjects)),r[0]>=v.range[0]&&r[0]<=v.range[1]&&(o.push(C),y=y.concat(v.subjects),r[0]=v.range[0]),r[1]>=v.range[0]&&r[1]<=v.range[1]&&(o.push(C),y=y.concat(v.subjects),r[1]=v.range[1])}if(g.push(a),r[0]<=h&&r[1]>=l)return[{subjects:g,range:r}];o.length&&o.reverse().forEach(C=>{t.splice(C,1)}),t.push({subjects:y.concat([a]),range:r})}}return t},[]).sort((t,e)=>t.range[0]-e.range[0]);function je(){let i={};function t(){for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&delete i[o];return!0}function e(o){let l={};for(let h in i)+h<=o&&(l[h]=i[h]);return l}function n(o){let l={};for(let h in i)+h>=o&&(l[h]=i[h]);return l}function s({timestamp:o,priority:l,initiator:h}){if(Kt(o)){let y=i[o]??null;if(y&&J(l,!0)){let g={},C=y[l];return C&&(g={...g,...C}),g=G(g)?null:g,g&&J(h,!0)?g[h]??null:g}return y}return null}function r({timestamp:o,priority:l,initiator:h}){if(Kt(o))if(i[o]){if(J(l,!0))if(i[o][l]){if(J(h,!0))if(i[o][l][h]){if(delete i[o][l][h],!G(i[o][l]))return!0}else return!1;if(delete i[o][l],!G(i[o]))return!0}else return!1;return delete i[o]}else return!1}function a({timestamp:o,priority:l,initiator:h,...y}){i[o]?.[l]?.[h]?i[o][l][h].push({...y}):i[o]?.[l]?i[o][l]={...i[o][l],[h]:[{...y}]}:i[o]?i[o]={...i[o],[l]:{[h]:[{...y}]}}:i[o]={[l]:{[h]:[{...y}]}}}return{map:i,remove:r,add:a,removeAll:t,get:s,getLte:e,getGte:n}}var xi=[E.expect,E.setNextBranch],Ii=1/0;function se(i){let t=i,e,n=Ti(),s=new je,r,a=()=>{C(),d()},o=c=>{s.add.call(void 0,c),V()},l=(c=[])=>{for(let p of c)if(p.action(),xi.includes(p.actionType))break},h=(c=1/0)=>{let p=jt(s.get({timestamp:c,priority:"control"})??{}),m=jt(s.get({timestamp:c,priority:"container"})??{}),f=jt(s.get({timestamp:c,priority:"chapter"})??{});return[...p,...m,...f]},y=c=>{n.isReady(c)&&l(h(c))},g=()=>{l([...jt(s.get({timestamp:1/0,priority:"chapter"})??{})])},C=()=>{e&&(r?.unsubscribe(),e=void 0)},v=c=>{},V=()=>{e||(e=()=>setTimeout(()=>{y(1/0)}),r=t.events.ended$.subscribe(e))},lt=c=>{C(),t=c},j=c=>{c.priority==="container"&&n.resetCalled(c.timestamp),s.remove(c)},d=()=>{n.release(),s.removeAll()};return{setPlayer:lt,add:o,remove:j,exec:y,execEndOfVideo:g,listen:V,unlisten:C,release:a,containersEventsCallState:n,getPreparedToExecActions:h}}function Ti(){let i=new Map;return{setCalled:({timestamp:a,id:o})=>{let l=i.get(a);l&&l[o]!==void 0&&(l[o]=!0)},setData:(a=[])=>{for(let o of a){let l=o.endTime??Ii,h=i.get(l)??{};i.set(l,{...h,[o.id]:!1})}},resetCalled:a=>{let o=i.get(a);if(o)for(let l in o)o[l]=!1},isReady:a=>{let o=i.get(a);return o?!Object.values(o).some(l=>!l):!0},release:()=>i.clear()}}function jt(i){return Object.values(i).flat().sort(t=>t.actionType===E.expect?-1:1)}var Oe={videoContentHeight:0,videoContentWidth:0},Pe=(i,t)=>{let{height:e,width:n}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&n))return Oe;let{clientHeight:s,clientWidth:r}=t.experimental.element$.getValue()||{};if(!(s&&r))return Oe;let a=e/n,o=s/r,l,h;return o>a?(h=r,l=r*a):o<a?(h=s/a,l=s):(h=r,l=s),{videoContentWidth:h,videoContentHeight:l}};var Si=250;function $e(i){let t=()=>{},e=new ResizeObserver(o=>{r(o),t=r.bind(null,o)});function n(o){let{parentElement:l,player:h}=i();if(l&&h){let{videoContentWidth:y,videoContentHeight:g}=Pe(l,h);l.style.setProperty("--interactive-content-width",`${y}px`),l.style.setProperty("--interactive-content-height",`${g}px`),l.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function s(){let{parentElement:o}=i();o.removeAttribute("style")}let r=Et(o=>{let{fns:l=[]}=i();n(o);for(let h of l)h()},Si);function a(){t=void 0,e.disconnect(),s()}return{resizeObserver:e,calc:()=>{t()},release:a}}var ot=class{constructor(){this.map={}}push(t,e){t in this.map?this.map[t].push(e):this.map[t]=[e]}get(t){let e=this.map[t];return e?e.slice():null}getAll(){let t=[];for(let e in this.map)t.concat(this.map[e]);return t}remove(t,e){t in this.map&&(this.map[t]=this.map[t].filter(n=>n!==e),this.map[t].length===0&&delete this.map[t])}clear(){this.map={}}keys(){return Object.keys(this.map)}size(){return this.keys().length}};var wi=i=>Math.floor(Math.random()*i),Fe=i=>{let t=i.length,e=1/0,n=null;for(;t--;)i[t].weight<e&&(e=i[t].weight,n=i[t]);return n},Be=i=>{let t=i.length,e=-1/0,n=null;for(;t--;)i[t].weight>e&&(e=i[t].weight,n=i[t]);return n};var He=i=>{let t=i.length,e=wi(t);return i[e]};var De=i=>{let t=0;for(let n=0;n<i.length;++n)t+=i[n].weight??1;let e=Math.random()*t;t=0;for(let n=0;n<i.length-1;++n)if(t+=i[n].weight??1,t>=e)return i[n];return i[i.length-1]};var Ge=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var oe=(i,t=!1)=>({...i,args:t?{...i.args,...Ge}:{...Ge,...i.args}}),ae=({globalEventEmitter:i,player:t,interactiveEvents:e,removeControllers:n})=>{let s={isExpect:!1},r=()=>{s.isExpect&&(s.isExpect=!1)},a=({action:d,controlType:c,controlId:p,containerId:m,branches:f=[],onEvent:I,isEOV:T=()=>!1,isDisabled:w=()=>!1})=>{let x=oe(d,T()),R={timestamp:1/0,priority:"control",initiator:p,actionType:x.type},A=w(),O=i.emit.bind(i,u.interactives,{subjectId:p,subjectType:c,subjectName:"control",type:A?b.actionChoiceCanceled:b.actionChoice,actionType:d.type,payload:{containerId:m,...x.args}});if(A){O();return}switch(x.type.trim().toLowerCase()){case E.setNextBranch.trim().toLowerCase():{let k=f.find(ht=>ht.id===x.args.branchId);if(!k)return;I(x.args.isDetachContainer,C.bind(null,{subjectId:p,subjectName:"control"})),O(),x.args.shouldOpenNow?V({subjectId:p,subjectName:"control",subjectType:c,action:x,payload:{chapterId:k.chapterId,autoSelect:!1}}):(e.add({...R,action:V.bind(null,{subjectId:p,subjectName:"control",subjectType:c,action:x,payload:{chapterId:k.chapterId,autoSelect:!1}})}),n?.());return}case E.continuePlayback.trim().toLowerCase():{I(x.args.isDetachContainer,C.bind(null,{subjectId:p,subjectName:"control"})),O(),x.args.shouldOpenNow?v({subjectId:p,subjectName:"control",subjectType:c,action:d}):e.add({...R,action:v.bind(null,{subjectId:p,subjectName:"control",subjectType:c,action:d})});return}case E.openURI.trim().toLowerCase():{I(x.args.isDetachContainer,C.bind(null,{subjectId:p,subjectName:"control"})),O(),x.args.shouldOpenNow?j({subjectId:p,subjectName:"control",subjectType:c,action:x,payload:{URI:d.args.uri}}):(e.add({...R,action:j.bind(null,{subjectId:p,subjectName:"control",subjectType:c,action:x,payload:{URI:d.args.uri}})}),n?.());return}default:console.error("Unexpected control event"),i.emit(u.errors,new M(1,1,{message:"Unexpected control event"}));return}},o=({action:d,container:{id:c,endTime:p},branches:m=[],isEOV:f=!1,autoSelected:I=!1})=>{let T=oe(d,f),w={timestamp:!T.args.shouldOpenNow||f?1/0:p,priority:"container",initiator:c,actionType:T.type},x=i.emit.bind(i,u.interactives,{subjectId:c,subjectName:"container",type:b.actionChoice,actionType:T.type,payload:T.args});switch(T.type.trim().toLowerCase()){case E.setNextBranch.trim().toLowerCase():{let R=m.find(A=>A.id===T.args.branchId);if(!R)return;x(),e.add({...w,action:V.bind(null,{subjectId:c,subjectName:"container",action:T,payload:{chapterId:R.chapterId,autoSelect:I}})}),n?.();return}case E.setMaxWeightBranch.trim().toLowerCase():return;case E.setMinWeightBranch.trim().toLowerCase():return;case E.setRandomBranch.trim().toLowerCase():return;case E.setWeightlessRandomBranch.trim().toLowerCase():return;case E.continuePlayback.trim().toLowerCase():{x(),e.add({...w,action:v.bind(null,{subjectId:c,subjectName:"container",action:T})});return}case E.openURI.trim().toLowerCase():{x(),e.add({...w,action:j.bind(null,{subjectId:c,subjectName:"container",action:T,payload:{URI:d.args.uri}})}),n?.();return}default:console.error("Unexpected container event"),i.emit(u.errors,new M(1,1,{message:"Unexpected container event"}));return}};function l({container:d,branches:c,isEOV:p=!1}){let m=ee(d.events);if(m){let f=oe(m.action,p);i.emit(u.interactives,{subjectId:d.id,subjectName:"container",type:b.actionChoice,actionType:f.type,payload:f.args}),e.add({timestamp:p?1/0:d.endTime,priority:"container",initiator:d.id,actionType:E.expect,action:g.bind(null,{subjectId:d.id,subjectName:"container"})}),s.isExpect=!0}else for(let f of d.events)o({action:f.action,container:d,branches:c,isEOV:p})}let h=({chapterId:d,action:c,branches:p=[]})=>{let m=i.emit.bind(i,u.interactives,{subjectId:d,subjectName:"chapter",type:b.actionChoice,actionType:c.type,payload:c.args});switch(c.type.trim().toLowerCase()){case E.setNextBranch.trim().toLowerCase():{let f=p.find(I=>I.id===c.args.branchId);return f?.chapterId?(m(),V.bind(null,{subjectId:d,subjectName:"chapter",action:c,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case E.setWeightlessRandomBranch.trim().toLowerCase():{let f=He(p);return f?.chapterId?(m(),V.bind(null,{subjectId:d,subjectName:"chapter",action:c,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case E.setRandomBranch.trim().toLowerCase():{let f=De(p);return f?.chapterId?(m(),V.bind(null,{subjectId:d,subjectName:"chapter",action:c,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case E.setMaxWeightBranch.trim().toLowerCase():{let f=Be(p);return f?.chapterId?(m(),V.bind(null,{subjectId:d,subjectName:"chapter",action:c,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case E.setMinWeightBranch.trim().toLowerCase():{let f=Fe(p);return f?.chapterId?(m(),V.bind(null,{subjectId:d,subjectName:"chapter",action:c,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case E.continuePlayback.trim().toLowerCase():return m(),v.bind(null,{subjectId:d,subjectName:"chapter",action:c});case E.openURI.trim().toLowerCase():return m(),j.bind(null,{subjectId:d,subjectName:"chapter",action:c,payload:{URI:c.args.uri}});default:console.error("Unexpected chapter event"),i.emit(u.errors,new M(1,1,{message:"Unexpected chapter event"}));return}};function y(d){let c=ee(d.events);if(c){if(P(d))return;i.emit(u.interactives,{subjectId:d.id,subjectName:"chapter",type:b.actionChoice,actionType:c.action.type,payload:c.action.args}),e.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:E.expect,action:g.bind(null,{subjectId:d.id,subjectName:"chapter"})})}else d.events.forEach(p=>{let m=h({chapterId:d.id,action:p.action,branches:d.branches});m&&e.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:p.action.type,action:m})})}let g=({subjectId:d,subjectName:c,action:p})=>{t.pause(),i.emit(u.interactives,{subjectId:d,subjectName:c,type:b.actionExecution,actionType:p?.type??E.expect})},C=({subjectId:d,subjectName:c})=>{t.info.isEnded$.getValue()?e.execEndOfVideo():t.play(),i.emit(u.interactives,{subjectId:d,subjectName:c,type:b.actionExecution,actionType:"after-expect"})},v=({subjectId:d,subjectName:c,subjectType:p,action:m})=>{i.emit(u.interactives,{subjectId:d,subjectName:c,subjectType:p,type:b.actionExecution,actionType:m.type})},V=({subjectId:d,subjectName:c,subjectType:p,action:m,payload:f})=>{f.behaviour="change-chapter",i.emit(u.interactives,{subjectId:d,subjectName:c,subjectType:p,type:b.actionExecution,actionType:m.type,payload:f})},lt=({subjectId:d,subjectName:c,subjectType:p,action:m,payload:f})=>{f.behaviour="change-manifest",i.emit(u.interactives,{subjectId:d,subjectName:c,subjectType:p,type:b.actionExecution,actionType:m.type,payload:f})},j=({subjectId:d,subjectName:c,subjectType:p,action:m,payload:f})=>{if(!f.URI)return;let I=window.open(f.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),i.emit(u.interactives,{subjectId:d,subjectName:c,subjectType:p,type:b.actionExecution,actionType:m.type})};return{onControlEvent:a,onContainerEvent:o,onChapterEvent:h,onExpectEvent:g,expectEventHandler:C,setManifestChapterEvents:y,setManifestContainerEvents:l,stopExpect:r,state:s}};import{Subscription as Mi,ValueSubject as at}from"@vkontakte/videoplayer-shared";var ce=(i,t)=>{let e={};return i.map(n=>{if(!e[n]){let s=t.chapters.find(a=>a.id===n);if(!s)return null;let r=t.media.videos.find(a=>s.videoId===a.id);if(!r)return null;e[n]=We(r)}return e[n]}).filter(Boolean)},Vi=i=>{for(let t of i.variants)if(Ri(t)&&"payload"in t)return t.payload.id},Ri=i=>i.type==="custom"&&"payload"in i&&i.payload.type==="vk",We=i=>{let t=Vi(i);if(!t)return null;let e=t.split("_").pop();return e?parseInt(e,10):null},Ai=(i,t)=>{for(let e of i.media.videos)if(t===We(e)){for(let n of i.chapters)if(n.videoId===e.id)return n.id;return}},Qe=(i,t)=>i.reduce((e,n)=>{let s=Ai(t,n);return s?[...e,s]:e},[]);var ct=class{constructor({globalEventEmitter:t,videoId:e,interactiveController:n,historyApi:s,settings:r}){this.state={history$:new at([]),hasPrevChapter$:new at(!1),prevChapter$:new at(null),isInitialChapter$:new at(!1),isGoBackLimited$:new at(!1)};this.#o=null;this.#h=!1;this.#i=null;this.#d=null;this.#n=null;this.#s=null;this.#a=null;this.#t=new Mi;this.#p=!1;this.#u=0;this.#n=e,this.#a=t,this.#s=n,this.#o=s,this.#r=r,this.state?.history$&&this.#t&&this.#t?.add(this.state?.history$.subscribe(a=>{this.state?.prevChapter$.next(a.at(-2)||null),this.state?.hasPrevChapter$.next(a.length>1),this.state?.isInitialChapter$.next(this.getInitialChapterId()===this.#i?.metadata?.initChapterId),this.state?.isGoBackLimited$.next(this.#u===this.#r.maxLength-1)}))}#o;#r;#h;#i;#d;#n;#s;#a;#t;#p;#u;async setManifest(t){!this.#s||!this.#a||(this.#i=t,await this.getProjectHistory(),await this.#s.setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),this.#h||(this.#h=!0,this.#a.emit(u.historyInited,{initChapterId:this.getInitialChapterId()})))}get inited(){return this.#h}async updateHistory(t,e=!0){if(!this.#i)return;this.#p?(this.#p=!1,this.#u++):this.#u=0;let n=this.#i,s=t.length-this.#r.maxLength,r=s>0?t.slice(s):t,a=ce(r,n);if(this.#d=a,this?.state?.history$.next(r),!(!e||!this.#o||!this.#n))try{await this.#o.save(this.#n,a)}catch{this.#a?.emit(u.errors,new M(1,5,"Unable to save interactive history"))}}async goBack(){if(!this.state||!this.#s)return this.#a?.emit(u.errors,new M(1,5,"Cannot go back because HistoryController has not been initialized"));this.#p=!0;let t=this.state.history$.getValue().slice(0,-1),e=t.pop();this.state.history$.next(t),await this.#s.setChapter({chapterId:e})}async getProjectHistory(){if(!this.#i||!this.#n)return;let t=this.#i,e=[this.getInitialVideoId()];if(this.#o)try{let s=await this.#o.get(this.#n);s.length&&(e=s)}catch{this.#a?.emit(u.errors,new M(1,5,"Error while trying to fetch data"))}let n=Qe(e,t);this?.state?.history$.next(n)}getInitialChapterId(){return this.state?.history$.getValue()?.at(-1)||this.#r.initChapterId||this.#i?.metadata.initChapterId}getInitialVideoId(){if(this.#i){let t=this.getInitialChapterId();return ce([t],this.#i).pop()}return null}destroy(){this.state=null,this.#n=null,this.#o=null,this.#s=null,this.#t?.unsubscribe(),this.#t=null,this.#h=!1,this.#a?.emit(u.historyDestroyed),this.#a=null}};var Ot=class i{constructor(t,e,n,s){this.target=t,this.type=e,this.listener=n,this.options=i._convertOptions(t,s),this.target.addEventListener(e,n,this.options)}unlisten(){this.type&&this.listener&&this.options&&this.target?.removeEventListener(this.type,this.listener,this.options),this.target=null,this.type=null,this.listener=null,this.options=!1}static _convertOptions(t,e){if(e===void 0)return!1;if(typeof e=="boolean")return e;{let n=new Set(["passive","capture"]),s=Object.keys(e).filter(a=>!n.has(a));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),i._doesSupportObject(t)?e:e.capture||!1}}static{this._supportsObject=void 0}static _doesSupportObject(t){let e=i._supportsObject;if(e===void 0){e=!1;try{let n={},s={get:()=>(e=!0,!1)};Object.defineProperty(n,"passive",s),Object.defineProperty(n,"capture",s);let r=()=>{};t.addEventListener("test",r,n),t.removeEventListener("test",r,n)}catch{e=!1}i._supportsObject=e}return e||!1}};var Pt=class{constructor(){this.bindingMap=new ot}release(){this.removeAll(),this.bindingMap=null}listen(t,e,n,s){if(!this.bindingMap)return;let r=new Ot(t,e,n,s);this.bindingMap.push(e,r)}listenOnce(t,e,n,s){let r=a=>{this.unlisten(t,e,r),n(a)};this.listen(t,e,r,s)}unlisten(t,e,n){if(!this.bindingMap)return;let s=this.bindingMap.get(e)||[];for(let r of s)r.target===t&&(n===r.listener||!n)&&(r.unlisten(),this.bindingMap.remove(e,r))}removeAll(){if(!this.bindingMap)return;let t=this.bindingMap.getAll();for(let e of t)e.unlisten();this.bindingMap.clear()}};var $t=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 t=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!t)return!1;let e=t.data,n=e.length;for(let s=3;s<n;s+=40)if(e[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(t){this.canvasImgSrc=t}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(t,e=!1){let n=t.width+t.height;if(this._prevSizeId===n)return;let s;e&&(s=await this.save()),this.rootElement.width=t.width,this.rootElement.height=t.height,e&&s&&this.restore(s),this._prevSizeId=n}async save(){let t=this.rootElement.toDataURL("image/jpeg",1),e=new Image;return e.crossOrigin="anonymous",e.src=t,await e.decode(),e}restore(t){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(t,0,0,this.rootElement.width,this.rootElement.height)}};var Ft=class{constructor({parentElement:t,endOffsetMs:e=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=t=>{let e=t??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(e);if(this.isContainerTime(e))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 pe="1.0.16-dev.4f41c335.0";function Dt(i,t=1){let e="0",n="0",s="0";return i.length===4?(e="0x"+i[1]+i[1],n="0x"+i[2]+i[2],s="0x"+i[3]+i[3]):i.length===7&&(e="0x"+i[1]+i[2],n="0x"+i[3]+i[4],s="0x"+i[5]+i[6]),`rgba(${+e},${+n},${+s},${t})`}var M="SDK_NAME",Je="SDK_NAME-controls-container",pt=()=>document.querySelector(`.${Je}`),me=.4,L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},de={top:"flex-start",bottom:"flex-end",center:"center"},ue={start:"flex-start",end:"flex-end",center:"center"},fe={start:"left",end:"right",center:"center"},dt=({target:i,props:t})=>{i.style.alignItems=de[t?.text?.gravityVertical]??de.center,i.style.justifyContent=ue[t?.text?.gravityHorizontal]??ue.center,i.style.textAlign=fe[t?.text?.alignment]??fe.start},ut=({target:i,props:t,fallback:e,dependsOn:n})=>{i.style.color=t?.text?.color??e.textColor,i.style.fontSize=`calc(${n.height} * ${t?.text?.size??e.textSize})`,i.textContent=t?.text?.value??e.textContent},ft=({target:i,props:t,fallback:e})=>{i.style.backgroundColor=Dt(t?.background?.color??e.backgroundColor,t?.background?.alpha??e.backgroundAlpha)},mt=({target:i,props:t,fallback:e,dependsOn:n})=>{i.style.border=`calc(${n.height} * ${t?.shape?.border?.width??e.borderWidth}) solid ${Dt(t?.shape?.border?.color??e.borderColor,t?.shape?.border?.alpha??e.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${t?.shape?.roundCorners??e.roundCorners})`},W=({target:i,layoutParams:t,fallback:e})=>{i.style.transform=`rotate(${-t.angle}rad)`};var Ht="int",Q={AREA:`${Ht}_area`,TEXT:`${Ht}_text`,BUTTON:`${Ht}_bttn`};var $=class{constructor(t){this.control=t}createView(t){let e=document.createElement("div");e.classList.add(`${M}-control-container-${this.control.id}`),t(e,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??L.innerSizesDependOn)==="self"?{height:e.style.height,width:e.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:e,dependsOn:n}}setEvents(t,e){t&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":t.addEventListener("click",r=>{r.stopPropagation(),e&&e({action:n.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${M}-control-container-${this.control.id}`)}};var yt=i=>{if(i.type.trim().toLowerCase()==="area")return new Gt(i)},Gt=class extends ${constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:s}=super.createView(e),r=document.createElement("button");return r.classList.add(`${M}-${this.control.id}`),r.setAttribute("data-testid",Q.AREA),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.type="button",ft({target:r,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),mt({target:r,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:n}),W({target:r,layoutParams:this.control.layoutParams,fallback:L}),s.append(r),t.append(s),this.controlEl=r,s}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${M}-${this.control.id}`)}};var gt=()=>{let i=document.createElement("span");return i.style.display="inline-block",i.style.whiteSpace="pre",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.maxWidth="100%",i.style.maxHeight="100%",i};var vt=i=>{if(i.type.trim().toLowerCase()==="button")return new Ut(i)},Ut=class extends ${constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:s}=super.createView(e),r=document.createElement("button");r.type="button",r.classList.add(`${M}-${this.control.id}`),r.setAttribute("data-testid",Q.BUTTON),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.style.fontFamily="inherit";let o=gt();return W({target:r,layoutParams:this.control.layoutParams,fallback:L}),ft({target:r,props:this.control.props,fallback:L}),mt({target:r,props:this.control.props,fallback:L,dependsOn:n}),dt({target:r,props:this.control.props}),ut({target:o,props:this.control.props,fallback:L,dependsOn:n}),r.append(o),s.append(r),t.append(s),this.controlEl=r,s}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${M}-${this.control.id}`)}};var ye=i=>{if(i.type.trim().toLowerCase()==="text")return new zt(i)},zt=class extends ${constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:s}=super.createView(e),r=document.createElement("div");r.classList.add(`${M}-${this.control.id}`),r.setAttribute("data-testid",Q.TEXT),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.fontFamily="inherit";let o=gt();return W({target:r,layoutParams:this.control.layoutParams,fallback:L}),dt({target:r,props:this.control.props}),ut({target:o,props:this.control.props,fallback:L,dependsOn:n}),r.append(o),s.append(r),t.append(s),this.controlEl=r,s}disable(){}enable(){}getElement(){return document.querySelector(`.${M}-${this.control.id}`)}};var Wt=class{constructor(t){this.layout=t}},ge=i=>{if(i.type.trim().toLowerCase()==="relative")return new X(i)},X=class extends Wt{constructor(t){super(t)}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,e){t.style.position="absolute",t.style.width=`calc(var(--interactive-content-width) * ${e.width})`,t.style.height=`calc(var(--interactive-content-height) * ${e.height})`,t.style.left=`calc(var(--interactive-content-width) * ${e.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,t.style.top=`calc(var(--interactive-content-height) * ${e.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var K=class{constructor(t){this.container=t,this.factories=new Map,this.#a()}addControlFactory(t,e){this.factories.set(t.trim().toLowerCase(),e),this.#a()}removeControlFactory(t){this.factories.delete(t.trim().toLowerCase()),this.#a()}#a(){this.controls=this.#s()}#s(){return this.container.controls?.reduce((t,e)=>{let n=e.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...t,s(e)]:[...t]},[])}};var bt=(i,t)=>{if(i.type.trim().toLowerCase()==="choice")return new Qt(i,t)},Qt=class extends K{constructor(t,e){super(t),this.rootElement=e??pt(),this.layout=new X(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",vt),this.addControlFactory("text",ye),this.addControlFactory("area",yt)}createView(t){let e=document.createElement("div");return e.classList.add(`${M}-${this.container.id}`),this.layout.setContainerLayout(e),this.controls.forEach(n=>{let s=n.createView({parent:e,layoutFn:this.layout.setControlLayout});n.setEvents(s,t)}),this.rootElement.append(e),this.isRemoved=!1,e}hide(){let t=this.getElement();t&&(t.style.visibility="hidden")}show(){let t=this.getElement();t&&(t.style.visibility="visible")}enable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.enable()),t.style.opacity=1,this.isDisabled=!1)}disable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.disable()),t.style.opacity=me,this.isDisabled=!0)}removeView(){this.isRemoved||(this.getElement()?.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${M}-${this.container.id}`)}};import{Subject as Li,ValueSubject as N,Observable as Ze,once as ki,Subscription as Ni,clientChecker as ji,combine as Oi}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as ct}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as ti}from"@vkontakte/videoplayer-shared";function Ct(i,t){let e;return(...n)=>{clearTimeout(e),e=setTimeout(()=>i(...n),t)}}var H=(i,t)=>Object.prototype.toString.call(i)===`[object ${t}]`,Y=i=>H(i,"Object"),Et=i=>H(i,"String"),It=i=>H(i,"Array"),xt=i=>H(i,"Number"),ve=i=>H(i,"Function");var Kt=i=>xt(i)&&!isNaN(i);var G=i=>Y(i)&&Object.keys(i).length===0,qt=i=>It(i)&&!i.length;var J=(i,t)=>Et(i)&&(t?i.trim():i).length;var be="video_interactive",Ce="videoint";var ei=250,tt=class{constructor(t){this.init(t)}init({root:t,onOpenPreviewClick:e,onError:n,lang:s,visitedChapters:r=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(r),this.onOpenPreviewClick=e,this.onError=n,this.lang=s??"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=ii(t),this.resizeObserver=new ResizeObserver(Ct(this.onResize,ei)),this.resizeObserver.observe(this.graphWrapperElement)}onResize=t=>{this.isReady&&(!t[0].contentRect.width||!t[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:t[0].contentRect.width,height:t[0].contentRect.height}))};getNextPoint(t=this.ngEditorSize){return[(this.lastZoomInfo.x-t.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-t.height/2)/this.lastZoomInfo.value*-1]}handleChapterChange=t=>{if(this.isReady){if(this.isHidden||this.hide(),!t?.id){this.onError?.("Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(t.id),this.ngEditor.selectChapter(t.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=t.id,this.lastZoomInfo=void 0}};handleManifestChange=async(t,e=[])=>{if(!xt(t.graph.edit.chapters[0].x)){this.isReady=!1,this.onError?.("Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let n;try{n=await ti(this.lang,be,Ce)}catch{console.log("Unable to load graph language pack")}let{GraphEditor:s}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new s(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:n}),this.ngEditor.on("control",({name:r,chapterId:o})=>{r==="openPreview"&&this.onOpenPreviewClick(o)}),this.ngEditor.on("zoomEnd",r=>{this.lastZoomInfo={...r}})}this.visitedChapterIds=new Set(e),t.metadata.id!==this.currentManifestId?(this.ngEditor.update(t),this.currentManifestId=t.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0};setVisitedChapters(t){this.visitedChapterIds=new Set([...this.visitedChapterIds,...t]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(t){this.ngEditor.updateVideosInfo(t)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function ii(i){let t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.height="100%",t.style.width="100%",t.style.display="none",i.append(t),t}var et=class{constructor(){this._containers=[];this._player=null;this.setPlayer=t=>{this._player=t};this.setContainers=t=>{this._containers=t};this.deleteContainer=t=>{this._containers=this._containers.filter(e=>e.id!==t)};this.getNextInteractiveTime=(t=3e3)=>{if(!this._containers.length||this._player===null)return null;let e=-1,n=!1,s=Math.round(this._player.info.position$.getValue()*1e3);for(let r of this._containers){let o=r.startTime-t;if(o<=s&&(r.endTime&&s<=r.endTime||r.endTime===null)){n=!0;break}s<o&&(e=e===-1?o:Math.min(e,o))}return!n&&e!==-1?e:null}}};var B=(i="",t="")=>{let e=i.split("."),n=t.split("."),s=0;for(let r=0;r<Math.max(e.length,n.length)&&!s;r++)e[r]>n[r]?s=1:e[r]<n[r]?s=-1:s=0;return s};import{v4 as ni}from"uuid";var si="3.1",Ee={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},ri={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ie=i=>{let t=[];for(let e of i.chapters){let n,s=[];for(let{isDefault:a,...c}of e.branches)a&&(n=c.id),s.push(c);let r=[],o=[];for(let{fallbackStrategy:a,...c}of e.containers){let h=!!c.endTime,y=[ri];switch(a){case"await":h?y=[]:r=[];break;case"default":{let g={type:"onSuspense",action:{type:Ee.default,args:{branchId:n,shouldOpenNow:!h,isDetachContainer:!0}}};h?y=[g]:r=[g];break}case"random":case"weightlessRandom":case"max":case"min":{let g={type:"onSuspense",action:{type:Ee[a],args:{}}};h?y=[g]:r=[g];break}}for(let g of c.controls)o.push({...c,controls:[{...g}],id:ni(),events:y})}t.push({...e,containers:o,events:r,branches:s})}return i.metadata.version=si,i.metadata.updated=new Date().toISOString(),{...i,chapters:t}};var ai="3.2",xe=i=>{if(!i.media){let{media:t,...e}=i.metadata;return{...i,metadata:{...e,version:ai},media:t}}return i};var oi="3.3",ci=(i=[])=>({edit:{chapters:i},view:{}}),Te={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Se=i=>{let t=[],e=[];for(let n of i.chapters){let{id:s,x:r,y:o,...a}=n,c=a.containers.map(h=>({...h,controls:h.controls.map(({subtype:y,type:g,...E})=>({...E,type:y??g})),events:h.events?.length?h.events:[Te]}));t.push({id:s,...a,containers:c,events:a.events?.length?a.events:[Te]}),e.push({id:s,x:r,y:o})}return{...i,chapters:t,graph:ci(e),metadata:{...i.metadata,version:oi}}};var li=[{version:"3.0",migrate:Ie},{version:"3.1",migrate:xe},{version:"3.2",migrate:Se}],Zt=i=>li.reduce((t,e)=>B(t.metadata.version,e.version)?t:e.migrate(t),i);var qn=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),we=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Zn=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),I=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});var _e={metadata:"Object",chapters:"Array"},hi="3.0.0",pi="3.3.0",Tt=i=>{let t=B(i,hi);return t===-1?!1:t===0?!0:B(i,pi)!==1},Ve=i=>{if(!Y(i))return!1;for(let t in _e)if(!i[t]||!H(i[t],_e[t]))return!1;return Tt(i.metadata.version)},St=i=>i.type===we.Text;var R=class{constructor(t,e,...n){this.severity=t;this.category=e;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var q=class{constructor(){this.listeners={}}addListener(t,e){return this.listeners[t]=this.listeners[t]||[],this.listeners[t].push(e),this}on(t,e){return this.addListener(t,e)}once(t,e){this.listeners[t]=this.listeners[t]||[];let n=()=>{e(),this.off(t,n)};return this.listeners[t].push(n),this}off(t,e){return this.removeListener(t,e)}reset(){this.listeners={}}removeListener(t,e){let n=this.listeners[t]||[];for(let s=n.length;s>0;s--)if(n[s]===e){n.splice(s,1);break}return this}emit(t,...e){let n=this.listeners[t];return n?(n.forEach(s=>{s(...e)}),!0):!1}listenerCount(t){return this.rawListeners(t).length}rawListeners(t){return this.listeners[t]||[]}};var wt=class{constructor(t){this.fns=[];this.addFn=(t,e=!1)=>{ve(t)&&(this.fns.push(t),e&&this.updateFn())};this.removeFn=(t,e=!1)=>{this.fns=this.fns.filter(n=>n!==t),e&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(t=>t()),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)};this.fn=t,this.addFn(t)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as vi}from"@vkontakte/videoplayer-shared";var _t=class{constructor(t){this.loaders={chapterLoaders:t?.chapterLoaders??[],manifestLoaders:t?.manifestLoaders??[]}}async exec(t,e){return di(...this.loaders[t])(e)}};function di(...i){return async function(e){let n=[...i];for(;n.length>0;)e=await n.shift()(e);return e}}function it(i,t,e){return i?{...i,[t]:i[t]?[e,...i[t]]:[e]}:{[t]:[e]}}function Vt({actions:i,errors:t,chapterId:e,...n}){if(e){let s=i.getManifest(),r=i.getChapter(s.chapters,e);if(r){let o=i.getMedia(s.media,r.videoId),a=i.getGraph(s.graph,r.id);return o?{...n,actions:i,errors:t,result:{chapter:r,media:o,graph:a}}:{...n,errors:it(t,Vt.name,"Could not find media"),actions:i}}}return{...n,errors:it(t,Vt.name,"Could not find chapter"),actions:i}}var ui=async i=>{try{let t={},e;if(Et(i)){e=new URL(i).href;let s=await fetch(e);if(!s.ok)return{};t=await s.json()}else if(Y(i))t=i;else return{};if(!Ve(t))return{};let n=t.metadata.media;if(Et(n)&&!t.media)try{let s;e?s=new URL(n,e).href:(s=new URL(n).href,e=s);let r=await fetch(s);if(!r.ok)throw new Error;t.metadata.media=await r.json()}catch{return yi(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:e}}catch{return{}}};async function Me(i){let{manifest:t,manifestURL:e}=await ui(i),n=Zt(t);return n.media=fi(n.media,e),delete n.metadata.media,n}function Mt(i,t){if(t)return i.find(e=>e.id===t)}function Xt(i,t){return i.edit?.chapters?i.edit.chapters.find(e=>e.id===t):i.view?.chapters?i.view.chapters.find(e=>e.id===t):void 0}function Yt(i,t){return i.videos.find(e=>e.id===t)}function fi(i,t){return{...i,videos:i.videos.map(e=>({...e,variants:e.variants.map(n=>{let s="url"in n?n.url:"",r=mi(s,t);return{...n,url:r||s}})}))}}function mi(i="",t){try{return new URL(i,t).href}catch{return""}}function yi(i){return B(i,"3.2.0")>=0}var x=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Rt=i=>It(i)&&!qt(i),O=i=>i.order==="end",At=i=>It(i.containers)&&!qt(i.containers)&&O(i),Re=(i,t)=>{let e=i*1e3;return Rt(t.controls)&&e<(t.startTime??0)},Jt=(i,t)=>{let e=i*1e3;return Rt(t.controls)&&e>=(t.startTime??0)&&e<=(t.endTime??1/0)};var U=i=>i.some(t=>t.action.type==="expect"),te=i=>i.find(t=>t.action.type==="expect"),gi=i=>i?.length===1,Lt=i=>gi(i)&&St(i[0]);var Ae=({fn:i,type:t=1},...e)=>(...n)=>t?i(...n,...e):i({...n[t],...e[t]}),Le=(i,t)=>U(i.events)?!1:t.some(({container:e})=>e.container.id!==i.id&&U(e.container.events)&&e.container.endTime===i.endTime&&!e.isRemoved);var Z=class extends _t{constructor(e,n){super(e);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new vi(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(e){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:it},result:null,errors:null,source:e});return n.errors&&this.errorHandler(n.errors),this.manifest=await Me(n.result??e),this}async setInitial(){return this.setNext()}async setNext(e=this.manifest?.metadata.initChapterId){if(!e)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",Vt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Xt,getChapter:Mt,getMedia:Yt,getByBranches:this.getByBranches.bind(this),addErrorMessage:it},result:null,errors:null,chapterId:e}));return n.errors&&this.errorHandler(n.errors),this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(e=this.manifest?.metadata.initChapterId){if(!e||!this.manifest)return null;let n=Mt(this.manifest.chapters,e);if(n){let s=Yt(this.manifest.media,n.videoId),r=Xt(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:r}}return null}getBranches(e=this.chapter?.id){if(e===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Mt(this.manifest?.chapters||[],e);return this.getByBranches(n?.branches)}}getByBranches(e=[]){return e.reduce((n,s)=>{let r=this.getByChapterId(s.chapterId);return r&&n.push(r),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return O(this.chapter)}};import{Player as bi}from"@vkontakte/videoplayer-core";import{Subscription as Ne}from"@vkontakte/videoplayer-shared";var ke=i=>{let t=i.variants.find(e=>e.payload?.type==="vk");if(t&&"payload"in t){let[e,n]=t.payload.id.split("_");return[e,n]}return[]};var d={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},C={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function ee(){let i=new Map;function t({listId:r=Math.random().toString(),itemId:o=Math.random().toString(),...a}){let c=i.get(r),h={...a};return c?c[o]=h:i.set(r,{[o]:h}),{listId:r,itemId:o,...a}}function e(r){r.player.destroy(),r.container.remove(),r.subscription.unsubscribe(),r.statistics?.oneStat.destroy(),r.statistics?.statSubscription.unsubscribe()}function n(r,o){let a=i.get(r);if(!a)throw Error("Can't remove. Not find.");if(o){let c=a[o];c&&e(c),delete a[o],Object.keys(a).length||i.delete(r)}else{for(let c of Object.values(a))e(c);i.delete(r)}}function s(){for(let r of i)n(r[0])}return{createPlayer:t,removePlayer:n,map:i,removeAll:s}}function ie(i,t=[]){let e={},n,s=!t.length;for(let r of i.variants)if(!n&&"cover"in r&&(n=r.cover),"url"in r)switch(r.type.toLowerCase()){case"mp4":(s||t.includes("mp4"))&&(e.MPEG={...e.MPEG,[r.standard??"Invariant quality"]:r.url});break;case"mpeg":(s||t.includes("mpeg"))&&(e.MPEG={...e.MPEG,[r.standard??"Invariant quality"]:r.url});break;case"hls":(s||t.includes("hls"))&&(e={...e,HLS:{type:"url",url:r.url}});break;case"dash":(s||t.includes("dash"))&&(e={...e,DASH_SEP:{compatibilityMode:!0,type:"url",url:r.url}});break;default:break}return{sources:e,thumbUrl:n,title:i.title??""}}var st=(i,t)=>{let e=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();e!==t&&n.includes(t)&&(i.setQuality(t),i.setAutoQuality(!1))};var kt={activePlayerChanged:"sc-active-player-changed",playerCreated:"sc-player-created"},Ci=2;function ne(i){let t=ee(),e=new q,n={},s=null,r=!1,o;i&&a(i);function a(T){s=T}function c(T,S,p){if(!s)throw Error("need to set interactive controller");if(!s.options)return;let u=(t.map.get(T)??{})[S];if(u){n={chapterId:p,listId:T,itemId:S,...u};let m=n.player;n.subscription.add(m.info.currentQuality$.subscribe(f=>{let _=m.info.position$.getValue(),w=m.info.isAutoQualityEnabled$.getValue();if(!(!f||!_||w))for(let V of t.map)Object.values(V[1]).forEach(({player:b})=>{st(b,f)})})).add(m.events.started$.subscribe(()=>{h(S)})),u.container.remove(),s.setPlayer(u.player),r||(s.init(),r=!0),e.emit(kt.activePlayerChanged,{player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function h(T){if(!s)throw Error("need to set interactive controller");if(G(n)||T!==n.itemId)return;let S=s.getChapterBranches(),p=new Set;for(let l of S)p.has(l.media.id)||(await g({media:l.media,chapterId:l.chapter.id,setAsActive:!1,title:l.chapter.label}),p.add(l.media.id))}async function y({chapter:{id:T},media:S}){if(G(n))return;let p=n.player.info.muted$.getValue(),l=n.player.info.currentQuality$.getValue(),u=n.player.info.isAutoQualityEnabled$.getValue(),m=n.player.info.volume$.getValue(),f=n.player.info.currentPlaybackRate$.getValue(),_=!u,w=!1;for(let V of t.map)if(V[0]===S.id){let b=Object.keys(V[1]);for(let A of b)A===n.itemId?(b.length<Ci||(w=!0),t.removePlayer(V[0],A)):(w=!0,c(V[0],A,T),_?st(n.player,l):n.player.setAutoQuality(!0),n.player.setVolume(m),n.player.setMuted(p),n.player.setPlaybackRate(f))}else t.removePlayer(V[0]);w||(await g({media:S,chapterId:T,setAsActive:!0,playbackRate:f}),_?st(n.player,l):n.player.setAutoQuality(!0),n.player.setVolume(m),n.player.setMuted(p))}async function g({media:T,chapterId:S,prefetch:p=!0,setAsActive:l=!0,autoplay:u=!1,preferredExt:m,title:f,playbackRate:_}){let w=Math.random().toString(),V=document.createElement("div");o.append(V);let b;if(s?.options?.vkVideoLoader){let ht=ke(T);ht.length&&(b=await s.options.vkVideoLoader(...ht))}let A=s?.options?.coreConfig||{},z={...A,configName:[...A.configName??[],"interactive"]},F={container:V,...b?.videos?.[0]||{sources:ie(T,m).sources},title:f,failoverHosts:b?.failoverHosts||[]},j=new bi(z);j.initVideo(F);let lt=null;if(s?.options.createOneStat){let ht=b.videos[0],le=s.options.createOneStat(ht),he=new Ne;he.add(le.attachTo(j)),lt={oneStat:le,statSubscription:he}}let ce=new Ne,Ye=n?.player?.info.isAutoQualityEnabled$.getValue();ce.add(j.events.canplay$.subscribe(function(){Ye||st(j,n.player.info.currentQuality$.getValue()),_&&j.setPlaybackRate(_)}));let D=t.createPlayer({listId:T.id,itemId:w,player:j,container:V,sources:ie(T,m).sources,config:F,subscription:ce,statistics:lt});return l&&c(T.id,D.itemId,S),u&&D.player.play(),p&&!u&&D.player.prepare(),e.emit(kt.playerCreated,D.player),{player:D.player,config:D.config,statistics:D.statistics}}function E(){v(),s=null,o.remove()}function v(){s?.off(d.chapterChanged,y),t.removeAll(),n={},r=!1}async function k(){if(!s)throw Error("need to set interactive controller");v(),o=document.createElement("div");let{media:T,chapter:S}=s.getCurrentChapter();T?(s.on(d.chapterChanged,y),await g({media:T,chapterId:S.id,title:S.label})):console.error("not found")}return{...t,on:e.on.bind(e),off:e.off.bind(e),init:k,setInteractiveController:a,createPlayer:g,removeAll:E,getActivePlayer:function(){return n}}}import{Subscription as Ei}from"@vkontakte/videoplayer-shared";var Nt=class{constructor({player:t,container:e,branches:n,selectBranches:s,interactiveEvents:r,globalEventEmitter:o,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:h,onRemove:y}){this.container=e,this.branches=n,this.selectBranches=s,this.subscription=new Ei,this.player=t,this.interactiveEvents=r,this.ignoreContainerEvent=a,this.isPermanentText=c&&Lt(e.container.controls),this.disabledControls$=h,this.onRemove=y,this.globalEventEmitter=o,this.gameState=x.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(t=>{t?this.container.disable?.():this.container.enable?.()}))}hide=()=>{setTimeout(()=>{this.gameState!==x.end&&(U(this.container.container.events)&&this.gameState===x.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==x.interactive&&this.container.hide?.(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!1})))})};show=()=>{if(this.gameState===x.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())this.container.show?.(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!0,isFirst:!1});else{let e=Ae({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!1})},onEvent:(n,s)=>{this.isSelectedControlEvent=!0,n!==!1&&(this.removeView(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!1})),(this.gameState===x.end||this.gameState===x.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),s(),this.removeView(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!1}))},isEOV:()=>this.gameState===x.end});this.container.createView(e),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&this.container.disable?.()}};selectContainerEvent(t=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:t?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:t}),!t&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let t=U(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!t)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.visibility,visibility:!1})}onEndOfVideo=()=>{this.gameState=x.end,this.selectContainerEvent(!0)};whilePlaying=()=>{if(this.player.experimental.element$.getValue()?.readyState<1||[x.destroyed,x.removed].includes(this.gameState)&&!this.isPermanentText)return;let e=this.player.getExactTime();if(Re(e,this.container.container))this.gameState!==x.beforeInteractive&&(this.gameState=x.beforeInteractive,this.onBeforeStartTime());else if(Jt(e,this.container.container))this.gameState!==x.interactive&&(this.gameState=x.interactive,this.onStartTime());else if(this.gameState!==x.afterInteractive){let r=this.gameState;this.gameState=x.afterInteractive,r===x.interactive&&this.onEndTime()}else this.gameState!==x.destroyed&&!this.isPermanentText&&this.removeView();let n=Jt(e,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[];this.globalEventEmitter.emit(d.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:e,isInteractiveTime:n})};reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=x.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(d.interactives,{subjectId:this.container.container.id,subjectName:"container",type:C.containerRemoved,visibility:!1}),this.gameState=x.removed,this.onRemove?.()}destroy(){this.reset(),this.removeView(),this.gameState=x.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var je=(i=[])=>i.reduce((t,e,n)=>{let s=(e?.controls??[]).filter(r=>!St(r));if(Rt(s)){let r=[e.startTime??0,e.endTime??1/0],o=e.id;if(!n)t.push({subjects:[o],range:r});else{let a=[],c=-1/0,h=1/0,y=[],g=[];for(let E=0;E<t.length;E++){let v=t[E];if(g.push(...v.subjects),v.range[0]<h&&(h=v.range[0]),v.range[1]>c&&(c=v.range[1]),r[0]>=v.range[0]&&r[1]<=v.range[1])return t[E].subjects.push(o),t;r[0]<v.range[0]&&r[1]>v.range[0]&&(a.push(E),y=y.concat(v.subjects)),r[0]>=v.range[0]&&r[0]<=v.range[1]&&(a.push(E),y=y.concat(v.subjects),r[0]=v.range[0]),r[1]>=v.range[0]&&r[1]<=v.range[1]&&(a.push(E),y=y.concat(v.subjects),r[1]=v.range[1])}if(g.push(o),r[0]<=h&&r[1]>=c)return[{subjects:g,range:r}];a.length&&a.reverse().forEach(E=>{t.splice(E,1)}),t.push({subjects:y.concat([o]),range:r})}}return t},[]).sort((t,e)=>t.range[0]-e.range[0]);function Oe(){let i={};function t(){for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&delete i[a];return!0}function e(a){let c={};for(let h in i)+h<=a&&(c[h]=i[h]);return c}function n(a){let c={};for(let h in i)+h>=a&&(c[h]=i[h]);return c}function s({timestamp:a,priority:c,initiator:h}){if(Kt(a)){let y=i[a]??null;if(y&&J(c,!0)){let g={},E=y[c];return E&&(g={...g,...E}),g=G(g)?null:g,g&&J(h,!0)?g[h]??null:g}return y}return null}function r({timestamp:a,priority:c,initiator:h}){if(Kt(a))if(i[a]){if(J(c,!0))if(i[a][c]){if(J(h,!0))if(i[a][c][h]){if(delete i[a][c][h],!G(i[a][c]))return!0}else return!1;if(delete i[a][c],!G(i[a]))return!0}else return!1;return delete i[a]}else return!1}function o({timestamp:a,priority:c,initiator:h,...y}){i[a]?.[c]?.[h]?i[a][c][h].push({...y}):i[a]?.[c]?i[a][c]={...i[a][c],[h]:[{...y}]}:i[a]?i[a]={...i[a],[c]:{[h]:[{...y}]}}:i[a]={[c]:{[h]:[{...y}]}}}return{map:i,remove:r,add:o,removeAll:t,get:s,getLte:e,getGte:n}}var Ii=[I.expect,I.setNextBranch],xi=1/0;function se(i){let t=i,e,n=Ti(),s=new Oe,r,o=()=>{E(),p()},a=l=>{s.add.call(void 0,l),k()},c=(l=[])=>{for(let u of l)if(u.action(),Ii.includes(u.actionType))break},h=(l=1/0)=>{let u=jt(s.get({timestamp:l,priority:"control"})??{}),m=jt(s.get({timestamp:l,priority:"container"})??{}),f=jt(s.get({timestamp:l,priority:"chapter"})??{});return[...u,...m,...f]},y=l=>{n.isReady(l)&&c(h(l))},g=()=>{c([...jt(s.get({timestamp:1/0,priority:"chapter"})??{})])},E=()=>{e&&(r?.unsubscribe(),e=void 0)},v=l=>{},k=()=>{e||(e=()=>setTimeout(()=>{y(1/0)}),r=t.events.ended$.subscribe(e))},T=l=>{E(),t=l},S=l=>{l.priority==="container"&&n.resetCalled(l.timestamp),s.remove(l)},p=()=>{n.release(),s.removeAll()};return{setPlayer:T,add:a,remove:S,exec:y,execEndOfVideo:g,listen:k,unlisten:E,release:o,containersEventsCallState:n,getPreparedToExecActions:h}}function Ti(){let i=new Map;return{setCalled:({timestamp:o,id:a})=>{let c=i.get(o);c&&c[a]!==void 0&&(c[a]=!0)},setData:(o=[])=>{for(let a of o){let c=a.endTime??xi,h=i.get(c)??{};i.set(c,{...h,[a.id]:!1})}},resetCalled:o=>{let a=i.get(o);if(a)for(let c in a)a[c]=!1},isReady:o=>{let a=i.get(o);return a?!Object.values(a).some(c=>!c):!0},release:()=>i.clear()}}function jt(i){return Object.values(i).flat().sort(t=>t.actionType===I.expect?-1:1)}var Pe={videoContentHeight:0,videoContentWidth:0},$e=(i,t)=>{let{height:e,width:n}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&n))return Pe;let{clientHeight:s,clientWidth:r}=t.experimental.element$.getValue()||{};if(!(s&&r))return Pe;let o=e/n,a=s/r,c,h;return a>o?(h=r,c=r*o):a<o?(h=s/o,c=s):(h=r,c=s),{videoContentWidth:h,videoContentHeight:c}};var Si=250;function Be(i){let t=()=>{},e=new ResizeObserver(a=>{r(a),t=r.bind(null,a)});function n(a){let{parentElement:c,player:h}=i();if(c&&h){let{videoContentWidth:y,videoContentHeight:g}=$e(c,h);c.style.setProperty("--interactive-content-width",`${y}px`),c.style.setProperty("--interactive-content-height",`${g}px`),c.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function s(){let{parentElement:a}=i();a.removeAttribute("style")}let r=Ct(a=>{let{fns:c=[]}=i();n(a);for(let h of c)h()},Si);function o(){t=void 0,e.disconnect(),s()}return{resizeObserver:e,calc:()=>{t()},release:o}}var rt=class{constructor(){this.map={}}push(t,e){t in this.map?this.map[t].push(e):this.map[t]=[e]}get(t){let e=this.map[t];return e?e.slice():null}getAll(){let t=[];for(let e in this.map)t.concat(this.map[e]);return t}remove(t,e){t in this.map&&(this.map[t]=this.map[t].filter(n=>n!==e),this.map[t].length===0&&delete this.map[t])}clear(){this.map={}}keys(){return Object.keys(this.map)}size(){return this.keys().length}};var wi=i=>Math.floor(Math.random()*i),Fe=i=>{let t=i.length,e=1/0,n=null;for(;t--;)i[t].weight<e&&(e=i[t].weight,n=i[t]);return n},De=i=>{let t=i.length,e=-1/0,n=null;for(;t--;)i[t].weight>e&&(e=i[t].weight,n=i[t]);return n};var He=i=>{let t=i.length,e=wi(t);return i[e]};var Ge=i=>{let t=0;for(let n=0;n<i.length;++n)t+=i[n].weight??1;let e=Math.random()*t;t=0;for(let n=0;n<i.length-1;++n)if(t+=i[n].weight??1,t>=e)return i[n];return i[i.length-1]};var Ue=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var re=(i,t=!1)=>({...i,args:t?{...i.args,...Ue}:{...Ue,...i.args}}),ae=({globalEventEmitter:i,player:t,interactiveEvents:e,removeControllers:n})=>{let s={isExpect:!1},r=()=>{s.isExpect&&(s.isExpect=!1)},o=({action:p,controlType:l,controlId:u,containerId:m,branches:f=[],onEvent:_,isEOV:w=()=>!1,isDisabled:V=()=>!1})=>{let b=re(p,w()),A={timestamp:1/0,priority:"control",initiator:u,actionType:b.type},z=V(),F=i.emit.bind(i,d.interactives,{subjectId:u,subjectType:l,subjectName:"control",type:z?C.actionChoiceCanceled:C.actionChoice,actionType:p.type,payload:{containerId:m,...b.args}});if(z){F();return}switch(b.type.trim().toLowerCase()){case I.setNextBranch.trim().toLowerCase():{let j=f.find(lt=>lt.id===b.args.branchId);if(!j)return;_(b.args.isDetachContainer,E.bind(null,{subjectId:u,subjectName:"control"})),F(),b.args.shouldOpenNow?k({subjectId:u,subjectName:"control",subjectType:l,action:b,payload:{chapterId:j.chapterId,autoSelect:!1}}):(e.add({...A,action:k.bind(null,{subjectId:u,subjectName:"control",subjectType:l,action:b,payload:{chapterId:j.chapterId,autoSelect:!1}})}),n?.());return}case I.continuePlayback.trim().toLowerCase():{_(b.args.isDetachContainer,E.bind(null,{subjectId:u,subjectName:"control"})),F(),b.args.shouldOpenNow?v({subjectId:u,subjectName:"control",subjectType:l,action:p}):e.add({...A,action:v.bind(null,{subjectId:u,subjectName:"control",subjectType:l,action:p})});return}case I.openURI.trim().toLowerCase():{_(b.args.isDetachContainer,E.bind(null,{subjectId:u,subjectName:"control"})),F(),b.args.shouldOpenNow?S({subjectId:u,subjectName:"control",subjectType:l,action:b,payload:{URI:p.args.uri}}):(e.add({...A,action:S.bind(null,{subjectId:u,subjectName:"control",subjectType:l,action:b,payload:{URI:p.args.uri}})}),n?.());return}default:console.error("Unexpected control event"),i.emit(d.errors,new R(1,1,{message:"Unexpected control event"}));return}},a=({action:p,container:{id:l,endTime:u},branches:m=[],isEOV:f=!1,autoSelected:_=!1})=>{let w=re(p,f),V={timestamp:!w.args.shouldOpenNow||f?1/0:u,priority:"container",initiator:l,actionType:w.type},b=i.emit.bind(i,d.interactives,{subjectId:l,subjectName:"container",type:C.actionChoice,actionType:w.type,payload:w.args});switch(w.type.trim().toLowerCase()){case I.setNextBranch.trim().toLowerCase():{let A=m.find(z=>z.id===w.args.branchId);if(!A)return;b(),e.add({...V,action:k.bind(null,{subjectId:l,subjectName:"container",action:w,payload:{chapterId:A.chapterId,autoSelect:_}})}),n?.();return}case I.setMaxWeightBranch.trim().toLowerCase():return;case I.setMinWeightBranch.trim().toLowerCase():return;case I.setRandomBranch.trim().toLowerCase():return;case I.setWeightlessRandomBranch.trim().toLowerCase():return;case I.continuePlayback.trim().toLowerCase():{b(),e.add({...V,action:v.bind(null,{subjectId:l,subjectName:"container",action:w})});return}case I.openURI.trim().toLowerCase():{b(),e.add({...V,action:S.bind(null,{subjectId:l,subjectName:"container",action:w,payload:{URI:p.args.uri}})}),n?.();return}default:console.error("Unexpected container event"),i.emit(d.errors,new R(1,1,{message:"Unexpected container event"}));return}};function c({container:p,branches:l,isEOV:u=!1}){let m=te(p.events);if(m){let f=re(m.action,u);i.emit(d.interactives,{subjectId:p.id,subjectName:"container",type:C.actionChoice,actionType:f.type,payload:f.args}),e.add({timestamp:u?1/0:p.endTime,priority:"container",initiator:p.id,actionType:I.expect,action:g.bind(null,{subjectId:p.id,subjectName:"container"})}),s.isExpect=!0}else for(let f of p.events)a({action:f.action,container:p,branches:l,isEOV:u})}let h=({chapterId:p,action:l,branches:u=[]})=>{let m=i.emit.bind(i,d.interactives,{subjectId:p,subjectName:"chapter",type:C.actionChoice,actionType:l.type,payload:l.args});switch(l.type.trim().toLowerCase()){case I.setNextBranch.trim().toLowerCase():{let f=u.find(_=>_.id===l.args.branchId);return f?.chapterId?(m(),k.bind(null,{subjectId:p,subjectName:"chapter",action:l,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case I.setWeightlessRandomBranch.trim().toLowerCase():{let f=He(u);return f?.chapterId?(m(),k.bind(null,{subjectId:p,subjectName:"chapter",action:l,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case I.setRandomBranch.trim().toLowerCase():{let f=Ge(u);return f?.chapterId?(m(),k.bind(null,{subjectId:p,subjectName:"chapter",action:l,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case I.setMaxWeightBranch.trim().toLowerCase():{let f=De(u);return f?.chapterId?(m(),k.bind(null,{subjectId:p,subjectName:"chapter",action:l,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case I.setMinWeightBranch.trim().toLowerCase():{let f=Fe(u);return f?.chapterId?(m(),k.bind(null,{subjectId:p,subjectName:"chapter",action:l,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case I.continuePlayback.trim().toLowerCase():return m(),v.bind(null,{subjectId:p,subjectName:"chapter",action:l});case I.openURI.trim().toLowerCase():return m(),S.bind(null,{subjectId:p,subjectName:"chapter",action:l,payload:{URI:l.args.uri}});default:console.error("Unexpected chapter event"),i.emit(d.errors,new R(1,1,{message:"Unexpected chapter event"}));return}};function y(p){let l=te(p.events);if(l){if(O(p))return;i.emit(d.interactives,{subjectId:p.id,subjectName:"chapter",type:C.actionChoice,actionType:l.action.type,payload:l.action.args}),e.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.expect,action:g.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else p.events.forEach(u=>{let m=h({chapterId:p.id,action:u.action,branches:p.branches});m&&e.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:u.action.type,action:m})})}let g=({subjectId:p,subjectName:l,action:u})=>{t.pause(),i.emit(d.interactives,{subjectId:p,subjectName:l,type:C.actionExecution,actionType:u?.type??I.expect})},E=({subjectId:p,subjectName:l})=>{t.info.isEnded$.getValue()?e.execEndOfVideo():t.play(),i.emit(d.interactives,{subjectId:p,subjectName:l,type:C.actionExecution,actionType:"after-expect"})},v=({subjectId:p,subjectName:l,subjectType:u,action:m})=>{i.emit(d.interactives,{subjectId:p,subjectName:l,subjectType:u,type:C.actionExecution,actionType:m.type})},k=({subjectId:p,subjectName:l,subjectType:u,action:m,payload:f})=>{f.behaviour="change-chapter",i.emit(d.interactives,{subjectId:p,subjectName:l,subjectType:u,type:C.actionExecution,actionType:m.type,payload:f})},T=({subjectId:p,subjectName:l,subjectType:u,action:m,payload:f})=>{f.behaviour="change-manifest",i.emit(d.interactives,{subjectId:p,subjectName:l,subjectType:u,type:C.actionExecution,actionType:m.type,payload:f})},S=({subjectId:p,subjectName:l,subjectType:u,action:m,payload:f})=>{if(!f.URI)return;let _=window.open(f.URI,"_blank","noopener,noreferrer");_&&(_.opener=null),i.emit(d.interactives,{subjectId:p,subjectName:l,subjectType:u,type:C.actionExecution,actionType:m.type})};return{onControlEvent:o,onContainerEvent:a,onChapterEvent:h,onExpectEvent:g,expectEventHandler:E,setManifestChapterEvents:y,setManifestContainerEvents:c,stopExpect:r,state:s}};import{Subscription as Ai,ValueSubject as at}from"@vkontakte/videoplayer-shared";var oe=(i,t)=>{let e={};return i.map(n=>{if(!e[n]){let s=t.chapters.find(o=>o.id===n);if(!s)return null;let r=t.media.videos.find(o=>s.videoId===o.id);if(!r)return null;e[n]=Qe(r)}return e[n]}).filter(Boolean)},Vi=i=>{for(let t of i.variants)if(Mi(t)&&"payload"in t)return t.payload.id},Mi=i=>i.type==="custom"&&"payload"in i&&i.payload.type==="vk",Qe=i=>{let t=Vi(i);if(!t)return null;let e=t.split("_").pop();return e?parseInt(e,10):null},Ri=(i,t)=>{for(let e of i.media.videos)if(t===Qe(e)){for(let n of i.chapters)if(n.videoId===e.id)return n.id;return}},Ke=(i,t)=>i.reduce((e,n)=>{let s=Ri(t,n);return s?[...e,s]:e},[]);var ot=class{constructor({globalEventEmitter:t,videoId:e,interactiveController:n,historyApi:s,settings:r}){this.state={history$:new at([]),hasPrevChapter$:new at(!1),prevChapter$:new at(null),isInitialChapter$:new at(!1),isGoBackLimited$:new at(!1)};this.#a=null;this.#h=!1;this.#i=null;this.#d=null;this.#n=null;this.#r=null;this.#o=null;this.#t=new Ai;this.#p=!1;this.#u=0;this.#n=e,this.#o=t,this.#r=n,this.#a=s,this.#s=r,this.state?.history$&&this.#t&&this.#t?.add(this.state?.history$.subscribe(o=>{this.state?.prevChapter$.next(o.at(-2)||null),this.state?.hasPrevChapter$.next(o.length>1),this.state?.isInitialChapter$.next(this.getInitialChapterId()===this.#i?.metadata?.initChapterId),this.state?.isGoBackLimited$.next(this.#u===this.#s.maxLength-1)}))}#a;#s;#h;#i;#d;#n;#r;#o;#t;#p;#u;async setManifest(t){!this.#r||!this.#o||(this.#i=t,await this.getProjectHistory(),await this.#r.setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),this.#h||(this.#h=!0,this.#o.emit(d.historyInited,{initChapterId:this.getInitialChapterId()})))}get inited(){return this.#h}async updateHistory(t,e=!0){if(!this.#i)return;this.#p?(this.#p=!1,this.#u++):this.#u=0;let n=this.#i,s=t.length-this.#s.maxLength,r=s>0?t.slice(s):t,o=oe(r,n);if(this.#d=o,this?.state?.history$.next(r),!(!e||!this.#a||!this.#n))try{await this.#a.save(this.#n,o)}catch{this.#o?.emit(d.errors,new R(1,5,"Unable to save interactive history"))}}async goBack(){if(!this.state||!this.#r)return this.#o?.emit(d.errors,new R(1,5,"Cannot go back because HistoryController has not been initialized"));this.#p=!0;let t=this.state.history$.getValue().slice(0,-1),e=t.pop();this.state.history$.next(t),await this.#r.setChapter({chapterId:e})}async getProjectHistory(){if(!this.#i||!this.#n)return;let t=this.#i,e=[this.getInitialVideoId()];if(this.#a)try{let s=await this.#a.get(this.#n);s.length&&(e=s)}catch{this.#o?.emit(d.errors,new R(1,5,"Error while trying to fetch data"))}let n=Ke(e,t);this?.state?.history$.next(n)}getInitialChapterId(){return this.state?.history$.getValue()?.at(-1)||this.#s.initChapterId||this.#i?.metadata.initChapterId}getInitialVideoId(){if(this.#i){let t=this.getInitialChapterId();return oe([t],this.#i).pop()}return null}destroy(){this.state=null,this.#n=null,this.#a=null,this.#r=null,this.#t?.unsubscribe(),this.#t=null,this.#h=!1,this.#o?.emit(d.historyDestroyed),this.#o=null}};var Ot=class i{constructor(t,e,n,s){this.target=t,this.type=e,this.listener=n,this.options=i._convertOptions(t,s),this.target.addEventListener(e,n,this.options)}unlisten(){this.type&&this.listener&&this.options&&this.target?.removeEventListener(this.type,this.listener,this.options),this.target=null,this.type=null,this.listener=null,this.options=!1}static _convertOptions(t,e){if(e===void 0)return!1;if(typeof e=="boolean")return e;{let n=new Set(["passive","capture"]),s=Object.keys(e).filter(o=>!n.has(o));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),i._doesSupportObject(t)?e:e.capture||!1}}static{this._supportsObject=void 0}static _doesSupportObject(t){let e=i._supportsObject;if(e===void 0){e=!1;try{let n={},s={get:()=>(e=!0,!1)};Object.defineProperty(n,"passive",s),Object.defineProperty(n,"capture",s);let r=()=>{};t.addEventListener("test",r,n),t.removeEventListener("test",r,n)}catch{e=!1}i._supportsObject=e}return e||!1}};var Pt=class{constructor(){this.bindingMap=new rt}release(){this.removeAll(),this.bindingMap=null}listen(t,e,n,s){if(!this.bindingMap)return;let r=new Ot(t,e,n,s);this.bindingMap.push(e,r)}listenOnce(t,e,n,s){let r=o=>{this.unlisten(t,e,r),n(o)};this.listen(t,e,r,s)}unlisten(t,e,n){if(!this.bindingMap)return;let s=this.bindingMap.get(e)||[];for(let r of s)r.target===t&&(n===r.listener||!n)&&(r.unlisten(),this.bindingMap.remove(e,r))}removeAll(){if(!this.bindingMap)return;let t=this.bindingMap.getAll();for(let e of t)e.unlisten();this.bindingMap.clear()}};var $t=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 t=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!t)return!1;let e=t.data,n=e.length;for(let s=3;s<n;s+=40)if(e[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(t){this.canvasImgSrc=t}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(t,e=!1){let n=t.width+t.height;if(this._prevSizeId===n)return;let s;e&&(s=await this.save()),this.rootElement.width=t.width,this.rootElement.height=t.height,e&&s&&this.restore(s),this._prevSizeId=n}async save(){let t=this.rootElement.toDataURL("image/jpeg",1),e=new Image;return e.crossOrigin="anonymous",e.src=t,await e.decode(),e}restore(t){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(t,0,0,this.rootElement.width,this.rootElement.height)}};var Bt=class{constructor({parentElement:t,endOffsetMs:e=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=t=>{let e=t??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(e);if(this.isContainerTime(e))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;
|
|
@@ -16,8 +16,8 @@ var pe="1.0.16-dev.4720172e.0";function Ht(i,t=1){let e="0",n="0",s="0";return i
|
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),t.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(t){this.currentVideoDurationMs=t}setVideoElement(t){this.lastFrameCanvas.setCanvasImageSource(t)}setCurrentChapter(t){this.currentChapter=t}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(t=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(t=!1);let e=getComputedStyle(this.rootElement),n={width:parseInt(e.getPropertyValue("--interactive-content-width"),10),height:parseInt(e.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,t)}catch(s){this._onError(s)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(t){return this.currentVideoDurationMs&&t>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(t){if(this.currentChapter)return this.currentChapter.containers.some(e=>e.controls?.length&&t>=(e.startTime??0)&&t<=Math.min(e.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(t){this._callbacks?.onError?.(t)}};function
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),t.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(t){this.currentVideoDurationMs=t}setVideoElement(t){this.lastFrameCanvas.setCanvasImageSource(t)}setCurrentChapter(t){this.currentChapter=t}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(t=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(t=!1);let e=getComputedStyle(this.rootElement),n={width:parseInt(e.getPropertyValue("--interactive-content-width"),10),height:parseInt(e.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,t)}catch(s){this._onError(s)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(t){return this.currentVideoDurationMs&&t>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(t){if(this.currentChapter)return this.currentChapter.containers.some(e=>e.controls?.length&&t>=(e.startTime??0)&&t<=Math.min(e.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(t){this._callbacks?.onError?.(t)}};function qe(i=0){return new Promise(t=>{setTimeout(()=>{t(0)},i)})}var Xe=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,historyApi:null,historyParams:null,projectInfo:{},initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}}),P=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function Pi(){let i=document.createElement("div");return i.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,i}var Bt=class{#o=null;#r=null;#h=null;#i=null;#d=null;#n=null;#s=null;#a=null;#t=null;#p=new N(!1);#u=new Set;#l=null;#v=null;#c=null;#e=null;#f=new et;#m=null;state={prevChapter$:new N(null),isInitialChapter$:new N(!1),isEndChapter$:new N(!1),isInteractiveExpectation$:new N(!1),calledByInteractive$:new N(!1),lastChapterChangeWasInitiatedByInteractive$:new N(!1),disabledControls$:new N(!1),interactiveRanges$:new N([]),isInteractiveTime$:new N(!1)};events={noInteraction$:new Li};constructor(t){this.options={...qe,...t,config:{...qe.config,...t.config}},this.#r=[],this.factories=new Map([["choice",Ct]]),this.rootElement=Pi(),this.options.parentElement.append(this.rootElement),this.#e=new X,this.#d=new Ni,this.#h=new Pt,this.#i=new ct({interactiveController:this,globalEventEmitter:this.#e,videoId:this.options.projectInfo?.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}}),this.options.lastFrame&&(this.#c=new Ft({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:e=>this.#e.emit(u.errors,new M(1,6,e))})),this.#h.listen(this.rootElement,"mousedown",e=>e.stopPropagation()),this.#h.listen(this.rootElement,"mouseup",e=>e.stopPropagation()),this.#t=new q(this.options.loaders,e=>this.#e.emit(u.errors,new M(1,3,e))),this.#n=se(this.options.player),this.#s=new _t,this.#a=ae({player:this.options.player,interactiveEvents:this.#n,globalEventEmitter:this.#e,removeControllers:this.#y}),this.#o=$e(()=>({player:this.options?.player,parentElement:this.options?.parentElement,fns:this.options?.lastFrame?[()=>{this.#c.updateCanvasDimensions(!0)}]:[]})),this.options.graph&&(this.#l=new tt({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:e=>{this.setChapter({chapterId:e}),this.#e.emit(u.graph,{type:nt.watchAgainClicked,chapterId:e})},onError:e=>this.#e.emit(u.errors,new M(1,4,{message:e}))})),this.#I(this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=$.created}emitPlayerChanged=t=>{this.#e.emit(u.playerChanged,t)};#I(t=!1){this.#e.on(u.historyInited,async({initChapterId:e,videosInfo:n=[]})=>{t&&await this.#T({initialChapter:e,videosInfo:n})}),this.#e.on(u.interactives,async e=>{if(e.type===b.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s})}if(e.payload?.behaviour==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===b.containerRemoved&&this.#A(e.subjectId)}),this.#e.on(u.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}async#T({source:t,videosInfo:e=[]}){this.#v=re(this);let n=document.createElement("div");this.#v.on(st.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:r}=await this.#v.init({source:t,initialChapter:this.#i.getInitialChapterId(),container:n});return this.updateGraphVideosInfo(e),{player:s,config:r}}getStatEvents(){return{click$:new Xe(t=>{this.#e.on(u.graph,({type:e,visibility:n})=>{e==="visibility"&&t.next(n?"OPEN_GRAPH":"CLOSE_GRAPH"),e==="watchAgainClicked"&&t.next("WATCH_AGAIN")}),this.#e.on(u.interactives,({type:e,subjectName:n,subjectType:s})=>{e!=="action-choice"||n!=="control"||(s==="Button"&&t.next("GO_NEXT_BUTTON"),s==="Area"&&t.next("GO_NEXT_AREA"))})}),nextMovie$:new Xe(t=>{this.#e.on(u.playerChanged,({config:e})=>{e?.unitedVideoId&&t.next(e.unitedVideoId)})})}}setPlayer(t){this.#b(),this.options.player=t,this.#f.setPlayer(this.options.player),this.#n?this.#n.setPlayer(this.options.player):this.#n=se(this.options.player),this.#a=ae({player:this.options.player,interactiveEvents:this.#n,globalEventEmitter:this.#e,removeControllers:()=>this.#y(!1)}),this.appState===$.initiated&&(this.#C(),this.#g(this.#t.chapter))}async setManifest(t){this.#b(),this.isFirstChapterFetched=!1;let e=await this.#t.setManifest(t);return this.#l&&await this.#l.handleManifestChange(e.manifest),await this.#i.setManifest(e.manifest),this.#e.emit(u.manifestChanged,{manifest:e.manifest}),this.#g(this.#t.chapter),e.manifest}setVisitedChapters(t){Array.isArray(t)&&this.#l?.setVisitedChapters(t)}updateGraphVideosInfo(t){Array.isArray(t)&&this.#l?.updateVideosInfo(t)}async setChapter({chapterId:t,pushToHistory:e=!0}={}){this.#b(),this.#c&&this.isFirstChapterFetched&&(this.#c.draw(),this.#c.show()),ji.isSafari&&await Ke(35);let{chapter:n,media:s,graph:r}=await(t?this.#t.setNext(t):this.#t.setInitial());return e&&this.#R(n.id),this.state.isInitialChapter$.next(this.#t.isInitialChapter()),this.state.isEndChapter$.next(this.#t.isEndChapter()),this.#l&&this.#l.handleChapterChange(r),this.#c?.setCurrentChapter(this.getCurrentChapter().chapter),this.#e.emit(u.chapterChanged,{chapter:n,media:s,graph:r}),this.#g(this.#t.chapter),this.#u=new Set,this.isFirstChapterFetched=!0,{chapter:n,media:s,graph:r}}toggleGraphView(t=!0){this.#l&&(t?(this.#l.show(),this.#p.next(!1)):(this.#l.hide(),this.#E()),this.#e.emit(u.graph,{type:nt.visibility,visibility:t}))}init(){this.#t.chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===$.created&&(this.#o.resizeObserver.observe(this.options.fullscreenTargetElement),this.#C(),this.appState=$.initiated,this.#g(this.#t.chapter))}#b(){this.appState===$.ready&&(this.#y(),this.#r=[],this.#s.release(),this.#n?.release(),this.appState=$.initiated,this.#p.next(!1),this.#x())}#M=()=>{this.#s.fns.forEach(n=>n());let t=this.options.player.info.position$.getValue()*1e3,e=(this.#t.chapter.containers||[]).filter(n=>n.startTime>=Math.floor(t));for(let n of e){this.#n.remove({timestamp:1/0,priority:"container",initiator:n.id});for(let s of n.controls)this.#n.remove({timestamp:1/0,priority:"control",initiator:s.id});this.#r.find(s=>s.container.container.id===n.id).reset()}};#S=()=>{this.#o.calc(),this.#s.requestAnimation()};#w(t){(!this.#l||this.#l.isHidden)&&this.#E();let e=t*1e3,s=this.getInteractiveRanges().findLast(({range:r})=>e>=r[1]);if(s){let r=s.range.join("-");this.#u.has(r)||(this.#u.add(r),this.#e.emit(u.interactives,{type:b.rangeEnded,payload:s,visibility:!0}))}}deadEndCheck(){return!(this.#n?.getPreparedToExecActions()??[]).some(n=>n.actionType===E.setNextBranch)}allControlsAreRemoved(){return!this.#r.some(e=>!e.container.isRemoved)}isEndedExpectation(){if(!this.options?.player||!this.#r)return!1;let t=this.options.player.info.position$.getValue(),e=this.options.player.info.duration$.getValue();return t===e&&this.#r.some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&U(s.events)})}#C(){this.#d.unsubscribe(),this.#d.add(this.options.player.events.started$.pipe(ki()).subscribe(this.#S)).add(this.options.player.events.playing$.subscribe(this.#s.requestAnimation)).add(this.options.player.events.willPause$.subscribe(this.#s.cancelAnimation)).add(this.options.player.info.position$.subscribe(this.#w.bind(this))).add(this.#t.prevChapter$.subscribe(t=>this.state.prevChapter$.next(t))).add(Oi({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:t,interactiveRanges:e,isInteractiveExpectation:n})=>{let s;if(n)s=!0;else{let l=t*1e3;s=!!e?.find(({range:[y,g],subjects:C})=>y<l&&l<g&&C.length)}s!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(s);let r=this.#m!==null,o=this.options.player.info.playbackState$.getValue()==="playing"||n;s&&!r&&o?this.#m=setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout):r&&!o&&this.#x()})),this.options.lastFrame&&this.#d.add(this.options.player.info.duration$.subscribe(t=>{this.#c.setVideoDuration(t*1e3)})).add(this.options.player.experimental.element$.subscribe(t=>{t&&this.#c.setVideoElement(t)})).add(this.options.player.events.firstFrame$.subscribe(()=>{this.#c.reset(),setTimeout(()=>{this.#c.hide(),this.#c.lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(this.#c.onSeek))}#y=(t=!0)=>{this.#r.forEach(e=>{!t&&e.isPermanentText||(this.#s.removeFn(e.whilePlaying),e.destroy())})};#g(t){this.#t.chapter&&this.appState===$.initiated&&(this.#a.setManifestChapterEvents(t),this.#r=this.#_(t),this.#n.containersEventsCallState.setData(t.containers),this.#f.setContainers(this.#r.map(e=>e.container.container).filter(e=>!kt(e.controls))),this.options.lastFrame&&this.#s.addFn(()=>{this.#c.onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=$.ready)}#_(t){return t?.containers?.reduce((e,n)=>{let s=n.type.trim().toLowerCase(),r=this.factories.get(s);if(r){let a=new Nt({player:this.options.player,container:r(n,this.rootElement),branches:this.#t.chapter.branches,selectBranches:this.#a,interactiveEvents:this.#n,globalEventEmitter:this.#e,ignoreContainerEvent:()=>Le(n,this.#r),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.#f.deleteContainer(n.id)}});return this.#s.addFn(a.whilePlaying,!0),[...e,a]}return[...e]},[])??[]}#E(){if(this.state.isInteractiveExpectation$.getValue()){this.#p.next(!1);return}let e=this.#p.getValue(),n=!!this.#f.getNextInteractiveTime();(n&&!e||!n&&e)&&this.#p.next(!e)}#V(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}#R(t){if(this.#V(),!this.#i.inited)return;let e=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),s=(n&&P(n)&&Lt(n))??!1,r=this.#t.manifest.metadata.initChapterId===t,a=this.#i.state.history$.getValue();if(r||s&&e){this.#i.updateHistory([t]);return}a.at(-1)!==t&&this.#i.updateHistory([...a,t])}#A=t=>{let{interactiveRanges$:e}=this.state,s=e.getValue().map(r=>({...r,subjects:r.subjects.filter(a=>a!==t)}));e.next(s)};#x=()=>{this.#m&&(clearTimeout(this.#m),this.#m=null)};playPrevChapter(){this.#i?.goBack()}setDisabledControls(t){this.state.disabledControls$.next(t)}isSupport(t=this.#t.manifest){return St(t.metadata.version)}getInitialVideoInfo(){return{videoId:this.#i.getInitialVideoId(),chapterId:this.#i.getInitialChapterId()}}getHistoryState(){return this.#i.state}getIsSeekable(){return this.#p}getInteractiveRanges(){return Ne(this.#t.chapter?.containers)}getNextInteractiveStartTime(t){return this.#f.getNextInteractiveTime(t)}getChapterBranches(t){return this.#t.getBranches(t)}getCurrentChapter(){return this.#t.getCurrent()}getCurrentManifest(){return this.#t.manifest}addFactory(t,e){this.factories.set(t.trim().toLowerCase(),e)}removeFactory(t){this.factories.delete(t.trim().toLowerCase())}on(...t){return this.#e.on(...t),this}off(...t){return this.#e.off(...t),this}once(...t){return this.#e.once(...t),this}destroy(){this.#y(),this.#r=void 0,this.state=void 0,this.#l?.destroy(),this.#l=void 0,this.#o.release(),this.#o=void 0,this.#a=void 0,this.#s.release(),this.#s=void 0,this.#n.release(),this.#n=void 0,this.#t.release(),this.#a=void 0,this.#h.release(),this.#h=void 0,this.#d.unsubscribe(),this.#d=void 0,this.#e.reset(),this.#e=void 0,this.#c?.destroy(),this.#c=void 0,this.rootElement.remove(),this.rootElement=void 0,this.#i.destroy(),this.#i=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=$.destroyed}};var $i={Container:K,createChoiceContainer:Ct,createAreaControl:gt,createButtonControl:bt,createRelativeLayout:ge,getRootEl:dt,classnamesPrefix:_};var oo={version:pe};export{M as CustomError,u as EVENT_NAMES,Zt as INTERACTIVE_CLICK_ACTIONS,Bt as Interactives,q as ManifestController,oo as SDKInfo,ce as chapterIdsToVKVideoIds,B as compareVersions,Ai as getChapterIdByVkVideoId,We as getVKVideoIdByMedia,Vi as getVideoRawIdByMedia,nt as graphEventTypes,Lt as hasEndTemplate,b as interactivesEventTypes,P as isLastChapter,St as isSupportedManifest,Ri as isVKVariantItem,$i as utils,Qe as vkVideoIdsToChapterIds};
|
|
23
|
+
`,i}var Ft=class{#a=null;#s=null;#h=null;#i=null;#d=null;#n=null;#r=null;#o=null;#t=null;#p=new N(!1);#u=new Set;#l=null;#f=null;#c=null;#e=null;#m=new et;#y=null;state={prevChapter$:new N(null),isInitialChapter$:new N(!1),isEndChapter$:new N(!1),isInteractiveExpectation$:new N(!1),calledByInteractive$:new N(!1),lastChapterChangeWasInitiatedByInteractive$:new N(!1),disabledControls$:new N(!1),interactiveRanges$:new N([]),isInteractiveTime$:new N(!1),statistics$:new N(null)};events={noInteraction$:new Li};constructor(t){this.options={...Xe,...t,config:{...Xe.config,...t.config}},this.#s=[],this.factories=new Map([["choice",bt]]),this.rootElement=Pi(),this.options.parentElement.append(this.rootElement),this.#e=new q,this.#d=new Ni,this.#h=new Pt,this.#i=new ot({interactiveController:this,globalEventEmitter:this.#e,videoId:this.options.projectInfo?.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}}),this.options.lastFrame&&(this.#c=new Bt({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:e=>this.#e.emit(d.errors,new R(1,6,e))})),this.#h.listen(this.rootElement,"mousedown",e=>e.stopPropagation()),this.#h.listen(this.rootElement,"mouseup",e=>e.stopPropagation()),this.#t=new Z(this.options.loaders,e=>this.#e.emit(d.errors,new R(1,3,e))),this.#n=se(this.options.player),this.#r=new wt,this.#o=ae({player:this.options.player,interactiveEvents:this.#n,globalEventEmitter:this.#e,removeControllers:this.#g}),this.#a=Be(()=>({player:this.options?.player,parentElement:this.options?.parentElement,fns:this.options?.lastFrame?[()=>{this.#c.updateCanvasDimensions(!0)}]:[]})),this.options.graph&&(this.#l=new tt({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:e=>{this.setChapter({chapterId:e}),this.#e.emit(d.graph,{type:nt.watchAgainClicked,chapterId:e})},onError:e=>this.#e.emit(d.errors,new R(1,4,{message:e}))})),this.#x(),this.isFirstChapterFetched=!1,this.appState=P.created}#x(){this.#e.on(d.historyInited,async({videosInfo:t=[]})=>{this.options.initSeamless&&(await this.#S(),this.updateGraphVideosInfo(t))}),this.#e.on(d.interactives,async t=>{if(t.type===C.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),t.payload?.behaviour==="change-chapter"){let{chapterId:n}=t.payload;this.setChapter({chapterId:n})}if(t.payload?.behaviour==="change-manifest"){let{manifestURL:n}=t.payload;this.setManifest(n)}let e=t.type==="action-execution";e&&t.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e&&t.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}t.type===C.containerRemoved&&this.#A(t.subjectId)}),this.#e.on(d.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}#T=({statistics:t,...e})=>{if(t){let{statSubscription:n,oneStat:s}=t;n.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.#e.emit(d.playerChanged,e)};async#S(){this.#f=ne(this),this.#f.on(kt.activePlayerChanged,this.#T),this.#f.init()}getStatEvents(){return{click$:new Ze(t=>{this.#e.on(d.graph,({type:e,visibility:n})=>{e==="visibility"&&t.next(n?ct.GRAPH_SHOW:ct.GRAPH_HIDE),e==="watchAgainClicked"&&t.next(ct.WATCH_AGAIN)}),this.#e.on(d.interactives,({type:e,subjectName:n,subjectType:s})=>{e!=="action-choice"||n!=="control"||(s==="Button"&&t.next(ct.NEXT_BUTTON),s==="Area"&&t.next(ct.NEXT_AREA))})}),nextMovie$:new Ze(t=>{this.#e.on(d.playerChanged,({config:e})=>{e?.unitedVideoId&&t.next(e.unitedVideoId)})})}}setPlayer(t){this.#b(),this.options.player=t,this.#m.setPlayer(this.options.player),this.#n?this.#n.setPlayer(this.options.player):this.#n=se(this.options.player),this.#o=ae({player:this.options.player,interactiveEvents:this.#n,globalEventEmitter:this.#e,removeControllers:()=>this.#g(!1)}),this.appState===P.initiated&&(this.#C(),this.#v(this.#t.chapter))}async setManifest(t){this.#b(),this.isFirstChapterFetched=!1;let e=await this.#t.setManifest(t);return this.#l&&await this.#l.handleManifestChange(e.manifest),await this.#i.setManifest(e.manifest),this.#e.emit(d.manifestChanged,{manifest:e.manifest}),this.#v(this.#t.chapter),e.manifest}setVisitedChapters(t){Array.isArray(t)&&this.#l?.setVisitedChapters(t)}updateGraphVideosInfo(t){Array.isArray(t)&&this.#l?.updateVideosInfo(t)}async setChapter({chapterId:t,pushToHistory:e=!0}={}){this.#b(),this.#c&&this.isFirstChapterFetched&&(this.#c.draw(),this.#c.show()),ji.isSafari&&await qe(35);let{chapter:n,media:s,graph:r}=await(t?this.#t.setNext(t):this.#t.setInitial());return e&&this.#R(n.id),this.state.isInitialChapter$.next(this.#t.isInitialChapter()),this.state.isEndChapter$.next(this.#t.isEndChapter()),this.#l&&this.#l.handleChapterChange(r),this.#c?.setCurrentChapter(this.getCurrentChapter().chapter),this.#e.emit(d.chapterChanged,{chapter:n,media:s,graph:r}),this.#v(this.#t.chapter),this.#u=new Set,this.isFirstChapterFetched=!0,{chapter:n,media:s,graph:r}}toggleGraphView(t=!0){this.#l&&(t?(this.#l.show(),this.#p.next(!1)):(this.#l.hide(),this.#E()),this.#e.emit(d.graph,{type:nt.visibility,visibility:t}))}init(){this.#t.chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===P.created&&(this.#a.resizeObserver.observe(this.options.fullscreenTargetElement),this.#C(),this.appState=P.initiated,this.#v(this.#t.chapter))}#b(){this.appState===P.ready&&(this.#g(),this.#s=[],this.#r.release(),this.#n?.release(),this.appState=P.initiated,this.#p.next(!1),this.#I())}#L=()=>{this.#r.fns.forEach(n=>n());let t=this.options.player.info.position$.getValue()*1e3,e=(this.#t.chapter.containers||[]).filter(n=>n.startTime>=Math.floor(t));for(let n of e){this.#n.remove({timestamp:1/0,priority:"container",initiator:n.id});for(let s of n.controls)this.#n.remove({timestamp:1/0,priority:"control",initiator:s.id});this.#s.find(s=>s.container.container.id===n.id).reset()}};#w=()=>{this.#a.calc(),this.#r.requestAnimation()};#_(t){(!this.#l||this.#l.isHidden)&&this.#E();let e=t*1e3,s=this.getInteractiveRanges().findLast(({range:r})=>e>=r[1]);if(s){let r=s.range.join("-");this.#u.has(r)||(this.#u.add(r),this.#e.emit(d.interactives,{type:C.rangeEnded,payload:s,visibility:!0}))}}deadEndCheck(){return!(this.#n?.getPreparedToExecActions()??[]).some(n=>n.actionType===I.setNextBranch)}allControlsAreRemoved(){return!this.#s.some(e=>!e.container.isRemoved)}isEndedExpectation(){if(!this.options?.player||!this.#s)return!1;let t=this.options.player.info.position$.getValue(),e=this.options.player.info.duration$.getValue();return t===e&&this.#s.some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&U(s.events)})}#C(){this.#d.unsubscribe(),this.#d.add(this.options.player.events.started$.pipe(ki()).subscribe(this.#w)).add(this.options.player.events.playing$.subscribe(this.#r.requestAnimation)).add(this.options.player.events.willPause$.subscribe(this.#r.cancelAnimation)).add(this.options.player.info.position$.subscribe(this.#_.bind(this))).add(this.#t.prevChapter$.subscribe(t=>this.state.prevChapter$.next(t))).add(Oi({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:t,interactiveRanges:e,isInteractiveExpectation:n})=>{let s;if(n)s=!0;else{let c=t*1e3;s=!!e?.find(({range:[y,g],subjects:E})=>y<c&&c<g&&E.length)}s!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(s);let r=this.#y!==null,a=this.options.player.info.playbackState$.getValue()==="playing"||n;s&&!r&&a?this.#y=setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout):r&&!a&&this.#I()})),this.options.lastFrame&&this.#d.add(this.options.player.info.duration$.subscribe(t=>{this.#c.setVideoDuration(t*1e3)})).add(this.options.player.experimental.element$.subscribe(t=>{t&&this.#c.setVideoElement(t)})).add(this.options.player.events.firstFrame$.subscribe(()=>{this.#c.reset(),setTimeout(()=>{this.#c.hide(),this.#c.lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(this.#c.onSeek))}#g=(t=!0)=>{this.#s.forEach(e=>{!t&&e.isPermanentText||(this.#r.removeFn(e.whilePlaying),e.destroy())})};#v(t){this.#t.chapter&&this.appState===P.initiated&&(this.#o.setManifestChapterEvents(t),this.#s=this.#V(t),this.#n.containersEventsCallState.setData(t.containers),this.#m.setContainers(this.#s.map(e=>e.container.container).filter(e=>!Lt(e.controls))),this.options.lastFrame&&this.#r.addFn(()=>{this.#c.onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=P.ready)}#V(t){return t?.containers?.reduce((e,n)=>{let s=n.type.trim().toLowerCase(),r=this.factories.get(s);if(r){let o=new Nt({player:this.options.player,container:r(n,this.rootElement),branches:this.#t.chapter.branches,selectBranches:this.#o,interactiveEvents:this.#n,globalEventEmitter:this.#e,ignoreContainerEvent:()=>Le(n,this.#s),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.#m.deleteContainer(n.id)}});return this.#r.addFn(o.whilePlaying,!0),[...e,o]}return[...e]},[])??[]}#E(){if(this.state.isInteractiveExpectation$.getValue()){this.#p.next(!1);return}let e=this.#p.getValue(),n=!!this.#m.getNextInteractiveTime();(n&&!e||!n&&e)&&this.#p.next(!e)}#M(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}#R(t){if(this.#M(),!this.#i.inited)return;let e=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),s=(n&&O(n)&&At(n))??!1,r=this.#t.manifest.metadata.initChapterId===t,o=this.#i.state.history$.getValue();if(r||s&&e){this.#i.updateHistory([t]);return}o.at(-1)!==t&&this.#i.updateHistory([...o,t])}#A=t=>{let{interactiveRanges$:e}=this.state,s=e.getValue().map(r=>({...r,subjects:r.subjects.filter(o=>o!==t)}));e.next(s)};#I=()=>{this.#y&&(clearTimeout(this.#y),this.#y=null)};playPrevChapter(){this.#i?.goBack()}setDisabledControls(t){this.state.disabledControls$.next(t)}isSupport(t=this.#t.manifest){return Tt(t.metadata.version)}getInitialVideoInfo(){return{videoId:this.#i.getInitialVideoId(),chapterId:this.#i.getInitialChapterId()}}getHistoryState(){return this.#i.state}getIsSeekable(){return this.#p}getInteractiveRanges(){return je(this.#t.chapter?.containers)}getNextInteractiveStartTime(t){return this.#m.getNextInteractiveTime(t)}getChapterBranches(t){return this.#t.getBranches(t)}getCurrentChapter(){return this.#t.getCurrent()}getCurrentManifest(){return this.#t.manifest}addFactory(t,e){this.factories.set(t.trim().toLowerCase(),e)}removeFactory(t){this.factories.delete(t.trim().toLowerCase())}on(...t){return this.#e.on(...t),this}off(...t){return this.#e.off(...t),this}once(...t){return this.#e.once(...t),this}destroy(){this.#g(),this.#s=void 0,this.state=void 0,this.#l?.destroy(),this.#l=void 0,this.#a.release(),this.#a=void 0,this.#o=void 0,this.#r.release(),this.#r=void 0,this.#n.release(),this.#n=void 0,this.#t.release(),this.#o=void 0,this.#h.release(),this.#h=void 0,this.#d.unsubscribe(),this.#d=void 0,this.#e.reset(),this.#e=void 0,this.#c?.destroy(),this.#c=void 0,this.rootElement.remove(),this.rootElement=void 0,this.#i.destroy(),this.#i=void 0,this.#f?.removeAll(),this.#f=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=P.destroyed}};var $i={Container:K,createChoiceContainer:bt,createAreaControl:yt,createButtonControl:vt,createRelativeLayout:ge,getRootEl:pt,classnamesPrefix:M};var ca={version:pe};export{R as CustomError,d as EVENT_NAMES,Ft as Interactives,Z as ManifestController,ca as SDKInfo,oe as chapterIdsToVKVideoIds,B as compareVersions,Ri as getChapterIdByVkVideoId,Qe as getVKVideoIdByMedia,Vi as getVideoRawIdByMedia,nt as graphEventTypes,At as hasEndTemplate,C as interactivesEventTypes,O as isLastChapter,Tt as isSupportedManifest,Mi as isVKVariantItem,$i as utils,Ke as vkVideoIdsToChapterIds};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-interactive",
|
|
3
|
-
"version": "1.0.16-dev.
|
|
3
|
+
"version": "1.0.16-dev.4f41c335.0",
|
|
4
4
|
"author": "vk.com",
|
|
5
5
|
"description": "Movika interactive SDK",
|
|
6
6
|
"homepage": "https://vk.com",
|
|
@@ -50,8 +50,9 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@interactiveplatform/movika-graph-editor": "^1.11.0",
|
|
53
|
-
"@vkontakte/videoplayer-core": "2.0.
|
|
54
|
-
"@vkontakte/videoplayer-shared": "1.0.
|
|
53
|
+
"@vkontakte/videoplayer-core": "^2.0.107",
|
|
54
|
+
"@vkontakte/videoplayer-shared": "^1.0.39",
|
|
55
|
+
"@vkontakte/videoplayer-statistics": "^1.0.53",
|
|
55
56
|
"uuid": "^9.0.0"
|
|
56
57
|
}
|
|
57
58
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { EVENT_NAMES, Interactives, utils, graphEventTypes, interactivesEventTyp
|
|
|
2
2
|
export type { InteractiveRange, VideoInfo } from './modules/Interactives';
|
|
3
3
|
export { ManifestController } from './modules/ManifestController';
|
|
4
4
|
export type { Container, Chapter, Manifest, ManifestVideo, ManifestVideoVariant, Media, Metadata } from './movika.core/manifest';
|
|
5
|
-
export { isSupportedManifest
|
|
5
|
+
export { isSupportedManifest } from './movika.core/manifest';
|
|
6
6
|
export { compareVersions } from './utils/compareVersions';
|
|
7
7
|
export { CustomError } from './utils/Error';
|
|
8
8
|
export * from './utils/chapterHelpers';
|
|
@@ -10,6 +10,7 @@ export class Interactives {
|
|
|
10
10
|
disabledControls$: ValueSubject<boolean>;
|
|
11
11
|
interactiveRanges$: ValueSubject<never[]>;
|
|
12
12
|
isInteractiveTime$: ValueSubject<boolean>;
|
|
13
|
+
statistics$: ValueSubject<null>;
|
|
13
14
|
};
|
|
14
15
|
events: {
|
|
15
16
|
noInteraction$: Subject<any>;
|
|
@@ -19,7 +20,6 @@ export class Interactives {
|
|
|
19
20
|
rootElement: HTMLDivElement;
|
|
20
21
|
isFirstChapterFetched: boolean;
|
|
21
22
|
appState: 0;
|
|
22
|
-
emitPlayerChanged: (data: any) => void;
|
|
23
23
|
/**
|
|
24
24
|
* Returns an object with observables used for sending statistics
|
|
25
25
|
* @returns {any}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { IValueSubject } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import type { ChapterBranch, ManifestVideo, LatestChapter, LatestManifest, LatestMedia } from '../../movika.core/manifest';
|
|
3
|
+
import type { GraphEditChapter, GraphViewChapter } from '../../movika.core/manifest/manifest_3_3/graph';
|
|
4
|
+
import { Loadable } from './Loadable';
|
|
5
|
+
type BranchesData = {
|
|
6
|
+
chapter: LatestChapter;
|
|
7
|
+
graph: GraphEditChapter | GraphViewChapter | undefined;
|
|
8
|
+
media: ManifestVideo;
|
|
9
|
+
};
|
|
10
|
+
export declare class ManifestController extends Loadable {
|
|
11
|
+
manifest: Nullable<LatestManifest>;
|
|
12
|
+
chapter: Nullable<LatestChapter>;
|
|
13
|
+
media: Nullable<LatestMedia>;
|
|
14
|
+
graph: Nullable<LatestManifest['graph']>;
|
|
15
|
+
prevChapter$: IValueSubject<LatestChapter | null>;
|
|
16
|
+
onError: Function;
|
|
17
|
+
constructor(loaders: any, onError: Function);
|
|
5
18
|
release(): this;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getInitial(): {
|
|
15
|
-
chapter: any;
|
|
16
|
-
media: any;
|
|
17
|
-
graph: any;
|
|
18
|
-
} | null;
|
|
19
|
-
getByChapterId(chapterId?: any): {
|
|
20
|
-
chapter: any;
|
|
21
|
-
media: any;
|
|
22
|
-
graph: any;
|
|
23
|
-
} | null;
|
|
24
|
-
getBranches(chapterId?: any): any;
|
|
25
|
-
getByBranches(branches?: any[]): any;
|
|
19
|
+
setManifest(source: LatestManifest): Promise<ManifestController>;
|
|
20
|
+
setInitial(): Promise<ManifestController>;
|
|
21
|
+
setNext(chapterId?: string | undefined): Promise<ManifestController>;
|
|
22
|
+
errorHandler(errors: unknown): void;
|
|
23
|
+
getInitial(): BranchesData | null;
|
|
24
|
+
getByChapterId(chapterId?: string | undefined): Nullable<BranchesData>;
|
|
25
|
+
getBranches(chapterId?: string | undefined): BranchesData[];
|
|
26
|
+
getByBranches(branches?: ChapterBranch[]): BranchesData[];
|
|
26
27
|
getCurrent(): {
|
|
27
|
-
chapter:
|
|
28
|
-
media:
|
|
29
|
-
graph:
|
|
28
|
+
chapter: Nullable<import("../../movika.core/manifest/types").Chapter>;
|
|
29
|
+
media: Nullable<import("../../movika.core/manifest/manifest_3_3/manifest").Media>;
|
|
30
|
+
graph: Nullable<import("../../movika.core/manifest/manifest_3_3/graph").GraphDesign>;
|
|
30
31
|
};
|
|
31
32
|
isInitialChapter(): boolean;
|
|
32
33
|
isEndChapter(): boolean;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
import { ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
35
|
+
export {};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
manifest: any;
|
|
14
|
-
manifestURL: string | undefined;
|
|
15
|
-
}>;
|
|
1
|
+
import type { Manifest, LatestManifest, Media, Chapter } from '../../movika.core/manifest';
|
|
2
|
+
type ManifestInfo = {
|
|
3
|
+
manifest: Manifest;
|
|
4
|
+
manifestURL: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const convertToObject: (manifest: Manifest | string) => Promise<Partial<ManifestInfo>>;
|
|
7
|
+
export declare function fetchManifest(manifest: Manifest): Promise<LatestManifest>;
|
|
8
|
+
export declare function getInitialChapter(manifest: any): Chapter | undefined;
|
|
9
|
+
export declare function getChapter(chapters: Chapter[], chapterId?: string): Chapter | undefined;
|
|
10
|
+
export declare function getGraphItem(graphObj: LatestManifest['graph'], chapterId: string): import("../../movika.core/manifest/manifest_3_3/graph").GraphEditChapter | import("../../movika.core/manifest/manifest_3_3/graph").GraphViewChapter | undefined;
|
|
11
|
+
export declare function getMedia(media: Media, videoId?: string): import("../../movika.core/manifest/manifest_3_2/manifest").ManifestVideo | undefined;
|
|
12
|
+
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import type { ISubscription } from '@vkontakte/videoplayer-shared';
|
|
1
2
|
import type { IPlayer } from '@vkontakte/videoplayer-core';
|
|
2
|
-
import {
|
|
3
|
+
import type { IOneStat } from '@vkontakte/videoplayer-statistics';
|
|
4
|
+
export interface InstanceStatistics {
|
|
5
|
+
oneStat: IOneStat;
|
|
6
|
+
statSubscription: ISubscription;
|
|
7
|
+
}
|
|
3
8
|
export interface Instance {
|
|
4
9
|
[key: string]: any;
|
|
5
10
|
container: HTMLElement;
|
|
6
11
|
player: IPlayer;
|
|
7
12
|
subscription: ISubscription;
|
|
13
|
+
statistics?: InstanceStatistics;
|
|
8
14
|
}
|
|
9
15
|
export default function InstanceManager(): Record<string, any>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { IConfig, PlaybackRate, VideoQuality } from '@vkontakte/videoplayer-core';
|
|
2
2
|
import { EventEmitter } from '../../utils/EventEmitter';
|
|
3
3
|
import type { ManifestVideo, Extensions } from '../../movika.core/manifest';
|
|
4
|
-
interface InitProps extends Omit<IConfig, 'sources' | 'container'> {
|
|
5
|
-
source?: string | Record<string, any>;
|
|
6
|
-
container: HTMLElement;
|
|
7
|
-
initialChapter?: string;
|
|
8
|
-
}
|
|
9
4
|
interface CreatePlayerParams extends Omit<IConfig, 'sources' | 'container'> {
|
|
10
5
|
media: ManifestVideo;
|
|
11
6
|
chapterId: string;
|
|
@@ -19,20 +14,17 @@ interface CreatePlayerParams extends Omit<IConfig, 'sources' | 'container'> {
|
|
|
19
14
|
}
|
|
20
15
|
export declare const SEAMLESS_CONTROLLER_EVENTS: {
|
|
21
16
|
activePlayerChanged: string;
|
|
22
|
-
initiated: string;
|
|
23
17
|
playerCreated: string;
|
|
24
18
|
};
|
|
25
19
|
export default function SeamlessController(interactiveController?: Record<string, any>): {
|
|
26
20
|
on: (eventName: string, fn: Function) => EventEmitter;
|
|
27
21
|
off: (eventName: string, fn: Function) => EventEmitter;
|
|
28
|
-
init: (
|
|
29
|
-
player: any;
|
|
30
|
-
config: any;
|
|
31
|
-
} | undefined>;
|
|
22
|
+
init: () => Promise<void>;
|
|
32
23
|
setInteractiveController: (instance: Record<string, any>) => void;
|
|
33
24
|
createPlayer: ({ media, chapterId, prefetch, setAsActive, autoplay, preferredExt, title, playbackRate }: CreatePlayerParams) => Promise<{
|
|
34
25
|
player: any;
|
|
35
26
|
config: any;
|
|
27
|
+
statistics: any;
|
|
36
28
|
}>;
|
|
37
29
|
removeAll: () => void;
|
|
38
30
|
getActivePlayer: () => Record<string, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Chapter as Chapter_3_2, ChapterContainer as ChapterContainer_3_2 } from './manifest_3_2/chapter';
|
|
1
|
+
import type { Chapter as Chapter_3_2, ChapterContainer as ChapterContainer_3_2, ChapterBranch as ChapterBranch_3_2 } from './manifest_3_2/chapter';
|
|
2
2
|
import type { Manifest_3_2, ManifestVideo as ManifestVideo_3_2, ManifestVideoVariant as ManifestVideoVariant_3_2, Media as Media_3_2, Metadata as Metadata_3_2 } from './manifest_3_2/manifest';
|
|
3
|
-
import type { Chapter as Chapter_3_3, ChapterContainer as ChapterContainer_3_3 } from './manifest_3_3/chapter';
|
|
3
|
+
import type { Chapter as Chapter_3_3, ChapterContainer as ChapterContainer_3_3, ChapterBranch as ChapterBranch_3_3 } from './manifest_3_3/chapter';
|
|
4
4
|
import type { Manifest_3_3, ManifestVideo as ManifestVideo_3_3, ManifestVideoVariant as ManifestVideoVariant_3_3, Media as Media_3_3, Metadata as Metadata_3_3, ManifestVideoVariantType, Extensions, Standard } from './manifest_3_3/manifest';
|
|
5
5
|
export type Container = ChapterContainer_3_2 | ChapterContainer_3_3;
|
|
6
6
|
export type Media = Media_3_2 | Media_3_3;
|
|
@@ -9,7 +9,11 @@ export type Manifest = Manifest_3_2 | Manifest_3_3;
|
|
|
9
9
|
export type Metadata = Metadata_3_2 | Metadata_3_3;
|
|
10
10
|
export type ManifestVideo = ManifestVideo_3_2 | ManifestVideo_3_3;
|
|
11
11
|
export type ManifestVideoVariant = ManifestVideoVariant_3_2 | ManifestVideoVariant_3_3;
|
|
12
|
+
export type ChapterBranch = ChapterBranch_3_2 | ChapterBranch_3_3;
|
|
12
13
|
export type { ManifestVideoVariantType, Extensions, Standard };
|
|
14
|
+
export type LatestMedia = Media_3_3;
|
|
15
|
+
export type LatestChapter = Chapter_3_3;
|
|
16
|
+
export type LatestManifest = Manifest_3_3;
|
|
13
17
|
export * from './migrations';
|
|
14
18
|
export * from './types';
|
|
15
19
|
export * from './utils';
|
|
@@ -24,13 +24,6 @@ export declare const eventActionTypes: Readonly<{
|
|
|
24
24
|
continuePlayback: "continuePlayback";
|
|
25
25
|
expect: "expect";
|
|
26
26
|
}>;
|
|
27
|
-
export declare enum INTERACTIVE_CLICK_ACTIONS {
|
|
28
|
-
GO_NEXT_BUTTON = "GO_NEXT_BUTTON",
|
|
29
|
-
GO_NEXT_AREA = "GO_NEXT_AREA",
|
|
30
|
-
WATCH_AGAIN = "WATCH_AGAIN",
|
|
31
|
-
OPEN_GRAPH = "OPEN_GRAPH",
|
|
32
|
-
CLOSE_GRAPH = "CLOSE_GRAPH"
|
|
33
|
-
}
|
|
34
27
|
export type VideoId = number | string;
|
|
35
28
|
export type ChapterContainers = Chapter['containers'];
|
|
36
29
|
export type { Chapter } from './manifest_3_3/chapter';
|