@vkontakte/videoplayer-interactive 1.0.6-beta.1 → 1.0.6-dev.35f8adc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/evergreen.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.6-beta.1
3
- * Wed, 13 Dec 2023 16:01:42 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.6-dev.35f8adc.0
3
+ * Tue, 09 Jan 2024 10:19:32 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-6/doc/
5
5
  */
6
- import{loadVKLangPack as it,Subscription as ce,ValueSubject as nt,Observable as ye,getCurrentBrowser as st,CurrentClientBrowser as rt,once as at}from"@vkontakte/videoplayer-shared/esnext.esm.js";import{v4 as he}from"uuid";import{Player as ot}from"@vkontakte/videoplayer-core/esnext.esm.js";const ct="1.0.6-beta.1";function ke(i,e=1){let t="0",n="0",r="0";return i.length===4?(t="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+t},${+n},${+r},${e})`}const L="SDK_NAME",ht="SDK_NAME-controls-container",Fe=()=>document.querySelector(`.${ht}`),M={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ge={top:"flex-start",bottom:"flex-end",center:"center"},ve={start:"flex-start",end:"flex-end",center:"center"},be={start:"left",end:"right",center:"center"},Pe=({target:i,props:e})=>{i.style.alignItems=ge[e?.text?.gravityVertical]??ge.center,i.style.justifyContent=ve[e?.text?.gravityHorizontal]??ve.center,i.style.textAlign=be[e?.text?.alignment]??be.start},Be=({target:i,props:e,fallback:t,dependsOn:n})=>{i.style.color=e?.text?.color??t.textColor,i.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,i.textContent=e?.text?.value??t.textContent},$e=({target:i,props:e,fallback:t})=>{i.style.backgroundColor=ke(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},De=({target:i,props:e,fallback:t,dependsOn:n})=>{i.style.border=`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth}) solid ${ke(e?.shape?.border?.color??t.borderColor,e?.shape?.border?.alpha??t.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`},le=({target:i,layoutParams:e,fallback:t})=>{i.style.transform=`rotate(${-e.angle}rad)`};class de{constructor(e){this.control=e}createView(e){const t=document.createElement("div");t.classList.add(`${L}-control-container-${this.control.id}`),e(t,this.control.layoutParams);const n=(this.control.layoutParams.innerSizesDependOn??M.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:t,dependsOn:n}}setEvents(e,t){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),t&&t({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${L}-control-container-${this.control.id}`)}}const He=i=>{if(i.type.trim().toLowerCase()==="area")return new lt(i)};class lt extends de{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:r}=super.createView(t),s=document.createElement("button");return s.classList.add(`${L}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",$e({target:s,props:this.control.props,fallback:{...M,backgroundColor:"transparent"}}),De({target:s,props:this.control.props,fallback:{...M,borderAlpha:0},dependsOn:n}),le({target:s,layoutParams:this.control.layoutParams,fallback:M}),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${L}-${this.control.id}`)}}const Ge=i=>{if(i.type.trim().toLowerCase()==="button")return new dt(i)};class dt extends de{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:r}=super.createView(t),s=document.createElement("button");s.type="button",s.classList.add(`${L}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";const o=document.createElement("span");return o.style.display="inline-block",o.style.whiteSpace="pre",o.style.overflow="hidden",o.style.textOverflow="ellipsis",le({target:s,layoutParams:this.control.layoutParams,fallback:M}),$e({target:s,props:this.control.props,fallback:M}),De({target:s,props:this.control.props,fallback:M,dependsOn:n}),Pe({target:s,props:this.control.props}),Be({target:o,props:this.control.props,fallback:M,dependsOn:n}),s.append(o),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${L}-${this.control.id}`)}}const ut=i=>{if(i.type.trim().toLowerCase()==="text")return new pt(i)};class pt extends de{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:r}=super.createView(t),s=document.createElement("div");s.classList.add(`${L}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";const o=document.createElement("span");return o.style.whiteSpace="pre",le({target:s,layoutParams:this.control.layoutParams,fallback:M}),Pe({target:s,props:this.control.props}),Be({target:o,props:this.control.props,fallback:M,dependsOn:n}),s.append(o),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${L}-${this.control.id}`)}}class ft{constructor(e){this.layout=e}}const mt=i=>{if(i.type.trim().toLowerCase()==="relative")return new Ue(i)};class Ue extends ft{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}class ze{constructor(e){this.container=e,this.factories=new Map,this.#a()}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.#a()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.#a()}#a(){this.controls=this.#s()}#s(){return this.container.controls?.reduce((e,t)=>{const n=t.type.trim().toLowerCase(),r=this.factories.get(n);return r?[...e,r(t)]:[...e]},[])}}const We=(i,e)=>{if(i.type.trim().toLowerCase()==="choice")return new yt(i,e)};class yt extends ze{constructor(e,t){super(e),this.rootElement=t??Fe(),this.layout=new Ue(this.container.layout),this.isRemoved=!1,this.addControlFactory("button",Ge),this.addControlFactory("text",ut),this.addControlFactory("area",He)}createView(e){const t=document.createElement("div");return t.classList.add(`${L}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(n=>{const r=n.createView({parent:t,layoutFn:this.layout.setControlLayout});n.setEvents(r,e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}removeView(){this.isRemoved||(this.getElement()?.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${L}-${this.container.id}`)}}function Qe(i,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>i(...n),e)}}const W={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},U=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,ue=i=>U(i,W.Object),re=i=>U(i,W.String),G=i=>U(i,W.Array),qe=i=>U(i,W.Number),gt=i=>U(i,W.Function),Ce=i=>qe(i)&&!isNaN(i),vt=i=>i==null,z=i=>ue(i)&&Object.keys(i).length===0,Xe=i=>G(i)&&!i.length,X=(i,e)=>re(i)&&(e?i.trim():i).length,Ze=window.navigator.userAgent.toLowerCase(),bt=/mobi/i.test(Ze);Ze.indexOf("android")>-1;const Ct="video_interactive",Et="videoint",wt=250;class St{constructor(e){this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=It(e),this.resizeObserver=new ResizeObserver(Qe(this.onResize,wt)),this.resizeObserver.observe(this.graphWrapperElement)}onResize=e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))};getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}handleChapterChange=e=>{if(this.isReady){if(this.isHidden||this.hide(),!e?.id){this.onError?.("Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor.selectChapter(e.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=void 0}};handleManifestChange=async(e,t=[])=>{if(!qe(e.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 it(this.lang,Ct,Et)}catch{console.log("Unable to load graph language pack")}const{GraphEditor:r}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new r(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:n}),this.ngEditor.on("control",({name:s,chapterId:o})=>{s==="openPreview"&&this.onOpenPreviewClick(o)}),this.ngEditor.on("zoomEnd",s=>{this.lastZoomInfo={...s}})}this.visitedChapterIds=new Set(t),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0};setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function It(i){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",i.append(e),e}const Tt=(i={})=>Array.from(new Set(i.sessions?.map(e=>e.visitedChapters.map(t=>t.chapterId)??[]).flat())),Ee=(i=[],e="")=>i.reduce((t,n)=>(t.find(r=>r[e]===n[e])||t.push(n),t),[]),we="chapterId";class ${constructor(e){this.id=e?.id??he(),this.startDate=e?.startDate?new Date(e.startDate).toISOString():new Date(Date.now()).toISOString(),this.updateOn=e?.updateOn?new Date(e.updateOn).toISOString():null,this.visitedChapters=e?.visitedChapters?Ee(Array.from(e.visitedChapters),we):[],this.branches=G(e?.branches)?e.branches:[]}update(e){e?.startDate&&(this.startDate=new Date(e.startDate).toISOString()),e?.updateOn&&(this.updateOn=new Date(e.updateOn).toISOString()),G(e?.visitedChapters)&&(this.visitedChapters=Ee([...this.visitedChapters,...e.visitedChapters],we)),G(e?.branches)&&(this.branches=this.branches.concat(e.branches))}getSession(){return{...this}}static createVisitedChapter(e){return[{chapterId:e}]}static createBranch(e,t,n){return[{chapterId:e,branchId:t,autoSelect:n}]}}class Z{constructor(e){this.id=e?.id??he(),this.manifestId=e?.manifestId,this.manifestVersion=e?.manifestVersion,this.manifestBuild=e?.manifestBuild,this.sessions=G(e?.sessions)?e?.sessions.map(t=>new $(t)):[],this.isCompleted=e?.isCompleted??!1}update(e){this.id=e?.id??this.id,this.manifestId=e?.manifestId??this.manifestId,this.manifestVersion=e?.manifestVersion??this.manifestVersion,this.manifestBuild=e?.manifestBuild??this.manifestBuild,this.isCompleted=e?.isCompleted??this.isCompleted}addSession(e){this.sessions.push(new $(e))}updateSession(e,t){let n;vt(e)?n=this.sessions[this.sessions.length-1]:n=this.sessions.find(r=>r.id===e),n&&n.update(t)}resetSession(){this.sessions=[]}getHistory(){return{...this,sessions:this.sessions.map(e=>e.getSession())}}}const ae="SDK_NAME-history-changed";class xt extends EventTarget{constructor(){super(),this.history=new Z,this.sendEvent()}onChapterChange({chapterId:e,mediaId:t,autoSelect:n=!1,isLastChapter:r=!1}){this.history.isCompleted?this.history=new Z({manifestId:this.history.manifestId,manifestVersion:this.history.manifestVersion,manifestBuild:this.history.manifestBuild}):r&&this.history.update({isCompleted:!0}),this.history.sessions.length?this.history.updateSession(null,{updateOn:Date.now(),visitedChapters:$.createVisitedChapter(e),branches:$.createBranch(e,t,n)}):this.history.addSession({updateOn:Date.now(),visitedChapters:$.createVisitedChapter(e),branches:$.createBranch(e,t,!1)}),this.sendEvent()}onManifestChange(e,t){t?this.history=new Z(t):this.history=new Z({manifestId:e.id,manifestVersion:e.version,manifestBuild:e.build}),this.history.addSession({updateOn:Date.now()}),this.sendEvent()}getHistory(){if(history)return this.history.getHistory()}sendEvent(){this.dispatchEvent(new CustomEvent(ae,{bubbles:!1,detail:this.getHistory()}))}destroy(){this.history=void 0}}function Rt(i,e){if(!e||!i||!e.sessions.length)return;const t=e.sessions.reverse().find(n=>n.branches.length);return t.branches[t.branches.length-1].chapterId??void 0}const ee=(i="",e="")=>{i=i.split("."),e=e.split(".");let t=0;for(let n=0;n<Math.max(i.length,e.length)&&!t;n++)i[n]>e[n]?t=1:i[n]<e[n]?t=-1:t=0;return t},At="3.1",Se={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},jt={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Nt=i=>{const e=[];for(const t of i.chapters){let n;const r=[];for(const{isDefault:a,...c}of t.branches)a&&(n=c.id),r.push(c);let s=[];const o=[];for(const{fallbackStrategy:a,...c}of t.containers){const l=!!c.endTime;let g=[jt];switch(a){case"await":l?g=[]:s=[];break;case"default":{const f={type:"onSuspense",action:{type:Se.default,args:{branchId:n,shouldOpenNow:!l,isDetachContainer:!0}}};l?g=[f]:s=[f];break}case"random":case"weightlessRandom":case"max":case"min":{const f={type:"onSuspense",action:{type:Se[a],args:{}}};l?g=[f]:s=[f];break}}for(const f of c.controls)o.push({...c,controls:[{...f}],id:he(),events:g})}e.push({...t,containers:o,events:s,branches:r})}return i.metadata.version=At,i.metadata.updated=new Date().toISOString(),{...i,chapters:e}},Ot="3.2",Lt=i=>{if(!i.media){const{media:e,...t}=i.metadata;return{...i,metadata:{...t,version:Ot},media:e}}return i},Mt="3.3",Vt=(i=[])=>({edit:{chapters:i},view:{}}),Ie={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},_t=i=>{const e=[],t=[];for(const n of i.chapters){const{id:r,x:s,y:o,...a}=n,c=a.containers.map(l=>({...l,controls:l.controls.map(({subtype:g,type:f,...w})=>({...w,type:g??f})),events:l.events?.length?l.events:[Ie]}));e.push({id:r,...a,containers:c,events:a.events?.length?a.events:[Ie]}),t.push({id:r,x:s,y:o})}return{...i,chapters:e,graph:Vt(t),metadata:{...i.metadata,version:Mt}}},kt=[{version:"3.0",migrate:Nt},{version:"3.1",migrate:Lt},{version:"3.2",migrate:_t}],Ft=i=>kt.reduce((e,t)=>ee(e.metadata.version,t.version)?e:t.migrate(e),i),Pt=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),S=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});var P;(function(i){i.GO_NEXT_BUTTON="GO_NEXT_BUTTON",i.GO_NEXT_AREA="GO_NEXT_AREA",i.WATCH_AGAIN="WATCH_AGAIN",i.OPEN_GRAPH="OPEN_GRAPH",i.CLOSE_GRAPH="CLOSE_GRAPH"})(P||(P={}));const Te={metadata:"Object",chapters:"Array"},Bt="3.0.0",$t="3.3.0",Ke=i=>{const e=ee(i,Bt);return e===-1?!1:e===0?!0:ee(i,$t)!==1},Dt=i=>{if(!ue(i))return!1;for(const e in Te)if(!i[e]||!U(i[e],Te[e]))return!1;return Ke(i.metadata.version)},Ye=i=>i.type===Pt.Text;class R{constructor(e,t,...n){this.severity=e,this.category=t,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}static Severity={RECOVERABLE:1,CRITICAL:2};static Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6}}class Je{listeners={};addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];const n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){const n=this.listeners[e];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===t){n.splice(r,1);break}return this}emit(e,...t){const n=this.listeners[e];return n?(n.forEach(r=>{r(...t)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Ht{constructor(e){this.raf,this.fn,this.fns=[],this.addFn(e)}addFn=(e,t=!1)=>{gt(e)&&(this.fns.push(e),t&&this.updateFn())};removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};requestAnimation=()=>{this.raf||this.forceRequestAnimation()};cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0};release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Gt{loaders;constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Ut(...this.loaders[e])(t)}}function Ut(...i){return async function(t){const n=[...i];for(;n.length>0;)t=await n.shift()(t);return t}}function te(i,e,t){return i?{...i,[e]:i[e]?[t,...i[e]]:[t]}:{[e]:[t]}}function oe({actions:i,errors:e,chapterId:t,...n}){if(t){const r=i.getManifest(),s=i.getChapter(r.chapters,t);if(s){const o=i.getMedia(r.media,s.videoId),a=i.getGraph(r.graph,s.id);return o?{...n,actions:i,errors:e,result:{chapter:s,media:o,graph:a}}:{...n,errors:te(e,oe.name,"Could not find media"),actions:i}}}return{...n,errors:te(e,oe.name,"Could not find chapter"),actions:i}}const zt=async i=>{try{let e,t;if(ue(i))e=i;else if(re(i)){t=new URL(i).href;const r=await fetch(t);if(!r.ok)return{};e=await r.json()}else return{};if(!Dt(e))return{};const n=e.metadata.media;if(re(n)&&!e.media)try{let r;t?r=new URL(n,t).href:(r=new URL(n).href,t=r);const s=await fetch(r);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch{return Xt(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Wt(i){const{manifest:e,manifestURL:t}=await zt(i),n=Ft(e);return n.media=Qt(n.media,t),delete n.metadata.media,n}function ne(i,e){return i.find(t=>t.id===e)}function xe(i,e){return i.edit?.chapters?i.edit.chapters.find(t=>t.id===e):i.view?.chapters?i.view.chapters.find(t=>t.id===e):void 0}function Re(i,e){return i.videos.find(t=>t.id===e)}function Qt(i,e){return{...i,videos:i.videos.map(t=>({...t,variants:t.variants.map(n=>{const r=qt(n.url,e);return{...n,url:r||n.url}})}))}}function qt(i,e){try{return new URL(i,e).href}catch{return""}}function Xt(i){return ee(i,"3.2.0")>=0}class Zt extends Gt{constructor(e,t){super(e),this.onError=t,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this}async setManifest(e){this.release();const t=await this.exec("manifestLoaders",{actions:{addErrorMessage:te},result:null,errors:null,source:e});t.errors&&this.errorHandler(t.errors);const n=await Wt(t.result??e);return this.manifest=n,this}async setInitial(){return this.setNext()}async setNext(e=this.manifest.metadata.initChapterId){const t=await this.exec("chapterLoaders",oe({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:xe,getChapter:ne,getMedia:Re,getByBranches:this.getByBranches.bind(this),addErrorMessage:te},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){const t=ne(this.manifest.chapters,e);if(t){const n=Re(this.manifest.media,t.videoId),r=xe(this.manifest.graph,t.id);if(n)return{chapter:t,media:n,graph:r}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const t=ne(this.manifest.chapters,e);return this.getByBranches(t?.branches)}}getByBranches(e=[]){return e.reduce((t,n)=>{const r=this.getByChapterId(n.chapterId);return r&&t.push(r),t},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}}const m={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},Ae={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},x={actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Kt(){const i=new Map;function e({listId:r=Math.random().toString(),itemId:s=Math.random().toString(),...o}){const a=i.get(r),c={...o};return a?a[s]=c:i.set(r,{[s]:c}),{listId:r,itemId:s,...o}}function t(r,s){const o=i.get(r);if(o){if(s)return o[s]?.player.destroy(),o[s]?.container.remove(),o[s]?.subscription.unsubscribe(),delete o[s],Object.keys(o).length||i.delete(r),!0;for(const a of Object.values(o))a.player.destroy(),a.container.remove();return i.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(const r of i)t(r[0])}return{createPlayer:e,removePlayer:t,map:i,removeAll:n}}function je(i,e=[]){let t={},n;const r=!e.length;for(const s of i.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(r||e.includes("mp4"))&&(t.MPEG={...t.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"mpeg":(r||e.includes("mpeg"))&&(t.MPEG={...t.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"hls":(r||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(r||e.includes("dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break}return{sources:t,thumbUrl:n,title:i.title??""}}const K=(i,e)=>{const t=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();t!==e&&n.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))},Yt=i=>{const e=i.variants.find(t=>t.payload?.type==="vk");if(e&&"payload"in e){const[t,n]=e.payload.id.split("_");return[t,n]}return[]},J={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},Jt=2;function ei(i){const e=Kt();let t,n;const r=new Je;let s={},o=!1,a=null,c=!1,l;i&&g(i);function g(d){a=d}function f(d,y,p){if(!a)throw Error("need to set interactive controller");const b=(e.map.get(d)??{})[y];if(b){s={chapterId:p,listId:d,itemId:y,...b};const v=s.player;n=v.info.currentQuality$.subscribe(E=>{if(!(!E||!v.info.position$.getValue())){t=E;for(const N of e.map)Object.values(N[1]).forEach(({player:O})=>{v.info.isAutoQualityEnabled$.getValue()||K(O,E)})}}),b.container.remove(),o=!1,a.setPlayer(b.player),c||(a.init(),c=!0),r.emit(J.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}async function w(d,y,p){if(!a)throw Error("need to set interactive controller");if(z(s)||d!==s.itemId)return;if(p>=0&&!o){const b=a.getChapterBranches();o=!0;const v=new Set;for(const E of b)v.has(E.media.id)||(await A({media:E.media,chapterId:E.chapter.id,setAsActive:!1,title:E.chapter.label}),v.add(E.media.id))}}async function C({chapter:{id:d},media:y}){if(z(s))return;n?.unsubscribe();const p=s.player.info.muted$.getValue(),I=s.player.info.currentQuality$.getValue(),b=s.player.info.isAutoQualityEnabled$.getValue(),v=s.player.info.volume$.getValue(),E=s.player.info.currentPlaybackRate$.getValue(),N=!b;let O=!1;for(const j of e.map)if(j[0]===y.id){const Q=Object.keys(j[1]);for(const k of Q)k===s.itemId?(Q.length<Jt||(O=!0),e.removePlayer(j[0],k)):(O=!0,f(j[0],k,d),N?K(s.player,I):s.player.setAutoQuality(!0),s.player.setVolume(v),s.player.setMuted(p),s.player.setPlaybackRate(E))}else e.removePlayer(j[0]);O||(await A({media:y,chapterId:d,setAsActive:!0,playbackRate:E}),N?K(s.player,I):s.player.setAutoQuality(!0),s.player.setVolume(v),s.player.setMuted(p))}async function A({media:d,chapterId:y,prefetch:p=!0,setAsActive:I=!0,autoplay:b=!1,preferredExt:v,title:E,playbackRate:N}){const O=Math.random().toString(),j=document.createElement("div");l.append(j);const Q=s?.player?.info.isAutoQualityEnabled$.getValue();let k;if(a?.options?.vkVideoLoader){const q=Yt(d);q.length&&(k=await a.options.vkVideoLoader(...q))}const fe={container:j,...k?.videos?.[0]||{sources:je(d,v).sources},title:E},F=new ot;F.initVideo(fe);const tt=j.lastChild,me=new ce;me.add(F.info.position$.subscribe(function(q){w(O,F.info.duration$.getValue(),q)})).add(F.events.canplay$.subscribe(function(){Q||K(F,t),N&&F.setPlaybackRate(N)})),tt&&(j.style.display="none",j.classList.add(y));const B=e.createPlayer({listId:d.id,itemId:O,player:F,container:j,sources:je(d,v).sources,config:fe,subscription:me});return I&&f(d.id,B.itemId,y),b&&B.player.play(),p&&!b&&B.player.prepare(),r.emit(J.playerCreated,B.player),{player:B.player,config:B.config}}function _(){h(),a=null}function h(){a?.off(m.chapterChanged,C),e.removeAll(),s={},c=!1,o=!1}async function u({source:d,initialChapter:y,container:p}){if(!a)throw Error("need to set interactive controller");await a.setManifest(d),h(),l=p;const{media:I,chapter:b}=await a.setChapter({chapterId:y});if(I){a.on(m.chapterChanged,C);const{player:v,config:E}=await A({media:I,chapterId:b.id,title:b.label});return r.emit(J.initiated,{container:p,media:I,chapterId:b.id}),{player:v,config:E}}else console.error("not found")}return{...e,on:r.on.bind(r),off:r.off.bind(r),init:u,setInteractiveController:g,createPlayer:A,removeAll:_,getActivePlayer:function(){return s}}}const ti=3e3,ii=()=>{let i=[],e=null;return{setPlayer:o=>{e=o},setContainers:o=>{i=o},deleteContainer:o=>{i=i.filter(a=>a.id!==o)},getNextInteractiveTime:(o=ti)=>{if(!i.length||e===null)return null;let a=-1,c=!1;const l=e.info.position$.getValue()*1e3;for(const g of i){const f=g.startTime-o;if(f<=l&&(l<=g.endTime||g.endTime===null)){c=!0;break}l<f&&(a=a===-1?f:Math.min(a,f))}return!c&&a!==-1?a:null}}},D=ii(),T=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),pe=i=>G(i)&&!Xe(i),et=i=>Xe(i.branches)||i.order==="end",ni=(i,e)=>{const t=i*1e3;return pe(e.controls)&&t<(e.startTime??0)},Ne=(i,e)=>{const t=i*1e3;return pe(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)},ie=i=>i.some(e=>e.action.type==="expect"),Oe=i=>i.find(e=>e.action.type==="expect"),si=i=>i?.length===1,ri=i=>si(i)&&Ye(i[0]),ai=({fn:i,type:e=1},...t)=>(...n)=>e?i(...n,...t):i({...n[e],...t[e]}),oi=(i=[])=>i.reduce((e,t,n)=>{const r=(t?.controls??[]).filter(s=>!Ye(s));if(pe(r)){const s=[t.startTime??0,t.endTime??1/0],o=t.id;if(!n)e.push({subjects:[o],range:s});else{const a=[];let c=-1/0,l=1/0,g=[];const f=[];for(let w=0;w<e.length;w++){const C=e[w];if(f.push(...C.subjects),C.range[0]<l&&(l=C.range[0]),C.range[1]>c&&(c=C.range[1]),C.range[0]<=s[0]&&C.range[1]>=s[1])return e[w].subjects.push(o),e;s[0]>=C.range[0]&&s[0]<=C.range[1]&&(a.push(w),g=g.concat(C.subjects),s[0]=C.range[0]),s[1]>=C.range[0]&&s[1]<=C.range[1]&&(a.push(w),g=g.concat(C.subjects),s[1]=C.range[1])}if(f.push(o),s[0]<=l&&s[1]>=c)return[{subjects:f,range:s}];a.length&&a.reverse().forEach(w=>{e.splice(w,1)}),e.push({subjects:g.concat([o]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]),ci=(i,e)=>ie(i.events)?!1:e.some(({container:t})=>t.container.id!==i.id&&ie(t.container.events)&&t.container.endTime===i.endTime&&!t.isRemoved);class hi{constructor({player:e,container:t,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:o,ignoreContainerEvent:a,permanentTextControls:c}){this.container=t,this.branches=n,this.selectBranches=r,this.subscription=new ce,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&ri(t.container.controls),this.globalEventEmitter=o,this.gameState=T.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))}hide=()=>{setTimeout(()=>{this.gameState!==T.end&&(ie(this.container.container.events)&&this.gameState===T.afterInteractive||this.selectBranches.state.isExpect||(this.container.hide?.(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})))})};show=()=>{if(this.gameState===T.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())this.container.show?.(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!0,isFirst:!1});else{const t=ai({fn:this.selectBranches.onControlEvent,type:0},{branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})},onEvent:(n,r)=>{this.isSelectedControlEvent=!0,n!==!1&&(this.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})),(this.gameState===T.end||this.gameState===T.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),r(),this.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})),D.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===T.end});this.container.createView(t),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!0,isFirst:!0})}};selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=ie(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})}onEndOfVideo=()=>{this.gameState=T.end,this.selectContainerEvent(!0)};whilePlaying=()=>{if(this.player.experimental.element$.getValue()?.readyState<1||[T.destroyed,T.removed].includes(this.gameState)&&!this.isPermanentText)return;const t=this.player.getExactTime();if(ni(t,this.container.container))this.gameState!==T.beforeInteractive&&(this.gameState=T.beforeInteractive,this.onBeforeStartTime());else if(Ne(t,this.container.container))this.gameState!==T.interactive&&(this.gameState=T.interactive,this.onStartTime());else if(this.gameState!==T.afterInteractive){const s=this.gameState;this.gameState=T.afterInteractive,s===T.interactive&&this.onEndTime()}else this.gameState!==T.destroyed&&this.removeView();const n=Ne(t,this.container.container),r=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[];this.container.onProgress?.(t,n),this.globalEventEmitter.emit(m.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:r,currentTime:t,isInteractiveTime:n})};reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=T.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.containerRemoved,visibility:!1}),this.gameState=T.removed}destroy(){this.reset(),this.removeView(),this.gameState=T.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id}),D.deleteContainer(this.container.container.id)}}function li(){const i={};function e(){for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&delete i[a];return!0}function t(a){const c={};for(const l in i)+l<=a&&(c[l]=i[l]);return c}function n(a){const c={};for(const l in i)+l>=a&&(c[l]=i[l]);return c}function r({timestamp:a,priority:c,initiator:l}){if(Ce(a)){const g=i[a]??null;if(g&&X(c,!0)){let f={};const w=g[c];return w&&(f={...f,...w}),f=z(f)?null:f,f&&X(l,!0)?f[l]??null:f}return g}return null}function s({timestamp:a,priority:c,initiator:l}){if(Ce(a))if(i[a]){if(X(c,!0))if(i[a][c]){if(X(l,!0))if(i[a][c][l]){if(delete i[a][c][l],!z(i[a][c]))return!0}else return!1;if(delete i[a][c],!z(i[a]))return!0}else return!1;return delete i[a]}else return!1}function o({timestamp:a,priority:c,initiator:l,...g}){i[a]?.[c]?.[l]?i[a][c][l].push({...g}):i[a]?.[c]?i[a][c]={...i[a][c],[l]:[{...g}]}:i[a]?i[a]={...i[a],[c]:{[l]:[{...g}]}}:i[a]={[c]:{[l]:[{...g}]}}}return{map:i,remove:s,add:o,removeAll:e,get:r,getLte:t,getGte:n}}const di=[S.expect,S.setNextBranch],ui=1/0;function Le(i){let e=i,t;const n=pi(),r=new li;let s;const o=()=>{f(),_()},a=h=>{r.add.call(void 0,h),w()},c=(h=[])=>{for(const u of h)if(u.action(),di.includes(u.actionType))break},l=h=>{if(!n.isReady(h))return;const u=Y(r.get({timestamp:h,priority:"control"})??{}),d=Y(r.get({timestamp:h,priority:"container"})??{}),y=Y(r.get({timestamp:h,priority:"chapter"})??{});c([...u,...d,...y])},g=()=>{c([...Y(r.get({timestamp:1/0,priority:"chapter"})??{})])},f=()=>{t&&(s?.unsubscribe(),t=void 0)},w=()=>{t||(t=()=>setTimeout(()=>{l(1/0)}),s=e.events.ended$.subscribe(t))},C=h=>{f(),e=h},A=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),r.remove(h)},_=()=>{n.release(),r.removeAll()};return{setPlayer:C,add:a,remove:A,exec:l,execEndOfVideo:g,listen:w,unlisten:f,release:o,containersEventsCallState:n}}function pi(){const i=new Map;return{setCalled:({timestamp:o,id:a})=>{const c=i.get(o);c&&c[a]!==void 0&&(c[a]=!0)},setData:(o=[])=>{for(const a of o){const c=a.endTime??ui,l=i.get(c)??{};i.set(c,{...l,[a.id]:!1})}},resetCalled:o=>{const a=i.get(o);if(a)for(const c in a)a[c]=!1},isReady:o=>{const a=i.get(o);return a?!Object.values(a).some(c=>!c):!0},release:()=>i.clear()}}function Y(i){return Object.values(i).flat().sort(e=>e.actionType===S.expect?-1:1)}const fi=(i,e)=>{const{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:r,clientWidth:s}=e.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};const o=t/n,a=r/s;let c,l;return a>o?(l=s,c=s*o):a<o?(l=r/o,c=r):(l=s,c=r),{videoContentWidth:l,videoContentHeight:c}},mi=250;function yi(i){let e=()=>{};const t=new ResizeObserver(a=>{s(a),e=s.bind(null,a)});function n(a){const{parentElement:c,player:l}=i();if(c&&l){const{videoContentWidth:g,videoContentHeight:f}=fi(c,l);c.style.setProperty("--interactive-content-width",`${g}px`),c.style.setProperty("--interactive-content-height",`${f}px`),c.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function r(){const{parentElement:a}=i();a.removeAttribute("style")}const s=Qe(a=>{const{fns:c=[]}=i();n(a);for(const l of c)l()},mi);function o(){e=void 0,t.disconnect(),r()}return{resizeObserver:t,calc:()=>{e()},release:o}}class gi{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){const t=this.map[e];return t?t.slice():null}getAll(){const e=[];for(const t in this.map)e.push(...this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const vi=i=>Math.floor(Math.random()*i),bi=i=>{let e=i.length,t=1/0,n=null;for(;e--;)i[e].weight<t&&(t=i[e].weight,n=i[e]);return n},Ci=i=>{let e=i.length,t=-1/0,n=null;for(;e--;)i[e].weight>t&&(t=i[e].weight,n=i[e]);return n},Ei=i=>{const e=i.length,t=vi(e);return i[t]},Me=1,wi=i=>{let e=0;for(let n=0;n<i.length;++n)e+=i[n].weight??Me;const t=Math.random()*e;e=0;for(let n=0;n<i.length-1;++n)if(e+=i[n].weight??Me,e>=t)return i[n];return i[i.length-1]},Ve=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),se=(i,e=!1)=>({...i,args:e?{...i.args,...Ve}:{...Ve,...i.args}}),_e=({globalEventEmitter:i,player:e,interactiveEvents:t,removeControllers:n})=>{const r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},o=({action:h,controlType:u,controlId:d,containerId:y,branches:p=[],onEvent:I,isEOV:b=()=>!1})=>{const v=se(h,b()),E={timestamp:1/0,priority:"control",initiator:d,actionType:v.type},N=i.emit.bind(i,m.interactives,{subjectId:d,subjectType:u,subjectName:"control",type:x.actionChoice,actionType:h.type,payload:{containerId:y,...v.args}});switch(v.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{const O=p.find(j=>j.id===v.args.branchId);if(!O)return;I(v.args.isDetachContainer,w.bind(null,{subjectId:d,subjectName:"control"})),N(),v.args.shouldOpenNow?A({subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{chapterId:O.chapterId,autoSelect:!1}}):(t.add({...E,action:A.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{chapterId:O.chapterId,autoSelect:!1}})}),n?.());return}case S.continuePlayback.trim().toLowerCase():{I(v.args.isDetachContainer,w.bind(null,{subjectId:d,subjectName:"control"})),N(),v.args.shouldOpenNow?C({subjectId:d,subjectName:"control",subjectType:u,action:h}):t.add({...E,action:C.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:h})});return}case S.openURI.trim().toLowerCase():{I(v.args.isDetachContainer,w.bind(null,{subjectId:d,subjectName:"control"})),N(),v.args.shouldOpenNow?_({subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{URI:h.args.uri}}):(t.add({...E,action:_.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{URI:h.args.uri}})}),n?.());return}default:console.error("Unexpected control event"),i.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},a=({action:h,container:{id:u,endTime:d},branches:y=[],isEOV:p=!1,autoSelected:I=!1})=>{const b=se(h,p),v={timestamp:!b.args.shouldOpenNow||p?1/0:d,priority:"container",initiator:u,actionType:b.type},E=i.emit.bind(i,m.interactives,{subjectId:u,subjectName:"container",type:x.actionChoice,actionType:b.type,payload:b.args});switch(b.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{const N=y.find(O=>O.id===b.args.branchId);if(!N)return;E(),t.add({...v,action:A.bind(null,{subjectId:u,subjectName:"container",action:b,payload:{chapterId:N.chapterId,autoSelect:I}})}),n?.();return}case S.setMaxWeightBranch.trim().toLowerCase():return;case S.setMinWeightBranch.trim().toLowerCase():return;case S.setRandomBranch.trim().toLowerCase():return;case S.setWeightlessRandomBranch.trim().toLowerCase():return;case S.continuePlayback.trim().toLowerCase():{E(),t.add({...v,action:C.bind(null,{subjectId:u,subjectName:"container",action:b})});return}case S.openURI.trim().toLowerCase():{E(),t.add({...v,action:_.bind(null,{subjectId:u,subjectName:"container",action:b,payload:{URI:h.args.uri}})}),n?.();return}default:console.error("Unexpected container event"),i.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:h,branches:u,isEOV:d=!1}){const y=Oe(h.events);if(y){const p=se(y.action,d);i.emit(m.interactives,{subjectId:h.id,subjectName:"container",type:x.actionChoice,actionType:p.type,payload:p.args}),t.add({timestamp:d?1/0:h.endTime,priority:"container",initiator:h.id,actionType:S.expect,action:f.bind(null,{subjectId:h.id,subjectName:"container"})}),r.isExpect=!0}else for(const p of h.events)a({action:p.action,container:h,branches:u,isEOV:d})}const l=({chapterId:h,action:u,branches:d=[]})=>{const y=i.emit.bind(i,m.interactives,{subjectId:h,subjectName:"chapter",type:x.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{const p=d.find(I=>I.id===u.args.branchId);return p?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:p.chapterId,autoSelect:!0}})):void 0}case S.setWeightlessRandomBranch.trim().toLowerCase():{const p=Ei(d);return p?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:p.chapterId,autoSelect:!0}})):void 0}case S.setRandomBranch.trim().toLowerCase():{const p=wi(d);return p?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:p.chapterId,autoSelect:!0}})):void 0}case S.setMaxWeightBranch.trim().toLowerCase():{const p=Ci(d);return p?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:p.chapterId,autoSelect:!0}})):void 0}case S.setMinWeightBranch.trim().toLowerCase():{const p=bi(d);return p?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:p.chapterId,autoSelect:!0}})):void 0}case S.continuePlayback.trim().toLowerCase():return y(),C.bind(null,{subjectId:h,subjectName:"chapter",action:u});case S.openURI.trim().toLowerCase():return y(),_.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),i.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function g(h){const u=Oe(h.events);if(u){if(et(h))return;i.emit(m.interactives,{subjectId:h.id,subjectName:"chapter",type:x.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:S.expect,action:f.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events.forEach(d=>{const y=l({chapterId:h.id,action:d.action,branches:h.branches});y&&t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:d.action.type,action:y})})}const f=({subjectId:h,subjectName:u,action:d})=>{e.pause(),i.emit(m.interactives,{subjectId:h,subjectName:u,type:x.actionExecution,actionType:d?.type??S.expect})},w=({subjectId:h,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),i.emit(m.interactives,{subjectId:h,subjectName:u,type:x.actionExecution,actionType:"after-expect"})},C=({subjectId:h,subjectName:u,subjectType:d,action:y})=>{i.emit(m.interactives,{subjectId:h,subjectName:u,subjectType:d,type:x.actionExecution,actionType:y.type})},A=({subjectId:h,subjectName:u,subjectType:d,action:y,payload:p})=>{p.behaviour="change-chapter",i.emit(m.interactives,{subjectId:h,subjectName:u,subjectType:d,type:x.actionExecution,actionType:y.type,payload:p})},_=({subjectId:h,subjectName:u,subjectType:d,action:y,payload:p})=>{if(!p.URI)return;const I=window.open(p.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),i.emit(m.interactives,{subjectId:h,subjectName:u,subjectType:d,type:x.actionExecution,actionType:y.type})};return{onControlEvent:o,onContainerEvent:a,onChapterEvent:l,onExpectEvent:f,expectEventHandler:w,setManifestChapterEvents:g,setManifestContainerEvents:c,stopExpect:s,state:r}};class H{constructor(e,t,n,r){this.target=e,this.type=t,this.listener=n,this.options=H.#a(e,r),this.target.addEventListener(t,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}static#a(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{const n=new Set(["passive","capture"]),r=Object.keys(t).filter(o=>!n.has(o));return r.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+r.join(",")),H.#h(e)?t:t.capture||!1}}static#s=void 0;static#h(e){let t=H.#s;if(t===void 0){t=!1;try{const n={},r={get:()=>(t=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);const s=()=>{};e.addEventListener("test",s,n),e.removeEventListener("test",s,n)}catch{t=!1}H.#s=t}return t||!1}}class Si{constructor(){this.bindingMap=new gi}release(){this.removeAll(),this.bindingMap=null}listen(e,t,n,r){if(!this.bindingMap)return;const s=new H(e,t,n,r);this.bindingMap.push(t,s)}listenOnce(e,t,n,r){const s=o=>{this.unlisten(e,t,s),n(o)};this.listen(e,t,s,r)}unlisten(e,t,n){if(!this.bindingMap)return;const r=this.bindingMap.get(t)||[];for(const s of r)s.target===e&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(t,s))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const t of e)t.unlisten();this.bindingMap.clear()}}class Ii{rootElement;canvasImgSrc;_prevSizeId=0;constructor(){this.rootElement=document.createElement("canvas")}clear(){this.rootElement.getContext("2d")?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){const e=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;const t=e.data,n=t.length;for(let r=3;r<n;r+=40)if(t[r]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){const n=e.width+e.height;if(this._prevSizeId===n)return;let r;t&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&r&&this.restore(r),this._prevSizeId=n}async save(){const e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}}class Ti{lastFrameCanvas;endOffsetMs;currentChapter;currentVideoDurationMs=1/0;rootElement;_containerTimeFrameShouldReceived=!1;_endTimeFrameReceived=!1;_shouldCallSkip=!1;_callbacks;constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
6
+ import{loadVKLangPack as tt,Subscription as ce,ValueSubject as it,Observable as ye,getCurrentBrowser as nt,CurrentClientBrowser as st,once as rt}from"@vkontakte/videoplayer-shared/esnext.esm.js";import{v4 as he}from"uuid";import{Player as at}from"@vkontakte/videoplayer-core/esnext.esm.js";const ot="1.0.6-dev.35f8adc.0";function ke(i,e=1){let t="0",n="0",r="0";return i.length===4?(t="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+t},${+n},${+r},${e})`}const L="SDK_NAME",ct="SDK_NAME-controls-container",Fe=()=>document.querySelector(`.${ct}`),V={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ge={top:"flex-start",bottom:"flex-end",center:"center"},ve={start:"flex-start",end:"flex-end",center:"center"},be={start:"left",end:"right",center:"center"},Be=({target:i,props:e})=>{i.style.alignItems=ge[e?.text?.gravityVertical]??ge.center,i.style.justifyContent=ve[e?.text?.gravityHorizontal]??ve.center,i.style.textAlign=be[e?.text?.alignment]??be.start},Pe=({target:i,props:e,fallback:t,dependsOn:n})=>{i.style.color=e?.text?.color??t.textColor,i.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,i.textContent=e?.text?.value??t.textContent},$e=({target:i,props:e,fallback:t})=>{i.style.backgroundColor=ke(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},De=({target:i,props:e,fallback:t,dependsOn:n})=>{i.style.border=`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth}) solid ${ke(e?.shape?.border?.color??t.borderColor,e?.shape?.border?.alpha??t.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`},le=({target:i,layoutParams:e,fallback:t})=>{i.style.transform=`rotate(${-e.angle}rad)`};class de{constructor(e){this.control=e}createView(e){const t=document.createElement("div");t.classList.add(`${L}-control-container-${this.control.id}`),e(t,this.control.layoutParams);const n=(this.control.layoutParams.innerSizesDependOn??V.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:t,dependsOn:n}}setEvents(e,t){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),t&&t({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${L}-control-container-${this.control.id}`)}}const He=i=>{if(i.type.trim().toLowerCase()==="area")return new ht(i)};class ht extends de{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:r}=super.createView(t),s=document.createElement("button");return s.classList.add(`${L}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",$e({target:s,props:this.control.props,fallback:{...V,backgroundColor:"transparent"}}),De({target:s,props:this.control.props,fallback:{...V,borderAlpha:0},dependsOn:n}),le({target:s,layoutParams:this.control.layoutParams,fallback:V}),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${L}-${this.control.id}`)}}const Ue=i=>{if(i.type.trim().toLowerCase()==="button")return new lt(i)};class lt extends de{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:r}=super.createView(t),s=document.createElement("button");s.type="button",s.classList.add(`${L}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";const o=document.createElement("span");return o.style.display="inline-block",o.style.whiteSpace="pre",o.style.overflow="hidden",o.style.textOverflow="ellipsis",le({target:s,layoutParams:this.control.layoutParams,fallback:V}),$e({target:s,props:this.control.props,fallback:V}),De({target:s,props:this.control.props,fallback:V,dependsOn:n}),Be({target:s,props:this.control.props}),Pe({target:o,props:this.control.props,fallback:V,dependsOn:n}),s.append(o),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${L}-${this.control.id}`)}}const dt=i=>{if(i.type.trim().toLowerCase()==="text")return new ut(i)};class ut extends de{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:r}=super.createView(t),s=document.createElement("div");s.classList.add(`${L}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";const o=document.createElement("span");return o.style.whiteSpace="pre",le({target:s,layoutParams:this.control.layoutParams,fallback:V}),Be({target:s,props:this.control.props}),Pe({target:o,props:this.control.props,fallback:V,dependsOn:n}),s.append(o),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${L}-${this.control.id}`)}}class ft{constructor(e){this.layout=e}}const pt=i=>{if(i.type.trim().toLowerCase()==="relative")return new ze(i)};class ze extends ft{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}class Ge{constructor(e){this.container=e,this.factories=new Map,this.#a()}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.#a()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.#a()}#a(){this.controls=this.#s()}#s(){return this.container.controls?.reduce((e,t)=>{const n=t.type.trim().toLowerCase(),r=this.factories.get(n);return r?[...e,r(t)]:[...e]},[])}}const We=(i,e)=>{if(i.type.trim().toLowerCase()==="choice")return new mt(i,e)};class mt extends Ge{constructor(e,t){super(e),this.rootElement=t??Fe(),this.layout=new ze(this.container.layout),this.isRemoved=!1,this.addControlFactory("button",Ue),this.addControlFactory("text",dt),this.addControlFactory("area",He)}createView(e){const t=document.createElement("div");return t.classList.add(`${L}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(n=>{const r=n.createView({parent:t,layoutFn:this.layout.setControlLayout});n.setEvents(r,e)}),this.rootElement.append(t),t}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}removeView(){this.isRemoved||(this.getElement()?.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${L}-${this.container.id}`)}}function Qe(i,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>i(...n),e)}}const W={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},z=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,ue=i=>z(i,W.Object),re=i=>z(i,W.String),U=i=>z(i,W.Array),qe=i=>z(i,W.Number),yt=i=>z(i,W.Function),Ce=i=>qe(i)&&!isNaN(i),gt=i=>i==null,G=i=>ue(i)&&Object.keys(i).length===0,Xe=i=>U(i)&&!i.length,X=(i,e)=>re(i)&&(e?i.trim():i).length,Ze=window.navigator.userAgent.toLowerCase(),vt=/mobi/i.test(Ze);Ze.indexOf("android")>-1;const bt="video_interactive",Ct="videoint",Et=250;class wt{constructor(e){this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=St(e),this.resizeObserver=new ResizeObserver(Qe(this.onResize,Et)),this.resizeObserver.observe(this.graphWrapperElement)}onResize=e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))};getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}handleChapterChange=e=>{if(this.isReady){if(this.isHidden||this.hide(),!e?.id){this.onError?.("Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor.selectChapter(e.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=void 0}};handleManifestChange=async(e,t=[])=>{if(!qe(e.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 tt(this.lang,bt,Ct)}catch{console.log("Unable to load graph language pack")}const{GraphEditor:r}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new r(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:n}),this.ngEditor.on("control",({name:s,chapterId:o})=>{s==="openPreview"&&this.onOpenPreviewClick(o)}),this.ngEditor.on("zoomEnd",s=>{this.lastZoomInfo={...s}})}this.visitedChapterIds=new Set(t),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0};setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function St(i){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",i.append(e),e}const It=(i={})=>Array.from(new Set(i.sessions?.map(e=>e.visitedChapters.map(t=>t.chapterId)??[]).flat())),Ee=(i=[],e="")=>i.reduce((t,n)=>(t.find(r=>r[e]===n[e])||t.push(n),t),[]),we="chapterId";class ${constructor(e){this.id=e?.id??he(),this.startDate=e?.startDate?new Date(e.startDate).toISOString():new Date(Date.now()).toISOString(),this.updateOn=e?.updateOn?new Date(e.updateOn).toISOString():null,this.visitedChapters=e?.visitedChapters?Ee(Array.from(e.visitedChapters),we):[],this.branches=U(e?.branches)?e.branches:[]}update(e){e?.startDate&&(this.startDate=new Date(e.startDate).toISOString()),e?.updateOn&&(this.updateOn=new Date(e.updateOn).toISOString()),U(e?.visitedChapters)&&(this.visitedChapters=Ee([...this.visitedChapters,...e.visitedChapters],we)),U(e?.branches)&&(this.branches=this.branches.concat(e.branches))}getSession(){return{...this}}static createVisitedChapter(e){return[{chapterId:e}]}static createBranch(e,t,n){return[{chapterId:e,branchId:t,autoSelect:n}]}}class Z{constructor(e){this.id=e?.id??he(),this.manifestId=e?.manifestId,this.manifestVersion=e?.manifestVersion,this.manifestBuild=e?.manifestBuild,this.sessions=U(e?.sessions)?e?.sessions.map(t=>new $(t)):[],this.isCompleted=e?.isCompleted??!1}update(e){this.id=e?.id??this.id,this.manifestId=e?.manifestId??this.manifestId,this.manifestVersion=e?.manifestVersion??this.manifestVersion,this.manifestBuild=e?.manifestBuild??this.manifestBuild,this.isCompleted=e?.isCompleted??this.isCompleted}addSession(e){this.sessions.push(new $(e))}updateSession(e,t){let n;gt(e)?n=this.sessions[this.sessions.length-1]:n=this.sessions.find(r=>r.id===e),n&&n.update(t)}resetSession(){this.sessions=[]}getHistory(){return{...this,sessions:this.sessions.map(e=>e.getSession())}}}const ae="SDK_NAME-history-changed";function Tt(){return Object.assign(new EventTarget,{history:new Z,onChapterChange({chapterId:i,mediaId:e,autoSelect:t=!1,isLastChapter:n=!1}){this.history.isCompleted?this.history=new Z({manifestId:this.history.manifestId,manifestVersion:this.history.manifestVersion,manifestBuild:this.history.manifestBuild}):n&&this.history.update({isCompleted:!0}),this.history.sessions.length?this.history.updateSession(null,{updateOn:Date.now(),visitedChapters:$.createVisitedChapter(i),branches:$.createBranch(i,e,t)}):this.history.addSession({updateOn:Date.now(),visitedChapters:$.createVisitedChapter(i),branches:$.createBranch(i,e,!1)}),this.sendEvent()},onManifestChange(i,e){e?this.history=new Z(e):this.history=new Z({manifestId:i.id,manifestVersion:i.version,manifestBuild:i.build}),this.history.addSession({updateOn:Date.now()}),this.sendEvent()},getHistory(){if(history)return this.history.getHistory()},sendEvent(){this.dispatchEvent(new CustomEvent(ae,{bubbles:!1,detail:this.getHistory()}))},destroy(){this.history=void 0}})}function xt(i,e){if(!e||!i||!e.sessions.length)return;const t=e.sessions.reverse().find(n=>n.branches.length);return t.branches[t.branches.length-1].chapterId??void 0}const ee=(i="",e="")=>{i=i.split("."),e=e.split(".");let t=0;for(let n=0;n<Math.max(i.length,e.length)&&!t;n++)i[n]>e[n]?t=1:i[n]<e[n]?t=-1:t=0;return t},Rt="3.1",Se={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},At={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},jt=i=>{const e=[];for(const t of i.chapters){let n;const r=[];for(const{isDefault:a,...c}of t.branches)a&&(n=c.id),r.push(c);let s=[];const o=[];for(const{fallbackStrategy:a,...c}of t.containers){const l=!!c.endTime;let g=[At];switch(a){case"await":l?g=[]:s=[];break;case"default":{const p={type:"onSuspense",action:{type:Se.default,args:{branchId:n,shouldOpenNow:!l,isDetachContainer:!0}}};l?g=[p]:s=[p];break}case"random":case"weightlessRandom":case"max":case"min":{const p={type:"onSuspense",action:{type:Se[a],args:{}}};l?g=[p]:s=[p];break}}for(const p of c.controls)o.push({...c,controls:[{...p}],id:he(),events:g})}e.push({...t,containers:o,events:s,branches:r})}return i.metadata.version=Rt,i.metadata.updated=new Date().toISOString(),{...i,chapters:e}},Nt="3.2",Ot=i=>{if(!i.media){const{media:e,...t}=i.metadata;return{...i,metadata:{...t,version:Nt},media:e}}return i},Lt="3.3",Vt=(i=[])=>({edit:{chapters:i},view:{}}),Ie={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Mt=i=>{const e=[],t=[];for(const n of i.chapters){const{id:r,x:s,y:o,...a}=n,c=a.containers.map(l=>({...l,controls:l.controls.map(({subtype:g,type:p,...w})=>({...w,type:g??p})),events:l.events?.length?l.events:[Ie]}));e.push({id:r,...a,containers:c,events:a.events?.length?a.events:[Ie]}),t.push({id:r,x:s,y:o})}return{...i,chapters:e,graph:Vt(t),metadata:{...i.metadata,version:Lt}}},_t=[{version:"3.0",migrate:jt},{version:"3.1",migrate:Ot},{version:"3.2",migrate:Mt}],kt=i=>_t.reduce((e,t)=>ee(e.metadata.version,t.version)?e:t.migrate(e),i),Ft=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),S=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});var B;(function(i){i.GO_NEXT_BUTTON="GO_NEXT_BUTTON",i.GO_NEXT_AREA="GO_NEXT_AREA",i.WATCH_AGAIN="WATCH_AGAIN",i.OPEN_GRAPH="OPEN_GRAPH",i.CLOSE_GRAPH="CLOSE_GRAPH"})(B||(B={}));const Te={metadata:"Object",chapters:"Array"},Bt="3.0.0",Pt="3.3.0",Ke=i=>{const e=ee(i,Bt);return e===-1?!1:e===0?!0:ee(i,Pt)!==1},$t=i=>{if(!ue(i))return!1;for(const e in Te)if(!i[e]||!z(i[e],Te[e]))return!1;return Ke(i.metadata.version)},Dt=i=>i.type===Ft.Text;class R{constructor(e,t,...n){this.severity=e,this.category=t,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}static Severity={RECOVERABLE:1,CRITICAL:2};static Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6}}class Ye{listeners={};addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];const n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){const n=this.listeners[e];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===t){n.splice(r,1);break}return this}emit(e,...t){const n=this.listeners[e];return n?(n.forEach(r=>{r(...t)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Ht{constructor(e){this.raf,this.fn,this.fns=[],this.addFn(e)}addFn=(e,t=!1)=>{yt(e)&&(this.fns.push(e),t&&this.updateFn())};removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};requestAnimation=()=>{this.raf||this.forceRequestAnimation()};cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0};release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Ut{loaders;constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return zt(...this.loaders[e])(t)}}function zt(...i){return async function(t){const n=[...i];for(;n.length>0;)t=await n.shift()(t);return t}}function te(i,e,t){return i?{...i,[e]:i[e]?[t,...i[e]]:[t]}:{[e]:[t]}}function oe({actions:i,errors:e,chapterId:t,...n}){if(t){const r=i.getManifest(),s=i.getChapter(r.chapters,t);if(s){const o=i.getMedia(r.media,s.videoId),a=i.getGraph(r.graph,s.id);return o?{...n,actions:i,errors:e,result:{chapter:s,media:o,graph:a}}:{...n,errors:te(e,oe.name,"Could not find media"),actions:i}}}return{...n,errors:te(e,oe.name,"Could not find chapter"),actions:i}}const Gt=async i=>{try{let e,t;if(ue(i))e=i;else if(re(i)){t=new URL(i).href;const r=await fetch(t);if(!r.ok)return{};e=await r.json()}else return{};if(!$t(e))return{};const n=e.metadata.media;if(re(n)&&!e.media)try{let r;t?r=new URL(n,t).href:(r=new URL(n).href,t=r);const s=await fetch(r);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch{return Xt(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Wt(i){const{manifest:e,manifestURL:t}=await Gt(i),n=kt(e);return n.media=Qt(n.media,t),delete n.metadata.media,n}function ne(i,e){return i.find(t=>t.id===e)}function xe(i,e){return i.edit?.chapters?i.edit.chapters.find(t=>t.id===e):i.view?.chapters?i.view.chapters.find(t=>t.id===e):void 0}function Re(i,e){return i.videos.find(t=>t.id===e)}function Qt(i,e){return{...i,videos:i.videos.map(t=>({...t,variants:t.variants.map(n=>{const r=qt(n.url,e);return{...n,url:r||n.url}})}))}}function qt(i,e){try{return new URL(i,e).href}catch{return""}}function Xt(i){return ee(i,"3.2.0")>=0}class Zt extends Ut{constructor(e,t){super(e),this.onError=t,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this}async setManifest(e){this.release();const t=await this.exec("manifestLoaders",{actions:{addErrorMessage:te},result:null,errors:null,source:e});t.errors&&this.errorHandler(t.errors);const n=await Wt(t.result??e);return this.manifest=n,this}async setInitial(){return this.setNext()}async setNext(e=this.manifest.metadata.initChapterId){const t=await this.exec("chapterLoaders",oe({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:xe,getChapter:ne,getMedia:Re,getByBranches:this.getByBranches.bind(this),addErrorMessage:te},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){const t=ne(this.manifest.chapters,e);if(t){const n=Re(this.manifest.media,t.videoId),r=xe(this.manifest.graph,t.id);if(n)return{chapter:t,media:n,graph:r}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const t=ne(this.manifest.chapters,e);return this.getByBranches(t?.branches)}}getByBranches(e=[]){return e.reduce((t,n)=>{const r=this.getByChapterId(n.chapterId);return r&&t.push(r),t},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}}const m={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},Ae={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},x={actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Kt(){const i=new Map;function e({listId:r=Math.random().toString(),itemId:s=Math.random().toString(),...o}){const a=i.get(r),c={...o};return a?a[s]=c:i.set(r,{[s]:c}),{listId:r,itemId:s,...o}}function t(r,s){const o=i.get(r);if(o){if(s)return o[s]?.player.destroy(),o[s]?.container.remove(),o[s]?.subscription.unsubscribe(),delete o[s],Object.keys(o).length||i.delete(r),!0;for(const a of Object.values(o))a.player.destroy(),a.container.remove();return i.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(const r of i)t(r[0])}return{createPlayer:e,removePlayer:t,map:i,removeAll:n}}function je(i,e=[]){let t={},n;const r=!e.length;for(const s of i.variants)switch(!n&&"cover"in s&&(n=s.cover),s.type){case"mp4":(r||e.includes("mp4"))&&(t={...t,MPEG:{"Invariant quality":s.url}});break;case"hls":(r||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(r||e.includes("dash"))&&(t={...t,DASH:{type:"url",url:s.url}});break}return{sources:t,thumbUrl:n,title:i.id}}const K=(i,e)=>{const t=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();t!==e&&n.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))},Yt=i=>{const e=i.variants.find(t=>t.payload?.type==="vk");if(e&&"payload"in e){const[t,n]=e.payload.id.split("_");return[t,n]}return[]},J={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},Jt=2;function ei(i){const e=Kt();let t,n;const r=new Ye;let s={},o=!1,a=null,c=!1,l;i&&g(i);function g(d){a=d}function p(d,y,f){if(!a)throw Error("need to set interactive controller");const b=(e.map.get(d)??{})[y];if(b){s={chapterId:f,listId:d,itemId:y,...b};const v=s.player;n=v.info.currentQuality$.subscribe(E=>{if(!(!E||!v.info.position$.getValue())){t=E;for(const N of e.map)Object.values(N[1]).forEach(({player:O})=>{v.info.isAutoQualityEnabled$.getValue()||K(O,E)})}}),b.container.remove(),o=!1,a.setPlayer(b.player),c||(a.init(),c=!0),r.emit(J.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}async function w(d,y,f){if(!a)throw Error("need to set interactive controller");if(G(s)||d!==s.itemId)return;if(f>=0&&!o){const b=a.getChapterBranches();o=!0;const v=new Set;for(const E of b)v.has(E.media.id)||(await A({media:E.media,chapterId:E.chapter.id,setAsActive:!1,title:E.chapter.label}),v.add(E.media.id))}}async function C({chapter:{id:d},media:y}){if(G(s))return;n?.unsubscribe();const f=s.player.info.muted$.getValue(),I=s.player.info.currentQuality$.getValue(),b=s.player.info.isAutoQualityEnabled$.getValue(),v=s.player.info.volume$.getValue(),E=s.player.info.currentPlaybackRate$.getValue(),N=!b;let O=!1;for(const j of e.map)if(j[0]===y.id){const Q=Object.keys(j[1]);for(const k of Q)k===s.itemId?(Q.length<Jt||(O=!0),e.removePlayer(j[0],k)):(O=!0,p(j[0],k,d),N?K(s.player,I):s.player.setAutoQuality(!0),s.player.setVolume(v),s.player.setMuted(f),s.player.setPlaybackRate(E))}else e.removePlayer(j[0]);O||(await A({media:y,chapterId:d,setAsActive:!0,playbackRate:E}),N?K(s.player,I):s.player.setAutoQuality(!0),s.player.setVolume(v),s.player.setMuted(f))}async function A({media:d,chapterId:y,prefetch:f=!0,setAsActive:I=!0,autoplay:b=!1,preferredExt:v,title:E,playbackRate:N}){const O=Math.random().toString(),j=document.createElement("div");l.append(j);const Q=s?.player?.info.isAutoQualityEnabled$.getValue();let k;if(a?.options?.vkVideoLoader){const q=Yt(d);q.length&&(k=await a.options.vkVideoLoader(...q))}const pe={container:j,...k?.videos?.[0]||{sources:je(d,v).sources},title:E},F=new at;F.initVideo(pe);const et=j.lastChild,me=new ce;me.add(F.info.position$.subscribe(function(q){w(O,F.info.duration$.getValue(),q)})).add(F.events.canplay$.subscribe(function(){Q||K(F,t),N&&F.setPlaybackRate(N)})),et&&(j.style.display="none",j.classList.add(y));const P=e.createPlayer({listId:d.id,itemId:O,player:F,container:j,sources:je(d,v).sources,config:pe,subscription:me});return I&&p(d.id,P.itemId,y),b&&P.player.play(),f&&!b&&P.player.prepare(),r.emit(J.playerCreated,P.player),{player:P.player,config:P.config}}function _(){h(),a=null}function h(){a?.off(m.chapterChanged,C),e.removeAll(),s={},c=!1,o=!1}async function u({source:d,initialChapter:y,container:f}){if(!a)throw Error("need to set interactive controller");await a.setManifest(d),h(),l=f;const{media:I,chapter:b}=await a.setChapter({chapterId:y});if(I){a.on(m.chapterChanged,C);const{player:v,config:E}=await A({media:I,chapterId:b.id,title:b.label});return r.emit(J.initiated,{container:f,media:I,chapterId:b.id}),{player:v,config:E}}else console.error("not found")}return{...e,on:r.on.bind(r),off:r.off.bind(r),init:u,setInteractiveController:g,createPlayer:A,removeAll:_,getActivePlayer:function(){return s}}}const ti=3e3,ii=()=>{let i=[],e=null;return{setPlayer:o=>{e=o},setContainers:o=>{i=o},deleteContainer:o=>{i=i.filter(a=>a.id!==o)},getNextInteractiveTime:(o=ti)=>{if(!i.length||e===null)return null;let a=-1,c=!1;const l=e.info.position$.getValue()*1e3;for(const g of i){const p=g.startTime-o;if(p<=l&&(l<=g.endTime||g.endTime===null)){c=!0;break}l<p&&(a=a===-1?p:Math.min(a,p))}return!c&&a!==-1?a:null}}},D=ii(),T=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),fe=i=>U(i)&&!Xe(i),Je=i=>Xe(i.branches)||i.order==="end",ni=(i,e)=>{const t=i*1e3;return fe(e.controls)&&t<(e.startTime??0)},Ne=(i,e)=>{const t=i*1e3;return fe(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)},ie=i=>i.some(e=>e.action.type==="expect"),Oe=i=>i.find(e=>e.action.type==="expect"),si=({fn:i,type:e=1},...t)=>(...n)=>e?i(...n,...t):i({...n[e],...t[e]}),ri=(i=[])=>i.reduce((e,t,n)=>{const r=(t?.controls??[]).filter(s=>!Dt(s));if(fe(r)){const s=[t.startTime??0,t.endTime??1/0],o=t.id;if(!n)e.push({subjects:[o],range:s});else{const a=[];let c=-1/0,l=1/0,g=[];const p=[];for(let w=0;w<e.length;w++){const C=e[w];if(p.push(...C.subjects),C.range[0]<l&&(l=C.range[0]),C.range[1]>c&&(c=C.range[1]),C.range[0]<=s[0]&&C.range[1]>=s[1])return e[w].subjects.push(o),e;s[0]>=C.range[0]&&s[0]<=C.range[1]&&(a.push(w),g=g.concat(C.subjects),s[0]=C.range[0]),s[1]>=C.range[0]&&s[1]<=C.range[1]&&(a.push(w),g=g.concat(C.subjects),s[1]=C.range[1])}if(p.push(o),s[0]<=l&&s[1]>=c)return[{subjects:p,range:s}];a.length&&a.reverse().forEach(w=>{e.splice(w,1)}),e.push({subjects:g.concat([o]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]),ai=(i,e)=>ie(i.events)?!1:e.some(({container:t})=>t.container.id!==i.id&&ie(t.container.events)&&t.container.endTime===i.endTime&&!t.isRemoved);class oi{constructor({player:e,container:t,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:o,ignoreContainerEvent:a}){this.container=t,this.branches=n,this.selectBranches=r,this.subscription=new ce,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.globalEventEmitter=o,this.gameState=T.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))}hide=()=>{setTimeout(()=>{this.gameState!==T.end&&(ie(this.container.container.events)&&this.gameState===T.afterInteractive||this.selectBranches.state.isExpect||(this.container.hide?.(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})))})};show=()=>{if(this.gameState===T.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())this.container.show?.(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!0,isFirst:!1});else{const t=si({fn:this.selectBranches.onControlEvent,type:0},{branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})},onEvent:(n,r)=>{this.isSelectedControlEvent=!0,n!==!1&&(this.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})),(this.gameState===T.end||this.gameState===T.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),r(),this.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})),D.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===T.end});this.container.createView(t),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!0,isFirst:!0})}};selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!this.isSelectedControlEvent&&(this.isSelectedContainerEvent||(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime)))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=ie(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.visibility,visibility:!1})}onEndOfVideo=()=>{this.gameState=T.end,this.selectContainerEvent(!0)};whilePlaying=()=>{if(this.player.experimental.element$.getValue()?.readyState<1||[T.destroyed,T.removed].includes(this.gameState))return;const t=this.player.info.position$.getValue();if(ni(t,this.container.container))this.gameState!==T.beforeInteractive&&(this.gameState=T.beforeInteractive,this.onBeforeStartTime());else if(Ne(t,this.container.container))this.gameState!==T.interactive&&(this.gameState=T.interactive,this.onStartTime());else if(this.gameState!==T.afterInteractive){const s=this.gameState;this.gameState=T.afterInteractive,s===T.interactive&&this.onEndTime()}else this.gameState!==T.destroyed&&this.removeView();const n=Ne(t,this.container.container),r=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[];this.container.onProgress?.(t,n),this.globalEventEmitter.emit(m.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:r,currentTime:t,isInteractiveTime:n})};reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=T.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(m.interactives,{subjectId:this.container.container.id,subjectName:"container",type:x.containerRemoved,visibility:!1}),this.gameState=T.removed}destroy(){this.reset(),this.removeView(),this.gameState=T.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id}),D.deleteContainer(this.container.container.id)}}function ci(){const i={};function e(){for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&delete i[a];return!0}function t(a){const c={};for(const l in i)+l<=a&&(c[l]=i[l]);return c}function n(a){const c={};for(const l in i)+l>=a&&(c[l]=i[l]);return c}function r({timestamp:a,priority:c,initiator:l}){if(Ce(a)){const g=i[a]??null;if(g&&X(c,!0)){let p={};const w=g[c];return w&&(p={...p,...w}),p=G(p)?null:p,p&&X(l,!0)?p[l]??null:p}return g}return null}function s({timestamp:a,priority:c,initiator:l}){if(Ce(a))if(i[a]){if(X(c,!0))if(i[a][c]){if(X(l,!0))if(i[a][c][l]){if(delete i[a][c][l],!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:l,...g}){i[a]?.[c]?.[l]?i[a][c][l].push({...g}):i[a]?.[c]?i[a][c]={...i[a][c],[l]:[{...g}]}:i[a]?i[a]={...i[a],[c]:{[l]:[{...g}]}}:i[a]={[c]:{[l]:[{...g}]}}}return{map:i,remove:s,add:o,removeAll:e,get:r,getLte:t,getGte:n}}const hi=[S.expect,S.setNextBranch],li=1/0;function Le(i){let e=i,t;const n=di(),r=new ci;let s;const o=()=>{p(),_()},a=h=>{r.add.call(void 0,h),w()},c=(h=[])=>{for(const u of h)if(u.action(),hi.includes(u.actionType))break},l=h=>{if(!n.isReady(h))return;const u=Y(r.get({timestamp:h,priority:"control"})??{}),d=Y(r.get({timestamp:h,priority:"container"})??{}),y=Y(r.get({timestamp:h,priority:"chapter"})??{});c([...u,...d,...y])},g=()=>{c([...Y(r.get({timestamp:1/0,priority:"chapter"})??{})])},p=()=>{t&&(s?.unsubscribe(),t=void 0)},w=()=>{t||(t=()=>setTimeout(()=>{l(1/0)}),s=e.events.ended$.subscribe(t))},C=h=>{p(),e=h},A=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),r.remove(h)},_=()=>{n.release(),r.removeAll()};return{setPlayer:C,add:a,remove:A,exec:l,execEndOfVideo:g,listen:w,unlisten:p,release:o,containersEventsCallState:n}}function di(){const i=new Map;return{setCalled:({timestamp:o,id:a})=>{const c=i.get(o);c&&c[a]!==void 0&&(c[a]=!0)},setData:(o=[])=>{for(const a of o){const c=a.endTime??li,l=i.get(c)??{};i.set(c,{...l,[a.id]:!1})}},resetCalled:o=>{const a=i.get(o);if(a)for(const c in a)a[c]=!1},isReady:o=>{const a=i.get(o);return a?!Object.values(a).some(c=>!c):!0},release:()=>i.clear()}}function Y(i){return Object.values(i).flat().sort(e=>e.actionType===S.expect?-1:1)}const ui=(i,e)=>{const{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:r,clientWidth:s}=e.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};const o=t/n,a=r/s;let c,l;return a>o?(l=s,c=s*o):a<o?(l=r/o,c=r):(l=s,c=r),{videoContentWidth:l,videoContentHeight:c}},fi=250;function pi(i){let e=()=>{};const t=new ResizeObserver(a=>{s(a),e=s.bind(null,a)});function n(a){const{parentElement:c,player:l}=i();if(c&&l){const{videoContentWidth:g,videoContentHeight:p}=ui(c,l);c.style.setProperty("--interactive-content-width",`${g}px`),c.style.setProperty("--interactive-content-height",`${p}px`),c.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function r(){const{parentElement:a}=i();a.removeAttribute("style")}const s=Qe(a=>{const{fns:c=[]}=i();n(a);for(const l of c)l()},fi);function o(){e=void 0,t.disconnect(),r()}return{resizeObserver:t,calc:()=>{e()},release:o}}class mi{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){const t=this.map[e];return t?t.slice():null}getAll(){const e=[];for(const t in this.map)e.push(...this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const yi=i=>Math.floor(Math.random()*i),gi=i=>{let e=i.length,t=1/0,n=null;for(;e--;)i[e].weight<t&&(t=i[e].weight,n=i[e]);return n},vi=i=>{let e=i.length,t=-1/0,n=null;for(;e--;)i[e].weight>t&&(t=i[e].weight,n=i[e]);return n},bi=i=>{const e=i.length,t=yi(e);return i[t]},Ve=1,Ci=i=>{let e=0;for(let n=0;n<i.length;++n)e+=i[n].weight??Ve;const t=Math.random()*e;e=0;for(let n=0;n<i.length-1;++n)if(e+=i[n].weight??Ve,e>=t)return i[n];return i[i.length-1]},Me=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),se=(i,e=!1)=>({...i,args:e?{...i.args,...Me}:{...Me,...i.args}}),_e=({globalEventEmitter:i,player:e,interactiveEvents:t,removeControllers:n})=>{const r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},o=({action:h,controlType:u,controlId:d,containerId:y,branches:f=[],onEvent:I,isEOV:b=()=>!1})=>{const v=se(h,b()),E={timestamp:1/0,priority:"control",initiator:d,actionType:v.type},N=i.emit.bind(i,m.interactives,{subjectId:d,subjectType:u,subjectName:"control",type:x.actionChoice,actionType:h.type,payload:{containerId:y,...v.args}});switch(v.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{const O=f.find(j=>j.id===v.args.branchId);if(!O)return;I(v.args.isDetachContainer,w.bind(null,{subjectId:d,subjectName:"control"})),N(),v.args.shouldOpenNow?A({subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{chapterId:O.chapterId,autoSelect:!1}}):(t.add({...E,action:A.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{chapterId:O.chapterId,autoSelect:!1}})}),n?.());return}case S.continuePlayback.trim().toLowerCase():{I(v.args.isDetachContainer,w.bind(null,{subjectId:d,subjectName:"control"})),N(),v.args.shouldOpenNow?C({subjectId:d,subjectName:"control",subjectType:u,action:h}):t.add({...E,action:C.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:h})});return}case S.openURI.trim().toLowerCase():{I(v.args.isDetachContainer,w.bind(null,{subjectId:d,subjectName:"control"})),N(),v.args.shouldOpenNow?_({subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{URI:h.args.uri}}):(t.add({...E,action:_.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:v,payload:{URI:h.args.uri}})}),n?.());return}default:console.error("Unexpected control event"),i.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},a=({action:h,container:{id:u,endTime:d},branches:y=[],isEOV:f=!1,autoSelected:I=!1})=>{const b=se(h,f),v={timestamp:!b.args.shouldOpenNow||f?1/0:d,priority:"container",initiator:u,actionType:b.type},E=i.emit.bind(i,m.interactives,{subjectId:u,subjectName:"container",type:x.actionChoice,actionType:b.type,payload:b.args});switch(b.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{const N=y.find(O=>O.id===b.args.branchId);if(!N)return;E(),t.add({...v,action:A.bind(null,{subjectId:u,subjectName:"container",action:b,payload:{chapterId:N.chapterId,autoSelect:I}})}),n?.();return}case S.setMaxWeightBranch.trim().toLowerCase():return;case S.setMinWeightBranch.trim().toLowerCase():return;case S.setRandomBranch.trim().toLowerCase():return;case S.setWeightlessRandomBranch.trim().toLowerCase():return;case S.continuePlayback.trim().toLowerCase():{E(),t.add({...v,action:C.bind(null,{subjectId:u,subjectName:"container",action:b})});return}case S.openURI.trim().toLowerCase():{E(),t.add({...v,action:_.bind(null,{subjectId:u,subjectName:"container",action:b,payload:{URI:h.args.uri}})}),n?.();return}default:console.error("Unexpected container event"),i.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:h,branches:u,isEOV:d=!1}){const y=Oe(h.events);if(y){const f=se(y.action,d);i.emit(m.interactives,{subjectId:h.id,subjectName:"container",type:x.actionChoice,actionType:f.type,payload:f.args}),t.add({timestamp:d?1/0:h.endTime,priority:"container",initiator:h.id,actionType:S.expect,action:p.bind(null,{subjectId:h.id,subjectName:"container"})}),r.isExpect=!0}else for(const f of h.events)a({action:f.action,container:h,branches:u,isEOV:d})}const l=({chapterId:h,action:u,branches:d=[]})=>{const y=i.emit.bind(i,m.interactives,{subjectId:h,subjectName:"chapter",type:x.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case S.setNextBranch.trim().toLowerCase():{const f=d.find(I=>I.id===u.args.branchId);return f?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case S.setWeightlessRandomBranch.trim().toLowerCase():{const f=bi(d);return f?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case S.setRandomBranch.trim().toLowerCase():{const f=Ci(d);return f?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case S.setMaxWeightBranch.trim().toLowerCase():{const f=vi(d);return f?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case S.setMinWeightBranch.trim().toLowerCase():{const f=gi(d);return f?.chapterId?(y(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:f.chapterId,autoSelect:!0}})):void 0}case S.continuePlayback.trim().toLowerCase():return y(),C.bind(null,{subjectId:h,subjectName:"chapter",action:u});case S.openURI.trim().toLowerCase():return y(),_.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),i.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function g(h){const u=Oe(h.events);if(u){if(Je(h))return;i.emit(m.interactives,{subjectId:h.id,subjectName:"chapter",type:x.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:S.expect,action:p.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events.forEach(d=>{const y=l({chapterId:h.id,action:d.action,branches:h.branches});y&&t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:d.action.type,action:y})})}const p=({subjectId:h,subjectName:u,action:d})=>{e.pause(),i.emit(m.interactives,{subjectId:h,subjectName:u,type:x.actionExecution,actionType:d?.type??S.expect})},w=({subjectId:h,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),i.emit(m.interactives,{subjectId:h,subjectName:u,type:x.actionExecution,actionType:"after-expect"})},C=({subjectId:h,subjectName:u,subjectType:d,action:y})=>{i.emit(m.interactives,{subjectId:h,subjectName:u,subjectType:d,type:x.actionExecution,actionType:y.type})},A=({subjectId:h,subjectName:u,subjectType:d,action:y,payload:f})=>{f.behaviour="change-chapter",i.emit(m.interactives,{subjectId:h,subjectName:u,subjectType:d,type:x.actionExecution,actionType:y.type,payload:f})},_=({subjectId:h,subjectName:u,subjectType:d,action:y,payload:f})=>{if(!f.URI)return;const I=window.open(f.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),i.emit(m.interactives,{subjectId:h,subjectName:u,subjectType:d,type:x.actionExecution,actionType:y.type})};return{onControlEvent:o,onContainerEvent:a,onChapterEvent:l,onExpectEvent:p,expectEventHandler:w,setManifestChapterEvents:g,setManifestContainerEvents:c,stopExpect:s,state:r}};class H{constructor(e,t,n,r){this.target=e,this.type=t,this.listener=n,this.options=H.#a(e,r),this.target.addEventListener(t,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}static#a(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{const n=new Set(["passive","capture"]),r=Object.keys(t).filter(o=>!n.has(o));return r.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+r.join(",")),H.#h(e)?t:t.capture||!1}}static#s=void 0;static#h(e){let t=H.#s;if(t===void 0){t=!1;try{const n={},r={get:()=>(t=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);const s=()=>{};e.addEventListener("test",s,n),e.removeEventListener("test",s,n)}catch{t=!1}H.#s=t}return t||!1}}class Ei{constructor(){this.bindingMap=new mi}release(){this.removeAll(),this.bindingMap=null}listen(e,t,n,r){if(!this.bindingMap)return;const s=new H(e,t,n,r);this.bindingMap.push(t,s)}listenOnce(e,t,n,r){const s=o=>{this.unlisten(e,t,s),n(o)};this.listen(e,t,s,r)}unlisten(e,t,n){if(!this.bindingMap)return;const r=this.bindingMap.get(t)||[];for(const s of r)s.target===e&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(t,s))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const t of e)t.unlisten();this.bindingMap.clear()}}class wi{rootElement;canvasImgSrc;_prevSizeId=0;constructor(){this.rootElement=document.createElement("canvas")}clear(){this.rootElement.getContext("2d")?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){const e=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;const t=e.data,n=t.length;for(let r=3;r<n;r+=40)if(t[r]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){const n=e.width+e.height;if(this._prevSizeId===n)return;let r;t&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&r&&this.restore(r),this._prevSizeId=n}async save(){const e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}}class Si{lastFrameCanvas;endOffsetMs;currentChapter;currentVideoDurationMs=1/0;rootElement;_containerTimeFrameShouldReceived=!1;_endTimeFrameReceived=!1;_shouldCallSkip=!1;_callbacks;constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
7
7
  position: absolute;
8
8
  top: 0;
9
9
  left: 0;
@@ -11,13 +11,13 @@ import{loadVKLangPack as it,Subscription as ce,ValueSubject as nt,Observable as
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new Ii,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new wi,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
15
15
  position: absolute;
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);const t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(r){this._onError(r)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}onEachTick=e=>{const t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){this._callbacks?.onError?.(e)}}function xi(i=0){return new Promise(e=>{setTimeout(()=>{e(0)},i)})}const Ri=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,lastFrame:!1,permanentTextControls:!0}),V=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function Ai(){const i=document.createElement("div");return i.style.cssText=`
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);const t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(r){this._onError(r)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}onEachTick=e=>{const t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){this._callbacks?.onError?.(e)}}function Ii(i=0){return new Promise(e=>{setTimeout(()=>{e(0)},i)})}const Ti=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,lastFrame:!1}),M=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function xi(){const i=document.createElement("div");return i.style.cssText=`
20
20
  position: absolute;
21
21
  top: 0;
22
22
  left: 0;
23
- `,i}class Li{#a=null;#s=null;#h=null;#l=null;#r=null;#o=null;#d=null;#t=null;#u=new nt(!1);#m=new Set;#n=null;#c=null;#y=null;#i=null;#e=null;constructor(e){this.options={...Ri,...e},this.#s=[],this.factories=new Map([["choice",We]]),this.rootElement=Ai(),this.options.parentElement.append(this.rootElement),this.#e=new Je,this.#l=new ce,this.#h=new Si,this.options.lastFrame&&(this.#i=new Ti({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:t=>this.#e.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.SEAMLESS,t))})),this.#h.listen(this.rootElement,"mousedown",t=>t.stopPropagation()),this.#h.listen(this.rootElement,"mouseup",t=>t.stopPropagation()),this.#t=new Zt(this.options.loaders,t=>this.#e.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.MANIFEST,t))),this.#r=Le(this.options.player),this.#o=new Ht,this.#d=_e({player:this.options.player,interactiveEvents:this.#r,globalEventEmitter:this.#e,removeControllers:this.#p}),this.#a=yi(()=>({player:this.options?.player,parentElement:this.options.parentElement,fns:this.options.lastFrame?[()=>{this.#i.updateCanvasDimensions(!0)}]:[]})),this.options.graph&&(this.#n=new St({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:t=>{this.setChapter({chapterId:t}),this.#e.emit(m.graph,{type:Ae.watchAgainClicked,chapterId:t})},onError:t=>this.#e.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.LOADERS,{message:t}))})),this.#c=new xt,this.#c.addEventListener(ae,this.#C),this.#e.on(m.interactives,t=>{if(t.type===x.actionExecution){if(t.payload?.behaviour==="change-chapter"){const{chapterId:n,autoSelect:r}=t.payload;this.setChapter({chapterId:n,autoSelect:r})}if(t.payload?.behaviour==="change-manifest"){const{manifestURL:n}=t.payload;this.setManifest(n)}}}),this.isFirstChapterFetched=!1,this.state=V.created}emitPlayerChanged=e=>{this.#e.emit(m.playerChanged,e)};async initSeamless({source:e,initialChapter:t,visitedChapters:n=[],videosInfo:r}){this.#y=ei(this);const s=document.createElement("div");this.#y.on(J.activePlayerChanged,this.emitPlayerChanged);const{player:o,config:a}=await this.#y.init({source:e,initialChapter:t,container:s});return this.setVisitedChapters(n),this.updateGraphVideosInfo(r),{player:o,config:a}}getStatEvents(){return{click$:new ye(e=>{this.#e.on(m.graph,({type:t,visibility:n})=>{t==="visibility"&&e.next(n?P.OPEN_GRAPH:P.CLOSE_GRAPH),t==="watchAgainClicked"&&e.next(P.WATCH_AGAIN)}),this.#e.on(m.interactives,({type:t,subjectName:n,subjectType:r})=>{t!=="action-choice"||n!=="control"||(r==="Button"&&e.next(P.GO_NEXT_BUTTON),r==="Area"&&e.next(P.GO_NEXT_AREA))})}),nextMovie$:new ye(e=>{this.#e.on(m.playerChanged,({config:t})=>{t?.unitedVideoId&&e.next(t.unitedVideoId)})})}}setPlayer(e){this.#g(),this.options.player=e,D.setPlayer(this.options.player),this.#r?this.#r.setPlayer(this.options.player):this.#r=Le(this.options.player),this.#d=_e({player:this.options.player,interactiveEvents:this.#r,globalEventEmitter:this.#e,removeControllers:()=>this.#p(!1)}),this.state===V.initiated&&(this.#v(),this.#f(this.#t.chapter))}async setManifest(e,t){this.#g(),this.isFirstChapterFetched=!1;const n=await this.#t.setManifest(e),r=t&&t.manifestId===n.manifest.metadata.id?{...t}:void 0;return this.#c.onManifestChange(n.manifest.metadata,r),this.#n&&await this.#n.handleManifestChange(n.manifest,r?Tt(r):[]),this.#e.emit(m.manifestChanged,{manifest:n.manifest}),this.#f(this.#t.chapter),n.manifest}setVisitedChapters(e){Array.isArray(e)&&this.#n?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.#n?.updateVideosInfo(e)}async setChapter({chapterId:e,autoSelect:t,tryContinueFromHistory:n=!1}={}){this.#g(),this.#i&&this.isFirstChapterFetched&&(this.#i.draw(),this.#i.show()),st().browser===rt.Safari&&await xi(35);let s;e?s=await this.#t.setNext(e):s=await(n?this.#t.setNext(Rt(this.#t.manifest,this.getHistory())):this.#t.setInitial());const{chapter:o,media:a,graph:c}=s;return this.#c.onChapterChange({chapterId:o.id,mediaId:a.id,autoSelect:t,isLastChapter:et(o)}),this.#n&&this.#n.handleChapterChange(c),this.#i?.setCurrentChapter(this.getCurrentChapter().chapter),this.#e.emit(m.chapterChanged,{chapter:o,media:a,graph:c}),this.#f(this.#t.chapter),this.#m=new Set,this.isFirstChapterFetched=!0,{chapter:o,media:a,graph:c}}toggleGraphView(e=!0){this.#n&&(e?(this.#n.show(),this.#u.next(!1)):(this.#n.hide(),this.#b()),this.#e.emit(m.graph,{type:Ae.visibility,visibility:e}))}init(){this.#t.chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.state===V.created&&(this.#a.resizeObserver.observe(this.options.fullscreenTargetElement),this.#v(),this.state=V.initiated,this.#f(this.#t.chapter))}#g(){this.state===V.ready&&(this.#p(),this.#s=[],this.#o.release(),this.#r?.release(),this.state=V.initiated,this.#u.next(!1))}#I=()=>{this.#o.fns.forEach(n=>n());const e=this.options.player.info.position$.getValue()*1e3,t=(this.#t.chapter.containers||[]).filter(n=>n.startTime>=Math.floor(e));for(const n of t){this.#r.remove({timestamp:1/0,priority:"container",initiator:n.id});for(const r of n.controls)this.#r.remove({timestamp:1/0,priority:"control",initiator:r.id});this.#s.find(r=>r.container.container.id===n.id).reset()}};#E=()=>{this.#a.calc(),this.#o.requestAnimation()};#w(e){(!this.#n||this.#n.isHidden)&&this.#b();const t=e*1e3,r=this.getInteractiveRanges().findLast(({range:s})=>t>=s[1]);if(r){const s=r.range.join("-");this.#m.has(s)||(this.#m.add(s),this.#e.emit(m.interactives,{type:x.rangeEnded,payload:r,visibility:!0}))}}#v(){this.#l.unsubscribe(),this.#l.add(this.options.player.events.started$.pipe(at()).subscribe(this.#E)).add(this.options.player.events.playing$.subscribe(this.#o.requestAnimation)).add(this.options.player.events.willPause$.subscribe(this.#o.cancelAnimation)).add(this.options.player.info.position$.subscribe(this.#w.bind(this))),this.options.lastFrame&&this.#l.add(this.options.player.info.duration$.subscribe(e=>{this.#i.setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&this.#i.setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{this.#i.reset(),setTimeout(()=>{this.#i.hide(),this.#i.lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(this.#i.onSeek))}#p=(e=!0)=>{this.#s.forEach(t=>{!e&&t.isPermanentText||(this.#o.removeFn(t.whilePlaying),t.destroy())})};#f(e){this.#t.chapter&&this.state===V.initiated&&(this.#d.setManifestChapterEvents(e),this.#s=this.#S(e),this.#r.containersEventsCallState.setData(e.containers),D.setContainers(this.#s.map(t=>t.container.container)),this.options.lastFrame&&this.#o.addFn(()=>{this.#i.onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state=V.ready)}#S(e){return e?.containers?.reduce((t,n)=>{const r=n.type.trim().toLowerCase(),s=this.factories.get(r);if(s){const o=new hi({player:this.options.player,container:s(n,this.rootElement),branches:this.#t.chapter.branches,selectBranches:this.#d,interactiveEvents:this.#r,globalEventEmitter:this.#e,ignoreContainerEvent:()=>ci(n,this.#s),permanentTextControls:this.options.permanentTextControls});return this.#o.addFn(o.whilePlaying,!0),[...t,o]}return[...t]},[])??[]}#b(){const e=this.#u.getValue(),t=!!D.getNextInteractiveTime();(t&&!e||!t&&e)&&this.#u.next(!e)}isSupport(e=this.#t.manifest){return Ke(e.metadata.version)}getIsSeekable(){return this.#u}getHistory(){return this.#c.getHistory()}#C=({detail:e})=>{this.#e.emit(m.historyChanged,e)};getInteractiveRanges(){return oi(this.#t.chapter?.containers)}getNextInteractiveStartTime(e){return D.getNextInteractiveTime(e)}getChapterBranches(e){return this.#t.getBranches(e)}getCurrentChapter(){return this.#t.getCurrent()}getCurrentManifest(){return this.#t.manifest}addFactory(e,t){this.factories.set(e.trim().toLowerCase(),t)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return this.#e.on(...e),this}off(...e){return this.#e.off(...e),this}once(...e){return this.#e.once(...e),this}destroy(){this.#p(),this.#s=void 0,this.#c.removeEventListener(ae,this.#C),this.#c.destroy(),this.#c=void 0,this.#n?.destroy(),this.#n=void 0,this.#a.release(),this.#a=void 0,this.#d=void 0,this.#o.release(),this.#o=void 0,this.#r.release(),this.#r=void 0,this.#t.release(),this.#d=void 0,this.#h.release(),this.#h=void 0,this.#l.unsubscribe(),this.#l=void 0,this.#e.reset(),this.#e=void 0,this.#i?.destroy(),this.#i=void 0,this.rootElement.remove(),this.rootElement=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.state=V.destroyed}}const Mi={Container:ze,createChoiceContainer:We,createAreaControl:He,createButtonControl:Ge,createRelativeLayout:mt,getRootEl:Fe,classnamesPrefix:L},Vi={version:ct};export{R as CustomError,m as EVENT_NAMES,P as INTERACTIVE_CLICK_ACTIONS,Li as Interactives,Zt as ManifestController,Vi as SDKInfo,ee as compareVersions,Ke as isSupportedManifest,Mi as utils};
23
+ `,i}class Ni{#a=null;#s=null;#h=null;#l=null;#r=null;#o=null;#d=null;#t=null;#u=new it(!1);#m=new Set;#n=null;#c=null;#y=null;#i=null;#e=null;constructor(e){this.options={...Ti,...e},this.#s=[],this.factories=new Map([["choice",We]]),this.rootElement=xi(),this.options.parentElement.append(this.rootElement),this.#e=new Ye,this.#l=new ce,this.#h=new Ei,this.options.lastFrame&&(this.#i=new Si({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:t=>this.#e.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.SEAMLESS,t))})),this.#h.listen(this.rootElement,"mousedown",t=>t.stopPropagation()),this.#h.listen(this.rootElement,"mouseup",t=>t.stopPropagation()),this.#t=new Zt(this.options.loaders,t=>this.#e.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.MANIFEST,t))),this.#r=Le(this.options.player),this.#o=new Ht,this.#d=_e({player:this.options.player,interactiveEvents:this.#r,globalEventEmitter:this.#e,removeControllers:this.#f}),this.#a=pi(()=>({player:this.options?.player,parentElement:this.options.parentElement,fns:this.options.lastFrame?[()=>{this.#i.updateCanvasDimensions(!0)}]:[]})),this.options.graph&&(this.#n=new wt({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:t=>{this.setChapter({chapterId:t}),this.#e.emit(m.graph,{type:Ae.watchAgainClicked,chapterId:t})},onError:t=>this.#e.emit(m.errors,new R(R.Severity.RECOVERABLE,R.Category.LOADERS,{message:t}))})),this.#c=new Tt,this.#c.addEventListener(ae,this.#C),this.#e.on(m.interactives,t=>{if(t.type===x.actionExecution){if(t.payload?.behaviour==="change-chapter"){const{chapterId:n,autoSelect:r}=t.payload;this.setChapter({chapterId:n,autoSelect:r})}if(t.payload?.behaviour==="change-manifest"){const{manifestURL:n}=t.payload;this.setManifest(n)}}}),this.isFirstChapterFetched=!1,this.state=M.created}emitPlayerChanged=e=>{this.#e.emit(m.playerChanged,e)};async initSeamless({source:e,initialChapter:t,visitedChapters:n=[],videosInfo:r}){this.#y=ei(this);const s=document.createElement("div");this.#y.on(J.activePlayerChanged,this.emitPlayerChanged);const{player:o,config:a}=await this.#y.init({source:e,initialChapter:t,container:s});return this.setVisitedChapters(n),this.updateGraphVideosInfo(r),{player:o,config:a}}getStatEvents(){return{click$:new ye(e=>{this.#e.on(m.graph,({type:t,visibility:n})=>{t==="visibility"&&e.next(n?B.OPEN_GRAPH:B.CLOSE_GRAPH),t==="watchAgainClicked"&&e.next(B.WATCH_AGAIN)}),this.#e.on(m.interactives,({type:t,subjectName:n,subjectType:r})=>{t!=="action-choice"||n!=="control"||(r==="Button"&&e.next(B.GO_NEXT_BUTTON),r==="Area"&&e.next(B.GO_NEXT_AREA))})}),nextMovie$:new ye(e=>{this.#e.on(m.playerChanged,({config:t})=>{t?.unitedVideoId&&e.next(t.unitedVideoId)})})}}setPlayer(e){this.#g(),this.options.player=e,D.setPlayer(this.options.player),this.#r?this.#r.setPlayer(this.options.player):this.#r=Le(this.options.player),this.#d=_e({player:this.options.player,interactiveEvents:this.#r,globalEventEmitter:this.#e,removeControllers:this.#f}),this.state===M.initiated&&(this.#v(),this.#p(this.#t.chapter))}async setManifest(e,t){this.#g(),this.isFirstChapterFetched=!1;const n=await this.#t.setManifest(e),r=t&&t.manifestId===n.manifest.metadata.id?{...t}:void 0;return this.#c.onManifestChange(n.manifest.metadata,r),this.#n&&await this.#n.handleManifestChange(n.manifest,r?It(r):[]),this.#e.emit(m.manifestChanged,{manifest:n.manifest}),this.#p(this.#t.chapter),n.manifest}setVisitedChapters(e){Array.isArray(e)&&this.#n?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.#n?.updateVideosInfo(e)}async setChapter({chapterId:e,autoSelect:t,tryContinueFromHistory:n=!1}={}){this.#g(),this.#i&&this.isFirstChapterFetched&&(this.#i.draw(),this.#i.show()),nt().browser===st.Safari&&await Ii(35);let s;e?s=await this.#t.setNext(e):s=await(n?this.#t.setNext(xt(this.#t.manifest,this.getHistory())):this.#t.setInitial());const{chapter:o,media:a,graph:c}=s;return this.#c.onChapterChange({chapterId:o.id,mediaId:a.id,autoSelect:t,isLastChapter:Je(o)}),this.#n&&this.#n.handleChapterChange(c),this.#i?.setCurrentChapter(this.getCurrentChapter().chapter),this.#e.emit(m.chapterChanged,{chapter:o,media:a,graph:c}),this.#p(this.#t.chapter),this.#m=new Set,this.isFirstChapterFetched=!0,{chapter:o,media:a,graph:c}}toggleGraphView(e=!0){this.#n&&(e?(this.#n.show(),this.#u.next(!1)):(this.#n.hide(),this.#b()),this.#e.emit(m.graph,{type:Ae.visibility,visibility:e}))}init(){this.#t.chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.state===M.created&&(this.#a.resizeObserver.observe(this.options.fullscreenTargetElement),this.#v(),this.state=M.initiated,this.#p(this.#t.chapter))}#g(){this.state===M.ready&&(this.#f(),this.#s=[],this.#o.release(),this.#r?.release(),this.state=M.initiated,this.#u.next(!1))}#I=()=>{this.#o.fns.forEach(n=>n());const e=this.options.player.info.position$.getValue()*1e3,t=(this.#t.chapter.containers||[]).filter(n=>n.startTime>=Math.floor(e));for(const n of t){this.#r.remove({timestamp:1/0,priority:"container",initiator:n.id});for(const r of n.controls)this.#r.remove({timestamp:1/0,priority:"control",initiator:r.id});this.#s.find(r=>r.container.container.id===n.id).reset()}};#E=()=>{this.#a.calc(),this.#o.requestAnimation()};#w(e){(!this.#n||this.#n.isHidden)&&this.#b();const t=e*1e3,r=this.getInteractiveRanges().findLast(({range:s})=>t>=s[1]);if(r){const s=r.range.join("-");this.#m.has(s)||(this.#m.add(s),this.#e.emit(m.interactives,{type:x.rangeEnded,payload:r,visibility:!0}))}}#v(){this.#l.unsubscribe(),this.#l.add(this.options.player.events.started$.pipe(rt()).subscribe(this.#E)).add(this.options.player.events.playing$.subscribe(this.#o.requestAnimation)).add(this.options.player.events.willPause$.subscribe(this.#o.cancelAnimation)).add(this.options.player.info.position$.subscribe(this.#w.bind(this))),this.options.lastFrame&&this.#l.add(this.options.player.info.duration$.subscribe(e=>{this.#i.setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&this.#i.setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{this.#i.reset(),setTimeout(()=>{this.#i.hide(),this.#i.lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(this.#i.onSeek))}#f=()=>{this.#s.forEach(e=>{this.#o.removeFn(e.whilePlaying),e.destroy()})};#p(e){this.#t.chapter&&this.state===M.initiated&&(this.#d.setManifestChapterEvents(e),this.#s=this.#S(e),this.#r.containersEventsCallState.setData(e.containers),D.setContainers(this.#s.map(t=>t.container.container)),this.options.lastFrame&&this.#o.addFn(()=>{this.#i.onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state=M.ready)}#S(e){return e?.containers?.reduce((t,n)=>{const r=n.type.trim().toLowerCase(),s=this.factories.get(r);if(s){const o=new oi({player:this.options.player,container:s(n,this.rootElement),branches:this.#t.chapter.branches,selectBranches:this.#d,interactiveEvents:this.#r,globalEventEmitter:this.#e,ignoreContainerEvent:()=>ai(n,this.#s)});return this.#o.addFn(o.whilePlaying,!0),[...t,o]}return[...t]},[])??[]}#b(){const e=this.#u.getValue(),t=!!D.getNextInteractiveTime();(t&&!e||!t&&e)&&this.#u.next(!e)}isSupport(e=this.#t.manifest){return Ke(e.metadata.version)}getIsSeekable(){return this.#u}getHistory(){return this.#c.getHistory()}#C=({detail:e})=>{this.#e.emit(m.historyChanged,e)};getInteractiveRanges(){return ri(this.#t.chapter?.containers)}getNextInteractiveStartTime(e){return D.getNextInteractiveTime(e)}getChapterBranches(e){return this.#t.getBranches(e)}getCurrentChapter(){return this.#t.getCurrent()}getCurrentManifest(){return this.#t.manifest}addFactory(e,t){this.factories.set(e.trim().toLowerCase(),t)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return this.#e.on(...e),this}off(...e){return this.#e.off(...e),this}once(...e){return this.#e.once(...e),this}destroy(){this.#f(),this.#s=void 0,this.#c.removeEventListener(ae,this.#C),this.#c.destroy(),this.#c=void 0,this.#n?.destroy(),this.#n=void 0,this.#a.release(),this.#a=void 0,this.#d=void 0,this.#o.release(),this.#o=void 0,this.#r.release(),this.#r=void 0,this.#t.release(),this.#d=void 0,this.#h.release(),this.#h=void 0,this.#l.unsubscribe(),this.#l=void 0,this.#e.reset(),this.#e=void 0,this.#i?.destroy(),this.#i=void 0,this.rootElement.remove(),this.rootElement=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.state=M.destroyed}}const Oi={Container:Ge,createChoiceContainer:We,createAreaControl:He,createButtonControl:Ue,createRelativeLayout:pt,getRootEl:Fe,classnamesPrefix:L},Li={version:ot};export{R as CustomError,m as EVENT_NAMES,B as INTERACTIVE_CLICK_ACTIONS,Ni as Interactives,Zt as ManifestController,Li as SDKInfo,ee as compareVersions,Ke as isSupportedManifest,Oi as utils};
package/index.d.ts CHANGED
@@ -359,9 +359,8 @@ interface Chapter$2 {
359
359
  order: 'start' | 'end' | 'simple';
360
360
  }
361
361
 
362
- type ManifestVideoVariantType$1 = 'custom' | 'mp4' | 'hls' | 'dash' | 'mpeg';
362
+ type ManifestVideoVariantType$1 = 'custom' | 'mp4' | 'hls' | 'dash';
363
363
  type Extensions$1 = Exclude<ManifestVideoVariantType$1, 'custom'>;
364
- type Standard$1 = '144p' | '240p' | '360p' | '480p' | '720p' | '1080p' | '1440p' | '2160p' | '4320p';
365
364
  interface CustomManifestVideoVariant$1 {
366
365
  type: Extract<ManifestVideoVariantType$1, 'custom'>;
367
366
  payload: {
@@ -373,7 +372,7 @@ interface DefaultManifestVideoVariant$1 {
373
372
  type: Extensions$1;
374
373
  url: string;
375
374
  size?: number | null;
376
- standard?: Standard$1 | null;
375
+ standard?: string | null;
377
376
  resolution?: string | null;
378
377
  bitrate?: number | null;
379
378
  cover?: string | null;
@@ -610,9 +609,8 @@ interface GraphDesign {
610
609
  };
611
610
  }
612
611
 
613
- type ManifestVideoVariantType = 'custom' | 'mp4' | 'hls' | 'dash' | 'mpeg';
612
+ type ManifestVideoVariantType = 'custom' | 'mp4' | 'hls' | 'dash';
614
613
  type Extensions = Exclude<ManifestVideoVariantType, 'custom'>;
615
- type Standard = '144p' | '240p' | '360p' | '480p' | '720p' | '1080p' | '1440p' | '2160p' | '4320p';
616
614
  interface CustomManifestVideoVariant {
617
615
  type: Extract<ManifestVideoVariantType, 'custom'>;
618
616
  payload: {
@@ -624,7 +622,7 @@ interface DefaultManifestVideoVariant {
624
622
  type: Extensions;
625
623
  url: string;
626
624
  size?: number | null;
627
- standard?: Standard | null;
625
+ standard?: string | null;
628
626
  resolution?: string | null;
629
627
  bitrate?: number | null;
630
628
  cover?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-interactive",
3
- "version": "1.0.6-beta.1",
3
+ "version": "1.0.6-dev.35f8adc.0",
4
4
  "author": "vk.com",
5
5
  "description": "Movika interactive SDK",
6
6
  "homepage": "https://vk.com",
@@ -41,17 +41,19 @@
41
41
  "./es2018.esm.js": "./es2018.esm.js",
42
42
  "./es2018.cjs.js": "./es2018.cjs.js",
43
43
  "./es2015.esm.js": "./es2015.esm.js",
44
- "./es2015.cjs.js": "./es2015.cjs.js"
44
+ "./es2015.cjs.js": "./es2015.cjs.js",
45
+ "./es2015.umd.js": "./es2015.umd.js"
45
46
  },
46
47
  "files": [
47
48
  "*.cjs.js",
48
49
  "*.esm.js",
49
- "**/*.d.ts"
50
+ "**/*.d.ts",
51
+ "*.umd.js"
50
52
  ],
51
53
  "dependencies": {
52
54
  "@interactiveplatform/movika-graph-editor": "^1.11.0",
53
- "@vkontakte/videoplayer-core": "2.0.97-beta.0",
54
- "@vkontakte/videoplayer-shared": "1.0.31-beta.1",
55
+ "@vkontakte/videoplayer-core": "^2.0.93",
56
+ "@vkontakte/videoplayer-shared": "1.0.31-dev.680271f.0",
55
57
  "uuid": "^9.0.0"
56
58
  }
57
59
  }