Build 545032stable
Module 112541
76,071 characters · in f08fed5b39d8e5b5.jsDependencies
Lazily required by (0)none
Requires (98)
1428917928317173527735956376323840547167647007839095561112107143236154283155718157941168186186306203779209932222823224868234320264322267102284009287809317525317681321073323350323874332173339871351906355622365971375708376943392054408018427262442433453771459016465365465532485845494921503698522602527214531685545442551483562153565150565645579940607399608299625494626584627968635377649671650583652215654821667532670482677134721768723702730134730296734057735438741394768947770178775602778712785562820066826745827669842209861382871237877413885386927813939249941426967144990078994500
Source Raw
function(e,t,n){"use strict";let l;n.d(t,{A:()=>nt}),n(321073),n(323874),n(14289),n(35956);var i=n(627968),s=n(64700),r=n(503698),a=n.n(r),o=n(735438),c=n.n(o),u=n(607399),d=n(465532),h=n(608299),m=n(494921),p=n(155718),f=n(565150),g=n(861382),x=n(626584),A=n(522602),C=n(234320),E=n(453771),I=n(741394),y=n(355622),S=n(408018),v=n(579940),N=n(734057),_=n(222823),T=n(531685),j=n(365971);function b(e){let t=_.Ay.getChannelIdsForWindowId(e)[0];return null==t?null:N.A.getChannel(t)??null}var R=n(826745),O=n(442433),M=n(721768),L=n(723702),w=n(677134),k=n(652215),P=n(650583);let D=/(\t|\s)/;class U extends s.PureComponent{_ref;state={nextSelection:-1};componentDidMount(){this.props.disableAutoFocus||(Promise.resolve().then(()=>{let{value:e}=this.props;this._ref?.setSelection(e.length,e.length)}),this.focus()),null!=g.A.getActiveCommand(this.props.channel.id)&&M.Gf({channelId:this.props.channel.id,command:null,section:null})}componentDidUpdate(e,t){this.state.nextSelection!==t.nextSelection&&null!=this._ref&&this._ref.setSelection(this.state.nextSelection,this.state.nextSelection)}getCurrentWord(){let e=this._ref;if(null==e)return{word:null,fullWord:null,isAtStart:!1};let{value:t}=this.props;if(0===t.trim().length)return{word:null,fullWord:null,isAtStart:!1};let n=e.selectionStart,l=e.selectionEnd;for(;n>0&&!D.test(t[n-1]);)n--;let i=e.selectionEnd;for(;i<t.length&&!D.test(t[i]);)i++;return{word:t.slice(n,l),fullWord:t.slice(n,i),isAtStart:0===n}}focus=()=>{let{_ref:e}=this;null!=e&&e.focus()};blur(){let{_ref:e}=this;null!=e&&e.blur()}submit(e){return e?.preventDefault(),this.props.onSubmit(this.props.value)}insertAutocomplete(e,t){let{addSpace:n=!0,replaceFullWord:l=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{word:i,fullWord:s}=this.getCurrentWord();if(null==i)this.insertText(e,t,n);else{let t=this._ref;if(null==t)return;let r=t.value.slice(0,t.selectionStart-i.length),a=l&&null!=s?s.length-i.length:0,o=t.value.slice(t.selectionEnd+a);this._insertText(e,r,o,n)}}insertInlineAutocompleteInput(e){}replaceInlineAutocompleteInput(e,t,n){}insertText(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l=this._ref;if(null==l)return;let i=l.value.slice(0,l.selectionStart),s=l.value.slice(l.selectionEnd);this._insertText(e,i,s,n)}_insertText(e,t,n,l){if(null==this._ref)return;l&&(e+=" ");let i=t+e+n,{onChange:s}=this.props;s?.(null,i,(0,S.x7)(i));let r=t.length+e.length;this.setState({nextSelection:r},()=>{this.props.maybeShowAutocomplete()})}hasOpenCodeBlock(){let e=this._ref;if(null==e)return!1;let t=this.props.value.slice(0,e.selectionStart).match(/```/g);return null!=t&&t.length>0&&t.length%2!=0}render(){let{value:e,disabled:t,placeholder:n,required:l,onResize:s,className:r,id:o,submitting:c,textAreaPaddingClassName:u,spellcheckEnabled:d,"aria-controls":h,"aria-expanded":m,"aria-activedescendant":p}=this.props;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(C.EG,{event:k.jej.GLOBAL_CLIPBOARD_PASTE,handler:this.handleGlobalPaste}),(0,i.jsx)(R.y,{ref:this.handleSetRef,className:a()(r,u),id:o,rows:1,fontWidthEstimate:6,placeholder:n,disabled:t||c,required:l,onChange:this.handleOnChange,onResize:s,onKeyPress:this.handleKeyPress,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onFocus:this.props.onFocus,onBlur:this.props.onBlur,onPaste:this.handlePaste,onClick:this.handleClick,onContextMenu:this.handleContextMenu,value:t?"":e,tabIndex:0,spellCheck:d,"aria-controls":h,"aria-expanded":m,"aria-activedescendant":p,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-multiline":!0})]})}handleSetRef=e=>{this._ref=e};handleKeyPress=e=>{if(e.key===P.dh.ENTER&&!e.shiftKey&&!this.hasOpenCodeBlock()&&(!this.props.disableEnterToSubmit||e.ctrlKey))return e.preventDefault(),this.props.onSubmit(this.props.value)};handleKeyDown=e=>{switch(e.which){case k.Ks6.ARROW_DOWN:this.props.moveSelection(1)&&e.preventDefault();break;case k.Ks6.N:e.ctrlKey&&this.props.moveSelection(1)&&e.preventDefault();break;case k.Ks6.ARROW_UP:this.props.moveSelection(-1)&&e.preventDefault();break;case k.Ks6.P:e.ctrlKey&&this.props.moveSelection(-1)&&e.preventDefault();break;case k.Ks6.TAB:case k.Ks6.ENTER:this.handleTabOrEnterDown(e)}let{onKeyDown:t}=this.props;t?.(e)};handleTabOrEnterDown(e){e.key===P.dh.TAB&&this.props.onTab()||e.key===P.dh.ENTER&&this.props.onEnter(e)?(e.preventDefault(),e.stopPropagation()):e.key===P.dh.ESCAPE?(e.preventDefault(),e.stopPropagation(),this.props.hideAutocomplete()):e.key===P.dh.TAB&&this.hasOpenCodeBlock()&&(e.preventDefault(),e.stopPropagation(),this.insertText(" ",void 0,!1))}handleKeyUp=e=>{switch(e.key){case P.dh.ARROW_RIGHT:case P.dh.ARROW_LEFT:case P.dh.HOME:case P.dh.END:this.props.maybeShowAutocomplete()}let{onKeyUp:t}=this.props;t?.(e)};handleGlobalPaste=e=>{let{event:t}=e;this.handlePaste(t)||this.focus()};handlePaste=e=>{let t=this.props.onPaste(e);return t&&e.preventDefault(),t};handleClick=()=>{this.props.maybeShowAutocomplete()};handleContextMenu=e=>{L.isPlatformEmbedded&&(0,O.L3)(e,async()=>{let{default:e}=await Promise.all([n.e("30803"),n.e("42312")]).then(n.bind(n,216603));return t=>(0,i.jsx)(e,{...t,text:(0,w.u)()})},{align:"bottom",enableSpellCheck:!0})};handleOnChange=e=>{let{onChange:t,allowNewLines:n}=this.props,l=e.currentTarget.value,i=n?l:l.replace("\n","");t?.(e,i,(0,S.x7)(i))};insertEmoji(e){let{emoji:t,addSpace:n=!1}=e;this.insertText(`:${t.name}:`,void 0,n)}getFirstText(){return this.props.value}}var G=n(95561),V=n(625494),F=n(317681),H=n(186306),B=n(670482),W=n(267102),K=n(38405),z=n(654821),Z=n(35277),Y=n(820066),q=n(112107),J=n(17928),$=n(990078),X=n(778712),Q=n(939249),ee=n(545442),et=n(565645),en=n(730134),el=n(775602),ei=n(47167),es=n(376943),er=n(465365),ea=n(78390),eo=n(785562),ec=n(332173),eu=n(37632),ed=n(967144);n(209932);var eh=n(317525),em=n(994500),ep=n(351906),ef=n(287809),eg=n(871237),ex=n(562153),eA=n(427262),eC=n(375708),eE=n(178259);function eI(e){let{emoji:t}=e;return(0,i.jsx)($.m,{text:t.name,delay:750,position:"top",children:(0,i.jsx)(et.A,{src:t.src,emojiName:t.name,animated:!1,surrogate:t.surrogate})})}function ey(e){let{emoji:t}=e;return(0,i.jsx)($.m,{text:t.name,delay:750,position:"top",children:(0,i.jsx)(et.A,{emojiId:t.emojiId,emojiName:t.name,animated:t.animated})})}function eS(e){let{text:t}=e;return(0,i.jsx)(ec.A,{children:t})}function ev(e){let{id:t,guildId:n,channelId:l}=e,s=(0,J.bG)([ef.default],()=>ef.default.getUser(t)),r=(0,J.bG)([ep.A],()=>ep.A.hidePersonalInformation),a=ex.Ay.useName(n,l,s),o=(0,i.jsx)(ec.A,{children:null==a?`<@${t}>`:`@${a}`});if(null!=s){let e=r||s.hasUniqueUsername()?null:`#${s.discriminator}`;return(0,i.jsx)($.m,{__unsupportedReactNodeAsText:(0,i.jsxs)("div",{className:eE.fX,children:[(0,i.jsx)(en.A,{user:s,animate:!0,size:X._3.SIZE_16,className:eE.my}),eA.Ay.getUserTag(s,{mode:"username",identifiable:r?"never":"always"}),(0,i.jsx)("span",{className:eE.D2,children:e})]}),delay:750,position:"top","aria-label":eA.Ay.getUserTag(s,{decoration:"never"}),asContainer:!0,children:(0,i.jsx)(Q.D,{tag:"span",children:o})})}return o}function eN(e){let{id:t,guildId:n}=e,l=(0,J.bG)([eh.A],()=>null!=n?eh.A.getRole(n,t):void 0),s=(0,J.bG)([el.A],()=>el.A.roleStyle),r=(0,ed.X_)(n,l,l?.colorStrings);if(null==l)return(0,i.jsxs)("span",{children:["@",eC.intl.string(eC.t["YV4F/n"])]});let a=null!=l.color&&0!==l.color,o="username"===s&&a;return(0,i.jsxs)(ec.A,{color:o?l.color:null,roleColors:o?r:null,children:["dot"===s&&(0,i.jsx)(ee.W,{color:l.colorString,colors:r,background:!1,tooltip:!1}),"@",l.name]})}function e_(e){let{id:t}=e,n=(0,J.bG)([N.A],()=>N.A.getChannel(t)),l=eC.intl.string(eC.t.zLZPmk).toLowerCase(),s="text",r=!0;return(null!=n&&(l=(0,es.nc)(n)?(0,ei.m1)(n,ef.default,em.A):eC.intl.string(eC.t["/YzI63"]),s=(0,es.nc)(n)?(0,eg.QG)(n)??"text":"locked",r=(0,er.Y)(n.type)),r)?(0,i.jsx)(ec.A,{iconType:s,children:l}):(0,i.jsx)("span",{children:"#"+l})}function eT(e){let{id:t,itemId:n,guildId:l}=e,s=(0,ea.Q)(t),r=(0,ea.f)(t,n,l);return(0,i.jsxs)(ec.A,{iconType:t,children:[s,null!=r&&(0,i.jsx)(eu.A,{}),r]})}function ej(e){let{text:t,id:n}=e;return(0,i.jsxs)(ec.A,{children:[t,"(",n,")"]})}function eb(e){let{timestamp:t}=e;return(0,i.jsx)(eo.A,{node:t,className:"R"===t.format?eE.gS:null})}var eR=n(571898),eO=n(494715),eM=n(766184);let eL={strong:eR.bold,em:eR.italics,u:eR.underline,s:eR.strikethrough,inlineCode:eR.inlineCode,link:eR.fakeLink,url:eR.fakeLink,autolink:eR.fakeLink,silentPrefix:eR.fakeLink,spoiler:a()(eM.ur,eM.F0,eM.kx,eR.spoiler),staticRouteLink:eR.fakeLink,syntaxBefore:eR.syntaxBefore,syntaxAfter:eR.syntaxAfter,codeBlockText:eR.codeBlockText,codeBlockSyntax:eR.codeBlockSyntax,codeBlockLang:eR.codeBlockLang,subtext:eR.subtext};var ew=n(992595);let ek=e=>{let{className:t,attributes:n,children:l}=e,s=a()(eO.S0,eO.Cj,t);return(0,i.jsx)("span",{...n,className:s,contentEditable:!1,children:l})};var eP=n(422404);class eD extends s.PureComponent{containerRef=s.createRef();state;constructor(e){super(e),this.renderElement=this.renderElement.bind(this),this.renderLeaf=this.renderLeaf.bind(this),this.handleOnChange=this.handleOnChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleBeforeInput=this.handleBeforeInput.bind(this),this.handleCompositionStart=this.handleCompositionStart.bind(this),this.handleCompositionEnd=this.handleCompositionEnd.bind(this),this.handleFocusCapture=this.handleFocusCapture.bind(this),this.handleBlurCapture=this.handleBlurCapture.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePasteCapture=this.handlePasteCapture.bind(this),Y.VW.isEditorEmpty(e.editor)?this.state={initialValue:(0,S.N3)().richValue,showPlaceholder:!0}:this.state={initialValue:Y.VW.richValue(e.editor),showPlaceholder:!1}}componentDidMount(){this.props.editor.events.addListener("onChange",this.handleOnChange)}componentDidUpdate(e,t,n){e.editor!==this.props.editor&&(e.editor.events.removeListener("onChange",this.handleOnChange),this.props.editor.events.addListener("onChange",this.handleOnChange))}componentWillUnmount(){this.props.editor.events.removeListener("onChange",this.handleOnChange)}componentDidCatch(e,t){K.A.captureException(e,{extra:t}),this.setState({initialValue:[...this.props.editor.children]})}renderElement(e){let{guildId:t,channelId:n,renderExtraElement:l}=this.props,{attributes:s,children:r}=e;"rtl"===s.dir&&(s.style={...s.style,textAlign:"right"});let o=l?.(e)??function(e,t,n){let{attributes:l,children:s,element:r,decorations:o}=e,c=Object.entries(o?.[0]??{}).filter(e=>{let[t]=e;return"anchor"!==t&&"focus"!==t}).map(e=>{let[t,n]=e;return!0===n&&t in eL?eL[t]:null}).filter(e=>null!=e).join(" ");switch(r.type){case"line":if(r.codeBlockState?.isInCodeBlock)return(0,i.jsx)("div",{className:eR.codeLine,spellCheck:null==r.codeBlockState||null==r.codeBlockState.lang,...l,children:s});return(0,i.jsx)("div",{...l,children:s});case"blockQuote":{let e=a()(ew.h,ew.MN);return(0,i.jsxs)("div",{...l,className:e,children:[(0,i.jsx)("span",{contentEditable:!1,className:ew.r}),(0,i.jsx)("blockquote",{children:s})]})}case"emoji":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(eI,{emoji:r.emoji}),s]});case"customEmoji":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(ey,{emoji:r.emoji}),s]});case"textMention":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(eS,{text:r.name}),s]});case"userMention":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(ev,{id:r.userId,channelId:n,guildId:t}),s]});case"roleMention":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(eN,{id:r.roleId,guildId:t}),s]});case"channelMention":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(e_,{id:r.channelId}),s]});case"staticRouteLink":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(eT,{id:r.id,itemId:r.itemId,guildId:t}),s]});case"soundboard":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(q.LF,{soundId:r.soundId}),s]});case"commandMention":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(ej,{text:r.commandName,id:r.commandId}),s]});case"timestamp":return(0,i.jsxs)(ek,{attributes:l,className:c,children:[(0,i.jsx)(eb,{timestamp:r.parsed}),s]});default:return null}}(e,t,n);return null!=o?o:(0,i.jsx)("div",{...s,children:r})}renderLeaf(e){let{editor:t,renderExtraLeaf:n}=this.props,{attributes:l,children:s}=e,r=n?.(e)??function(e,t){let n,{attributes:l,children:s,leaf:r,text:o}=t,c=!1,[u]=Y.VW.node(e,Y.PW.parent(Y.VW.findPath(e,o)));switch(Y.VW.isEditor(u)?"editor":u.type){case"line":case"blockQuote":{c=void 0;let e=Object.entries(r).filter(e=>{let[t]=e;return"text"!==t}).flatMap(e=>{let[t,n]=e;if("hljsTypes"===t)return n;if(!0===n){if(("codeBlockLang"===t||"codeBlockSyntax"===t)&&(c=!1),t.startsWith("before_")||t.startsWith("after_"))return[eR[t]];if(t in eL)return[eL[t]];throw Error(`Slate: Unknown decoration attribute: ${t}`)}}).filter(e=>null!=e).join(" ");n=a()(e,{[eR.syntaxOverride]:"||"===r.text||"\\"===r.text})}}return n=a()(n,{[eO.BI]:""===o.text}),(0,i.jsx)("span",{...l,className:n,spellCheck:c,children:s})}(t,e);return null!=r?r:(0,i.jsx)("span",{...l,children:s})}handleOnChange(){let{editor:e}=this.props,t=Y.VW.isEditorEmpty(e)&&null==e.composition;if(t!==this.state.showPlaceholder&&this.setState({showPlaceholder:t}),this.props.onChange?.(Y.VW.richValue(e)),!1===this.props.canFocus){let t=B.rL.findDocumentOrShadowRoot(e).getSelection();null!=t&&this.isSelectionPartiallyInside(t)&&t?.removeAllRanges()}}handleKeyDown(e){if(null!=this.props.editor.composition){e.preventDefault(),e.stopPropagation();return}this.props.onKeyDown?.(e)}handleKeyUp(e){if(null!=this.props.editor.composition){e.preventDefault(),e.stopPropagation();return}this.props.onKeyUp?.(e)}handleBeforeInput(e){let{editor:t}=this.props,n=B.rL.findDocumentOrShadowRoot(t).getSelection(),l=null!=n&&n.rangeCount>0?n.getRangeAt(0):null,i=e.getTargetRanges()[0]??null;if(null==t.composition){if(("insertText"===e.inputType||"insertReplacementText"===e.inputType)&&(null==i&&(i=l),null!=i)){let n=Y.VW.toSlateRange(t,i,{exactMatch:!1,suppressThrow:!0});null!=n&&null!=e.data&&(Y.ZF.isExpanded(n)?H.o.withSingleEntry(t,()=>{t.selection=n,t.deleteFragment(),t.insertText(e.data),e.preventDefault()}):(t.insertText(e.data),e.preventDefault()))}if(e.inputType.startsWith("deleteContent")&&null!=l&&!l.collapsed){let n=Y.VW.toSlateRange(t,l,{exactMatch:!0,suppressThrow:!0});null!=n&&Y.ZF.isExpanded(n)&&(t.selection=n,t.deleteFragment(e.inputType.endsWith("Backward")?"backward":"forward"),e.preventDefault())}}}handleCompositionStart(){let{editor:e}=this.props,t={insertedPrefix:!1,startedInsideInline:!1};this.state.showPlaceholder&&this.setState({showPlaceholder:!1});let n=null!=e.selection&&Y.ZF.isCollapsed(e.selection)?Y.VW.leaf(e,e.selection.anchor.path):null;if(null==n){e.composition=t;return}if(null!=(null!=e.selection&&Y.ZF.isCollapsed(e.selection)?Y.VW.above(e,{at:n[1],match:t=>Y.VW.isInline(e,t),mode:"lowest"}):null)&&(t.startedInsideInline=!0),Y.VW.isEditorEmpty(e)){Z.b.insertNodes(e,{text:"\uFEFF"},{select:!0}),t.insertedPrefix=!0,e.composition=t;return}let l=B.rL.findDocumentOrShadowRoot(this.props.editor).getSelection(),i=(l?.rangeCount??0)>0?l?.getRangeAt(0):null;if(null==(null!=i?Y.VW.toSlateRange(e,i,{exactMatch:!0,suppressThrow:!0}):null)&&null!=i){let t=Y.VW.toSlateRange(e,i,{exactMatch:!1,suppressThrow:!0});e.selection=null,null!=t?Z.b.select(e,t):Z.b.select(e,Y.VW.end(e,[]))}e.composition=t}handleCompositionEnd(e){let{editor:t}=this.props;if(null==t.composition)return;let{insertedPrefix:n}=t.composition;if(n&&null!=t.selection&&Y.ZF.isCollapsed(t.selection)){let e=t.selection.anchor.path,n=Y.AS.leaf(t,e);Y.VW.withoutNormalizing(t,()=>{let e=n.text.replace(/^\uFEFF/,"");Z.b.delete(t,{unit:"offset",distance:n.text.length,reverse:!0}),Y.VW.insertText(t,e)})}t.composition=null}handleFocusCapture(e){let{onFocus:t}=this.props;t?.(e)}handleBlurCapture(e){let{editor:t,onBlur:n}=this.props,l=e.relatedTarget,i=B.rL.findDocumentOrShadowRoot(this.props.editor),s=i.getElementById("textarea-context"),r=i.getElementById("slate-toolbar");if(null!=l&&!(0,z.hasDomParent)(l,s)&&!(0,z.hasDomParent)(l,r)){let e=B.rL.findDocumentOrShadowRoot(t).getSelection();null!=e&&this.isSelectionEscaping(e)&&e.removeAllRanges()}n?.(e)}isSelectionPartiallyInside(e){let t=this.containerRef.current;if(null!=e&&null!=t)for(let n=e.rangeCount-1;n>=0;n--){let l=e.getRangeAt(n),i=l.startContainer,s=l.endContainer,r=l.startOffset,a=l.endOffset;if((0,z.hasDomParent)(i,t)||!(0,z.isDOMRangeCollapsed)(i,r,s,a)&&(0,z.hasDomParent)(s,t))return!0}return!1}isSelectionEscaping(e){let t=this.containerRef.current,n=!1,l=!1;if(null!=e&&null!=t)for(let i=e.rangeCount-1;i>=0;i--){let s=e.getRangeAt(i),r=s.startContainer,a=s.endContainer,o=s.startOffset,c=s.endOffset;if((0,z.hasDomParent)(r,t)){if(l)return!0;n=!0}else{if(n)return!0;l=!0}if(!(0,z.isDOMRangeCollapsed)(r,o,a,c))if((0,z.hasDomParent)(r,t)){if(l)return!0;n=!0}else{if(n)return!0;l=!0}}return!1}handleContextMenu(e){let{editor:t}=this.props,l=e.pageY,s=window.innerHeight;if(L.isPlatformEmbedded){let r=(0,W.zd)();(0,O.L3)(e,async()=>{let{default:e}=await Promise.all([n.e("10310"),n.e("58273"),n.e("14591"),n.e("96804"),n.e("30803"),n.e("22401")]).then(n.bind(n,258360));return n=>(0,i.jsx)(e,{...n,editor:t,text:Y.VW.getSelectedText(t,!0)})},{align:null!=l&&null!=s&&l<s/2?"top":"bottom",enableSpellCheck:r===k.BRT.APP,repositionOnContentChange:!0})}else blur()}handlePasteCapture(e){let{editor:t,onPaste:n,readOnly:l}=this.props;n?.(e),e.isDefaultPrevented()||e.isPropagationStopped()||l||(t.insertData(e.clipboardData),e.preventDefault(),e.stopPropagation())}render(){let{editor:e,className:t,containerClassName:n,canFocus:l,autoFocus:s,placeholder:r,decorate:o,channelId:c,guildId:u,onChange:d,onFocus:h,onBlur:m,onKeyDown:p,onKeyUp:f,renderExtraElement:g,renderExtraLeaf:x,...A}=this.props;return(0,i.jsxs)("div",{ref:this.containerRef,className:n,children:[this.state.showPlaceholder?(0,i.jsx)("div",{className:a()(eP.q,t),"aria-hidden":!0,children:r}):null,(0,i.jsx)(B.A,{editor:e,value:[...this.state.initialValue],children:(0,i.jsx)(B.Fo,{...A,className:a()(ew.PT,eP.E,t),decorate:o,renderElement:this.renderElement,renderLeaf:this.renderLeaf,onFocusCapture:this.handleFocusCapture,onBlurCapture:this.handleBlurCapture,onContextMenu:this.handleContextMenu,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onDOMBeforeInput:this.handleBeforeInput,onCompositionStart:this.handleCompositionStart,onCompositionEnd:this.handleCompositionEnd,onPasteCapture:this.handlePasteCapture,autoFocus:s&&!1!==l,autoCorrect:"off","data-can-focus":!1!==l,"aria-label":r,"aria-multiline":!0})})]})}}var eU=n(323350);function eG(e,t,n,l){let i=0;for(let s=0;s<n.length;s++){let r=n[s];if(null==r)continue;let a=i+r.length;if(l<=a){let n=Y.PW.child(t,s),r=Y.VW.node(e,n)[0];if(Y.l5.isText(r))return{path:n,offset:Math.min(Math.max(l-i,0),r.text.length)}}i=a}let s=n.length-1;return{path:Y.PW.child(t,s),offset:n[s]?.length??0}}let eV=new Set(["line","blockQuote"]),eF=[];var eH=n(143236),eB=n(154283),eW=n(264322),eK=n(885386);n(667532);var ez=n(485845),eZ=n(459016),eY=n(842209),eq=n(392054),eJ=n(168186),e$=n(203779),eX=n(649671),eQ=n(551483);n(827669);let e0=new Set(["applicationCommandOption"]),e1=new Set([p.n4.ATTACHMENT]),e2=new Set(["line","applicationCommand"]);function e6(e,t,n,l){let[i]=Y.VW.blocks(e)[0],s=(l?(0,eU.IQ)(i,{mode:"plain"}).trimEnd():"").split("\n").map(e=>({type:"line",children:[{text:e}]})),r=[s.length-1];for(let[,t]of(Z.b.insertNodes(e,s,{at:eQ.Xg}),Y.VW.blocks(e).reverse()))Y.PW.isAfter(t,r)&&Z.b.removeNodes(e,{at:t,voids:!0});null!=n&&M.Gf({channelId:t,command:null,section:null})}function e3(e,t){if(null==t.options||1!==t.options.length||!0===t.options[0].required||e1.has(t.options[0].type)||F.O7(e).length>0||null==F.n$(e))return!1;let n=Y.VW.getFirstText(e);if(null==n)return!1;let l=t.options[0],i={path:eQ.fP,offset:t.displayName.length+2},s={path:eQ.fP,offset:n.text.length};return!(!n.text.startsWith(`/${t.displayName} `.toLocaleLowerCase())||Y.Kh.equals(i,s))&&(Z.b.textToInline(e,{type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:n.text.substring(t.displayName.length+2)}]},{anchor:i,focus:s}),!0)}function e7(e){let{guildId:t,channelId:n,command:l,activeOption:i,currentOptionValues:s,previousOptionValues:r,validateAll:a,allowEmpty:o}=e;if(null==l.options)return!1;let c=a?null:g.A.getActiveOptionName(n),u={},d=g.A.getOptionStates(n),h=!1;for(let e of l.options){let l=d[e.name],m=a||e.name===c&&c!==i||l?.lastValidationResult?.success===!1&&s?.[e.name]!==r?.[e.name],p={hasValue:null!=s&&e.name in s,isActive:e.name===i,lastValidationResult:m?(0,e$.J)({option:e,content:s?.[e.name]??null,guildId:t,channelId:n,allowEmptyValues:o}):l?.lastValidationResult};(null==l||l.hasValue!==p.hasValue||l.isActive!==p.isActive||m&&l.lastValidationResult?.success===!1)&&(u[e.name]=p,h=!0)}h&&M.H2(n,u)}function e4(e){let t=F.n$(e);if(null==t)return{command:null,commandText:null};let[n]=t,l=n.children[0];return Y.l5.isText(l)?{command:n.command,commandText:l.text}:{command:n.command,commandText:null}}function e5(e,t){let n=F.O7(e)[0];t();let l=Y.ZF.toPoint(e.selection);if(null==l||n===F.O7(e)[0])return;let{command:i,commandText:s}=e4(e);!(null==i||null==s||s.endsWith(" "))&&Y.Kh.equals(l,{path:eQ.fP,offset:i.displayName.length+1})&&Z.b.insertText(e," ")}function e8(e,t,n){let l=e.activeCommand?.options?.find(e=>e.name===n),i=e.initialValues[n];if(null==l||null==i)return null;if(null!=l.choices)return l.choices.find(e=>e.value===i.value)?.displayName;let s=i.value?.toString();return l.type===p.n4.CHANNEL||l.type===p.n4.MENTIONABLE&&null!=N.A.getChannel(s)?`<#${s}> `:l.type===p.n4.USER||l.type===p.n4.MENTIONABLE&&null!=ef.default.getUser(s)?`<@${s}>`:l.type===p.n4.ROLE||l.type===p.n4.MENTIONABLE&&null!=eh.A.getRole(t.guild_id,s??k.dJq)?`<@&${s}>`:s}var e9=n(635377),te=n.n(e9),tt=n(941426),tn=n(730296);let tl=new Map,ti=new Map,ts=new Set;function tr(e){let t=tl.get(e);if(null!=t)return t;if(!(e in tn.pb)){let t=Promise.resolve(null);return tl.set(e,t),t}return t=(null==l&&(l=(0,tn.A)()),l).then(t=>t.loadGrammar(tn.pb[e])).then(t=>{for(let n of(ti.set(e,t),ts))n(e);return t}),tl.set(e,t),t}var ta=n(157941),to=n(768947),tc=n(927813),tu=n(618559);let td=new tt.Vy("withCodeBlocks"),th=new Set(["line"]),tm=/^[a-z0-9_+\-.#]+$/i,tp=null,tf=null;function tg(e,t){let n=function(e,t){let n=[],l=null;for(let t of Y.VW.blocks(e))l=function(e,t,n,l,i){let s=function(e){let t,[n,l]=e;if(!th.has(n.type))return[];let i=[],s=/\\|```/g;for(let e=0;e<n.children.length;e++){let r=n.children[e];if(Y.l5.isText(r))for(s.lastIndex=0;null!=(t=s.exec(r.text));){if("\\"===t[0]){s.lastIndex+=1;continue}i.push({path:Y.PW.child(l,e),offset:t.index})}}return i}(t),r=s[0],a=s[s.length-1],o=null;if(null!=a){let[t]=Y.VW.node(e,a.path);o=t.text.substring(a.offset+3)}let c=n&&null!=r,u=n&&0===s.length,d=l&&0===s.length,h=(c?s.slice(1):s).length%2==1,m=h&&(null==o||""===o||null!=o.match(tm)),p=m&&null!=o&&""!==o?o.toLowerCase():null;return{blockEntry:t,wasInCodeBlock:n,isInCodeBlock:u,isStyledCodeBlockLine:d,lang:h||c?p:i,hljsTypes:null,closesCodeBlock:c,opensCodeBlock:h,opensCodeBlockOnOwnLine:m}}(e,t,null!=l&&(l.isInCodeBlock||l.opensCodeBlock),null!=l&&(l.isStyledCodeBlockLine||l.opensCodeBlockOnOwnLine),null!=l&&(l.opensCodeBlock||!l.closesCodeBlock)?l.lang:null),n.push(l);return function(e,t){let n=ta.L.getConfig({location:"syntaxHighlightCodeBlocks"}).enabled,l=[],i=!1;for(let s of e){let r=s===e[e.length-1];if((s.closesCodeBlock||r)&&(i&&r&&!s.closesCodeBlock&&l.push(s),i=!1,l.length>0)){let e=l.map(e=>(0,eU.IQ)(e.blockEntry[0])).join("\n"),i=l[0].lang;if(null!=i&&n)!function(e,t,n,l){let i=function(e,t,n,l){let i,s=(0,to.py)(t);if(null==s)return null;let r=`${e}-${s}`,a=ty.get(r);if(null!=a&&a.length===n)return a;for(let t of e.split("\n"))if(t.length>1e3)return null;let o=ti.has(s)?ti.get(s)??null:(tr(s),null);if(null==o)return l?.(s),null;let c=e.endsWith("\n")?e:`${e}
`,u=o.createSession();try{u.setText(c);let e=u.highlightToHtml();if(i=e.html,null!=l)for(let t of e.missingInjections)l(t)}finally{u.free()}let d=i.endsWith("\n")?i.slice(0,-1).split("\n"):i.split("\n");if(d.length!==n)return null;let h=[];for(let e=0;e<n;e++)h.push(function(e){let t,n=[],l=[],i=0,s=0;for(tA.lastIndex=0;null!=(t=tA.exec(e));){let r=t.index+t[0].length,a=tS(e.substring(s,t.index)).length,o=l.filter(e=>null!=e);if(a>0&&o.length>0&&n.push({types:o,start:i,end:i+a}),a>0&&(i+=a),null!=t[1]){let e=tC.get(t[1]);l.push(e??null)}else l.pop();s=r}let r=tS(e.substring(s)).length,a=l.filter(e=>null!=e);return r>0&&a.length>0&&n.push({types:a,start:i,end:i+r}),n}(d[e]));return ty.set(r,h),h}(e,t,n.length,l);if(null!=i)for(let e=0;e<n.length;e++)n[e].hljsTypes=i[e];else for(let e=0;e<n.length;e++)n[e].hljsTypes=[]}(e,i,l,t);else if(null==i||null==tp||tp.hasLanguage(i)){if(null!=i&&null!=tp&&tp.hasLanguage(i)){let t=function(e,t){if(null==tp)return null;let n=`${e}-${t}`,l=tI.get(n);if(null!=l)return l;let i=tp.highlight(t,e,!1);if(null==i||i.illegal)return null;let s=i.value.split("\n");return tI.set(n,s),s}(e,i);if(null!=t&&t.length===l.length){let e=[];for(let n=0;n<l.length;n++){let i,s=t[n].replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'"),r=[],a=0,o=0;for(;null!=(i=tx.exec(s));){let t=i.index+i[0].length,n=i.index-o;i.index>o&&(e.length>0&&r.push({types:[...e],start:a,end:a+n}),a+=n),"</span>"===i[0]?e.pop():e.push(i[1]),o=t}if(e.length>0){let t=s.length-o;r.push({types:[...e],start:a,end:a+t})}l[n].hljsTypes=r}}else for(let e=0;e<l.length;e++)l[e].hljsTypes=null}}else for(let e=0;e<l.length;e++)l[e].hljsTypes=[];l=[]}i&&l.push(s),s.opensCodeBlock&&(i=!0)}}(n,t),n}(e,t);return function(e,t){for(let l of t){var n;let[t,i]=l.blockEntry,s=(n=l).isStyledCodeBlockLine||n.wasInCodeBlock?{lang:n.lang,wasInCodeBlock:n.wasInCodeBlock,isInCodeBlock:n.isInCodeBlock,isStyledCodeBlockLine:n.isStyledCodeBlockLine,hljsTypes:n.hljsTypes}:null;t?.codeBlockState!=s&&Z.b.setNodes(e,{codeBlockState:s},{at:i})}}(e,n),n.some(e=>null!=e.lang)}let tx=/(?:<span class="([^"]*)">)|(?:<\/span>)/g,tA=/(?:<(a-[a-z]{1,2})>)|(?:<\/a-[a-z]{1,2}>)/g,tC=new Map;for(let[e,t]of Object.entries(tu))e.startsWith("a-")&&null!=t&&tC.set(e,t);let tE={max:1/0,maxAge:+tc.A.Millis.MINUTE,updateAgeOnGet:!0},tI=new(te())(tE),ty=new(te())(tE);function tS(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function tv(e,t){let n=0;for(let l of Y.VW.nodes(e,{at:{anchor:{path:eQ.fP,offset:0},focus:t},mode:"lowest",match:e=>Y.l5.isText(e)})){let e=l[0].text;Y.PW.equals(l[1],t.path)&&(e=e.substring(0,t.offset));let i=e.match(/```/g);n+=i?.length??0}return n%2!=0}function tN(e){if(null==e.selection)return!1;let t=Y.ZF.start(e.selection);return tv(e,t)}ts.add(()=>{ty.reset()});let t_=new Set(["line","blockQuote"]),tT=["applicationCommand"],tj=["timestampMentionInput"];function tb(e){let t=Y.VW.getCurrentBlock(e),n=Y.VW.getCurrentInline(e);return null!=t&&!tT.includes(t[0].type)&&!tj.includes(n?.[0]?.type)}function tR(e){return{type:"other",mergeable:!1,createdAt:Date.now(),value:Y.VW.richValue(e),selection:e.selection}}var tO=n(877413),tM=n.n(tO),tL=n(284009),tw=n.n(tL),tk=n(339871);function tP(e,t){let{cmd:n=!1,ctrl:l=!1,alt:i=!1,shift:s=!1}=t;return(null==n||e.metaKey===n)&&(null==l||e.ctrlKey===l)&&(null==i||e.altKey===i)&&(null==s||e.shiftKey===s)}let tD=e=>{let t=Y.VW.getCurrentBlock(e);if(null!=t){let n=Y.VW.start(e,t[1]);return Z.b.select(e,{anchor:n,focus:n}),!0}return!1},tU=e=>{let t=Y.VW.getCurrentBlock(e);if(null!=t){let n=Y.VW.end(e,t[1]);return Z.b.select(e,{anchor:n,focus:n}),!0}return!1};var tG=n(224868);let tV=/(@[^@#]+(?:#0|#\d{4}))|(@[^\s\t@#:]+)(?=[\s\t@:])|(:[a-zA-Z0-9_~]+:)|(#"(?:\ |\\\\|\\"|(?!")\w)+")|(#[^\s\t@#:]+(?=[\s\t@#:]))/g,tF=new Set(["emoji","customEmoji","textMention","userMention","roleMention","channelMention","staticRouteLink","soundboard","timestamp"]),tH=new Set(["timestampMentionInput"]),tB=new Set(["line","blockQuote"]),tW=new Set(["applicationCommandOption"]);function tK(e,t,n){let l=Y.VW.areStylesDisabled(e);for(let i of Y.VW.blocks(e))if(tB.has(i[0].type))l?tZ(e,i,!0,null):tz(e,i,t,n);else{let[s,r]=i;for(let i=s.children.length-1;i>=0;i--){let a=s.children[i];if(!Y.l5.isText(a)&&tW.has(a.type)){let s=[a,Y.PW.child(r,i)];l?tZ(e,s,!0,null):tz(e,s,t,n)}}}}function tz(e,t,n,l){let i="line"===t[0].type&&t[0].codeBlockState?.isInCodeBlock===!0,s=Y.cv.markdown(t[0],n);tZ(e,t,i,s)&&(t=Y.cv.updateElement(e,t),s=Y.cv.markdown(t[0],n)),i||(tY(e,t,l,s)&&(t=Y.cv.updateElement(e,t),s=Y.cv.markdown(t[0],n)),function(e,t,n,l,i){let[s,r]=t;for(let a=s.children.length-1;a>=0;a--){let o,c=s.children[a];if(!Y.l5.isText(c))continue;let u=Y.PW.child(r,a),d=[];for(tV.lastIndex=0;null!=(o=tV.exec(c.text));){if(0!==o.index&&null==c.text.charAt(o.index-1).match(/(\t|\s)/)){tV.lastIndex=o.index+1;continue}if(tq(e,r,{path:u,offset:o.index},i))continue;let s=(0,tG.p)(o[0],n,l);null!=s&&tJ(l,t[0],s)?d.push({index:o.index,length:o[0].length,node:s}):tV.lastIndex=o.index+1}for(let t of d.reverse())(function(e,t,n,l,i){let[s,r]=t,a={path:r,offset:n},o={path:r,offset:n+l};tw()(a.offset>=0&&a.offset<=s.text.length,"Failed to find valid start position for raw mention replace"),tw()(o.offset>=0&&o.offset<=s.text.length,"Failed to find valid end position for raw mention replace"),Z.b.textToVoid(e,i,{anchor:a,focus:o})})(e,[c,Y.PW.child(r,a)],t.index,t.length,t.node)}}(e,t,n,l,s))}function tZ(e,t,n,l){let[i,s]=t,r=!1;for(let t=i.children.length-1;t>=0;t--){let a=i.children[t];if(Y.l5.isText(a)&&!n){let n=t<i.children.length-1?i.children[t+1]:null;if(null==n||!Y.cv.isElement(n)||!e.isVoid(n))continue;let l=!1,o=0;for(;;){let e=a.text.indexOf("\\",o);if(-1===e)break;if(e===a.text.length-1){l=!0;break}o=e+2}if(l){let l=Y.PW.child(s,t+1);Z.b.voidToText(e,(0,eU.IQ)(n,{mode:"plain",preventEmojiSurrogates:!0}),l),r=!0}}else if(Y.cv.isElement(a)&&e.isVoid(a)){let i=Y.PW.child(s,t),o={path:Y.PW.child(i,0),offset:0};(n||null!=l&&tq(e,s,o,l))&&(Z.b.voidToText(e,(0,eU.IQ)(a,{mode:"plain",preventEmojiSurrogates:!0}),i),r=!0)}}return r}function tY(e,t,n,l){let i=t[1],s=!1,r=[...l.entries].reverse();for(let a=0;a<r.length;a++){let o,c=r[a],u=r[a+1];if(null!=u&&u.text.endsWith("\\")&&c.start===u.start+u.text.length)continue;switch(c.attributes[0]){case"emoji":o={type:"emoji",emoji:{name:c.data.name,src:c.data.src,surrogate:c.data.surrogate,jumboable:!0===c.data.jumboable},children:[{text:""}]};break;case"customEmoji":o={type:"customEmoji",emoji:{emojiId:c.data.emojiId,name:c.data.name,animated:c.data.animated,jumboable:!0===c.data.jumboable},children:[{text:""}]};break;case"textMention":o={type:"textMention",name:c.data.text,children:[{text:""}]};break;case"mention":o={type:"userMention",userId:c.data.id,children:[{text:""}]};break;case"roleMention":o={type:"roleMention",roleId:c.data.id,children:[{text:""}]};break;case"channelMention":o={type:"channelMention",channelId:c.data.id,children:[{text:""}]};break;case"staticRouteLink":o={type:"staticRouteLink",id:c.data.id,itemId:c.data.itemId,children:[{text:""}]};break;case"soundboard":o={type:"soundboard",guildId:c.data.guildId,soundId:c.data.soundId,children:[{text:""}]};break;case"timestamp":o={type:"timestamp",parsed:c.data,children:[{text:""}]};break;case"timestampMentionInput":o={type:"timestampMentionInput",children:[{text:c.data.content}]};break;default:continue}if(!tJ(n,t[0],o))continue;let d=eG(e,i,l.serializedChildren,c.start),h=eG(e,i,l.serializedChildren,c.start+c.text.length);Z.b.textToVoid(e,o,{anchor:d,focus:h}),s=!0}return s}function tq(e,t,n,l){let i=0;for(let[l,s]of Y.VW.nodes(e,{at:{anchor:Y.VW.start(e,t),focus:n},mode:"lowest"}))Y.l5.isText(l)?Y.PW.equals(s,n.path)?i+=n.offset:i+=l.text.length:i+=1;for(let e of l.entries){if(!e.attributes.includes("codeBlockText")&&!e.attributes.includes("inlineCode"))continue;let t=e.start,n=e.start+e.text.length;if(t<=i&&n>=i)return!0}return!1}function tJ(e,t,n){if("applicationCommandOption"!==t.type)return!0;switch(t.optionType){case p.n4.CHANNEL:return"channelMention"===n.type;case p.n4.ROLE:return"roleMention"===n.type||"textMention"===n.type&&"@everyone"===n.name;case p.n4.USER:return"userMention"===n.type;case p.n4.MENTIONABLE:return"roleMention"===n.type||"userMention"===n.type||"textMention"===n.type&&"@everyone"===n.name;case p.n4.STRING:{let n=null!=e?g.A.getOption(e,t.optionName):null;return n?.choices==null&&n?.autocomplete!==!0}default:return!1}}function t$(e,t,n){let l=Y.VW.getCurrentInline(e);if("block"===t)return!0;let i=Y.VW.getCurrentText(e);if(null==i)return!0;let[s,r]=i,[a,o]=Y.VW.edges(e,r),c=Y.ZF.toPoint(e.selection);if(null==c)return!0;if(null!=l){let[t,n]=l;if(Y.VW.isEmpty(e,t)||Y.VW.isVoid(e,t))return Z.b.removeInline(e,n),!0}if("line"===t)if(null==l)return!1;else{let[i,s]=Y.VW.edges(e,l[1]);return Z.b.delete(e,{at:c,unit:t,reverse:n,select:!0,bounds:{anchor:i,focus:s}}),!0}let u=Y.VW.getParentBlock(e,c);if(null==u)return!0;let d=u[1],h=l;if(Y.Kh.equals(c,n?a:o))for(;;){let t=(n?Y.VW.before:Y.VW.after)(e,c);if(null==t)return!0;if(!Y.PW.isDescendant(t.path,d))break;if(c=t,null!=(h=Y.VW.getParentInline(e,t))){let[t,n]=h;if(Y.VW.isEmpty(e,t)||Y.VW.isVoid(e,t)){let t=Y.VW.before(e,n);return null!=t&&Z.b.select(e,t),Z.b.removeInline(e,n),!0}}let l=Y.VW.node(e,t.path);if(null==l||!Y.l5.isText(l[0]))return!0;if([s,r]=l,0!==s.text.length){[a,o]=Y.VW.edges(e,r);break}}return Z.b.delete(e,{at:c,unit:t,reverse:n,select:!0}),!0}var tX=n(527214);function tQ(e,t){let n=g.A.getActiveCommand(e.id),l=n?.options?.find(e=>e.name===t.optionName);return null!=l&&(l.type!==p.n4.STRING||l?.choices!=null||l?.autocomplete)}function t0(e,t,n,l){let i=Y.VW.areStylesDisabled(e)||null==n?t:n;H.o.withSingleEntry(e,()=>{Z.b.insertText(e,l?i+" ":i)})}var t1=n(770178);let t2={enabled:!0,fireOnMount:!0,fireOnDepsChange:!0};function t6(e){try{return Y.VW.toDOMNode(e,e)}catch(t){let e=Error(`Unable to find Slate EditorDOMNode: ${t.message}`);return e.stack=t.stack,K.A.captureException(e),null}}var t3=n(31717);let t7=e=>{let t,{channelId:n,element:l,attributes:r,children:o}=e,c=(0,B.f7)(),u=(0,B.zL)(),d=(0,B.RV)(),{optionType:h,errored:m}=(0,J.cf)([g.A],()=>({optionType:g.A.getOption(n,l.optionName)?.type,errored:g.A.getOptionState(n,l.optionName)?.lastValidationResult?.success!==!0}),[n,l.optionName]),f=(0,J.bG)([A.A],()=>A.A.getUpload(n,l.optionName,t3.C.SlashCommand),[n,l.optionName]),x=l.children[l.children.length-1],C=null!=x&&Y.l5.isText(x)&&x.text.endsWith("\n"),E=a()(eO.S0,eO.xP,{[eO.t$]:u&&c,[eO.$2]:(!u||!c)&&m}),I=s.useCallback(()=>{Y.VW.isVoid(d,l)||Z.b.selectCommandOption(d,l.optionName,!0)},[d,l]);return t=h===p.n4.ATTACHMENT?f?.filename!=null?(0,i.jsxs)("span",{className:a()(eO._K,eO.dU),contentEditable:!1,children:[f.filename,o]}):(0,i.jsxs)("span",{className:a()(eO._K,eO.ZI),contentEditable:!1,children:[eC.intl.string(eC.t.GRdFni),o]}):(0,i.jsxs)("span",{className:eO._K,children:[o,C?(0,i.jsx)("span",{className:eO.Nx,contentEditable:!1}):null]}),(0,i.jsxs)("span",{...r,className:E,children:[(0,i.jsxs)("span",{className:eO.gA,contentEditable:!1,onClick:I,children:[l.optionDisplayName,"\u200B"]}),t,(0,i.jsx)("span",{contentEditable:!1,children:"\u200B"})]})},t4=e=>{let{element:t,attributes:n,children:l}=e,s=(0,B.f7)(),r=(0,B.zL)(),o=a()(eO.S0,eO.xP,eO.Bz,{[eO.t$]:r&&s,[eO.$2]:t.error}),c=t.children[t.children.length-1],u=null!=c&&Y.l5.isText(c)&&c.text.endsWith("\n"),d=(0,i.jsxs)("span",{className:eO._K,children:[l,u?(0,i.jsx)("span",{className:eO.Nx,contentEditable:!1}):null]});return(0,i.jsxs)("span",{...n,className:o,children:[(0,i.jsxs)("span",{className:eO.gA,contentEditable:!1,children:["@time","\u200B"]}),d,(0,i.jsx)("span",{contentEditable:!1,children:"\u200B"})]})};var t5=n(471910);let t8=s.forwardRef(function(e,t){let l,r,o,c,u,d,{value:h,type:m,channel:f,className:x,id:E,disabled:I,submitting:v,placeholder:N,required:_,textAreaPaddingClassName:T,onChange:j,onPaste:b,onResize:R,onFocus:O,onBlur:L,onKeyDown:w,onKeyUp:D,onTab:U,onEnter:K,onSubmit:z,onSubmitFailure:q,maybeShowAutocomplete:J,hideAutocomplete:$,moveSelection:X,spellcheckEnabled:Q,canUseCommands:ee,canOnlyUseTextCommands:et,disableAutoFocus:en,disableEnterToSubmit:el,allowNewLines:ei,"aria-owns":es,"aria-expanded":er,"aria-haspopup":ea,"aria-activedescendant":eo,"aria-controls":ec,"aria-invalid":eu,"aria-describedby":ed,"aria-labelledby":eh,"aria-autocomplete":em}=e,ep=s.useRef(null),ef=s.useRef(null),eg=s.useRef(!0),ex=s.useRef(!0),eA=I||v,eE=s.useCallback((e,t,n)=>{let{value:l,selection:i}=n,s=Y.VW.richValue(e),r=e.selection,a=!1;if(void 0!==l&&l!==s){if(e.children=l,"parent"===t&&!e.previewMarkdown&&e.chatInputType===y.oU.EDIT){try{e.previewMarkdown=!0,tK(e,f.guild_id,f.id)}finally{e.previewMarkdown=!1}tK(e,f.guild_id,f.id),i=void 0}"undo"!==t&&void 0!==l&&l!==s&&H.o.insertEntry(e,"other",!1,s,r),a=!0}if(null==i||Y.Ot.isValid(e,i)||(i=void 0),(a||!Y.Ot.isValid(e,r))&&void 0===i){let t=Y.VW.end(e,[]);i={anchor:t,focus:t}}let o=null!=i&&!Y.Ot.equals(i,r);if(a&&!en&&Y.VW.focus(e),null!=i&&o){e.selection=i;let t=H.o.currentEntry(e);null!=t&&(t.selection=i),a=!0}let c=F.n$(e);if(null!=c&&c[0].command.id!==g.A.getActiveCommand(f.id)?.id&&H.o.withMergedEntry(e,()=>{e6(e,f.id,null,!0)}),a)if("parent"===t)try{ex.current=!1,e.onChange()}finally{ex.current=!0}else e.onChange()},[f.id,f.guild_id,en]),eI=function(e){let t=s.useContext(W.Ay),l=eK.SI.useSetting(),[i]=s.useState(()=>{let i=(0,eB.ie)();return i.children=(0,S.x7)(""),i.selection={anchor:eQ.K,focus:eQ.K},function(e){var t,l;let{editor:i,chatInputType:s,channel:r,canUseCommands:a,canOnlyUseTextCommands:o,windowContext:c,previewMarkdown:u,forTests:d,onChangeStart:h,onChangeEnd:m,updateState:f}=e,x=i,{onChange:A}=x;x.chatInputType=s,x.windowContext=c,x.previewMarkdown=u,x.composition=null,x.events=new eH.EventEmitter,x.isMac="MacIntel"===navigator.platform,x.onChange=()=>{x.events.emit("onChange"),A()},(t=x=((e,t)=>{let{addMark:n,removeMark:l,deleteBackward:i,deleteForward:s,setFragmentData:r,insertData:a,insertFragmentData:o,insertTextData:c}=e;return(e=(0,B.o$)(e)).addMark=n,e.removeMark=l,e.setFragmentData=r,e.insertData=a,e.insertFragmentData=o,e.insertTextData=c,e.deleteBackward=n=>{if("line"===n&&!t){let t=Y.ZF.toPoint(e.selection);if(null!=t){let l=Y.VW.before(e,t,{unit:n});if(null!=l){let n=Y.e0.getLineStart(e,t,!1);null!=n&&Y.Kh.isAfter(n,l)?Z.b.delete(e,{at:{anchor:n,focus:t}}):Z.b.delete(e,{at:{anchor:l,focus:t}});return}}}i(n)},e.deleteForward=n=>{if("line"===n&&!t){let t=Y.ZF.toPoint(e.selection);if(null!=t){let l=Y.VW.after(e,t,{unit:n});if(null!=l){let n=Y.e0.getLineEnd(e,t,!1);null!=n&&Y.Kh.isBefore(n,l)?Z.b.delete(e,{at:{anchor:n,focus:t}}):Z.b.delete(e,{at:{anchor:l,focus:t}});return}}}s(n)},e})(x,!0===d)).setFragmentData=e=>{if(null!=t.selection&&!Y.Kh.equals(t.selection.anchor,t.selection.focus)){let n=(0,eU.WO)(Y.VW.richValue(t),{mode:"plain",range:t.selection,preventEmojiSurrogates:!0});e.setData("text/plain",n)}},t.insertData=e=>{t.insertTextData(e)},t.insertFragmentData=e=>!1,t.insertTextData=e=>{let n=e.getData("text/plain");if(0===n.length)return!1;if(null!=t.selection&&Y.ZF.isExpanded(t.selection)){let e=eB.KE.string(t,t.selection),l=(0,tX.W1)(n),i=(0,tX.W1)(e);if(null!=l&&null==i){let[e,n]=Y.ZF.edges(t.selection);return Y.VW.withoutNormalizing(t,()=>{Z.b.select(t,e),t.insertText("["),Z.b.select(t,n),0===Y.PW.compare(e.path,n.path)&&Z.b.move(t,{distance:1}),t.insertText(`](${l.target})`)}),!0}if(null!=l&&null!=i)return Z.b.delete(t,{at:t.selection}),t.insertText(l.target),!0;Z.b.delete(t,{at:t.selection})}return t.insertText(n),!0},x=function(e){let{apply:t,deleteBackward:n,deleteForward:l,deleteFragment:i,insertText:s}=e;return e.apply=n=>{if("set_selection"===n.type&&e.composition?.startedInsideInline&&Y.ZF.isRange(n.properties)&&Y.ZF.isRange(n.newProperties)&&Y.ZF.isCollapsed(n.newProperties)){let t=Y.VW.getParentInline(e,n.properties),l=Y.VW.getParentInline(e,n.newProperties);if(null!=t&&(null==l||!Y.PW.equals(t[1],l[1])))return}t(n)},e.insertText=t=>{null!=e.selection&&null!=Y.VW.getCurrentInline(e)?Z.b.insertText(e,t):s(t)},e.deleteBackward=t=>{t$(e,t,!0)||n(t)},e.deleteForward=t=>{t$(e,t,!1)||l(t)},e.deleteFragment=t=>{if(null!=e.selection&&Y.ZF.isExpanded(e.selection)){let n=e.selection.anchor,l=e.selection.focus,s=Y.VW.getParentInline(e,n),r=Y.VW.getParentInline(e,l);if(null!=s&&null!=r&&Y.PW.equals(s[1],r[1]))return void i(t);let a=Y.ZF.isForward(e.selection);if(null!=s){let[,t]=s,[l,i]=Y.VW.edges(e,t);a&&Y.Kh.equals(n,l)?n=Y.VW.before(e,l)??Y.VW.start(e,[]):!a&&Y.Kh.equals(n,i)&&(n=Y.VW.after(e,i)??Y.VW.end(e,[]))}if(null!=r){let[,t]=r,[n,i]=Y.VW.edges(e,t);!a&&Y.Kh.equals(l,n)?l=Y.VW.before(e,n)??Y.VW.start(e,[]):a&&Y.Kh.equals(l,i)&&(l=Y.VW.after(e,i)??Y.VW.end(e,[]))}return void Z.b.delete(e,{at:{anchor:n,focus:l},reverse:"backward"===t,select:!0})}i(t)},e}(x=t),s.commands?.enabled&&(x=function(e,t,n,l){let{insertData:i,isInline:s,isVoid:r,onChange:a,deleteBackward:o,deleteForward:c,deleteFragment:u}=e;e.insertData=n=>{if(null!=t&&Y.VW.isEditorEmpty(e)&&n.types.includes("application/x-discord-interaction-data")){let e=JSON.parse(n.getData("application/x-discord-interaction-data")),{commandKey:l,interactionOptions:i}=(0,eJ.Ez)(e),{application:s,command:r}=eY.EW({channel:t,type:"channel"},l);if(null!=r){let e=null!=s?{type:eq.Hf.APPLICATION,id:s.id,icon:s.icon,name:s.bot?.username??s.name,application:s}:null;return M.Gf({channelId:t.id,command:r,section:e,location:eq.Oh.PASTE,initialValues:(0,eZ.getInitialValuesFromInteractionOptions)(r,i??[])}),null}}return i(n)},e.isInline=e=>!!e0.has(e.type)||s(e),e.isVoid=e=>!!("applicationCommandOption"===e.type&&e1.has(e.optionType))||r(e),e.deleteBackward=t=>{e5(e,()=>o(t))},e.deleteForward=t=>{e5(e,()=>c(t))},e.deleteFragment=t=>{e5(e,()=>u(t))};let d=null,h=null,m=null,f=null,x=null;return e.onChange=()=>{if(null!=t){let i=g.A.getState(t.id),s=eY.j8({channel:t,type:"channel"});if(Y.VW.richValue(e)!==d||!Y.Ot.equals(e.selection,h)||i.activeCommand!==m||null==x||s.some((e,t)=>x[t]!==e)){let r=H.o.withMergedEntry(e,()=>(function(e){let{editor:t,storeCommandState:n,channel:l,canUseCommands:i,canOnlyUseTextCommands:s,commandChanged:r,previousOptionValues:a}=e,{command:o,commandText:c}=e4(t),u=n.activeCommand;if(!i&&u?.integration_types?.includes(ez.b.GUILD_INSTALL)||s&&u?.inputType!==eq.y$.BUILT_IN_TEXT&&u?.inputType!==eq.y$.BUILT_IN_INTEGRATION)return null!=o&&e6(t,l.id,u,!0),null;if(null!=o){if(Y.VW.isEditorEmpty(t)||null==u)return e6(t,l.id,u,!1),null;let e=`/${o.displayName}`;if(null==c||!c.startsWith(e)||0===F.O7(t).length&&(c.length<e.length+1||" "!==c[e.length]))return e6(t,l.id,u,!0),null}else{if(null!=u&&r){let e=function(e,t,n){let l,{initialValues:i,activeCommand:s}=n;if(null==s)return null;let r=(s.options?.length??0)>0?F.pY(e,s):null,a=(0,eU.WO)(Y.VW.richValue(e),{mode:"raw",range:{anchor:Y.VW.start(e,[]),focus:r?.[0]?.keyRange.anchor??Y.VW.end(e,[])}}),o="",c=a.toLocaleLowerCase(),u=`/${s.displayName} `.toLocaleLowerCase(),d=`/${s.untranslatedName} `.toLocaleLowerCase();c.startsWith(u)?o=a.substring(u.length).trim():c.startsWith(d)&&(o=a.substring(d.length).trim());let h=[],m=null,p=null;if(null!=s.options){let e=new Set;if(null!=r)for(let l of r){e.add(l.name);let i=e8(n,t,l.name)??l.text,s={type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:i}]};h.push(s),0===l.text.length&&null==m&&(m=s)}for(let l of s.options)if(!e.has(l.name)&&(l.required||null!=i[l.name])){let e,i;o.length>0&&!e1.has(l.type)?(e=o,o=""):e=(i=e8(n,t,l.name))??"";let s={type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:e}]};h.push(s),0===e.length&&null==m&&(m=s),null==i&&(p=s)}}l=o.length>0?`/${s.displayName} ${o.replace(/\r|\n/g," ")}`:0===h.length?`/${s.displayName} `:`/${s.displayName}`,h.unshift({text:l});let f={type:"applicationCommand",children:h,command:{id:s.id,name:s.untranslatedName,displayName:s.displayName}};Y.VW.withoutNormalizing(e,()=>{for(let[,t]of(Z.b.insertNodes(e,[f],{at:eQ.Xg}),Y.VW.blocks(e).reverse()))Y.PW.isAfter(t,eQ.Xg)&&Z.b.removeNodes(e,{at:t,voids:!0})});let g=null;return null!=m?(Z.b.selectCommandOption(e,m.optionName),g=m.optionName):null!=p?(Z.b.selectCommandOption(e,p.optionName,!1),g=p.optionName):Z.b.resetSelectionToEditorEnd(e),null==p&&e3(e,s),g}(t,l,n),i=F.SQ(t,u,l.id);return e7({guildId:l.guild_id,channelId:l.id,command:u,activeOption:e,currentOptionValues:i,previousOptionValues:null,validateAll:!0,allowEmpty:!0}),{commandId:u.id,optionValues:i}}if(null!=u&&!r)return M.Gf({channelId:l.id,command:null,section:null}),null;let e=Y.VW.richValue(t)[0],i=e.children[0];if(e2.has(e.type)&&Y.l5.isText(i)){let e=function(e,t){if(!e.startsWith("/"))return null;let n=(0,eX.Yn)(t,e.substring(1));if(!n.hasSpaceTerminator)return null;let{commands:l,sections:i}=eY.v7({channel:t,type:"channel"},p.kc.CHAT,n.text);if(0===l.length)return null;let s=n.text.trim(),r=s+" ",a=l.filter(e=>e.inputType!==eq.y$.PLACEHOLDER&&(e.displayName===s||e.displayName.startsWith(r)));if(1===a.length&&a[0].displayName===s){let e=a[0],t=i.find(t=>t.application?.id===e.applicationId);return{command:e,section:t}}return null}(i.text,l);if(null!=e)return M.Gf({channelId:l.id,command:e.command,section:e.section}),null}}if(null!=u&&null!=o){!function(e,t){if(null==t.options||0===t.options.length)return!1;let n=F.pY(e,t);return 0!==n.length&&(Y.VW.withoutNormalizing(e,()=>{for(let t=n.length-1;t>=0;t--){let l=n[t];Z.b.textToInline(e,{type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:l.text}]},{anchor:l.keyRange.anchor,focus:l.valueRange.focus})}let t=Y.VW.getFirstText(e);if(null==t)return!1;let l=t.text.trim();t.text!==l&&Z.b.textToText(e,l,{anchor:{path:eQ.fP,offset:0},focus:{path:eQ.fP,offset:t.text.length}})}),!0)}(t,u)&&e3(t,u);let e=F.SQ(t,u,l.id),n=Y.VW.above(t,{match:e=>Y.VW.isInline(t,e)&&"applicationCommandOption"===e.type,mode:"lowest"}),i=n?.[0].optionName??null;return e7({guildId:l.guild_id,channelId:l.id,command:u,activeOption:i,currentOptionValues:e,previousOptionValues:a,validateAll:!1,allowEmpty:!1}),{commandId:o.id,optionValues:e}}return null})({editor:e,storeCommandState:i,channel:t,canUseCommands:n,canOnlyUseTextCommands:l,commandChanged:i.activeCommand?.id!==m?.id,previousOptionValues:f}));if(null!=r){let t=H.o.currentEntry(e);null!=t&&(t.commandId=r.commandId),f=r.optionValues}else f=null;d=Y.VW.richValue(e),h=e.selection,m=i.activeCommand,x=s}}a()},e}(x,r,!0===a,!0===o)),x=function(e,t,n){let{isInline:l,isVoid:i,onChange:s}=e;e.isVoid=e=>!!tF.has(e.type)||i(e),e.isInline=e=>!!(tF.has(e.type)||tH.has(e.type))||l(e);let r=null,a=!0;return e.onChange=()=>{let l=Y.VW.richValue(e);(l!==r||e.previewMarkdown!==a)&&(H.o.withMergedEntry(e,()=>{Y.VW.withoutNormalizing(e,()=>tK(e,t,n))}),r=l,a=e.previewMarkdown),s()},e}(x,r.guild_id,r.id),s.markdown?.disableBlockQuotes||(x=function(e){let{deleteBackward:t,deleteFragment:n,insertBreak:l,onChange:i}=e;e.deleteBackward=n=>{let l=Y.VW.getCurrentBlock(e);if(l?.[0].type==="blockQuote"){let t=Y.ZF.toPoint(e.selection);if(null!=t&&Y.PW.isFirstChild(l[1],t.path)&&0===t.offset)return void Z.b.setNodes(e,{type:"line"},{at:l[1]})}t(n)},e.deleteFragment=t=>{if(null!=e.selection){let[l,i]=Y.ZF.edges(e.selection),s=[l.path[0]],r=Y.VW.node(e,s),a=[i.path[0]],o=Y.PW.equals(s,a)?null:Y.VW.node(e,a);H.o.withSingleEntry(e,()=>{r?.[0].type==="blockQuote"&&Y.Kh.isAtStart(l,r)&&Z.b.setNodes(e,{type:"line"},{at:s}),o?.[0].type==="blockQuote"&&Y.Kh.isAtEnd(i,o)&&Z.b.setNodes(e,{type:"line"},{at:a}),n(t)});return}n(t)},e.insertBreak=()=>{let t=Y.VW.getCurrentBlock(e);if(t?.[0].type==="blockQuote"){let n=Y.ZF.toPoint(e.selection);if(null==n)return;!function(e,t,n){if(!Y.VW.isEmpty(e,t[0]))return!1;let l=Y.VW.previous(e,{at:t[1]});return null!=l&&!!Y.AS.isType(l[0],"blockQuote")&&!!Y.VW.isEmpty(e,l[0])&&!!Y.Kh.isAtStart(n,t)&&(Z.b.setNodes(e,{type:"line"},{at:t[1]}),Z.b.removeNodes(e,{at:l[1]}),!0)}(e,t,n)&&Z.b.splitNodes(e,{at:n,always:!0});return}l()};let s=null,r=!0;return e.onChange=()=>{let t=Y.VW.richValue(e);(t!==s||e.previewMarkdown!==r)&&(H.o.withMergedEntry(e,()=>{Y.VW.withoutNormalizing(e,()=>(function(e){let t=!1;for(let n of Y.VW.blocks(e)){let[l,i]=n;if(!t_.has(l.type))continue;let s={path:Y.PW.child(i,0),offset:0};if(tv(e,s)){"blockQuote"===l.type&&(Z.b.setNodes(e,{type:"line"},{at:i}),Z.b.insertText(e,"> ",{at:s}));continue}if("blockQuote"===l.type||Y.VW.areStylesDisabled(e))continue;let r=l.children[0];if(!Y.l5.isText(r))continue;let a=r.text.match(/^\s*>>> /),o=r.text.match(/^\s*> /);if((null!=o||null!=a||t)&&(Z.b.setNodes(e,{type:"blockQuote"},{at:i}),!t)){let n=o?.[0].length??a?.[0].length??0,l=Y.PW.child(i,0);Z.b.delete(e,{at:{anchor:{path:l,offset:0},focus:{path:l,offset:n}}}),t=null!=a}}})(e))}),s=t,r=e.previewMarkdown),i()},e}(x)),s.markdown?.disableCodeBlocks||(x=function(e){let{onChange:t}=e,l=null,i=!1,s=!1,r=e=>{tr(e).then(e=>{null!=e&&a()}).catch(()=>{})},a=()=>{s||(s=!0,queueMicrotask(()=>{s=!1;try{H.o.withoutSaving(e,()=>{Y.VW.withoutNormalizing(e,()=>tg(e,r))}),l=Y.VW.richValue(e)}catch(e){td.warn("error applying arborium highlighting to editor",e)}}))};return e.onChange=()=>{Y.VW.richValue(e)!==l&&(H.o.withoutSaving(e,()=>{Y.VW.withoutNormalizing(e,()=>{tg(e,r)&&null==tp&&!i&&(i=!0,(null==tf&&(tf=Promise.all([n.e("57036"),n.e("75134")]).then(n.bind(n,981776)).then(e=>{tp=e.default}).catch(e=>{throw tf=null,e})),tf).then(()=>{l=null,H.o.withoutSaving(e,()=>{Y.VW.withoutNormalizing(e,()=>tg(e))}),l=Y.VW.richValue(e)}).catch(()=>{}).finally(()=>{i=!1}))})}),l=Y.VW.richValue(e)),t()},e}(x)),d&&(x=function(e){let{isInline:t,isVoid:n}=e;return e.isInline=e=>"testInline"===e.type||"testInlineVoid"===e.type||t(e),e.isVoid=e=>"testInlineVoid"===e.type||n(e),e}(x)),(l=x).onKeyDown=e=>{let t=l.isMac;switch(e.which){case k.Ks6.B:if(!Y.VW.isEditorEmpty(l)&&tP(e,{ctrl:!t,cmd:t}))return(0,tk.Px)(l,"bold"),!0;break;case k.Ks6.I:if(!Y.VW.isEditorEmpty(l)&&tP(e,{ctrl:!t,cmd:t}))return(0,tk.Px)(l,"italics"),!0;break;case k.Ks6.U:if(!Y.VW.isEditorEmpty(l)&&tP(e,{ctrl:!t,cmd:t}))return(0,tk.Px)(l,"underline"),!0;break;case k.Ks6.S:if(!Y.VW.isEditorEmpty(l)&&tP(e,{ctrl:!t,cmd:t,shift:!0}))return(0,tk.Px)(l,"strikethrough"),!0;break;case k.Ks6.TAB:if(null!=l.selection&&tP(e,{shift:null})){let[t,n]=Y.ZF.edges(l.selection),i=Y.VW.blocks(l).slice(t.path[0],n.path[0]+1),s=!0;for(let[e]of i)if("line"!==e.type||!e.codeBlockState?.isInCodeBlock){s=!1;break}if(s){if(!e.shiftKey&&Y.ZF.isCollapsed(l.selection))return Z.b.insertText(l," "),!0;let t=!e.shiftKey;return H.o.withSingleEntry(l,()=>{let e=l.selection?.anchor??Y.VW.start(l,[]),n=l.selection?.focus??Y.VW.end(l,[]);for(let[s,r]of i){let i=s.children[0];if(!Y.l5.isText(i))continue;let a=Y.PW.child(r,0),o={path:a,offset:0};if(t)Z.b.insertText(l," ",{at:o}),Y.PW.equals(e.path,a)&&0!==e.offset&&(e={path:a,offset:e.offset+2}),Y.PW.equals(n.path,a)&&0!==n.offset&&(n={path:a,offset:n.offset+2});else if(i.text.startsWith(" ")){let t={path:Y.PW.child(r,0),offset:2};Z.b.delete(l,{at:{anchor:o,focus:t}}),Y.PW.equals(e.path,a)&&(e={path:a,offset:Math.max(0,e.offset-2)}),Y.PW.equals(n.path,a)&&(n={path:a,offset:Math.max(0,n.offset-2)})}}Z.b.select(l,{anchor:e,focus:n})}),!0}}break;case k.Ks6.ARROW_LEFT:case k.Ks6.ARROW_RIGHT:{let n;if(tP(e,{shift:null}))n="character";else if(tP(e,{ctrl:!t,alt:t,shift:null}))n="word";else if(t&&tP(e,{cmd:!0,shift:null}))return!1;else return!1;let i=l.children[l.selection?.focus?.path[0]??0],s="rtl"===tM()(Y.AS.string(i)),r=e.which===k.Ks6.ARROW_LEFT==!s;return Z.b.keyboardMove(l,{reverse:r,unit:n,edge:e.shiftKey?"focus":void 0}),!0}case k.Ks6.A:if(t&&tP(e,{ctrl:!0})&&tD(l))return!0;break;case k.Ks6.E:if(t&&tP(e,{ctrl:!0})&&tU(l))return!0;break;case k.Ks6.HOME:if(tP(e,{shift:!1,ctrl:!1})&&tD(l))return!0;break;case k.Ks6.END:if(tP(e,{shift:!1,ctrl:!1})&&tU(l))return!0;break;case k.Ks6.BACKSPACE:case k.Ks6.DELETE:case k.Ks6.K:let n=e.which===k.Ks6.BACKSPACE;if((!t&&e.which!==k.Ks6.K&&tP(e,{ctrl:!0,shift:!0})||t&&e.which!==k.Ks6.K&&tP(e,{cmd:!0})||t&&e.which===k.Ks6.K&&tP(e,{ctrl:!0}))&&null!=l.selection){let[e,t]=Y.ZF.edges(l.selection),[i,s]=Y.VW.node(l,[n?e.path[0]:t.path[0]]);if(tw()(Y.VW.isBlock(l,i),"Top-most node of selection is not a block"),n&&!Y.Kh.isAtStart(e,[i,s])||!n&&!Y.Kh.isAtEnd(t,[i,s]))return n?l.deleteBackward("line"):l.deleteForward("line"),!0}}return!1},x=function(e,t){let{apply:n,deleteBackward:l,deleteForward:i,deleteFragment:s,insertData:r,insertText:a,onChange:o}=e;function c(n){let l=H.o.currentEntry(e);if(null!=l&&(l.mergeable=!1),n>=e.history.stack.length)return;e.history.index=n;let i=H.o.currentEntry(e);t({newValue:i.value,newSelection:i.selection})}e.history={index:0,stack:[]},e.onChange=()=>{let{history:t}=e;0===t.stack.length&&(t.stack=[tR(e)],t.index=0),null!=e.selection&&(H.o.currentEntry(e).selection=e.selection),d=null,o()},e.undo=()=>{e.history.index>0&&c(e.history.index-1)},e.redo=()=>{e.history.index<e.history.stack.length-1&&c(e.history.index+1)};let u=null,d=null,h=null;return e.apply=t=>{let{history:l}=e;n(t);let i=Y.VW.richValue(e);i!==h&&(0===l.stack.length&&(l.stack=[tR(e)],l.index=0),H.o.isSaving(e)&&(function(e,t,n){var l,i;let s,{selection:r}=e,a=H.o.currentEntry(e),o=!0,c=!0;if("insert_text"===t.type&&1===t.text.length?(s="insert",c=!((""===t.text||t.text.endsWith(" "))&&n?.type==="insert_text"&&!(""===n.text&&n.text.endsWith(" ")))):"split_node"===t.type?s="insert":"remove_text"===t.type&&1===t.text.length?s="delete":(s="other",o=!1,c=!1),"set_selection"===t.type&&null!=a){a.selection=r;return}o&&(l=a,i=s,!(l?.type!==i||Date.now()-l.createdAt>=4e3))?H.o.insertOrMergeEntry(e,s,c):H.o.insertEntry(e,s,c)}(e,t,u),u=t),d=t,h=i)},e.deleteBackward=t=>{H.o.withSingleEntry(e,()=>l(t))},e.deleteForward=t=>{H.o.withSingleEntry(e,()=>i(t))},e.deleteFragment=t=>{H.o.withSingleEntry(e,()=>s(t))},e.insertText=t=>{1===t.length&&d?.type==="remove_text"?H.o.withMergedEntry(e,()=>a(t)):null!=e.selection&&Y.ZF.isExpanded(e.selection)?H.o.withSingleEntry(e,()=>a(t)):a(t)},e.insertData=t=>{d?.type==="remove_text"?H.o.withMergedEntry(e,()=>r(t)):H.o.withSingleEntry(e,()=>r(t))},e}(x=function(e,t,n){let{onChange:l}=e,i=!1,s=!1;return e.onChange=()=>{if(i){s=!0;return}i=!0;try{let e=0;do{if(s=!1,e++>=5)break;t?.();try{l()}finally{n?.()}}while(s)}finally{i=!1}},e}(x=function(e){let{apply:t,onChange:n}=e;return e.apply=n=>{t(n),Y.Ot.isValid(e,e.selection)&&(e.lastGoodSelection=e.selection)},e.onChange=()=>{if(Y.Ot.isValid(e,e.selection)||(e.selection=function(e){let t;if(Y.Ot.isValid(e,e.lastGoodSelection))t=e.lastGoodSelection;else{let n=Y.VW.end(e,[]);t={anchor:n,focus:n}}return t}(e)),null!=e.selection){let t,n,[l,i]=Y.ZF.edges(e.selection),s=!1;for(;null!=l&&null!=(t=Y.VW.getParentVoid(e,l))&&!eQ.XR.includes(t[0].type);)l=Y.VW.before(e,l,{unit:"offset"}),s=!0;for(;null!=i&&null!=(n=Y.VW.getParentVoid(e,i))&&!eQ.XR.includes(n[0].type);)i=Y.VW.after(e,i,{unit:"offset"}),s=!0;s&&null!=l&&null!=i&&(Y.ZF.isForward(e.selection)?Z.b.select(e,{anchor:l,focus:i}):Z.b.select(e,{anchor:i,focus:l}))}n()},e}(x=function(e){let{insertBreak:t,insertText:n}=e;return e.insertBreak=()=>{tb(e)&&t()},e.insertSoftBreak=()=>{e.insertBreak()},e.insertText=t=>{if(0>t.indexOf("\r")&&0>t.indexOf("\n"))return void n(t);let l=t.split(/\r\n|\r|\n/);tb(e)?H.o.withSingleEntry(e,()=>{let t=!1;for(let i of l)t&&Z.b.splitNodes(e,{always:!0}),n(i),t=!0}):n(l.join(" "))},e}(x=l)),h,m),e=>{let{newValue:t,newSelection:n}=e;return f(x,"undo",{value:t,selection:n})})}({...e,editor:i,windowContext:t,previewMarkdown:l}),i});return s.useEffect(()=>{let e=()=>i.onChange();return g.A.addChangeListener(e),eW.Ay.addChangeListener(e),()=>{g.A.removeChangeListener(e),eW.Ay.removeChangeListener(e)}},[i]),s.useEffect(()=>{i.previewMarkdown!==l&&(i.previewMarkdown=l,i.onChange())},[i,l]),i}({channel:f,chatInputType:m,canUseCommands:ee,canOnlyUseTextCommands:et,onChangeStart:s.useCallback(()=>{eg.current=!1},[]),onChangeEnd:s.useCallback(()=>{eg.current=!0},[]),updateState:eE}),ey=s.useCallback((e,t)=>{let n=F.SQ(eI,e,f.id),l=F.cd(e,f.guild_id,f.id,n,t);return{values:n,results:l}},[f.guild_id,f.id,eI]),eS=s.useCallback(()=>{let e,t=Y.VW.getNodesOfType(eI,["timestampMentionInput"]),n=null!=t?[...t]:null,l=ee?g.A.getActiveCommand(f.id):null,i=!1;if(null!=l&&null!=l.options){let t=ey(l,!1);e=t.values;let n=F.O7(eI).filter(e=>!t.results[e].success).map(e=>(l.options??[]).find(t=>t.name===e));for(let e of l.options)!e.required||e.name in t.values||(Z.b.insertCommandOption(eI,e),n.push(e));if(n.length>0){let e=n[0];Z.b.selectCommandOption(eI,e.name),i=!0,(0,G.zV)(k.HAw.APPLICATION_COMMAND_VALIDATION_FAILED,{application_id:l?.applicationId,command_id:l?.rootCommand?.id,argument_type:p.n4[e?.type??3],is_required:e?.required})}}if(null!=n)for(let[e,t]of n)Z.b.setNodes(eI,{error:!0},{at:t}),i||Z.b.select(eI,Y.VW.end(eI,t)),i=!0;if(i){V._.dispatch(k.jej.SHAKE_APP,{duration:200,intensity:2}),q?.();return}z?.((0,eU.WO)(Y.VW.richValue(eI),{mode:"raw",ignoreTrailingEmptyNodes:!0}),l,e)},[f.id,eI,z,q,ey,ee]);s.useImperativeHandle(t,()=>({getSlateEditor:()=>eI,submit(e){e?.preventDefault(),eS()},focus(){Y.VW.focus(eI)},blur(){B.rL.blur(eI)},getCurrentWord(){let e=eI.selection;if(null==e||!Y.Ot.isValid(eI,e)||Y.ZF.isExpanded(e)||tN(eI))return{word:null,isAtStart:!1};let[t,n]=Y.VW.node(eI,Y.PW.parent(e.anchor.path)),[l,i]=Y.VW.node(eI,e.anchor.path),s=e.anchor.offset;if(!Y.PW.hasPrevious(i)&&Y.l5.isText(l)){let e=l.text.substring(0,s);if(Y.AS.isType(t,"applicationCommand")&&s<t.command.displayName.length+2)return{word:e,isAtStart:!0}}let r="",a=!1;for(;;){if(--s<0){if(!Y.PW.hasPrevious(i)){a=!0;break}[l,i]=Y.VW.node(eI,Y.PW.previous(i))}if(!Y.l5.isText(l))break;let e=l.text[s];if(eQ.ug.test(e))break;r=e+r}let o=r,c=e.anchor.offset,[u]=Y.VW.node(eI,e.anchor.path);for(;Y.l5.isText(u)&&!(c>=u.text.length);){let e=u.text[c];if(eQ.ug.test(e))break;o+=e,c++}return{word:r,fullWord:o,isAtStart:a&&Y.PW.isFirstEditorBlock(n)}},getFirstText:()=>Y.VW.getFirstText(eI)?.text??"",getCurrentCommandOption(){let e=F.M3(eI);return null==e?null:e[0].optionName},getCurrentCommandOptionValue(){let e=F.M3(eI);if(null==e)return[];let t=g.A.getActiveCommand(f.id),n=t?.options?.find(t=>t.name===e[0].optionName);return null==n?[]:F.FV(eI,n,e[0],f.id)},getCommandOptionValues(){let e=g.A.getActiveCommand(f.id);return null==e?{}:F.SQ(eI,e,f.id)},insertText(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];H.o.withSingleEntry(eI,()=>{let l=F.M3(eI),i=null!=l&&tQ(f,l[0]);if(null!=t&&i&&(Z.b.removeInlineChildren(eI,l),n=!1),t0(eI,e,t,n),null!=t&&i){let e=F.n$(eI);if(l=Y.cv.updateElement(eI,l),null!=e){let t=Y.cv.markdown(e[0],f.guild_id);tY(eI,l,f.id,t)&&(l=Y.cv.updateElement(eI,l))}F.ke(eI,f.guild_id,f.id,Y.cv.updateElement(eI,l),!1),Z.b.selectNextCommandOption(eI)}})},insertAutocomplete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,{addSpace:n=!0,replaceFullWord:l=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};H.o.withSingleEntry(eI,()=>{let i=F.M3(eI),s=null!=i&&tQ(f,i[0]);if(s)Z.b.removeInlineChildren(eI,i),n=!1;else{let{word:e,fullWord:t}=this.getCurrentWord();null!=e&&e.length>0&&Z.b.delete(eI,{distance:e.length,unit:"character",reverse:!0}),l&&null!=e&&null!=t&&t.length-e.length>0&&Z.b.delete(eI,{distance:t.length-e.length,unit:"character"})}t0(eI,e,t,n),s&&Z.b.selectNextCommandOption(eI)})},insertInlineAutocompleteInput(e){H.o.withSingleEntry(eI,()=>{let{word:t}=this.getCurrentWord();null!=t&&t.length>0&&Z.b.delete(eI,{distance:t.length,unit:"character",reverse:!0}),Z.b.insertNodes(eI,[{type:e,children:[{text:""}]}])})},replaceInlineAutocompleteInput(e,t,n){H.o.withSingleEntry(eI,()=>{let l=Y.VW.getSelectedParentOfType(eI,[e]);tw()(null!=l,`Cannot replace inline input of type ${e} when none is selected`),Z.b.removeNodes(eI,{at:l[1]}),t0(eI,t,n,!0)})},insertEmoji(e){let{emoji:t,addSpace:n=!1}=e;H.o.withSingleEntry(eI,()=>{let e=t.animated?"a":"",l=t.originalName??t.name??"";t0(eI,`:${t.name}:`,null!=t.id?`<${e}:${l.replace(/:/g,"")}:${t.id}>`:null,n)})}}),[eI,f,eS]),l=s.useRef(null),r=s.useRef(null),o=s.useRef(null),s.useLayoutEffect(()=>{r.current=t6(eI),null==r.current&&null==o.current&&(o.current=setTimeout(()=>{r.current=t6(eI)},100))},[eI]),s.useEffect(()=>{let e=o.current;return()=>{null!=e&&clearTimeout(e)}},[]),c=s.useCallback(()=>{let e=r.current;if(null==e)return;let t=e.offsetHeight;l.current!==t&&(null!=ep.current&&(ep.current.style.height=`${t}px`),l.current=t,R?.(t))},[ep,R]),(0,t1.g)(r,c,[c,eI,R],t2),s.useLayoutEffect(()=>{let e=B.rL.findDocumentOrShadowRoot(eI).defaultView;if(e?.ResizeObserver==null)return;let t=t6(eI);null!=t&&(l.current=t.offsetHeight,R?.(l.current))},[ep,eI,R]);let{handleKeyDown:ev,handleKeyUp:eN}=function(e){let{editor:t,channel:n,disableEnterToSubmit:l,onKeyDown:i,onKeyUp:r,onTab:a,onEnter:o,allowNewLines:c,submit:u,hideAutocomplete:d,moveSelection:h}=e;return{handleKeyDown:s.useCallback(e=>{switch(e.which){case k.Ks6.ARROW_UP:if(h(-1))return void e.preventDefault();break;case k.Ks6.ARROW_DOWN:if(h(1))return void e.preventDefault();break;case k.Ks6.P:if(tP(e,{ctrl:!0})&&h(-1))return void e.preventDefault();break;case k.Ks6.N:if(tP(e,{ctrl:!0})&&h(1))return void e.preventDefault();break;case k.Ks6.ESCAPE:d?.();break;case k.Ks6.TAB:if(tP(e,{})&&a?.()){e.preventDefault(),e.stopPropagation();return}if(null!=g.A.getActiveCommand(n.id)){e.preventDefault(),e.stopPropagation(),e.shiftKey?Z.b.selectPreviousCommandOption(t):Z.b.selectNextCommandOption(t);return}break;case k.Ks6.ENTER:if(tP(e,{})&&o?.(e)){e.preventDefault(),e.stopPropagation();return}}if(t.onKeyDown?.(e)===!0){e.preventDefault(),e.stopPropagation();return}e.key!==P.dh.ENTER||(e.altKey||e.shiftKey||l&&!e.ctrlKey||tN(t))&&c||(e.preventDefault(),e.stopPropagation(),u()),i?.(e)},[c,n.id,l,t,d,h,o,i,a,u]),handleKeyUp:s.useCallback(e=>{r?.(e)},[r])}}({editor:eI,channel:f,disableEnterToSubmit:el,onKeyDown:w,onKeyUp:D,onTab:U,onEnter:K,allowNewLines:ei,submit:eS,hideAutocomplete:$,moveSelection:X}),{handlePaste:e_,handleGlobalPaste:eT}=(u=s.useCallback(e=>{if(eA)return!0;if(!0===e.defaultPrevented)return!1;let t=b(e);return t&&(e.preventDefault(),e.stopPropagation()),t},[eA,b]),d=s.useCallback(e=>{let{event:t}=e;u(t)||(t.preventDefault(),t.stopPropagation(),null!=t.clipboardData&&(eI.insertData(t.clipboardData),Y.VW.focus(eI)))},[eI,u]),{handlePaste:u,handleGlobalPaste:d}),ej=s.useCallback(e=>{J?.()},[J]),eb=s.useCallback(e=>{e!==ef.current?ex.current&&j?.(null,(0,eU.WO)(e,{mode:"raw"}),e):ex.current&&J()},[J,j]);s.useLayoutEffect(()=>{eg.current&&(ef.current=h,eE(eI,"parent",{value:h}))},[eI,h,eE]),s.useEffect(()=>{let e=()=>{let e=g.A.getActiveCommand(f.id)??null;null!==e&&null!=e.options&&ey(e,!0)};return A.A.addChangeListener(e),()=>A.A.removeChangeListener(e)},[f,eI,ey]);let eR=s.useCallback(e=>[...function(e,t,n){if(Y.VW.areStylesDisabled(e))return[];let[l,i]=t;if(1!==i.length||!Y.AS.isInTypes(l,eV))return eF;let{entries:s,serializedChildren:r}=Y.cv.markdown(l,n,!0),a=[];for(let t=0;t<s.length;t++){let n=s[t];if(n.attributes.length>0&&n.text.length>0){let l=s[t-1],o=s[t+1],c={anchor:eG(e,i,r,n.start),focus:eG(e,i,r,n.start+n.text.length)},u=Y.VW.nodes(e,{at:c,mode:"lowest",voids:!1}),d={};for(let e of n.attributes)if(d[e]=!0,"syntaxBefore"===e&&null!=o)for(let e of o.attributes)d[`before_${e}`]=!0;else if("syntaxAfter"===e&&null!=l)for(let e of l.attributes)d[`after_${e}`]=!0;for(let[t,n]of u){let t={anchor:Y.VW.start(e,n),focus:Y.VW.end(e,n)};Y.Kh.isBefore(t.anchor,c.anchor)&&(t.anchor=c.anchor),Y.Kh.isAfter(t.focus,c.focus)&&(t.focus=c.focus),a.push({...d,...t})}}}return a}(eI,e,f.guild_id),...function(e,t){if(Y.VW.areStylesDisabled(e))return[];let[n,l]=t,i=[];if(!Y.AS.isType(n,"line")||null==n.codeBlockState)return i;let{hljsTypes:s,isStyledCodeBlockLine:r}=n.codeBlockState;if(null==s||0===s.length||!r)return[];for(let t of s){let s=n.children.map(e=>Y.l5.isText(e)?e.text:null);i.push({hljsTypes:t.types,anchor:eG(e,l,s,t.start),focus:eG(e,l,s,t.end)})}return i}(eI,e),...function(e,t){if(Y.VW.areStylesDisabled(e))return[];let[n,l]=t,i=[];if(!Y.l5.isText(n))return i;let[s]=Y.VW.node(e,Y.PW.parent(l));return Y.AS.isType(s,"applicationCommand")&&n===s.children[0]&&i.push({anchor:{path:l,offset:0},focus:{path:l,offset:0+s.command.displayName.length+1},commandName:!0}),i}(eI,e)],[eI,f]),eM=s.useCallback(e=>{let t=function(e,t,n){let{attributes:l,children:s,element:r}=t;switch(r.type){case"applicationCommand":let a=g.A.getActiveCommand(n),o=0,c=0;if(null!=a&&a.id===r.command.id){let t=F.O7(e);for(let e of a.options??[])t.includes(e.name)?c++:o++}let u={};if(o>0){let e;e=c>0?eC.intl.formatToPlainString(eC.t.BP8N0K,{count:o}):eC.intl.formatToPlainString(eC.t.lziVC9,{count:o}),u["data-trailing-placeholder"]=e}return(0,i.jsx)("div",{className:eO.uB,...l,...u,children:s});case"applicationCommandOption":return(0,i.jsx)(t7,{attributes:l,channelId:n,element:r,children:s});default:return null}}(eI,e,f.id);return null==t&&(t=function(e){let{attributes:t,children:n,element:l}=e;return"timestampMentionInput"===l.type?(0,i.jsx)(t4,{attributes:t,element:l,children:n}):null}(e)),t},[f.id,eI]),eL=s.useCallback(e=>(function(e){let{attributes:t,children:n,leaf:l,text:s}=e;if(l.commandName){let e=a()(eO.p6,{[eO.BI]:""===s.text});return(0,i.jsx)("span",{...t,className:e,spellCheck:!1,children:n})}return null})(e),[]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(C.EG,{event:k.jej.GLOBAL_CLIPBOARD_PASTE,handler:eT}),(0,i.jsx)("div",{ref:ep,className:a()(x,t5.pC),children:(0,i.jsx)(eD,{id:E,editor:eI,channelId:f.id,guildId:f.guild_id,className:a()(t5.gf,T),placeholder:N,readOnly:eA,spellCheck:Q,autoFocus:!en,canFocus:!I,onChange:eb,onFocus:O,onBlur:L,onClick:ej,onPaste:e_,onKeyDown:ev,onKeyUp:eN,decorate:eR,renderExtraElement:eM,renderExtraLeaf:eL,"aria-owns":es,"aria-haspopup":ea,"aria-expanded":er,"aria-activedescendant":eo,"aria-controls":ec,"aria-labelledby":eh,"aria-describedby":ed,"aria-invalid":eu,"aria-autocomplete":em,"aria-required":_})})]})});var t9=n(266599);new x.A("ChannelEditor.tsx");let ne=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n]};class nt extends s.Component{ref=s.createRef();_focusBlurQueue=Promise.resolve();_unsubscribe;_initTimeoutId=null;_cachedEditorWindow=null;constructor(e){super(e),this._unsubscribe=v.Y0.subscribe(e=>{requestAnimationFrame(()=>{this.setState({popup:e})})}),this.state={focused:!1,submitting:!1,popup:v.Y0.getState()}}_getEditorWindow(){let e=this.ref?.current?.getSlateEditor?.()?.windowContext?.renderWindow;if(null==this._cachedEditorWindow||this._cachedEditorWindow!==e){if(null!=this._cachedEditorWindow&&null==e)return null;this._cachedEditorWindow=e??window}return this._cachedEditorWindow}componentDidMount(){this.props.focused&&requestAnimationFrame(()=>this.focus()),document.addEventListener("selectionchange",this.handleSelectionChange),window.addEventListener("beforeunload",this.handleBeforeUnload),this._initTimeoutId=setTimeout(()=>void this._getEditorWindow(),1e3)}componentDidUpdate(e){if(this.fixFocus(e),this.props.useSlate!==e.useSlate){let e;e=this.props.useSlate?this.props.textValue:(0,eU.WO)(this.props.richValue,{mode:"plain"}),this.props.onChange?.(null,e,(0,S.x7)(e))}else this.props.textValue!==e.textValue&&this.saveCurrentTextThrottled()}componentWillUnmount(){this.saveCurrentText(),this._unsubscribe?.(),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("selectionchange",this.handleSelectionChange),this._focusBlurQueue=null,this._unsubscribe=null,this._cachedEditorWindow=null,null!=this._initTimeoutId&&clearTimeout(this._initTimeoutId)}handleSelectionChange=()=>{this.props.focused&&this.props.onSelectionChanged(document.getSelection?.()?.toString())};focus=()=>{this._focusBlurQueue?.then(()=>{this.setState({focused:!0},()=>{let e=this.ref.current;null!=e&&e.focus()})})};blur(){let e=this.ref.current;null!=e&&e.blur()}submit(e){this.ref.current?.submit(e)}insertEmoji(e){let{emoji:t,willClose:n}=e,l=this.ref.current;null!=t&&null!=l&&(l.insertEmoji({emoji:t,addSpace:n}),n&&this.focus())}insertGIF(e){let{textValue:t}=this.props,n=this.ref.current;null!=e&&null!=n&&(t.endsWith(" ")||n.insertText(" ",void 0,!1),n.insertText(e.url))}insertSound(e){let{textValue:t}=this.props,n=this.ref.current;null!=e&&null!=n&&(t.endsWith(" ")||n.insertText(" ",void 0,!1),n.insertText(`<sound:${e.guildId}:${e.soundId}>`,void 0,!0))}insertKaomoji(e){let{textValue:t}=this.props,n=this.ref.current;if(null!=e&&null!=n){let l=t.length>0?e.replace(/([_`\xb4*])/g,"\\$1"):e;t.length>0&&!t.endsWith(" ")&&n.insertText(" ",void 0,!1),n.insertText(l,void 0,!0)}}handleOuterClick(){this.focus()}clearValue(){let{channel:e,type:t}=this.props;this.setState({focused:!0,submitting:!1}),d.A.saveDraft(e.id,"",t.drafts.type)}getCurrentWord(){let e=this.ref.current;return e?.getCurrentWord()??{word:null,isAtStart:!1}}insertAutocomplete(e,t,n){let l=this.ref.current;return l?.insertAutocomplete(e,t,n)}insertInlineAutocompleteElement(e){let t=this.ref.current;return t?.insertInlineAutocompleteInput(e)}replaceInlineAutocompleteInput(e,t,n){let l=this.ref.current;return l?.replaceInlineAutocompleteInput(e,t,n)}getCurrentCommandOption(){let e=this.ref.current;return e?.getCurrentCommandOption?.()??null}getCurrentCommandOptionValue(){let e=this.ref.current;return e?.getCurrentCommandOptionValue?.()??[]}getCommandOptionValues(){let e=this.ref.current;return e?.getCommandOptionValues?.()??{}}getFirstText(){let e=this.ref.current;return e?.getFirstText()??null}getSlateEditor(){let e=this.ref.current;return e?.getSlateEditor?.()??null}fixFocus(e){e.focused&&!this.props.focused?this.blur():!e.focused&&this.props.focused&&this.focus()}appendText(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];this.ref.current?.insertText(e,t,n)}saveCurrentText=(()=>{var e=this;return function(){let t=!(arguments.length>0)||void 0===arguments[0]||arguments[0],{type:n,channel:l}=e.props;n.drafts.autoSave&&(t&&e.saveCurrentTextThrottled.cancel(),e.handleSaveCurrentText(l.id))}})();handleBeforeUnload=()=>this.saveCurrentText();saveCurrentTextThrottled=c().throttle(this.saveCurrentText.bind(this,!1),500);getPlaceholder(){let{disabled:e,placeholder:t,isPreviewing:n,showValueWhenDisabled:l}=this.props;return e&&!n?l?"":eC.intl.string(eC.t.IYKTTc):t}handleEnter=e=>this.props.onEnter?.(e);handleTab=()=>this.props.onTab?.();handleMoveSelection=e=>this.props.onMoveSelection?.(e);maybeShowAutocomplete=()=>this.props.onMaybeShowAutocomplete?.();hideAutocomplete=()=>this.props.onHideAutocomplete?.();render(){let{textValue:e,richValue:t,disabled:n,onChange:l,onKeyDown:s,onResize:r,onSubmit:o,onSubmitFailure:c,channel:d,type:h,useSlate:m,spellcheckEnabled:p,useNewSlashCommands:f,canOnlyUseTextCommands:g,className:x,id:A,required:E,maxCharacterCount:I,allowNewLines:v,"aria-describedby":N,"aria-labelledby":_,accessibilityLabel:T,showValueWhenDisabled:j}=this.props,{submitting:b,popup:R}=this.state,O={channel:d,className:a()(x,t9.Tg,{[t9.w5]:m,[t9.Rr]:n||b}),id:A,placeholder:this.getPlaceholder(),required:E,accessibilityLabel:T,disabled:n||!1,submitting:b,isEdit:h===y.oU.EDIT,onFocus:this.handleFocus,onBlur:this.handleBlur,onPaste:this.handlePaste,onTab:this.handleTab,onEnter:this.handleEnter,moveSelection:this.handleMoveSelection,maybeShowAutocomplete:this.maybeShowAutocomplete,hideAutocomplete:this.hideAutocomplete,allowNewLines:v,onChange:l,onResize:r,onKeyDown:s,onSubmit:o,textAreaPaddingClassName:a()({[t9.H$]:h===y.oU.CREATE_FORUM_POST,[t9.g_]:h===y.oU.CUSTOM_GIFT,[t9.Yg]:h===y.oU.USER_PROFILE,[t9.$$]:h===y.oU.OVERLAY_INLINE_REPLY}),spellcheckEnabled:p,useNewSlashCommands:f,disableAutoFocus:u.Fr||(h.disableAutoFocus??!1),disableEnterToSubmit:h.submit?.disableEnterToSubmit??!1,"aria-controls":R.id??void 0,"aria-haspopup":"listbox","aria-expanded":null!==R.id||void 0,"aria-activedescendant":R.activeDescendant??void 0,"aria-invalid":e.length>I,"aria-describedby":N,"aria-labelledby":_,"aria-autocomplete":"list"},M=m?(0,i.jsx)(t8,{ref:this.ref,...O,type:h,value:n&&!j?(0,S.x7)(""):t,canUseCommands:h.commands?.enabled,canOnlyUseTextCommands:g,onSubmitFailure:c}):(0,i.jsx)(U,{ref:this.ref,...O,value:n&&!j?"":e});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(C.EG,{event:k.jej.INSERT_TEXT,handler:this.handleInsertText}),(0,i.jsx)(C.EG,{event:k.jej.CLEAR_TEXT,handler:this.handleClearText}),M]})}handleSaveCurrentText=e=>{d.A.saveDraft(e,this.props.textValue,this.props.type.drafts.type)};handleClearText=()=>{this.props.onChange?.(null,"",(0,S.x7)(""))};handleInsertText=e=>{let{plainText:t,rawText:n,addSpace:l=!1}=e;this.props.disabled||(this.appendText(t,n,l),this.focus())};handleFocus=e=>{let{onFocus:t}=this.props,{focused:n}=this.state;t?.(e),n||this.setState({focused:!0})};handleBlur=e=>{let{onBlur:t}=this.props,{focused:n}=this.state;t?.(e),n&&this.setState({focused:!1})};handlePaste=e=>{let t,n=e.target?.ownerDocument?.defaultView,{channel:l,canPasteFiles:i,uploadPromptCharacterCount:s,promptToUpload:r,maxCharacterCount:a,type:o}=this.props,c=null!=n?function(e){if(null==e)return null;let t=(0,j.Q2)(e);return null==t?null:b(t)}(n):null,u=null==(t=T.A.getFocusedWindowId())?null:b(t),d=!function(e,t){if(null==e||null==t)return!1;let n=(0,j.Q2)(e);return n===(0,j.Q2)(t)&&null!=n}(n,this._getEditorWindow())?c??u??l:l;if(null==r||!d.isPrivate()&&!i||d.isPrivate()&&d.isManaged())return!1;let{files:x,errors:C}=function(e,t){let n=[],l=[],i=null,s=null,r=[];for(let t of e.items)if("file"===t.kind){let e=t.webkitGetAsEntry?.()??t.getAsEntry?.()??null;if(null!=e&&!1===e.isFile){r.push({item:t,error:"is_directory"});continue}let i=t.getAsFile();if(null==i)continue;null!=i.path&&i.path.length>0?n.push(i):l.push(i)}else"string"===t.kind&&("text/plain"===t.type&&null==i?i=t:"text/html"===t.type&&null==s&&(s=t));if(n.length>0)return{files:n,errors:r};if(l.length>0){if(1===l.length&&"image/png"===l[0].type&&null!=s){let t=l[0],n=function(e){let t=new DOMParser().parseFromString(e,"text/html").querySelector("img");if(null!=t){let e;try{let{pathname:n}=new URL(t.src);null!=n&&n.length>0&&(e=(0,I.kh)(n))}catch{}if(null!=e&&e.length>0)return`${e}.png`}}(e.getData(s.type))??t.name;return{files:[(0,E.VE)(t,n,t.type)],errors:r}}return{files:l,errors:r}}if(null!=i&&null!=t){let n=e.getData(i.type);if(n.length>t){let e=new Blob([n],{type:"text/plain"});return{files:[(0,E.VE)(e,"message.txt","text/plain")],convertedStringToFile:!0,errors:r}}}return{files:[],errors:r}}(e.clipboardData,o.uploadLongMessages?s??a:null);return(ne("onPaste",[...e.clipboardData.items].map(e=>{if("file"!==e.kind)return{kind:e.kind,type:e.type};{let t=e.getAsFile();return{kind:e.kind,type:e.type,name:t?.name,path:t?.path}}})),0===x.length)?(C?.some(e=>{let{error:t}=e;return"is_directory"===t})&&(0,m.openUploadError)({title:eC.intl.string(eC.t.azO1Pe),help:eC.intl.string(eC.t["Koklr/"])}),!1):(e.preventDefault(),e.stopPropagation(),this.saveCurrentText(),(e=>{let t=g.A.getActiveCommand(d.id);if(null==t)return r(e,d,o.drafts.type,{requireConfirm:!0,origin:"clipboard"});let n=o.drafts.commandType??o.drafts.type,l=null,i=g.A.getActiveOption(d.id);null!=(l=i?.type===p.n4.ATTACHMENT?i:t.options?.find(e=>{if(e.type===p.n4.ATTACHMENT)return null==A.A.getUpload(d.id,e.name,n)}))&&h.A.setFile({channelId:d.id,id:l.name,draftType:n,file:{id:l.name,platform:f.xz.WEB,file:e[0]}})})(x),this.focus(),!0)}}}