Build 574548stable
Module 317681
3,340 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{FV:()=>g,M3:()=>E,O7:()=>p,SQ:()=>m,cd:()=>A,ke:()=>I,n$:()=>f,pY:()=>T}),n(321073);var i=n(155718),r=n(721768),s=n(861382),a=n(203779),o=n(31717),l=n(522602),u=n(408018),c=n(323350),d=n(820066),_=n(551483);let h=/([\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}_-]+):/gu;function f(e){let t=d.VW.richValue(e)[0];return null==t||"applicationCommand"!==t.type?null:[t,_.Xg]}function E(e){if(null==e.selection)return null;let t=d.VW.above(e,{at:e.selection.focus,match:e=>d.AS.isType(e,"applicationCommandOption")})??null;return null!=t||d.ZF.isCollapsed(e.selection)?t:d.VW.above(e,{at:e.selection.anchor,match:e=>d.AS.isType(e,"applicationCommandOption")})??null}function p(e){let t=f(e),n=[],i=t?.[0].children;if(null!=i)for(let e of i)d.AS.isType(e,"applicationCommandOption")&&n.push(e.optionName);return n}function m(e,t,n){let i={};if(null==t.options)return{};let r=f(e),s=Object.fromEntries(t.options.map(e=>[e.name,e])),a=r?.[0].children;if(null!=a){for(let t of a)if(d.AS.isType(t,"applicationCommandOption")){let r=s[t.optionName];null!=r&&(i[t.optionName]=g(e,r,t,n))}}return i}function g(e,t,n,r){let s=n.children.map(n=>{if(t.type===i.n4.ATTACHMENT){let e=l.A.getUpload(r,t.name,o.C.SlashCommand);if(null!=e)return{type:"text",text:e.filename??""}}if(d.l5.isText(n))return{type:"text",text:n.text};if(d.VW.isVoid(e,n)){let e=(0,u.QR)(n);if(null!=e)return e}return{type:"text",text:(0,c.IQ)(n,{mode:"raw"})}});if(t.type!==i.n4.STRING){for(;s.length>0&&"text"===s[0].type&&""===s[0].text.trim();)s.shift();for(;s.length>0&&"text"===s[s.length-1].type&&""===s[s.length-1].text.trim();)s.pop()}return s}function A(e,t,n,i,s){if(null==e.options)return{};let o=Object.fromEntries(e.options.map(e=>[e.name,a.J({option:e,content:i[e.name]??null,guildId:t,channelId:n,allowEmptyValues:s})]));return r._y(n,o),o}function I(e,t,n,i,o){let[l]=i,u=s.A.getActiveCommand(n),c=u?.options?.find(e=>e.name===l.optionName);if(null==c)return;let d=g(e,c,l,n),_=a.J({option:c,content:d,guildId:t,channelId:n,allowEmptyValues:o});return r.H2(n,{[l.optionName]:{lastValidationResult:_}}),_}function T(e,t){if(null==t.options||0===t.options.length)return[];let n=d.VW.richValue(e),i=[],r=new Set(p(e)),s={},a=new Set;for(let e of t.options)s[e.displayName]=e,r.has(e.name)||a.add(e.displayName);let o=null;for(let t=0;t<n.length;t++){let r=n[t];if("line"===r.type||"applicationCommand"===r.type)for(let l=0;l<r.children.length;l++){let u,_=r.children[l],f=[t,l];if(d.AS.isType(_,"applicationCommandOption")){null!=o&&(o.valueRange.focus=d.VW.before(e,f)??d.VW.start(e,[]),o.text=(0,c.WO)(n,{mode:"raw",range:o.valueRange}).trim(),i.push(o),o=null);continue}if(d.l5.isText(_))for(h.lastIndex=0;null!=(u=h.exec(_.text));){if(0!==u.index&&null==_.text.charAt(u.index-1).match(/(\t|\s)/))continue;let e=u[1];if(!a.has(e))continue;a.delete(e);let t=s[e];if(null==t)continue;let r={path:f,offset:u.index},l={path:f,offset:r.offset+u[0].length},d={path:f,offset:l.offset},h={name:t.name,displayName:t.displayName,type:t.type,keyRange:{anchor:r,focus:l},valueRange:{anchor:d,focus:d},text:""};null!=o&&(o.valueRange.focus=h.keyRange.anchor,o.text=(0,c.WO)(n,{mode:"raw",range:o.valueRange}).trim(),i.push(o)),o=h}}}return null!=o&&(o.valueRange.focus=d.VW.end(e,[]),o.text=(0,c.WO)(n,{mode:"raw",range:o.valueRange}).trim(),i.push(o)),i}}