Build 567923stable
Module 544048
2,688 characters · in 3d3b05863accbf32.jsDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{t:()=>m});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(941861),o=n(844222),u=n(460890),c=n(409341);class d extends i.PureComponent{static defaultProps={pauseWhileUnfocused:!0,pause:!1};animationRef=null;animation;currentScene=this.props.nextScene;isUnmounted=!1;async componentDidMount(){let{importData:e,nextScene:t,pauseWhileUnfocused:l,pause:i,isWindowFocused:s,useReducedMotion:r,rendererSettings:a}=this.props,[o,{default:u}]=await Promise.all([e(),n.e("96382").then(n.t.bind(n,883885,23))]);null!=this.animationRef&&(this.animation=u.loadAnimation({container:this.animationRef,renderer:"svg",loop:!0,autoplay:!0,animationData:o,rendererSettings:a}),this.animation.addEventListener("loopComplete",this.handleLoopComplete),this.animation.addEventListener("complete",this.handleComplete),this.animation.addEventListener("enterFrame",this.handleEnterFrame),this.playScene(t),(l&&!s||i||r)&&this.animation.pause())}componentWillUnmount(){this.isUnmounted=!0,null!=this.animation&&(this.animation.destroy(),this.animation=void 0)}componentDidUpdate(e){let{nextScene:t,pauseWhileUnfocused:n,pause:l,isWindowFocused:i,useReducedMotion:s}=this.props;t!==this.currentScene&&this.shouldForcePlayAfter()&&!l&&this.playScene(t),null!=this.animation&&(n&&!e.isWindowFocused&&i&&!s&&!0!==l?this.animation.play():(s||n&&e.isWindowFocused&&!i)&&this.animation.pause()),!e.pause&&l?this.animation?.pause():!e.pause||l||s||this.animation?.play(),e.nextScene!==t&&l&&(this.playScene(t),this.animation?.pause())}shouldForcePlayAfter(){let{sceneSegments:e}=this.props;return!0===e[this.currentScene].shouldForcePlayAfter}playScene(e){if(this.isUnmounted)return;let{onScenePlay:t,sceneSegments:n,useReducedMotion:l}=this.props,i=n[e],s=n[this.currentScene];null!=this.animation&&(e===this.currentScene||i.BEG!==s.BEG||i.END!==s.END)&&this.animation.playSegments([i.BEG,i.END],!0),this.currentScene=e,null!=t&&t(this.currentScene),l&&this.animation?.pause()}handleLoopComplete=()=>{let{onSceneComplete:e,nextScene:t}=this.props;null!=e&&e(this.currentScene),this.playScene(t)};handleComplete=()=>{let{onSceneComplete:e}=this.props;null!=e&&e(this.currentScene)};handleEnterFrame=e=>{let{onEnterFrame:t}=this.props;t?.(this.currentScene,e)};handleSetRef=e=>{this.animationRef=e;let{animationRef:t}=this.props;null!=t&&t(e)};render(){return(0,l.jsx)("div",{ref:this.handleSetRef,className:r()(this.props.className,c.i)})}}let m=e=>{let{componentRef:t,ignoreReducedMotion:n=!1,...s}=e,{isWindowFocused:r}=(0,u.G9)(),c=(0,a.R)(),{reducedMotion:m}=i.useContext(o.C),h=m.enabled&&!n,p={...s,isWindowFocused:r?.()??c,useReducedMotion:h};return(0,l.jsx)(d,{...p,ref:t})}}