Module 904290

3,426 characters · in 3d3b05863accbf32.js
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>M});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(3203),o=n(192308),u=n(408278),c=n(308528),d=n(688810),m=n(355622),h=n(408018),p=n(138617),f=n(195880),g=n(45787),E=n(95701),A=n(562153),C=n(183555),x=n(448613),I=n(597770),_=n(751188),S=n(17928),y=n(451988),v=n(775602),T=n(21161),N=n(652215),j=n(375708);function b(e){let{user:t,analyticsLocations:n,confettiEnabled:s=!0,onClose:r}=e,{giftButtonRef:a,handleMouseEnter:o}=function(e){let{enabled:t}=e,n=(0,S.bG)([v.Ay],()=>v.Ay.useReducedMotion),l=i.useRef(null),s=i.useRef(0),{createMultipleConfettiAt:r}=i.useContext(T.x),a=i.useMemo(()=>({size:{type:"static-random",minValue:2,maxValue:6},velocity:{type:"static-random",minValue:{x:-10,y:-25},maxValue:{x:10,y:-5}},dragCoefficient:{type:"static",value:.001}}),[]),o=i.useCallback(()=>{if(n)return;let e=l.current?.getBoundingClientRect();null!=e&&r(e.left+e.width/2,e.top+e.height/2,a,30)},[r,n,a]);return i.useEffect(()=>{if(!t||n)return;let e=new y.J_(1e3,o);return e.delay(),()=>e.cancel()},[t,n,o]),{giftButtonRef:l,handleMouseEnter:i.useCallback(()=>{t&&(s.current+=1,s.current%4==0&&o())},[t,o])}}({enabled:s}),{openGiftModal:c}=(0,_.$)({giftRecipient:t,analyticsLocations:n,analyticsObject:{page:N.liQ.USER_PROFILE,section:N.JJy.USER_PROFILE,object:N.ZSU.BUTTON_ICON,objectType:N.AnalyticsObjectTypes.GIFT},location:"gift-button-with-confetti"}),d=i.useCallback(()=>{c(),r?.()},[c,r]);return(0,l.jsx)("div",{ref:a,onMouseEnter:o,children:(0,l.jsx)(u.K,{size:"sm",variant:"icon-only",icon:I.o,"aria-label":j.intl.string(j.t.PEjaCx),onClick:d})})}var R=n(788868),P=n(831111);let L=(0,E.createChannelRecord)({id:"1",type:N.rbe.DM});function M(e){let{user:t,guildId:s,channelId:E,onClose:I,disableAutoFocus:_=!1,upsell:S=!1}=e,{newestAnalyticsLocation:y,analyticsLocations:v}=(0,d.Ay)(),{trackUserProfileAction:T}=(0,C.NJ)(),[N,M]=i.useState(""),[O,w]=i.useState((0,h.x7)(N)),k=i.useRef(!1),D=i.useRef(null),U=i.useRef(null),{Component:G}=(0,a.V)(),F=i.useMemo(()=>({...m.oU.USER_PROFILE,disableAutoFocus:_}),[_]),V=i.useCallback(async()=>{(0,g.xs)(t.id),await c.A.openPrivateChannel({recipientIds:[t.id]}),(0,o.openModalLazy)(async()=>{let{default:e}=await Promise.all([n.e("30593"),n.e("22638"),n.e("8891"),n.e("95501")]).then(n.bind(n,367516));return t=>(0,l.jsx)(e,{...t,giftIntentType:R.np.FRIEND_ANNIVERSARY,analyticsLocationHistory:v})})},[t.id,v]),B=i.useCallback(()=>(0,l.jsxs)("div",{className:P.Uo,children:[(0,l.jsx)(u.K,{size:"sm",variant:"icon-only",icon:G,"aria-label":j.intl.string(j.t.I61IsE),onClick:V}),(0,l.jsx)(b,{user:t,analyticsLocations:v,onClose:I,confettiEnabled:S})]}),[G,V,t,v,I,S]);return(0,l.jsx)(p.Ay,{className:r()(P.kL,{[P.UX]:S}),editorClassName:P.EN,type:F,placeholder:j.intl.formatToPlainString(j.t["0ZQw/X"],{name:A.Ay.getName(s,E,t)}),channel:L,textValue:N,richValue:O,onChange:(e,t,n)=>{t!==N&&(M(t),w(n))},focused:k.current,onFocus:()=>{k.current=!0},onBlur:()=>{k.current=!1},onSubmit:async e=>{let{value:n}=e,l=n.trim();if(""===l)return{shouldClear:!1,shouldRefocus:!0};(D.current!==l||null==U.current)&&(D.current=l,U.current=(0,f.m)());try{return T({action:"SEND_DIRECT_MESSAGE"}),await (0,x.p)({userId:t.id,content:l,openChannel:!0,whenReady:!0,location:y,nonce:U.current??void 0}),D.current=null,U.current=null,I?.(),{shouldClear:!0,shouldRefocus:!1}}catch{return{shouldClear:!1,shouldRefocus:!1}}},renderButtons:S?B:void 0})}}