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