@vkontakte/videoplayer-interactive 1.0.63-dev.3c17a78b.0 → 1.0.63-dev.b63e600f.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.esm.js +286 -0
- package/esnext.esm.js +286 -0
- package/evergreen.esm.js +286 -0
- package/package.json +4 -4
- package/types/index.d.ts +11 -2
- package/{manifest → types/manifest}/index.d.ts +3 -3
- package/types/manifest/utils.d.ts +48 -0
- package/types/modules/Graph/Graph.d.ts +54 -0
- package/types/modules/Graph/index.d.ts +1 -0
- package/types/modules/Interactives/Interactives.d.ts +143 -0
- package/types/modules/Interactives/Layout.d.ts +16 -0
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +34 -0
- package/types/modules/Interactives/containers/Container.d.ts +21 -0
- package/types/modules/Interactives/containers/index.d.ts +4 -0
- package/types/modules/Interactives/containers/types.d.ts +11 -0
- package/{modules → types/modules}/Interactives/containers/utils.d.ts +3 -3
- package/types/modules/Interactives/controls/AreaControl.d.ts +21 -0
- package/types/modules/Interactives/controls/ButtonControl.d.ts +25 -0
- package/types/modules/Interactives/controls/Control.d.ts +48 -0
- package/types/modules/Interactives/controls/TextControl.d.ts +18 -0
- package/types/modules/Interactives/controls/index.d.ts +6 -0
- package/types/modules/Interactives/controls/types.d.ts +38 -0
- package/types/modules/Interactives/controls/utils.d.ts +14 -0
- package/types/modules/Interactives/index.d.ts +16 -0
- package/types/modules/Interactives/styles/index.d.ts +1 -0
- package/types/modules/Interactives/types.d.ts +79 -0
- package/types/modules/Interactives/utils/BlinkAnimationRef.d.ts +15 -0
- package/types/modules/Interactives/utils/ControlFillAnimation/ControlFillAnimation.d.ts +34 -0
- package/types/modules/Interactives/utils/ControlFillAnimation/index.d.ts +1 -0
- package/types/modules/Interactives/utils/ControlFillAnimation/utils.d.ts +12 -0
- package/types/modules/Interactives/utils/ControlTap/ControlTap.d.ts +17 -0
- package/types/modules/Interactives/utils/ControlTap/index.d.ts +1 -0
- package/{modules → types/modules}/Interactives/utils/ControlTap/utils.d.ts +3 -3
- package/types/modules/Interactives/utils/GameController.d.ts +71 -0
- package/types/modules/Interactives/utils/GroupsStack.d.ts +30 -0
- package/types/modules/Interactives/utils/HistoryController.d.ts +51 -0
- package/types/modules/Interactives/utils/InteractiveEvents.d.ts +32 -0
- package/types/modules/Interactives/utils/ResizeManager.d.ts +15 -0
- package/types/modules/Interactives/utils/SelectBranches.d.ts +23 -0
- package/types/modules/Interactives/utils/SelectBranches.types.d.ts +78 -0
- package/{modules → types/modules}/Interactives/utils/angleUtils.d.ts +12 -12
- package/types/modules/Interactives/utils/createControlText.d.ts +4 -0
- package/types/modules/Interactives/utils/emitOnError.d.ts +13 -0
- package/types/modules/Interactives/utils/events.d.ts +79 -0
- package/types/modules/Interactives/utils/events.types.d.ts +55 -0
- package/{modules → types/modules}/Interactives/utils/fallbackStrategies.d.ts +13 -13
- package/types/modules/Interactives/utils/functionUtils.d.ts +12 -0
- package/{modules → types/modules}/Interactives/utils/gameUtils.d.ts +20 -20
- package/{modules → types/modules}/Interactives/utils/getInteractiveRanges.d.ts +5 -5
- package/types/modules/Interactives/utils/renderingUtils.d.ts +75 -0
- package/types/modules/Loaders/index.d.ts +1 -0
- package/types/modules/Loaders/movikaProjectIdLoader/index.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/{modules → types/modules}/Loaders/vkVideoLoader/utils.d.ts +1 -1
- package/{modules → types/modules}/ManifestController/Loadable.d.ts +5 -5
- package/types/modules/ManifestController/ManifestController.d.ts +34 -0
- package/types/modules/ManifestController/index.d.ts +1 -0
- package/{modules → types/modules}/ManifestController/utils.d.ts +5 -5
- package/types/modules/SeamlessController/InstanceManager.d.ts +15 -0
- package/types/modules/SeamlessController/SeamlessController.d.ts +33 -0
- package/types/modules/SeamlessController/utils.d.ts +9 -0
- package/types/modules/SeekToInteractiveController/SeekToInteractiveController.d.ts +10 -0
- package/types/modules/SeekToInteractiveController/index.d.ts +1 -0
- package/types/types/CustomError.d.ts +13 -0
- package/types/types/index.d.ts +2 -0
- package/types/utils/CssVarsManager.d.ts +23 -0
- package/types/utils/Error.d.ts +8 -0
- package/types/utils/EventEmitter.d.ts +12 -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/{utils → types/utils}/chapterHelpers.d.ts +1 -1
- package/types/utils/compareVersions.d.ts +14 -0
- package/{utils → types/utils}/extractVkMovieId.d.ts +1 -1
- package/types/utils/getVideoContentSize.d.ts +5 -0
- package/{utils → types/utils}/hexToRgb.d.ts +2 -2
- package/{utils → types/utils}/typeCheck.d.ts +6 -6
- package/index.d.ts +0 -11
- package/manifest/utils.d.ts +0 -48
- package/modules/Graph/Graph.d.ts +0 -54
- package/modules/Graph/index.d.ts +0 -1
- package/modules/Interactives/Interactives.d.ts +0 -143
- package/modules/Interactives/Layout.d.ts +0 -16
- package/modules/Interactives/containers/ChoiceContainer.d.ts +0 -34
- package/modules/Interactives/containers/Container.d.ts +0 -21
- package/modules/Interactives/containers/index.d.ts +0 -4
- package/modules/Interactives/containers/types.d.ts +0 -11
- package/modules/Interactives/controls/AreaControl.d.ts +0 -21
- package/modules/Interactives/controls/ButtonControl.d.ts +0 -25
- package/modules/Interactives/controls/Control.d.ts +0 -48
- package/modules/Interactives/controls/TextControl.d.ts +0 -18
- package/modules/Interactives/controls/index.d.ts +0 -6
- package/modules/Interactives/controls/types.d.ts +0 -35
- package/modules/Interactives/controls/utils.d.ts +0 -14
- package/modules/Interactives/index.d.ts +0 -16
- package/modules/Interactives/styles/index.d.ts +0 -1
- package/modules/Interactives/types.d.ts +0 -79
- package/modules/Interactives/utils/BlinkAnimationRef.d.ts +0 -15
- package/modules/Interactives/utils/ControlFillAnimation/ControlFillAnimation.d.ts +0 -34
- package/modules/Interactives/utils/ControlFillAnimation/index.d.ts +0 -1
- package/modules/Interactives/utils/ControlFillAnimation/utils.d.ts +0 -12
- package/modules/Interactives/utils/ControlTap/ControlTap.d.ts +0 -17
- package/modules/Interactives/utils/ControlTap/index.d.ts +0 -1
- package/modules/Interactives/utils/GameController.d.ts +0 -71
- package/modules/Interactives/utils/GroupsStack.d.ts +0 -32
- package/modules/Interactives/utils/HistoryController.d.ts +0 -52
- package/modules/Interactives/utils/InteractiveEvents.d.ts +0 -32
- package/modules/Interactives/utils/ResizeManager.d.ts +0 -15
- package/modules/Interactives/utils/SelectBranches.d.ts +0 -23
- package/modules/Interactives/utils/SelectBranches.types.d.ts +0 -78
- package/modules/Interactives/utils/createControlText.d.ts +0 -4
- package/modules/Interactives/utils/emitOnError.d.ts +0 -13
- package/modules/Interactives/utils/events.d.ts +0 -79
- package/modules/Interactives/utils/events.types.d.ts +0 -52
- package/modules/Interactives/utils/functionUtils.d.ts +0 -5
- package/modules/Interactives/utils/renderingUtils.d.ts +0 -75
- package/modules/Loaders/index.d.ts +0 -1
- package/modules/Loaders/movikaProjectIdLoader/index.d.ts +0 -1
- package/modules/Loaders/vkVideoLoader/CustomVkVideoLoader.d.ts +0 -10
- package/modules/Loaders/vkVideoLoader/index.d.ts +0 -1
- package/modules/Loaders/vkVideoLoader/types.d.ts +0 -257
- package/modules/ManifestController/ManifestController.d.ts +0 -34
- package/modules/ManifestController/index.d.ts +0 -1
- package/modules/SeamlessController/InstanceManager.d.ts +0 -15
- package/modules/SeamlessController/SeamlessController.d.ts +0 -34
- package/modules/SeamlessController/utils.d.ts +0 -9
- package/modules/SeekToInteractiveController/SeekToInteractiveController.d.ts +0 -10
- package/modules/SeekToInteractiveController/index.d.ts +0 -1
- package/types/CustomError.d.ts +0 -13
- package/utils/CssVarsManager.d.ts +0 -23
- package/utils/Error.d.ts +0 -8
- package/utils/EventEmitter.d.ts +0 -12
- package/utils/LastFrame.d.ts +0 -35
- package/utils/LastFrameCanvasAPI.d.ts +0 -19
- package/utils/MultiMap.d.ts +0 -10
- package/utils/Raf.d.ts +0 -13
- package/utils/compareVersions.d.ts +0 -14
- package/utils/getVideoContentSize.d.ts +0 -5
- /package/{constants.d.ts → types/constants.d.ts} +0 -0
- /package/{env.d.ts → types/env.d.ts} +0 -0
- /package/{modules → types/modules}/Interactives/styles/utils.d.ts +0 -0
- /package/{modules → types/modules}/Loaders/movikaProjectIdLoader/movikaProjectIdLoader.d.ts +0 -0
- /package/types/{dom.d.ts → types/dom.d.ts} +0 -0
- /package/{utils → types/utils}/debounce.d.ts +0 -0
- /package/{utils → types/utils}/throttle.d.ts +0 -0
package/es2015.esm.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.63-dev.b63e600f.0
|
|
3
|
+
* Thu, 26 Mar 2026 09:05:53 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-63/doc/
|
|
5
|
+
*/
|
|
6
|
+
const e=[`name`],t=[`actions`,`errors`,`chapterId`],n=[`listId`,`itemId`],r=[`timestamp`,`priority`,`initiator`],i=[`statistics`];import a from"@oxc-project/runtime/helpers/defineProperty";import o from"@oxc-project/runtime/helpers/objectSpread2";import s from"@oxc-project/runtime/helpers/asyncToGenerator";import c from"@oxc-project/runtime/helpers/objectWithoutProperties";import l from"@oxc-project/runtime/helpers/classPrivateFieldInitSpec";import u from"@oxc-project/runtime/helpers/classPrivateFieldSet2";import d from"@oxc-project/runtime/helpers/classPrivateFieldGet2";var f=`1.0.63-dev.b63e600f.0`;import{fromEvent as p,Subscription as m}from"@vkontakte/videoplayer-shared/es2015";class h{constructor(e,t){a(this,`layout`,void 0),a(this,`cssVarsManager`,void 0),this.layout=e,this.cssVarsManager=t}}class g extends h{constructor(e,t){super(e,t),a(this,`cssVarsManager`,void 0),this.cssVarsManager=t,this.cssVarsManager=t}setContainerLayout(e){e.style.position=`relative`}setControlLayout(e,t){let n=this.cssVarsManager.getPropValue(`--interactive-content-width`),r=this.cssVarsManager.getPropValue(`--interactive-content-height`),i=this.cssVarsManager.getPropValue(`--interactive-width`),a=this.cssVarsManager.getPropValue(`--interactive-height`);e.style.position=`absolute`,e.style.width=`calc(${n} * (${t.width} + 0.0002))`,e.style.height=`calc(${r} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${i} - ${n}) / 2))`,e.style.top=`calc(${r} * ${t.y} + ((${a} - ${r}) / 2))`}}import{Subject as _}from"@vkontakte/videoplayer-shared/es2015";function v(e){return`features`in e}class y{constructor(e,t,...n){a(this,`severity`,void 0),a(this,`category`,void 0),a(this,`data`,void 0),this.severity=e,this.category=t,this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null,` `)}`}}function b({emitter$:e,error:t,subjectId:n,message:r=``,severity:i=1,category:a=1}){let o=new y(i,a,{message:r,error:t,details:{id:n}});e.next(o)}class x{constructor(e,t,n){a(this,`container`,void 0),a(this,`options`,void 0),a(this,`factories`,void 0),a(this,`controls`,void 0),a(this,`error$`,new _),a(this,`cssVarsManager`,void 0),this.container=e,this.options=n,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return!!(this.options&&this.options.features&&v(this.options)&&this.options.features[e])}onError(e=``,t){b({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),r=this.factories.get(n);if(r){let n=r(t,this.options);if(n)return[...e,n]}return[...e]},[])||[]}}import{fromEvent as S,once as C}from"@vkontakte/videoplayer-shared/es2015";var w=(e,t)=>Object.prototype.toString.call(e)===`[object ${t}]`,T=e=>w(e,`Object`),ee=e=>w(e,`String`),E=e=>w(e,`Array`),te=e=>w(e,`Number`),ne=e=>w(e,`Function`),re=e=>w(e,`Boolean`),ie=e=>te(e)&&!isNaN(e),D=e=>T(e)&&Object.keys(e).length===0,ae=e=>E(e)&&!e.length,oe=(e,t)=>ee(e)&&!!(t?e.trim():e).length;function se(e,t=1){let n=`0`,r=`0`,i=`0`;return e.length===4?(n=`0x`+e[1]+e[1],r=`0x`+e[2]+e[2],i=`0x`+e[3]+e[3]):e.length===7&&(n=`0x`+e[1]+e[2],r=`0x`+e[3]+e[4],i=`0x`+e[5]+e[6]),`rgba(${+n},${+r},${+i},${t})`}var ce=`interactive`,O={textColor:`#000`,textSize:.4,textContent:``,roundCorners:0,borderWidth:0,borderWidthRawValue:`1px`,roundCornersRawValue:`0`,borderColor:`#000`,borderAlpha:1,backgroundColor:`#fff`,backgroundAlpha:1,innerSizesDependOn:`self`,angle:0,shadowColorLight:`#fff`,shadowColorDark:`#000`,shadowColorAlpha:.24},le;(e=>{e.top=`flex-start`,e.bottom=`flex-end`,e.center=`center`})(le||={});var ue;(e=>{e.start=`flex-start`,e.end=`flex-end`,e.center=`center`})(ue||={});var de=({target:e,props:t})=>{e.style.alignItems=(t?.gravityVertical&&le[t.gravityVertical])??`center`,e.style.justifyContent=(t?.gravityHorizontal&&ue[t.gravityHorizontal])??`center`,e.style.textAlign=t?.alignment??`center`},fe=({target:e,props:t,fallback:n,dependsOn:r})=>{var i,a,o;e.style.color=(t==null||(i=t.text)==null?void 0:i.color)??n.textColor,e.style.fontSize=`calc(${r.height} * ${(t==null||(a=t.text)==null?void 0:a.size)??n.textSize})`,e.textContent=(t==null||(o=t.text)==null?void 0:o.value)??n.textContent},pe=({target:e,props:t,fallback:n})=>{var r,i;e.style.backgroundColor=se((t==null||(r=t.background)==null?void 0:r.color)??n.backgroundColor,(t==null||(i=t.background)==null?void 0:i.alpha)??n.backgroundAlpha)},me=({target:e,props:t,fallback:n,dependsOn:r,useRawValues:i=!1})=>{var a,o,s,c;let l=i?n.borderWidthRawValue:`calc(${r.height} * ${(t==null||(a=t.shape)==null||(a=a.border)==null?void 0:a.width)??n.borderWidth})`,u=i?n.roundCornersRawValue:`calc(${r.height} * ${(t==null||(o=t.shape)==null?void 0:o.roundCorners)??n.roundCorners})`;e.style.borderWidth=l,e.style.borderStyle=`solid`,e.style.borderColor=se(i?n.borderColor:(t==null||(s=t.shape)==null||(s=s.border)==null?void 0:s.color)??n.borderColor,i?n.borderAlpha:(t==null||(c=t.shape)==null||(c=c.border)==null?void 0:c.alpha)??n.borderAlpha),e.style.borderRadius=u},he=({target:e,isDark:t,baseDimension:n,fallback:r})=>{let i=se(r.shadowColorLight,r.shadowColorAlpha),a=se(r.shadowColorDark,r.shadowColorAlpha),o=`0px 0px ${`calc(${n} * 0.25)`} ${`calc(${n} * 0.11)`} ${t?a:i}`;e.style.boxShadow=o},ge=({target:e,layoutParams:t,fallback:n})=>{let r=t.angle??n.angle;r&&=r*-1,e.style.transform=`rotate(${r}rad)`};import{fromEvent as k,Subject as _e,Subscription as ve}from"@vkontakte/videoplayer-shared/es2015";var ye=`interactive-control-tap`,A={common:ye,animation:`${ye}-animation`,visible:`${ye}-visible`},be=60;class xe{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:n=be,useDimensionsBasedSize:r=!1}){a(this,`element`,void 0),a(this,`controlRotateAngleRad`,void 0),a(this,`clickCancelCondition`,void 0),a(this,`circleDiameterPx`,void 0),a(this,`useDimensionsBasedSize`,void 0),a(this,`onElementClick`,e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},i=Math.min(r.width,r.height),a=n.left+n.width/2,o=n.top+n.height/2,s=Se(e.clientX-a,e.clientY-o,this.controlRotateAngleRad);this.element.style.width=i+`px`,this.element.style.left=s.x+n.width/2-i/2+`px`,this.element.style.top=s.y+n.height/2-i/2+`px`,this.element.classList.add(A.visible,A.animation)}),a(this,`onAnimationEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(A.visible,A.animation)});let i=document.createElement(`div`);i.classList.add(A.common),this.controlRotateAngleRad=e,this.element=i,this.clickCancelCondition=t,this.circleDiameterPx=n,this.useDimensionsBasedSize=r}}function Se(e,t,n){return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}}function Ce(e){return`features`in e}var j=`interactive-control`,M={common:j,selected:`${j}-selected`,wrapper:`${j}-wrapper`,disabled:`${j}-disabled`,button:`${j}-button`,area:`${j}-area`,text:`${j}-text`,blinkAnim:`${j}-blink-anim`,blinkAnimButton:`${j}-blink-anim-button`,blinkAnimArea:`${j}-blink-anim-area`},we=40;import{arrayIncludes as Te}from"@vkontakte/videoplayer-shared/es2015";import{isSupportedManifest as Ee,ContainerTypes as De,ControlTypes as Oe,EventActionTypes as N,EventTypes as ke,migrateManifestToLatestVersion as Ae}from"@interactiveplatform/movika-manifest";var je={metadata:`Object`,chapters:`Array`},Me=e=>{if(!T(e))return!1;for(let t in je){let n=e[t];if(!n||!w(n,je[t]))return!1}return Ee(e.metadata.version)};function Ne(e){return e.type===Oe.Text}function Pe(e){return e.type===Oe.Button}function Fe(e){return e.type===Oe.Area}var Ie={Choice:`Choice`,TextInput:`TextInput`},Le={Button:`Button`,Area:`Area`,Text:`Text`},Re={onClick:`onClick`,onSuspense:`onSuspense`},ze={openURI:`openURI`,setNextBranch:`setNextBranch`,setWeightlessRandomBranch:`setWeightlessRandomBranch`,setRandomBranch:`setRandomBranch`,setMaxWeightBranch:`setMaxWeightBranch`,setMinWeightBranch:`setMinWeightBranch`,setDefaultBranch:`setDefaultBranch`,continuePlayback:`continuePlayback`,expect:`expect`},Be=e=>E(e)&&!ae(e),P=e=>e.order===`end`,Ve=e=>E(e.containers)&&!ae(e.containers)&&P(e),He=(e,t)=>{let n=e*1e3;return Be(t.controls)&&n<(t.startTime??0)},Ue=(e,t)=>{let n=e*1e3;return Be(t.controls)&&n>=(t.startTime??0)&&n<=(t.endTime??1/0)},We=(e=[])=>e.some(e=>e.action.type===`expect`),Ge=(e=[])=>e.find(e=>e.action.type===`expect`),Ke=e=>e?.length===1,qe=e=>Ke(e)&&Ne(e[0]);function Je(e=[],t=1/0,n=[]){return e.filter(({container:e})=>!Te(n,e.container.id)&&We(e.container.events)&&e.container.endTime===t&&!e.isRemoved&&!e.willRemoved)}function Ye({gameControllers:e=[],subjectName:t,subjectId:n,execFn:r}){for(let i of e)if(t===`container`&&i.container.container.id===n){r(i),Je(e,i.container.container.endTime,[i.container.container.id]).forEach(e=>{r(e)});break}}function Xe(e){for(let t of e.events)if(t.action.type===`openURI`)return!0;return!1}var Ze=(e,t)=>{let n=We(e.events)&&!(e=>t.find(({container:t})=>t.container.id===e)?.container.isRemoved)(e.id),r=(t,n=!1,r=!1)=>{let i=r?`every`:`some`;return t.controls[i](r=>{let a=n?t.endTime===e.endTime:!0;return r.events?.[i](e=>e.action?.type===N.openURI)&&a})},i=e=>e.some(({container:e})=>r(e.container,!0,!1)&&!e.isRemoved),a=e=>e.every(({container:e})=>e.isRemoved||e.willRemoved?!0:r(e.container,!0,!0)),o=Je(t,e.endTime,[e.id]).length,s=e=>e.controls.some(e=>e.events?.some(e=>{var t;return(t=e.action)==null||(t=t.args)==null?void 0:t.shouldOpenNow})),c=n||o>0,l=i(t),u=r(e),d=a(t),f=n?!1:o>0,p=s(e);return{isExpectTime:c,hasOtherExpect:o>0,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:u,isAllOpenURIEventsValid:d,isExpectEventForCurrentContainer:f,hasShouldOpenNowEvent:p}};class F{constructor(e,t=void 0){a(this,`control`,void 0),a(this,`options`,void 0),a(this,`container`,null),a(this,`controlElement`,null),a(this,`subscriptions`,new ve),a(this,`error$`,new _e),a(this,`controlTap`,void 0),a(this,`isInteracted`,!1),a(this,`isRemoved`,!1),a(this,`cssVarsManager`,null),a(this,`onControlSelect`,()=>{var e;this.container?.isManifestContainerDisabled()||Xe(this.control)||(e=this.container)==null||(e=e.element)==null||e.classList.add(`interactive-control-wrapper-selected`)}),a(this,`onTransitionEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}),this.control=e,this.options=t}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains(`interactive-control-before-remove`))return;t.classList.add(`interactive-control-before-remove`),this.subscriptions.add(k(t,`transitionend`).subscribe(this.onTransitionEnd,e=>this.onError(`${F.name} remove view transition error`,e))).add(k(t,`transitioncancel`).subscribe(this.onTransitionEnd,e=>this.onError(`${F.name} remove view transition error`,e)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e=``,t){b({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){this.featureIsEnabled(`controlsTapPlace`)&&this.container&&(this.controlTap=new xe({controlRotateAngleRad:this.control.layoutParams.angle??O.angle,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?we:void 0}),this.subscriptions.add(k(e,`click`).subscribe(this.controlTap.onElementClick,e=>this.onError(`Control click tap animation error`,e))).add(k(this.controlTap.element,`animationend`).subscribe(this.controlTap.onAnimationEnd,e=>this.onError(`Tap animationend error`,e))),this.container.element.append(this.controlTap.element))}createContainerElement(e){let t=document.createElement(`div`);t.classList.add(M.wrapper),e.setControlLayout(t,this.control.layoutParams),this.container={element:t,dimensions:(this.control.layoutParams.innerSizesDependOn??O.innerSizesDependOn)===`self`?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue(`--interactive-content-height`)??0,width:this.cssVarsManager?.getPropValue(`--interactive-content-width`)??0},isManifestContainerDisabled:()=>e.isContainerDisabled?.call(e)??!1}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return!!(this.options&&Ce(this.options)&&this.options.features[e])}isTouch(){return!!(this.options&&Ce(this.options)&&this.options.isTouch)}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case`onclick`:if(!this.container)break;this.subscriptions.add(k(this.container.element,`click`).subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),e=>this.onError(`Error happened on control interaction`,e)));break;default:break}})}removeListeners(){this.subscriptions.unsubscribe()}}var Qe=`interactive-blink-anim-reference`,I={common:Qe,animation:`${Qe}-animation`,disabled:`${Qe}-disabled`};class $e{constructor(){a(this,`_RAFId`,0),a(this,`_element`,void 0)}get element(){return this._element}create(){if(this._element)return;let e=document.createElement(`div`);e.classList.add(I.common,I.animation),this._element=e}restart(){this._element&&(this._element.classList.add(I.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(I.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&=(cancelAnimationFrame(this._RAFId),0)}destroy(){this.cleanupRAF(),this._element=void 0}}var et=`interactive-container`,L={common:et,hidden:`${et}-hidden`,disabled:`${et}-disabled`},tt=(e,t)=>{if(e.type.trim().toLowerCase()===`area`)return new nt(e,t)};class nt extends F{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`button`);n.type=`button`,n.classList.add(M.common,M.area),n.setAttribute(`data-testid`,`int_area`),pe({target:n,props:this.control.props,fallback:o(o({},O),{},{backgroundColor:`transparent`})}),ge({target:n,layoutParams:this.control.layoutParams,fallback:O}),this.addControlTap(n),this.subscriptions.add(S(this.container.element,`click`).pipe(C()).subscribe(this.onControlSelect,e=>this.onError(`Control click handler error`,e))),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled(`controlsExpectTimeBlinkAnimation`))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(S(this.controlElement,`mouseleave`).subscribe(()=>{if(e.classList.contains(L.disabled))return;let t=e.parentElement;if(t){let e=t.querySelector(`.${I.common}`);e&&this.syncBlinkAnimation(e)}},e=>this.onError(`Error happened in mouseleave callback`,e))),this.subscriptions.add(S(this.controlElement,`mouseenter`).subscribe(()=>{e.classList.contains(L.disabled)||this.onBlinkHovering()},e=>this.onError(`Error happened in mouseenter callback`,e))).add(S(this.controlElement,`mouseleave`).subscribe(()=>{this.controlElement&&(this.controlElement.style.animation=``)},e=>this.onError(`Error happened in mouseleave callback`,e))))}disable(){this.controlElement&&this.controlElement.classList.add(M.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(M.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(re(e)){var t;let n=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+`px`;he({target:this.controlElement,props:this.control.props,fallback:O,isDark:e,baseDimension:n}),me({target:this.controlElement,props:this.control.props,fallback:o(o({},O),{},{borderColor:e?O.shadowColorDark:O.shadowColorLight,borderAlpha:1,borderWidthRawValue:`0.1px`,roundCornersRawValue:`calc(${this.container.dimensions.height} * ${((t=this.control.props)==null||(t=t.shape)==null?void 0:t.roundCorners)??O.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else me({target:this.controlElement,props:this.control.props,fallback:o(o({},O),{},{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(M.blinkAnim,e),this.controlElement?.classList.toggle(M.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${M.blinkAnimArea}`)||this.controlElement.classList.contains(M.selected)||this.controlElement.classList.contains(I.disabled)||(this.controlElement.classList.add(I.disabled),this.subscriptions.add(S(e,`animationiteration`).pipe(C()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(I.disabled)},e=>this.onError(`Error happened in animationiteration callback`,e)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${M.blinkAnimArea}`)||this.controlElement.classList.contains(M.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue(`--interactive-area-hover-opacity`).trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation=`none`,requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}}import{fromEvent as R,once as rt}from"@vkontakte/videoplayer-shared/es2015";var it=e=>{let t=document.createElement(`span`);switch(e){case`Button`:case`button`:{let e=document.createElement(`div`);return Object.assign(e.style,{overflow:`hidden`,display:`flex`,justifyContent:`center`,alignItems:`center`}),e.append(t),Object.assign(t.style,{display:`inline-block`,whiteSpace:`pre`,textOverflow:`ellipsis`,maxWidth:`initial`,maxHeight:`100%`,wordBreak:`normal`}),e}default:return Object.assign(t.style,{display:`inline-block`,whiteSpace:`break-spaces`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,maxHeight:`100%`,wordBreak:`break-all`}),t}},at=Math.PI,ot=2*at,st=at/2,ct=3*st,lt=[0,st,at,ct];function ut(e){return e===st}function dt(e){return e===at}function ft(e){return e===ct}function pt(e){return(e%ot+ot)%ot}function mt(e){for(let t of lt)if(e===t)return t}function ht(e){return mt(e)?null:[1,2,3,4][Math.floor(e/st)+1-1]}function gt(e){return e*180/Math.PI}var z=`interactive-control-fill-animation`,B={common:z,fillerWrapper:`${z}-filler-wrapper`,filler:`${z}-filler`,fillHeight:`${z}-fill-height`,fillWidth:`${z}-fill-width`,fromTop:`${z}-from-top`,fromBottom:`${z}-from-bottom`,fromLeft:`${z}-from-left`,fromRight:`${z}-from-right`};class _t{constructor(e){a(this,`fillAnimationElement`,void 0),a(this,`fillAnimationFillerElement`,void 0),a(this,`fillAnimationFillerWrapperElement`,void 0),a(this,`startTime`,void 0),a(this,`endTime`,void 0),a(this,`shouldFillHeight`,void 0),a(this,`widthExpansionCoef`,0),a(this,`isDebug`,void 0),a(this,`fromLeft`,void 0),a(this,`useSkew`,void 0),a(this,`rotateAngle`,void 0);let t=document.createElement(`div`);t.classList.add(B.common);let n=document.createElement(`div`);n.classList.add(B.fillerWrapper);let r=document.createElement(`div`);r.classList.add(B.filler),n.append(r),t.append(n);let i=pt(e.rotateAngle),o=ht(i),s=o!==null,c=o===2||!s&&dt(i)||o===3,l=!s&&ut(i),u=!s&&ft(i),d=!c&&!l&&!u,f=l||u,p=s&&!f,m=p?i:0;t.style.borderRadius=e.borderRadius,n.style.transform=`skew(${m*-1}rad)`,f?(r.classList.add(B.fillHeight,l?B.fromTop:B.fromBottom),n.classList.add(B.fillHeight,l?B.fromTop:B.fromBottom)):(r.classList.add(B.fillWidth,d?B.fromLeft:B.fromRight),n.classList.add(B.fillWidth)),e.debug&&console.log(`[interactive ${_t.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:f,rotateAngleRad:i,rotateAngelDeg:gt(i),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:l,fromBottom:u,fromLeft:d}),this.useSkew=p,this.fromLeft=d,this.rotateAngle=i,this.fillAnimationElement=t,this.fillAnimationFillerElement=r,this.fillAnimationFillerWrapperElement=n,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=f,this.isDebug=e.debug??!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+`%`,this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?`left`:`right`}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((e=>e<this.startTime||e>this.endTime)(e))return;let t=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/t,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:n,initHeight:r}){return t?(n+r*Math.abs(Math.tan(e)))/n-1:0}}var vt=(e,t)=>{if(e.type.trim().toLowerCase()===`button`)return new yt(e,t)};class yt extends F{constructor(e,t){super(e,t),a(this,`startTime`,void 0),a(this,`endTime`,void 0),a(this,`controlFillAnimation`,void 0)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`button`);n.type=`button`,n.classList.add(M.common,M.button),n.setAttribute(`data-testid`,`int_bttn`),ge({target:n,layoutParams:this.control.layoutParams,fallback:O}),pe({target:n,props:this.control.props,fallback:O}),me({target:n,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),de({target:n,props:o(o({},this.control.props.text),{},{alignment:this.control.layoutParams.alignment})});let r=it(this.control.type.trim().toLowerCase());fe({target:r.firstElementChild??r,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),this.addControlTap(n),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled(`controlsFillAnimation`)&&(this.controlFillAnimation=new _t({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??O.angle,borderRadius:n.style.borderRadius})),this.subscriptions.add(R(n,`click`).pipe(rt()).subscribe(this.onControlSelect,e=>this.onError(`Control click handler error`,e))),n.append(r,this.controlFillAnimation?.fillAnimationElement??``),this.container.element.append(this.controlTap?.element??``,n),e.append(this.container.element),this.controlElement=n,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled(`controlsExpectTimeBlinkAnimation`))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(R(this.controlElement,`mouseleave`).subscribe(()=>{if(e.classList.contains(L.disabled))return;let t=e.parentElement;if(t){let e=t.querySelector(`.${I.common}`);e&&this.syncBlinkAnimation(e)}},e=>this.onError(`Error happened in mouseleave callback`,e))),this.subscriptions.add(R(this.controlElement,`mouseenter`).subscribe(()=>{e.classList.contains(L.disabled)||this.onBlinkHovering()},e=>this.onError(`Error happened in mouseenter callback`,e))).add(R(this.controlElement,`mouseleave`).subscribe(()=>{this.controlElement&&(this.controlElement.style.animation=``)},e=>this.onError(`Error happened in mouseleave callback`,e))))}disable(){this.controlElement&&this.controlElement.classList.add(M.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(M.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(M.blinkAnim,e),this.controlElement?.classList.toggle(M.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${M.blinkAnimButton}`)||this.controlElement.classList.contains(M.selected)||this.controlElement.classList.contains(I.disabled)||(this.controlElement.classList.add(I.disabled),this.subscriptions.add(R(e,`animationiteration`).pipe(rt()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(I.disabled)},e=>this.onError(`Error happened in animationiteration callback`,e)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${M.blinkAnimButton}`)||this.controlElement.classList.contains(M.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue(`--interactive-button-hover-opacity`).trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation=`none`,requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){this.controlFillAnimation?.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}}var bt=(e,t)=>{if(e.type.trim().toLowerCase()===`text`)return new xt(e,t)};class xt extends F{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`div`);n.classList.add(M.common,M.text),n.setAttribute(`data-testid`,`int_text`),ge({target:n,layoutParams:this.control.layoutParams,fallback:O}),de({target:n,props:o(o({},this.control.props.text),{},{alignment:this.control.layoutParams.alignment})});let r=it(this.control.type.trim().toLowerCase());fe({target:r.firstElementChild??r,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}}var St=(e,t,n,r)=>{if(e.type.trim().toLowerCase()===`choice`)return new Ct(e,t,n,r)};class Ct extends x{constructor(e,t,n,r){super(e,n,r),a(this,`rootElement`,void 0),a(this,`containerElement`,null),a(this,`layout`,void 0),a(this,`subscriptions`,new m),a(this,`isRemoved`,void 0),a(this,`isDisabled`,void 0),a(this,`willRemoved`,void 0),a(this,`cssVarsManager`,void 0),a(this,`onTransitionEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}),this.rootElement=t,this.layout=new g(this.container.layout,n),this.cssVarsManager=n,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory(`button`,vt),this.addControlFactory(`text`,bt),this.addControlFactory(`area`,tt)}createView({eventCallback:e,videoDurationMs:t}){let n=document.createElement(`div`);return n.classList.add(L.common,L.disabled),n.setAttribute(`data-subjectId`,this.container.id),requestAnimationFrame(()=>{n.classList.remove(L.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(r=>{r.setShowTimeRange(this.container.startTime,this.container.endTime??t),r.setCssVarsManager(this.cssVarsManager),r.createView({parentElement:n,callbacks:{setControlLayout:(e,t)=>this.layout.setControlLayout(e,t),isContainerDisabled:()=>this.isDisabled}}),r.setEvents(e),this.subscriptions.add(r.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let e of this.controls)e.updateFillAnimationDimensions()}hide(){let e=this.getElement();e&&e.classList.add(L.hidden)}show(){let e=this.getElement();e&&e.classList.remove(L.hidden)}enable(){let e=this.getElement();e&&(e.classList.remove(L.disabled),this.controls.forEach(e=>e.enable()),this.isDisabled=!1)}disable(){let e=this.getElement();e&&(e.classList.add(L.disabled),this.controls.forEach(e=>e.disable()),this.isDisabled=!0)}removeView(e=!1,t=!1){let n=this.getElement();if(n){if(e){if(this.willRemoved)return;this.willRemoved=!0,t&&n.classList.add(`interactive-container-before-remove-delay`),n.classList.add(`interactive-container-before-remove`),this.subscriptions.add(p(n,`transitionend`).subscribe(this.onTransitionEnd,e=>this.onError(`${Ct.name} remove view transition error`,e))).add(p(n,`transitioncancel`).subscribe(this.onTransitionEnd,e=>this.onError(`${Ct.name} remove view transition error`,e)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(e=!1){this.controls.forEach(t=>t.removeView(e))}removeNonInteractedControls(e=!1){this.controls.forEach(t=>{t.isInteracted||t.removeView(e)})}isInteracted(){return this.controls.some(e=>e.isInteracted)}fakeRemove(){this.isRemoved||=!0}getElement(){return this.containerElement}onProgress(e,t){t&&this.controls.forEach(t=>{t.onProgress(e)})}onResize(e){e&&this.controls.forEach(e=>{e.onResize()})}updateControlsShadowStyles(e){this.controls.forEach(t=>t.updateShadowStyles(e))}toggleBlinkAnimation(e){this.controls.forEach(t=>t.toggleBlinkAnimation(e))}}import{combine as wt,InterfaceLanguage as Tt,Observable as Et,once as Dt,Subject as V,Subscription as Ot,ValueSubject as H,fromEvent as kt}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as U}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as At}from"@vkontakte/videoplayer-shared/es2015";function jt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}var Mt=`video_interactive`,Nt=`videoint`,Pt=250;class Ft{constructor(e){a(this,`isHidden`,void 0),a(this,`currentManifestId`,void 0),a(this,`currentChapterId`,void 0),a(this,`visitedChapterIds`,void 0),a(this,`onOpenPreviewClick`,void 0),a(this,`onError`,void 0),a(this,`lang`,void 0),a(this,`zoom`,void 0),a(this,`lastZoomInfo`,void 0),a(this,`isReady`,void 0),a(this,`ngEditor`,void 0),a(this,`ngEditorSize`,void 0),a(this,`graphWrapperElement`,void 0),a(this,`resizeObserver`,void 0),a(this,`manifest`,void 0),a(this,`handleZoomChange`,jt(e=>{this.lastZoomInfo=e},Pt)),a(this,`onResize`,e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}}),a(this,`handleChapterChange`,e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.call(this,`Chapter id is not found`);return}this.visitedChapterIds.add(e.id),this.ngEditor?.selectChapter(e.id),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}}),a(this,`handleManifestChange`,(e,t=[])=>{if(this.isReady=!1,!te(e.graph.edit.chapters[0].x)){this.onError?.call(this,`Can't show graph`);return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id===this.currentManifestId?this.ngEditor.setVisitedChapters(Array.from(t)):(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id),this.isReady=!0)}),this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:i=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(i),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??`ru`,this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=It(e),this.resizeObserver=new ResizeObserver(jt(this.onResize,Pt)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}show(){var e=this;return s(function*(){e.manifest&&(e.ngEditor||(yield e.initNgEditor()),e.graphWrapperElement.style.display=`block`,!e.lastZoomInfo&&e.currentChapterId&&e.ngEditor?.focusChapter(e.currentChapterId),e.isHidden=!1)})()}initNgEditor(){var t=this;return s(function*(){if(!t.manifest)return;let n;try{n=yield At(t.lang,Mt,Nt)}catch{t.onError?.call(t,`Unable to load graph language pack`)}let{GraphEditor:r}=yield import(`@interactiveplatform/movika-graph-editor`);t.ngEditor=new r(t.graphWrapperElement,{mode:`view`,lang:t.lang===`ru`?`ru`:`en`,translation:n}),t.currentManifestId=t.manifest.metadata.id,t.ngEditor.update(t.manifest),t.ngEditor.setVisitedChapters(Array.from(t.visitedChapterIds)),t.currentChapterId&&t.ngEditor.selectChapter(t.currentChapterId),t.ngEditor.on(`control`,n=>{let{name:r}=n,i=c(n,e);r===`openPreview`&&`chapterId`in i&&t.onOpenPreviewClick?.call(t,i.chapterId)}),t.ngEditor.on(`zoom`,t.handleZoomChange),t.isReady=!0})()}hide(){this.graphWrapperElement.style.display=`none`,this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function It(e){let t=document.createElement(`div`);return t.style.position=`absolute`,t.style.top=`0`,t.style.left=`0`,t.style.height=`100%`,t.style.width=`100%`,t.style.display=`none`,e.append(t),t}var Lt=3e3;class Rt{constructor(){a(this,`_containers`,[]),a(this,`_player`,null),a(this,`setPlayer`,e=>{this._player=e}),a(this,`setContainers`,e=>{this._containers=e}),a(this,`deleteContainer`,e=>{this._containers=this._containers.filter(t=>t.id!==e)}),a(this,`getNextInteractiveTime`,(e=Lt)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,r=Math.round(this._player.info.position$.getValue()*1e3);for(let i of this._containers){let a=i.startTime-e;if(a<=r&&(i.endTime&&r<=i.endTime||i.endTime===null)){n=!0;break}r<a&&(t=t===-1?a:Math.min(t,a))}return!n&&t!==-1?t:null})}}class zt{constructor(){a(this,`listeners`,{})}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let e=n.length;e>0;e--)if(n[e]===t){n.splice(e,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(e=>{e(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}}class Bt{constructor(e){a(this,`raf`,void 0),a(this,`fn`,void 0),a(this,`fns`,[]),a(this,`addFn`,(e,t=!1)=>{ne(e)&&(this.fns.push(e),t&&this.updateFn())}),a(this,`removeFn`,(e,t=!1)=>{this.fns=this.fns.filter(t=>t!==e),t&&this.updateFn()}),a(this,`updateFn`,()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}}),a(this,`forceRequestAnimation`,()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))}),a(this,`requestAnimation`,()=>{this.raf||this.forceRequestAnimation()}),a(this,`cancelAnimation`,()=>{this.raf&&=(cancelAnimationFrame(this.raf),void 0)}),e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}import{objectEntries as Vt}from"@vkontakte/videoplayer-shared/es2015";class Ht{constructor(e){a(this,`rootElement`,void 0),a(this,`isCssVarsSupported`,void 0),a(this,`rootElementProps`,{}),this.rootElement=e,this.isCssVarsSupported=Ht.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t=`--test-key`,n=`test`;e.style.setProperty(t,n);let r=e.style.getPropertyValue(t)===n;return r&&e.style.removeProperty(t),r}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??``}setup(e){if(this.rootElementProps=o(o({},this.rootElementProps),e),this.isCssVarsSupported)for(let[t,n]of Vt(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}}import{ValueSubject as Ut}from"@vkontakte/videoplayer-shared/es2015";class Wt{constructor(e){a(this,`loaders`,void 0),this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}exec(e,t){var n=this;return s(function*(){return Gt(...n.loaders[e])(t)})()}}function Gt(...e){return function(){var t=s(function*(t){let n=[...e];for(;n.length>0;)t=yield n.shift()(t);return t});function n(e){return t.apply(this,arguments)}return n}()}function Kt(e,t,n){return e?o(o({},e),{},{[t]:e[t]?[n,...e[t]]:[n]}):{[t]:[n]}}function qt(e){let{actions:n,errors:r,chapterId:i}=e,a=c(e,t);if(i){let e=n.getManifest();if(e){let t=n.getChapter(e.chapters,i);if(t){let i=n.getMedia(e.media,t.videoId),s=n.getGraph(e.graph,t.id);return i?o(o({},a),{},{actions:n,errors:r,result:{chapter:t,media:i,graph:s}}):o(o({},a),{},{errors:Kt(r,qt.name,`Could not find media`),actions:n})}}}return o(o({},a),{},{errors:Kt(r,qt.name,`Could not find chapter`),actions:n})}import{fetchPolyfilled as Jt}from"@vkontakte/videoplayer-shared/es2015";var Yt=(e=``,t=``)=>{let n=e.split(`.`),r=t.split(`.`),i=0;for(let e=0;e<Math.max(n.length,r.length)&&!i;e++)i=n[e]>r[e]?1:n[e]<r[e]?-1:0;return i},Xt=function(){var e=s(function*(e){try{let t={},n;if(ee(e)){n=new URL(e).href;let r=yield Jt(n);if(!r.ok)return{};t=yield r.json()}else if(T(e))t=e;else return{};if(!Me(t))return{};let r=t.metadata.media;if(ee(r)&&!(`media`in t))try{let e;n?e=new URL(r,n).href:(e=new URL(r).href,n=e);let i=yield Jt(e);if(!i.ok)throw Error();t.metadata.media=yield i.json()}catch{return an(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:n}}catch{return{}}});return function(t){return e.apply(this,arguments)}}();function Zt(e){return Qt.apply(this,arguments)}function Qt(){return Qt=s(function*(e){let{manifest:t,manifestURL:n}=yield Xt(e);if(!t)throw Error(`Failed on fetch`);let r=Ae(t);return r.media=nn(r.media,n),delete r.metadata.media,r}),Qt.apply(this,arguments)}function $t(e,t){if(t)return e.find(e=>e.id===t)}function en(e,t){if(e.edit?.chapters)return e.edit.chapters.find(e=>e.id===t);if(e.view?.chapters)return e.view.chapters.find(e=>e.id===t)}function tn(e,t){return e.videos.find(e=>e.id===t)}function nn(e,t){return o(o({},e),{},{videos:e.videos.map(e=>o(o({},e),{},{variants:e.variants.map(e=>{let n=`url`in e?e.url:``,r=rn(n,t);return o(o({},e),{},{url:r||n})})}))})}function rn(e=``,t){try{return new URL(e,t).href}catch{return``}}function an(e){return Yt(e,`3.2.0`)>=0}class on extends Wt{constructor(e,t){super(e),a(this,`manifest`,null),a(this,`chapter`,null),a(this,`media`,null),a(this,`graph`,null),a(this,`prevChapter$`,new Ut(null)),a(this,`onError`,void 0),this.onError=t,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(e){var t=this;return s(function*(){t.release();let n=yield t.exec(`manifestLoaders`,{actions:{addErrorMessage:Kt},result:null,errors:null,source:e});return n.errors&&t.errorHandler(n.errors),t.manifest=yield Zt(n.result??e),t})()}setInitial(){var e=this;return s(function*(){return e.setNext()})()}setNext(){var e=this;return s(function*(t=this.manifest?.metadata.initChapterId){if(!t)return e;e.prevChapter$.next(e.chapter);let n=yield e.exec(`chapterLoaders`,qt({actions:{getManifest:()=>e.manifest,getCurrent:e.getCurrent,getGraph:en,getChapter:$t,getMedia:tn,getByBranches:e.getByBranches.bind(e),addErrorMessage:Kt},result:null,errors:null,chapterId:t}));return n.errors&&e.errorHandler(n.errors),n.result&&(e.chapter=n.result.chapter,e.media=n.result.media,e.graph=n.result.graph),e}).apply(this,arguments)}errorHandler(e){this.onError(e),console.error(`Something went wrong with loaders`,{errors:e})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(e=this.manifest?.metadata.initChapterId){if(!e||!this.manifest)return null;let t=$t(this.manifest.chapters,e);if(t){let e=tn(this.manifest.media,t.videoId),n=en(this.manifest.graph,t.id);if(e)return{chapter:t,media:e,graph:n}}return null}getBranches(e=this.chapter?.id){if(e===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let t=$t(this.manifest?.chapters||[],e);return this.getByBranches(t?.branches)}}getByBranches(e=[]){return e.reduce((e,t)=>{let n=this.getByChapterId(t.chapterId);return n&&e.push(n),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?P(this.chapter):!1}}import{objectValues as sn}from"@vkontakte/videoplayer-shared/es2015";import{Player as cn}from"@vkontakte/videoplayer-core/es2015";import{Subscription as ln,TracerFactory as un,ValueSubject as dn}from"@vkontakte/videoplayer-shared/es2015";var fn=e=>{let t=e.variants.find(e=>e.payload?.type===`vk`);if(t&&t.payload){let[e,n]=t.payload.id.split(`_`);return[e,n]}return[]};import{objectValues as pn}from"@vkontakte/videoplayer-shared/es2015";function mn(){let e=new Map;function t(t){let{listId:r=Math.random().toString(),itemId:i=Math.random().toString()}=t,a=c(t,n),s=e.get(r),l=o({},a);return s?s[i]=l:e.set(r,{[i]:l}),o({listId:r,itemId:i},a)}function r(e){e.player.destroy(),e.container.remove(),e.subscription.unsubscribe(),e.statistics?.oneStat.destroy(),e.statistics?.statSubscription.unsubscribe()}function i(t,n){let i=e.get(t);if(!i)throw Error(`Can't remove. Not find.`);if(n){let a=i[n];a&&r(a),delete i[n],Object.keys(i).length||e.delete(t)}else{for(let e of pn(i))r(e);e.delete(t)}}function a(){for(let t of e)i(t[0])}return{createPlayer:t,removePlayer:i,map:e,removeAll:a}}import{arrayIncludes as W}from"@vkontakte/videoplayer-shared/es2015";function hn(e,t=[]){let n={},r,i=!t.length;for(let a of e.variants)if(!r&&`cover`in a&&(r=a.cover),`url`in a)switch(a.type.toLowerCase()){case`mp4`:(i||W(t,`mp4`))&&(n.MPEG=o(o({},n.MPEG),{},{[a.standard??`Invariant quality`]:a.url}));break;case`mpeg`:(i||W(t,`mpeg`))&&(n.MPEG=o(o({},n.MPEG),{},{[a.standard??`Invariant quality`]:a.url}));break;case`hls`:(i||W(t,`hls`))&&(n=o(o({},n),{},{HLS:{type:`url`,url:a.url}}));break;case`dash`:(i||W(t,`dash`))&&(n=o(o({},n),{},{DASH_SEP:{compatibilityMode:!0,type:`url`,url:a.url}}));break;default:break}return{sources:n,thumbUrl:r,title:e.title??``}}var gn=(e,t)=>{let n=e.info.currentQuality$.getValue(),r=e.info.availableQualities$.getValue();n!==t&&W(r,t)&&(e.setQuality(t),e.setAutoQuality(!1))},_n=2;function vn(e){let t=mn(),n=new ln,r={},i=null,a=!1,c,l=new dn(null);e&&u(e);function u(e){i=e}function d(e,n,s){if(!i)throw Error(`need to set interactive controller`);if(!i.options)return;let c=(t.map.get(e)??{})[n];if(c){r=o({chapterId:s,listId:e,itemId:n},c);let u=r.player;r.subscription.add(u.info.currentQuality$.subscribe(e=>{let n=u.info.position$.getValue(),r=u.info.isAutoQualityEnabled$.getValue();if(!(!e||!n||r))for(let n of t.map)sn(n[1]).forEach(({player:t})=>{gn(t,e)})})).add(u.events.started$.subscribe(()=>{f(n)})),c.container.remove(),i.setPlayer(c.player),a||=(i.init(),!0),l.next({player:r.player,config:r.config,statistics:r.statistics});return}throw Error(`Can't set. Not find.`)}function f(e){return p.apply(this,arguments)}function p(){return p=s(function*(e){if(!i)throw Error(`need to set interactive controller`);if(D(r)||e!==r.itemId)return;let t=i.getChapterBranches(),n=new Set;for(let e of t)n.has(e.media.id)||(yield g({media:e.media,chapterId:e.chapter.id,setAsActive:!1,title:e.chapter.label}),n.add(e.media.id))}),p.apply(this,arguments)}function m(e){return h.apply(this,arguments)}function h(){return h=s(function*({chapter:{id:e},manifestVideo:n}){if(D(r)||!i)return;let a=r.player.info.muted$.getValue(),o=r.player.info.currentQuality$.getValue(),s=r.player.info.isAutoQualityEnabled$.getValue(),c=r.player.info.volume$.getValue(),l=r.player.info.currentPlaybackRate$.getValue(),u=!s,f=!1;for(let s of t.map)if(s[0]===n.id&&!i.state.isReplay$.getValue()){let n=Object.keys(s[1]);for(let i of n)i===r.itemId?(n.length<_n||(f=!0),t.removePlayer(s[0],i)):(f=!0,d(s[0],i,e),u?gn(r.player,o):r.player.setAutoQuality(!0),r.player.setVolume(c),r.player.setMuted(a),r.player.setPlaybackRate(l))}else t.removePlayer(s[0]);f||(yield g({media:n,chapterId:e,setAsActive:!0,playbackRate:l}),u?gn(r.player,o):r.player.setAutoQuality(!0),r.player.setVolume(c),r.player.setMuted(a))}),h.apply(this,arguments)}function g(e){return _.apply(this,arguments)}function _(){return _=s(function*({media:e,chapterId:n,prefetch:a=!0,setAsActive:s=!0,autoplay:l=!1,preferredExt:u,title:f,playbackRate:p}){var m,h,g,_;let v=Math.random().toString(),y=document.createElement(`div`);c.append(y);let b;if(!(i==null||(m=i.options)==null)&&m.vkVideoLoader){let t=fn(e);t.length&&(b=yield i.options.vkVideoLoader(...t))}let x=o({},(i==null||(h=i.options)==null?void 0:h.coreConfig)||void 0),S=o(o({container:y,sources:hn(e,u).sources},b==null||(g=b.videos)==null?void 0:g[0]),{},{title:f,failoverHosts:b?.failoverHosts||[]}),C=new cn(x,un.createRootTracer());C.initVideo(S);let w=null;if(b?.videos&&i?.options.createOneStat){let e=b.videos[0],t=i.options.createOneStat(e),n=new ln;t&&(n.add(t.attachTo(C)),w={oneStat:t,statSubscription:n})}let T=new ln,ee=r==null||(_=r.player)==null?void 0:_.info.isAutoQualityEnabled$.getValue();T.add(C.events.canplay$.subscribe(function(){ee||gn(C,r.player.info.currentQuality$.getValue()),p&&C.setPlaybackRate(p)}));let E=t.createPlayer({listId:e.id,itemId:v,player:C,container:y,sources:hn(e,u).sources,config:S,subscription:T,statistics:w});return s&&d(e.id,E.itemId,n),l&&E.player.play(),a&&!l&&E.player.prepare(),{player:E.player,config:E.config,statistics:E.statistics}}),_.apply(this,arguments)}function v(){y(),i=null,c.remove()}function y(){n.unsubscribe(),t.removeAll(),r={},a=!1}function b(){return x.apply(this,arguments)}function x(){return x=s(function*(){if(!i)throw Error(`need to set interactive controller`);y(),c=document.createElement(`div`);let{media:e,chapter:t}=i.getCurrentChapter();e&&t?(n.add(i.events.chapterChanged$.subscribe(m)),yield g({media:e,chapterId:t.id,title:t.label})):console.error(`not found`)}),x.apply(this,arguments)}return{map:t.map,removePlayer:t.removePlayer,init:b,setInteractiveController:u,createPlayer:g,removeAll:v,getActivePlayer:function(){return r},activePlayerChanged:l}}var G={graph:`graph`,interactives:`interactives`,chapterChanged:`chapter-changed`,playerChanged:`player-changed`,manifestChanged:`manifest-changed`,errors:`errors`,eachTick:`eachTick`,historyInited:`history-inited`,historyDestroyed:`history-destroyed`},yn={visibility:`visibility`,watchAgainClicked:`watchAgainClicked`},K={actionChoiceCanceled:`action-choice-canceled`,actionChoice:`action-choice`,actionExecution:`action-execution`,visibility:`visibility`,containerRemoved:`container-removed`,rangeEnded:`range-ended`};import{Subscription as bn}from"@vkontakte/videoplayer-shared/es2015";function xn(e){return function(...t){return e(...t.reverse())}}function Sn(e,...t){return(...n)=>T(t[0])&&T(n[0])?e(o(o({},t[0]),n[0])):e(...t,...n)}class Cn{constructor({player:e,container:t,branches:n,selectBranches:r,interactiveEvents:i,globalEvents:o,globalEventEmitter:s,getContainerEventState:c,permanentTextControls:l,interactiveTimeOpenUri:u,disabledControls$:d,onRemove:f,onError:p,disableTextControlContainerVisibilityEvents:m=!1,features:h}){a(this,`container`,void 0),a(this,`branches`,void 0),a(this,`selectBranches`,void 0),a(this,`subscription`,void 0),a(this,`player`,void 0),a(this,`interactiveEvents`,void 0),a(this,`getContainerEventState`,void 0),a(this,`isPermanentText`,void 0),a(this,`interactiveTimeOpenUri`,void 0),a(this,`disabledControls$`,void 0),a(this,`onRemove`,void 0),a(this,`globalEventEmitter`,void 0),a(this,`gameState`,void 0),a(this,`isSelectedControlEvent`,void 0),a(this,`isSelectedContainerEvent`,void 0),a(this,`globalEvents`,void 0),a(this,`onError`,void 0),a(this,`disableTextControlContainerVisibilityEvents`,void 0),a(this,`features`,void 0),a(this,`hide`,()=>{setTimeout(()=>{if(this.gameState!==4&&!(We(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect)){if(this.gameState!==2){var e;(e=this.container).hide?.call(e)}this.emitContainerVisibilityEvent(!1)}})}),a(this,`show`,()=>{if(!(this.gameState!==2||this.isSelectedControlEvent))if(this.container.getElement()){var e;let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if((e=this.container).show?.call(e),this.interactiveTimeOpenUri&&t||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let e={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(e,t)=>{let{isExpectTime:n,hasOtherExpect:r,hasOpenURIEvent:i,hasOpenURIEventInCurrentContainer:a,isAllOpenURIEventsValid:o,hasShouldOpenNowEvent:s}=this.getContainerEventState(),c=this.interactiveTimeOpenUri&&!a,l=this.interactiveTimeOpenUri&&a;if((!this.interactiveTimeOpenUri||c)&&(this.isSelectedControlEvent=!0),e!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||c)){if(this.interactiveTimeOpenUri){let e=!r&&!o&&a;e&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-fake-removed`,removeAllOpenURI:e})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&i&&this.gameState!==5){if(l){let e=((e,t,n,r)=>!e&&!t&&n||e&&!t&&n&&!r||e&&!t&&n&&r)(n,r,o,this.isSelectedContainerEvent);this.fakeRemoveView(e)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!n||!r||!s)&&(this.selectBranches.stopExpect(),t())}},isEOV:()=>this.gameState===4},n=Sn(this.selectBranches.onControlEvent,e),r=(this.player?.info.duration$.getValue()??1/0)*1e3;if(this.container.createView({eventCallback:n,videoDurationMs:r}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()){var t;(t=this.container).disable?.call(t)}}}),a(this,`onEndOfVideo`,()=>{this.gameState=4,this.selectContainerEvent(!0)}),a(this,`whilePlaying`,()=>{let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||=e instanceof HTMLObjectElement&&e?.getAttribute(`type`)===`application/avplayer`),!(t&&e?.readyState)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(He(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Ue(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let e=this.gameState;this.gameState=3,e===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:e}=this.getContainerEventState(),t=this.selectBranches.state.isExpect,n=this.interactiveTimeOpenUri&&e;if(n&&!t){let e=this.container.getElement();if(e){if(e.style.visibility!==`hidden`){var r;(r=this.container).hide?.call(r)}this.container.isRemoved||this.fakeRemoveView()}}!this.isPermanentText&&!n&&this.removeView()}let i=Ue(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],o={subjectId:this.container.container.id,subjectName:`container`,range:a,currentTime:n,isInteractiveTime:i};this.container.onProgress(n*1e3,i),this.globalEventEmitter.emit(G.eachTick,o),this.globalEvents.eachTick$.next(o)}),this.container=t,this.branches=n,this.selectBranches=r,this.subscription=new bn,this.player=e,this.interactiveEvents=i,this.getContainerEventState=c;let g=qe(t.container.controls);this.isPermanentText=l&&g,this.disableTextControlContainerVisibilityEvents=m&&g,this.interactiveTimeOpenUri=u,this.disabledControls$=d,this.onRemove=f,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=o,this.onError=p,this.features=h,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(G.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:K.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:`container`,type:`visibility`,visibility:e,isFirst:t})):(this.globalEventEmitter.emit(G.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:K.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:`container`,type:`visibility`,visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{if(e){var t;(t=this.container).disable?.call(t)}else{var n;(n=this.container).enable?.call(n)}})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:We(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e;(e=this.container).hide?.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(G.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:K.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-removed`}),this.gameState=5,this.onRemove?.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-fake-removed`,removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}}var wn=(e=[])=>e.reduce((e,t,n)=>{if(Be((t?.controls??[]).filter(e=>!Ne(e)))){let r=[t.startTime??0,t.endTime??1/0],i={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[i],range:r});else{let t=[],n=-1/0,a=1/0,o=[],s=[];for(let c=0;c<e.length;c++){let l=e[c];if(s.push(...l.subjects),l.range[0]<a&&(a=l.range[0]),l.range[1]>n&&(n=l.range[1]),r[0]>=l.range[0]&&r[1]<=l.range[1])return e[c].subjects.push(i),e;r[0]<l.range[0]&&r[1]>l.range[0]&&(t.push(c),o=o.concat(l.subjects)),r[0]>=l.range[0]&&r[0]<=l.range[1]&&(t.push(c),o=o.concat(l.subjects),r[0]=l.range[0]),r[1]>=l.range[0]&&r[1]<=l.range[1]&&(t.push(c),o=o.concat(l.subjects),r[1]=l.range[1])}if(s.push(i),r[0]<=a&&r[1]>=n)return[{subjects:s,range:r}];t.length&&t.reverse().forEach(t=>{e.splice(t,1)}),e.push({subjects:o.concat([i]),range:r})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);import{arrayIncludes as Tn}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as En}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlat as Dn}from"@vkontakte/videoplayer-shared/es2015";function On(){let e={};function t(){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t]}function n(t){let n={};for(let r in e)+r<=t&&(n[r]=e[r]);return n}function i(t){let n={};for(let r in e)+r>=t&&(n[r]=e[r]);return n}function a({timestamp:t,priority:n,initiator:r}){if(ie(t)){let i=e[t]??null;if(i&&n&&oe(n,!0)){let e={},t=i[n];return t&&(e=o(o({},e),t)),e=D(e)?null:e,e&&oe(r,!0)?e[r]??null:e}return i}return null}function s({timestamp:t,priority:n,initiator:r}){if(ie(t))if(e[t]){if(n&&oe(n,!0))if(e[t][n]){if(r&&oe(r,!0))if(e[t][n][r]){if(delete e[t][n][r],!D(e[t][n]))return!0}else return!1;if(delete e[t][n],!D(e[t]))return!0}else return!1;return delete e[t]}else return!1;return!1}function l(t){var n;let{timestamp:i,priority:a,initiator:s}=t,l=c(t,r);!((n=e[i])==null||(n=n[a])==null)&&n[s]?e[i][a][s].push(o({},l)):e[i]?.[a]?e[i][a]=o(o({},e[i][a]),{},{[s]:[o({},l)]}):e[i]?e[i]=o(o({},e[i]),{},{[a]:{[s]:[o({},l)]}}):e[i]={[a]:{[s]:[o({},l)]}}}return{map:e,remove:s,add:l,removeAll:t,get:a,getLte:n,getGte:i}}var kn=[N.expect,N.setNextBranch],An=1/0;function jn(e,t){let n=e,r,i=Mn(t),a=On(),o,s=()=>{p(),_()},c=e=>{a.add.call(void 0,e),m()},l=(e=[])=>{for(let t of e)if(t.action(),Tn(kn,t.actionType))break},u=(e=1/0)=>{let t=Nn(a.get({timestamp:e,priority:`control`})??{}),n=Nn(a.get({timestamp:e,priority:`container`})??{}),r=Nn(a.get({timestamp:e,priority:`chapter`})??{});return[...t,...n,...r]},d=e=>{i.isReady(e)&&l(u(e))},f=()=>{l([...Nn(a.get({timestamp:1/0,priority:`chapter`})??{})])},p=()=>{r&&=(o?.unsubscribe(),void 0)},m=()=>{r||(r=()=>setTimeout(()=>{d(1/0)}),o=n.events.ended$.subscribe(r))},h=e=>{p(),n=e},g=e=>{e.priority===`container`&&i.resetCalled(e.timestamp),a.remove(e)},_=()=>{i.release(),a.removeAll()};return{setPlayer:h,add:c,remove:g,exec:d,execEndOfVideo:f,listen:m,unlisten:p,release:s,containersEventsCallState:i,getPreparedToExecActions:u}}function Mn(e){let t=new Map;return{setCalled:({timestamp:e,id:n})=>{let r=t.get(e);r&&r[n]!==void 0&&(r[n]=!0)},setData:(e=[])=>{for(let n of e){let e=n.endTime??An,r=t.get(e);t.set(e,o(o({},r),{},{[n.id]:!1}))}},resetCalled:e=>{let n=t.get(e);if(n)for(let e in n)n[e]=!1},isReady:n=>{let r=t.get(n);if(!r)return!0;let i=En(r);return e?i.some(e=>e):!i.some(e=>!e)},release:()=>t.clear()}}function Nn(e){return Dn(En(e)).sort(e=>e.actionType===N.expect?-1:1)}var Pn={videoContentHeight:0,videoContentWidth:0},Fn=e=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return Pn;let{clientHeight:r,clientWidth:i}=e.experimental.element$.getValue()||{};if(!(r&&i))return Pn;let a=t/n,o=r/i,s,c;return o>a?(c=i,s=i*a):o<a?(c=r/a,s=r):(c=i,s=r),{videoContentWidth:c,videoContentHeight:s}},In=250;function Ln(e){let t,n=new ResizeObserver(e=>{a(e),t=a.bind(null,e)});function r(t){let{parentElement:n,player:r,cssVarsManager:i}=e();if(!n||!r)return;let{videoContentWidth:a,videoContentHeight:o}=Fn(r);i.setup({"--interactive-content-width":`${a}px`,"--interactive-content-height":`${o}px`,"--interactive-width":`${t[0].contentRect.width}px`,"--interactive-height":`${t[0].contentRect.height}px`})}function i(){let{parentElement:t}=e();t.removeAttribute(`style`)}let a=jt(t=>{let{fns:n=[]}=e();r(t);for(let e of n)e()},In);function o(){t=void 0,n.disconnect(),i()}return{resizeObserver:n,calc:()=>{t?.()},release:o}}var Rn=e=>Math.floor(Math.random()*e),zn=e=>{let t=e.length,n=1/0,r=null;for(;t--;){let i=e[t],a=i.weight??1;a<n&&(n=a,r=i)}return r},Bn=e=>{let t=e.length,n=-1/0,r=null;for(;t--;){let i=e[t],a=i.weight??0;a>n&&(n=a,r=i)}return r},Vn=e=>{let t=e.length;return e[Rn(t)]},Hn=1,Un=e=>{let t=0;for(let n=0;n<e.length;++n)t+=e[n].weight??Hn;let n=Math.random()*t;t=0;for(let r=0;r<e.length-1;++r)if(t+=e[r].weight??Hn,t>=n)return e[r];return e[e.length-1]},Wn={shouldOpenNow:!0,isDetachContainer:!0},Gn=`after-expect`,Kn=(e,t=!1)=>o(o({},e),{},{args:t?o(o({},e.args),Wn):o(o({},Wn),e.args)}),qn=({globalEventEmitter:e,globalEvents:t,player:n,interactiveEvents:r})=>{let i={isExpect:!1},a=()=>{i.isExpect&&=!1},s=({action:n,controlType:i,controlId:a,containerId:s,branches:c=[],onEvent:l,isEOV:u=()=>!1,isDisabled:f=()=>!1})=>{let p=Kn(n,u()),v={timestamp:1/0,priority:`control`,initiator:a,actionType:p.type},b=f(),x=e.emit.bind(e,G.interactives,{subjectId:a,subjectType:i,subjectName:`control`,type:b?K.actionChoiceCanceled:K.actionChoice,actionType:n.type,payload:o({invokeImmediately:p.args.shouldOpenNow,containerId:s},p.args)}),S=()=>{t.interactiveActionChoice$.next({subjectId:a,subjectType:i,subjectName:`control`,type:b?`action-choice-canceled`:`action-choice`,actionType:n.type,payload:o({invokeImmediately:p.args.shouldOpenNow,containerId:s},p.args)})};if(b){x(),S();return}switch(p.type.trim().toLowerCase()){case N.setNextBranch.trim().toLowerCase():{let e=c.find(e=>e.id===p.args.branchId);if(!e)return;l(p.args.isDetachContainer,m.bind(null,{subjectId:a,subjectName:`control`})),x(),S(),p.args.shouldOpenNow?g({subjectId:a,subjectName:`control`,subjectType:i,action:p,payload:{chapterId:e.chapterId,autoSelect:!1}}):r.add(o(o({},v),{},{action:g.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:p,payload:{chapterId:e.chapterId,autoSelect:!1}})}));return}case N.continuePlayback.trim().toLowerCase():l(p.args.isDetachContainer,m.bind(null,{subjectId:a,subjectName:`control`})),x(),S(),p.args.shouldOpenNow?h({subjectId:a,subjectName:`control`,subjectType:i,action:n}):r.add(o(o({},v),{},{action:h.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:n})}));return;case N.openURI.trim().toLowerCase():l(p.args.isDetachContainer,m.bind(null,{subjectId:a,subjectName:`control`})),x(),S(),p.args.shouldOpenNow?_({subjectId:a,subjectName:`control`,subjectType:i,action:p,payload:{URI:n.args.uri}}):r.add(o(o({},v),{},{action:_.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:p,payload:{URI:n.args.uri}})}));return;default:{let e=`Unexpected control event`;d(new y(1,1,{message:e}),e);return}}},c=({action:n,container:{id:i,endTime:a},branches:s=[],isEOV:c=!1,autoSelected:l=!1})=>{let u=Kn(n,c),f={timestamp:!u.args.shouldOpenNow||c?1/0:a??1/0,priority:`container`,initiator:i,actionType:u.type},p=e.emit.bind(e,G.interactives,{subjectId:i,subjectName:`container`,type:K.actionChoice,actionType:u.type,payload:o({invokeImmediately:u.args.shouldOpenNow},u.args)}),m=()=>{t.interactiveActionChoice$.next({subjectId:i,subjectName:`container`,type:`action-choice`,actionType:u.type,payload:o({invokeImmediately:u.args.shouldOpenNow},u.args)})};switch(u.type.trim().toLowerCase()){case N.setNextBranch.trim().toLowerCase():{let e=s.find(e=>e.id===u.args.branchId);if(!e)return;p(),m(),r.add(o(o({},f),{},{action:g.bind(null,{subjectId:i,subjectName:`container`,action:u,payload:{chapterId:e.chapterId,autoSelect:l}})}));return}case N.setMaxWeightBranch.trim().toLowerCase():return;case N.setMinWeightBranch.trim().toLowerCase():return;case N.setRandomBranch.trim().toLowerCase():return;case N.setWeightlessRandomBranch.trim().toLowerCase():return;case N.continuePlayback.trim().toLowerCase():p(),m(),r.add(o(o({},f),{},{action:h.bind(null,{subjectId:i,subjectName:`container`,action:u})}));return;case N.openURI.trim().toLowerCase():p(),m(),r.add(o(o({},f),{},{action:_.bind(null,{subjectId:i,subjectName:`container`,action:u,payload:{URI:n.args.uri}})}));return;default:{let e=`Unexpected container event`;d(new y(1,1,{message:e}),e);return}}};function l({container:n,branches:a,isEOV:s=!1}){let l=Ge(n.events);if(l){let a=Kn(l.action,s);e.emit(G.interactives,{subjectId:n.id,subjectName:`container`,type:K.actionChoice,actionType:a.type,payload:o({invokeImmediately:a.args.shouldOpenNow},a.args)}),t.interactiveActionChoice$.next({subjectId:n.id,subjectName:`container`,type:`action-choice`,actionType:a.type,payload:o({invokeImmediately:a.args.shouldOpenNow},a.args)}),r.add({timestamp:s?1/0:n.endTime??1/0,priority:`container`,initiator:n.id,actionType:N.expect,action:p.bind(null,{subjectId:n.id,subjectName:`container`})}),i.isExpect=!0}else for(let e of n.events??[])c({action:e.action,container:n,branches:a,isEOV:s})}let u=({chapterId:n,action:r,branches:i=[]})=>{let a=e.emit.bind(e,G.interactives,{subjectId:n,subjectName:`chapter`,type:K.actionChoice,actionType:r.type,payload:r.args}),o=()=>{t.interactiveActionChoice$.next({subjectId:n,subjectName:`chapter`,type:`action-choice`,actionType:r.type,payload:r.args})};switch(r.type.trim().toLowerCase()){case N.setNextBranch.trim().toLowerCase():{let e=i.find(e=>e.id===r.args.branchId);return e?.chapterId?(a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case N.setWeightlessRandomBranch.trim().toLowerCase():{let e=Vn(i);return e?.chapterId?(a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case N.setRandomBranch.trim().toLowerCase():{let e=Un(i);return e?.chapterId?(a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case N.setMaxWeightBranch.trim().toLowerCase():{let e=Bn(i);return e?.chapterId?(a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case N.setMinWeightBranch.trim().toLowerCase():{let e=zn(i);return e?.chapterId?(a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case N.continuePlayback.trim().toLowerCase():return a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r});case N.openURI.trim().toLowerCase():return a(),o(),_.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{URI:r.args.uri}});default:{let e=`Unexpected chapter event`;d(new y(1,1,{message:e}),e);return}}};function d(n,r){console.error(r),t.error$.next(n),e.emit(G.errors,n)}function f(n){let i=Ge(n.events);if(i){if(P(n))return;e.emit(G.interactives,{subjectId:n.id,subjectName:`chapter`,type:K.actionChoice,actionType:i.action.type,payload:i.action.args}),t.interactiveActionChoice$.next({subjectId:n.id,subjectName:`chapter`,type:`action-choice`,actionType:i.action.type,payload:i.action.args}),r.add({timestamp:1/0,priority:`chapter`,initiator:n.id,actionType:N.expect,action:p.bind(null,{subjectId:n.id,subjectName:`chapter`})})}else n.events?.forEach(e=>{let t=u({chapterId:n.id,action:e.action,branches:n.branches});t&&r.add({timestamp:1/0,priority:`chapter`,initiator:n.id,actionType:e.action.type,action:t})})}let p=({subjectId:r,subjectName:i})=>{n.pause(),e.emit(G.interactives,{subjectId:r,subjectName:i,type:K.actionExecution,actionType:N.expect}),t.interactiveActionExecution$.next({subjectId:r,subjectName:i,type:`action-execution`,actionType:N.expect})},m=({subjectId:i,subjectName:a})=>{n.info.isEnded$.getValue()?r.execEndOfVideo():n.play(),e.emit(G.interactives,{subjectId:i,subjectName:a,type:K.actionExecution,actionType:Gn}),t.interactiveActionExecution$.next({subjectId:i,subjectName:a,type:`action-execution`,actionType:Gn})},h=({subjectId:n,subjectName:r,subjectType:i,action:a})=>{e.emit(G.interactives,{subjectId:n,subjectName:r,subjectType:i,type:K.actionExecution,actionType:a.type}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type})},g=({subjectId:n,subjectName:r,subjectType:i,action:a,payload:o})=>{o.behaviour=`change-chapter`,e.emit(G.interactives,{subjectId:n,subjectName:r,subjectType:i,type:K.actionExecution,actionType:a.type,payload:o}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type,payload:o})},_=({subjectId:n,subjectName:r,subjectType:i,action:a,payload:o})=>{if(!o.URI)return;let s=window.open(o.URI,`_blank`,`noopener,noreferrer`);s&&(s.opener=null),e.emit(G.interactives,{subjectId:n,subjectName:r,subjectType:i,type:K.actionExecution,actionType:a.type}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type})};return{onControlEvent:s,onContainerEvent:c,onChapterEvent:u,onExpectEvent:p,expectEventHandler:m,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:a,state:i}};import{Subscription as Jn,Subject as Yn,ValueSubject as q}from"@vkontakte/videoplayer-shared/es2015";var Xn=(e,t)=>{let n={};return e.map(e=>{if(!n[e]){let r=t.chapters.find(t=>t.id===e);if(!r)return null;let i=t.media.videos.find(e=>r.videoId===e.id);if(!i)return null;n[e]=$n(i)}return n[e]}).filter(e=>e!==null)},Zn=e=>{for(let t of e.variants)if(Qn(t)&&t.payload)return t.payload.id},Qn=e=>!!(e.type===`custom`&&e.payload&&e.payload.type===`vk`),$n=e=>{let t=Zn(e);if(!t)return null;let n=t.split(`_`).pop();return n?parseInt(n,10):null},er=(e,t)=>{for(let n of e.media.videos)if(t===$n(n)){for(let t of e.chapters)if(t.videoId===n.id)return t.id;return}},tr=(e,t)=>e.reduce((e,n)=>{let r=er(t,n);return r?[...e,r]:e},[]),J=new WeakMap,Y=new WeakMap,nr=new WeakMap,X=new WeakMap,rr=new WeakMap,Z=new WeakMap,Q=new WeakMap,$=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap;class sr{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:r,settings:i}){a(this,`state`,{history$:new q([]),hasPrevChapter$:new q(!1),prevChapter$:new q(null),isInitialChapter$:new q(!1),isGoBackLimited$:new q(!1)}),l(this,J,null),l(this,Y,void 0),l(this,nr,!1),l(this,X,null),l(this,rr,null),a(this,`events`,{inited$:new Yn,destroyed$:new Yn,error$:new Yn}),l(this,Z,null),l(this,Q,null),l(this,$,null),l(this,ir,new Jn),l(this,ar,!1),l(this,or,0),u(Z,this,t),u($,this,e),u(Q,this,n),u(J,this,r),u(Y,this,i),this.state.history$&&d(ir,this)&&d(ir,this)?.add(this.state.history$.subscribe(e=>{var t;this.state.prevChapter$.next(e.at(-2)||null),this.state.hasPrevChapter$.next(e.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((t=d(X,this))==null||(t=t.metadata)==null?void 0:t.initChapterId)),this.state.isGoBackLimited$.next(d(or,this)===d(Y,this).maxLength-1)}))}setManifest(e){var t=this;return s(function*(){if(!d(Q,t)||!d($,t))return;u(X,t,e),yield t.getProjectHistory();let n=t.getInitialChapterId();yield d(Q,t).setChapter({chapterId:n,pushToHistory:!1}),d(nr,t)||(u(nr,t,!0),t.events.inited$.next({initChapterId:n}))})()}get inited(){return d(nr,this)}updateHistory(e,t=!0){var n=this;return s(function*(){if(!d(X,n))return;if(d(ar,n)){var r;u(ar,n,!1),u(or,n,(r=d(or,n),r++,r))}else u(or,n,0);let i=d(X,n),a=e.length-d(Y,n).maxLength,o=a>0?e.slice(a):e,s=Xn(o,i);if(u(rr,n,s),n.state.history$.next(o),!(!t||!d(J,n)||!d(Z,n)))try{yield d(J,n).save(d(Z,n),s)}catch{let e=new y(1,5,`Unable to save interactive history`);n.events.error$.next(e),d($,n)?.emit(G.errors,e)}})()}goBack(){var e=this;return s(function*(){if(!e.state||!d(Q,e)){let t=new y(1,5,`Unable to save interactive history`);e.events.error$.next(t),d($,e)?.emit(G.errors,t);return}u(ar,e,!0);let t=e.state.history$.getValue().slice(0,-1),n=t.pop();e.state.history$.next(t),yield d(Q,e).setChapter({chapterId:n,playPrev:!0})})()}getProjectHistory(){var e=this;return s(function*(){if(!d(X,e)||!d(Z,e))return;let t=d(X,e),n=[e.getInitialVideoId()];if(d(J,e))try{let t=yield d(J,e).get(d(Z,e));t.length&&(n=t)}catch{let t=new y(1,5,`Error while trying to fetch data`);e.events.error$.next(t),d($,e)?.emit(G.errors,t)}let r=tr(n,t);e.state.history$.next(r)})()}getInitialChapterId(){return this.state.history$.getValue()?.at(-1)||d(Y,this).initChapterId||d(X,this)?.metadata.initChapterId}getInitialVideoId(){return d(X,this)?Xn([this.getInitialChapterId()],d(X,this)).pop():null}destroy(){u(Z,this,null),u(J,this,null),u(Q,this,null),d(ir,this)?.unsubscribe(),u(ir,this,null),u(nr,this,!1),d($,this)?.emit(G.historyDestroyed),this.events.destroyed$.next(),u($,this,null)}}class cr{constructor(){a(this,`rootElement`,void 0),a(this,`canvasImgSrc`,void 0),a(this,`_prevSizeId`,0),this.rootElement=document.createElement(`canvas`)}clear(){this.rootElement.getContext(`2d`)?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext(`2d`)?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let e=3;e<n;e+=40)if(t[e]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility=`visible`}hide(){this.rootElement.style.visibility=`hidden`}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext(`2d`)?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}updateCanvasDimensions(e,t=!1){var n=this;return s(function*(){let r=e.width+e.height;if(n._prevSizeId===r)return;let i;t&&(i=yield n.save()),n.rootElement.width=e.width,n.rootElement.height=e.height,t&&i&&n.restore(i),n._prevSizeId=r})()}save(){var e=this;return s(function*(){let t=e.rootElement.toDataURL(`image/jpeg`,1),n=new Image;return n.crossOrigin=`anonymous`,n.src=t,yield n.decode(),n})()}restore(e){this.rootElement&&this.rootElement.getContext(`2d`)?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}}class lr{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){a(this,`lastFrameCanvas`,void 0),a(this,`endOffsetMs`,void 0),a(this,`currentChapter`,void 0),a(this,`currentVideoDurationMs`,1/0),a(this,`rootElement`,void 0),a(this,`_containerTimeFrameShouldReceived`,!1),a(this,`_endTimeFrameReceived`,!1),a(this,`_shouldCallSkip`,!1),a(this,`_callbacks`,void 0),a(this,`onEachTick`,e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}}),a(this,`onSeek`,()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())}),this.rootElement=document.createElement(`div`),this.rootElement.style.cssText=`
|
|
7
|
+
position: absolute;
|
|
8
|
+
top: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
width: var(--interactive-width);
|
|
11
|
+
height: var(--interactive-height);
|
|
12
|
+
background-color: var(--black);
|
|
13
|
+
visibility: hidden;
|
|
14
|
+
`,this.lastFrameCanvas=new cr,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: 50%;
|
|
17
|
+
left: 50%;
|
|
18
|
+
transform: translate(-50%, -50%);
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility=`visible`}hide(){this.rootElement.style.visibility=`hidden`}updateCanvasDimensions(e=!1){var t=this;return s(function*(){t._containerTimeFrameShouldReceived||t._endTimeFrameReceived||(e=!1);let n=getComputedStyle(t.rootElement),r={width:parseInt(n.getPropertyValue(`--interactive-content-width`),10),height:parseInt(n.getPropertyValue(`--interactive-content-height`),10)};try{t.lastFrameCanvas.updateCanvasDimensions(r,e)}catch(e){t._onError(e)}})()}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return!!(this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs)}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(t=this._callbacks)==null||(n=t.onError)==null||n.call(t,e)}}function ur(e=0){return new Promise(t=>{setTimeout(()=>{t(0)},e)})}var dr=`/* interactive-container */
|
|
20
|
+
.interactive-container {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
visibility: visible;
|
|
23
|
+
transition: opacity var(--interactive-transition-1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.interactive-container-disabled {
|
|
27
|
+
opacity: 0.5;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.interactive-container-hidden {
|
|
31
|
+
visibility: hidden;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.interactive-container.interactive-container-before-remove.interactive-container-before-remove-delay {
|
|
35
|
+
transition-delay: var(--interactive-remove-delay);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.interactive-container.interactive-container-before-remove {
|
|
39
|
+
transition: opacity var(--interactive-transition-1);
|
|
40
|
+
opacity: 0;
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* blink-anim */
|
|
45
|
+
.interactive-control-blink-anim {
|
|
46
|
+
animation-duration: 2001ms;
|
|
47
|
+
animation-iteration-count: infinite;
|
|
48
|
+
animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.interactive-control-blink-anim-button {
|
|
52
|
+
animation-name: interactive-blinking-button;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.interactive-control-blink-anim-area {
|
|
56
|
+
animation-name: interactive-blinking-area;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@keyframes interactive-blinking-area {
|
|
60
|
+
0%, 100% {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
50% {
|
|
64
|
+
opacity: var(--interactive-area-hover-opacity);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@keyframes interactive-blinking-button {
|
|
69
|
+
0%, 100% {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
50% {
|
|
73
|
+
opacity: var(--interactive-button-hover-opacity);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* blink-anim-reference */
|
|
78
|
+
.interactive-blink-anim-reference {
|
|
79
|
+
position: absolute;
|
|
80
|
+
height: 0;
|
|
81
|
+
width: 0;
|
|
82
|
+
top: 0;
|
|
83
|
+
left: 0;
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.interactive-blink-anim-reference-animation {
|
|
88
|
+
animation-duration: 2001ms;
|
|
89
|
+
animation-iteration-count: infinite;
|
|
90
|
+
animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
|
|
91
|
+
animation-name: interactive-blinking-button;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.interactive-blink-anim-reference-disabled {
|
|
95
|
+
animation: none;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* control tap */
|
|
99
|
+
.interactive-control-tap {
|
|
100
|
+
position: absolute;
|
|
101
|
+
aspect-ratio: 1;
|
|
102
|
+
background-color: var(--interactive-bg-color-1);
|
|
103
|
+
border: 1px solid var(--interactive-color-1);
|
|
104
|
+
border-radius: 50%;
|
|
105
|
+
transition: opacity var(--interactive-transition-1);
|
|
106
|
+
opacity: 0;
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
z-index: 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.interactive-control-tap-animation {
|
|
112
|
+
animation-duration: 300ms;
|
|
113
|
+
animation-iteration-count: 1;
|
|
114
|
+
animation-timing-function: ease;
|
|
115
|
+
animation-name: interactive-control-tap-bounce;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@keyframes interactive-control-tap-bounce {
|
|
119
|
+
0%, 100% {
|
|
120
|
+
transform: scale(1);
|
|
121
|
+
}
|
|
122
|
+
50% {
|
|
123
|
+
transform: scale(0.3);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-tap-visible {
|
|
128
|
+
opacity: 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* interactive-chapter */
|
|
132
|
+
.interactive-chapter {
|
|
133
|
+
position: absolute;
|
|
134
|
+
top: 0;
|
|
135
|
+
left: 0;
|
|
136
|
+
font-family: inherit;
|
|
137
|
+
|
|
138
|
+
--interactive-transition-1: 100ms ease-in-out;
|
|
139
|
+
--interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
140
|
+
--interactive-color-1: #fff;
|
|
141
|
+
--interactive-bg-color-1: rgba(255, 255, 255, 0.08);
|
|
142
|
+
--interactive-button-hover-opacity: 0.8;
|
|
143
|
+
--interactive-area-hover-opacity: 0;
|
|
144
|
+
--interactive-remove-delay: 300ms;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* interactive-control */
|
|
148
|
+
.interactive-control-wrapper-selected {
|
|
149
|
+
pointer-events: none;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.interactive-control {
|
|
153
|
+
display: flex;
|
|
154
|
+
width: 100%;
|
|
155
|
+
height: 100%;
|
|
156
|
+
font-family: inherit;
|
|
157
|
+
|
|
158
|
+
position: relative;
|
|
159
|
+
isolation: isolate;
|
|
160
|
+
opacity: 1;
|
|
161
|
+
|
|
162
|
+
box-shadow: none;
|
|
163
|
+
border: none;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.interactive-control.interactive-control-disabled {
|
|
167
|
+
cursor: default;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.interactive-control-button,
|
|
171
|
+
.interactive-control-area {
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.interactive-control-button {
|
|
176
|
+
transition: opacity var(--interactive-transition-2);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.interactive-control-area {
|
|
180
|
+
transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.interactive-control-wrapper-selected > .interactive-control-button {
|
|
184
|
+
transition: opacity var(--interactive-transition-1);
|
|
185
|
+
opacity: 0.5;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.interactive-control-wrapper-selected > .interactive-control-area {
|
|
189
|
+
transition: opacity var(--interactive-transition-1);
|
|
190
|
+
opacity: 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
.interactive-control.interactive-control-before-remove {
|
|
195
|
+
transition: opacity var(--interactive-transition-1);
|
|
196
|
+
opacity: 0;
|
|
197
|
+
pointer-events: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.interactive-container.interactive-container-disabled .interactive-control-button,
|
|
201
|
+
.interactive-container.interactive-container-disabled .interactive-control-area {
|
|
202
|
+
animation: none;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):hover,
|
|
206
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):focus-visible {
|
|
207
|
+
opacity: var(--interactive-button-hover-opacity);
|
|
208
|
+
animation: none;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):hover,
|
|
212
|
+
.interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):focus-visible {
|
|
213
|
+
opacity: var(--interactive-area-hover-opacity);
|
|
214
|
+
animation: none;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* fill animation */
|
|
218
|
+
.interactive-control-fill-animation {
|
|
219
|
+
position: absolute;
|
|
220
|
+
overflow: hidden;
|
|
221
|
+
z-index: -1;
|
|
222
|
+
pointer-events: none;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.interactive-control-fill-animation-filler-wrapper {
|
|
226
|
+
position: absolute;
|
|
227
|
+
width: 100%;
|
|
228
|
+
height: 100%;
|
|
229
|
+
transform-origin: center;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-width {
|
|
233
|
+
top: 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-height {
|
|
237
|
+
left: 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-right {
|
|
241
|
+
right: 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-left {
|
|
245
|
+
left: 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-top {
|
|
249
|
+
top: 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-bottom {
|
|
253
|
+
bottom: 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.interactive-control-fill-animation-filler {
|
|
257
|
+
width: 100%;
|
|
258
|
+
height: 100%;
|
|
259
|
+
background-color: rgba(173, 211, 255, 0.32);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-width {
|
|
263
|
+
transform: scaleX(0);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-height {
|
|
267
|
+
transform: scaleY(0);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-right {
|
|
271
|
+
transform-origin: right;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-left {
|
|
275
|
+
transform-origin: left;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-top {
|
|
279
|
+
transform-origin: top;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
|
|
283
|
+
transform-origin: bottom;
|
|
284
|
+
}
|
|
285
|
+
`,fr=e=>{let t=document.createElement(`style`);t.textContent=dr,e.prepend(t)};import{clientChecker as pr}from"@vkontakte/videoplayer-core/es2015";var mr=Object.freeze({lang:Tt.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1},enableAvPlayerSupport:!1});function hr(){let e=document.createElement(`div`);return e.classList.add(`interactive-chapter`),e}class gr{constructor(e){if(a(this,`playerSubscriptions`,new Ot),a(this,`subscriptions`,new Ot),a(this,`globalEventEmitter`,new zt),a(this,`animation`,new Bt),a(this,`seekToInteractiveController`,new Rt),a(this,`endedRanges`,new Set),a(this,`gameControllers`,[]),a(this,`rootElement`,hr()),a(this,`factories`,new Map([[`choice`,St]])),a(this,`isFirstChapterFetched`,!1),a(this,`_options`,void 0),a(this,`manifestController`,void 0),a(this,`resizeManager`,void 0),a(this,`cssVarsManager`,void 0),a(this,`historyController`,void 0),a(this,`player`,null),a(this,`interactiveEvents`,null),a(this,`selectBranches`,null),a(this,`seamlessController`,null),a(this,`seamlessControllerSubs`,new Ot),a(this,`graph`,null),a(this,`lastFrame`,null),a(this,`noInteractionTimeout`,void 0),a(this,`blinkAnimationRef`,null),a(this,`appState`,0),a(this,`state`,{prevChapter$:new H(null),isInitialChapter$:new H(!1),isFirstChapter$:new H(!0),isEndChapter$:new H(!1),isInteractiveExpectation$:new H(!1),isReplay$:new H(!1),calledByInteractive$:new H(!1),lastChapterChangeWasInitiatedByInteractive$:new H(!1),disabledControls$:new H(!1),interactiveRanges$:new H([]),isInteractiveTime$:new H(!1),statistics$:new H(null),isSeekable$:new H(!1)}),a(this,`events`,{noInteraction$:new V,graphVisibilityChanged$:new V,watchAgainIsClicked$:new V,chapterChanged$:new V,playerChanged$:new V,error$:new V,eachTick$:new V,manifestChanged$:new V,interactiveRangeEnded$:new V,interactiveContainerRemoved$:new V,interactiveContainerFakeRemoved$:new V,interactiveActionExecution$:new V,interactiveActionChoice$:new V,interactiveVisibilityChanged$:new V}),a(this,`emitErrorEvent`,e=>{this.events.error$.next(e),this.globalEventEmitter.emit(G.errors,e)}),a(this,`clearHistoryIfEnded`,()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&P(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener(`beforeunload`,this.clearHistoryIfEnded)}),a(this,`handleSeamlessPlayerChanged`,e=>{if(!e)return;let{statistics:t}=e,n=c(e,i);if(t){let{statSubscription:e,oneStat:n}=t;e.add(n.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(G.playerChanged,n)}),a(this,`onPlaybackStarted`,()=>{this.resizeManager?.calc(),this.animation.requestAnimation()}),a(this,`destroyGameControllers`,({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let n of this.gameControllers)!e&&n.isPermanentText||(this.animation.removeFn(n.whilePlaying),n.destroy(t))}),a(this,`completeInteractiveRange`,e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(t=>o(o({},t),{},{subjects:t.subjects.filter(t=>t.id!==e)}));t.next(n)}),a(this,`clearNoInteractionTimeout`,()=>{this.noInteractionTimeout&&=(clearTimeout(this.noInteractionTimeout),void 0)}),this._options=o(o(o({},mr),e),{},{config:o(o({},mr.config),e.config)}),this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new $e,this.blinkAnimationRef.create();let e=this.blinkAnimationRef.element;e&&this.rootElement.append(e)}this._options.parentElement.append(this.rootElement),this.historyController=new sr({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new lr({parentElement:this._options.parentElement,onError:e=>{let t=new y(1,6,e);this.emitErrorEvent(t)}})),fr(this._options.parentElement),this.subscriptions.add(kt(this.rootElement,`mousedown`).subscribe(e=>e.stopPropagation())).add(kt(this.rootElement,`mouseup`).subscribe(e=>e.stopPropagation())),this.manifestController=new on(this._options.loaders,e=>{let t=new y(1,3,e);this.emitErrorEvent(t)});let t=[];this._options.lastFrame&&t.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),t.push(()=>{let e=this.state.isInteractiveTime$.getValue();for(let t of this.gameControllers)t.onResize(e)}),this.cssVarsManager=new Ht(this._options?.parentElement),this.resizeManager=Ln(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Ft({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:e=>{this.setChapter({chapterId:e}),this.globalEventEmitter.emit(G.graph,{type:yn.watchAgainClicked,chapterId:e}),this.events.watchAgainIsClicked$.next(e)},onError:e=>{let t=new y(1,2,{message:e});this.emitErrorEvent(t)}})),this.initSubscriptions()}initSubscriptions(){var e=this;this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(function(){var t=s(function*({videosInfo:t=[]}){e._options.initSeamless&&(yield e.initSeamless(),e.updateGraphVideosInfo(t))});return function(e){return t.apply(this,arguments)}}())),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),(e.actionType===`setNextBranch`||!this._options.endChapterHistoryFix)&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour===`change-chapter`){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour===`change-manifest`){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}e.actionType===`expect`?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType===`after-expect`&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!==`action-choice`||t===`chapter`||`invokeImmediately`in n&&n.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:this._options.animationsFeatureToggles?.controlsHideAnimation})}))}initSeamless(){var e=this;return s(function*(){e.seamlessController=vn(e),e.seamlessControllerSubs.add(e.seamlessController.activePlayerChanged.subscribe(e.handleSeamlessPlayerChanged)),yield e.seamlessController.init()})()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:e})=>t>=e[1]);if(n){let e=n.range.join(`-`);this.endedRanges.has(e)||(this.endedRanges.add(e),this.globalEventEmitter.emit(G.interactives,{type:K.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:`range-ended`,payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener(`beforeunload`,this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener(`beforeunload`,this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(Dt()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(wt({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{let r;if(n)r=!0;else{let n=e*1e3;r=!!t.find(({range:[e,t],subjects:r})=>e<n&&n<t&&r.some(e=>!e.isRemoved)&&r.length)}r!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(r);let i=!!this.noInteractionTimeout,a=this.player?.info.playbackState$.getValue()===`playing`||n;r&&!i&&a?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):i&&!a&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(e=>e.container.container).filter(e=>!qe(e.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{let r=n.type.trim().toLowerCase(),i=this.factories.get(r)?.(n,this.rootElement,this.cssVarsManager,{isTouch:this._options?.isTouch??!1,features:{controlsExpectTimeBlinkAnimation:this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation,controlsTapPlace:this._options.animationsFeatureToggles?.controlsTapPlace,controlsFillAnimation:this._options.animationsFeatureToggles?.controlsFillAnimation}});if(i&&this.selectBranches&&this.interactiveEvents&&this.player){let r=new Cn({player:this.player,container:i,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Ze(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:this.options.disableTextControlContainerVisibilityEvents??!1,features:{controlsHideAnimation:this._options.animationsFeatureToggles?.controlsHideAnimation,enableAvPlayerSupport:this._options.enableAvPlayerSupport}});this.animation.addFn(r.whilePlaying,!0),t.push(r)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let e=this.state.isSeekable$.getValue(),t=!!this.seekToInteractiveController.getNextInteractiveTime();(t&&!e||!t&&e)&&this.state.isSeekable$.next(!e)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),r=(n&&P(n)&&Ve(n))??!1,i=this.manifestController.manifest?.metadata.initChapterId===e,a=this.historyController.state.history$.getValue();if(i||r&&t){this.historyController.updateHistory([e]);return}a.at(-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,r=n.getValue().map(n=>{let r=n.subjects.some(t=>t.id===e),i=n.subjects.map(n=>t&&r||n.id===e?o(o({},n),{},{isRemoved:!0}):n);return o(o({},n),{},{subjects:i})});n.next(r)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this._options.endChapterHistoryFix&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation&&(Ye(o(o({},e),{},{gameControllers:this.gameControllers,execFn:Sn(xn((e,t)=>{e.toggleBlinkAnimation(t)}),e.isExpect)})),e.isExpect)&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(e,t)=>{e.updateControlsShadowStyles(t)};e.isExpect?Ye(o(o({},e),{},{gameControllers:this.gameControllers,execFn:Sn(xn(t),!1)})):Ye(o(o({},e),{},{gameControllers:this.gameControllers,execFn:t}))}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}setManifest(e){var t=this;return s(function*(){t.reset(),t.isFirstChapterFetched=!1;let n=yield t.manifestController.setManifest(e);if(n.manifest)return t.graph&&t.graph.handleManifestChange(n.manifest),yield t.historyController.setManifest(n.manifest),t.events.manifestChanged$.next(n.manifest),t.globalEventEmitter.emit(G.manifestChanged,{manifest:n.manifest}),t.setGameControllers(),n.manifest})()}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=jn(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=qn({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){var e=this;return s(function*({chapterId:t,pushToHistory:n=!0,playPrev:r=!1}={}){e.reset(),e.lastFrame&&e.isFirstChapterFetched&&(e.lastFrame.draw(),e.lastFrame.show()),e.lastFrame&&pr.browser.isSafari&&(yield ur(35));let i=!r&&e.state.isEndChapter$.getValue()&&e.getCurrentManifest()?.metadata.initChapterId===t;e.state.isReplay$.next(i);let{chapter:a,media:o,graph:s}=yield t?e.manifestController.setNext(t):e.manifestController.setInitial();(!t||i)&&e.state.isFirstChapter$.next(!0),!(!a||!o)&&(n&&e.pushChapterToHistory(a.id),e.state.isInitialChapter$.next(e.manifestController.isInitialChapter()),e.state.isEndChapter$.next(e.manifestController.isEndChapter()),e.graph&&e.graph.handleChapterChange(a),e.state.isInteractiveTime$.next(!1),e.state.isInteractiveExpectation$.next(!1),e.lastFrame?.setCurrentChapter(a),e.events.chapterChanged$.next({chapter:a,manifestVideo:o}),e.globalEventEmitter.emit(G.chapterChanged,{chapter:a,media:o,graph:s}),e.setGameControllers(),e.endedRanges=new Set,e.isFirstChapterFetched=!0)}).apply(this,arguments)}getStatEvents(){return{click$:new Et(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?U.GRAPH_SHOW:U.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(U.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:r})=>{t!==`action-choice`||n!==`control`||(r===`Button`&&e.next(U.NEXT_BUTTON),r===`Area`&&e.next(U.NEXT_AREA))}))}),nextMovie$:new Et(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){var t=this;return s(function*(){t.graph&&(e?(yield t.graph.show(),t.state.isSeekable$.next(!1)):(t.graph.hide(),t.checkIfSeekable()),t.globalEventEmitter.emit(G.graph,{type:yn.visibility,visibility:e}),t.events.graphVisibilityChanged$.next(e))})()}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(e=>e.actionType===N.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(t=>{let n=e&&this._options.animationsFeatureToggles?.controlsHideAnimation?t.container.willRemoved:!0;return!t.container.isRemoved||!n})}isEndedExpectation(){return!this.player||!this.gameControllers?!1:this.player.info.position$.getValue()===this.player.info.duration$.getValue()&&this.gameControllers.some(e=>{let t=e.container.container;return!e.container.isRemoved&&!e.container.willRemoved&&t.endTime===null&&We(t.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&Ee(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return wn(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}}var _r={Container:x,createChoiceContainer:St,createAreaControl:tt,createButtonControl:vt,classnamesPrefix:ce},vr={version:f};export{tr as vkVideoIdsToChapterIds,_r as utils,Ae as migrateManifestToLatestVersion,Me as isValidManifest,Qn as isVKVariantItem,Ne as isTextControl,Ee as isSupportedManifest,qe as isOneTextCtrlContainer,P as isLastChapter,Pe as isButtonControl,Fe as isAreaControl,K as interactivesEventTypes,Ve as hasEndTemplate,yn as graphEventTypes,Zn as getVideoRawIdByMedia,$n as getVKVideoIdByMedia,er as getChapterIdByVkVideoId,Re as eventTypes,ze as eventActionTypes,Le as controlTypes,Ie as containerTypes,Yt as compareVersions,Xn as chapterIdsToVKVideoIds,vr as SDKInfo,on as ManifestController,gr as Interactives,ke as EventTypes,N as EventActionTypes,G as EVENT_NAMES,y as CustomError,Oe as ControlTypes,De as ContainerTypes};
|
|
286
|
+
//# sourceMappingURL=es2015.esm.js.map
|