Module 811656

5,235 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{K:()=>T,A:()=>S});var i=n(627968),r=n(64700),s=n(503698),a=n.n(s),o=n(17928),l=n(970002),u=n(228366),d=n(775602),c=n(607470),_=n(174459),h=n(625494);n(323874),n(14289),n(35956);var f=n(671325),E=n(636537),p=n(105596),m=n(676279),g=n(652215);let A=function(e){(0,r.useEffect)(()=>{e&&_.default.track(g.HAw.PREMIUM_BRAND_REFRESH_WOW_MOMENT_ASSETS_PREFETCHING)},[e]);let{mediaUrls:t,isSuccess:n,isLoading:i}=function(e){let t=(0,m.TM)(),[n,i]=(0,r.useState)({modalGlowEntry:void 0,modalGlowIdle:void 0,modalGlowExit:void 0}),[s,a]=(0,r.useState)(!1),[o,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(!1),c=(0,r.useRef)(!0);(0,r.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let h=(0,r.useCallback)(()=>null!=n.modalGlowEntry&&null!=n.modalGlowIdle&&null!=n.modalGlowExit,[n.modalGlowEntry,n.modalGlowIdle,n.modalGlowExit]),f=(0,r.useCallback)(async()=>{if(!h()&&!u){d(!0),l(!1),a(!1);try{let e=Date.now(),[n,r,s]=await Promise.all([E.Bo.get({url:t?"https://cdn.discordapp.com/assets/content/26968a6375b676097d7234b043b61312b8037f45d077c91b621ead07c6b0544b.mov":"https://cdn.discordapp.com/assets/content/49d12c146442880c181fcc5502a49bd31d7537c2d6d5255aa2ad6b3d668553e7.webm",binary:!0,rejectWithError:!0}),E.Bo.get({url:t?"https://cdn.discordapp.com/assets/content/e1b69b796171027073273beebfee03fdf466010bf89a2ff116deccaec44d7c6f.mov":"https://cdn.discordapp.com/assets/content/ad6e3d6f3a4bb6a1debd45bc21e47b7f522685c3facc578bd2129aa4cd795f40.webm",binary:!0,rejectWithError:!0}),E.Bo.get({url:t?"https://cdn.discordapp.com/assets/content/7c384bc29166872d908b60c5faec0d00d9bd960267a8943331c456018ede5e7d.mov":"https://cdn.discordapp.com/assets/content/54bef6c79e1a3e1c2ec8f0d4a208643a7e203dc4c94e3463e6c6b38f6f4bdb23.webm",binary:!0,rejectWithError:!0})]);c.current&&(i({modalGlowEntry:window.URL.createObjectURL(n.body),modalGlowExit:window.URL.createObjectURL(r.body),modalGlowIdle:window.URL.createObjectURL(s.body)}),a(!0),_.default.track(g.HAw.PREMIUM_BRAND_REFRESH_WOW_MOMENT_ASSETS_PREFETCH_SUCCESS,{load_duration_ms:Date.now()-e}))}catch(e){c.current&&l(!0)}finally{c.current&&d(!1)}}},[h,u,t]);return(0,r.useEffect)(()=>{e&&f()},[e,f]),(0,r.useEffect)(()=>()=>{null!=n.modalGlowEntry&&window.URL.revokeObjectURL(n.modalGlowEntry),null!=n.modalGlowIdle&&window.URL.revokeObjectURL(n.modalGlowIdle),null!=n.modalGlowExit&&window.URL.revokeObjectURL(n.modalGlowExit)},[n.modalGlowEntry,n.modalGlowIdle,n.modalGlowExit]),{mediaUrls:n,isSuccess:s,isFailure:o,isLoading:u}}(e),{status:s}=(0,p.CE)(e?f.A:null);return{mediaUrls:t,isSuccess:n&&s===p.BW.Loaded,isLoading:i||s===p.BW.Loading}};var I=n(669414);let T=1e3,S=e=>{let{children:t,isConfirmationStep:n,isEligibleForWowMoment:s,shouldPrefetchWowMoment:f}=e,E=(0,o.bG)([d.Ay],()=>d.Ay.useReducedMotion),[p,m]=(0,r.useState)("entry"),T=(0,r.useRef)(null),S=(0,r.useRef)(null),N=(0,r.useCallback)(()=>{"entry"===p&&(m("idle"),null!=T.current&&T.current?.play())},[p]),C=(0,r.useCallback)(()=>{"exit"!==p&&(m("exit"),null!=S.current&&S.current?.play())},[p]),[y,v]=(0,r.useState)(!1);(0,r.useEffect)(()=>{f&&v(!0)},[f]);let{mediaUrls:R,isSuccess:O}=A(!E&&s&&y),b=(0,r.useRef)(null),[L,D]=(0,r.useState)(!1),[P,w]=(0,r.useState)(!1),[M,x]=(0,r.useState)("none"),[U,k]=(0,r.useState)(!1);return((0,r.useEffect)(()=>{let e;s&&n&&!U&&"none"===M&&(E||!O?(x("static"),E||(k(!0),_.default.track(g.HAw.PREMIUM_BRAND_REFRESH_WOW_MOMENT_ASSETS_NOT_LOADED_ON_CONFIRMATION)),e=!1):(x("animated"),w(!0),e=!0),u.h.dispatch({type:"WOW_MOMENT_CONFIRMATION_SET_IS_DISPLAYING_WOW_MOMENT_CONFIRMATION",value:!0,isAnimated:e}),_.default.track(g.HAw.PREMIUM_BRAND_REFRESH_WOW_MOMENT_VIEWED,{wow_moment_type:e?"animated":"static"}))},[E,s,n,O,U,M]),(0,r.useEffect)(()=>{function e(){D(!0),C()}return h._.subscribe(g.jej.WOW_MOMENT_CONFIRMATION_MODAL_CLOSED,e),()=>{h._.unsubscribe(g.jej.WOW_MOMENT_CONFIRMATION_MODAL_CLOSED,e)}},[C]),(0,r.useEffect)(()=>()=>{u.h.dispatch({type:"WOW_MOMENT_CONFIRMATION_SET_IS_DISPLAYING_WOW_MOMENT_CONFIRMATION",value:!1,isAnimated:!1})},[]),"animated"===M)?(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:I.j,children:[(0,i.jsx)("div",{className:I.ws,children:(0,i.jsx)(c.A,{playsInline:!0,muted:!0,autoPlay:!0,onEnded:N,className:a()(I.Ki,"entry"===p?I.RK:I.R),children:(0,i.jsx)("source",{src:R.modalGlowEntry})})}),(0,i.jsx)(c.A,{ref:T,playsInline:!0,muted:!0,loop:!0,className:a()(I.Ki,"idle"===p?I.RK:I.R),children:(0,i.jsx)("source",{src:R.modalGlowIdle})}),(0,i.jsx)(c.A,{ref:S,playsInline:!0,muted:!0,className:a()(I.Ki,"exit"===p?I.RK:I.R),children:(0,i.jsx)("source",{src:R.modalGlowExit})})]}),(0,i.jsx)("div",{className:I.Sh,children:(0,i.jsx)(l.e,{fit:"layout",ref:b,dataBinding:{ExitTrigger:L,EntryTrigger:P},listenOnDocumentBody:!0})}),(0,i.jsx)("div",{className:"exit"===p?I.aO:I.ws,children:t})]}):"static"===M?(0,i.jsxs)(i.Fragment,{children:[!L&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("img",{src:"https://cdn.discordapp.com/assets/content/ada94a00ba3648b0d01f5bbf870b152b02ac6eb1bd1d245d8b46a54527416853.png",alt:"",className:I.Uw}),(0,i.jsx)("img",{src:"https://cdn.discordapp.com/assets/content/096964379958760a2615df5128a9022ac6de873c8f7a6af0beadb1c958ce55ea.png",alt:"",className:I.Gv})]}),t]}):t}}