Module 383442

73,852 characters · in 381faf2c40dd0284.js
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>tJ}),n(321073),n(323874),n(14289),n(35956);var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(735438),o=n.n(a),c=n(607399),u=n(465532),d=n(608299),h=n(494921),m=n(155718),p=n(565150),f=n(861382),g=n(626584),x=n(522602),A=n(234320),C=n(453771),E=n(741394),I=n(355622),y=n(408018),S=n(579940),v=n(734057),N=n(222823),_=n(531685),T=n(365971);function j(e){let t=N.Ay.getChannelIdsForWindowId(e)[0];return null==t?null:v.A.getChannel(t)??null}var b=n(826745),R=n(442433),O=n(721768),M=n(723702),L=n(677134),w=n(652215),k=n(650583);let P=/(\t|\s)/;class D extends i.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!=f.A.getActiveCommand(this.props.channel.id)&&O.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&&!P.test(t[n-1]);)n--;let i=e.selectionEnd;for(;i<t.length&&!P.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,y.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:i,onResize:s,className:a,id:o,submitting:c,textAreaPaddingClassName:u,spellcheckEnabled:d,"aria-controls":h,"aria-expanded":m,"aria-activedescendant":p}=this.props;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(A.EG,{event:w.jej.GLOBAL_CLIPBOARD_PASTE,handler:this.handleGlobalPaste}),(0,l.jsx)(b.y,{ref:this.handleSetRef,className:r()(a,u),id:o,rows:1,fontWidthEstimate:6,placeholder:n,disabled:t||c,required:i,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===k.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 w.Ks6.ARROW_DOWN:this.props.moveSelection(1)&&e.preventDefault();break;case w.Ks6.N:e.ctrlKey&&this.props.moveSelection(1)&&e.preventDefault();break;case w.Ks6.ARROW_UP:this.props.moveSelection(-1)&&e.preventDefault();break;case w.Ks6.P:e.ctrlKey&&this.props.moveSelection(-1)&&e.preventDefault();break;case w.Ks6.TAB:case w.Ks6.ENTER:this.handleTabOrEnterDown(e)}let{onKeyDown:t}=this.props;t?.(e)};handleTabOrEnterDown(e){e.key===k.dh.TAB&&this.props.onTab()||e.key===k.dh.ENTER&&this.props.onEnter(e)?(e.preventDefault(),e.stopPropagation()):e.key===k.dh.ESCAPE?(e.preventDefault(),e.stopPropagation(),this.props.hideAutocomplete()):e.key===k.dh.TAB&&this.hasOpenCodeBlock()&&(e.preventDefault(),e.stopPropagation(),this.insertText("	",void 0,!1))}handleKeyUp=e=>{switch(e.key){case k.dh.ARROW_RIGHT:case k.dh.ARROW_LEFT:case k.dh.HOME:case k.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=>{M.isPlatformEmbedded&&(0,R.L3)(e,async()=>{let{default:e}=await Promise.all([n.e("30803"),n.e("42312")]).then(n.bind(n,216603));return t=>(0,l.jsx)(e,{...t,text:(0,L.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,y.x7)(i))};insertEmoji(e){let{emoji:t,addSpace:n=!1}=e;this.insertText(`:${t.name}:`,void 0,n)}getFirstText(){return this.props.value}}var U=n(95561),G=n(625494),V=n(317681),F=n(186306),H=n(670482),B=n(267102),W=n(38405),K=n(654821),z=n(35277),Z=n(820066),Y=n(112107),q=n(17928),J=n(990078),$=n(778712),X=n(939249),Q=n(545442),ee=n(565645),et=n(730134),en=n(775602),el=n(47167),ei=n(376943),es=n(465365),er=n(78390),ea=n(785562),eo=n(332173),ec=n(37632),eu=n(967144);n(209932);var ed=n(317525),eh=n(994500),em=n(351906),ep=n(287809),ef=n(871237),eg=n(562153),ex=n(427262),eA=n(375708),eC=n(178259);function eE(e){let{emoji:t}=e;return(0,l.jsx)(J.m,{text:t.name,delay:750,position:"top",children:(0,l.jsx)(ee.A,{src:t.src,emojiName:t.name,animated:!1,surrogate:t.surrogate})})}function eI(e){let{emoji:t}=e;return(0,l.jsx)(J.m,{text:t.name,delay:750,position:"top",children:(0,l.jsx)(ee.A,{emojiId:t.emojiId,emojiName:t.name,animated:t.animated})})}function ey(e){let{text:t}=e;return(0,l.jsx)(eo.A,{children:t})}function eS(e){let{id:t,guildId:n,channelId:i}=e,s=(0,q.bG)([ep.default],()=>ep.default.getUser(t)),r=(0,q.bG)([em.A],()=>em.A.hidePersonalInformation),a=eg.Ay.useName(n,i,s),o=(0,l.jsx)(eo.A,{children:null==a?`<@${t}>`:`@${a}`});if(null!=s){let e=r||s.hasUniqueUsername()?null:`#${s.discriminator}`;return(0,l.jsx)(J.m,{__unsupportedReactNodeAsText:(0,l.jsxs)("div",{className:eC.fX,children:[(0,l.jsx)(et.A,{user:s,animate:!0,size:$._3.SIZE_16,className:eC.my}),ex.Ay.getUserTag(s,{mode:"username",identifiable:r?"never":"always"}),(0,l.jsx)("span",{className:eC.D2,children:e})]}),delay:750,position:"top","aria-label":ex.Ay.getUserTag(s,{decoration:"never"}),asContainer:!0,children:(0,l.jsx)(X.D,{tag:"span",children:o})})}return o}function ev(e){let{id:t,guildId:n}=e,i=(0,q.bG)([ed.A],()=>null!=n?ed.A.getRole(n,t):void 0),s=(0,q.bG)([en.A],()=>en.A.roleStyle),r=(0,eu.X_)(n,i,i?.colorStrings);if(null==i)return(0,l.jsxs)("span",{children:["@",eA.intl.string(eA.t["YV4F/n"])]});let a=null!=i.color&&0!==i.color,o="username"===s&&a;return(0,l.jsxs)(eo.A,{color:o?i.color:null,roleColors:o?r:null,children:["dot"===s&&(0,l.jsx)(Q.W,{color:i.colorString,colors:r,background:!1,tooltip:!1}),"@",i.name]})}function eN(e){let{id:t}=e,n=(0,q.bG)([v.A],()=>v.A.getChannel(t)),i=eA.intl.string(eA.t.zLZPmk).toLowerCase(),s="text",r=!0;return(null!=n&&(i=(0,ei.nc)(n)?(0,el.m1)(n,ep.default,eh.A):eA.intl.string(eA.t["/YzI63"]),s=(0,ei.nc)(n)?(0,ef.QG)(n)??"text":"locked",r=(0,es.Y)(n.type)),r)?(0,l.jsx)(eo.A,{iconType:s,children:i}):(0,l.jsx)("span",{children:"#"+i})}function e_(e){let{id:t,itemId:n,guildId:i}=e,s=(0,er.Q)(t),r=(0,er.f)(t,n,i);return(0,l.jsxs)(eo.A,{iconType:t,children:[s,null!=r&&(0,l.jsx)(ec.A,{}),r]})}function eT(e){let{text:t,id:n}=e;return(0,l.jsxs)(eo.A,{children:[t,"(",n,")"]})}function ej(e){let{timestamp:t}=e;return(0,l.jsx)(ea.A,{node:t,className:"R"===t.format?eC.gS:null})}var eb=n(571898),eR=n(494715),eO=n(766184);let eM={strong:eb.bold,em:eb.italics,u:eb.underline,s:eb.strikethrough,inlineCode:eb.inlineCode,link:eb.fakeLink,url:eb.fakeLink,autolink:eb.fakeLink,silentPrefix:eb.fakeLink,spoiler:r()(eO.ur,eO.F0,eO.kx,eb.spoiler),staticRouteLink:eb.fakeLink,syntaxBefore:eb.syntaxBefore,syntaxAfter:eb.syntaxAfter,codeBlockText:eb.codeBlockText,codeBlockSyntax:eb.codeBlockSyntax,codeBlockLang:eb.codeBlockLang,subtext:eb.subtext};var eL=n(992595);let ew=e=>{let{className:t,attributes:n,children:i}=e,s=r()(eR.S0,eR.Cj,t);return(0,l.jsx)("span",{...n,className:s,contentEditable:!1,children:i})};var ek=n(422404);class eP extends i.PureComponent{containerRef=i.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),Z.VW.isEditorEmpty(e.editor)?this.state={initialValue:(0,y.N3)().richValue,showPlaceholder:!0}:this.state={initialValue:Z.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){W.A.captureException(e,{extra:t}),this.setState({initialValue:[...this.props.editor.children]})}renderElement(e){let{guildId:t,channelId:n,renderExtraElement:i}=this.props,{attributes:s,children:a}=e;"rtl"===s.dir&&(s.style={...s.style,textAlign:"right"});let o=i?.(e)??function(e,t,n){let{attributes:i,children:s,element:a,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 eM?eM[t]:null}).filter(e=>null!=e).join(" ");switch(a.type){case"line":if(a.codeBlockState?.isInCodeBlock)return(0,l.jsx)("div",{className:eb.codeLine,spellCheck:null==a.codeBlockState||null==a.codeBlockState.lang,...i,children:s});return(0,l.jsx)("div",{...i,children:s});case"blockQuote":{let e=r()(eL.h,eL.MN);return(0,l.jsxs)("div",{...i,className:e,children:[(0,l.jsx)("span",{contentEditable:!1,className:eL.r}),(0,l.jsx)("blockquote",{children:s})]})}case"emoji":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(eE,{emoji:a.emoji}),s]});case"customEmoji":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(eI,{emoji:a.emoji}),s]});case"textMention":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(ey,{text:a.name}),s]});case"userMention":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(eS,{id:a.userId,channelId:n,guildId:t}),s]});case"roleMention":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(ev,{id:a.roleId,guildId:t}),s]});case"channelMention":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(eN,{id:a.channelId}),s]});case"staticRouteLink":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(e_,{id:a.id,itemId:a.itemId,guildId:t}),s]});case"soundboard":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(Y.LF,{soundId:a.soundId}),s]});case"commandMention":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(eT,{text:a.commandName,id:a.commandId}),s]});case"timestamp":return(0,l.jsxs)(ew,{attributes:i,className:c,children:[(0,l.jsx)(ej,{timestamp:a.parsed}),s]});default:return null}}(e,t,n);return null!=o?o:(0,l.jsx)("div",{...s,children:a})}renderLeaf(e){let{editor:t,renderExtraLeaf:n}=this.props,{attributes:i,children:s}=e,a=n?.(e)??function(e,t){let n,{attributes:i,children:s,leaf:a,text:o}=t,c=!1,[u]=Z.VW.node(e,Z.PW.parent(Z.VW.findPath(e,o)));switch(Z.VW.isEditor(u)?"editor":u.type){case"line":case"blockQuote":{c=void 0;let e=Object.entries(a).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[eb[t]];if(t in eM)return[eM[t]];throw Error(`Slate: Unknown decoration attribute: ${t}`)}}).filter(e=>null!=e).join(" ");n=r()(e,{[eb.syntaxOverride]:"||"===a.text||"\\"===a.text})}}return n=r()(n,{[eR.BI]:""===o.text}),(0,l.jsx)("span",{...i,className:n,spellCheck:c,children:s})}(t,e);return null!=a?a:(0,l.jsx)("span",{...i,children:s})}handleOnChange(){let{editor:e}=this.props,t=Z.VW.isEditorEmpty(e)&&null==e.composition;if(t!==this.state.showPlaceholder&&this.setState({showPlaceholder:t}),this.props.onChange?.(Z.VW.richValue(e)),!1===this.props.canFocus){let t=H.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=H.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=Z.VW.toSlateRange(t,i,{exactMatch:!1,suppressThrow:!0});null!=n&&null!=e.data&&(Z.ZF.isExpanded(n)?F.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=Z.VW.toSlateRange(t,l,{exactMatch:!0,suppressThrow:!0});null!=n&&Z.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&&Z.ZF.isCollapsed(e.selection)?Z.VW.leaf(e,e.selection.anchor.path):null;if(null==n){e.composition=t;return}if(null!=(null!=e.selection&&Z.ZF.isCollapsed(e.selection)?Z.VW.above(e,{at:n[1],match:t=>Z.VW.isInline(e,t),mode:"lowest"}):null)&&(t.startedInsideInline=!0),Z.VW.isEditorEmpty(e)){z.b.insertNodes(e,{text:"\uFEFF"},{select:!0}),t.insertedPrefix=!0,e.composition=t;return}let l=H.rL.findDocumentOrShadowRoot(this.props.editor).getSelection(),i=(l?.rangeCount??0)>0?l?.getRangeAt(0):null;if(null==(null!=i?Z.VW.toSlateRange(e,i,{exactMatch:!0,suppressThrow:!0}):null)&&null!=i){let t=Z.VW.toSlateRange(e,i,{exactMatch:!1,suppressThrow:!0});e.selection=null,null!=t?z.b.select(e,t):z.b.select(e,Z.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&&Z.ZF.isCollapsed(t.selection)){let e=t.selection.anchor.path,n=Z.AS.leaf(t,e);Z.VW.withoutNormalizing(t,()=>{let e=n.text.replace(/^\uFEFF/,"");z.b.delete(t,{unit:"offset",distance:n.text.length,reverse:!0}),Z.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=H.rL.findDocumentOrShadowRoot(this.props.editor),s=i.getElementById("textarea-context"),r=i.getElementById("slate-toolbar");if(null!=l&&!(0,K.hasDomParent)(l,s)&&!(0,K.hasDomParent)(l,r)){let e=H.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,K.hasDomParent)(i,t)||!(0,K.isDOMRangeCollapsed)(i,r,s,a)&&(0,K.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,K.hasDomParent)(r,t)){if(l)return!0;n=!0}else{if(n)return!0;l=!0}if(!(0,K.isDOMRangeCollapsed)(r,o,a,c))if((0,K.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,i=e.pageY,s=window.innerHeight;if(M.isPlatformEmbedded){let r=(0,B.zd)();(0,R.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,l.jsx)(e,{...n,editor:t,text:Z.VW.getSelectedText(t,!0)})},{align:null!=i&&null!=s&&i<s/2?"top":"bottom",enableSpellCheck:r===w.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:i,autoFocus:s,placeholder:a,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,l.jsxs)("div",{ref:this.containerRef,className:n,children:[this.state.showPlaceholder?(0,l.jsx)("div",{className:r()(ek.q,t),"aria-hidden":!0,children:a}):null,(0,l.jsx)(H.A,{editor:e,value:[...this.state.initialValue],children:(0,l.jsx)(H.Fo,{...A,className:r()(eL.PT,ek.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!==i,autoCorrect:"off","data-can-focus":!1!==i,"aria-label":a,"aria-multiline":!0})})]})}}var eD=n(323350);function eU(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=Z.PW.child(t,s),r=Z.VW.node(e,n)[0];if(Z.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:Z.PW.child(t,s),offset:n[s]?.length??0}}let eG=new Set(["line","blockQuote"]),eV=[];var eF=n(143236),eH=n(154283),eB=n(264322),eW=n(885386);n(667532);var eK=n(485845),ez=n(459016),eZ=n(842209),eY=n(392054),eq=n(168186),eJ=n(203779),e$=n(649671),eX=n(551483);n(827669);let eQ=new Set(["applicationCommandOption"]),e0=new Set([m.n4.ATTACHMENT]),e1=new Set(["line","applicationCommand"]);function e2(e,t,n,l){let[i]=Z.VW.blocks(e)[0],s=(l?(0,eD.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:eX.Xg}),Z.VW.blocks(e).reverse()))Z.PW.isAfter(t,r)&&z.b.removeNodes(e,{at:t,voids:!0});null!=n&&O.Gf({channelId:t,command:null,section:null})}function e6(e,t){if(null==t.options||1!==t.options.length||!0===t.options[0].required||e0.has(t.options[0].type)||V.O7(e).length>0||null==V.n$(e))return!1;let n=Z.VW.getFirstText(e);if(null==n)return!1;let l=t.options[0],i={path:eX.fP,offset:t.displayName.length+2},s={path:eX.fP,offset:n.text.length};return!(!n.text.startsWith(`/${t.displayName} `.toLocaleLowerCase())||Z.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 e3(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:f.A.getActiveOptionName(n),u={},d=f.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,eJ.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&&O.H2(n,u)}function e7(e){let t=V.n$(e);if(null==t)return{command:null,commandText:null};let[n]=t,l=n.children[0];return Z.l5.isText(l)?{command:n.command,commandText:l.text}:{command:n.command,commandText:null}}function e4(e,t){let n=V.O7(e)[0];t();let l=Z.ZF.toPoint(e.selection);if(null==l||n===V.O7(e)[0])return;let{command:i,commandText:s}=e7(e);!(null==i||null==s||s.endsWith(" "))&&Z.Kh.equals(l,{path:eX.fP,offset:i.displayName.length+1})&&z.b.insertText(e," ")}function e5(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===m.n4.CHANNEL||l.type===m.n4.MENTIONABLE&&null!=v.A.getChannel(s)?`<#${s}>	`:l.type===m.n4.USER||l.type===m.n4.MENTIONABLE&&null!=ep.default.getUser(s)?`<@${s}>`:l.type===m.n4.ROLE||l.type===m.n4.MENTIONABLE&&null!=ed.A.getRole(t.guild_id,s??w.dJq)?`<@&${s}>`:s}var e8=n(635377),e9=n.n(e8),te=n(927813);let tt=new Set(["line"]),tn=/^[a-z0-9_+\-.#]+$/i,tl=null,ti=null;function ts(e){let t=function(e){let t=[],n=null;for(let l of Z.VW.blocks(e))n=function(e,t,n,l,i){let s=function(e){let t,[n,l]=e;if(!tt.has(n.type))return[];let i=[],s=/\\|```/g;for(let e=0;e<n.children.length;e++){let r=n.children[e];if(Z.l5.isText(r))for(s.lastIndex=0;null!=(t=s.exec(r.text));){if("\\"===t[0]){s.lastIndex+=1;continue}i.push({path:Z.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]=Z.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(tn)),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,l,null!=n&&(n.isInCodeBlock||n.opensCodeBlock),null!=n&&(n.isStyledCodeBlockLine||n.opensCodeBlockOnOwnLine),null!=n&&(n.opensCodeBlock||!n.closesCodeBlock)?n.lang:null),t.push(n);return function(e){let t=[],n=!1;for(let l of e){let i=l===e[e.length-1];if((l.closesCodeBlock||i)&&(n&&i&&!l.closesCodeBlock&&t.push(l),n=!1,t.length>0)){let e=t.map(e=>(0,eD.IQ)(e.blockEntry[0])).join("\n"),n=t[0].lang;if(null==n||null==tl||tl.hasLanguage(n)){if(null!=n&&null!=tl&&tl.hasLanguage(n)){let l=function(e,t){if(null==tl)return null;let n=`${e}-${t}`,l=to.get(n);if(null!=l)return l;let i=tl.highlight(t,e,!1);if(null==i||i.illegal)return null;let s=i.value.split("\n");return to.set(n,s),s}(e,n);if(null!=l&&l.length===t.length){let e=[];for(let n=0;n<t.length;n++){let i,s=l[n].replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'"),r=[],a=0,o=0;for(;null!=(i=tr.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})}t[n].hljsTypes=r}}else for(let e=0;e<t.length;e++)t[e].hljsTypes=null}}else for(let e=0;e<t.length;e++)t[e].hljsTypes=[];t=[]}n&&t.push(l),l.opensCodeBlock&&(n=!0)}}(t),t}(e);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,t),t.some(e=>null!=e.lang)}let tr=/(?:<span class="([^"]*)">)|(?:<\/span>)/g,ta={max:1/0,maxAge:+te.A.Millis.MINUTE,updateAgeOnGet:!0},to=new(e9())(ta);function tc(e,t){let n=0;for(let l of Z.VW.nodes(e,{at:{anchor:{path:eX.fP,offset:0},focus:t},mode:"lowest",match:e=>Z.l5.isText(e)})){let e=l[0].text;Z.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 tu(e){if(null==e.selection)return!1;let t=Z.ZF.start(e.selection);return tc(e,t)}let td=new Set(["line","blockQuote"]),th=["applicationCommand"],tm=["timestampMentionInput"];function tp(e){let t=Z.VW.getCurrentBlock(e),n=Z.VW.getCurrentInline(e);return null!=t&&!th.includes(t[0].type)&&!tm.includes(n?.[0]?.type)}function tf(e){return{type:"other",mergeable:!1,createdAt:Date.now(),value:Z.VW.richValue(e),selection:e.selection}}var tg=n(877413),tx=n.n(tg),tA=n(284009),tC=n.n(tA),tE=n(339871);function tI(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 ty=e=>{let t=Z.VW.getCurrentBlock(e);if(null!=t){let n=Z.VW.start(e,t[1]);return z.b.select(e,{anchor:n,focus:n}),!0}return!1},tS=e=>{let t=Z.VW.getCurrentBlock(e);if(null!=t){let n=Z.VW.end(e,t[1]);return z.b.select(e,{anchor:n,focus:n}),!0}return!1};var tv=n(224868);let tN=/(@[^@#]+(?:#0|#\d{4}))|(@[^\s\t@#:]+)(?=[\s\t@:])|(:[a-zA-Z0-9_~]+:)|(#"(?:\ |\\\\|\\"|(?!")\w)+")|(#[^\s\t@#:]+(?=[\s\t@#:]))/g,t_=new Set(["emoji","customEmoji","textMention","userMention","roleMention","channelMention","staticRouteLink","soundboard","timestamp"]),tT=new Set(["timestampMentionInput"]),tj=new Set(["line","blockQuote"]),tb=new Set(["applicationCommandOption"]);function tR(e,t,n){let l=Z.VW.areStylesDisabled(e);for(let i of Z.VW.blocks(e))if(tj.has(i[0].type))l?tM(e,i,!0,null):tO(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(!Z.l5.isText(a)&&tb.has(a.type)){let s=[a,Z.PW.child(r,i)];l?tM(e,s,!0,null):tO(e,s,t,n)}}}}function tO(e,t,n,l){let i="line"===t[0].type&&t[0].codeBlockState?.isInCodeBlock===!0,s=Z.cv.markdown(t[0],n);tM(e,t,i,s)&&(t=Z.cv.updateElement(e,t),s=Z.cv.markdown(t[0],n)),i||(tL(e,t,l,s)&&(t=Z.cv.updateElement(e,t),s=Z.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(!Z.l5.isText(c))continue;let u=Z.PW.child(r,a),d=[];for(tN.lastIndex=0;null!=(o=tN.exec(c.text));){if(0!==o.index&&null==c.text.charAt(o.index-1).match(/(\t|\s)/)){tN.lastIndex=o.index+1;continue}if(tw(e,r,{path:u,offset:o.index},i))continue;let s=(0,tv.p)(o[0],n,l);null!=s&&tk(l,t[0],s)?d.push({index:o.index,length:o[0].length,node:s}):tN.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};tC()(a.offset>=0&&a.offset<=s.text.length,"Failed to find valid start position for raw mention replace"),tC()(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,Z.PW.child(r,a)],t.index,t.length,t.node)}}(e,t,n,l,s))}function tM(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(Z.l5.isText(a)&&!n){let n=t<i.children.length-1?i.children[t+1]:null;if(null==n||!Z.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=Z.PW.child(s,t+1);z.b.voidToText(e,(0,eD.IQ)(n,{mode:"plain",preventEmojiSurrogates:!0}),l),r=!0}}else if(Z.cv.isElement(a)&&e.isVoid(a)){let i=Z.PW.child(s,t),o={path:Z.PW.child(i,0),offset:0};(n||null!=l&&tw(e,s,o,l))&&(z.b.voidToText(e,(0,eD.IQ)(a,{mode:"plain",preventEmojiSurrogates:!0}),i),r=!0)}}return r}function tL(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(!tk(n,t[0],o))continue;let d=eU(e,i,l.serializedChildren,c.start),h=eU(e,i,l.serializedChildren,c.start+c.text.length);z.b.textToVoid(e,o,{anchor:d,focus:h}),s=!0}return s}function tw(e,t,n,l){let i=0;for(let[l,s]of Z.VW.nodes(e,{at:{anchor:Z.VW.start(e,t),focus:n},mode:"lowest"}))Z.l5.isText(l)?Z.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 tk(e,t,n){if("applicationCommandOption"!==t.type)return!0;switch(t.optionType){case m.n4.CHANNEL:return"channelMention"===n.type;case m.n4.ROLE:return"roleMention"===n.type||"textMention"===n.type&&"@everyone"===n.name;case m.n4.USER:return"userMention"===n.type;case m.n4.MENTIONABLE:return"roleMention"===n.type||"userMention"===n.type||"textMention"===n.type&&"@everyone"===n.name;case m.n4.STRING:{let n=null!=e?f.A.getOption(e,t.optionName):null;return n?.choices==null&&n?.autocomplete!==!0}default:return!1}}function tP(e,t,n){let l=Z.VW.getCurrentInline(e);if("block"===t)return!0;let i=Z.VW.getCurrentText(e);if(null==i)return!0;let[s,r]=i,[a,o]=Z.VW.edges(e,r),c=Z.ZF.toPoint(e.selection);if(null==c)return!0;if(null!=l){let[t,n]=l;if(Z.VW.isEmpty(e,t)||Z.VW.isVoid(e,t))return z.b.removeInline(e,n),!0}if("line"===t)if(null==l)return!1;else{let[i,s]=Z.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=Z.VW.getParentBlock(e,c);if(null==u)return!0;let d=u[1],h=l;if(Z.Kh.equals(c,n?a:o))for(;;){let t=(n?Z.VW.before:Z.VW.after)(e,c);if(null==t)return!0;if(!Z.PW.isDescendant(t.path,d))break;if(c=t,null!=(h=Z.VW.getParentInline(e,t))){let[t,n]=h;if(Z.VW.isEmpty(e,t)||Z.VW.isVoid(e,t)){let t=Z.VW.before(e,n);return null!=t&&z.b.select(e,t),z.b.removeInline(e,n),!0}}let l=Z.VW.node(e,t.path);if(null==l||!Z.l5.isText(l[0]))return!0;if([s,r]=l,0!==s.text.length){[a,o]=Z.VW.edges(e,r);break}}return z.b.delete(e,{at:c,unit:t,reverse:n,select:!0}),!0}var tD=n(527214);function tU(e,t){let n=f.A.getActiveCommand(e.id),l=n?.options?.find(e=>e.name===t.optionName);return null!=l&&(l.type!==m.n4.STRING||l?.choices!=null||l?.autocomplete)}function tG(e,t,n,l){let i=Z.VW.areStylesDisabled(e)||null==n?t:n;F.o.withSingleEntry(e,()=>{z.b.insertText(e,l?i+" ":i)})}var tV=n(770178);let tF={enabled:!0,fireOnMount:!0,fireOnDepsChange:!0};function tH(e){try{return Z.VW.toDOMNode(e,e)}catch(t){let e=Error(`Unable to find Slate EditorDOMNode: ${t.message}`);return e.stack=t.stack,W.A.captureException(e),null}}var tB=n(31717);let tW=e=>{let t,{channelId:n,element:s,attributes:a,children:o}=e,c=(0,H.f7)(),u=(0,H.zL)(),d=(0,H.RV)(),{optionType:h,errored:p}=(0,q.cf)([f.A],()=>({optionType:f.A.getOption(n,s.optionName)?.type,errored:f.A.getOptionState(n,s.optionName)?.lastValidationResult?.success!==!0}),[n,s.optionName]),g=(0,q.bG)([x.A],()=>x.A.getUpload(n,s.optionName,tB.C.SlashCommand),[n,s.optionName]),A=s.children[s.children.length-1],C=null!=A&&Z.l5.isText(A)&&A.text.endsWith("\n"),E=r()(eR.S0,eR.xP,{[eR.t$]:u&&c,[eR.$2]:(!u||!c)&&p}),I=i.useCallback(()=>{Z.VW.isVoid(d,s)||z.b.selectCommandOption(d,s.optionName,!0)},[d,s]);return t=h===m.n4.ATTACHMENT?g?.filename!=null?(0,l.jsxs)("span",{className:r()(eR._K,eR.dU),contentEditable:!1,children:[g.filename,o]}):(0,l.jsxs)("span",{className:r()(eR._K,eR.ZI),contentEditable:!1,children:[eA.intl.string(eA.t.GRdFni),o]}):(0,l.jsxs)("span",{className:eR._K,children:[o,C?(0,l.jsx)("span",{className:eR.Nx,contentEditable:!1}):null]}),(0,l.jsxs)("span",{...a,className:E,children:[(0,l.jsxs)("span",{className:eR.gA,contentEditable:!1,onClick:I,children:[s.optionDisplayName,"\u200B"]}),t,(0,l.jsx)("span",{contentEditable:!1,children:"\u200B"})]})},tK=e=>{let{element:t,attributes:n,children:i}=e,s=(0,H.f7)(),a=(0,H.zL)(),o=r()(eR.S0,eR.xP,eR.Bz,{[eR.t$]:a&&s,[eR.$2]:t.error}),c=t.children[t.children.length-1],u=null!=c&&Z.l5.isText(c)&&c.text.endsWith("\n"),d=(0,l.jsxs)("span",{className:eR._K,children:[i,u?(0,l.jsx)("span",{className:eR.Nx,contentEditable:!1}):null]});return(0,l.jsxs)("span",{...n,className:o,children:[(0,l.jsxs)("span",{className:eR.gA,contentEditable:!1,children:["@time","\u200B"]}),d,(0,l.jsx)("span",{contentEditable:!1,children:"\u200B"})]})};var tz=n(471910);let tZ=i.forwardRef(function(e,t){let s,a,o,c,u,d,{value:h,type:p,channel:g,className:C,id:E,disabled:S,submitting:v,placeholder:N,required:_,textAreaPaddingClassName:T,onChange:j,onPaste:b,onResize:R,onFocus:M,onBlur:L,onKeyDown:P,onKeyUp:D,onTab:W,onEnter:K,onSubmit:Y,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=i.useRef(null),ef=i.useRef(null),eg=i.useRef(!0),ex=i.useRef(!0),eC=S||v,eE=i.useCallback((e,t,n)=>{let{value:l,selection:i}=n,s=Z.VW.richValue(e),r=e.selection,a=!1;if(void 0!==l&&l!==s){if(e.children=l,"parent"===t&&!e.previewMarkdown&&e.chatInputType===I.oU.EDIT){try{e.previewMarkdown=!0,tR(e,g.guild_id,g.id)}finally{e.previewMarkdown=!1}tR(e,g.guild_id,g.id),i=void 0}"undo"!==t&&void 0!==l&&l!==s&&F.o.insertEntry(e,"other",!1,s,r),a=!0}if(null==i||Z.Ot.isValid(e,i)||(i=void 0),(a||!Z.Ot.isValid(e,r))&&void 0===i){let t=Z.VW.end(e,[]);i={anchor:t,focus:t}}let o=null!=i&&!Z.Ot.equals(i,r);if(a&&!en&&Z.VW.focus(e),null!=i&&o){e.selection=i;let t=F.o.currentEntry(e);null!=t&&(t.selection=i),a=!0}let c=V.n$(e);if(null!=c&&c[0].command.id!==f.A.getActiveCommand(g.id)?.id&&F.o.withMergedEntry(e,()=>{e2(e,g.id,null,!0)}),a)if("parent"===t)try{ex.current=!1,e.onChange()}finally{ex.current=!0}else e.onChange()},[g.id,g.guild_id,en]),eI=function(e){let t=i.useContext(B.Ay),l=eW.SI.useSetting(),[s]=i.useState(()=>{let i=(0,eH.ie)();return i.children=(0,y.x7)(""),i.selection={anchor:eX.K,focus:eX.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:p,updateState:g}=e,x=i,{onChange:A}=x;x.chatInputType=s,x.windowContext=c,x.previewMarkdown=u,x.composition=null,x.events=new eF.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,H.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=Z.ZF.toPoint(e.selection);if(null!=t){let l=Z.VW.before(e,t,{unit:n});if(null!=l){let n=Z.e0.getLineStart(e,t,!1);null!=n&&Z.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=Z.ZF.toPoint(e.selection);if(null!=t){let l=Z.VW.after(e,t,{unit:n});if(null!=l){let n=Z.e0.getLineEnd(e,t,!1);null!=n&&Z.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&&!Z.Kh.equals(t.selection.anchor,t.selection.focus)){let n=(0,eD.WO)(Z.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&&Z.ZF.isExpanded(t.selection)){let e=eH.KE.string(t,t.selection),l=(0,tD.W1)(n),i=(0,tD.W1)(e);if(null!=l&&null==i){let[e,n]=Z.ZF.edges(t.selection);return Z.VW.withoutNormalizing(t,()=>{z.b.select(t,e),t.insertText("["),z.b.select(t,n),0===Z.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&&Z.ZF.isRange(n.properties)&&Z.ZF.isRange(n.newProperties)&&Z.ZF.isCollapsed(n.newProperties)){let t=Z.VW.getParentInline(e,n.properties),l=Z.VW.getParentInline(e,n.newProperties);if(null!=t&&(null==l||!Z.PW.equals(t[1],l[1])))return}t(n)},e.insertText=t=>{null!=e.selection&&null!=Z.VW.getCurrentInline(e)?z.b.insertText(e,t):s(t)},e.deleteBackward=t=>{tP(e,t,!0)||n(t)},e.deleteForward=t=>{tP(e,t,!1)||l(t)},e.deleteFragment=t=>{if(null!=e.selection&&Z.ZF.isExpanded(e.selection)){let n=e.selection.anchor,l=e.selection.focus,s=Z.VW.getParentInline(e,n),r=Z.VW.getParentInline(e,l);if(null!=s&&null!=r&&Z.PW.equals(s[1],r[1]))return void i(t);let a=Z.ZF.isForward(e.selection);if(null!=s){let[,t]=s,[l,i]=Z.VW.edges(e,t);a&&Z.Kh.equals(n,l)?n=Z.VW.before(e,l)??Z.VW.start(e,[]):!a&&Z.Kh.equals(n,i)&&(n=Z.VW.after(e,i)??Z.VW.end(e,[]))}if(null!=r){let[,t]=r,[n,i]=Z.VW.edges(e,t);!a&&Z.Kh.equals(l,n)?l=Z.VW.before(e,n)??Z.VW.start(e,[]):a&&Z.Kh.equals(l,i)&&(l=Z.VW.after(e,i)??Z.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&&Z.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,eq.Ez)(e),{application:s,command:r}=eZ.EW({channel:t,type:"channel"},l);if(null!=r){let e=null!=s?{type:eY.Hf.APPLICATION,id:s.id,icon:s.icon,name:s.bot?.username??s.name,application:s}:null;return O.Gf({channelId:t.id,command:r,section:e,location:eY.Oh.PASTE,initialValues:(0,ez.getInitialValuesFromInteractionOptions)(r,i??[])}),null}}return i(n)},e.isInline=e=>!!eQ.has(e.type)||s(e),e.isVoid=e=>!!("applicationCommandOption"===e.type&&e0.has(e.optionType))||r(e),e.deleteBackward=t=>{e4(e,()=>o(t))},e.deleteForward=t=>{e4(e,()=>c(t))},e.deleteFragment=t=>{e4(e,()=>u(t))};let d=null,h=null,p=null,g=null,x=null;return e.onChange=()=>{if(null!=t){let i=f.A.getState(t.id),s=eZ.j8({channel:t,type:"channel"});if(Z.VW.richValue(e)!==d||!Z.Ot.equals(e.selection,h)||i.activeCommand!==p||null==x||s.some((e,t)=>x[t]!==e)){let r=F.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}=e7(t),u=n.activeCommand;if(!i&&u?.integration_types?.includes(eK.b.GUILD_INSTALL)||s&&u?.inputType!==eY.y$.BUILT_IN_TEXT&&u?.inputType!==eY.y$.BUILT_IN_INTEGRATION)return null!=o&&e2(t,l.id,u,!0),null;if(null!=o){if(Z.VW.isEditorEmpty(t)||null==u)return e2(t,l.id,u,!1),null;let e=`/${o.displayName}`;if(null==c||!c.startsWith(e)||0===V.O7(t).length&&(c.length<e.length+1||" "!==c[e.length]))return e2(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?V.pY(e,s):null,a=(0,eD.WO)(Z.VW.richValue(e),{mode:"raw",range:{anchor:Z.VW.start(e,[]),focus:r?.[0]?.keyRange.anchor??Z.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=e5(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&&!e0.has(l.type)?(e=o,o=""):e=(i=e5(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}};Z.VW.withoutNormalizing(e,()=>{for(let[,t]of(z.b.insertNodes(e,[f],{at:eX.Xg}),Z.VW.blocks(e).reverse()))Z.PW.isAfter(t,eX.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&&e6(e,s),g}(t,l,n),i=V.SQ(t,u,l.id);return e3({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 O.Gf({channelId:l.id,command:null,section:null}),null;let e=Z.VW.richValue(t)[0],i=e.children[0];if(e1.has(e.type)&&Z.l5.isText(i)){let e=function(e,t){if(!e.startsWith("/"))return null;let n=(0,e$.Yn)(t,e.substring(1));if(!n.hasSpaceTerminator)return null;let{commands:l,sections:i}=eZ.v7({channel:t,type:"channel"},m.kc.CHAT,n.text);if(0===l.length)return null;let s=n.text.trim(),r=s+" ",a=l.filter(e=>e.inputType!==eY.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 O.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=V.pY(e,t);return 0!==n.length&&(Z.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=Z.VW.getFirstText(e);if(null==t)return!1;let l=t.text.trim();t.text!==l&&z.b.textToText(e,l,{anchor:{path:eX.fP,offset:0},focus:{path:eX.fP,offset:t.text.length}})}),!0)}(t,u)&&e6(t,u);let e=V.SQ(t,u,l.id),n=Z.VW.above(t,{match:e=>Z.VW.isInline(t,e)&&"applicationCommandOption"===e.type,mode:"lowest"}),i=n?.[0].optionName??null;return e3({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!==p?.id,previousOptionValues:g}));if(null!=r){let t=F.o.currentEntry(e);null!=t&&(t.commandId=r.commandId),g=r.optionValues}else g=null;d=Z.VW.richValue(e),h=e.selection,p=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=>!!t_.has(e.type)||i(e),e.isInline=e=>!!(t_.has(e.type)||tT.has(e.type))||l(e);let r=null,a=!0;return e.onChange=()=>{let l=Z.VW.richValue(e);(l!==r||e.previewMarkdown!==a)&&(F.o.withMergedEntry(e,()=>{Z.VW.withoutNormalizing(e,()=>tR(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=Z.VW.getCurrentBlock(e);if(l?.[0].type==="blockQuote"){let t=Z.ZF.toPoint(e.selection);if(null!=t&&Z.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]=Z.ZF.edges(e.selection),s=[l.path[0]],r=Z.VW.node(e,s),a=[i.path[0]],o=Z.PW.equals(s,a)?null:Z.VW.node(e,a);F.o.withSingleEntry(e,()=>{r?.[0].type==="blockQuote"&&Z.Kh.isAtStart(l,r)&&z.b.setNodes(e,{type:"line"},{at:s}),o?.[0].type==="blockQuote"&&Z.Kh.isAtEnd(i,o)&&z.b.setNodes(e,{type:"line"},{at:a}),n(t)});return}n(t)},e.insertBreak=()=>{let t=Z.VW.getCurrentBlock(e);if(t?.[0].type==="blockQuote"){let n=Z.ZF.toPoint(e.selection);if(null==n)return;!function(e,t,n){if(!Z.VW.isEmpty(e,t[0]))return!1;let l=Z.VW.previous(e,{at:t[1]});return null!=l&&!!Z.AS.isType(l[0],"blockQuote")&&!!Z.VW.isEmpty(e,l[0])&&!!Z.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=Z.VW.richValue(e);(t!==s||e.previewMarkdown!==r)&&(F.o.withMergedEntry(e,()=>{Z.VW.withoutNormalizing(e,()=>(function(e){let t=!1;for(let n of Z.VW.blocks(e)){let[l,i]=n;if(!td.has(l.type))continue;let s={path:Z.PW.child(i,0),offset:0};if(tc(e,s)){"blockQuote"===l.type&&(z.b.setNodes(e,{type:"line"},{at:i}),z.b.insertText(e,"> ",{at:s}));continue}if("blockQuote"===l.type||Z.VW.areStylesDisabled(e))continue;let r=l.children[0];if(!Z.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=Z.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;return e.onChange=()=>{Z.VW.richValue(e)!==l&&(F.o.withMergedEntry(e,()=>{Z.VW.withoutNormalizing(e,()=>{ts(e)&&null==tl&&!i&&(i=!0,(null==ti&&(ti=Promise.all([n.e("57036"),n.e("75134")]).then(n.bind(n,981776)).then(e=>{tl=e.default}).catch(e=>{throw ti=null,e})),ti).then(()=>{l=null,F.o.withMergedEntry(e,()=>{Z.VW.withoutNormalizing(e,()=>ts(e))}),l=Z.VW.richValue(e)}).catch(()=>{}).finally(()=>{i=!1}))})}),l=Z.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 w.Ks6.B:if(!Z.VW.isEditorEmpty(l)&&tI(e,{ctrl:!t,cmd:t}))return(0,tE.Px)(l,"bold"),!0;break;case w.Ks6.I:if(!Z.VW.isEditorEmpty(l)&&tI(e,{ctrl:!t,cmd:t}))return(0,tE.Px)(l,"italics"),!0;break;case w.Ks6.U:if(!Z.VW.isEditorEmpty(l)&&tI(e,{ctrl:!t,cmd:t}))return(0,tE.Px)(l,"underline"),!0;break;case w.Ks6.S:if(!Z.VW.isEditorEmpty(l)&&tI(e,{ctrl:!t,cmd:t,shift:!0}))return(0,tE.Px)(l,"strikethrough"),!0;break;case w.Ks6.TAB:if(null!=l.selection&&tI(e,{shift:null})){let[t,n]=Z.ZF.edges(l.selection),i=Z.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&&Z.ZF.isCollapsed(l.selection))return z.b.insertText(l,"  "),!0;let t=!e.shiftKey;return F.o.withSingleEntry(l,()=>{let e=l.selection?.anchor??Z.VW.start(l,[]),n=l.selection?.focus??Z.VW.end(l,[]);for(let[s,r]of i){let i=s.children[0];if(!Z.l5.isText(i))continue;let a=Z.PW.child(r,0),o={path:a,offset:0};if(t)z.b.insertText(l,"  ",{at:o}),Z.PW.equals(e.path,a)&&0!==e.offset&&(e={path:a,offset:e.offset+2}),Z.PW.equals(n.path,a)&&0!==n.offset&&(n={path:a,offset:n.offset+2});else if(i.text.startsWith("  ")){let t={path:Z.PW.child(r,0),offset:2};z.b.delete(l,{at:{anchor:o,focus:t}}),Z.PW.equals(e.path,a)&&(e={path:a,offset:Math.max(0,e.offset-2)}),Z.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 w.Ks6.ARROW_LEFT:case w.Ks6.ARROW_RIGHT:{let n;if(tI(e,{shift:null}))n="character";else if(tI(e,{ctrl:!t,alt:t,shift:null}))n="word";else if(t&&tI(e,{cmd:!0,shift:null}))return!1;else return!1;let i=l.children[l.selection?.focus?.path[0]??0],s="rtl"===tx()(Z.AS.string(i)),r=e.which===w.Ks6.ARROW_LEFT==!s;return z.b.keyboardMove(l,{reverse:r,unit:n,edge:e.shiftKey?"focus":void 0}),!0}case w.Ks6.A:if(t&&tI(e,{ctrl:!0})&&ty(l))return!0;break;case w.Ks6.E:if(t&&tI(e,{ctrl:!0})&&tS(l))return!0;break;case w.Ks6.HOME:if(tI(e,{shift:!1,ctrl:!1})&&ty(l))return!0;break;case w.Ks6.END:if(tI(e,{shift:!1,ctrl:!1})&&tS(l))return!0;break;case w.Ks6.BACKSPACE:case w.Ks6.DELETE:case w.Ks6.K:let n=e.which===w.Ks6.BACKSPACE;if((!t&&e.which!==w.Ks6.K&&tI(e,{ctrl:!0,shift:!0})||t&&e.which!==w.Ks6.K&&tI(e,{cmd:!0})||t&&e.which===w.Ks6.K&&tI(e,{ctrl:!0}))&&null!=l.selection){let[e,t]=Z.ZF.edges(l.selection),[i,s]=Z.VW.node(l,[n?e.path[0]:t.path[0]]);if(tC()(Z.VW.isBlock(l,i),"Top-most node of selection is not a block"),n&&!Z.Kh.isAtStart(e,[i,s])||!n&&!Z.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=F.o.currentEntry(e);if(null!=l&&(l.mergeable=!1),n>=e.history.stack.length)return;e.history.index=n;let i=F.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=[tf(e)],t.index=0),null!=e.selection&&(F.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=Z.VW.richValue(e);i!==h&&(0===l.stack.length&&(l.stack=[tf(e)],l.index=0),F.o.isSaving(e)&&(function(e,t,n){var l,i;let s,{selection:r}=e,a=F.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))?F.o.insertOrMergeEntry(e,s,c):F.o.insertEntry(e,s,c)}(e,t,u),u=t),d=t,h=i)},e.deleteBackward=t=>{F.o.withSingleEntry(e,()=>l(t))},e.deleteForward=t=>{F.o.withSingleEntry(e,()=>i(t))},e.deleteFragment=t=>{F.o.withSingleEntry(e,()=>s(t))},e.insertText=t=>{1===t.length&&d?.type==="remove_text"?F.o.withMergedEntry(e,()=>a(t)):null!=e.selection&&Z.ZF.isExpanded(e.selection)?F.o.withSingleEntry(e,()=>a(t)):a(t)},e.insertData=t=>{d?.type==="remove_text"?F.o.withMergedEntry(e,()=>r(t)):F.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),Z.Ot.isValid(e,e.selection)&&(e.lastGoodSelection=e.selection)},e.onChange=()=>{if(Z.Ot.isValid(e,e.selection)||(e.selection=function(e){let t;if(Z.Ot.isValid(e,e.lastGoodSelection))t=e.lastGoodSelection;else{let n=Z.VW.end(e,[]);t={anchor:n,focus:n}}return t}(e)),null!=e.selection){let t,n,[l,i]=Z.ZF.edges(e.selection),s=!1;for(;null!=l&&null!=(t=Z.VW.getParentVoid(e,l))&&!eX.XR.includes(t[0].type);)l=Z.VW.before(e,l,{unit:"offset"}),s=!0;for(;null!=i&&null!=(n=Z.VW.getParentVoid(e,i))&&!eX.XR.includes(n[0].type);)i=Z.VW.after(e,i,{unit:"offset"}),s=!0;s&&null!=l&&null!=i&&(Z.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=()=>{tp(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/);tp(e)?F.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,p),e=>{let{newValue:t,newSelection:n}=e;return g(x,"undo",{value:t,selection:n})})}({...e,editor:i,windowContext:t,previewMarkdown:l}),i});return i.useEffect(()=>{let e=()=>s.onChange();return f.A.addChangeListener(e),eB.Ay.addChangeListener(e),()=>{f.A.removeChangeListener(e),eB.Ay.removeChangeListener(e)}},[s]),i.useEffect(()=>{s.previewMarkdown!==l&&(s.previewMarkdown=l,s.onChange())},[s,l]),s}({channel:g,chatInputType:p,canUseCommands:ee,canOnlyUseTextCommands:et,onChangeStart:i.useCallback(()=>{eg.current=!1},[]),onChangeEnd:i.useCallback(()=>{eg.current=!0},[]),updateState:eE}),ey=i.useCallback((e,t)=>{let n=V.SQ(eI,e,g.id),l=V.cd(e,g.guild_id,g.id,n,t);return{values:n,results:l}},[g.guild_id,g.id,eI]),eS=i.useCallback(()=>{let e,t=Z.VW.getNodesOfType(eI,["timestampMentionInput"]),n=null!=t?[...t]:null,l=ee?f.A.getActiveCommand(g.id):null,i=!1;if(null!=l&&null!=l.options){let t=ey(l,!1);e=t.values;let n=V.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,U.zV)(w.HAw.APPLICATION_COMMAND_VALIDATION_FAILED,{application_id:l?.applicationId,command_id:l?.rootCommand?.id,argument_type:m.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,Z.VW.end(eI,t)),i=!0;if(i){G._.dispatch(w.jej.SHAKE_APP,{duration:200,intensity:2}),q?.();return}Y?.((0,eD.WO)(Z.VW.richValue(eI),{mode:"raw",ignoreTrailingEmptyNodes:!0}),l,e)},[g.id,eI,Y,q,ey,ee]);i.useImperativeHandle(t,()=>({getSlateEditor:()=>eI,submit(e){e?.preventDefault(),eS()},focus(){Z.VW.focus(eI)},blur(){H.rL.blur(eI)},getCurrentWord(){let e=eI.selection;if(null==e||!Z.Ot.isValid(eI,e)||Z.ZF.isExpanded(e)||tu(eI))return{word:null,isAtStart:!1};let[t,n]=Z.VW.node(eI,Z.PW.parent(e.anchor.path)),[l,i]=Z.VW.node(eI,e.anchor.path),s=e.anchor.offset;if(!Z.PW.hasPrevious(i)&&Z.l5.isText(l)){let e=l.text.substring(0,s);if(Z.AS.isType(t,"applicationCommand")&&s<t.command.displayName.length+2)return{word:e,isAtStart:!0}}let r="",a=!1;for(;;){if(--s<0){if(!Z.PW.hasPrevious(i)){a=!0;break}[l,i]=Z.VW.node(eI,Z.PW.previous(i))}if(!Z.l5.isText(l))break;let e=l.text[s];if(eX.ug.test(e))break;r=e+r}let o=r,c=e.anchor.offset,[u]=Z.VW.node(eI,e.anchor.path);for(;Z.l5.isText(u)&&!(c>=u.text.length);){let e=u.text[c];if(eX.ug.test(e))break;o+=e,c++}return{word:r,fullWord:o,isAtStart:a&&Z.PW.isFirstEditorBlock(n)}},getFirstText:()=>Z.VW.getFirstText(eI)?.text??"",getCurrentCommandOption(){let e=V.M3(eI);return null==e?null:e[0].optionName},getCurrentCommandOptionValue(){let e=V.M3(eI);if(null==e)return[];let t=f.A.getActiveCommand(g.id),n=t?.options?.find(t=>t.name===e[0].optionName);return null==n?[]:V.FV(eI,n,e[0],g.id)},getCommandOptionValues(){let e=f.A.getActiveCommand(g.id);return null==e?{}:V.SQ(eI,e,g.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];F.o.withSingleEntry(eI,()=>{let l=V.M3(eI),i=null!=l&&tU(g,l[0]);if(null!=t&&i&&(z.b.removeInlineChildren(eI,l),n=!1),tG(eI,e,t,n),null!=t&&i){let e=V.n$(eI);if(l=Z.cv.updateElement(eI,l),null!=e){let t=Z.cv.markdown(e[0],g.guild_id);tL(eI,l,g.id,t)&&(l=Z.cv.updateElement(eI,l))}V.ke(eI,g.guild_id,g.id,Z.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]:{};F.o.withSingleEntry(eI,()=>{let i=V.M3(eI),s=null!=i&&tU(g,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"})}tG(eI,e,t,n),s&&z.b.selectNextCommandOption(eI)})},insertInlineAutocompleteInput(e){F.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){F.o.withSingleEntry(eI,()=>{let l=Z.VW.getSelectedParentOfType(eI,[e]);tC()(null!=l,`Cannot replace inline input of type ${e} when none is selected`),z.b.removeNodes(eI,{at:l[1]}),tG(eI,t,n,!0)})},insertEmoji(e){let{emoji:t,addSpace:n=!1}=e;F.o.withSingleEntry(eI,()=>{let e=t.animated?"a":"",l=t.originalName??t.name??"";tG(eI,`:${t.name}:`,null!=t.id?`<${e}:${l.replace(/:/g,"")}:${t.id}>`:null,n)})}}),[eI,g,eS]),s=i.useRef(null),a=i.useRef(null),o=i.useRef(null),i.useLayoutEffect(()=>{a.current=tH(eI),null==a.current&&null==o.current&&(o.current=setTimeout(()=>{a.current=tH(eI)},100))},[eI]),i.useEffect(()=>{let e=o.current;return()=>{null!=e&&clearTimeout(e)}},[]),c=i.useCallback(()=>{let e=a.current;if(null==e)return;let t=e.offsetHeight;s.current!==t&&(null!=ep.current&&(ep.current.style.height=`${t}px`),s.current=t,R?.(t))},[ep,R]),(0,tV.g)(a,c,[c,eI,R],tF),i.useLayoutEffect(()=>{let e=H.rL.findDocumentOrShadowRoot(eI).defaultView;if(e?.ResizeObserver==null)return;let t=tH(eI);null!=t&&(s.current=t.offsetHeight,R?.(s.current))},[ep,eI,R]);let{handleKeyDown:ev,handleKeyUp:eN}=function(e){let{editor:t,channel:n,disableEnterToSubmit:l,onKeyDown:s,onKeyUp:r,onTab:a,onEnter:o,allowNewLines:c,submit:u,hideAutocomplete:d,moveSelection:h}=e;return{handleKeyDown:i.useCallback(e=>{switch(e.which){case w.Ks6.ARROW_UP:if(h(-1))return void e.preventDefault();break;case w.Ks6.ARROW_DOWN:if(h(1))return void e.preventDefault();break;case w.Ks6.P:if(tI(e,{ctrl:!0})&&h(-1))return void e.preventDefault();break;case w.Ks6.N:if(tI(e,{ctrl:!0})&&h(1))return void e.preventDefault();break;case w.Ks6.ESCAPE:d?.();break;case w.Ks6.TAB:if(tI(e,{})&&a?.()){e.preventDefault(),e.stopPropagation();return}if(null!=f.A.getActiveCommand(n.id)){e.preventDefault(),e.stopPropagation(),e.shiftKey?z.b.selectPreviousCommandOption(t):z.b.selectNextCommandOption(t);return}break;case w.Ks6.ENTER:if(tI(e,{})&&o?.(e)){e.preventDefault(),e.stopPropagation();return}}if(t.onKeyDown?.(e)===!0){e.preventDefault(),e.stopPropagation();return}e.key!==k.dh.ENTER||(e.altKey||e.shiftKey||l&&!e.ctrlKey||tu(t))&&c||(e.preventDefault(),e.stopPropagation(),u()),s?.(e)},[c,n.id,l,t,d,h,o,s,a,u]),handleKeyUp:i.useCallback(e=>{r?.(e)},[r])}}({editor:eI,channel:g,disableEnterToSubmit:el,onKeyDown:P,onKeyUp:D,onTab:W,onEnter:K,allowNewLines:ei,submit:eS,hideAutocomplete:$,moveSelection:X}),{handlePaste:e_,handleGlobalPaste:eT}=(u=i.useCallback(e=>{if(eC)return!0;if(!0===e.defaultPrevented)return!1;let t=b(e);return t&&(e.preventDefault(),e.stopPropagation()),t},[eC,b]),d=i.useCallback(e=>{let{event:t}=e;u(t)||(t.preventDefault(),t.stopPropagation(),null!=t.clipboardData&&(eI.insertData(t.clipboardData),Z.VW.focus(eI)))},[eI,u]),{handlePaste:u,handleGlobalPaste:d}),ej=i.useCallback(e=>{J?.()},[J]),eb=i.useCallback(e=>{e!==ef.current?ex.current&&j?.(null,(0,eD.WO)(e,{mode:"raw"}),e):ex.current&&J()},[J,j]);i.useLayoutEffect(()=>{eg.current&&(ef.current=h,eE(eI,"parent",{value:h}))},[eI,h,eE]),i.useEffect(()=>{let e=()=>{let e=f.A.getActiveCommand(g.id)??null;null!==e&&null!=e.options&&ey(e,!0)};return x.A.addChangeListener(e),()=>x.A.removeChangeListener(e)},[g,eI,ey]);let eO=i.useCallback(e=>[...function(e,t,n){if(Z.VW.areStylesDisabled(e))return[];let[l,i]=t;if(1!==i.length||!Z.AS.isInTypes(l,eG))return eV;let{entries:s,serializedChildren:r}=Z.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:eU(e,i,r,n.start),focus:eU(e,i,r,n.start+n.text.length)},u=Z.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:Z.VW.start(e,n),focus:Z.VW.end(e,n)};Z.Kh.isBefore(t.anchor,c.anchor)&&(t.anchor=c.anchor),Z.Kh.isAfter(t.focus,c.focus)&&(t.focus=c.focus),a.push({...d,...t})}}}return a}(eI,e,g.guild_id),...function(e,t){if(Z.VW.areStylesDisabled(e))return[];let[n,l]=t,i=[];if(!Z.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=>Z.l5.isText(e)?e.text:null);i.push({hljsTypes:t.types,anchor:eU(e,l,s,t.start),focus:eU(e,l,s,t.end)})}return i}(eI,e),...function(e,t){if(Z.VW.areStylesDisabled(e))return[];let[n,l]=t,i=[];if(!Z.l5.isText(n))return i;let[s]=Z.VW.node(e,Z.PW.parent(l));return Z.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,g]),eM=i.useCallback(e=>{let t=function(e,t,n){let{attributes:i,children:s,element:r}=t;switch(r.type){case"applicationCommand":let a=f.A.getActiveCommand(n),o=0,c=0;if(null!=a&&a.id===r.command.id){let t=V.O7(e);for(let e of a.options??[])t.includes(e.name)?c++:o++}let u={};if(o>0){let e;e=c>0?eA.intl.formatToPlainString(eA.t.BP8N0K,{count:o}):eA.intl.formatToPlainString(eA.t.lziVC9,{count:o}),u["data-trailing-placeholder"]=e}return(0,l.jsx)("div",{className:eR.uB,...i,...u,children:s});case"applicationCommandOption":return(0,l.jsx)(tW,{attributes:i,channelId:n,element:r,children:s});default:return null}}(eI,e,g.id);return null==t&&(t=function(e){let{attributes:t,children:n,element:i}=e;return"timestampMentionInput"===i.type?(0,l.jsx)(tK,{attributes:t,element:i,children:n}):null}(e)),t},[g.id,eI]),eL=i.useCallback(e=>(function(e){let{attributes:t,children:n,leaf:i,text:s}=e;if(i.commandName){let e=r()(eR.p6,{[eR.BI]:""===s.text});return(0,l.jsx)("span",{...t,className:e,spellCheck:!1,children:n})}return null})(e),[]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(A.EG,{event:w.jej.GLOBAL_CLIPBOARD_PASTE,handler:eT}),(0,l.jsx)("div",{ref:ep,className:r()(C,tz.pC),children:(0,l.jsx)(eP,{id:E,editor:eI,channelId:g.id,guildId:g.guild_id,className:r()(tz.gf,T),placeholder:N,readOnly:eC,spellCheck:Q,autoFocus:!en,canFocus:!S,onChange:eb,onFocus:M,onBlur:L,onClick:ej,onPaste:e_,onKeyDown:ev,onKeyUp:eN,decorate:eO,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 tY=n(266599);new g.A("ChannelEditor.tsx");let tq=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n]};class tJ extends i.Component{ref=i.createRef();_focusBlurQueue=Promise.resolve();_unsubscribe;_initTimeoutId=null;_cachedEditorWindow=null;constructor(e){super(e),this._unsubscribe=S.Y0.subscribe(e=>{requestAnimationFrame(()=>{this.setState({popup:e})})}),this.state={focused:!1,submitting:!1,popup:S.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,eD.WO)(this.props.richValue,{mode:"plain"}),this.props.onChange?.(null,e,(0,y.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}),u.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=o().throttle(this.saveCurrentText.bind(this,!1),500);getPlaceholder(){let{disabled:e,placeholder:t,isPreviewing:n,showValueWhenDisabled:l}=this.props;return e&&!n?l?"":eA.intl.string(eA.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:i,onKeyDown:s,onResize:a,onSubmit:o,onSubmitFailure:u,channel:d,type:h,useSlate:m,spellcheckEnabled:p,useNewSlashCommands:f,canOnlyUseTextCommands:g,className:x,id:C,required:E,maxCharacterCount:S,allowNewLines:v,"aria-describedby":N,"aria-labelledby":_,accessibilityLabel:T,showValueWhenDisabled:j}=this.props,{submitting:b,popup:R}=this.state,O={channel:d,className:r()(x,tY.Tg,{[tY.w5]:m,[tY.Rr]:n||b}),id:C,placeholder:this.getPlaceholder(),required:E,accessibilityLabel:T,disabled:n||!1,submitting:b,isEdit:h===I.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:i,onResize:a,onKeyDown:s,onSubmit:o,textAreaPaddingClassName:r()({[tY.H$]:h===I.oU.CREATE_FORUM_POST,[tY.g_]:h===I.oU.CUSTOM_GIFT,[tY.Yg]:h===I.oU.USER_PROFILE,[tY.$$]:h===I.oU.OVERLAY_INLINE_REPLY}),spellcheckEnabled:p,useNewSlashCommands:f,disableAutoFocus:c.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>S,"aria-describedby":N,"aria-labelledby":_,"aria-autocomplete":"list"},M=m?(0,l.jsx)(tZ,{ref:this.ref,...O,type:h,value:n&&!j?(0,y.x7)(""):t,canUseCommands:h.commands?.enabled,canOnlyUseTextCommands:g,onSubmitFailure:u}):(0,l.jsx)(D,{ref:this.ref,...O,value:n&&!j?"":e});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(A.EG,{event:w.jej.INSERT_TEXT,handler:this.handleInsertText}),(0,l.jsx)(A.EG,{event:w.jej.CLEAR_TEXT,handler:this.handleClearText}),M]})}handleSaveCurrentText=e=>{u.A.saveDraft(e,this.props.textValue,this.props.type.drafts.type)};handleClearText=()=>{this.props.onChange?.(null,"",(0,y.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,T.Q2)(e);return null==t?null:j(t)}(n):null,u=null==(t=_.A.getFocusedWindowId())?null:j(t),g=!function(e,t){if(null==e||null==t)return!1;let n=(0,T.Q2)(e);return n===(0,T.Q2)(t)&&null!=n}(n,this._getEditorWindow())?c??u??l:l;if(null==r||!g.isPrivate()&&!i||g.isPrivate()&&g.isManaged())return!1;let{files:A,errors:I}=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,E.kh)(n))}catch{}if(null!=e&&e.length>0)return`${e}.png`}}(e.getData(s.type))??t.name;return{files:[(0,C.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,C.VE)(e,"message.txt","text/plain")],convertedStringToFile:!0,errors:r}}}return{files:[],errors:r}}(e.clipboardData,o.uploadLongMessages?s??a:null);return(tq("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===A.length)?(I?.some(e=>{let{error:t}=e;return"is_directory"===t})&&(0,h.openUploadError)({title:eA.intl.string(eA.t.azO1Pe),help:eA.intl.string(eA.t["Koklr/"])}),!1):(e.preventDefault(),e.stopPropagation(),this.saveCurrentText(),(e=>{let t=f.A.getActiveCommand(g.id);if(null==t)return r(e,g,o.drafts.type,{requireConfirm:!0,origin:"clipboard"});let n=o.drafts.commandType??o.drafts.type,l=null,i=f.A.getActiveOption(g.id);null!=(l=i?.type===m.n4.ATTACHMENT?i:t.options?.find(e=>{if(e.type===m.n4.ATTACHMENT)return null==x.A.getUpload(g.id,e.name,n)}))&&d.A.setFile({channelId:g.id,id:l.name,draftType:n,file:{id:l.name,platform:p.xz.WEB,file:e[0]}})})(A),this.focus(),!0)}}}