Build 555975stable
Module 664111
16,129 characters · in 0959f28d586e222f.jsDependencies
Source Raw
function(e,t,n){n.r(t),n.d(t,{default:()=>K}),n(321073);var r=n(627968),l=n(64700),a=n(503698),i=n.n(a),s=n(922139),u=n(17928),o=n(876230),c=n(966697),d=n(231723),m=n(717421),h=n(939249),f=n(289873),p=n(782134),v=n(113494),x=n(834730),g=n(964486),E=n(775602),b=n(607470),S=n(475815),C=n(718499),w=n(23590),N=n(671897),y=n(565164),A=n(275664),R=n(408121),T=n(984212),j=n(739416),L=n(931853),M=n(90721),P=n(920228),k=n(652215),D=n(838541),I=n(375708),B=n(834926);let F={tension:250,friction:5,clamp:!0},_={visibility:"hidden"},U=l.forwardRef(function(e,t){let{parentTransitionState:n,autoplay:a=!1,orientation:c="landscape",videoUrlOverride:k,src:I,poster:U,initialTimeSec:O=0,onProgressUpdate:K,onEnded:$,onError:Q,maxSeekableTimeSec:V,captionTrackUrl:G,transcriptText:Y,renderEndScreen:H,onPlayerStateChange:Z,onFullscreenChange:z,onVolumeChange:X,onMutedChange:W,initialVolume:J=.3,initialMuted:q=!1,onLoadStart:ee,onLoadEnd:et,onFirstFrame:en,onBufferingStart:er,onBufferingEnd:el,onFocusChange:ea,onVisibilityChange:ei,onSeek:es,renderOverlay:eu,renderPersistentOverlay:eo,transcriptClassName:ec,onHlsInstance:ed,onClick:em,preload:eh,downloadUrl:ef,downloadContentType:ep,extraButtons:ev,hideFullScreenBtn:ex=!1,hideSkipButtons:eg,compactTimeDisplay:eE=!1,hidePlaybackSpeedBtn:eb=!1,getPlaybackBlockedMessage:eS,progressClassName:eC,pauseOnLostVisibility:ew=!1,persistTimeline:eN=!1,persistPlayhead:ey=!0,autoFocus:eA=!1,autoHideVolumeSlider:eR=!1,timelineIndicatorConfig:eT,scrubPreviewVttUrl:ej,scrubPreviewImageUrl:eL,loadingSpinnerPosition:eM="top-left",crossOrigin:eP="anonymous",withVideoHalo:ek=!1,objectFit:eD="contain",muxContentMetadata:eI,awaitMuxReady:eB=!1}=e,eF=k??I,e_=eS??L.u,eU=l.useRef(null),eO=(0,y.z5)(eU,ej,eL),{focused:eK,focusedChanged:e$}=(0,j.A7)(),{visible:eQ,visibleChanged:eV,targetRef:eG}=(0,j.O7)(),[eY,eH]=l.useState(a?o.Q6.PLAYING:o.Q6.PAUSED),[eZ,ez]=l.useState(!1),[eX,eW]=l.useState(!1),[eJ,eq]=l.useState(0),[e0,e1]=l.useState(null),e2=l.useCallback(e=>{e1(null),eq(e)},[]),[e6,e4]=l.useState(!1),e3=l.useRef(null),[e9,e8]=l.useState(o.h$.LOADING),e7=l.useRef(!1),e5=l.useRef(null),[te,tt]=l.useState([]),[tn,tr]=l.useState(!1),tl=l.useRef(!1),ta=l.useRef(!1),ti=l.useRef(!1),ts=l.useRef(!1),[tu,to]=l.useState(!0),tc=l.useRef(!0),td=l.useRef(null),tm=l.useRef(null),[th,tf]=l.useState(J),[tp,tv]=l.useState(q),[tx,tg]=l.useState(!eR),[tE,tb]=l.useState(!1),[tS,tC]=l.useState(!1),[tw,tN]=l.useState(!1),ty=(0,u.bG)([E.A],()=>E.A.useReducedMotion),tA=(0,l.useRef)(null),tR=(0,l.useRef)(null),tT=(0,l.useRef)(null),tj=l.useRef(!0),[tL,tM]=l.useState(null),tP=l.useCallback(()=>tA.current?.currentTime??null,[]);(0,M.A)({videoRef:tA,canvasRef:tR,enabled:ek&&!ty,canvasWidth:32,canvasHeight:18});let tk=l.useCallback((e,t)=>{Q?.(e,t)},[Q]),{isHlsActive:tD,hlsRef:tI}=(0,C.Ay)(tA,{src:eF,initialTimeSec:O,onError:tk,onHlsInstance:ed,crossOrigin:eP}),{isReady:tB}=(0,w.A)({videoRef:tA,hlsRef:tI,contentMetadata:eI,isHls:tD}),tF=eB&&!tB&&!tD,[t_,tU]=l.useState(null),[tO,tK]=l.useState(0),[t$,tQ]=l.useState(!1),tV=V??tA.current?.duration??0,[tG,tY]=l.useState(o.oA.MD),tH={[o.oA.MD]:56,[o.oA.LG]:64};(0,g.u5)(()=>{tj.current&&(tj.current=!1)});let tZ=l.useCallback(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(ts.current=!0,eH(e),Z?.(e,t),null!=tA.current)switch(e){case o.Q6.PLAYING:tM(null),tA.current.play();break;case o.Q6.PAUSED:tl.current=!1,tA.current.pause(),tc.current=!1;break;case o.Q6.ENDED:tb(!1)}},[Z]);l.useEffect(()=>{if(!ew)return;let e=null!=n&&(n===d.ip.HIDDEN||n===d.ip.EXITING||n===d.ip.EXITED),t=null!=n&&eV&&!eQ,r=e$&&!eK;if((e||t||r)&&null!=tA.current&&eY===o.Q6.PLAYING){let n=e||t?o.KB.VISIBILITY:o.KB.FOCUS;tM(n),tZ(o.Q6.PAUSED,n)}},[ew,n,eK,e$,eQ,eV,eY,tZ]),(0,P.A)({videoRef:tA,enabled:ew,onPipPause:()=>{tM(o.KB.PICTURE_IN_PICTURE),tZ(o.Q6.PAUSED,o.KB.PICTURE_IN_PICTURE)},onHiddenPause:()=>{tM(o.KB.FOCUS),tZ(o.Q6.PAUSED,o.KB.FOCUS)}}),l.useEffect(()=>{e$&&ea?.(eK,eY)},[eK,e$,eY,ea]),l.useEffect(()=>{eV&&ei?.(eQ,eY)},[eQ,eV,eY,ei]);let[tz,tX]=l.useState(!1),tW=l.useRef(null),tJ=l.useRef(0);l.useLayoutEffect(()=>{tJ.current=performance.now()},[]);let tq=l.useCallback(()=>{null!=tW.current&&clearTimeout(tW.current),eY!==o.Q6.PLAYING||(tW.current=setTimeout(()=>{eY===o.Q6.PLAYING&&tX(!0)},Math.max(0,3e3-(performance.now()-tJ.current))))},[eY]),t0=l.useCallback(()=>{tX(!1),tJ.current=performance.now(),tq()},[tq]);l.useEffect(()=>{if(eY!==o.Q6.PLAYING){tX(!1),null!=tW.current&&clearTimeout(tW.current);return}return tq(),()=>{null!=tW.current&&clearTimeout(tW.current)}},[eY,tq]),l.useEffect(()=>()=>{null!=e3.current&&clearTimeout(e3.current)},[]);let t1=!tz&&(eX||eZ||eY===o.Q6.ENDED),t2=l.useRef(z);t2.current=z;let t6=l.useCallback(()=>{let e=(0,S.qf)(tA.current?.parentNode,tA.current);null==e||(0,S._U)(e)||(e.removeEventListener(S.Wb,t6),tN(!1),t2.current?.(!1),tY(o.oA.MD))},[]),t4=()=>{null==tA.current||(t9(Math.max((e5.current??tA.current.currentTime)-10,0)),eY===o.Q6.ENDED&&tZ(o.Q6.PAUSED,o.KB.SEEK))},t3=()=>{if(null==tA.current)return;let e=Math.min((e5.current??tA.current.currentTime)+10,tV);t9(e),eY!==o.Q6.ENDED&&e>=tA.current.duration&&tZ(o.Q6.ENDED,o.KB.SEEK)};l.useEffect(()=>{let e=tA.current;return()=>{let t=(0,S.qf)(e?.parentNode,e);null!=t&&t.removeEventListener(S.Wb,t6)}},[t6]);let t9=l.useCallback(function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(null==tA.current)return;let n=tA.current.currentTime;e5.current=e,e1(e/(tA.current.duration??1)*100),e4(!0),null!=e3.current&&clearTimeout(e3.current),e3.current=setTimeout(()=>{e4(!1),e3.current=null},100),e7.current=!0,tA.current.currentTime=e,t&&es?.(n,e)},[es]),t8=()=>{if(null!=tA.current)switch(eY){case o.Q6.ENDED:t9(0),tZ(o.Q6.PLAYING,o.KB.USER);break;case o.Q6.PLAYING:tM(o.KB.USER),tZ(o.Q6.PAUSED,o.KB.USER);break;default:tZ(o.Q6.PLAYING,o.KB.USER)}},t7=e=>{tU(e)},t5=e=>{tU(t=>t?.id===e.id?null:t)},ne=l.useCallback(()=>{if(null==tA.current||0===tA.current.textTracks.length)return;let e=tA.current.textTracks[0];if(e.mode="hidden",null!=e.cues)for(let t=0;t<e.cues.length;t++){let n=e.cues[t];(0,T.C)(n)&&(n.id=`cue-${t}`,n.onenter=()=>t7(n),n.onexit=()=>t5(n))}},[]);l.useEffect(()=>{if(null==tT.current)return;let e=tT.current;return e.addEventListener("load",ne),()=>{null!=e&&e.removeEventListener("load",ne)}},[ne]);let nt=e=>{if(null!=tA.current){if(e9===o.h$.BUFFERING){let e=null!=tm.current?performance.now()-tm.current:null;el?.(e)}else if(e9===o.h$.LOADING){let e=null!=td.current?performance.now()-td.current:null;et?.(e)}e8(o.h$.READY),eY===o.Q6.PLAYING&&(tl.current||tZ(o.Q6.PLAYING,o.KB.BUFFERING_RECOVERY))}},nn=e=>{if(t9(e),eY===o.Q6.ENDED&&!ta.current){let t=tA.current?.duration;(null==t||Number.isNaN(t)||e<t)&&tZ(o.Q6.PLAYING,o.KB.USER)}},[{controlBarAnimSpring:nr},nl]=(0,m.z)(()=>({from:{controlBarAnimSpring:0},config:F,onStart:()=>{to(!1)},onRest:()=>{to(!0)}})),na=(0,l.useRef)(null),[{captionHeightSpring:ni},ns]=(0,m.z)(()=>({from:{captionHeightSpring:0},config:F}));l.useEffect(()=>(ns({captionHeightSpring:tS&&null!=t_?na.current?.clientHeight??0:0,immediate:ty}),()=>{ni.stop()}),[tS,ns,ty,t_,ni]),l.useEffect(()=>(nl({controlBarAnimSpring:t1||tn?1:0,immediate:ty}),()=>{nr.stop()}),[t1,nl,ty,tn,nr]);let nu=eY===o.Q6.ENDED&&null!=H,no=l.useCallback(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.KB.USER;null!=tA.current&&(t9(0),tZ(o.Q6.PLAYING,e))},[t9,tZ]),nc=l.useRef(null),nd=l.useCallback(e=>{t0(),nc.current?.(e.nativeEvent)},[t0]);return(0,r.jsx)(h.D,{className:B.W6,"data-fullscreen":tw,"data-testid":"discord-web-video-player-container",tabIndex:-1,onMouseEnter:()=>{ez(!0),tX(!1),tJ.current=performance.now(),null!=tW.current&&clearTimeout(tW.current)},onMouseLeave:()=>{ez(!1),tX(!1)},onMouseMove:t0,children:(0,r.jsxs)("div",{className:i()(B.NS,{[B.DO]:"portrait"===c,[B.r7]:"landscape"===c}),tabIndex:-1,onKeyDown:nd,style:{"--custom-footer-horizontal-padding":"20px","--custom-footer-bottom":"4px"},children:[ek&&!ty&&(0,r.jsx)("canvas",{ref:tR,className:B.Xm}),nu&&H?.({replay:no}),(0,r.jsxs)(b.A,{ref:e=>{tA.current=e,eG.current=e,"function"==typeof t?t(e):null!=t&&(t.current=e)},autoPlay:a,playsInline:!0,mediaLayoutType:tw?D.dG.STATIC:D.dG.RESPONSIVE,className:i()({[B.R]:nu,[B.IR]:!0,[B.FP]:"cover"===eD&&!tw}),controls:!1,poster:U,preload:eh,disablePictureInPicture:!0,"data-testid":"discord-web-video-player-video",onTimeUpdate:e=>{null!=tA.current&&(K?.(tA.current.currentTime,tA.current.duration),e7.current||e2(tA.current.currentTime/tA.current.duration*100))},onEnded:e=>{e8(o.h$.READY),$?.(),ta.current||tZ(o.Q6.ENDED,o.KB.PLAYBACK_COMPLETE)},onLoadedData:e=>{if(e9===o.h$.LOADING){let e=null!=td.current?performance.now()-td.current:null;et?.(e),e8(o.h$.READY)}},onLoadedMetadata:e=>{if(null==tA.current)return;O>0&&!tD&&t9(O,!1),tp?tA.current.volume=0:tA.current.volume=th;let t=tA.current.duration;t>0&&isFinite(t)&&tK(t),tQ(!0)},onLoadStart:()=>{td.current=performance.now(),ee?.()},onPlaying:()=>{tc.current&&(en?.(performance.now()),tc.current=!1)},onWaiting:e=>{tm.current=performance.now(),er?.(),e8(o.h$.BUFFERING)},onProgress:e=>{if(null==tA.current)return;let t=[];for(let e=0;e<tA.current.buffered.length;e++){let n=tA.current.buffered.start(e),r=tA.current.buffered.end(e);r-n<1||t.push({start:n/tA.current.duration,size:(r-n)/tA.current.duration})}tt(t)},onCanPlay:nt,onCanPlayThrough:nt,onSeeked:()=>{e7.current=!1,e5.current=null,null!=tA.current&&e2(tA.current.currentTime/tA.current.duration*100)},onAbort:()=>tk(o.SB.ABORT),onError:()=>tk(o.SB.ERROR),onEmptied:()=>tk(o.SB.EMPTIED),onStalled:()=>tk(o.SB.STALLED),onClick:e=>{null!=em?em(e):t8()},crossOrigin:eP??void 0,children:[null!=G&&(0,r.jsx)("track",{ref:tT,src:G,label:"English",kind:"captions",srcLang:"en",default:!0}),null!=ej&&(0,r.jsx)("track",{ref:eU,src:ej,kind:"metadata"}),!tD&&!tF&&(0,r.jsx)("source",{onError:()=>tk(o.SB.SOURCE_ERROR),src:eF,type:"video/mp4"})]}),e9!==o.h$.READY&&eY===o.Q6.PLAYING&&null!=eF&&(0,r.jsx)("span",{className:i()(B.S,{[B.F]:"center"===eM}),"data-testid":"discord-web-video-player-loading-spinner",children:(0,r.jsx)(f.y,{type:f.y.Type.WANDERING_CUBES})}),(0,r.jsx)(L.A,{message:e_({hasVideoAsset:null!=eF,playerState:eY,pauseReason:tL}),showOverlay:null==eF}),null!=eu&&(0,r.jsx)(s.animated.div,{className:B.MU,style:{opacity:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>`${e}`),visibility:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>e<.1?"hidden":"visible"),pointerEvents:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>e<.3?"none":"auto")},children:eu()}),tE&&eY!==o.Q6.ENDED&&null!=Y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.D,{onClick:()=>{eY===o.Q6.PAUSED&&tZ(o.Q6.PLAYING,o.KB.USER),tb(!1)},tabIndex:-1,children:(0,r.jsx)("div",{className:B.BG})}),(0,r.jsx)(s.animated.div,{className:i()(B.xr,ec,{[B.MZ]:"portrait"===c}),"data-testid":"discord-web-video-player-transcript",style:{marginBottom:(0,s.to)([nr,ni],(e,t)=>`${e*tH[tG]+t}px`)},children:(0,r.jsx)(R.X,{text:Y,onClose:()=>{tb(!1)}})})]}),(0,r.jsx)(s.animated.div,{className:B.Jp,style:{opacity:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>`${e}`)}}),(0,r.jsx)("div",{className:i()(B.yf,{[B.ZH]:ts.current&&eY===o.Q6.PLAYING,[B.v7]:ts.current&&eY===o.Q6.PAUSED}),style:{"--custom-play-pause-pop-ms":"1000ms"},children:eY===o.Q6.PLAYING?(0,r.jsx)(p.u,{className:B.PK}):(0,r.jsx)(v.E,{className:B.PK})},eY),tS&&null!=t_&&!nu&&(0,r.jsx)(s.animated.div,{className:B.o$,ref:na,"data-testid":"discord-web-video-player-captions",style:{translateY:(0,s.to)([nr.to({range:[0,1],output:[-20,-tH[tG]]})],e=>`${e}px`)},children:(0,r.jsx)(x.E,{variant:"text-lg/semibold",color:"always-white",className:B.qh,children:t_.text})}),(0,r.jsxs)(s.animated.div,{className:B.r8,style:{height:(0,s.to)([nr.to({range:[0,1],output:[0,tH[tG]]})],e=>`${e}px`)},children:[(0,r.jsx)(s.animated.div,{style:{transform:(0,s.to)([nr.to({range:[1,0],output:[0,1]})],e=>`translateY(-${20*e}px)`)},children:(0,r.jsx)("div",{style:t1||tn||eN?void 0:_,children:(0,r.jsx)(A.Ay,{percent:null!=e0?e0:eJ,animate:!0!==tj.current&&!e6&&eY===o.Q6.PLAYING&&t$&&e9===o.h$.READY,interactionEnabled:tu&&tV>0,backgroundColor:t1||eN?void 0:"rgba(0, 0, 0, 0.0)",playerState:eY,preloadedBuffers:t1?te:void 0,durationSec:tO>0?tO:+!t$,isFullyVisible:t1&&tu,maxSeekableTime:null!=V&&tV>0?tV:void 0,progressClassName:eC,persistPlayhead:ey,onClick:nn,onScrubBack:t4,onScrubForward:t3,onDragStateChange:e=>{if(ta.current=e,tr(e),e)tl.current=eY===o.Q6.PLAYING,ti.current=eY===o.Q6.ENDED,tl.current?tA.current?.pause():ti.current&&tZ(o.Q6.PAUSED,o.KB.SEEK);else{let e=tA.current,t=null!=e&&!Number.isNaN(e.duration)&&e.currentTime>=e.duration;tl.current?(tl.current=!1,t?tZ(o.Q6.ENDED,o.KB.PLAYBACK_COMPLETE):e?.play()):ti.current?(ti.current=!1,t?tZ(o.Q6.ENDED,o.KB.PLAYBACK_COMPLETE):tZ(o.Q6.PLAYING,o.KB.USER)):t&&tZ(o.Q6.ENDED,o.KB.PLAYBACK_COMPLETE)}},indicatorConfig:eT,scrubPreviewCues:eO,onIndicatorSeek:nn,getCurrentTimeSec:tP,"data-testid":"discord-web-video-player-timeline"})})}),(0,r.jsx)(s.animated.div,{className:B.uN,"data-testid":"discord-web-video-player-controls",style:{paddingTop:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>`${e*e*20}px`),paddingBottom:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>`${e*e*12}px`),pointerEvents:(0,s.to)([nr.to({range:[0,1],output:[0,1]})],e=>e<.3?"none":"auto")},onFocus:()=>eW(!0),onBlur:()=>eW(!1),children:(0,r.jsx)(N.A,{videoRef:tA,playerState:eY,animSpring:nr,visible:t1,seekForwardEnabled:null==V||(tA.current?.currentTime??0)+1<tV,hideCaptionBtn:null==G,hideTranscriptBtn:null==Y,hideFullScreenBtn:ex,hidePlaybackSpeedBtn:eb,hideSkipButtons:eg??"portrait"===c,compactTimeDisplay:eE,size:tG,downloadUrl:ef,downloadContentType:ep,extraButtons:ev,autoFocus:eA,keyDownHandlerRef:nc,volume:th,muted:tp,transcriptEnabled:tE,captionEnabled:tS,fullScreenEnabled:tw,handlePlaybackBtnClick:t8,handleTranscriptBtnClick:()=>{tb(!tE)},handleCaptionBtnClick:()=>{tC(!tS)},handleFullScreenBtnClick:()=>{let e=!tw,t=(0,S.qf)(tA.current?.parentNode,tA.current);e&&null!=t?((0,S.tl)(t),t.addEventListener(S.Wb,t6),z?.(!0),tY(o.oA.LG)):e||null==t||(t.removeEventListener(S.Wb,t6),z?.(!1),(0,S.sP)(t),tY(o.oA.MD)),tN(e)},handleSeekBackBtnClick:t4,handleSeekForwardBtnClick:t3,autoHideVolumeSlider:eR,handleControlBarPendingInteraction:tr,onVolumeChange:e=>{tf(e),X?.(e)},onMutedChange:e=>{tv(e),W?.(e)},onVolumeExpandedChange:e=>{tg(e)}})})]}),null!=eo&&(0,r.jsx)("div",{className:B.MU,children:eo({playerState:eY,isControlBarExpanded:t1,videoRef:tA,isActive:!0,isVolumeExpanded:tx})})]})})});function O(e){let{poster:t,posterPlaceholder:n,posterPlaceholderVersion:a,orientation:i,objectFit:s="contain"}=e,[u,o]=l.useState(!1),d=l.useCallback(()=>o(!0),[]);return null==t?null:(0,r.jsx)(c.y,{readyState:u?k.Rv1.READY:k.Rv1.LOADING,aspectRatio:"portrait"===i?9/16:16/9,placeholder:n,placeholderVersion:a??1,placeholderStyle:{width:"100%",height:"100%",objectFit:"cover"},disableSpinner:!0,children:(0,r.jsx)("img",{src:t,className:B.zH,style:{objectFit:s},alt:"",onLoad:d})})}let K=l.forwardRef(function(e,t){let{active:n=!0,onClick:a,...s}=e,{autoplay:u,poster:c,orientation:d="landscape",posterPlaceholder:m,posterPlaceholderVersion:f,renderOverlay:v,renderPersistentOverlay:x,objectFit:g}=s,[E,b]=l.useState(!1),S=n||E,C=l.useCallback(e=>{null!=a?a(e):b(!0)},[a]),w=l.useRef(null);return S?(0,r.jsx)(U,{...s,onClick:a,autoplay:u||E,ref:t}):(0,r.jsx)(h.D,{className:i()(B.W6,B.nZ),"data-testid":"discord-web-video-player-container",tabIndex:0,onClick:C,"aria-label":I.intl.string(I.t.RscU7I),focusProps:{ringTarget:w},children:(0,r.jsxs)("div",{className:i()(B.NS,{[B.DO]:"portrait"===d,[B.r7]:"landscape"===d}),children:[(0,r.jsx)(O,{poster:c,posterPlaceholder:m,posterPlaceholderVersion:f,orientation:d,objectFit:g}),null!=v&&(0,r.jsx)("div",{className:B.MU,children:v()}),null!=x&&(0,r.jsx)("div",{className:B.MU,children:x({playerState:o.Q6.PAUSED,isControlBarExpanded:!0,isActive:!1,isVolumeExpanded:!1})}),(0,r.jsx)("div",{className:B.mF,ref:w,children:(0,r.jsx)(p.u,{size:"xs",color:"currentColor",className:B.z_})})]})})})}