import{j as e,r as s}from"./vendor-react-Dp9pL_Wn.js";import{u as t}from"./vendor-intl-D2wGIp4M.js";import{dL as n,q8 as r,bZ as o}from"./c2ee0272b-DPDuX889.js";import{Np as i,Nq as a,Nr as l,C$ as c,Ns as g,D0 as p,D1 as m,D2 as d,D3 as u}from"./index-XoaBlZfC.js";import{I as x}from"./vendor-ant-cds-BLsR_p72.js";const f=e.jsx(x,{name:"Scroll"}),k=e.jsx(x,{name:"Plugin"}),b=/(^|\s)(\/[\w:.-]+)/g;function h(e){return{type:"doc",content:e.split("\n").map(e=>{if(!e)return{type:"paragraph"};const s=[];let t,n=0;for(b.lastIndex=0;null!==(t=b.exec(e));){const r=t[1],o=t[2],i=e.slice(n,t.index)+r;i&&s.push({type:"text",text:i});const a=o.slice(1);s.push({type:"skillChip",attrs:{skillId:a,skillDisplayName:a,skillDescription:"",skillArgumentHint:""}}),n=t.index+t[0].length}const r=e.slice(n);return r&&s.push({type:"text",text:r}),{type:"paragraph",content:s}})}}function y({prompt:t}){const n=i(),r=t.split(b);return e.jsx(e.Fragment,{children:r.map((t,r)=>{if(r%3!=2)return e.jsx(s.Fragment,{children:t},r);const o=t.slice(1),i=n.get(o);return i?e.jsx(a,{id:o,info:i},r):e.jsx(s.Fragment,{children:t},r)})})}function E({clientRect:i,decorationNode:a,editor:x,range:b,onClose:h,query:y}){const E=t(),{items:j}=l(),{data:w}=n(),C=s.useRef(b);C.current=b;const v=s.useCallback(e=>"skill"!==e.type?e:{...e,onAction:()=>{const s=C.current;x.chain().focus().deleteRange(s).insertContent(c(e.skillId,e.label??e.skillId,e.skillDescription??"",e.argumentHint??"")).run(),h()}},[x,h]),$=s.useMemo(()=>j.map(v),[j,v]),A=s.useCallback((e,s,t,n)=>{const r=C.current;x.chain().focus().deleteRange(r).insertContent(c(e,s,t,n??"")).run(),h()},[x,h]),M=s.useMemo(()=>w.filter(e=>e.enabled&&e.skills.some(r)).map(e=>({type:"submenu",label:o(e),items:g(e,A),submenuClassName:"!max-h-[288px]"})),[w,A]),S=s.useMemo(()=>{const e=[];return M.length>0&&e.push({type:"submenu",icon:k,label:E.formatMessage({defaultMessage:"Plugins",id:"QJAllUAc2k"}),items:M}),$.length>0&&e.push({type:"submenu",icon:f,label:E.formatMessage({defaultMessage:"Skills",id:"EJSVsOA19u"}),items:$}),e},[E,M,$]),F=s.useMemo(()=>p(S,y),[S,y]),N=F.length>0;return s.useEffect(()=>{const e=x.storage["slash-command-suggestion"];e&&(e.hasVisibleItems=N)},[x,N]),s.useEffect(()=>{x.view.dom.focus()},[x]),N?e.jsxs(e.Fragment,{children:[e.jsx(m,{editor:x,query:y}),e.jsx(d,{items:F,onClose:h,resetKey:y,children:e.jsx(u,{clientRect:i,decorationNode:a,maxHeightCap:384})})]}):null}
/*!-----------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
 * Released under the MIT license
 * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
 *-----------------------------------------------------------------------------*/var j={wordPattern:/(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\$\-\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,comments:{blockComment:["###","###"],lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{markers:{start:new RegExp("^\\s*#region\\b"),end:new RegExp("^\\s*#endregion\\b")}}};const w=Object.freeze(Object.defineProperty({__proto__:null,conf:j,language:{defaultToken:"",ignoreCase:!0,tokenPostfix:".coffee",brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],regEx:/\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/,keywords:["and","or","is","isnt","not","on","yes","@","no","off","true","false","null","this","new","delete","typeof","in","instanceof","return","throw","break","continue","debugger","if","else","switch","for","while","do","try","catch","finally","class","extends","super","undefined","then","unless","until","loop","of","by","when"],symbols:/[=><!~?&%|+\-*\/\^\.,\:]+/,escapes:/\\(?:[abfnrtv\\"'$]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/\@[a-zA-Z_]\w*/,"variable.predefined"],[/[a-zA-Z_]\w*/,{cases:{this:"variable.predefined","@keywords":{token:"keyword.$0"},"@default":""}}],[/[ \t\r\n]+/,""],[/###/,"comment","@comment"],[/#.*$/,"comment"],["///",{token:"regexp",next:"@hereregexp"}],[/^(\s*)(@regEx)/,["","regexp"]],[/(\()(\s*)(@regEx)/,["@brackets","","regexp"]],[/(\,)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\=)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\:)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\[)(\s*)(@regEx)/,["@brackets","","regexp"]],[/(\!)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\&)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\|)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\?)(\s*)(@regEx)/,["delimiter","","regexp"]],[/(\{)(\s*)(@regEx)/,["@brackets","","regexp"]],[/(\;)(\s*)(@regEx)/,["","","regexp"]],[/}/,{cases:{"$S2==interpolatedstring":{token:"string",next:"@pop"},"@default":"@brackets"}}],[/[{}()\[\]]/,"@brackets"],[/@symbols/,"delimiter"],[/\d+[eE]([\-+]?\d+)?/,"number.float"],[/\d+\.\d+([eE][\-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+/,"number.hex"],[/0[0-7]+(?!\d)/,"number.octal"],[/\d+/,"number"],[/[,.]/,"delimiter"],[/"""/,"string",'@herestring."""'],[/'''/,"string","@herestring.'''"],[/"/,{cases:{"@eos":"string","@default":{token:"string",next:'@string."'}}}],[/'/,{cases:{"@eos":"string","@default":{token:"string",next:"@string.'"}}}]],string:[[/[^"'\#\\]+/,"string"],[/@escapes/,"string.escape"],[/\./,"string.escape.invalid"],[/\./,"string.escape.invalid"],[/#{/,{cases:{'$S2=="':{token:"string",next:"root.interpolatedstring"},"@default":"string"}}],[/["']/,{cases:{"$#==$S2":{token:"string",next:"@pop"},"@default":"string"}}],[/#/,"string"]],herestring:[[/("""|''')/,{cases:{"$1==$S2":{token:"string",next:"@pop"},"@default":"string"}}],[/[^#\\'"]+/,"string"],[/['"]+/,"string"],[/@escapes/,"string.escape"],[/\./,"string.escape.invalid"],[/#{/,{token:"string.quote",next:"root.interpolatedstring"}],[/#/,"string"]],comment:[[/[^#]+/,"comment"],[/###/,"comment","@pop"],[/#/,"comment"]],hereregexp:[[/[^\\\/#]+/,"regexp"],[/\\./,"regexp"],[/#.*$/,"comment"],["///[igm]*",{token:"regexp",next:"@pop"}],[/\//,"regexp"]]}}},Symbol.toStringTag,{value:"Module"}));export{E as C,y as R,w as c,h as p};
