Build 562131stable
Module 953832
10,676 characters · in 8cd630370cafd3af.jsDependencies
Lazily required by (0)none
Requires (60)
5471792828289317176191664700651547139397483135621138617140735151054155718189213191023192308222713223863232835287809294454355622375708378570403362408018438729448381465364465532477262503698513480530912559647573435576705582068588975602853619517627968652215659674661531691540734057735438745812765178783465834730837381857250885386885918892547915089928039
Lazily requires (1)
Source Raw
function(e,t,n){n.d(t,{ForwardModal:()=>ef});var l=n(627968),a=n(64700),i=n(735438),s=n(837381),r=n(189213),o=n(17928),u=n(765178),c=n(834730),d=n(691540),h=n(857250),m=n(97483),g=n(192308),f=n(892547),x=n(140735),C=n(559647),p=n(465532),A=n(928039),b=n(408018),j=n(915089),v=n(547),k=n(135621),w=n(378570),y=n(223863),R=n(151054),S=n(734057),P=n(31717),E=n(232835),M=n(403362),N=n(885918),_=n(513480),D=n(530912),F=n(71393),T=n(287809),I=n(652215);function L(e){if(!e.isPrivate()){let t=F.A.getGuild(e.guild_id);return null!=t&&t.features.has(I.GuildFeatures.INTERNAL_EMPLOYEE_ONLY)}return e.recipients.every(e=>{let t=T.default.getUser(e);return null!=t&&t.isStaff()})}var O=n(355622),V=n(138617),U=n(294454),G=n(375708),B=n(745812);function H(e){let{message:t,canSend:n,selectedDestinations:i,onSend:s,inputValue:r,setInputValue:o}=e,u=(0,k.A)(),c=(0,_.QK)(i),d=(0,D.VF)(),{textValue:h,richValue:m}=r,[g,f]=a.useState(!1),x=a.useCallback(()=>f(!0),[]),C=a.useCallback(()=>f(!1),[]),A=a.useCallback((e,n,l)=>{o({textValue:n,richValue:l}),null!=t&&(p.A.saveDraft(t.channel_id,n,P.C.ForwardContextMessage),d(t.channel_id,t.id))},[d,t,o]),b=a.useCallback(()=>{null!=t&&(p.A.clearDraft(t.channel_id,P.C.ForwardContextMessage),s(h))},[t,s,h]),j=a.useCallback(()=>(!n||h.length>u||b(),Promise.resolve({shouldClear:!1,shouldRefocus:!0})),[b,h,u,n]);return(0,l.jsx)(V.Ay,{innerClassName:B.OG,onChange:A,placeholder:G.intl.string(G.t.ZroO3G),channel:c,textValue:h,richValue:m,type:O.oU.FORWARD_MESSAGE_INPUT,onBlur:C,onFocus:x,focused:g,onSubmit:j,parentModalKey:U.aU,autoCompletePosition:"bottom",emojiPickerCloseOnModalOuterClick:!0,disableThemedBackground:!0})}var Q=n(503698),W=n.n(Q),X=n(602853),J=n(477262),K=n(65154),q=n(191023),z=n(588975),Y=n(661531),Z=n(155718),$=n(222713),ee=n(783465),et=n(573435),en=n(619517),el=n(448381),ea=n(465364),ei=n(438729),es=n(885386),er=n(576705),eo=n(659674),eu=n(582068),ec=n(28289);function ed(e){let{message:t,forwardOptions:n,channel:s}=e,r=es.hH.useSetting(),{attachments:u,embeds:d,hasContent:h,contentMessage:m}=function(e){let{message:t,channel:n,forwardOptions:l}=e,a=l?.onlyAttachmentIds,i=l?.onlyEmbedIndices,s=t.messageSnapshots[0]?.message??t,r=s.attachments;null!=a?r=s.attachments.filter(e=>a.includes(e.id)):null!=i&&(r=[]);let u=[];return(0,o.bG)([er.A],()=>null!=n&&!(0,eo.fS)(n,er.A)&&(0,eo.ax)(t))||(u=s.embeds,null!=i?u=s.embeds.filter((e,t)=>i.includes(t)):null!=a&&(u=[])),(null!=i||""===s.content&&u.length>0)&&(s=s.set("content",u.map(e=>e.url).join("\n"))),""===s.content&&s.embeds[0]?.rawDescription!=null&&(s=s.set("content",s.embeds[0].rawDescription)),{attachments:r,embeds:u,hasContent:""!==s.content&&null==a,contentMessage:s}}({message:t,channel:s,forwardOptions:n}),g=m.components.length>0&&m.components[0].type===Z.I5.CHECKPOINT_CARD?m.components[0].checkpointData:null,f=$.f[g?.cardId??0],x=(0,X.r)(f.primaryColor).hex(),C=a.useMemo(()=>h?(0,ea.Ay)(t,{formatInline:!0,allowLinks:!0,allowHeading:!0,allowList:!0,allowGameMentions:!0,hideSimpleEmbedContent:!1,contentMessage:m}).content:null,[m,h,t]),p=u.length,A=null,b=null,j=null;if(p>0||d.length>0){let e=(0,i.countBy)(u,e=>(0,el.NI)(e,!0)),t=e.IMAGE??0,n=e.VIDEO??0;t>0&&n>0?(A=G.intl.formatToPlainString(G.t.Lr0Top,{image_count:t,video_count:n}),b=J.s):n>0?(A=G.intl.formatToPlainString(G.t.SJ6pPX,{count:n}),b=K.S):t>0?(A=G.intl.formatToPlainString(G.t.h4pFfU,{count:t}),b=1===t?q.x:J.s):(A=G.intl.formatToPlainString(G.t["89ihS8"],{count:p}),b=z.P),n>0&&p===n?j=(0,l.jsxs)("div",{className:W()(ec.cR,ec.JZ),children:[(0,l.jsx)(en.Ay,{className:ec.xn,src:u[0].proxy_url,width:56,height:56}),(0,l.jsx)(K.S,{className:ec.uZ,size:"md",color:"white"})]}):p>0?j=(0,l.jsx)("div",{className:ec.cR,children:(0,l.jsx)(en.Ay,{src:u[0].proxy_url,width:56,height:56})}):d[0]?.thumbnail?.proxyURL!=null&&(j=(0,l.jsx)("div",{className:ec.cR,children:(0,l.jsx)(en.Ay,{src:d[0].thumbnail.proxyURL,width:56,height:56})}))}return p>1&&null!=j&&(j=(0,l.jsxs)("div",{className:ec.EW,children:[(0,l.jsx)(et.Ay,{mask:et.Ay.Masks.FORWARD_ATTACHMENT_PILE_OVERFLOW,width:56,height:56,children:j}),(0,l.jsxs)(c.E,{className:ec.mB,variant:"text-xs/semibold",color:"text-default",children:["+",p-1]})]})),(0,l.jsxs)("div",{className:ec.sq,children:[(0,l.jsxs)("div",{className:ec.FG,children:[null!=g&&(0,l.jsx)(c.E,{variant:"text-md/medium",children:G.intl.string(eu.default.goiR2u)}),h&&(0,l.jsx)(ei.Ay,{className:W()(ec.vp,p>0&&ec.NL),message:t,content:C,compact:r}),p>0&&(0,l.jsxs)("div",{className:ec.kp,children:[null!=b&&(0,l.jsx)(b,{size:"custom",width:h?18:20,color:Y.A.colors.TEXT_MUTED}),null!=A&&(0,l.jsx)(c.E,{variant:h?"text-sm/medium":"text-md/medium",color:"text-muted",children:A})]})]}),j,null!=g&&(0,l.jsx)("div",{className:ec.cR,children:(0,l.jsx)("img",{alt:"",style:{backgroundColor:x},width:56,height:56,src:(0,ee.OW)(g.cardId??0)})})]})}var eh=n(61916);let em=(0,j.Ld)();function eg(){return(0,l.jsx)("div",{className:B.wV,children:(0,l.jsx)(c.E,{variant:"text-md/normal",color:"text-muted",children:G.intl.string(G.t.V6nAfF)})})}function ef(e){let{message:t,initialSelectedDestinations:j=[],forwardOptions:F,onClose:I,onRequestSent:O,customTitle:V,customSubtitle:Q,customPreview:W,customSendHandler:X,customValidateDestination:J,additionalActions:K,source:q,...z}=e,Y=t?.channel_id,Z=t?.id,$=a.useMemo(()=>null!=Y?(0,y._5)(Y):void 0,[Y]),[ee,et]=a.useState(!1),en=(0,o.bG)([E.A],()=>"checkpoint"===q?t:null!=t?E.A.getMessage(t.channel_id,t.id)??t:void 0,[t,q]),el=(0,o.bG)([S.A],()=>null!=Y?S.A.getChannel(Y):void 0,[Y]),ea=(0,D.Jf)(),ei=(0,D.nL)(),es=a.useRef(0),er=a.useRef(0),[eo,eu]=a.useState(j),ec=eo.length,ef=ec>=5,ex=(0,_.QK)(eo),eC=(0,_.l2)(eo),ep=(0,o.bG)([P.A],()=>null!=en?P.A.getDraft(en.channel_id,P.C.ForwardContextMessage):""),[eA,eb]=a.useState(()=>(0,b.ur)(ep)),ej=(0,_.M6)(eo),ev=(0,k.A)(),[ek,ew]=a.useState(""),{results:ey,updateSearchText:eR}=(0,R.R)({selectedDestinations:eo,originDestination:$,includeMissingDMs:!0}),eS=a.useCallback(e=>{ew(e),eR(e)},[eR]),eP=a.useCallback(e=>{eS(e),er.current+=1,""!==e&&null!=Y&&null!=Z&&ei(Y,Z)},[Y,Z,ei,eS]),eE=a.useCallback(()=>{eS("")},[eS]),eM=a.useCallback(async()=>{null!=Y&&null!=Z&&(0,D.hH)({channelId:Y,messageId:Z,numDestinationChanges:es.current,numQueryChanges:er.current}),await I()},[Y,Z,I]),eN=a.useRef(null);a.useEffect(()=>{""===ek&&eN.current?.focus()},[ek]);let e_=a.useMemo(()=>(0,i.throttle)(()=>{(0,d.P0)((0,h.o)(G.intl.string(G.t.kwmYkt),m.Ck.FORWARD))},3e3,{leading:!0,trailing:!1}),[]),eD=a.useCallback((e,t)=>{null!=Y&&null!=Z&&ea(Y,Z,""!==ek);let n=!eo.some(t=>{let{type:n,id:l}=t;return n===e.type&&l===e.id});if(!n||!ef){if(null!=t){let e=n?G.t.u2qHzE:G.t["+yF0ds"];u.O.announce(G.intl.formatToPlainString(e,{name:t,count:n?ec+1:ec-1}),"polite")}es.current+=1,n&&eS(""),eu(t=>{let n=t.findIndex(t=>{let{type:n,id:l}=t;return n===e.type&&l===e.id});if(-1===n)return[e,...t];let l=[...t];return l.splice(n,1),l})}},[Y,ec,ef,Z,ek,eo,eS,ea]),eF=a.useCallback(async function(e){let{withMessage:a,transitionToDestination:i,closeAfterSend:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=X)return void await X(e,{withMessage:a,transitionToDestination:i,closeAfterSend:s},et);if(null==Y||null==Z)return void(0,d.P0)((0,h.o)(G.intl.string(G.t.R0RpRX),m.Ck.FAILURE));let r=E.A.getMessage(Y,Z)??t;if(null==r)return void(0,d.P0)((0,h.o)(G.intl.string(G.t.R0RpRX),m.Ck.FAILURE));et(!0);let o=(await Promise.all(e.map(y.pk))).filter(M.Vq);if(function(e,t){if(!T.default.getCurrentUser()?.isStaff())return!1;let n=S.A.getChannel(e.channel_id);return null!=n&&!!L(n)&&t.some(e=>{let t=S.A.getChannel(e);return!(null==t||t.isPrivate())&&!L(t)})}(r,o)&&!await new Promise(e=>{(0,g.openModalLazy)(async()=>{let{default:t}=await n.e("51954").then(n.bind(n,156073));return n=>(0,l.jsx)(t,{...n,onConfirm:()=>e(!0),onBack:()=>e(!1)})})}))return void et(!1);s&&(0,U.Be)(),O?.(),i&&(await v.A.fetchMessages({channelId:o[0]}),(0,w.iN)(o[0],{openTextInVoiceIfVoiceChannel:!0}));let u=await N.A.sendForwards(r,o,{...F,withMessage:a}),c=o.some(e=>{let t=S.A.getChannel(e);return null!=t&&t.rateLimitPerUser>0});if(u.every(e=>{let{status:t}=e;return"fulfilled"===t})){(0,D.TA)({channelId:Y,messageId:Z,hasError:!1,hasContextMessage:null!=a&&""!==a,numDestinations:o.length,numDestinationChanges:es.current,numQueryChanges:er.current,anyDestinationHasSlowmode:c}),e_();return}(0,D.TA)({channelId:Y,messageId:Z,hasError:!0,hasContextMessage:null!=a&&""!==a,numDestinations:o.length,numDestinationChanges:es.current,numQueryChanges:er.current,anyDestinationHasSlowmode:c});let f=e.filter((e,t)=>"rejected"===u[t].status);(0,U.vK)({message:r,failedDestinations:f,forwardOptions:F})},[Y,F,Z,t,O,e_,X]),eT=a.useCallback(e=>{eF(eo,{withMessage:e,transitionToDestination:1===eo.length,closeAfterSend:!0})},[eF,eo]),eI=a.useCallback(()=>{null!=en&&p.A.clearDraft(en.channel_id,P.C.ForwardContextMessage),eT(eA.textValue)},[en,eA.textValue,eT]),eL=(0,eh.s)({rowData:ey,message:en,originChannel:el,selectedDestinations:eo,handleToggleDestination:eD,disableSelection:ef,validateDestination:J}),eO=a.useRef(null),eV=(0,A.A)("forward-modal",eO),eU=a.useMemo(()=>ey.length>0?eL:{sections:[1],sectionHeight:0,renderRow:()=>(0,l.jsx)(eg,{}),rowHeight:72},[ey,eL]),eG=ec<=1?G.intl.string(G.t.TXNS7S):G.intl.formatToPlainString(G.t.jWtYUm,{count:ec});return(0,l.jsx)(s.hD,{navigator:eV,children:(0,l.jsx)(s.PR,{children:e=>{let{ref:t,...n}=e;return(0,l.jsx)(r.Modal,{...z,onClose:eM,title:V??G.intl.string(G.t["+SkRRj"]),subtitle:Q??(ef?G.intl.formatToPlainString(G.t["3Fbkir"],{count:5}):G.intl.string(G.t["VA+btJ"])),input:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(f.I,{ref:eN,query:ek,onChange:eP,onClear:eE,placeholder:G.intl.string(G.t["5h0QOP"]),"aria-label":G.intl.string(G.t["5h0QOP"]),autoFocus:!0}),eC.length>0&&(0,l.jsx)(x.A,{id:em,children:G.intl.formatToPlainString(G.t["5X5Oe2"],{names:eC.join(", ")})})]}),preview:W??(null!=en&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ed,{message:en,forwardOptions:F,channel:ex}),ej.length>0&&eA.textValue.length>0&&(0,l.jsx)(c.E,{className:B.Lt,variant:"text-sm/normal",color:"text-feedback-warning",children:G.intl.format(G.t.xJFpij,{count:ej.length,channelNames:ej.join(", ")})})]})),actionBarInput:(0,l.jsx)(H,{message:en,canSend:ec>0,selectedDestinations:eo,isSending:ee,onSend:eT,inputValue:eA,setInputValue:eb}),actions:[...K??[],{variant:"primary",text:eG,"aria-describedby":eC.length>0?em:void 0,onClick:eI,disabled:ec<=0||eA.textValue.length>ev,loading:ee,icon:C.l,iconPosition:"end"}],actionBarInputLayout:"chat-input",listProps:{...eU,...n,innerRole:void 0,ref:e=>{eO.current=e,t.current=e?.getScrollerNode()??null}}})}})})}}