import{Cr as e,Jn as t,Lt as n,Qn as r,Xn as i,Zn as a,fr as o,hr as s,jr as c,rr as l}from"./index-jrCi0Lum.js";import{t as u}from"./_plugin-vue_export-helper-BDNMzG2s.js";var d=new Set(`if.then.else.elif.fi.for.while.do.done.case.esac.in.function.return.break.continue.select.until.cd.ls.grep.egrep.fgrep.find.cat.chmod.chown.docker.podman.kubectl.apt.apt-get.yum.dnf.apk.pip.pip3.npm.npx.ssh.scp.rsync.curl.wget.tar.gzip.gunzip.kill.ps.top.htop.nano.vim.vi.journalctl.systemctl.service.supervisorctl.crontab.nginx.df.du.free.mount.uname.hostname.whoami.id.pwd.head.tail.wc.sort.uniq.awk.sed.cut.tr.xargs.tee.netstat.ss.ip.ping.dig.git.make.nohup.timeout.watch`.split(`.`)),f=new Set([`echo`,`printf`,`test`,`read`,`pushd`,`popd`,`exit`,`set`,`unset`,`export`,`source`,`alias`,`type`,`command`,`hash`,`help`,`history`]);function p(e){return e===`sudo`?`sudo`:d.has(e)?`keyword`:f.has(e)?`builtin`:/^[/~]/.test(e)||e.startsWith(`./`)||e.startsWith(`../`)?`path`:/^\d+(?:\.\d+)?$/.test(e)?`number`:`text`}function m(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`#`){let r=n+1;for(;r<e.length&&e[r]!==`
`;)r++;t.push({type:`comment`,value:e.slice(n,r)}),n=r;continue}if(r===`'`||r===`"`){let i=r,a=n+1;for(;a<e.length;){if(e[a]===`\\`&&i===`"`){a+=2;continue}if(e[a]===i){a++;break}a++}t.push({type:`string`,value:e.slice(n,a)}),n=a;continue}if(r==="`"){let r=n+1;for(;r<e.length&&e[r]!=="`";)r++;r<e.length&&r++,t.push({type:`backtick`,value:e.slice(n,r)}),n=r;continue}if(r===`$`){let r=n+1;if(e[r]===`{`){for(;r<e.length&&e[r]!==`}`;)r++;r<e.length&&r++}else if(e[r]===`(`)r++;else for(;r<e.length&&/[\w]/.test(e[r]);)r++;t.push({type:`variable`,value:e.slice(n,r)}),n=r;continue}if(r===`|`||r===`&`||r===`;`){let r=n;e[r]===`|`&&e[r+1]===`|`||e[r]===`&`&&e[r+1]===`&`?r+=2:r+=1;let i=e.slice(n,r);t.push({type:i===`|`||i===`||`?`pipe`:`operator`,value:i}),n=r;continue}if(r===`>`||r===`<`){let r=n;e[r]===`>`&&e[r+1]===`>`||e[r]===`<`&&e[r+1]===`<`?r+=2:r+=1,e[r]===`&`&&r++,t.push({type:`redirect`,value:e.slice(n,r)}),n=r;continue}if(/\s/.test(r)){let r=n;for(;r<e.length&&/\s/.test(e[r]);)r++;t.push({type:`text`,value:e.slice(n,r)}),n=r;continue}if(r===`-`&&e[n+1]===`-`){let r=n+2;for(;r<e.length&&/[\w-]/.test(e[r]);)r++;t.push({type:`flag`,value:e.slice(n,r)}),n=r;continue}if(r===`-`&&/[a-zA-Z]/.test(e[n+1]||``)){let r=n+1;for(;r<e.length&&/[a-zA-Z]/.test(e[r]);)r++;t.push({type:`flag`,value:e.slice(n,r)}),n=r;continue}let i=n;for(;i<e.length&&!/[\s#"'`$|;&<>]/.test(e[i]);)i++;let a=e.slice(n,i);t.push({type:p(a),value:a}),n=i}return t}function h(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var g={keyword:`sh-keyword`,builtin:`sh-builtin`,sudo:`sh-sudo`,pipe:`sh-pipe`,operator:`sh-operator`,redirect:`sh-redirect`,string:`sh-string`,flag:`sh-flag`,variable:`sh-variable`,backtick:`sh-backtick`,comment:`sh-comment`,number:`sh-number`,path:`sh-path`,text:`sh-text`};function _(e){return e?m(e).map(e=>`<span class="${g[e.type]}">${h(e.value)}</span>`).join(``):``}var v=[`innerHTML`],y=u(l({__name:`ShellHighlightField`,props:{modelValue:{},placeholder:{default:``},disabled:{type:Boolean,default:!1},multiline:{type:Boolean,default:!1},rows:{default:3},size:{default:`default`}},emits:[`update:modelValue`,`keydown`],setup(e,{emit:n}){let l=e,u=n,d=t(()=>_(l.modelValue));function f(e){let t=e.target;u(`update:modelValue`,t.value)}function p(e){u(`keydown`,e)}return(t,n)=>(o(),r(`div`,{class:c([`sh-field position-relative`,{"sh-field--disabled":e.disabled,"sh-field--empty":!e.modelValue,"sh-field--large":e.size===`large`}])},[e.modelValue?(o(),r(`div`,{key:0,class:c([`sh-field__highlight font-mono`,e.multiline?`sh-field__highlight--multi`:`sh-field__highlight--single`]),"aria-hidden":`true`,innerHTML:d.value},null,10,v)):a(``,!0),(o(),i(s(e.multiline?`textarea`:`input`),{value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,rows:e.multiline?e.rows:void 0,class:c([`sh-field__input font-mono`,e.multiline?`sh-field__input--multi`:`sh-field__input--single`]),spellcheck:`false`,autocomplete:`off`,onInput:f,onKeydown:p},null,40,[`value`,`placeholder`,`disabled`,`rows`,`class`]))],2))}}),[[`__scopeId`,`data-v-3962f69e`]]);function b(e){return[...e].sort((e,t)=>e.is_builtin===t.is_builtin?e.sort_order===t.sort_order?e.id-t.id:e.sort_order-t.sort_order:e.is_builtin?1:-1)}function x(){let t=e([]),r=e(!1);async function i(){r.value=!0;try{t.value=b(await n.get(`/terminal/quick-commands`)||[])}catch{throw t.value=[],Error(`加载快捷命令失败`)}finally{r.value=!1}}async function a(e,t){await n.post(`/terminal/quick-commands`,{name:e.trim(),cmd:t.trim()}),await i()}async function o(e,t,r){await n.put(`/terminal/quick-commands/${e}`,{name:t.trim(),cmd:r.trim()}),await i()}async function s(e){await n.delete(`/terminal/quick-commands/${e}`),await i()}async function c(e){t.value=b((await n.put(`/terminal/quick-commands/reorder`,{ids:e})).items||[])}return{commands:t,loading:r,load:i,create:a,update:o,remove:s,reorder:c,customCommands:()=>t.value.filter(e=>!e.is_builtin),builtinCommands:()=>t.value.filter(e=>e.is_builtin)}}export{x as n,y as r,b as t};