Loading
function(e,t,n){"use strict";n.d(t,{A:()=>T,t:()=>N}),n(321073),n(667532);var l=n(485845),i=n(155718),s=n(721768),r=n(459016),a=n(842209),o=n(861382),u=n(392054),c=n(168186),d=n(203779),m=n(664929),h=n(734057),p=n(317525),f=n(287809),g=n(317681),E=n(186306),A=n(323350),C=n(35277),x=n(820066),I=n(551483),_=n(652215);n(827669);let S=new Set(["applicationCommandOption"]),y=new Set([i.n4.ATTACHMENT]),v=new Set(["line","applicationCommand"]);function T(e,t,n,d){let{insertData:h,isInline:p,isVoid:f,onChange:_,deleteBackward:T,deleteForward:M,deleteFragment:O}=e;e.insertData=n=>{if(null!=t&&x.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,c.Ez)(e),{application:o,command:d}=a.EW({channel:t,type:"channel"},l);if(null!=d){let e=null!=o?{type:u.Hf.APPLICATION,id:o.id,icon:o.icon,name:o.bot?.username??o.name,application:o}:null;return s.Gf({channelId:t.id,command:d,section:e,location:u.Oh.PASTE,initialValues:(0,r.getInitialValuesFromInteractionOptions)(d,i??[])}),null}}return h(n)},e.isInline=e=>!!S.has(e.type)||p(e),e.isVoid=e=>!!("applicationCommandOption"===e.type&&y.has(e.optionType))||f(e),e.deleteBackward=t=>{P(e,()=>T(t))},e.deleteForward=t=>{P(e,()=>M(t))},e.deleteFragment=t=>{P(e,()=>O(t))};let w=null,k=null,D=null,U=null,G=null;return e.onChange=()=>{if(null!=t){let r=o.A.getState(t.id),c=a.j8({channel:t,type:"channel"});if(x.VW.richValue(e)!==w||!x.Ot.equals(e.selection,k)||r.activeCommand!==D||null==G||c.some((e,t)=>G[t]!==e)){let o=E.o.withMergedEntry(e,()=>(function(e){let{editor:t,storeCommandState:n,channel:r,canUseCommands:o,canOnlyUseTextCommands:c,commandChanged:d,previousOptionValues:h}=e,{command:p,commandText:f}=R(t),E=n.activeCommand;if(!o&&E?.integration_types?.includes(l.b.GUILD_INSTALL)||c&&E?.inputType!==u.y$.BUILT_IN_TEXT&&E?.inputType!==u.y$.BUILT_IN_INTEGRATION)return null!=p&&N(t,r.id,E,!0),null;if(null!=p){if(x.VW.isEditorEmpty(t)||null==E)return N(t,r.id,E,!1),null;let e=`/${p.displayName}`;if(null==f||!f.startsWith(e)||0===g.O7(t).length&&(f.length<e.length+1||" "!==f[e.length]))return N(t,r.id,E,!0),null}else{if(null!=E&&d){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?g.pY(e,s):null,a=(0,A.WO)(x.VW.richValue(e),{mode:"raw",range:{anchor:x.VW.start(e,[]),focus:r?.[0]?.keyRange.anchor??x.VW.end(e,[])}}),o="",u=a.toLocaleLowerCase(),c=`/${s.displayName} `.toLocaleLowerCase(),d=`/${s.untranslatedName} `.toLocaleLowerCase();u.startsWith(c)?o=a.substring(c.length).trim():u.startsWith(d)&&(o=a.substring(d.length).trim());let m=[],h=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=L(n,t,l.name)??l.text,s={type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:i}]};m.push(s),0===l.text.length&&null==h&&(h=s)}for(let l of s.options)if(!e.has(l.name)&&(l.required||null!=i[l.name])){let e,i;o.length>0&&!y.has(l.type)?(e=o,o=""):e=(i=L(n,t,l.name))??"";let s={type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:e}]};m.push(s),0===e.length&&null==h&&(h=s),null==i&&(p=s)}}l=o.length>0?`/${s.displayName} ${o.replace(/\r|\n/g," ")}`:0===m.length?`/${s.displayName} `:`/${s.displayName}`,m.unshift({text:l});let f={type:"applicationCommand",children:m,command:{id:s.id,name:s.untranslatedName,displayName:s.displayName}};x.VW.withoutNormalizing(e,()=>{for(let[,t]of(C.b.insertNodes(e,[f],{at:I.Xg}),x.VW.blocks(e).reverse()))x.PW.isAfter(t,I.Xg)&&C.b.removeNodes(e,{at:t,voids:!0})});let E=null;return null!=h?(C.b.selectCommandOption(e,h.optionName),E=h.optionName):null!=p?(C.b.selectCommandOption(e,p.optionName,!1),E=p.optionName):C.b.resetSelectionToEditorEnd(e),null==p&&j(e,s),E}(t,r,n),l=g.SQ(t,E,r.id);return b({guildId:r.guild_id,channelId:r.id,command:E,activeOption:e,currentOptionValues:l,previousOptionValues:null,validateAll:!0,allowEmpty:!0}),{commandId:E.id,optionValues:l}}if(null!=E&&!d)return s.Gf({channelId:r.id,command:null,section:null}),null;let e=x.VW.richValue(t)[0],l=e.children[0];if(v.has(e.type)&&x.l5.isText(l)){let e=function(e,t){if(!e.startsWith("/"))return null;let n=(0,m.Yn)(t,e.substring(1));if(!n.hasSpaceTerminator)return null;let{commands:l,sections:s}=a.v7({channel:t,type:"channel"},i.kc.CHAT,n.text);if(0===l.length)return null;let r=n.text.trim(),o=r+" ",c=l.filter(e=>e.inputType!==u.y$.PLACEHOLDER&&(e.displayName===r||e.displayName.startsWith(o)));if(1===c.length&&c[0].displayName===r){let e=c[0],t=s.find(t=>t.application?.id===e.applicationId);return{command:e,section:t}}return null}(l.text,r);if(null!=e)return s.Gf({channelId:r.id,command:e.command,section:e.section}),null}}if(null!=E&&null!=p){!function(e,t){if(null==t.options||0===t.options.length)return!1;let n=g.pY(e,t);return 0!==n.length&&(x.VW.withoutNormalizing(e,()=>{for(let t=n.length-1;t>=0;t--){let l=n[t];C.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=x.VW.getFirstText(e);if(null==t)return!1;let l=t.text.trim();t.text!==l&&C.b.textToText(e,l,{anchor:{path:I.fP,offset:0},focus:{path:I.fP,offset:t.text.length}})}),!0)}(t,E)&&j(t,E);let e=g.SQ(t,E,r.id),n=x.VW.above(t,{match:e=>x.VW.isInline(t,e)&&"applicationCommandOption"===e.type,mode:"lowest"}),l=n?.[0].optionName??null;return b({guildId:r.guild_id,channelId:r.id,command:E,activeOption:l,currentOptionValues:e,previousOptionValues:h,validateAll:!1,allowEmpty:!1}),{commandId:p.id,optionValues:e}}return null})({editor:e,storeCommandState:r,channel:t,canUseCommands:n,canOnlyUseTextCommands:d,commandChanged:r.activeCommand?.id!==D?.id,previousOptionValues:U}));if(null!=o){let t=E.o.currentEntry(e);null!=t&&(t.commandId=o.commandId),U=o.optionValues}else U=null;w=x.VW.richValue(e),k=e.selection,D=r.activeCommand,G=c}}_()},e}function N(e,t,n,l){let[i]=x.VW.blocks(e)[0],r=(l?(0,A.IQ)(i,{mode:"plain"}).trimEnd():"").split("\n").map(e=>({type:"line",children:[{text:e}]})),a=[r.length-1];for(let[,t]of(C.b.insertNodes(e,r,{at:I.Xg}),x.VW.blocks(e).reverse()))x.PW.isAfter(t,a)&&C.b.removeNodes(e,{at:t,voids:!0});null!=n&&s.Gf({channelId:t,command:null,section:null})}function j(e,t){if(null==t.options||1!==t.options.length||!0===t.options[0].required||y.has(t.options[0].type)||g.O7(e).length>0||null==g.n$(e))return!1;let n=x.VW.getFirstText(e);if(null==n)return!1;let l=t.options[0],i={path:I.fP,offset:t.displayName.length+2},s={path:I.fP,offset:n.text.length};return!(!n.text.startsWith(`/${t.displayName} `.toLocaleLowerCase())||x.Kh.equals(i,s))&&(C.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 b(e){let{guildId:t,channelId:n,command:l,activeOption:i,currentOptionValues:r,previousOptionValues:a,validateAll:u,allowEmpty:c}=e;if(null==l.options)return!1;let m=u?null:o.A.getActiveOptionName(n),h={},p=o.A.getOptionStates(n),f=!1;for(let e of l.options){let l=p[e.name],s=u||e.name===m&&m!==i||l?.lastValidationResult?.success===!1&&r?.[e.name]!==a?.[e.name],o={hasValue:null!=r&&e.name in r,isActive:e.name===i,lastValidationResult:s?(0,d.J)({option:e,content:r?.[e.name]??null,guildId:t,channelId:n,allowEmptyValues:c}):l?.lastValidationResult};(null==l||l.hasValue!==o.hasValue||l.isActive!==o.isActive||s&&l.lastValidationResult?.success===!1)&&(h[e.name]=o,f=!0)}f&&s.H2(n,h)}function R(e){let t=g.n$(e);if(null==t)return{command:null,commandText:null};let[n]=t,l=n.children[0];return x.l5.isText(l)?{command:n.command,commandText:l.text}:{command:n.command,commandText:null}}function P(e,t){let n=g.O7(e)[0];t();let l=x.ZF.toPoint(e.selection);if(null==l||n===g.O7(e)[0])return;let{command:i,commandText:s}=R(e);!(null==i||null==s||s.endsWith(" "))&&x.Kh.equals(l,{path:I.fP,offset:i.displayName.length+1})&&C.b.insertText(e," ")}function L(e,t,n){let l=e.activeCommand?.options?.find(e=>e.name===n),s=e.initialValues[n];if(null==l||null==s)return null;if(null!=l.choices)return l.choices.find(e=>e.value===s.value)?.displayName;let r=s.value?.toString();return l.type===i.n4.CHANNEL||l.type===i.n4.MENTIONABLE&&null!=h.A.getChannel(r)?`<#${r}> `:l.type===i.n4.USER||l.type===i.n4.MENTIONABLE&&null!=f.default.getUser(r)?`<@${r}>`:l.type===i.n4.ROLE||l.type===i.n4.MENTIONABLE&&null!=p.A.getRole(t.guild_id,r??_.dJq)?`<@&${r}>`:r}}