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