dskcode 0.1.48 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,29 +1,28 @@
1
1
  #!/usr/bin/env node
2
- import{a as kn,b as ka,c as tn,d as Yn,e as kt,f as Sa,h as Ta}from"./chunk-V3LN4R4P.js";import{a as nd}from"./chunk-KMMG6QC6.js";import{a as Oe,b as Qn,c as Ca}from"./chunk-5Z3DMHRQ.js";import{a as td}from"./chunk-MDFCAIOB.js";import{a as ga,b as ya,c as Lt,d as xa,e as Yu,f as ba,g as wa,i as en}from"./chunk-LG2AWYGC.js";import{a as Qu,b as ed,c as as,f as ls}from"./chunk-O3L436MU.js";import{a as is}from"./chunk-XAWVLVWL.js";import{a as Ag,b as Zu,c as Eg,d as p}from"./chunk-LPD7BHH5.js";var ip=Ag((XR,sp)=>{"use strict";p();var nl,{defineProperty:wx,getPrototypeOf:kx,setPrototypeOf:op,create:Sx,keys:Tx}=Object,st="",{round:Ts,max:Cx}=Math,rl=e=>{let t=/([a-f\d]{3,6})/i.exec(e)?.[0],n=t?.length,r="0x"+(6^n?3^n?"0":t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t)|0;return[r>>16,r>>8&255,255&r]},ep=e=>{if(8>e)return 30+e;if(16>e)return 82+e;if(e>231)return e>243?37:30;let t=(e-=16)%36,n=e/36|0,r=t/6|0,o=t%6;return 30+(n>2|(r>2)<<1|(o>2)<<2)+(Cx(n,r,o)>4?60:0)},tp={open:st,close:st},np=(e,{open:t="",close:n="",f:r})=>{let o=(e.open||st)+t,s=n+(e.close||st),i=(a,...l)=>{if(!a){if(!n)return t;if((a??st)===st)return st}let c,u=r?r(a,...l):a.raw?String.raw({raw:a},...l):st+a,d=i;if(u.includes("\x1B"))for(;d=d.p;){let{t:m,o:h}=d,f=h.length,g=st,b=0;if(f)for(;~(c=u.indexOf(h,b));b=c+f)g+=u.slice(b,c)+m;u=g+u.slice(b)}return o+(u.includes(`
3
- `)?u.replace(/(\r?\n)/g,s+"$1"+o):u)+s};return op(i,kx(e)).p={t,o:n,p:e.p},i.open=o,i.close=s,i},rp=new function e(t=globalThis){let n=typeof t=="number"?t:(_=>{let E=_.process??{},M=E.argv??[],U=E.env??{},T=0;try{T=((le,ee,W)=>(nl=ee.TERM,{"24bit":3,truecolor:3,ansi256:2,ansi:1}[ee.COLORTERM]||(ee.CI?/,GITHUB/.test(W)?3:1:(ee.PM2_HOME||/edge/.test(ee.NEXT_RUNTIME)||le.stdout?.isTTY)&&nl!=="dumb"?le.platform==="win32"?3:/-256/.test(nl)?2:1:0)))(E,U,","+Tx(U).join(","))}catch{U={}}let N,F=T||1,q="FORCE_COLOR",$={false:0,0:0,1:1,2:2,3:3}[U[q]]??F,oe=-1;for(N of M)/^--color=?(true|always)?$/.test(N)&&(oe=F),/^--(no-color|color=(false|never))$/.test(N)&&(oe=0);return _.window?.chrome?3:q in U?$:~oe?oe:U.NO_COLOR?0:T})(t),r={},o={Ansis:e,level:n,isSupported:()=>l,strip:_=>_.replace(/][^]*|[›][[()#;?]*(?:\d+(?:;\d*)*)?[\dA-ORZcf-nqry=><]/g,st),extend(_){for(let E in _){let M=_[E];(typeof M)[0]==="s"&&(s(u(E),w(...rl(M))),M=b(...rl(M))),s(E,M)}return op(o,Sx({},r))}},s=(_,E)=>{r[_]={get(){return wx(this,_,{value:E.call?(...M)=>np(this,E(...M)):np(this,E)})[_]}}},i=1^n,a=n>2,l=n>0,c=(_,E)=>l?{open:`\x1B[${_}m`,close:E?`\x1B[${E}m`:st}:tp,u=_=>"bg"+_[0].toUpperCase()+_.slice(1),d=_=>E=>_(...rl(E)),m=(_,E)=>(M,U,T)=>c(`${_}8;2;${M};${U};${T}`,E),h=_=>(E,M,U)=>_(((T,N,F)=>T^N|N^F?16+36*Ts(T/51)+6*Ts(N/51)+Ts(F/51):8>T?16:T>248?231:Ts(24*(T-8)/247)+232)(E,M,U)),f=_=>c(i?"38;5;"+_:ep(_),39),g=_=>c(i?"48;5;"+_:ep(_)+10,49),b=a?m(3,39):h(f),w=a?m(4,49):h(g),S={fg:f,bg:g,rgb:b,bgRgb:w,hex:d(b),bgHex:d(w),visible:tp,reset:c(0,st),bold:c(1,22),dim:c(2,22),italic:c(3,23),underline:c(4,24),inverse:c(7,27),hidden:c(8,28),strikethrough:c(9,29),link:{f:(_,E=_)=>l?`\x1B]8;;${_}\x07${E}\x1B]8;;\x07`:E!=_?E+` (\u200B${_}\u200B)`:_}},v=(_,E)=>{S[_]=c(E,39),S[u(_)]=c(E+10,49)};return"gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((_,E)=>{E?v(_+"Bright",89+E):E=61,v(_,29+E)})),o.extend(S)};sp.exports=rp.default=rp});p();p();import{Command as KC}from"commander";import{useEffect as XC,useState as cg}from"react";p();p();p();import{mkdir as Ig,readFile as Pg,writeFile as Lg}from"fs/promises";import{dirname as $g}from"path";function cs(e){let t=process.env.VOLC_ASR_APP_ID?.trim(),n=process.env.VOLC_ASR_ACCESS_KEY?.trim(),r=t||e?.appId||"",o=n||e?.accessKey||"",s={appId:t?"env":e?.appId?"settings":"missing",accessKey:n?"env":e?.accessKey?"settings":"missing"},i=[];return r||i.push("appId"),o||i.push("accessKey"),{resolved:i.length===0,missing:i.length>0?i:void 0,source:s,config:{appId:r,accessKey:o,resourceId:e?.resourceId??"volc.bigasr.sauc.duration",language:e?.language??"zh-CN",sampleRate:e?.sampleRate??16e3,enabled:e?.enabled??!0}}}async function _a(e,t,n,r){let o={};try{let i=await Pg(e,"utf8"),a=JSON.parse(i);a&&typeof a=="object"&&(o=a)}catch(i){if(i.code!=="ENOENT")throw i}let s=o.voice??{appId:"",accessKey:""};o.voice={...s,appId:t,accessKey:n,resourceId:r?.resourceId??s.resourceId??"volc.bigasr.sauc.duration",language:r?.language??s.language??"zh-CN",enabled:s.enabled??!0},await Ig($g(e),{recursive:!0}),await Lg(e,JSON.stringify(o,null,2)+`
4
- `,"utf8")}async function rd(){let e=this.optsWithGlobals(),t=e.verbose??!1,n,r=[];try{let o=await Lt(e.config);if(n=o.config,o.errors.length>0)for(let s of o.errors)r.push(s.message)}catch{n=structuredClone(ga)}if(n=ya(n,{verbose:t,model:e.model}),r.length>0&&t)for(let o of r)console.error(` \u26A0 ${o}`);return{config:n,verbose:t}}p();import ve from"chalk";function od(e){let t=[];t.push(""),t.push(ve.bold("\u7528\u6CD5:")),t.push(` ${ve.cyan("dskcode")} ${ve.dim("[global-options]")} ${ve.green("<command>")} ${ve.dim("[options]")}`),t.push("");let n=e.options.filter(o=>o.long!=="--help"&&o.long!=="--version"&&o.long!=="--config");if(n.length>0){t.push(ve.bold("\u5168\u5C40\u9009\u9879:"));for(let o of n){let s=[o.short,o.long].filter(Boolean).join(", ");t.push(` ${ve.cyan(s.padEnd(24))} ${o.description??""}`)}t.push("")}t.push(ve.bold("\u5185\u7F6E\u9009\u9879:"));for(let o of["-h, --help","-V, --version"]){let s=e.options.find(i=>i.long===(o.includes("help")?"--help":"--version"));s&&t.push(` ${ve.cyan(o.padEnd(24))} ${s.description??""}`)}t.push("");let r=e.commands.filter(o=>!o.name().startsWith("help"));if(r.length>0){t.push(ve.bold("\u547D\u4EE4:"));for(let o of r)t.push(` ${ve.green(o.name().padEnd(24))} ${o.description()}`);t.push("")}return t.push(ve.bold("\u793A\u4F8B:")),t.push(` ${ve.dim("# \u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD(\u65E0\u53C2\u9ED8\u8BA4\u884C\u4E3A)")}`),t.push(" dskcode"),t.push(` ${ve.dim("# \u8BA9 AI \u6267\u884C\u4E00\u4E2A\u4EFB\u52A1")}`),t.push(" dskcode run \u4FEE\u6539\u6240\u6709 TODO \u6CE8\u91CA"),t.push(` ${ve.dim("# \u8FD0\u884C\u914D\u7F6E\u5411\u5BFC")}`),t.push(" dskcode setup"),t.push(` ${ve.dim("# \u751F\u6210 shell \u81EA\u52A8\u8865\u5168")}`),t.push(" dskcode completion"),t.push(` ${ve.dim("# \u67E5\u770B\u81EA\u9009\u80A1\u884C\u60C5")}`),t.push(" dskcode stock"),t.push(` ${ve.dim("# \u67E5\u770B\u6307\u5B9A\u80A1\u7968\u884C\u60C5")}`),t.push(" dskcode stock sh513090 sz000001"),t.push(""),t.join(`
5
- `)}p();import{createInterface as sd}from"readline";import me from"chalk";function id(e){return!!(e.some(t=>t.apiKey)||process.env.DEEPSEEK_API_KEY)}var va=10;async function ad(){console.log(me.yellow(`
2
+ import{a as kn,b as _a,c as tn,d as Jn,e as kt,f as Ra,h as va}from"./chunk-V3LN4R4P.js";import{a as ad}from"./chunk-XADXUHKL.js";import{a as Oe,b as Sn,c as Aa}from"./chunk-5Z3DMHRQ.js";import{a as id}from"./chunk-MDFCAIOB.js";import{a as wa,b as ka,c as Lt,d as Sa,e as rd,f as Ta,g as Ca,i as en}from"./chunk-QASDDP3K.js";import{a as od,b as sd,c as us,f as ds}from"./chunk-O3L436MU.js";import{a as cs}from"./chunk-XAWVLVWL.js";import{a as Og,b as nd,c as Dg,d as p}from"./chunk-LPD7BHH5.js";var up=Og((iA,cp)=>{"use strict";p();var tl,{defineProperty:Cx,getPrototypeOf:_x,setPrototypeOf:lp,create:Rx,keys:vx}=Object,st="",{round:Cs,max:Ax}=Math,nl=e=>{let t=/([a-f\d]{3,6})/i.exec(e)?.[0],n=t?.length,r="0x"+(6^n?3^n?"0":t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t)|0;return[r>>16,r>>8&255,255&r]},op=e=>{if(8>e)return 30+e;if(16>e)return 82+e;if(e>231)return e>243?37:30;let t=(e-=16)%36,n=e/36|0,r=t/6|0,o=t%6;return 30+(n>2|(r>2)<<1|(o>2)<<2)+(Ax(n,r,o)>4?60:0)},sp={open:st,close:st},ip=(e,{open:t="",close:n="",f:r})=>{let o=(e.open||st)+t,s=n+(e.close||st),i=(a,...l)=>{if(!a){if(!n)return t;if((a??st)===st)return st}let c,u=r?r(a,...l):a.raw?String.raw({raw:a},...l):st+a,d=i;if(u.includes("\x1B"))for(;d=d.p;){let{t:m,o:h}=d,f=h.length,g=st,k=0;if(f)for(;~(c=u.indexOf(h,k));k=c+f)g+=u.slice(k,c)+m;u=g+u.slice(k)}return o+(u.includes(`
3
+ `)?u.replace(/(\r?\n)/g,s+"$1"+o):u)+s};return lp(i,_x(e)).p={t,o:n,p:e.p},i.open=o,i.close=s,i},ap=new function e(t=globalThis){let n=typeof t=="number"?t:(v=>{let _=v.process??{},B=_.argv??[],j=_.env??{},D=0;try{D=((ie,ne,H)=>(tl=ne.TERM,{"24bit":3,truecolor:3,ansi256:2,ansi:1}[ne.COLORTERM]||(ne.CI?/,GITHUB/.test(H)?3:1:(ne.PM2_HOME||/edge/.test(ne.NEXT_RUNTIME)||ie.stdout?.isTTY)&&tl!=="dumb"?ie.platform==="win32"?3:/-256/.test(tl)?2:1:0)))(_,j,","+vx(j).join(","))}catch{j={}}let C,J=D||1,M="FORCE_COLOR",U={false:0,0:0,1:1,2:2,3:3}[j[M]]??J,N=-1;for(C of B)/^--color=?(true|always)?$/.test(C)&&(N=J),/^--(no-color|color=(false|never))$/.test(C)&&(N=0);return v.window?.chrome?3:M in j?U:~N?N:j.NO_COLOR?0:D})(t),r={},o={Ansis:e,level:n,isSupported:()=>l,strip:v=>v.replace(/][^]*|[›][[()#;?]*(?:\d+(?:;\d*)*)?[\dA-ORZcf-nqry=><]/g,st),extend(v){for(let _ in v){let B=v[_];(typeof B)[0]==="s"&&(s(u(_),b(...nl(B))),B=k(...nl(B))),s(_,B)}return lp(o,Rx({},r))}},s=(v,_)=>{r[v]={get(){return Cx(this,v,{value:_.call?(...B)=>ip(this,_(...B)):ip(this,_)})[v]}}},i=1^n,a=n>2,l=n>0,c=(v,_)=>l?{open:`\x1B[${v}m`,close:_?`\x1B[${_}m`:st}:sp,u=v=>"bg"+v[0].toUpperCase()+v.slice(1),d=v=>_=>v(...nl(_)),m=(v,_)=>(B,j,D)=>c(`${v}8;2;${B};${j};${D}`,_),h=v=>(_,B,j)=>v(((D,C,J)=>D^C|C^J?16+36*Cs(D/51)+6*Cs(C/51)+Cs(J/51):8>D?16:D>248?231:Cs(24*(D-8)/247)+232)(_,B,j)),f=v=>c(i?"38;5;"+v:op(v),39),g=v=>c(i?"48;5;"+v:op(v)+10,49),k=a?m(3,39):h(f),b=a?m(4,49):h(g),S={fg:f,bg:g,rgb:k,bgRgb:b,hex:d(k),bgHex:d(b),visible:sp,reset:c(0,st),bold:c(1,22),dim:c(2,22),italic:c(3,23),underline:c(4,24),inverse:c(7,27),hidden:c(8,28),strikethrough:c(9,29),link:{f:(v,_=v)=>l?`\x1B]8;;${v}\x07${_}\x1B]8;;\x07`:_!=v?_+` (\u200B${v}\u200B)`:v}},R=(v,_)=>{S[v]=c(_,39),S[u(v)]=c(_+10,49)};return"gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((v,_)=>{_?R(v+"Bright",89+_):_=61,R(v,29+_)})),o.extend(S)};cp.exports=ap.default=ap});p();p();import{Command as d_}from"commander";import{useEffect as p_,useState as gg}from"react";p();p();p();import{mkdir as Ng,readFile as Mg,writeFile as Bg}from"fs/promises";import{dirname as Fg}from"path";function ps(e){let t=process.env.VOLC_ASR_APP_ID?.trim(),n=process.env.VOLC_ASR_ACCESS_KEY?.trim(),r=t||e?.appId||"",o=n||e?.accessKey||"",s={appId:t?"env":e?.appId?"settings":"missing",accessKey:n?"env":e?.accessKey?"settings":"missing"},i=[];return r||i.push("appId"),o||i.push("accessKey"),{resolved:i.length===0,missing:i.length>0?i:void 0,source:s,config:{appId:r,accessKey:o,resourceId:e?.resourceId??"volc.bigasr.sauc.duration",language:e?.language??"zh-CN",sampleRate:e?.sampleRate??16e3,enabled:e?.enabled??!0}}}async function Ea(e,t,n,r){let o={};try{let i=await Mg(e,"utf8"),a=JSON.parse(i);a&&typeof a=="object"&&(o=a)}catch(i){if(i.code!=="ENOENT")throw i}let s=o.voice??{appId:"",accessKey:""};o.voice={...s,appId:t,accessKey:n,resourceId:r?.resourceId??s.resourceId??"volc.bigasr.sauc.duration",language:r?.language??s.language??"zh-CN",enabled:s.enabled??!0},await Ng(Fg(e),{recursive:!0}),await Bg(e,JSON.stringify(o,null,2)+`
4
+ `,"utf8")}async function ld(){let e=this.optsWithGlobals(),t=e.verbose??!1,n,r=[];try{let o=await Lt(e.config);if(n=o.config,o.errors.length>0)for(let s of o.errors)r.push(s.message)}catch{n=structuredClone(wa)}if(n=ka(n,{verbose:t,model:e.model}),r.length>0&&t)for(let o of r)console.error(` \u26A0 ${o}`);return{config:n,verbose:t}}p();import Re from"chalk";function cd(e){let t=[];t.push(""),t.push(Re.bold("\u7528\u6CD5:")),t.push(` ${Re.cyan("dskcode")} ${Re.dim("[global-options]")} ${Re.green("<command>")} ${Re.dim("[options]")}`),t.push("");let n=e.options.filter(o=>o.long!=="--help"&&o.long!=="--version"&&o.long!=="--config");if(n.length>0){t.push(Re.bold("\u5168\u5C40\u9009\u9879:"));for(let o of n){let s=[o.short,o.long].filter(Boolean).join(", ");t.push(` ${Re.cyan(s.padEnd(24))} ${o.description??""}`)}t.push("")}t.push(Re.bold("\u5185\u7F6E\u9009\u9879:"));for(let o of["-h, --help","-V, --version"]){let s=e.options.find(i=>i.long===(o.includes("help")?"--help":"--version"));s&&t.push(` ${Re.cyan(o.padEnd(24))} ${s.description??""}`)}t.push("");let r=e.commands.filter(o=>!o.name().startsWith("help"));if(r.length>0){t.push(Re.bold("\u547D\u4EE4:"));for(let o of r)t.push(` ${Re.green(o.name().padEnd(24))} ${o.description()}`);t.push("")}return t.push(Re.bold("\u793A\u4F8B:")),t.push(` ${Re.dim("# \u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD(\u65E0\u53C2\u9ED8\u8BA4\u884C\u4E3A)")}`),t.push(" dskcode"),t.push(` ${Re.dim("# \u8BA9 AI \u6267\u884C\u4E00\u4E2A\u4EFB\u52A1")}`),t.push(" dskcode run \u4FEE\u6539\u6240\u6709 TODO \u6CE8\u91CA"),t.push(` ${Re.dim("# \u8FD0\u884C\u914D\u7F6E\u5411\u5BFC")}`),t.push(" dskcode setup"),t.push(` ${Re.dim("# \u751F\u6210 shell \u81EA\u52A8\u8865\u5168")}`),t.push(" dskcode completion"),t.push(` ${Re.dim("# \u67E5\u770B\u81EA\u9009\u80A1\u884C\u60C5")}`),t.push(" dskcode stock"),t.push(` ${Re.dim("# \u67E5\u770B\u6307\u5B9A\u80A1\u7968\u884C\u60C5")}`),t.push(" dskcode stock sh513090 sz000001"),t.push(""),t.join(`
5
+ `)}p();import{createInterface as ud}from"readline";import me from"chalk";function dd(e){return!!(e.some(t=>t.apiKey)||process.env.DEEPSEEK_API_KEY)}var Ia=10;async function pd(){console.log(me.yellow(`
6
6
  \u26A0 \u672A\u68C0\u6D4B\u5230 API Key \u914D\u7F6E`)),console.log(me.dim(" \u4F60\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u4EFB\u4E00\u65B9\u5F0F\u914D\u7F6E\uFF1A")),console.log(me.dim(" \xB7 \u73AF\u5883\u53D8\u91CF: export DEEPSEEK_API_KEY=sk-xxx")),console.log(me.dim(" \xB7 \u914D\u7F6E\u6587\u4EF6: ~/.dskcode/settings.json")),console.log(me.dim(` \xB7 \u4E0B\u9762\u76F4\u63A5\u8F93\u5165\uFF0C\u81EA\u52A8\u4FDD\u5B58\u5230\u5168\u5C40\u914D\u7F6E
7
- `));let e=sd({input:process.stdin,output:process.stdout});return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,process.stdin.removeListener("keypress",o),e.close())},o=(s,i)=>{i.ctrl&&i.name==="c"&&(r(),t(null))};process.stdin.on("keypress",o),e.question(` ${me.cyan("\u{1F511}")} ${me.bold("\u8BF7\u8F93\u5165\u4F60\u7684 DeepSeek API Key:")} `,s=>{r();let i=s.trim();if(!i){console.log(me.red(" \u2716 API Key \u4E0D\u80FD\u4E3A\u7A7A")),t(null);return}if(i.length<va){console.log(me.red(" \u2716 API Key \u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u957F\u5EA6\u81F3\u5C11 10 \u4F4D")),t(null);return}t(i)})})}async function ld(){console.log(me.yellow(`
7
+ `));let e=ud({input:process.stdin,output:process.stdout});return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,process.stdin.removeListener("keypress",o),e.close())},o=(s,i)=>{i.ctrl&&i.name==="c"&&(r(),t(null))};process.stdin.on("keypress",o),e.question(` ${me.cyan("\u{1F511}")} ${me.bold("\u8BF7\u8F93\u5165\u4F60\u7684 DeepSeek API Key:")} `,s=>{r();let i=s.trim();if(!i){console.log(me.red(" \u2716 API Key \u4E0D\u80FD\u4E3A\u7A7A")),t(null);return}if(i.length<Ia){console.log(me.red(" \u2716 API Key \u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u957F\u5EA6\u81F3\u5C11 10 \u4F4D")),t(null);return}t(i)})})}async function fd(){console.log(me.yellow(`
8
8
  \u26A0 \u672A\u68C0\u6D4B\u5230\u706B\u5C71 ASR \u51ED\u636E`)),console.log(me.dim(" \u4F60\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u4EFB\u4E00\u65B9\u5F0F\u914D\u7F6E\uFF1A")),console.log(me.dim(" \xB7 \u73AF\u5883\u53D8\u91CF: export VOLC_ASR_APP_ID=... VOLC_ASR_ACCESS_KEY=...")),console.log(me.dim(" \xB7 \u914D\u7F6E\u6587\u4EF6: ~/.dskcode/settings.json \u7684 voice \u6BB5")),console.log(me.dim(` \xB7 \u4E0B\u9762\u76F4\u63A5\u8F93\u5165\uFF0C\u81EA\u52A8\u4FDD\u5B58\u5230\u5168\u5C40\u914D\u7F6E
9
9
  `)),console.log(me.dim(` \u51ED\u636E\u83B7\u53D6\u8DEF\u5F84\uFF1A\u706B\u5C71\u63A7\u5236\u53F0 \u2192 \u8BED\u97F3\u6280\u672F \u2192 \u6211\u7684\u5E94\u7528
10
- `));let e=sd({input:process.stdin,output:process.stdout});return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,process.stdin.removeListener("keypress",o),e.close())},o=(s,i)=>{i.ctrl&&i.name==="c"&&(r(),t(null))};process.stdin.on("keypress",o),e.question(` ${me.cyan("\u{1F194}")} ${me.bold("\u8BF7\u8F93\u5165 APP ID\uFF08\u7EAF\u6570\u5B57\uFF09:")} `,s=>{let i=s.trim();if(!/^\d+$/.test(i)){r(),console.log(me.red(" \u2716 APP ID \u5FC5\u987B\u662F\u7EAF\u6570\u5B57")),t(null);return}e.question(` ${me.cyan("\u{1F511}")} ${me.bold("\u8BF7\u8F93\u5165 Access Key:")} `,a=>{r();let l=a.trim();if(l.length<va){console.log(me.red(` \u2716 Access Key \u957F\u5EA6\u81F3\u5C11 ${va} \u4F4D`)),t(null);return}t({appId:i,accessKey:l})})})})}p();import{createInterface as Og}from"readline";import{existsSync as $t,statSync as er,lstatSync as Dg}from"fs";import{mkdir as Ng,readdir as tr,cp as Mg,access as Bg,realpath as Fg,readFile as Gg}from"fs/promises";import{join as Ke}from"path";import qe from"chalk";function Ra(){let e=process.env.HOME??process.env.USERPROFILE??"~";return Ke(e,".claude","skills")}function nr(){return Qu()}async function rr(e){try{return await Bg(Ke(e,"SKILL.md")),!0}catch{return!1}}async function jg(){let e=Ra();if(!$t(e))return[];let t;try{t=await tr(e)}catch{return[]}let n=[];for(let r of t){let o=Ke(e,r);er(o).isDirectory()&&await rr(o)&&n.push(r)}return n}function Ug(e){let t=Og({input:process.stdin,output:process.stdout});return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,process.stdin.removeListener("keypress",s),t.close())},s=(i,a)=>{a.ctrl&&a.name==="c"&&(o(),n(!1))};process.stdin.on("keypress",s),t.question(e,i=>{o();let a=i.trim().toLowerCase();n(a==="y"||a==="yes")})})}async function Wg(e){let t=Ra(),n=nr();await Ng(n,{recursive:!0});let r=[],o=[];for(let s of e){let i=Ke(t,s),a=Ke(n,s);if($t(a)){o.push(s);continue}let l=Dg(i).isSymbolicLink()?await Fg(i):i;await Mg(l,a,{recursive:!0,dereference:!0}),r.push(s)}return{imported:r,skipped:o}}async function ud(){let e=nr();if(!$t(e))return 0;let t;try{t=await tr(e)}catch{return 0}let n=0;for(let r of t){let o=Ke(e,r);er(o).isDirectory()&&await rr(o)&&n++}return n}function Aa(e){return ed(e)}async function Hg(e){return await Ea(e)>0}async function Ea(e){let t=Aa(e);if(!$t(t))return 0;let n;try{n=await tr(t)}catch{return 0}let r=0;for(let o of n){let s=Ke(t,o);er(s).isDirectory()&&await rr(s)&&r++}return r}async function Vg(){let e=nr();if(!$t(e))return!1;let t;try{t=await tr(e)}catch{return!1}for(let n of t){let r=Ke(e,n);if(er(r).isDirectory()&&await rr(r))return!0}return!1}async function dd(e){if(e&&await Hg(e)){console.log(qe.dim(` \u68C0\u6D4B\u5230\u9879\u76EE\u672C\u5730 .dskcode/skill\uFF0C\u8DF3\u8FC7\u5BFC\u5165 Claude Code skill
11
- `));return}if(await Vg())return;let n=await jg();if(n.length===0)return;console.log(qe.cyan(`
10
+ `));let e=ud({input:process.stdin,output:process.stdout});return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,process.stdin.removeListener("keypress",o),e.close())},o=(s,i)=>{i.ctrl&&i.name==="c"&&(r(),t(null))};process.stdin.on("keypress",o),e.question(` ${me.cyan("\u{1F194}")} ${me.bold("\u8BF7\u8F93\u5165 APP ID\uFF08\u7EAF\u6570\u5B57\uFF09:")} `,s=>{let i=s.trim();if(!/^\d+$/.test(i)){r(),console.log(me.red(" \u2716 APP ID \u5FC5\u987B\u662F\u7EAF\u6570\u5B57")),t(null);return}e.question(` ${me.cyan("\u{1F511}")} ${me.bold("\u8BF7\u8F93\u5165 Access Key:")} `,a=>{r();let l=a.trim();if(l.length<Ia){console.log(me.red(` \u2716 Access Key \u957F\u5EA6\u81F3\u5C11 ${Ia} \u4F4D`)),t(null);return}t({appId:i,accessKey:l})})})})}p();import{createInterface as Gg}from"readline";import{existsSync as $t,statSync as Zn,lstatSync as jg}from"fs";import{mkdir as Ug,readdir as Yn,cp as Wg,access as Hg,realpath as Vg,readFile as zg}from"fs/promises";import{join as Ke}from"path";import qe from"chalk";function Pa(){let e=process.env.HOME??process.env.USERPROFILE??"~";return Ke(e,".claude","skills")}function Qn(){return od()}async function er(e){try{return await Hg(Ke(e,"SKILL.md")),!0}catch{return!1}}async function qg(){let e=Pa();if(!$t(e))return[];let t;try{t=await Yn(e)}catch{return[]}let n=[];for(let r of t){let o=Ke(e,r);Zn(o).isDirectory()&&await er(o)&&n.push(r)}return n}function Kg(e){let t=Gg({input:process.stdin,output:process.stdout});return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,process.stdin.removeListener("keypress",s),t.close())},s=(i,a)=>{a.ctrl&&a.name==="c"&&(o(),n(!1))};process.stdin.on("keypress",s),t.question(e,i=>{o();let a=i.trim().toLowerCase();n(a==="y"||a==="yes")})})}async function Xg(e){let t=Pa(),n=Qn();await Ug(n,{recursive:!0});let r=[],o=[];for(let s of e){let i=Ke(t,s),a=Ke(n,s);if($t(a)){o.push(s);continue}let l=jg(i).isSymbolicLink()?await Vg(i):i;await Wg(l,a,{recursive:!0,dereference:!0}),r.push(s)}return{imported:r,skipped:o}}async function hd(){let e=Qn();if(!$t(e))return 0;let t;try{t=await Yn(e)}catch{return 0}let n=0;for(let r of t){let o=Ke(e,r);Zn(o).isDirectory()&&await er(o)&&n++}return n}function La(e){return sd(e)}async function Jg(e){return await $a(e)>0}async function $a(e){let t=La(e);if(!$t(t))return 0;let n;try{n=await Yn(t)}catch{return 0}let r=0;for(let o of n){let s=Ke(t,o);Zn(s).isDirectory()&&await er(s)&&r++}return r}async function Zg(){let e=Qn();if(!$t(e))return!1;let t;try{t=await Yn(e)}catch{return!1}for(let n of t){let r=Ke(e,n);if(Zn(r).isDirectory()&&await er(r))return!0}return!1}async function gd(e){if(e&&await Jg(e)){console.log(qe.dim(` \u68C0\u6D4B\u5230\u9879\u76EE\u672C\u5730 .dskcode/skill\uFF0C\u8DF3\u8FC7\u5BFC\u5165 Claude Code skill
11
+ `));return}if(await Zg())return;let n=await qg();if(n.length===0)return;console.log(qe.cyan(`
12
12
  \u2726 \u68C0\u6D4B\u5230\u4F60\u5728 Claude Code \u4E2D\u5B89\u88C5\u4E86 ${String(n.length)} \u4E2A skill\uFF1A`));let r=n.slice(0,5).map(s=>qe.dim(` \xB7 ${s}`)).join(`
13
- `);if(console.log(r),n.length>5&&console.log(qe.dim(` \xB7 ...\u7B49 ${String(n.length)} \u4E2A`)),console.log(qe.dim(` \u6E90\u76EE\u5F55: ${Ra()}`)),console.log(qe.dim(` \u76EE\u6807\u76EE\u5F55: ${nr()}
14
- `)),!await Ug(` ${qe.cyan("\u{1F4E6}")} \u662F\u5426\u5C06\u8FD9\u4E9B skill \u5BFC\u5165\u5230 dskcode\uFF1F${qe.dim("[y/N] ")} `)){console.log(qe.dim(` \u5DF2\u8DF3\u8FC7 skill \u5BFC\u5165
15
- `));return}try{let{imported:s,skipped:i}=await Wg(n);s.length>0&&console.log(qe.green(` \u2714 \u5DF2\u5BFC\u5165 ${String(s.length)} \u4E2A skill \u5230 ~/.dskcode/skills`)),i.length>0&&console.log(qe.yellow(` \u26A0 ${String(i.length)} \u4E2A skill \u5DF2\u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${i.join(", ")}`)),console.log("")}catch(s){console.log(qe.red(` \u2716 \u5BFC\u5165 skill \u5931\u8D25: ${s instanceof Error?s.message:String(s)}`)),console.log(qe.dim(` \u4F60\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u590D\u5236 ~/.claude/skills \u5230 ~/.dskcode/skills
16
- `))}}async function zg(){let e=nr();if(!$t(e))return[];let t;try{t=await tr(e)}catch{return[]}let n=[];for(let r of t){let o=Ke(e,r);er(o).isDirectory()&&await rr(o)&&n.push(r)}return n}async function qg(e){let t=Aa(e);if(!$t(t))return[];let n;try{n=await tr(t)}catch{return[]}let r=[];for(let o of n){let s=Ke(t,o);er(s).isDirectory()&&await rr(s)&&r.push(o)}return r}async function cd(e){try{let n=(await Gg(Ke(e,"SKILL.md"),"utf-8")).match(/^---\n([\s\S]*?)\n---/);if(!n)return null;let r=n[1],o=r.match(/^name:\s*(.+)$/m),s=r.match(/^description:\s*(.+)$/m);return{name:o?.[1]?.trim()??"",description:s?.[1]?.trim()??""}}catch{return null}}async function pd(e){let[t,n]=await Promise.all([zg(),qg(e)]),r=new Set,o=[];for(let l of[...n,...t])r.has(l)||(r.add(l),o.push(l));let s=nr(),i=Aa(e),a=[];for(let l of o){let c=Ke(i,l),u=null;if($t(c)&&(u=await cd(c)),!u){let d=Ke(s,l);$t(d)&&(u=await cd(d))}a.push(u??{name:l,description:""})}return a}import{readFile as JC}from"fs/promises";import{join as dg}from"path";p();p();import{render as Kg}from"ink";function Fr(e){let{waitUntilExit:t,clear:n,unmount:r}=Kg(e,{exitOnCtrlC:!1});return{waitUntilExit:t(),clear:n,unmount:r}}p();import{Text as nv}from"ink";import ov from"ink-spinner";import{jsx as av,jsxs as lv}from"react/jsx-runtime";p();import{Box as dv,Text as pv}from"ink";import{jsxs as hv}from"react/jsx-runtime";p();import{Box as xv,Text as bv}from"ink";import{useEffect as kv,useState as Sv}from"react";import{jsx as _v}from"react/jsx-runtime";var Gr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Ia=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557"," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D"," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557 "," \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D"];p();import{Box as H,Text as G,useInput as WT,Static as HT}from"ink";import{useEffect as Se,useState as z,useCallback as ct,useMemo as Th,useRef as ae}from"react";p();import{useState as Xg,useCallback as Jg,useEffect as Zg,useRef as fd}from"react";var Yg=1500;function Sn(e){let[t,n]=Xg(!1),r=fd(null),o=fd(e);o.current=e,Zg(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Jg(()=>{if(t){o.current();return}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},Yg)},[t]);return{doubleCtrlC:t,handleCtrlC:s}}import VT from"ink-spinner";p();import{Box as Tt,Text as Ot}from"ink";import{useEffect as Ey,useRef as _d,useState as vd}from"react";p();import{mkdir as Qg,readFile as ey,writeFile as ty}from"fs/promises";import{join as Pa}from"path";var Me=class e{static#e=new Set;static async flushAll(){await Promise.allSettled([...e.#e].map(t=>t.flush()))}#n;#r;#s;#t;#c;#p;#i=[];#d;#o;#a=!1;#m=!1;constructor(t={}){let n=process.env.HOME??process.env.USERPROFILE??"~";this.#n=t.costDir??Pa(n,".dskcode","costs"),this.#r=t.budgetLimit??0,this.#s=t.tokenBudgetLimit??0,this.#t=t.onBudgetExceeded,this.#c=md(),this.#p=new Date().toISOString();let r=La();this.#d=r,this.#o=hd(r),e.#e.add(this)}record(t,n){let r=kt(t,n),o={timestamp:new Date().toISOString(),model:n,usage:{...t},cost:{...r}};return this.#i.push(o),this.#f(),this.#u(o),this.#a=!0,this.#x(),r}get sessionId(){return this.#c}get records(){return this.#i}get sessionSummary(){let t=0,n=0,r=0,o=0;for(let s of this.#i)t+=s.usage.promptTokens,n+=s.usage.completionTokens,r+=s.usage.cachedPromptTokens??0,o+=s.cost.totalCost;return{sessionId:this.#c,startedAt:this.#p,totalPromptTokens:t,totalCompletionTokens:n,totalCachedTokens:r,totalCost:o,records:[...this.#i]}}get sessionTotalCost(){return this.#i.reduce((t,n)=>t+n.cost.totalCost,0)}get sessionPromptTokens(){return this.#i.reduce((t,n)=>t+n.usage.promptTokens,0)}get sessionCompletionTokens(){return this.#i.reduce((t,n)=>t+n.usage.completionTokens,0)}get sessionCallCount(){return this.#i.length}get todaySummary(){return this.#f(),{...this.#o}}get todayTotalCost(){return this.#f(),this.#o.totalCost}get todayCallCount(){return this.#f(),this.#o.totalCalls}get isBudgetExceeded(){return this.#r>0&&this.todayTotalCost>=this.#r||this.#s>0&&this.#o.totalPromptTokens+this.#o.totalCompletionTokens>=this.#s}get remainingBudget(){return this.#r<=0?1/0:Math.max(0,this.#r-this.todayTotalCost)}async load(){await this.#g();let t=await this.#h(),n=La();t.daily[n]&&(this.#o=t.daily[n],this.#d=n)}async flush(){if(!(!this.#a||this.#m)){this.#m=!0,this.#a=!1;try{await this.#g(),await this.#l()}catch(t){this.#a=!0,console.error("[CostTracker] flush \u5931\u8D25:",t)}finally{this.#m=!1}}}async queryRange(t,n){let r=await this.#h(),o=n??t,s=[];for(let[i,a]of Object.entries(r.daily))i>=t&&i<=o&&s.push(a);return s.sort((i,a)=>i.date.localeCompare(a.date)),s}resetSession(){this.#c=md(),this.#p=new Date().toISOString(),this.#i.length=0}async dispose(){e.#e.delete(this),await this.flush()}#f(){let t=La();t!==this.#d&&(this.#d=t,this.#o=hd(t),this.#a=!0)}#u(t){this.#o.totalPromptTokens+=t.usage.promptTokens,this.#o.totalCompletionTokens+=t.usage.completionTokens,this.#o.totalCachedTokens+=t.usage.cachedPromptTokens??0,this.#o.totalCost+=t.cost.totalCost,this.#o.totalCalls+=1;let n=t.model;this.#o.byModel[n]||(this.#o.byModel[n]={model:t.model,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0});let r=this.#o.byModel[n];r.totalPromptTokens+=t.usage.promptTokens,r.totalCompletionTokens+=t.usage.completionTokens,r.totalCachedTokens+=t.usage.cachedPromptTokens??0,r.totalCost+=t.cost.totalCost,r.totalCalls+=1}#x(){this.isBudgetExceeded&&this.#t?.(this)}async#h(){let t=Pa(this.#n,"history.json");try{let n=await ey(t,"utf-8");return JSON.parse(n)}catch{return{version:1,daily:{}}}}async#g(){await Qg(this.#n,{recursive:!0})}async#l(){let t=await this.#h();t.daily[this.#d]=this.#o;let n=ny(90),r=Object.keys(t.daily).filter(s=>s<n);for(let s of r)delete t.daily[s];let o=Pa(this.#n,"history.json");await ty(o,JSON.stringify(t,null,2),"utf-8")}};function md(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function La(){return new Date().toISOString().slice(0,10)}function ny(e){let t=new Date;return t.setDate(t.getDate()-e),t.toISOString().slice(0,10)}function hd(e){return{date:e,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0,byModel:{}}}function $a(e){return`\xA5${e.toFixed(4)}`}p();import{Box as Ur,Text as St}from"ink";p();var ry=new Set(["password","token","apikey","api_key","secret","authorization","auth","credential","credentials","private_key","privatekey"]);function us(e,t){if(!yd(t))return`${e}()`;switch(e){case"read_file":return`${e}(path=${rt(t.path)})`;case"write_file":return`${e}(path=${rt(t.path)})`;case"edit_file":return`${e}(path=${rt(t.path)}, old_text=${rt(t.old_text,30)})`;case"multi_edit":{let s=Array.isArray(t.edits)?t.edits.length:0;return`${e}(path=${rt(t.path)}, edits=${s})`}case"delete_range":return`${e}(path=${rt(t.path)})`;case"bash":return`${e}(command=${rt(t.command,60)})`;case"ls":return`${e}(path=${rt(t.path??".")})`;case"glob":return`${e}(pattern=${rt(t.pattern)})`;case"grep":return`${e}(pattern=${rt(t.pattern)}, path=${rt(t.path??".")})`;case"fetch":return`${e}(url=${rt(t.url,60)})`;default:let n=Object.keys(t);if(n.length===0)return`${e}()`;let r=n.slice(0,4).map(s=>`${s}=\u2026`).join(", "),o=n.length>4?`, +${n.length-4}`:"";return`${e}(${r}${o})`}}function jr(e){return Oa(e,new WeakSet)}function Oa(e,t){if(e==null||typeof e!="object")return e;let n=e;if(t.has(n))return"****";if(t.add(n),Array.isArray(e))return e.map(o=>Oa(o,t));let r={};for(let[o,s]of Object.entries(n))ry.has(o.toLowerCase())?r[o]="****":r[o]=Oa(s,t);return r}function gd(e,t={}){let n=t.valueMaxLen??80,r=t.maskSensitive!==!1,o=t.maxKeys??6;if(!yd(e))return Da(e,n);let s=r?jr(e):e,i=Object.entries(s),l=i.slice(0,o).map(([c,u])=>`${c}: ${Da(u,n)}`);return i.length>o&&l.push(`+${i.length-o} more`),l.join(`
17
- `)}function Da(e,t=80){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"\u2026":e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length<=3?JSON.stringify(e):`[\u2026${e.length} items\u2026]`;if(typeof e=="object"){let n=e,r=Object.keys(n);return r.length<=3?JSON.stringify(n):`{\u2026${r.length} keys\u2026}`}return JSON.stringify(e)}function rt(e,t=40){return e==null?String(e):typeof e!="string"?Da(e,t):e.length===0?"(\u7A7A)":e.length>t?e.slice(0,t-1)+"\u2026":e}function yd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}p();function or(e){if(e===""||e===void 0||e===null)return{ok:!0,args:{},fixed:""};try{return{ok:!0,args:JSON.parse(e),fixed:e}}catch(t){let n=oy(e);try{return{ok:!0,args:JSON.parse(n),fixed:n}}catch{let o=t instanceof Error?t.message:String(t);return sy(o,e)?{ok:!1,reason:"PARTIAL",partial:e,hint:"\u53C2\u6570 JSON \u5C1A\u672A\u6536\u5168\uFF0C\u6D41\u5F0F\u62FC\u63A5\u4E2D\uFF1B\u53EF\u80FD\u662F\u7F51\u7EDC/\u5FC3\u8DF3\u5BFC\u81F4\u534A\u622A"}:{ok:!1,reason:"INVALID_JSON",raw:e,error:o}}}}function oy(e){let t=e.length,n=0;for(let a=e.length-1;a>=0&&e[a]==="\\";a--)n++;n%2===1&&t--;let r=e.slice(0,t),o=[],s=!1,i=!1;for(let a=0;a<r.length;a++){let l=r[a];if(i){i=!1;continue}if(l==="\\"){i=!0;continue}if(l==='"'){s=!s;continue}s||(l==="{"?o.push("}"):l==="["?o.push("]"):(l==="}"||l==="]")&&o.pop())}for(s&&(r+='"');o.length>0;)r+=o.pop();return r}function sy(e,t){return!!(e.includes("Unexpected end of JSON")||e.includes("Unterminated string")||t.length<5)}import{jsx as Na,jsxs as Xe}from"react/jsx-runtime";function Ma({call:e,parsedArgs:t,schemaIssues:n,denial:r}){let o=t??ly(e.arguments),s=jr(o),i=us(e.name,s),a=gd(s);return Xe(Ur,{flexDirection:"column",marginLeft:3,marginTop:1,children:[Xe(Ur,{children:[Xe(St,{dimColor:!0,children:["\u{1F4E6} ",e.name]}),Xe(St,{dimColor:!0,children:[" ","\u2500".repeat(Math.max(1,30-e.name.length))]})]}),Xe(Ur,{flexDirection:"column",marginLeft:2,children:[Na(St,{dimColor:!0,children:i}),Na(St,{dimColor:!0,children:a})]}),n&&n.length>0&&Xe(Ur,{flexDirection:"column",marginLeft:2,children:[Xe(St,{color:"yellow",children:["\u26A0 schema \u95EE\u9898\uFF08",n.length,"\uFF09"]}),n.slice(0,3).map((l,c)=>Xe(St,{color:"yellow",children:[" - ",l.message]},c)),n.length>3&&Xe(St,{color:"yellow",children:[" ...\u8FD8\u6709 ",n.length-3," \u6761"]})]}),r&&Na(iy,{denial:r})]})}function iy({denial:e}){let t=ay[e.source]??e.source,n=e.source==="hardcoded_blacklist"?"\u{1F6AB}":"\u{1F6D1}";return Xe(Ur,{flexDirection:"column",marginLeft:2,marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[Xe(St,{color:"red",bold:!0,children:[n," \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\uFF08",t,"\uFF09"]}),Xe(St,{color:"red",children:[" \u539F\u56E0\uFF1A",e.reason]}),e.hint&&Xe(St,{color:"yellow",children:[" \u63D0\u793A\uFF1A",e.hint]})]})}var ay={hardcoded_blacklist:"\u786C\u7F16\u7801\u5B89\u5168\u89C4\u5219",permission_rule:"\u7528\u6237\u914D\u7F6E\u89C4\u5219",user_prompt:"\u7528\u6237\u624B\u52A8\u62D2\u7EDD"};function ly(e){if(!e)return{};let t=or(e);return t.ok?t.args:{}}p();import{Box as ds,Text as Le}from"ink";p();function xd(e){return e>=4352&&e<=4447||e===9001||e===9002||e>=11904&&e<=42191||e>=43360&&e<=43391||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65040&&e<=65055||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126976&&e<=131071||e>=12288&&e<=12351||e>=131072&&e<=196607?2:e<32||e>=127&&e<160?0:1}function Wr(e){let t=0;for(let n of e){let r=n.codePointAt(0);r!==void 0&&r!==8205&&(r>=65024&&r<=65039||(t+=xd(r)))}return t}function*cy(e){for(let t of e){let n=t.codePointAt(0);n!==void 0&&n!==8205&&(n>=65024&&n<=65039||(yield{ch:t,width:xd(n)}))}}function uy(e,t){if(t<=0)return[e];let n=[];for(let r of e.split(`
18
- `)){if(r.length===0){n.push("");continue}let o=dy(r,t);for(let s of o)n.push(s)}return n.length===0?[""]:n}function dy(e,t){if(Wr(e)<=t)return[e];let n=[],r="",o=0,s=-1,i=0;for(let{ch:a,width:l}of cy(e)){if(a===" "||a===" "){s=r.length,i=o+l,r+=a,o+=l;continue}if(o+l>t)if(s>0){let c=r.slice(0,s).replace(/[ \t]+$/,"");n.push(c),r=r.slice(s).replace(/^[ \t]+/,"")+a,o=Wr(r),s=-1,i=0}else n.push(r),r=a,o=l;else r+=a,o+=l}return r.length>0&&n.push(r),n}function py(e,t,n){return e.map((r,o)=>{let s=t[o]??3;return uy(r,s).map(a=>fy(a,s,n[o]??"left"))})}function fy(e,t,n="left"){let r=Wr(e),o=t-r;if(o<=0)return e;let s=n==="right"?o:n==="center"?Math.floor(o/2):0,i=o-s;return" ".repeat(s)+e+" ".repeat(i)}function Ba(e){let t=e.trim();return!t.startsWith("|")||!t.endsWith("|")?[]:t.slice(1,t.length-1).split("|").map(r=>r.trim())}function my(e){return Ba(e).map(t=>{let n=t.startsWith(":"),r=t.endsWith(":");return n&&r?"center":r?"right":"left"})}function bd(e,t={}){let n=t.termWidth??80,r=t.outerMargin??0,o=Math.max(n-r,20),s=e.split(`
19
- `).filter(T=>T.trim().length>0);if(s.length<2)return{lines:s,colWidths:[],totalWidth:0};let i=-1;for(let T=0;T<s.length;T++){let N=(s[T]??"").trim();if(/^\|[-: |]+\|$/.test(N)&&N.includes("-")){i=T;break}}if(i===-1)return{lines:s,colWidths:[],totalWidth:0};let a=Ba(s.slice(0,i).join("")),l=my(s[i]??""),c=s.slice(i+1).map(Ba),u=a.length;if(u===0)return{lines:s,colWidths:[],totalWidth:0};let d=[];for(let T=0;T<u;T++){let N=Wr(a[T]??"");for(let F of c){let q=Wr(F[T]??"");q>N&&(N=q)}d.push(Math.max(N,3))}let m=2,h=d.reduce((T,N)=>T+N+m,1),f;if(h<=o)f=d;else{let T=o-1-m*u,N=d.reduce((q,$)=>q+$,0);f=d.map(q=>Math.max(3,Math.floor(q/N*T)));let F=f.reduce((q,$)=>q+$+m,1);for(;F>o&&f.length>0;){let q=f.length-1,$=f[q]??3;if($<=3)break;f[q]=$-1,F=f.reduce((oe,le)=>oe+le+m,1)}}let g="\u2500",b=(T,N,F)=>T+f.map(q=>g.repeat(q+m)).join(N)+F,w=b("\u250C","\u252C","\u2510"),S=b("\u251C","\u253C","\u2524"),v=b("\u2514","\u2534","\u2518");function _(T){let N=py(T,f,l),F=Math.max(1,...N.map($=>$.length)),q=[];for(let $=0;$<F;$++){let oe="\u2502";for(let le=0;le<u;le++){let W=(N[le]??[])[$]??" ".repeat(f[le]??3);oe+=" "+W+" ",le<u-1&&(oe+="\u2502")}oe+="\u2502",q.push(oe)}return q}let E=_(a),M=c.map(_),U=f.reduce((T,N)=>T+N+m,1);return{lines:[w,...E,S,...M.flat(),v],colWidths:f,totalWidth:U}}function wd(){let e=process.stdout?.columns;return typeof e=="number"&&e>0?e:void 0}import{jsx as be,jsxs as Ga}from"react/jsx-runtime";function hy(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("```",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=e.indexOf("```",r+3);if(o===-1){t.push({text:e.slice(r),type:"plain"});break}let s=e.slice(r+3,o);t.push({text:s,type:"code_block"}),n=o+3}return t}function Fa(e){let t=e.trim();return/^\|.+\|$/.test(t)}function gy(e){let t=e.trim();return/^\|[-: |]+\|$/.test(t)&&t.includes("-")}function yy(e){let t=e.split(`
20
- `),n=[],r="";function o(){r&&(n.push({text:r,type:"plain"}),r="")}for(let s=0;s<t.length;s++){let i=t[s]??"";if(Fa(i)&&s+1<t.length&&gy(t[s+1]??"")&&s+2<t.length&&Fa(t[s+2]??"")){o();let a=[],l=s;for(;l<t.length&&Fa(t[l]??"");)a.push(t[l]),l++;n.push({text:a.join(`
13
+ `);if(console.log(r),n.length>5&&console.log(qe.dim(` \xB7 ...\u7B49 ${String(n.length)} \u4E2A`)),console.log(qe.dim(` \u6E90\u76EE\u5F55: ${Pa()}`)),console.log(qe.dim(` \u76EE\u6807\u76EE\u5F55: ${Qn()}
14
+ `)),!await Kg(` ${qe.cyan("\u{1F4E6}")} \u662F\u5426\u5C06\u8FD9\u4E9B skill \u5BFC\u5165\u5230 dskcode\uFF1F${qe.dim("[y/N] ")} `)){console.log(qe.dim(` \u5DF2\u8DF3\u8FC7 skill \u5BFC\u5165
15
+ `));return}try{let{imported:s,skipped:i}=await Xg(n);s.length>0&&console.log(qe.green(` \u2714 \u5DF2\u5BFC\u5165 ${String(s.length)} \u4E2A skill \u5230 ~/.dskcode/skills`)),i.length>0&&console.log(qe.yellow(` \u26A0 ${String(i.length)} \u4E2A skill \u5DF2\u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${i.join(", ")}`)),console.log("")}catch(s){console.log(qe.red(` \u2716 \u5BFC\u5165 skill \u5931\u8D25: ${s instanceof Error?s.message:String(s)}`)),console.log(qe.dim(` \u4F60\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u590D\u5236 ~/.claude/skills \u5230 ~/.dskcode/skills
16
+ `))}}async function Yg(){let e=Qn();if(!$t(e))return[];let t;try{t=await Yn(e)}catch{return[]}let n=[];for(let r of t){let o=Ke(e,r);Zn(o).isDirectory()&&await er(o)&&n.push(r)}return n}async function Qg(e){let t=La(e);if(!$t(t))return[];let n;try{n=await Yn(t)}catch{return[]}let r=[];for(let o of n){let s=Ke(t,o);Zn(s).isDirectory()&&await er(s)&&r.push(o)}return r}async function md(e){try{let n=(await zg(Ke(e,"SKILL.md"),"utf-8")).match(/^---\n([\s\S]*?)\n---/);if(!n)return null;let r=n[1],o=r.match(/^name:\s*(.+)$/m),s=r.match(/^description:\s*(.+)$/m);return{name:o?.[1]?.trim()??"",description:s?.[1]?.trim()??""}}catch{return null}}async function yd(e){let[t,n]=await Promise.all([Yg(),Qg(e)]),r=new Set,o=[];for(let l of[...n,...t])r.has(l)||(r.add(l),o.push(l));let s=Qn(),i=La(e),a=[];for(let l of o){let c=Ke(i,l),u=null;if($t(c)&&(u=await md(c)),!u){let d=Ke(s,l);$t(d)&&(u=await md(d))}a.push(u??{name:l,description:""})}return a}import{readFile as f_}from"fs/promises";import{join as xg}from"path";p();p();import{render as ey}from"ink";function Br(e){let{waitUntilExit:t,clear:n,unmount:r}=ey(e,{exitOnCtrlC:!1});return{waitUntilExit:t(),clear:n,unmount:r}}p();import{Text as kR}from"ink";import TR from"ink-spinner";import{jsx as RR,jsxs as vR}from"react/jsx-runtime";p();import{Box as IR,Text as PR}from"ink";import{jsxs as OR}from"react/jsx-runtime";p();import{Box as MR,Text as BR}from"ink";import{useEffect as GR,useState as jR}from"react";import{jsx as HR}from"react/jsx-runtime";var Fr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Oa=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557"," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D"," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557 "," \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D"];p();import{Box as V,Text as G,useInput as iC,Static as aC}from"ink";import{useEffect as xe,useState as q,useCallback as ct,useMemo as Ih,useRef as le}from"react";p();import{useState as ty,useCallback as ny,useEffect as ry,useRef as xd}from"react";var oy=1500;function Tn(e){let[t,n]=ty(!1),r=xd(null),o=xd(e);o.current=e,ry(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=ny(()=>{if(t){o.current();return}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},oy)},[t]);return{doubleCtrlC:t,handleCtrlC:s}}import lC from"ink-spinner";p();import{Box as Tt,Text as Ot}from"ink";import{useEffect as Dy,useRef as Id,useState as Pd}from"react";p();import{mkdir as sy,readFile as iy,writeFile as ay}from"fs/promises";import{join as Da}from"path";var Me=class e{static#e=new Set;static async flushAll(){await Promise.allSettled([...e.#e].map(t=>t.flush()))}#n;#r;#s;#t;#u;#p;#i=[];#d;#o;#a=!1;#m=!1;constructor(t={}){let n=process.env.HOME??process.env.USERPROFILE??"~";this.#n=t.costDir??Da(n,".dskcode","costs"),this.#r=t.budgetLimit??0,this.#s=t.tokenBudgetLimit??0,this.#t=t.onBudgetExceeded,this.#u=bd(),this.#p=new Date().toISOString();let r=Na();this.#d=r,this.#o=wd(r),e.#e.add(this)}record(t,n){let r=kt(t,n),o={timestamp:new Date().toISOString(),model:n,usage:{...t},cost:{...r}};return this.#i.push(o),this.#f(),this.#l(o),this.#a=!0,this.#x(),r}get sessionId(){return this.#u}get records(){return this.#i}get sessionSummary(){let t=0,n=0,r=0,o=0;for(let s of this.#i)t+=s.usage.promptTokens,n+=s.usage.completionTokens,r+=s.usage.cachedPromptTokens??0,o+=s.cost.totalCost;return{sessionId:this.#u,startedAt:this.#p,totalPromptTokens:t,totalCompletionTokens:n,totalCachedTokens:r,totalCost:o,records:[...this.#i]}}get sessionTotalCost(){return this.#i.reduce((t,n)=>t+n.cost.totalCost,0)}get sessionPromptTokens(){return this.#i.reduce((t,n)=>t+n.usage.promptTokens,0)}get sessionCompletionTokens(){return this.#i.reduce((t,n)=>t+n.usage.completionTokens,0)}get sessionCallCount(){return this.#i.length}get todaySummary(){return this.#f(),{...this.#o}}get todayTotalCost(){return this.#f(),this.#o.totalCost}get todayCallCount(){return this.#f(),this.#o.totalCalls}get isBudgetExceeded(){return this.#r>0&&this.todayTotalCost>=this.#r||this.#s>0&&this.#o.totalPromptTokens+this.#o.totalCompletionTokens>=this.#s}get remainingBudget(){return this.#r<=0?1/0:Math.max(0,this.#r-this.todayTotalCost)}async load(){await this.#g();let t=await this.#h(),n=Na();t.daily[n]&&(this.#o=t.daily[n],this.#d=n)}async flush(){if(!(!this.#a||this.#m)){this.#m=!0,this.#a=!1;try{await this.#g(),await this.#c()}catch(t){this.#a=!0,console.error("[CostTracker] flush \u5931\u8D25:",t)}finally{this.#m=!1}}}async queryRange(t,n){let r=await this.#h(),o=n??t,s=[];for(let[i,a]of Object.entries(r.daily))i>=t&&i<=o&&s.push(a);return s.sort((i,a)=>i.date.localeCompare(a.date)),s}resetSession(){this.#u=bd(),this.#p=new Date().toISOString(),this.#i.length=0}async dispose(){e.#e.delete(this),await this.flush()}#f(){let t=Na();t!==this.#d&&(this.#d=t,this.#o=wd(t),this.#a=!0)}#l(t){this.#o.totalPromptTokens+=t.usage.promptTokens,this.#o.totalCompletionTokens+=t.usage.completionTokens,this.#o.totalCachedTokens+=t.usage.cachedPromptTokens??0,this.#o.totalCost+=t.cost.totalCost,this.#o.totalCalls+=1;let n=t.model;this.#o.byModel[n]||(this.#o.byModel[n]={model:t.model,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0});let r=this.#o.byModel[n];r.totalPromptTokens+=t.usage.promptTokens,r.totalCompletionTokens+=t.usage.completionTokens,r.totalCachedTokens+=t.usage.cachedPromptTokens??0,r.totalCost+=t.cost.totalCost,r.totalCalls+=1}#x(){this.isBudgetExceeded&&this.#t?.(this)}async#h(){let t=Da(this.#n,"history.json");try{let n=await iy(t,"utf-8");return JSON.parse(n)}catch{return{version:1,daily:{}}}}async#g(){await sy(this.#n,{recursive:!0})}async#c(){let t=await this.#h();t.daily[this.#d]=this.#o;let n=ly(90),r=Object.keys(t.daily).filter(s=>s<n);for(let s of r)delete t.daily[s];let o=Da(this.#n,"history.json");await ay(o,JSON.stringify(t,null,2),"utf-8")}};function bd(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function Na(){return new Date().toISOString().slice(0,10)}function ly(e){let t=new Date;return t.setDate(t.getDate()-e),t.toISOString().slice(0,10)}function wd(e){return{date:e,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0,byModel:{}}}function Ma(e){return`\xA5${e.toFixed(4)}`}p();import{Box as jr,Text as St}from"ink";p();var cy=new Set(["password","token","apikey","api_key","secret","authorization","auth","credential","credentials","private_key","privatekey"]);function fs(e,t){if(!Sd(t))return`${e}()`;switch(e){case"read_file":return`${e}(path=${rt(t.path)})`;case"write_file":return`${e}(path=${rt(t.path)})`;case"edit_file":return`${e}(path=${rt(t.path)}, old_text=${rt(t.old_text,30)})`;case"multi_edit":{let s=Array.isArray(t.edits)?t.edits.length:0;return`${e}(path=${rt(t.path)}, edits=${s})`}case"delete_range":return`${e}(path=${rt(t.path)})`;case"bash":return`${e}(command=${rt(t.command,60)})`;case"ls":return`${e}(path=${rt(t.path??".")})`;case"glob":return`${e}(pattern=${rt(t.pattern)})`;case"grep":return`${e}(pattern=${rt(t.pattern)}, path=${rt(t.path??".")})`;case"fetch":return`${e}(url=${rt(t.url,60)})`;default:let n=Object.keys(t);if(n.length===0)return`${e}()`;let r=n.slice(0,4).map(s=>`${s}=\u2026`).join(", "),o=n.length>4?`, +${n.length-4}`:"";return`${e}(${r}${o})`}}function Gr(e){return Ba(e,new WeakSet)}function Ba(e,t){if(e==null||typeof e!="object")return e;let n=e;if(t.has(n))return"****";if(t.add(n),Array.isArray(e))return e.map(o=>Ba(o,t));let r={};for(let[o,s]of Object.entries(n))cy.has(o.toLowerCase())?r[o]="****":r[o]=Ba(s,t);return r}function kd(e,t={}){let n=t.valueMaxLen??80,r=t.maskSensitive!==!1,o=t.maxKeys??6;if(!Sd(e))return Fa(e,n);let s=r?Gr(e):e,i=Object.entries(s),l=i.slice(0,o).map(([c,u])=>`${c}: ${Fa(u,n)}`);return i.length>o&&l.push(`+${i.length-o} more`),l.join(`
17
+ `)}function Fa(e,t=80){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"\u2026":e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length<=3?JSON.stringify(e):`[\u2026${e.length} items\u2026]`;if(typeof e=="object"){let n=e,r=Object.keys(n);return r.length<=3?JSON.stringify(n):`{\u2026${r.length} keys\u2026}`}return JSON.stringify(e)}function rt(e,t=40){return e==null?String(e):typeof e!="string"?Fa(e,t):e.length===0?"(\u7A7A)":e.length>t?e.slice(0,t-1)+"\u2026":e}function Sd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}p();function tr(e){if(e===""||e===void 0||e===null)return{ok:!0,args:{},fixed:""};try{return{ok:!0,args:JSON.parse(e),fixed:e}}catch(t){let n=uy(e);try{return{ok:!0,args:JSON.parse(n),fixed:n}}catch{let o=t instanceof Error?t.message:String(t);return dy(o,e)?{ok:!1,reason:"PARTIAL",partial:e,hint:"\u53C2\u6570 JSON \u5C1A\u672A\u6536\u5168\uFF0C\u6D41\u5F0F\u62FC\u63A5\u4E2D\uFF1B\u53EF\u80FD\u662F\u7F51\u7EDC/\u5FC3\u8DF3\u5BFC\u81F4\u534A\u622A"}:{ok:!1,reason:"INVALID_JSON",raw:e,error:o}}}}function uy(e){let t=e.length,n=0;for(let a=e.length-1;a>=0&&e[a]==="\\";a--)n++;n%2===1&&t--;let r=e.slice(0,t),o=[],s=!1,i=!1;for(let a=0;a<r.length;a++){let l=r[a];if(i){i=!1;continue}if(l==="\\"){i=!0;continue}if(l==='"'){s=!s;continue}s||(l==="{"?o.push("}"):l==="["?o.push("]"):(l==="}"||l==="]")&&o.pop())}for(s&&(r+='"');o.length>0;)r+=o.pop();return r}function dy(e,t){return!!(e.includes("Unexpected end of JSON")||e.includes("Unterminated string")||t.length<5)}import{jsx as Ga,jsxs as Xe}from"react/jsx-runtime";function ja({call:e,parsedArgs:t,schemaIssues:n,denial:r}){let o=t??my(e.arguments),s=Gr(o),i=fs(e.name,s),a=kd(s);return Xe(jr,{flexDirection:"column",marginLeft:3,marginTop:1,children:[Xe(jr,{children:[Xe(St,{dimColor:!0,children:["\u{1F4E6} ",e.name]}),Xe(St,{dimColor:!0,children:[" ","\u2500".repeat(Math.max(1,30-e.name.length))]})]}),Xe(jr,{flexDirection:"column",marginLeft:2,children:[Ga(St,{dimColor:!0,children:i}),Ga(St,{dimColor:!0,children:a})]}),n&&n.length>0&&Xe(jr,{flexDirection:"column",marginLeft:2,children:[Xe(St,{color:"yellow",children:["\u26A0 schema \u95EE\u9898\uFF08",n.length,"\uFF09"]}),n.slice(0,3).map((l,c)=>Xe(St,{color:"yellow",children:[" - ",l.message]},c)),n.length>3&&Xe(St,{color:"yellow",children:[" ...\u8FD8\u6709 ",n.length-3," \u6761"]})]}),r&&Ga(py,{denial:r})]})}function py({denial:e}){let t=fy[e.source]??e.source,n=e.source==="hardcoded_blacklist"?"\u{1F6AB}":"\u{1F6D1}";return Xe(jr,{flexDirection:"column",marginLeft:2,marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[Xe(St,{color:"red",bold:!0,children:[n," \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\uFF08",t,"\uFF09"]}),Xe(St,{color:"red",children:[" \u539F\u56E0\uFF1A",e.reason]}),e.hint&&Xe(St,{color:"yellow",children:[" \u63D0\u793A\uFF1A",e.hint]})]})}var fy={hardcoded_blacklist:"\u786C\u7F16\u7801\u5B89\u5168\u89C4\u5219",permission_rule:"\u7528\u6237\u914D\u7F6E\u89C4\u5219",user_prompt:"\u7528\u6237\u624B\u52A8\u62D2\u7EDD"};function my(e){if(!e)return{};let t=tr(e);return t.ok?t.args:{}}p();import{Box as ms,Text as Le}from"ink";p();function Td(e){return e>=4352&&e<=4447||e===9001||e===9002||e>=11904&&e<=42191||e>=43360&&e<=43391||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65040&&e<=65055||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126976&&e<=131071||e>=12288&&e<=12351||e>=131072&&e<=196607?2:e<32||e>=127&&e<160?0:1}function Ur(e){let t=0;for(let n of e){let r=n.codePointAt(0);r!==void 0&&r!==8205&&(r>=65024&&r<=65039||(t+=Td(r)))}return t}function*hy(e){for(let t of e){let n=t.codePointAt(0);n!==void 0&&n!==8205&&(n>=65024&&n<=65039||(yield{ch:t,width:Td(n)}))}}function gy(e,t){if(t<=0)return[e];let n=[];for(let r of e.split(`
18
+ `)){if(r.length===0){n.push("");continue}let o=yy(r,t);for(let s of o)n.push(s)}return n.length===0?[""]:n}function yy(e,t){if(Ur(e)<=t)return[e];let n=[],r="",o=0,s=-1,i=0;for(let{ch:a,width:l}of hy(e)){if(a===" "||a===" "){s=r.length,i=o+l,r+=a,o+=l;continue}if(o+l>t)if(s>0){let c=r.slice(0,s).replace(/[ \t]+$/,"");n.push(c),r=r.slice(s).replace(/^[ \t]+/,"")+a,o=Ur(r),s=-1,i=0}else n.push(r),r=a,o=l;else r+=a,o+=l}return r.length>0&&n.push(r),n}function xy(e,t,n){return e.map((r,o)=>{let s=t[o]??3;return gy(r,s).map(a=>by(a,s,n[o]??"left"))})}function by(e,t,n="left"){let r=Ur(e),o=t-r;if(o<=0)return e;let s=n==="right"?o:n==="center"?Math.floor(o/2):0,i=o-s;return" ".repeat(s)+e+" ".repeat(i)}function Ua(e){let t=e.trim();return!t.startsWith("|")||!t.endsWith("|")?[]:t.slice(1,t.length-1).split("|").map(r=>r.trim())}function wy(e){return Ua(e).map(t=>{let n=t.startsWith(":"),r=t.endsWith(":");return n&&r?"center":r?"right":"left"})}function Cd(e,t={}){let n=t.termWidth??80,r=t.outerMargin??0,o=Math.max(n-r,20),s=e.split(`
19
+ `).filter(D=>D.trim().length>0);if(s.length<2)return{lines:s,colWidths:[],totalWidth:0};let i=-1;for(let D=0;D<s.length;D++){let C=(s[D]??"").trim();if(/^\|[-: |]+\|$/.test(C)&&C.includes("-")){i=D;break}}if(i===-1)return{lines:s,colWidths:[],totalWidth:0};let a=Ua(s.slice(0,i).join("")),l=wy(s[i]??""),c=s.slice(i+1).map(Ua),u=a.length;if(u===0)return{lines:s,colWidths:[],totalWidth:0};let d=[];for(let D=0;D<u;D++){let C=Ur(a[D]??"");for(let J of c){let M=Ur(J[D]??"");M>C&&(C=M)}d.push(Math.max(C,3))}let m=2,h=d.reduce((D,C)=>D+C+m,1),f;if(h<=o)f=d;else{let D=o-1-m*u,C=d.reduce((M,U)=>M+U,0);f=d.map(M=>Math.max(3,Math.floor(M/C*D)));let J=f.reduce((M,U)=>M+U+m,1);for(;J>o&&f.length>0;){let M=f.length-1,U=f[M]??3;if(U<=3)break;f[M]=U-1,J=f.reduce((N,ie)=>N+ie+m,1)}}let g="\u2500",k=(D,C,J)=>D+f.map(M=>g.repeat(M+m)).join(C)+J,b=k("\u250C","\u252C","\u2510"),S=k("\u251C","\u253C","\u2524"),R=k("\u2514","\u2534","\u2518");function v(D){let C=xy(D,f,l),J=Math.max(1,...C.map(U=>U.length)),M=[];for(let U=0;U<J;U++){let N="\u2502";for(let ie=0;ie<u;ie++){let H=(C[ie]??[])[U]??" ".repeat(f[ie]??3);N+=" "+H+" ",ie<u-1&&(N+="\u2502")}N+="\u2502",M.push(N)}return M}let _=v(a),B=c.map(v),j=f.reduce((D,C)=>D+C+m,1);return{lines:[b,..._,S,...B.flat(),R],colWidths:f,totalWidth:j}}function _d(){let e=process.stdout?.columns;return typeof e=="number"&&e>0?e:void 0}import{jsx as we,jsxs as Ha}from"react/jsx-runtime";function ky(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("```",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=e.indexOf("```",r+3);if(o===-1){t.push({text:e.slice(r),type:"plain"});break}let s=e.slice(r+3,o);t.push({text:s,type:"code_block"}),n=o+3}return t}function Wa(e){let t=e.trim();return/^\|.+\|$/.test(t)}function Sy(e){let t=e.trim();return/^\|[-: |]+\|$/.test(t)&&t.includes("-")}function Ty(e){let t=e.split(`
20
+ `),n=[],r="";function o(){r&&(n.push({text:r,type:"plain"}),r="")}for(let s=0;s<t.length;s++){let i=t[s]??"";if(Wa(i)&&s+1<t.length&&Sy(t[s+1]??"")&&s+2<t.length&&Wa(t[s+2]??"")){o();let a=[],l=s;for(;l<t.length&&Wa(t[l]??"");)a.push(t[l]),l++;n.push({text:a.join(`
21
21
  `),type:"table"}),s=l-1}else r?r+=`
22
- `+i:r=i}return o(),n}function xy(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("**",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=e.indexOf("**",r+2);if(o===-1){t.push({text:e.slice(r),type:"plain"});break}t.push({text:e.slice(r+2,o),type:"bold"}),n=o+2}return t}function by(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("`",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=1;for(;r+o<e.length&&e[r+o]==="`";)o++;if(o===1){let s=e.indexOf("`",r+1);if(s===-1){t.push({text:e.slice(r),type:"plain"});break}t.push({text:e.slice(r+1,s),type:"code"}),n=s+1}else t.push({text:e.slice(r,r+o),type:"plain"}),n=r+o}return t}function wy(e){let t=[];for(let n of e){if(n.type==="code_block"||n.type==="table"){t.push(n);continue}let r=by(n.text);for(let o of r)o.type==="code"?t.push(o):n.type==="bold"?t.push({text:o.text,type:"bold"}):t.push(o)}return t}var ky="#22c55e",Sy="#ef4444",Ty="#00cccc";function Cy({code:e}){let t=e.split(`
23
- `),n=t[0]??"",r=n.trim().length>0&&!n.startsWith("+")&&!n.startsWith("-")&&!n.startsWith("@@")&&!n.startsWith(" "),o=r?n:void 0,s=r?t.slice(1):t;return s.length===0?r?be(ds,{marginLeft:2,children:Ga(Le,{color:"#888888",children:["\u250C ",o]})}):null:Ga(ds,{flexDirection:"column",marginLeft:2,marginTop:1,children:[o&&Ga(Le,{color:"#888888",children:["\u250C ",o]}),s.map((i,a)=>i.startsWith("+")?be(Le,{color:ky,children:i},a):i.startsWith("-")?be(Le,{color:Sy,children:i},a):i.startsWith("@@")?be(Le,{color:Ty,children:i},a):be(Le,{children:i},a))]})}function _y({text:e}){let t=wd(),n=bd(e,{termWidth:t});return n.colWidths.length===0?be(Le,{children:e}):be(ds,{flexDirection:"column",marginTop:1,children:n.lines.map((r,o)=>{let s=o===0,i=o===n.lines.length-1,a=!s&&!i&&r.startsWith("\u251C");return be(Le,{color:s||i||a?"#888888":void 0,children:r},o)})})}var vy=/[\u{1F000}-\u{1FFFF}\u{FE00}-\u{FE0F}\u{200D}\u{20E3}\u{2600}-\u{27BF}\u{231A}-\u{23FF}\u{2934}\u{2935}\u{25AA}-\u{25FE}\u{2B50}\u{2B55}\u{00A9}\u{00AE}\u{2122}\u{3030}\u{303D}\u{3297}\u{3299}]/u;function Ry(e){return vy.test(e)}function Ay(e){try{return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(e)].map(r=>({text:r.segment,isEmoji:Ry(r.segment)}))}catch{return[{text:e,isEmoji:!1}]}}function kd(e,t){let n=Ay(e);if(n.length===1&&!n[0].isEmoji)return be(Le,{color:Td,children:e},t);let r=[];for(let o of n){let s=r[r.length-1];s&&s.isEmoji===o.isEmoji?s.text+=o.text:r.push({text:o.text,isEmoji:o.isEmoji})}return be(Le,{children:r.map((o,s)=>o.isEmoji?o.text:be(Le,{color:Td,children:o.text},s))},t)}var Sd="#00BFFF",Td="#A855F7";function Cd({children:e}){let t=hy(e),n=[];for(let c of t)c.type==="code_block"?n.push(c):n.push(...yy(c.text));let r=[];for(let c of n)c.type==="code_block"||c.type==="table"?r.push(c):r.push(...xy(c.text));let o=wy(r);if(!o.some(c=>c.type==="code_block"||c.type==="table"))return o.length===1&&o[0].type==="plain"?be(Le,{wrap:"wrap",children:e}):be(Le,{wrap:"wrap",children:o.map((u,d)=>u.type==="code"?be(Le,{color:Sd,children:u.text},d):u.type==="bold"?kd(u.text,d):u.text)});let i=[],a=[];function l(c){if(a.length===0)return;a.length===1&&a[0].type==="plain"?i.push(be(Le,{wrap:"wrap",children:a[0].text},c)):i.push(be(Le,{wrap:"wrap",children:a.map((d,m)=>d.type==="code"?be(Le,{color:Sd,children:d.text},m):d.type==="bold"?kd(d.text,m):d.text)},c)),a=[]}for(let c of o)c.type==="code_block"?(l(i.length),i.push(be(Cy,{code:c.text},`b${i.length}`))):c.type==="table"?(l(i.length),i.push(be(_y,{text:c.text},`t${i.length}`))):a.push(c);return l(i.length),be(ds,{flexDirection:"column",children:i})}import{Fragment as Ly,jsx as Ct,jsxs as Je}from"react/jsx-runtime";function Iy(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Py({usage:e,cost:t}){let n=e?e.promptTokens+e.completionTokens:0,r=t??0,[o,s]=vd(n),[i,a]=vd(r),l=_d(null),c=_d(null);return Ey(()=>{if(l.current&&l.current.toTokens===n&&l.current.toCost===r)return;if(n<=o&&r<=i){s(n),a(r),l.current={fromTokens:n,fromCost:r,toTokens:n,toCost:r,startMs:Date.now(),durationMs:0};return}let u=n-o,d=r-i,m=Math.min(600,Math.max(220,Math.max(u,0)*1.2+220));return l.current={fromTokens:o,fromCost:i,toTokens:n,toCost:r,startMs:Date.now(),durationMs:m},c.current&&clearInterval(c.current),c.current=setInterval(()=>{let h=l.current;if(!h)return;let f=Date.now()-h.startMs;if(f>=h.durationMs){s(h.toTokens),a(h.toCost),c.current&&(clearInterval(c.current),c.current=null);return}let g=f/h.durationMs,b=1-Math.pow(1-g,3),w=h.fromTokens+(h.toTokens-h.fromTokens)*b,S=h.fromCost+(h.toCost-h.fromCost)*b;s(w),a(S)},33),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[n,r]),Je(Ly,{children:[e&&Je(Ot,{color:"#888888",children:[Math.round(o).toLocaleString()," tokens"]}),t!==void 0&&t>0&&Je(Ot,{color:"#888888",children:[" \xB7 ","\xA5",i.toFixed(4)]})]})}function ps({content:e,toolCalls:t,isStreaming:n=!1,usage:r,elapsed:o,cost:s,model:i,toolResults:a}){return!e&&(!t||t.length===0)&&!n?null:Je(Tt,{flexDirection:"row",marginTop:1,children:[Ct(Tt,{width:1,backgroundColor:"#E040FB",flexShrink:0}),Je(Tt,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Je(Tt,{flexDirection:"row",children:[Ct(Tt,{width:4,flexShrink:0,children:Ct(Ot,{bold:!0,color:"#ff00ff",children:"\u{1F916}"})}),Je(Tt,{flexGrow:1,flexDirection:"column",children:[e&&Ct(Cd,{children:e}),n&&!e&&Ct(Ot,{color:"#888888",children:"..."})]})]}),t&&t.length>0&&Ct(Tt,{flexDirection:"column",children:t.map((l,c)=>Ct(Ma,{call:l,denial:a?.get(l.id??"")?.denial},l.id??c))}),n&&(r||s!==void 0)&&Ct(Tt,{flexDirection:"row",marginTop:1,marginLeft:3,children:Je(Ot,{color:"#666666",dimColor:!0,children:["\u23F3 \u5DF2\u6D88\u8017 ",Ct(Py,{usage:r,cost:s})]})}),!n&&(r||o!==void 0)&&Je(Tt,{flexDirection:"column",marginTop:1,marginLeft:3,children:[Ct(Ot,{color:"#555555",children:"\u2500".repeat(36)}),Je(Tt,{flexDirection:"row",gap:2,children:[s!==void 0&&s>0&&Je(Ot,{color:"yellow",children:["\u{1F4B0} \u672C\u6B21 ",$a(s)]}),o!==void 0&&Je(Ot,{color:"cyan",children:["\u{1F550} ",Iy(o)]}),r&&Je(Ot,{color:"#888888",children:["\u{1F4E6} ",(r.promptTokens+r.completionTokens).toLocaleString()," tokens"]})]})]})]})]})}p();import{Box as ja,Text as Tn}from"ink";import{jsx as Cn,jsxs as fs}from"react/jsx-runtime";function Ua({diff:e}){let{patch:t,additions:n,deletions:r,existedBefore:o,filePath:s}=e;if(!t||t.length===0)return null;let i=t.split(`
24
- `),a=s.replace(/\\/g,"/").split("/").pop()??s;return fs(ja,{flexDirection:"column",marginTop:1,children:[fs(ja,{flexDirection:"row",gap:1,children:[fs(Tn,{bold:!0,color:"#00ffff",children:["\u{1F4DD} ",o?"\u4FEE\u6539":"\u65B0\u5EFA",":"]}),Cn(Tn,{bold:!0,children:a}),fs(Tn,{color:"#555555",children:["(+",n," -",r,")"]})]}),Cn(ja,{flexDirection:"column",marginLeft:2,children:i.filter(l=>!l.startsWith("---")&&!l.startsWith("+++")).map((l,c)=>Cn($y,{line:l},c))})]})}function $y({line:e}){return e.startsWith("---")||e.startsWith("+++")?null:e.startsWith("@@")?Cn(Tn,{color:"#00cccc",children:e}):e.startsWith("+")?Cn(Tn,{color:"#22c55e",children:e}):e.startsWith("-")?Cn(Tn,{color:"#ef4444",children:e}):Cn(Tn,{color:"#6b7280",children:e})}p();import{Box as Wa,Text as Ha}from"ink";import{jsx as ms,jsxs as Rd}from"react/jsx-runtime";var Oy="#00bfff";function Va({skills:e,input:t,selectedIndex:n}){let r=t.match(/(?:^|\s)\/([^/]*)$/);if(!r)return null;let o=r[1].toLowerCase().trim();if(e.length===0)return null;let s=!o&&t.startsWith("/")?e.slice(0,3):e.filter(i=>i.name.toLowerCase().includes(o)).slice(0,3);return o&&s.some(i=>i.name.toLowerCase()===o)||s.length===0?null:Rd(Wa,{flexDirection:"column",marginLeft:4,marginTop:1,children:[ms(Ha,{color:"#808080",dimColor:!0,children:"\u652F\u6301\u7684 Skill\uFF1A"}),s.map((i,a)=>ms(Wa,{children:Rd(Ha,{color:a===n?Oy:"#808080",children:[a===n?" \u203A ":" ",i.name]})},i.name)),ms(Wa,{marginTop:1,children:ms(Ha,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as ln,Text as gr}from"ink";import{useEffect as c0,useState as u0}from"react";p();import{Box as hr,Text as On}from"ink";import{useEffect as o0,useState as s0}from"react";p();p();p();function Dy(e){return tl(e)}function tl(e){return Array.isArray(e)?Ny(e):e instanceof RegExp?e:typeof e=="object"?My(e):e}function Ny(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=tl(e[n]);return t}function My(e){let t={};for(let n in e)t[n]=tl(e[n]);return t}function Nd(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Md(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Md(e.substring(0,e.length-1)):e.substr(~t+1)}var za=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,hs=class{static hasCaptures(e){return e===null?!1:(za.lastIndex=0,za.test(e))}static replaceCaptures(e,t,n){return e.replace(za,(r,o,s,i)=>{let a=n[parseInt(o||s,10)];if(a){let l=t.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Bd(e,t){return e<t?-1:e>t?1:0}function Fd(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let o=0;o<n;o++){let s=Bd(e[o],t[o]);if(s!==0)return s}return 0}return n-r}function Ad(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Gd(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var jd=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},zr=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(Gy(e),t)}static createFromParsedTheme(e,t){return Uy(e,t)}_cachedMatchRoot=new jd(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(o=>By(e.parent,o.parentScopes));return r?new Ud(r.fontStyle,r.foreground,r.background):null}},qa=class gs{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new gs(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new gs(n,t[r]);return n}push(t){return new gs(this,t)}getSegments(){let t=this,n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let n=[],r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function By(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],o=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],o=!0}for(;e&&!Fy(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Fy(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Ud=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function Gy(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let o=0,s=t.length;o<s;o++){let i=t[o];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let d=i.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),a=d.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let d=i.settings.fontStyle.split(" ");for(let m=0,h=d.length;m<h;m++)switch(d[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&Ad(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Ad(i.settings.background)&&(u=i.settings.background);for(let d=0,m=a.length;d<m;d++){let f=a[d].trim().split(" "),g=f[f.length-1],b=null;f.length>1&&(b=f.slice(0,f.length-1),b.reverse()),n[r++]=new jy(g,b,o,l,c,u)}}return n}var jy=class{constructor(e,t,n,r,o,s){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=o,this.background=s}},de=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(de||{});function Uy(e,t){e.sort((l,c)=>{let u=Bd(l.scope,c.scope);return u!==0||(u=Fd(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",o="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(o=l.background)}let s=new Wy(t),i=new Ud(n,s.getId(r),s.getId(o)),a=new Vy(new Xa(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let u=e[l];a.insert(0,u.scope,u.parentScopes,u.fontStyle,s.getId(u.foreground),s.getId(u.background))}return new zr(s,i,a)}var Wy=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Hy=Object.freeze([]),Xa=class Wd{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,o,s){this.scopeDepth=t,this.parentScopes=n||Hy,this.fontStyle=r,this.foreground=o,this.background=s}clone(){return new Wd(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,o=t.length;r<o;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,o){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},Vy=class Ja{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,o=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=t.parentScopes.length||o>=n.parentScopes.length);){let s=n.parentScopes[o].length-t.parentScopes[r].length;if(s!==0)return s;r++,o++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),o,s;if(r===-1?(o=t,s=""):(o=t.substring(0,r),s=t.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(s)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ja._cmpBySpecificity),n}insert(t,n,r,o,s,i){if(n===""){this._doInsertHere(t,r,o,s,i);return}let a=n.indexOf("."),l,c;a===-1?(l=n,c=""):(l=n.substring(0,a),c=n.substring(a+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Ja(this._mainRule.clone(),Xa.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(t+1,c,r,o,s,i)}_doInsertHere(t,n,r,o,s){if(n===null){this._mainRule.acceptOverwrite(t,r,o,s);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let l=this._rulesWithParentScopes[i];if(Fd(l.parentScopes,n)===0){l.acceptOverwrite(t,r,o,s);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Xa(t,n,r,o,s))}},nn=class ot{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=ot.getLanguageId(t),r=ot.getTokenType(t),o=ot.getFontStyle(t),s=ot.getForeground(t),i=ot.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:s,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,o,s,i,a){let l=ot.getLanguageId(t),c=ot.getTokenType(t),u=ot.containsBalancedBrackets(t)?1:0,d=ot.getFontStyle(t),m=ot.getForeground(t),h=ot.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),o!==null&&(u=o?1:0),s!==-1&&(d=s),i!==0&&(m=i),a!==0&&(h=a),(l<<0|c<<8|u<<10|d<<11|m<<15|h<<24)>>>0}};function xs(e,t){let n=[],r=zy(e),o=r.next();for(;o!==null;){let l=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let c=i();if(n.push({matcher:c,priority:l}),o!==",")break;o=r.next()}return n;function s(){if(o==="-"){o=r.next();let l=s();return c=>!!l&&!l(c)}if(o==="("){o=r.next();let l=a();return o===")"&&(o=r.next()),l}if(Ed(o)){let l=[];do l.push(o),o=r.next();while(Ed(o));return c=>t(l,c)}return null}function i(){let l=[],c=s();for(;c;)l.push(c),c=s();return u=>l.every(d=>d(u))}function a(){let l=[],c=i();for(;c&&(l.push(c),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");c=i()}return u=>l.some(d=>d(u))}}function Ed(e){return!!e&&!!e.match(/[\w\.:]+/)}function zy(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Hd(e){typeof e.dispose=="function"&&e.dispose()}var qr=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},qy=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ky=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Xy=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new qr(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ky;for(let n of e)Jy(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof qr){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Jy(e,t,n,r){let o=n.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=n.lookup(t);e instanceof qr?ys({baseGrammar:s,selfGrammar:o},r):Za(e.ruleName,{baseGrammar:s,selfGrammar:o,repository:o.repository},r);let i=n.injections(e.scopeName);if(i)for(let a of i)r.add(new qr(a))}function Za(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];bs([r],t,n)}}function ys(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&bs(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&bs(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function bs(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let o=r.repository?Nd({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&bs(r.patterns,{...t,repository:o},n);let s=r.include;if(!s)continue;let i=Vd(s);switch(i.kind){case 0:ys({...t,selfGrammar:t.baseGrammar},n);break;case 1:ys(t,n);break;case 2:Za(i.ruleName,{...t,repository:o},n);break;case 3:case 4:let a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){let l={baseGrammar:t.baseGrammar,selfGrammar:a,repository:o};i.kind===4?Za(i.ruleName,l,n):ys(l,n)}else i.kind===4?n.add(new qy(i.scopeName,i.ruleName)):n.add(new qr(i.scopeName));break}}}var Zy=class{kind=0},Yy=class{kind=1},Qy=class{constructor(e){this.ruleName=e}kind=2},ex=class{constructor(e){this.scopeName=e}kind=3},tx=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Vd(e){if(e==="$base")return new Zy;if(e==="$self")return new Yy;let t=e.indexOf("#");if(t===-1)return new ex(e);if(t===0)return new Qy(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new tx(n,r)}}var nx=/\\(\d+)/,Id=/\\(\d+)/g;var rx=-1,zd=-2;var Jr=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=hs.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=hs.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Md(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:hs.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:hs.replaceCaptures(this._contentName,e,t)}},ox=class extends Jr{retokenizeCapturedWithRuleId;constructor(e,t,n,r,o){super(e,t,n,r),this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},sx=class extends Jr{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,null),this._match=new Kr(r,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Xr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Pd=class extends Jr{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Xr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ya=class extends Jr{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o,s,i,a,l,c){super(e,t,n,r),this._begin=new Kr(o,this.id),this.beginCaptures=s,this._end=new Kr(i||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Xr;for(let n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},ws=class extends Jr{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,o,s,i,a,l){super(e,t,n,r),this._begin=new Kr(o,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new Kr(i,zd),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Xr;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Xr,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},qd=class De{static createCaptureRule(t,n,r,o,s){return t.registerRule(i=>new ox(n,i,r,o,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new sx(t.$vscodeTextmateLocation,t.id,t.name,t.match,De._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Nd({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Pd(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,De._compilePatterns(s,n,r))}return t.while?new ws(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,De._compileCaptures(t.whileCaptures||t.captures,n,r),De._compilePatterns(t.patterns,n,r)):new Ya(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,De._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,De._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let o=[];if(t){let s=0;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10);a>s&&(s=a)}for(let i=0;i<=s;i++)o[i]=null;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10),l=0;t[i].patterns&&(l=De.getCompiledRuleId(t[i],n,r)),o[a]=De.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,l)}}return o}static _compilePatterns(t,n,r){let o=[];if(t)for(let s=0,i=t.length;s<i;s++){let a=t[s],l=-1;if(a.include){let c=Vd(a.include);switch(c.kind){case 0:case 1:l=De.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=De.getCompiledRuleId(u,n,r));break;case 3:case 4:let d=c.scopeName,m=c.kind===4?c.ruleName:null,h=n.getExternalGrammar(d,r);if(h)if(m){let f=h.repository[m];f&&(l=De.getCompiledRuleId(f,n,h.repository))}else l=De.getCompiledRuleId(h.repository.$self,n,h.repository);break}}else l=De.getCompiledRuleId(a,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Pd||c instanceof Ya||c instanceof ws)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},Kr=class Kd{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){let r=t.length,o=0,s=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){let c=t.charAt(a+1);c==="z"?(s.push(t.substring(o,a)),s.push("$(?!\\n)(?<!\\n)"),o=a+2):(c==="A"||c==="G")&&(i=!0),a++}this.hasAnchor=i,o===0?this.source=t:(s.push(t.substring(o,r)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=nx.test(this.source):this.hasBackReferences=!1}clone(){return new Kd(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(o=>t.substring(o.start,o.end));return Id.lastIndex=0,this.source.replace(Id,(o,s)=>Gd(r[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],o=[],s,i,a,l;for(s=0,i=this.source.length;s<i;s++)a=this.source.charAt(s),t[s]=a,n[s]=a,r[s]=a,o[s]=a,a==="\\"&&s+1<i&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",n[s+1]="\uFFFF",r[s+1]="A",o[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",n[s+1]="G",r[s+1]="\uFFFF",o[s+1]="G"):(t[s+1]=l,n[s+1]=l,r[s+1]=l,o[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Xr=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Ld(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(o=>o.resolveAnchors(t,n));return new Ld(e,r,this._items.map(o=>o.ruleId))}},Ld=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
25
- `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Ka=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ix=class Qa{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Ka(t,8),this._embeddedLanguagesMatcher=new ax(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Qa._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Ka(0,0);_getBasicScopeAttributes=new jd(t=>{let n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Ka(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let n=t.match(Qa.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},ax=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([n,r])=>Gd(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},mR={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Xd=!1,$d=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Jd(e,t,n,r,o,s,i,a){let l=t.content.length,c=!1,u=-1;if(i){let h=lx(e,t,n,r,o,s);o=h.stack,r=h.linePos,n=h.isFirstLine,u=h.anchorPosition}let d=Date.now();for(;!c;){if(a!==0&&Date.now()-d>a)return new $d(o,!0);m()}return new $d(o,!1);function m(){let h=cx(e,t,n,r,o,u);if(!h){s.produce(o,l),c=!0;return}let f=h.captureIndices,g=h.matchedRuleId,b=f&&f.length>0?f[0].end>r:!1;if(g===rx){let w=o.getRule(e);s.produce(o,f[0].start),o=o.withContentNameScopesList(o.nameScopesList),Hr(e,t,n,o,s,w.endCaptures,f),s.produce(o,f[0].end);let S=o;if(o=o.parent,u=S.getAnchorPos(),!b&&S.getEnterPos()===r){o=S,s.produce(o,l),c=!0;return}}else{let w=e.getRule(g);s.produce(o,f[0].start);let S=o,v=w.getName(t.content,f),_=o.contentNameScopesList.pushAttributed(v,e);if(o=o.push(g,r,u,f[0].end===l,null,_,_),w instanceof Ya){let E=w;Hr(e,t,n,o,s,E.beginCaptures,f),s.produce(o,f[0].end),u=f[0].end;let M=E.getContentName(t.content,f),U=_.pushAttributed(M,e);if(o=o.withContentNameScopesList(U),E.endHasBackReferences&&(o=o.withEndRule(E.getEndWithResolvedBackReferences(t.content,f))),!b&&S.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(w instanceof ws){let E=w;Hr(e,t,n,o,s,E.beginCaptures,f),s.produce(o,f[0].end),u=f[0].end;let M=E.getContentName(t.content,f),U=_.pushAttributed(M,e);if(o=o.withContentNameScopesList(U),E.whileHasBackReferences&&(o=o.withEndRule(E.getWhileWithResolvedBackReferences(t.content,f))),!b&&S.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(Hr(e,t,n,o,s,w.captures,f),s.produce(o,f[0].end),o=o.pop(),!b){o=o.safePop(),s.produce(o,l),c=!0;return}}f[0].end>r&&(r=f[0].end,n=!1)}}function lx(e,t,n,r,o,s){let i=o.beginRuleCapturedEOL?0:-1,a=[];for(let l=o;l;l=l.pop()){let c=l.getRule(e);c instanceof ws&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){let{ruleScanner:c,findOptions:u}=px(l.rule,e,l.stack.endRule,n,r===i),d=c.findNextMatchSync(t,r,u);if(d){if(d.ruleId!==zd){o=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),Hr(e,t,n,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),i=d.captureIndices[0].end,d.captureIndices[0].end>r&&(r=d.captureIndices[0].end,n=!1))}else{o=l.stack.pop();break}}return{stack:o,linePos:r,anchorPosition:i,isFirstLine:n}}function cx(e,t,n,r,o,s){let i=ux(e,t,n,r,o,s),a=e.getInjections();if(a.length===0)return i;let l=dx(a,e,t,n,r,o,s);if(!l)return i;if(!i)return l;let c=i.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:i}function ux(e,t,n,r,o,s){let i=o.getRule(e),{ruleScanner:a,findOptions:l}=Zd(i,e,o.endRule,n,r===s),c=a.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function dx(e,t,n,r,o,s,i){let a=Number.MAX_VALUE,l=null,c,u=0,d=s.contentNameScopesList.getScopeNames();for(let m=0,h=e.length;m<h;m++){let f=e[m];if(!f.matcher(d))continue;let g=t.getRule(f.ruleId),{ruleScanner:b,findOptions:w}=Zd(g,t,null,r,o===i),S=b.findNextMatchSync(n,o,w);if(!S)continue;let v=S.captureIndices[0].start;if(!(v>=a)&&(a=v,l=S.captureIndices,c=S.ruleId,u=f.priority,a===o))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function Zd(e,t,n,r,o){if(Xd){let i=e.compile(t,n),a=Yd(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileAG(t,n,r,o),findOptions:0}}function px(e,t,n,r,o){if(Xd){let i=e.compileWhile(t,n),a=Yd(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileWhileAG(t,n,r,o),findOptions:0}}function Yd(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function Hr(e,t,n,r,o,s,i){if(s.length===0)return;let a=t.content,l=Math.min(s.length,i.length),c=[],u=i[0].end;for(let d=0;d<l;d++){let m=s[d];if(m===null)continue;let h=i[d];if(h.length===0)continue;if(h.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=h.start;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?o.produceFromScopes(c[c.length-1].scopes,h.start):o.produce(r,h.start),m.retokenizeCapturedWithRuleId){let g=m.getName(a,i),b=r.contentNameScopesList.pushAttributed(g,e),w=m.getContentName(a,i),S=b.pushAttributed(w,e),v=r.push(m.retokenizeCapturedWithRuleId,h.start,-1,!1,null,b,S),_=e.createOnigString(a.substring(0,h.end));Jd(e,_,n&&h.start===0,h.start,v,o,!1,0),Hd(_);continue}let f=m.getName(a,i);if(f!==null){let b=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);c.push(new fx(b,h.end))}}for(;c.length>0;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var fx=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function mx(e,t,n,r,o,s,i,a){return new gx(e,t,n,r,o,s,i,a)}function Od(e,t,n,r,o){let s=xs(t,ks),i=qd.getCompiledRuleId(n,r,o.repository);for(let a of s)e.push({debugSelector:t,matcher:a.matcher,ruleId:i,grammar:o,priority:a.priority})}function ks(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let o=n;o<t.length;o++)if(hx(t[o],r))return n=o+1,!0;return!1})}function hx(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var gx=class{constructor(e,t,n,r,o,s,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new ix(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Dd(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(let l of Object.keys(o)){let c=xs(l,ks);for(let u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:o[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:o=>o===this._rootScopeName?this._grammar:this.getExternalGrammar(o),injections:o=>this._grammarRepository.injections(o)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let o=r.injections;if(o)for(let i in o)Od(t,i,o[i],this,r);let s=this._grammarRepository.injections(n);s&&s.forEach(i=>{let a=this.getExternalGrammar(i);if(a){let l=a.injectionSelector;l&&Od(t,l,a,this,a)}})}return t.sort((o,s)=>o.priority-s.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Dd(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=qd.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===el.NULL){o=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),d=nn.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),m=this.getRule(this._rootId).getName(null,null),h;m?h=Vr.createRootAndLookUpScopeName(m,d,this):h=Vr.createRoot("unknown",d),t=new el(null,this._rootId,-1,-1,!1,null,h,h)}else o=!1,t.reset();e=e+`
26
- `;let s=this.createOnigString(e),i=s.content.length,a=new xx(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Jd(this,s,o,0,t,a,!0,r);return Hd(s),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Dd(e,t){return e=Dy(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Vr=class _t{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,o=t?.scopePath??null;for(let s of n)o=qa.push(o,s.scopeNames),r=new _t(r,o,s.encodedTokenAttributes);return r}static createRoot(t,n){return new _t(null,new qa(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let o=r.getMetadataForScope(t),s=new qa(null,t),i=r.themeProvider.themeMatch(s),a=_t.mergeAttributes(n,o,i);return new _t(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return _t.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let o=-1,s=0,i=0;return r!==null&&(o=r.fontStyle,s=r.foregroundId,i=r.backgroundId),nn.set(t,n.languageId,n.tokenType,null,o,s,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return _t._pushAttributed(this,t,n);let r=t.split(/ /g),o=this;for(let s of r)o=_t._pushAttributed(o,s,n);return o}static _pushAttributed(t,n,r){let o=r.getMetadataForScope(n),s=t.scopePath.push(n),i=r.themeProvider.themeMatch(s),a=_t.mergeAttributes(t.tokenAttributes,o,i);return new _t(t,s,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let n=[],r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},el=class _n{constructor(t,n,r,o,s,i,a,l){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}_stackElementBrand=void 0;static NULL=new _n(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:_n._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Vr.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){_n._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,s,i,a){return new _n(this,t,n,r,o,s,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new _n(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=Vr.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new _n(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Vr.fromExtension(r,n.contentNameScopesList))}},yx=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):xs(n,ks).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>xs(n,ks).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},xx=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let i of this._tokenTypeOverrides)i.matcher(s)&&(r=nn.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(s))}if(o&&(r=nn.set(r,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let r=0,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},bx=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,o){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,mx(e,s,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},Qd=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new bx(zr.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(zr.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new yx(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,o){let s=new Xy(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(i=>this._loadSingleGrammar(i.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,n,r,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,o=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,o)}},Ss=el.NULL;p();var ol=Eg(ip(),1),sr=ol.default,{Ansis:ZR,fg:YR,bg:QR,rgb:eA,bgRgb:tA,hex:nA,bgHex:rA,reset:oA,inverse:sA,hidden:iA,visible:aA,link:lA,bold:cA,dim:uA,italic:dA,underline:pA,strikethrough:fA,black:mA,red:hA,green:gA,yellow:yA,blue:xA,magenta:bA,cyan:wA,white:kA,gray:SA,redBright:TA,greenBright:CA,yellowBright:_A,blueBright:vA,magentaBright:RA,cyanBright:AA,whiteBright:EA,bgBlack:IA,bgRed:PA,bgGreen:LA,bgYellow:$A,bgBlue:OA,bgMagenta:DA,bgCyan:NA,bgWhite:MA,bgGray:BA,bgRedBright:FA,bgGreenBright:GA,bgYellowBright:jA,bgBlueBright:UA,bgMagentaBright:WA,bgCyanBright:HA,bgWhiteBright:VA}=ol.default;p();p();var sl=Object.defineProperty,_x=Object.getOwnPropertyDescriptor,vx=Object.getOwnPropertyNames,Rx=Object.prototype.hasOwnProperty,ir=(e,t)=>{let n={};for(var r in e)sl(n,r,{get:e[r],enumerable:!0});return t||sl(n,Symbol.toStringTag,{value:"Module"}),n},ap=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=vx(t),s=0,i=o.length,a;s<i;s++)a=o[s],!Rx.call(e,a)&&a!==n&&sl(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=_x(t,a))||r.enumerable});return e},Cs=(e,t,n)=>(ap(e,t,"default"),n&&ap(n,t,"default"));p();var ar=[{id:"abap",name:"ABAP",import:(()=>import("./abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("./actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("./ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("./angular-html-FD45HTTF.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("./angular-ts-UGSD62EB.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("./apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("./apex-27CRTE2E.js"))},{id:"apl",name:"APL",import:(()=>import("./apl-DZEE5XRN.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("./applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("./ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("./asciidoc-6DTTKQ3A.js"))},{id:"asm",name:"Assembly",import:(()=>import("./asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("./astro-AZ66H24C.js"))},{id:"awk",name:"AWK",import:(()=>import("./awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("./ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("./bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("./beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("./berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("./bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("./bicep-EOACOM4G.js"))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>import("./bird2-ZG3DO533.js"))},{id:"blade",name:"Blade",import:(()=>import("./blade-6Y7SALML.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("./bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("./c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("./c3-4Z2YI6YO.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("./cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("./cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("./clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("./clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("./cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("./cobol-KCXH3T3Q.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("./codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("./codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("./coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("./common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("./coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("./cpp-B4ITA36J.js"))},{id:"crystal",name:"Crystal",import:(()=>import("./crystal-DVILAEWU.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("./csharp-VNJLKKRO.js"))},{id:"css",name:"CSS",import:(()=>import("./css-NLVM2B53.js"))},{id:"csv",name:"CSV",import:(()=>import("./csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("./cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("./cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("./d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("./dart-KG257MMB.js"))},{id:"dax",name:"DAX",import:(()=>import("./dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("./desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("./diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("./docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("./dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("./dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("./edge-75EAMBUG.js"))},{id:"elixir",name:"Elixir",import:(()=>import("./elixir-NWFINHZW.js"))},{id:"elm",name:"Elm",import:(()=>import("./elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("./emacs-lisp-NRIAYFLD.js"))},{id:"erb",name:"ERB",import:(()=>import("./erb-L6I32JVH.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("./erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("./fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("./fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("./fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("./fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("./fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("./fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("./gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("./gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("./gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("./genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("./gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("./git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("./git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("./gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("./glimmer-js-EJYO25PG.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("./glimmer-ts-Q2ZC2IIP.js"))},{id:"glsl",name:"GLSL",import:(()=>import("./glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("./gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("./gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("./go-WER5FUYJ.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("./graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("./groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("./hack-FLOLYEQ5.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("./haml-SCHIB33Y.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("./handlebars-BNURLECZ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("./haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("./haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("./hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("./hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("./hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("./html-DXDULU5G.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("./html-derivative-QD4CE6YQ.js"))},{id:"http",name:"HTTP",import:(()=>import("./http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("./hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("./hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("./hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("./imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("./ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("./java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("./javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("./jinja-DC3WU6ZJ.js"))},{id:"jison",name:"Jison",import:(()=>import("./jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("./json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("./json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("./jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("./jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("./jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("./jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("./jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("./julia-CHGX5VFI.js"))},{id:"just",name:"Just",import:(()=>import("./just-XO4JBQP4.js"))},{id:"kdl",name:"KDL",import:(()=>import("./kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("./kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("./kusto-55BKOIH6.js"))},{id:"latex",name:"LaTeX",import:(()=>import("./latex-7PE6CJI5.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("./lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("./less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("./liquid-OUYRJBEI.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("./llvm-F6576PPM.js"))},{id:"log",name:"Log file",import:(()=>import("./log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("./logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("./lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("./luau-7VRLQHZS.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("./make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("./markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("./marko-TQJFHH5J.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("./matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("./mdc-BVI2JKDR.js"))},{id:"mdx",name:"MDX",import:(()=>import("./mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("./mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("./mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("./mojo-NUFJUGRT.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("./moonbit-IQKVCQX6.js"))},{id:"move",name:"Move",import:(()=>import("./move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("./narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("./nextflow-OTA6EZBU.js"))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>import("./nextflow-groovy-434C6PKN.js"))},{id:"nginx",name:"Nginx",import:(()=>import("./nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("./nim-LBV5OEXG.js"))},{id:"nix",name:"Nix",import:(()=>import("./nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("./nushell-WFCCYAUY.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("./objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("./objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("./ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("./odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("./openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("./pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("./perl-N2JOL2L5.js"))},{id:"php",name:"PHP",import:(()=>import("./php-OXA56EZC.js"))},{id:"pkl",name:"Pkl",import:(()=>import("./pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("./plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("./po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("./polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("./postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("./powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("./powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("./prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("./prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("./proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("./pug-CWA4QCVE.js"))},{id:"puppet",name:"Puppet",import:(()=>import("./puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("./purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("./python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("./qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("./qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("./qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("./r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("./racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("./raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("./razor-B3X33ONZ.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("./reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("./regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("./rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("./riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("./ron-G4N7ZKMH.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("./rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("./rst-D5R5URHP.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("./ruby-DWCE4YYU.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("./rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("./sas-T7S4QIRM.js"))},{id:"sass",name:"Sass",import:(()=>import("./sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("./scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("./scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("./scss-RIXXNXKR.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("./sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("./shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("./shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("./shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("./smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("./solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("./soy-4TQM2FCJ.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("./sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("./splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("./sql-52F5XK5C.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("./ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("./stata-6C4TLAPQ.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("./stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("./surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("./svelte-NTV6SKXK.js"))},{id:"swift",name:"Swift",import:(()=>import("./swift-KMR3DOSF.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("./system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("./systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("./talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("./tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("./tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("./templ-U5PIZYER.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("./terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("./tex-MVHXDK4A.js"))},{id:"toml",name:"TOML",import:(()=>import("./toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("./ts-tags-K7BWB4VX.js"))},{id:"tsv",name:"TSV",import:(()=>import("./tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("./tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("./turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("./twig-7UZRHYW3.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("./typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("./typespec-535S7LOL.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("./typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("./v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("./vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("./vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("./verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("./vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("./viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("./vue-CKPBQTY7.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("./vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("./vue-vine-Q32TIQRB.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("./vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("./wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("./wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("./wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("./wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("./wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("./wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("./xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("./xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("./yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("./zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("./zig-6LJUAPBA.js"))}],Zr=Object.fromEntries(ar.map(e=>[e.id,e.import])),Yr=Object.fromEntries(ar.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Qr={...Zr,...Yr};p();var eo=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("./andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("./aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("./ayu-dark-55BH6GCR.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("./ayu-light-IPNR4FEJ.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("./ayu-mirage-MOSAI7A2.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("./catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("./catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("./catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("./catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("./dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("./dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("./dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("./everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("./everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("./github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("./github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("./github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("./github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("./github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("./github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("./github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("./gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("./gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("./gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("./gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("./gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("./gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("./horizon-EAAZ4KVN.js"))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>import("./horizon-bright-CGMA7ELN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("./houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("./kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("./kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("./kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("./laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("./light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("./material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("./material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("./material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("./material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("./material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("./min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("./min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("./monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("./night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("./night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("./nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("./one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("./one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("./plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("./poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("./red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("./rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("./rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("./rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("./slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("./slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("./snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("./solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("./solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("./synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("./tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("./vesper-DY3BCX5Y.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("./vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("./vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("./vitesse-light-RICZI4IG.js"))}],to=Object.fromEntries(eo.map(e=>[e.id,e.import]));p();p();var ul={};Zu(ul,{createOnigurumaEngine:()=>cl,getDefaultWasmLoader:()=>Wx,loadWasm:()=>As,setDefaultWasmLoader:()=>Ux});p();var ll=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Ax(){return 2147483648}function Ex(){return typeof performance<"u"?performance.now():Date.now()}var Ix=(e,t)=>e+(t-e%t)%t;async function Px(e){let t,n,r={};function o(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function s(h,f,g){r.HEAPU8.copyWithin(h,f,f+g)}function i(h){try{return t.grow(h-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function a(h){let f=r.HEAPU8.length;h=h>>>0;let g=Ax();if(h>g)return!1;for(let b=1;b<=4;b*=2){let w=f*(1+.2/b);w=Math.min(w,h+100663296);let S=Math.min(g,Ix(Math.max(h,w),65536));if(i(S))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(h,f,g=1024){let b=f+g,w=f;for(;h[w]&&!(w>=b);)++w;if(w-f>16&&h.buffer&&l)return l.decode(h.subarray(f,w));let S="";for(;f<w;){let v=h[f++];if(!(v&128)){S+=String.fromCharCode(v);continue}let _=h[f++]&63;if((v&224)===192){S+=String.fromCharCode((v&31)<<6|_);continue}let E=h[f++]&63;if((v&240)===224?v=(v&15)<<12|_<<6|E:v=(v&7)<<18|_<<12|E<<6|h[f++]&63,v<65536)S+=String.fromCharCode(v);else{let M=v-65536;S+=String.fromCharCode(55296|M>>10,56320|M&1023)}}return S}function u(h,f){return h?c(r.HEAPU8,h,f):""}let d={emscripten_get_now:Ex,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function m(){let f=await e({env:d,wasi_snapshot_preview1:d});t=f.memory,o(t.buffer),Object.assign(r,f),r.UTF8ToString=u}return await m(),r}var Lx=Object.defineProperty,$x=(e,t,n)=>t in e?Lx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Te=(e,t,n)=>$x(e,typeof t!="symbol"?t+"":t,n),Re=null;function Ox(e){throw new ll(e.UTF8ToString(e.getLastOnigError()))}var vs=class e{constructor(t){Te(this,"utf16Length"),Te(this,"utf8Length"),Te(this,"utf16Value"),Te(this,"utf8Value"),Te(this,"utf16OffsetToUtf8"),Te(this,"utf8OffsetToUtf16");let n=t.length,r=e._utf8ByteLength(t),o=r!==n,s=o?new Uint32Array(n+1):null;o&&(s[n]=r);let i=o?new Uint32Array(r+1):null;o&&(i[r]=n);let a=new Uint8Array(r),l=0;for(let c=0;c<n;c++){let u=t.charCodeAt(c),d=u,m=!1;if(u>=55296&&u<=56319&&c+1<n){let h=t.charCodeAt(c+1);h>=56320&&h<=57343&&(d=(u-55296<<10)+65536|h-56320,m=!0)}o&&(s[c]=l,m&&(s[c+1]=l),d<=127?i[l+0]=c:d<=2047?(i[l+0]=c,i[l+1]=c):d<=65535?(i[l+0]=c,i[l+1]=c,i[l+2]=c):(i[l+0]=c,i[l+1]=c,i[l+2]=c,i[l+3]=c)),d<=127?a[l++]=d:d<=2047?(a[l++]=192|(d&1984)>>>6,a[l++]=128|(d&63)>>>0):d<=65535?(a[l++]=224|(d&61440)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0):(a[l++]=240|(d&1835008)>>>18,a[l++]=128|(d&258048)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0),m&&c++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=a,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=i}static _utf8ByteLength(t){let n=0;for(let r=0,o=t.length;r<o;r++){let s=t.charCodeAt(r),i=s,a=!1;if(s>=55296&&s<=56319&&r+1<o){let l=t.charCodeAt(r+1);l>=56320&&l<=57343&&(i=(s-55296<<10)+65536|l-56320,a=!0)}i<=127?n+=1:i<=2047?n+=2:i<=65535?n+=3:n+=4,a&&r++}return n}createString(t){let n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}},Rs=class vt{constructor(t){if(Te(this,"id",++vt.LAST_ID),Te(this,"_onigBinding"),Te(this,"content"),Te(this,"utf16Length"),Te(this,"utf8Length"),Te(this,"utf16OffsetToUtf8"),Te(this,"utf8OffsetToUtf16"),Te(this,"ptr"),!Re)throw new ll("Must invoke loadWasm first.");this._onigBinding=Re,this.content=t;let n=new vs(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!vt._sharedPtrInUse?(vt._sharedPtr||(vt._sharedPtr=Re.omalloc(1e4)),vt._sharedPtrInUse=!0,Re.HEAPU8.set(n.utf8Value,vt._sharedPtr),this.ptr=vt._sharedPtr):this.ptr=n.createString(Re)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===vt._sharedPtr?vt._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Te(Rs,"LAST_ID",0);Te(Rs,"_sharedPtr",0);Te(Rs,"_sharedPtrInUse",!1);var lp=Rs,al=class{constructor(t){if(Te(this,"_onigBinding"),Te(this,"_ptr"),!Re)throw new ll("Must invoke loadWasm first.");let n=[],r=[];for(let a=0,l=t.length;a<l;a++){let c=new vs(t[a]);n[a]=c.createString(Re),r[a]=c.utf8Length}let o=Re.omalloc(4*t.length);Re.HEAPU32.set(n,o/4);let s=Re.omalloc(4*t.length);Re.HEAPU32.set(r,s/4);let i=Re.createOnigScanner(o,s,t.length);for(let a=0,l=t.length;a<l;a++)Re.ofree(n[a]);Re.ofree(s),Re.ofree(o),i===0&&Ox(Re),this._onigBinding=Re,this._ptr=i}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let o=0;if(typeof r=="number"&&(o=r),typeof t=="string"){t=new lp(t);let s=this._findNextMatchSync(t,n,!1,o);return t.dispose(),s}return this._findNextMatchSync(t,n,!1,o)}_findNextMatchSync(t,n,r,o){let s=this._onigBinding,i=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),o);if(i===0)return null;let a=s.HEAPU32,l=i/4,c=a[l++],u=a[l++],d=[];for(let m=0;m<u;m++){let h=t.convertUtf8OffsetToUtf16(a[l++]),f=t.convertUtf8OffsetToUtf16(a[l++]);d[m]={start:h,end:f,length:f-h}}return{index:c,captureIndices:d}}};function Dx(e){return typeof e.instantiator=="function"}function Nx(e){return typeof e.default=="function"}function Mx(e){return typeof e.data<"u"}function Bx(e){return typeof Response<"u"&&e instanceof Response}function Fx(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var _s;function As(e){if(_s)return _s;async function t(){Re=await Px(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),Dx(r)?r=await r.instantiator(n):Nx(r)?r=await r.default(n):(Mx(r)&&(r=r.data),Bx(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await Gx(r)(n):r=await jx(r)(n):Fx(r)?r=await il(r)(n):r instanceof WebAssembly.Module?r=await il(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await il(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return _s=t(),_s}function il(e){return t=>WebAssembly.instantiate(e,t)}function Gx(e){return t=>WebAssembly.instantiateStreaming(e,t)}function jx(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var cp;function Ux(e){cp=e}function Wx(){return cp}async function cl(e){return e&&await As(e),{createScanner(t){return new al(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new lp(t)}}}var dl=ir({});Cs(dl,ul);p();p();var re=class extends Error{constructor(e){super(e),this.name="ShikiError"}};p();function ro(e,t){let n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[o,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[o]=s:o===r&&Object.assign(n,s);return n}function Dt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function mp(e){return Array.isArray(e)?e:[e]}async function pl(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function oo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function fl(e){return e==="ansi"||oo(e)}function so(e){return e==="none"}function ml(e){return so(e)}var Hx=/(\r?\n)/g;function lr(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(Hx),r=0,o=[];for(let s=0;s<n.length;s+=2){let i=t?n[s]+(n[s+1]||""):n[s];o.push([i,r]),r+=n[s].length,r+=n[s+1]?.length||0}return o}var up={light:"#333333",dark:"#bbbbbb"},dp={light:"#fffffe",dark:"#1e1e1e"},pp="__shiki_resolved";function Es(e){if(e?.[pp])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let a=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?up.light:up.dark),n||(n=t.type==="light"?dp.light:dp.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let o=0,s=new Map;function i(a){if(s.has(a))return s.get(a);o+=1;let l=`#${o.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?i(a):(s.set(a,l),l)}t.settings=t.settings.map(a=>{let l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),c=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!c)return a;let u={...a,settings:{...a.settings}};if(l){let d=i(a.settings.foreground);t.colorReplacements[d]=a.settings.foreground,u.settings.foreground=d}if(c){let d=i(a.settings.background);t.colorReplacements[d]=a.settings.background,u.settings.background=d}return u});for(let a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){let l=i(t.colors[a]);t.colorReplacements[l]=t.colors[a],t.colors[a]=l}return Object.defineProperty(t,pp,{enumerable:!1,writable:!1,value:!0}),t}async function hp(e){return[...new Set((await Promise.all(e.filter(t=>!fl(t)).map(async t=>await pl(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function gp(e){return(await Promise.all(e.map(async t=>ml(t)?null:Es(await pl(t))))).filter(t=>!!t)}function yp(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new re(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Vx=class extends Qd{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Es(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=zr.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=yp(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,t.size)for(let o of t)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,o])=>!o);if(n.length){let r=t.filter(([o,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(o=>!n.includes(o));throw new re(`Missing languages ${n.map(([o])=>`\`${o}\``).join(", ")}, required by ${r.map(([o])=>`\`${o}\``).join(", ")}`)}for(let[r,o]of t)this._resolver.addLanguage(o);for(let[r,o]of t)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let n of t)this._langGraph.set(n,this._langMap.get(n))}},zx=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let o=t.slice(0,r).join(".");n=[...n,...this._injections.get(o)||[]]}return n}},no=0;function hl(e){no+=1,e.warnings!==!1&&no>=10&&no%10===0&&console.warn(`[Shiki] ${no} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new re("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Es),o=new Vx(new zx(e.engine,n),r,n,e.langAlias),s;function i(S){return yp(S,e.langAlias)}function a(S){b();let v=o.getGrammar(typeof S=="string"?S:S.name);if(!v)throw new re(`Language \`${S}\` not found, you may need to load it first`);return v}function l(S){if(S==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};b();let v=o.getTheme(S);if(!v)throw new re(`Theme \`${S}\` not found, you may need to load it first`);return v}function c(S){b();let v=l(S);return s!==S&&(o.setTheme(v),s=S),{theme:v,colorMap:o.getColorMap()}}function u(){return b(),o.getLoadedThemes()}function d(){return b(),o.getLoadedLanguages()}function m(...S){b(),o.loadLanguages(S.flat(1))}async function h(...S){return m(await hp(S))}function f(...S){b();for(let v of S.flat(1))o.loadTheme(v)}async function g(...S){return b(),f(await gp(S))}function b(){if(t)throw new re("Shiki instance has been disposed")}function w(){t||(t=!0,o.dispose(),no-=1)}return{setTheme:c,getTheme:l,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:g,loadThemeSync:f,dispose:w,[Symbol.dispose]:w}}async function gl(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([gp(e.themes||[]),hp(e.langs||[]),e.engine]);return hl({...e,themes:t,langs:n,engine:r})}var xp=new WeakMap;function io(e,t){xp.set(e,t)}function cr(e){return xp.get(e)}var Is=class bp{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new bp(Object.fromEntries(mp(n).map(r=>[r,Ss])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,o]=t;this.lang=r,this._stacks={[o]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return qx(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function qx(e){let t=[],n=new Set;function r(o){if(n.has(o))return;n.add(o);let s=o?.nameScopesList?.scopeName;s&&t.push(s),o.parent&&r(o.parent)}return r(e),t}function Kx(e,t){if(!(e instanceof Is))throw new re("Invalid grammar state");return e.getInternalStack(t)}var Xx=/,/,Jx=/ /;function yl(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(oo(e.resolveLangAlias(n.lang||"text"))||so(r))return lr(t).map(a=>[{content:a[0],offset:a[1]}]);let{theme:o,colorMap:s}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new re(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new re(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return kp(t,i,o,s,n)}function wp(...e){if(e.length===2)return cr(e[1]);let[t,n,r={}]=e,{lang:o="text",theme:s=t.getLoadedThemes()[0]}=r;if(oo(o)||so(s))throw new re("Plain language does not have grammar state");if(o==="ansi")throw new re("ANSI language does not have grammar state");let{theme:i,colorMap:a}=t.setTheme(s),l=t.getLanguage(o);return new Is(xl(n,l,i,a,r).stateStack,l.name,i.name)}function kp(e,t,n,r,o){let s=xl(e,t,n,r,o),i=new Is(s.stateStack,t.name,n.name);return io(s.tokens,i),s.tokens}function xl(e,t,n,r,o){let s=ro(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=o,c=lr(e),u=o.grammarState?Kx(o.grammarState,n.name)??Ss:o.grammarContextCode!=null?xl(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ss,d=[],m=[];for(let h=0,f=c.length;h<f;h++){let[g,b]=c[h];if(g===""){d=[],m.push([]);continue}if(i>0&&g.length>=i){d=[],m.push([{content:g,offset:b,color:"",fontStyle:0}]);continue}let w,S,v;l&&l!=="tokenType"&&(w=t.tokenizeLine(g,u,a),S=w.tokens,v=0);let _=t.tokenizeLine2(g,u,a),E=_.tokens.length/2;for(let M=0;M<E;M++){let U=_.tokens[2*M],T=M+1<E?_.tokens[2*M+2]:g.length;if(U===T)continue;let N=_.tokens[2*M+1],F=Dt(r[nn.getForeground(N)],s),q=nn.getFontStyle(N),$={content:g.substring(U,T),offset:b+U,color:F,fontStyle:q};if(l==="tokenType")$.type=nn.getTokenType(N);else if(l){let oe=[];if(l!=="scopeName")for(let ee of n.settings){let W;switch(typeof ee.scope){case"string":W=ee.scope.split(Xx).map(se=>se.trim());break;case"object":W=ee.scope;break;default:continue}oe.push({settings:ee,selectors:W.map(se=>se.split(Jx))})}$.explanation=[];let le=0;for(;U+le<T;){let ee=S[v],W=g.substring(ee.startIndex,ee.endIndex);le+=W.length,$.explanation.push({content:W,scopes:l==="scopeName"?Zx(ee.scopes):Yx(oe,ee.scopes)}),v+=1}}d.push($)}m.push(d),d=[],u=_.ruleStack}return{tokens:m,stateStack:u}}function Zx(e){return e.map(t=>({scopeName:t}))}function Yx(e,t){let n=[];for(let r=0,o=t.length;r<o;r++){let s=t[r];n[r]={scopeName:s,themeMatches:eb(e,s,t.slice(0,r))}}return n}function fp(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Qx(e,t,n){if(!fp(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)fp(e[r],n[o])&&(r-=1),o-=1;return r===-1}function eb(e,t,n){let r=[];for(let{selectors:o,settings:s}of e)for(let i of o)if(Qx(i,t,n)){r.push(s);break}return r}function Ps(e,t,n,r=yl){let o=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),s=o.map(c=>{let u=r(e,t,{...n,theme:c.theme});return{tokens:u,state:cr(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=tb(...s.map(c=>c.tokens)),a=i[0].map((c,u)=>c.map((d,m)=>{let h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),i.forEach((f,g)=>{let{content:b,explanation:w,offset:S,...v}=f[u][m];h.variants[o[g].color]=v}),h})),l=s[0].state?new Is(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return l&&io(a,l),a}function tb(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let o=e.map(l=>l[r]),s=t.map(()=>[]);t.forEach((l,c)=>l.push(s[c]));let i=o.map(()=>0),a=o.map(l=>l[0]);for(;a.every(l=>l);){let l=Math.min(...a.map(c=>c.content.length));for(let c=0;c<n;c++){let u=a[c];u.content.length===l?(s[c].push(u),i[c]+=1,a[c]=o[c][i[c]]):(s[c].push({...u,content:u.content.slice(0,l)}),a[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return t}p();p();p();var Sp=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];p();p();p();var Nt=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Nt.prototype.normal={};Nt.prototype.property={};Nt.prototype.space=void 0;function bl(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Nt(n,r,t)}p();p();p();function ao(e){return e.toLowerCase()}p();p();var Ae=class{constructor(t,n){this.attribute=n,this.property=t}};Ae.prototype.attribute="";Ae.prototype.booleanish=!1;Ae.prototype.boolean=!1;Ae.prototype.commaOrSpaceSeparated=!1;Ae.prototype.commaSeparated=!1;Ae.prototype.defined=!1;Ae.prototype.mustUseProperty=!1;Ae.prototype.number=!1;Ae.prototype.overloadedBoolean=!1;Ae.prototype.property="";Ae.prototype.spaceSeparated=!1;Ae.prototype.space=void 0;var lo={};Zu(lo,{boolean:()=>X,booleanish:()=>pe,commaOrSpaceSeparated:()=>je,commaSeparated:()=>Mt,number:()=>A,overloadedBoolean:()=>Ls,spaceSeparated:()=>ne});p();var nb=0,X=vn(),pe=vn(),Ls=vn(),A=vn(),ne=vn(),Mt=vn(),je=vn();function vn(){return 2**++nb}var wl=Object.keys(lo),Rn=class extends Ae{constructor(t,n,r,o){let s=-1;if(super(t,n),Tp(this,"space",o),typeof r=="number")for(;++s<wl.length;){let i=wl[s];Tp(this,wl[s],(r&lo[i])===lo[i])}}};Rn.prototype.defined=!0;function Tp(e,t,n){n&&(e[t]=n)}function it(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let s=new Rn(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ao(r)]=r,n[ao(s.attribute)]=r}return new Nt(t,n,e.space)}var kl=it({properties:{ariaActiveDescendant:null,ariaAtomic:pe,ariaAutoComplete:null,ariaBusy:pe,ariaChecked:pe,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:ne,ariaCurrent:null,ariaDescribedBy:ne,ariaDetails:null,ariaDisabled:pe,ariaDropEffect:ne,ariaErrorMessage:null,ariaExpanded:pe,ariaFlowTo:ne,ariaGrabbed:pe,ariaHasPopup:null,ariaHidden:pe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ne,ariaLevel:A,ariaLive:null,ariaModal:pe,ariaMultiLine:pe,ariaMultiSelectable:pe,ariaOrientation:null,ariaOwns:ne,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:pe,ariaReadOnly:pe,ariaRelevant:null,ariaRequired:pe,ariaRoleDescription:ne,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:pe,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});p();p();p();function $s(e,t){return t in e?e[t]:t}function Os(e,t){return $s(e,t.toLowerCase())}var Cp=it({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Mt,acceptCharset:ne,accessKey:ne,action:null,allow:null,allowFullScreen:X,allowPaymentRequest:X,allowUserMedia:X,alpha:X,alt:null,as:null,async:X,autoCapitalize:null,autoComplete:ne,autoFocus:X,autoPlay:X,blocking:ne,capture:null,charSet:null,checked:X,cite:null,className:ne,closedBy:null,colorSpace:null,cols:A,colSpan:A,command:null,commandFor:null,content:null,contentEditable:pe,controls:X,controlsList:ne,coords:A|Mt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:X,defer:X,dir:null,dirName:null,disabled:X,download:Ls,draggable:pe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:X,formTarget:null,headers:ne,height:A,hidden:Ls,high:A,href:null,hrefLang:null,htmlFor:ne,httpEquiv:ne,id:null,imageSizes:null,imageSrcSet:null,inert:X,inputMode:null,integrity:null,is:null,isMap:X,itemId:null,itemProp:ne,itemRef:ne,itemScope:X,itemType:ne,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:X,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:X,muted:X,name:null,nonce:null,noModule:X,noValidate:X,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:X,optimum:A,pattern:null,ping:ne,placeholder:null,playsInline:X,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:X,referrerPolicy:null,rel:ne,required:X,reversed:X,rows:A,rowSpan:A,sandbox:ne,scope:null,scoped:X,seamless:X,selected:X,shadowRootClonable:X,shadowRootCustomElementRegistry:X,shadowRootDelegatesFocus:X,shadowRootMode:null,shadowRootSerializable:X,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:pe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:X,useMap:null,value:pe,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ne,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:X,declare:X,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:X,noHref:X,noShade:X,noWrap:X,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:pe,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:X,disablePictureInPicture:X,disableRemotePlayback:X,exportParts:Mt,part:ne,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:Os});p();var _p=it({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:je,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:ne,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:X,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Mt,g2:Mt,glyphName:Mt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:je,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:A,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ne,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:je,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:je,rev:je,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:je,requiredFeatures:je,requiredFonts:je,requiredFormats:je,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:je,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:je,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:je,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$s});p();var Sl=it({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});p();var Tl=it({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Os});p();var Cl=it({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});p();var rb=/[A-Z]/g,vp=/-[a-z]/g,ob=/^data[-\w.:]+$/i;function _l(e,t){let n=ao(t),r=t,o=Ae;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ob.test(t)){if(t.charAt(4)==="-"){let s=t.slice(5).replace(vp,ib);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{let s=t.slice(4);if(!vp.test(s)){let i=s.replace(rb,sb);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=Rn}return new o(r,t)}function sb(e){return"-"+e.toLowerCase()}function ib(e){return e.charAt(1).toUpperCase()}var Rp=bl([kl,Cp,Sl,Tl,Cl],"html"),Ds=bl([kl,_p,Sl,Tl,Cl],"svg");p();p();var Ap={}.hasOwnProperty;function Ep(e,t){let n=t||{};function r(o,...s){let i=r.invalid,a=r.handlers;if(o&&Ap.call(o,e)){let l=String(o[e]);i=Ap.call(a,l)?a[l]:r.unknown}if(i)return i.call(this,o,...s)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}p();p();p();var ab=/["&'<>`]/g,lb=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,cb=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ub=/[|\\{}()[\]^$+*?.]/g,Ip=new WeakMap;function Pp(e,t){if(e=e.replace(t.subset?db(t.subset):ab,r),t.subset||t.escapeOnly)return e;return e.replace(lb,n).replace(cb,r);function n(o,s,i){return t.format((o.charCodeAt(0)-55296)*1024+o.charCodeAt(1)-56320+65536,i.charCodeAt(s+2),t)}function r(o,s,i){return t.format(o.charCodeAt(0),i.charCodeAt(s+1),t)}}function db(e){let t=Ip.get(e);return t||(t=pb(e),Ip.set(e,t)),t}function pb(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(ub,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}p();p();var fb=/[\dA-Fa-f]/;function Lp(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!fb.test(String.fromCharCode(t))?r:r+";"}p();var mb=/\d/;function $p(e,t,n){let r="&#"+String(e);return n&&t&&!mb.test(String.fromCharCode(t))?r:r+";"}p();p();var Op=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];p();var Ns={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};p();var Dp=["cent","copy","divide","gt","lt","not","para","times"];var Np={}.hasOwnProperty,vl={},Ms;for(Ms in Ns)Np.call(Ns,Ms)&&(vl[Ns[Ms]]=Ms);var hb=/[^\dA-Za-z]/;function Mp(e,t,n,r){let o=String.fromCharCode(e);if(Np.call(vl,o)){let s=vl[o],i="&"+s;return n&&Op.includes(s)&&!Dp.includes(s)&&(!r||t&&t!==61&&hb.test(String.fromCharCode(t)))?i:i+";"}return""}function Bp(e,t,n){let r=Lp(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=Mp(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){let s=$p(e,t,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Bt(e,t){return Pp(e,Object.assign({format:Bp},t))}var gb=/^>|^->|<!--|-->|--!>|<!-$/g,yb=[">"],xb=["<",">"];function Fp(e,t,n,r){return r.settings.bogusComments?"<?"+Bt(e.value,Object.assign({},r.settings.characterReferences,{subset:yb}))+">":"<!--"+e.value.replace(gb,o)+"-->";function o(s){return Bt(s,Object.assign({},r.settings.characterReferences,{subset:xb}))}}p();function Gp(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}p();p();function Rl(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}p();function jp(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}p();function Up(e){return e.join(" ").trim()}p();p();p();var bb=/[ \t\n\f\r]/g;function An(e){return typeof e=="object"?e.type==="text"?Wp(e.value):!1:Wp(e)}function Wp(e){return e.replace(bb,"")===""}p();var he=Hp(1),Al=Hp(-1),wb=[];function Hp(e){return t;function t(n,r,o){let s=n?n.children:wb,i=(r||0)+e,a=s[i];if(!o)for(;a&&An(a);)i+=e,a=s[i];return a}}p();var kb={}.hasOwnProperty;function Bs(e){return t;function t(n,r,o){return kb.call(e,n.tagName)&&e[n.tagName](n,r,o)}}var co=Bs({body:Tb,caption:El,colgroup:El,dd:Rb,dt:vb,head:El,html:Sb,li:_b,optgroup:Ab,option:Eb,p:Cb,rp:Vp,rt:Vp,tbody:Pb,td:zp,tfoot:Lb,th:zp,thead:Ib,tr:$b});function El(e,t,n){let r=he(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&An(r.value.charAt(0)))}function Sb(e,t,n){let r=he(n,t);return!r||r.type!=="comment"}function Tb(e,t,n){let r=he(n,t);return!r||r.type!=="comment"}function Cb(e,t,n){let r=he(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function _b(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="li"}function vb(e,t,n){let r=he(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Rb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Vp(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Ab(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function Eb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Ib(e,t,n){let r=he(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Pb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Lb(e,t,n){return!he(n,t)}function $b(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function zp(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}p();var qp=Bs({body:Nb,colgroup:Mb,head:Db,html:Ob,tbody:Bb});function Ob(e){let t=he(e,-1);return!t||t.type!=="comment"}function Db(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let n=e.children[0];return!n||n.type==="element"}function Nb(e){let t=he(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&An(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Mb(e,t,n){let r=Al(n,t),o=he(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&co(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function Bb(e,t,n){let r=Al(n,t),o=he(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&co(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}var Fs={name:[[`
22
+ `+i:r=i}return o(),n}function Cy(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("**",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=e.indexOf("**",r+2);if(o===-1){t.push({text:e.slice(r),type:"plain"});break}t.push({text:e.slice(r+2,o),type:"bold"}),n=o+2}return t}function _y(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("`",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=1;for(;r+o<e.length&&e[r+o]==="`";)o++;if(o===1){let s=e.indexOf("`",r+1);if(s===-1){t.push({text:e.slice(r),type:"plain"});break}t.push({text:e.slice(r+1,s),type:"code"}),n=s+1}else t.push({text:e.slice(r,r+o),type:"plain"}),n=r+o}return t}function Ry(e){let t=[];for(let n of e){if(n.type==="code_block"||n.type==="table"){t.push(n);continue}let r=_y(n.text);for(let o of r)o.type==="code"?t.push(o):n.type==="bold"?t.push({text:o.text,type:"bold"}):t.push(o)}return t}var vy="#22c55e",Ay="#ef4444",Ey="#00cccc";function Iy({code:e}){let t=e.split(`
23
+ `),n=t[0]??"",r=n.trim().length>0&&!n.startsWith("+")&&!n.startsWith("-")&&!n.startsWith("@@")&&!n.startsWith(" "),o=r?n:void 0,s=r?t.slice(1):t;return s.length===0?r?we(ms,{marginLeft:2,children:Ha(Le,{color:"#888888",children:["\u250C ",o]})}):null:Ha(ms,{flexDirection:"column",marginLeft:2,marginTop:1,children:[o&&Ha(Le,{color:"#888888",children:["\u250C ",o]}),s.map((i,a)=>i.startsWith("+")?we(Le,{color:vy,children:i},a):i.startsWith("-")?we(Le,{color:Ay,children:i},a):i.startsWith("@@")?we(Le,{color:Ey,children:i},a):we(Le,{children:i},a))]})}function Py({text:e}){let t=_d(),n=Cd(e,{termWidth:t});return n.colWidths.length===0?we(Le,{children:e}):we(ms,{flexDirection:"column",marginTop:1,children:n.lines.map((r,o)=>{let s=o===0,i=o===n.lines.length-1,a=!s&&!i&&r.startsWith("\u251C");return we(Le,{color:s||i||a?"#888888":void 0,children:r},o)})})}var Ly=/[\u{1F000}-\u{1FFFF}\u{FE00}-\u{FE0F}\u{200D}\u{20E3}\u{2600}-\u{27BF}\u{231A}-\u{23FF}\u{2934}\u{2935}\u{25AA}-\u{25FE}\u{2B50}\u{2B55}\u{00A9}\u{00AE}\u{2122}\u{3030}\u{303D}\u{3297}\u{3299}]/u;function $y(e){return Ly.test(e)}function Oy(e){try{return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(e)].map(r=>({text:r.segment,isEmoji:$y(r.segment)}))}catch{return[{text:e,isEmoji:!1}]}}function Rd(e,t){let n=Oy(e);if(n.length===1&&!n[0].isEmoji)return we(Le,{color:Ad,children:e},t);let r=[];for(let o of n){let s=r[r.length-1];s&&s.isEmoji===o.isEmoji?s.text+=o.text:r.push({text:o.text,isEmoji:o.isEmoji})}return we(Le,{children:r.map((o,s)=>o.isEmoji?o.text:we(Le,{color:Ad,children:o.text},s))},t)}var vd="#00BFFF",Ad="#A855F7";function Ed({children:e}){let t=ky(e),n=[];for(let c of t)c.type==="code_block"?n.push(c):n.push(...Ty(c.text));let r=[];for(let c of n)c.type==="code_block"||c.type==="table"?r.push(c):r.push(...Cy(c.text));let o=Ry(r);if(!o.some(c=>c.type==="code_block"||c.type==="table"))return o.length===1&&o[0].type==="plain"?we(Le,{wrap:"wrap",children:e}):we(Le,{wrap:"wrap",children:o.map((u,d)=>u.type==="code"?we(Le,{color:vd,children:u.text},d):u.type==="bold"?Rd(u.text,d):u.text)});let i=[],a=[];function l(c){if(a.length===0)return;a.length===1&&a[0].type==="plain"?i.push(we(Le,{wrap:"wrap",children:a[0].text},c)):i.push(we(Le,{wrap:"wrap",children:a.map((d,m)=>d.type==="code"?we(Le,{color:vd,children:d.text},m):d.type==="bold"?Rd(d.text,m):d.text)},c)),a=[]}for(let c of o)c.type==="code_block"?(l(i.length),i.push(we(Iy,{code:c.text},`b${i.length}`))):c.type==="table"?(l(i.length),i.push(we(Py,{text:c.text},`t${i.length}`))):a.push(c);return l(i.length),we(ms,{flexDirection:"column",children:i})}import{Fragment as By,jsx as Ct,jsxs as Je}from"react/jsx-runtime";function Ny(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function My({usage:e,cost:t}){let n=e?e.promptTokens+e.completionTokens:0,r=t??0,[o,s]=Pd(n),[i,a]=Pd(r),l=Id(null),c=Id(null);return Dy(()=>{if(l.current&&l.current.toTokens===n&&l.current.toCost===r)return;if(n<=o&&r<=i){s(n),a(r),l.current={fromTokens:n,fromCost:r,toTokens:n,toCost:r,startMs:Date.now(),durationMs:0};return}let u=n-o,d=r-i,m=Math.min(600,Math.max(220,Math.max(u,0)*1.2+220));return l.current={fromTokens:o,fromCost:i,toTokens:n,toCost:r,startMs:Date.now(),durationMs:m},c.current&&clearInterval(c.current),c.current=setInterval(()=>{let h=l.current;if(!h)return;let f=Date.now()-h.startMs;if(f>=h.durationMs){s(h.toTokens),a(h.toCost),c.current&&(clearInterval(c.current),c.current=null);return}let g=f/h.durationMs,k=1-Math.pow(1-g,3),b=h.fromTokens+(h.toTokens-h.fromTokens)*k,S=h.fromCost+(h.toCost-h.fromCost)*k;s(b),a(S)},33),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[n,r]),Je(By,{children:[e&&Je(Ot,{color:"#888888",children:[Math.round(o).toLocaleString()," tokens"]}),t!==void 0&&t>0&&Je(Ot,{color:"#888888",children:[" \xB7 ","\xA5",i.toFixed(4)]})]})}function hs({content:e,toolCalls:t,isStreaming:n=!1,usage:r,elapsed:o,cost:s,model:i,toolResults:a}){return!e&&(!t||t.length===0)&&!n?null:Je(Tt,{flexDirection:"row",marginTop:1,children:[Ct(Tt,{width:1,backgroundColor:"#E040FB",flexShrink:0}),Je(Tt,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Je(Tt,{flexDirection:"row",children:[Ct(Tt,{width:4,flexShrink:0,children:Ct(Ot,{bold:!0,color:"#ff00ff",children:"\u{1F916}"})}),Je(Tt,{flexGrow:1,flexDirection:"column",children:[e&&Ct(Ed,{children:e}),n&&!e&&Ct(Ot,{color:"#888888",children:"..."})]})]}),t&&t.length>0&&Ct(Tt,{flexDirection:"column",children:t.map((l,c)=>Ct(ja,{call:l,denial:a?.get(l.id??"")?.denial},l.id??c))}),n&&(r||s!==void 0)&&Ct(Tt,{flexDirection:"row",marginTop:1,marginLeft:3,children:Je(Ot,{color:"#666666",dimColor:!0,children:["\u23F3 \u5DF2\u6D88\u8017 ",Ct(My,{usage:r,cost:s})]})}),!n&&(r||o!==void 0)&&Je(Tt,{flexDirection:"column",marginTop:1,marginLeft:3,children:[Ct(Ot,{color:"#555555",children:"\u2500".repeat(36)}),Je(Tt,{flexDirection:"row",gap:2,children:[s!==void 0&&s>0&&Je(Ot,{color:"yellow",children:["\u{1F4B0} \u672C\u6B21 ",Ma(s)]}),o!==void 0&&Je(Ot,{color:"cyan",children:["\u{1F550} ",Ny(o)]}),r&&Je(Ot,{color:"#888888",children:["\u{1F4E6} ",(r.promptTokens+r.completionTokens).toLocaleString()," tokens"]})]})]})]})]})}p();import{Box as oc,Text as bo}from"ink";import{useEffect as m0,useState as h0}from"react";p();p();p();p();function Fy(e){return el(e)}function el(e){return Array.isArray(e)?Gy(e):e instanceof RegExp?e:typeof e=="object"?jy(e):e}function Gy(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=el(e[n]);return t}function jy(e){let t={};for(let n in e)t[n]=el(e[n]);return t}function Gd(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function jd(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?jd(e.substring(0,e.length-1)):e.substr(~t+1)}var Va=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,gs=class{static hasCaptures(e){return e===null?!1:(Va.lastIndex=0,Va.test(e))}static replaceCaptures(e,t,n){return e.replace(Va,(r,o,s,i)=>{let a=n[parseInt(o||s,10)];if(a){let l=t.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Ud(e,t){return e<t?-1:e>t?1:0}function Wd(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let o=0;o<n;o++){let s=Ud(e[o],t[o]);if(s!==0)return s}return 0}return n-r}function Ld(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Hd(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Vd=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Vr=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(Hy(e),t)}static createFromParsedTheme(e,t){return zy(e,t)}_cachedMatchRoot=new Vd(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(o=>Uy(e.parent,o.parentScopes));return r?new zd(r.fontStyle,r.foreground,r.background):null}},za=class ys{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new ys(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new ys(n,t[r]);return n}push(t){return new ys(this,t)}getSegments(){let t=this,n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let n=[],r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function Uy(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],o=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],o=!0}for(;e&&!Wy(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Wy(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var zd=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function Hy(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let o=0,s=t.length;o<s;o++){let i=t[o];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let d=i.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),a=d.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let d=i.settings.fontStyle.split(" ");for(let m=0,h=d.length;m<h;m++)switch(d[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&Ld(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Ld(i.settings.background)&&(u=i.settings.background);for(let d=0,m=a.length;d<m;d++){let f=a[d].trim().split(" "),g=f[f.length-1],k=null;f.length>1&&(k=f.slice(0,f.length-1),k.reverse()),n[r++]=new Vy(g,k,o,l,c,u)}}return n}var Vy=class{constructor(e,t,n,r,o,s){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=o,this.background=s}},de=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(de||{});function zy(e,t){e.sort((l,c)=>{let u=Ud(l.scope,c.scope);return u!==0||(u=Wd(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",o="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(o=l.background)}let s=new qy(t),i=new zd(n,s.getId(r),s.getId(o)),a=new Xy(new Ka(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let u=e[l];a.insert(0,u.scope,u.parentScopes,u.fontStyle,s.getId(u.foreground),s.getId(u.background))}return new Vr(s,i,a)}var qy=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Ky=Object.freeze([]),Ka=class qd{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,o,s){this.scopeDepth=t,this.parentScopes=n||Ky,this.fontStyle=r,this.foreground=o,this.background=s}clone(){return new qd(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,o=t.length;r<o;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,o){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},Xy=class Xa{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,o=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=t.parentScopes.length||o>=n.parentScopes.length);){let s=n.parentScopes[o].length-t.parentScopes[r].length;if(s!==0)return s;r++,o++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),o,s;if(r===-1?(o=t,s=""):(o=t.substring(0,r),s=t.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(s)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Xa._cmpBySpecificity),n}insert(t,n,r,o,s,i){if(n===""){this._doInsertHere(t,r,o,s,i);return}let a=n.indexOf("."),l,c;a===-1?(l=n,c=""):(l=n.substring(0,a),c=n.substring(a+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Xa(this._mainRule.clone(),Ka.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(t+1,c,r,o,s,i)}_doInsertHere(t,n,r,o,s){if(n===null){this._mainRule.acceptOverwrite(t,r,o,s);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let l=this._rulesWithParentScopes[i];if(Wd(l.parentScopes,n)===0){l.acceptOverwrite(t,r,o,s);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Ka(t,n,r,o,s))}},nn=class ot{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=ot.getLanguageId(t),r=ot.getTokenType(t),o=ot.getFontStyle(t),s=ot.getForeground(t),i=ot.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:s,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,o,s,i,a){let l=ot.getLanguageId(t),c=ot.getTokenType(t),u=ot.containsBalancedBrackets(t)?1:0,d=ot.getFontStyle(t),m=ot.getForeground(t),h=ot.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),o!==null&&(u=o?1:0),s!==-1&&(d=s),i!==0&&(m=i),a!==0&&(h=a),(l<<0|c<<8|u<<10|d<<11|m<<15|h<<24)>>>0}};function bs(e,t){let n=[],r=Jy(e),o=r.next();for(;o!==null;){let l=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let c=i();if(n.push({matcher:c,priority:l}),o!==",")break;o=r.next()}return n;function s(){if(o==="-"){o=r.next();let l=s();return c=>!!l&&!l(c)}if(o==="("){o=r.next();let l=a();return o===")"&&(o=r.next()),l}if($d(o)){let l=[];do l.push(o),o=r.next();while($d(o));return c=>t(l,c)}return null}function i(){let l=[],c=s();for(;c;)l.push(c),c=s();return u=>l.every(d=>d(u))}function a(){let l=[],c=i();for(;c&&(l.push(c),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");c=i()}return u=>l.some(d=>d(u))}}function $d(e){return!!e&&!!e.match(/[\w\.:]+/)}function Jy(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Kd(e){typeof e.dispose=="function"&&e.dispose()}var zr=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Zy=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Yy=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Qy=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new zr(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Yy;for(let n of e)ex(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof zr){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function ex(e,t,n,r){let o=n.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=n.lookup(t);e instanceof zr?xs({baseGrammar:s,selfGrammar:o},r):Ja(e.ruleName,{baseGrammar:s,selfGrammar:o,repository:o.repository},r);let i=n.injections(e.scopeName);if(i)for(let a of i)r.add(new zr(a))}function Ja(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];ws([r],t,n)}}function xs(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ws(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ws(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ws(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let o=r.repository?Gd({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&ws(r.patterns,{...t,repository:o},n);let s=r.include;if(!s)continue;let i=Xd(s);switch(i.kind){case 0:xs({...t,selfGrammar:t.baseGrammar},n);break;case 1:xs(t,n);break;case 2:Ja(i.ruleName,{...t,repository:o},n);break;case 3:case 4:let a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){let l={baseGrammar:t.baseGrammar,selfGrammar:a,repository:o};i.kind===4?Ja(i.ruleName,l,n):xs(l,n)}else i.kind===4?n.add(new Zy(i.scopeName,i.ruleName)):n.add(new zr(i.scopeName));break}}}var tx=class{kind=0},nx=class{kind=1},rx=class{constructor(e){this.ruleName=e}kind=2},ox=class{constructor(e){this.scopeName=e}kind=3},sx=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Xd(e){if(e==="$base")return new tx;if(e==="$self")return new nx;let t=e.indexOf("#");if(t===-1)return new ox(e);if(t===0)return new rx(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new sx(n,r)}}var ix=/\\(\d+)/,Od=/\\(\d+)/g;var ax=-1,Jd=-2;var Xr=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=gs.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=gs.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${jd(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:gs.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:gs.replaceCaptures(this._contentName,e,t)}},lx=class extends Xr{retokenizeCapturedWithRuleId;constructor(e,t,n,r,o){super(e,t,n,r),this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},cx=class extends Xr{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,null),this._match=new qr(r,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Kr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Dd=class extends Xr{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Kr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Za=class extends Xr{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o,s,i,a,l,c){super(e,t,n,r),this._begin=new qr(o,this.id),this.beginCaptures=s,this._end=new qr(i||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kr;for(let n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},ks=class extends Xr{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,o,s,i,a,l){super(e,t,n,r),this._begin=new qr(o,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new qr(i,Jd),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kr;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Kr,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Zd=class De{static createCaptureRule(t,n,r,o,s){return t.registerRule(i=>new lx(n,i,r,o,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new cx(t.$vscodeTextmateLocation,t.id,t.name,t.match,De._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Gd({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Dd(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,De._compilePatterns(s,n,r))}return t.while?new ks(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,De._compileCaptures(t.whileCaptures||t.captures,n,r),De._compilePatterns(t.patterns,n,r)):new Za(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,De._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,De._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let o=[];if(t){let s=0;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10);a>s&&(s=a)}for(let i=0;i<=s;i++)o[i]=null;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10),l=0;t[i].patterns&&(l=De.getCompiledRuleId(t[i],n,r)),o[a]=De.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,l)}}return o}static _compilePatterns(t,n,r){let o=[];if(t)for(let s=0,i=t.length;s<i;s++){let a=t[s],l=-1;if(a.include){let c=Xd(a.include);switch(c.kind){case 0:case 1:l=De.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=De.getCompiledRuleId(u,n,r));break;case 3:case 4:let d=c.scopeName,m=c.kind===4?c.ruleName:null,h=n.getExternalGrammar(d,r);if(h)if(m){let f=h.repository[m];f&&(l=De.getCompiledRuleId(f,n,h.repository))}else l=De.getCompiledRuleId(h.repository.$self,n,h.repository);break}}else l=De.getCompiledRuleId(a,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Dd||c instanceof Za||c instanceof ks)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},qr=class Yd{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){let r=t.length,o=0,s=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){let c=t.charAt(a+1);c==="z"?(s.push(t.substring(o,a)),s.push("$(?!\\n)(?<!\\n)"),o=a+2):(c==="A"||c==="G")&&(i=!0),a++}this.hasAnchor=i,o===0?this.source=t:(s.push(t.substring(o,r)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=ix.test(this.source):this.hasBackReferences=!1}clone(){return new Yd(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(o=>t.substring(o.start,o.end));return Od.lastIndex=0,this.source.replace(Od,(o,s)=>Hd(r[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],o=[],s,i,a,l;for(s=0,i=this.source.length;s<i;s++)a=this.source.charAt(s),t[s]=a,n[s]=a,r[s]=a,o[s]=a,a==="\\"&&s+1<i&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",n[s+1]="\uFFFF",r[s+1]="A",o[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",n[s+1]="G",r[s+1]="\uFFFF",o[s+1]="G"):(t[s+1]=l,n[s+1]=l,r[s+1]=l,o[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Kr=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Nd(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(o=>o.resolveAnchors(t,n));return new Nd(e,r,this._items.map(o=>o.ruleId))}},Nd=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
24
+ `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},qa=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ux=class Ya{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new qa(t,8),this._embeddedLanguagesMatcher=new dx(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Ya._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new qa(0,0);_getBasicScopeAttributes=new Vd(t=>{let n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new qa(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let n=t.match(Ya.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},dx=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([n,r])=>Hd(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},_v={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Qd=!1,Md=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function ep(e,t,n,r,o,s,i,a){let l=t.content.length,c=!1,u=-1;if(i){let h=px(e,t,n,r,o,s);o=h.stack,r=h.linePos,n=h.isFirstLine,u=h.anchorPosition}let d=Date.now();for(;!c;){if(a!==0&&Date.now()-d>a)return new Md(o,!0);m()}return new Md(o,!1);function m(){let h=fx(e,t,n,r,o,u);if(!h){s.produce(o,l),c=!0;return}let f=h.captureIndices,g=h.matchedRuleId,k=f&&f.length>0?f[0].end>r:!1;if(g===ax){let b=o.getRule(e);s.produce(o,f[0].start),o=o.withContentNameScopesList(o.nameScopesList),Wr(e,t,n,o,s,b.endCaptures,f),s.produce(o,f[0].end);let S=o;if(o=o.parent,u=S.getAnchorPos(),!k&&S.getEnterPos()===r){o=S,s.produce(o,l),c=!0;return}}else{let b=e.getRule(g);s.produce(o,f[0].start);let S=o,R=b.getName(t.content,f),v=o.contentNameScopesList.pushAttributed(R,e);if(o=o.push(g,r,u,f[0].end===l,null,v,v),b instanceof Za){let _=b;Wr(e,t,n,o,s,_.beginCaptures,f),s.produce(o,f[0].end),u=f[0].end;let B=_.getContentName(t.content,f),j=v.pushAttributed(B,e);if(o=o.withContentNameScopesList(j),_.endHasBackReferences&&(o=o.withEndRule(_.getEndWithResolvedBackReferences(t.content,f))),!k&&S.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(b instanceof ks){let _=b;Wr(e,t,n,o,s,_.beginCaptures,f),s.produce(o,f[0].end),u=f[0].end;let B=_.getContentName(t.content,f),j=v.pushAttributed(B,e);if(o=o.withContentNameScopesList(j),_.whileHasBackReferences&&(o=o.withEndRule(_.getWhileWithResolvedBackReferences(t.content,f))),!k&&S.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(Wr(e,t,n,o,s,b.captures,f),s.produce(o,f[0].end),o=o.pop(),!k){o=o.safePop(),s.produce(o,l),c=!0;return}}f[0].end>r&&(r=f[0].end,n=!1)}}function px(e,t,n,r,o,s){let i=o.beginRuleCapturedEOL?0:-1,a=[];for(let l=o;l;l=l.pop()){let c=l.getRule(e);c instanceof ks&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){let{ruleScanner:c,findOptions:u}=gx(l.rule,e,l.stack.endRule,n,r===i),d=c.findNextMatchSync(t,r,u);if(d){if(d.ruleId!==Jd){o=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),Wr(e,t,n,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),i=d.captureIndices[0].end,d.captureIndices[0].end>r&&(r=d.captureIndices[0].end,n=!1))}else{o=l.stack.pop();break}}return{stack:o,linePos:r,anchorPosition:i,isFirstLine:n}}function fx(e,t,n,r,o,s){let i=mx(e,t,n,r,o,s),a=e.getInjections();if(a.length===0)return i;let l=hx(a,e,t,n,r,o,s);if(!l)return i;if(!i)return l;let c=i.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:i}function mx(e,t,n,r,o,s){let i=o.getRule(e),{ruleScanner:a,findOptions:l}=tp(i,e,o.endRule,n,r===s),c=a.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function hx(e,t,n,r,o,s,i){let a=Number.MAX_VALUE,l=null,c,u=0,d=s.contentNameScopesList.getScopeNames();for(let m=0,h=e.length;m<h;m++){let f=e[m];if(!f.matcher(d))continue;let g=t.getRule(f.ruleId),{ruleScanner:k,findOptions:b}=tp(g,t,null,r,o===i),S=k.findNextMatchSync(n,o,b);if(!S)continue;let R=S.captureIndices[0].start;if(!(R>=a)&&(a=R,l=S.captureIndices,c=S.ruleId,u=f.priority,a===o))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function tp(e,t,n,r,o){if(Qd){let i=e.compile(t,n),a=np(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileAG(t,n,r,o),findOptions:0}}function gx(e,t,n,r,o){if(Qd){let i=e.compileWhile(t,n),a=np(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileWhileAG(t,n,r,o),findOptions:0}}function np(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function Wr(e,t,n,r,o,s,i){if(s.length===0)return;let a=t.content,l=Math.min(s.length,i.length),c=[],u=i[0].end;for(let d=0;d<l;d++){let m=s[d];if(m===null)continue;let h=i[d];if(h.length===0)continue;if(h.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=h.start;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?o.produceFromScopes(c[c.length-1].scopes,h.start):o.produce(r,h.start),m.retokenizeCapturedWithRuleId){let g=m.getName(a,i),k=r.contentNameScopesList.pushAttributed(g,e),b=m.getContentName(a,i),S=k.pushAttributed(b,e),R=r.push(m.retokenizeCapturedWithRuleId,h.start,-1,!1,null,k,S),v=e.createOnigString(a.substring(0,h.end));ep(e,v,n&&h.start===0,h.start,R,o,!1,0),Kd(v);continue}let f=m.getName(a,i);if(f!==null){let k=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);c.push(new yx(k,h.end))}}for(;c.length>0;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var yx=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function xx(e,t,n,r,o,s,i,a){return new wx(e,t,n,r,o,s,i,a)}function Bd(e,t,n,r,o){let s=bs(t,Ss),i=Zd.getCompiledRuleId(n,r,o.repository);for(let a of s)e.push({debugSelector:t,matcher:a.matcher,ruleId:i,grammar:o,priority:a.priority})}function Ss(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let o=n;o<t.length;o++)if(bx(t[o],r))return n=o+1,!0;return!1})}function bx(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var wx=class{constructor(e,t,n,r,o,s,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new ux(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Fd(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(let l of Object.keys(o)){let c=bs(l,Ss);for(let u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:o[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:o=>o===this._rootScopeName?this._grammar:this.getExternalGrammar(o),injections:o=>this._grammarRepository.injections(o)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let o=r.injections;if(o)for(let i in o)Bd(t,i,o[i],this,r);let s=this._grammarRepository.injections(n);s&&s.forEach(i=>{let a=this.getExternalGrammar(i);if(a){let l=a.injectionSelector;l&&Bd(t,l,a,this,a)}})}return t.sort((o,s)=>o.priority-s.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Fd(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=Zd.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===Qa.NULL){o=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),d=nn.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),m=this.getRule(this._rootId).getName(null,null),h;m?h=Hr.createRootAndLookUpScopeName(m,d,this):h=Hr.createRoot("unknown",d),t=new Qa(null,this._rootId,-1,-1,!1,null,h,h)}else o=!1,t.reset();e=e+`
25
+ `;let s=this.createOnigString(e),i=s.content.length,a=new Sx(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=ep(this,s,o,0,t,a,!0,r);return Kd(s),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Fd(e,t){return e=Fy(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Hr=class _t{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,o=t?.scopePath??null;for(let s of n)o=za.push(o,s.scopeNames),r=new _t(r,o,s.encodedTokenAttributes);return r}static createRoot(t,n){return new _t(null,new za(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let o=r.getMetadataForScope(t),s=new za(null,t),i=r.themeProvider.themeMatch(s),a=_t.mergeAttributes(n,o,i);return new _t(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return _t.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let o=-1,s=0,i=0;return r!==null&&(o=r.fontStyle,s=r.foregroundId,i=r.backgroundId),nn.set(t,n.languageId,n.tokenType,null,o,s,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return _t._pushAttributed(this,t,n);let r=t.split(/ /g),o=this;for(let s of r)o=_t._pushAttributed(o,s,n);return o}static _pushAttributed(t,n,r){let o=r.getMetadataForScope(n),s=t.scopePath.push(n),i=r.themeProvider.themeMatch(s),a=_t.mergeAttributes(t.tokenAttributes,o,i);return new _t(t,s,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let n=[],r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},Qa=class Cn{constructor(t,n,r,o,s,i,a,l){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}_stackElementBrand=void 0;static NULL=new Cn(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:Cn._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Hr.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){Cn._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,s,i,a){return new Cn(this,t,n,r,o,s,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new Cn(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=Hr.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new Cn(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Hr.fromExtension(r,n.contentNameScopesList))}},kx=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):bs(n,Ss).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>bs(n,Ss).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Sx=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let i of this._tokenTypeOverrides)i.matcher(s)&&(r=nn.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(s))}if(o&&(r=nn.set(r,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let r=0,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},Tx=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,o){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,xx(e,s,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},rp=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Tx(Vr.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Vr.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new kx(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,o){let s=new Qy(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(i=>this._loadSingleGrammar(i.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,n,r,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,o=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,o)}},Ts=Qa.NULL;p();var rl=Dg(up(),1),nr=rl.default,{Ansis:lA,fg:cA,bg:uA,rgb:dA,bgRgb:pA,hex:fA,bgHex:mA,reset:hA,inverse:gA,hidden:yA,visible:xA,link:bA,bold:wA,dim:kA,italic:SA,underline:TA,strikethrough:CA,black:_A,red:RA,green:vA,yellow:AA,blue:EA,magenta:IA,cyan:PA,white:LA,gray:$A,redBright:OA,greenBright:DA,yellowBright:NA,blueBright:MA,magentaBright:BA,cyanBright:FA,whiteBright:GA,bgBlack:jA,bgRed:UA,bgGreen:WA,bgYellow:HA,bgBlue:VA,bgMagenta:zA,bgCyan:qA,bgWhite:KA,bgGray:XA,bgRedBright:JA,bgGreenBright:ZA,bgYellowBright:YA,bgBlueBright:QA,bgMagentaBright:e1,bgCyanBright:t1,bgWhiteBright:n1}=rl.default;p();p();var ol=Object.defineProperty,Ex=Object.getOwnPropertyDescriptor,Ix=Object.getOwnPropertyNames,Px=Object.prototype.hasOwnProperty,rr=(e,t)=>{let n={};for(var r in e)ol(n,r,{get:e[r],enumerable:!0});return t||ol(n,Symbol.toStringTag,{value:"Module"}),n},dp=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=Ix(t),s=0,i=o.length,a;s<i;s++)a=o[s],!Px.call(e,a)&&a!==n&&ol(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=Ex(t,a))||r.enumerable});return e},_s=(e,t,n)=>(dp(e,t,"default"),n&&dp(n,t,"default"));p();var or=[{id:"abap",name:"ABAP",import:(()=>import("./abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("./actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("./ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("./angular-html-FD45HTTF.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("./angular-ts-UGSD62EB.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("./apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("./apex-27CRTE2E.js"))},{id:"apl",name:"APL",import:(()=>import("./apl-DZEE5XRN.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("./applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("./ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("./asciidoc-6DTTKQ3A.js"))},{id:"asm",name:"Assembly",import:(()=>import("./asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("./astro-AZ66H24C.js"))},{id:"awk",name:"AWK",import:(()=>import("./awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("./ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("./bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("./beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("./berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("./bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("./bicep-EOACOM4G.js"))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>import("./bird2-ZG3DO533.js"))},{id:"blade",name:"Blade",import:(()=>import("./blade-6Y7SALML.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("./bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("./c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("./c3-4Z2YI6YO.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("./cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("./cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("./clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("./clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("./cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("./cobol-KCXH3T3Q.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("./codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("./codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("./coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("./common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("./coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("./cpp-B4ITA36J.js"))},{id:"crystal",name:"Crystal",import:(()=>import("./crystal-DVILAEWU.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("./csharp-VNJLKKRO.js"))},{id:"css",name:"CSS",import:(()=>import("./css-NLVM2B53.js"))},{id:"csv",name:"CSV",import:(()=>import("./csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("./cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("./cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("./d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("./dart-KG257MMB.js"))},{id:"dax",name:"DAX",import:(()=>import("./dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("./desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("./diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("./docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("./dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("./dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("./edge-75EAMBUG.js"))},{id:"elixir",name:"Elixir",import:(()=>import("./elixir-NWFINHZW.js"))},{id:"elm",name:"Elm",import:(()=>import("./elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("./emacs-lisp-NRIAYFLD.js"))},{id:"erb",name:"ERB",import:(()=>import("./erb-L6I32JVH.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("./erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("./fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("./fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("./fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("./fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("./fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("./fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("./gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("./gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("./gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("./genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("./gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("./git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("./git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("./gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("./glimmer-js-EJYO25PG.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("./glimmer-ts-Q2ZC2IIP.js"))},{id:"glsl",name:"GLSL",import:(()=>import("./glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("./gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("./gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("./go-WER5FUYJ.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("./graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("./groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("./hack-FLOLYEQ5.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("./haml-SCHIB33Y.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("./handlebars-BNURLECZ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("./haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("./haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("./hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("./hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("./hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("./html-DXDULU5G.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("./html-derivative-QD4CE6YQ.js"))},{id:"http",name:"HTTP",import:(()=>import("./http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("./hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("./hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("./hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("./imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("./ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("./java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("./javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("./jinja-DC3WU6ZJ.js"))},{id:"jison",name:"Jison",import:(()=>import("./jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("./json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("./json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("./jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("./jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("./jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("./jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("./jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("./julia-CHGX5VFI.js"))},{id:"just",name:"Just",import:(()=>import("./just-XO4JBQP4.js"))},{id:"kdl",name:"KDL",import:(()=>import("./kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("./kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("./kusto-55BKOIH6.js"))},{id:"latex",name:"LaTeX",import:(()=>import("./latex-7PE6CJI5.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("./lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("./less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("./liquid-OUYRJBEI.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("./llvm-F6576PPM.js"))},{id:"log",name:"Log file",import:(()=>import("./log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("./logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("./lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("./luau-7VRLQHZS.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("./make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("./markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("./marko-TQJFHH5J.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("./matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("./mdc-BVI2JKDR.js"))},{id:"mdx",name:"MDX",import:(()=>import("./mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("./mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("./mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("./mojo-NUFJUGRT.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("./moonbit-IQKVCQX6.js"))},{id:"move",name:"Move",import:(()=>import("./move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("./narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("./nextflow-OTA6EZBU.js"))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>import("./nextflow-groovy-434C6PKN.js"))},{id:"nginx",name:"Nginx",import:(()=>import("./nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("./nim-LBV5OEXG.js"))},{id:"nix",name:"Nix",import:(()=>import("./nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("./nushell-WFCCYAUY.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("./objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("./objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("./ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("./odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("./openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("./pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("./perl-N2JOL2L5.js"))},{id:"php",name:"PHP",import:(()=>import("./php-OXA56EZC.js"))},{id:"pkl",name:"Pkl",import:(()=>import("./pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("./plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("./po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("./polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("./postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("./powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("./powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("./prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("./prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("./proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("./pug-CWA4QCVE.js"))},{id:"puppet",name:"Puppet",import:(()=>import("./puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("./purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("./python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("./qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("./qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("./qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("./r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("./racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("./raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("./razor-B3X33ONZ.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("./reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("./regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("./rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("./riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("./ron-G4N7ZKMH.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("./rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("./rst-D5R5URHP.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("./ruby-DWCE4YYU.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("./rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("./sas-T7S4QIRM.js"))},{id:"sass",name:"Sass",import:(()=>import("./sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("./scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("./scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("./scss-RIXXNXKR.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("./sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("./shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("./shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("./shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("./smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("./solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("./soy-4TQM2FCJ.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("./sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("./splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("./sql-52F5XK5C.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("./ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("./stata-6C4TLAPQ.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("./stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("./surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("./svelte-NTV6SKXK.js"))},{id:"swift",name:"Swift",import:(()=>import("./swift-KMR3DOSF.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("./system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("./systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("./talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("./tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("./tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("./templ-U5PIZYER.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("./terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("./tex-MVHXDK4A.js"))},{id:"toml",name:"TOML",import:(()=>import("./toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("./ts-tags-K7BWB4VX.js"))},{id:"tsv",name:"TSV",import:(()=>import("./tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("./tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("./turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("./twig-7UZRHYW3.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("./typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("./typespec-535S7LOL.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("./typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("./v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("./vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("./vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("./verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("./vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("./viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("./vue-CKPBQTY7.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("./vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("./vue-vine-Q32TIQRB.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("./vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("./wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("./wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("./wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("./wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("./wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("./wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("./xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("./xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("./yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("./zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("./zig-6LJUAPBA.js"))}],Jr=Object.fromEntries(or.map(e=>[e.id,e.import])),Zr=Object.fromEntries(or.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Yr={...Jr,...Zr};p();var Qr=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("./andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("./aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("./ayu-dark-55BH6GCR.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("./ayu-light-IPNR4FEJ.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("./ayu-mirage-MOSAI7A2.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("./catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("./catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("./catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("./catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("./dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("./dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("./dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("./everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("./everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("./github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("./github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("./github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("./github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("./github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("./github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("./github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("./gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("./gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("./gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("./gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("./gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("./gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("./horizon-EAAZ4KVN.js"))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>import("./horizon-bright-CGMA7ELN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("./houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("./kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("./kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("./kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("./laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("./light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("./material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("./material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("./material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("./material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("./material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("./min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("./min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("./monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("./night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("./night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("./nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("./one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("./one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("./plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("./poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("./red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("./rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("./rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("./rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("./slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("./slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("./snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("./solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("./solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("./synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("./tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("./vesper-DY3BCX5Y.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("./vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("./vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("./vitesse-light-RICZI4IG.js"))}],eo=Object.fromEntries(Qr.map(e=>[e.id,e.import]));p();p();var cl={};nd(cl,{createOnigurumaEngine:()=>ll,getDefaultWasmLoader:()=>qx,loadWasm:()=>Es,setDefaultWasmLoader:()=>zx});p();var al=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Lx(){return 2147483648}function $x(){return typeof performance<"u"?performance.now():Date.now()}var Ox=(e,t)=>e+(t-e%t)%t;async function Dx(e){let t,n,r={};function o(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function s(h,f,g){r.HEAPU8.copyWithin(h,f,f+g)}function i(h){try{return t.grow(h-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function a(h){let f=r.HEAPU8.length;h=h>>>0;let g=Lx();if(h>g)return!1;for(let k=1;k<=4;k*=2){let b=f*(1+.2/k);b=Math.min(b,h+100663296);let S=Math.min(g,Ox(Math.max(h,b),65536));if(i(S))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(h,f,g=1024){let k=f+g,b=f;for(;h[b]&&!(b>=k);)++b;if(b-f>16&&h.buffer&&l)return l.decode(h.subarray(f,b));let S="";for(;f<b;){let R=h[f++];if(!(R&128)){S+=String.fromCharCode(R);continue}let v=h[f++]&63;if((R&224)===192){S+=String.fromCharCode((R&31)<<6|v);continue}let _=h[f++]&63;if((R&240)===224?R=(R&15)<<12|v<<6|_:R=(R&7)<<18|v<<12|_<<6|h[f++]&63,R<65536)S+=String.fromCharCode(R);else{let B=R-65536;S+=String.fromCharCode(55296|B>>10,56320|B&1023)}}return S}function u(h,f){return h?c(r.HEAPU8,h,f):""}let d={emscripten_get_now:$x,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function m(){let f=await e({env:d,wasi_snapshot_preview1:d});t=f.memory,o(t.buffer),Object.assign(r,f),r.UTF8ToString=u}return await m(),r}var Nx=Object.defineProperty,Mx=(e,t,n)=>t in e?Nx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Te=(e,t,n)=>Mx(e,typeof t!="symbol"?t+"":t,n),ve=null;function Bx(e){throw new al(e.UTF8ToString(e.getLastOnigError()))}var vs=class e{constructor(t){Te(this,"utf16Length"),Te(this,"utf8Length"),Te(this,"utf16Value"),Te(this,"utf8Value"),Te(this,"utf16OffsetToUtf8"),Te(this,"utf8OffsetToUtf16");let n=t.length,r=e._utf8ByteLength(t),o=r!==n,s=o?new Uint32Array(n+1):null;o&&(s[n]=r);let i=o?new Uint32Array(r+1):null;o&&(i[r]=n);let a=new Uint8Array(r),l=0;for(let c=0;c<n;c++){let u=t.charCodeAt(c),d=u,m=!1;if(u>=55296&&u<=56319&&c+1<n){let h=t.charCodeAt(c+1);h>=56320&&h<=57343&&(d=(u-55296<<10)+65536|h-56320,m=!0)}o&&(s[c]=l,m&&(s[c+1]=l),d<=127?i[l+0]=c:d<=2047?(i[l+0]=c,i[l+1]=c):d<=65535?(i[l+0]=c,i[l+1]=c,i[l+2]=c):(i[l+0]=c,i[l+1]=c,i[l+2]=c,i[l+3]=c)),d<=127?a[l++]=d:d<=2047?(a[l++]=192|(d&1984)>>>6,a[l++]=128|(d&63)>>>0):d<=65535?(a[l++]=224|(d&61440)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0):(a[l++]=240|(d&1835008)>>>18,a[l++]=128|(d&258048)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0),m&&c++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=a,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=i}static _utf8ByteLength(t){let n=0;for(let r=0,o=t.length;r<o;r++){let s=t.charCodeAt(r),i=s,a=!1;if(s>=55296&&s<=56319&&r+1<o){let l=t.charCodeAt(r+1);l>=56320&&l<=57343&&(i=(s-55296<<10)+65536|l-56320,a=!0)}i<=127?n+=1:i<=2047?n+=2:i<=65535?n+=3:n+=4,a&&r++}return n}createString(t){let n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}},As=class Rt{constructor(t){if(Te(this,"id",++Rt.LAST_ID),Te(this,"_onigBinding"),Te(this,"content"),Te(this,"utf16Length"),Te(this,"utf8Length"),Te(this,"utf16OffsetToUtf8"),Te(this,"utf8OffsetToUtf16"),Te(this,"ptr"),!ve)throw new al("Must invoke loadWasm first.");this._onigBinding=ve,this.content=t;let n=new vs(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Rt._sharedPtrInUse?(Rt._sharedPtr||(Rt._sharedPtr=ve.omalloc(1e4)),Rt._sharedPtrInUse=!0,ve.HEAPU8.set(n.utf8Value,Rt._sharedPtr),this.ptr=Rt._sharedPtr):this.ptr=n.createString(ve)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Rt._sharedPtr?Rt._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Te(As,"LAST_ID",0);Te(As,"_sharedPtr",0);Te(As,"_sharedPtrInUse",!1);var pp=As,il=class{constructor(t){if(Te(this,"_onigBinding"),Te(this,"_ptr"),!ve)throw new al("Must invoke loadWasm first.");let n=[],r=[];for(let a=0,l=t.length;a<l;a++){let c=new vs(t[a]);n[a]=c.createString(ve),r[a]=c.utf8Length}let o=ve.omalloc(4*t.length);ve.HEAPU32.set(n,o/4);let s=ve.omalloc(4*t.length);ve.HEAPU32.set(r,s/4);let i=ve.createOnigScanner(o,s,t.length);for(let a=0,l=t.length;a<l;a++)ve.ofree(n[a]);ve.ofree(s),ve.ofree(o),i===0&&Bx(ve),this._onigBinding=ve,this._ptr=i}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let o=0;if(typeof r=="number"&&(o=r),typeof t=="string"){t=new pp(t);let s=this._findNextMatchSync(t,n,!1,o);return t.dispose(),s}return this._findNextMatchSync(t,n,!1,o)}_findNextMatchSync(t,n,r,o){let s=this._onigBinding,i=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),o);if(i===0)return null;let a=s.HEAPU32,l=i/4,c=a[l++],u=a[l++],d=[];for(let m=0;m<u;m++){let h=t.convertUtf8OffsetToUtf16(a[l++]),f=t.convertUtf8OffsetToUtf16(a[l++]);d[m]={start:h,end:f,length:f-h}}return{index:c,captureIndices:d}}};function Fx(e){return typeof e.instantiator=="function"}function Gx(e){return typeof e.default=="function"}function jx(e){return typeof e.data<"u"}function Ux(e){return typeof Response<"u"&&e instanceof Response}function Wx(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var Rs;function Es(e){if(Rs)return Rs;async function t(){ve=await Dx(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),Fx(r)?r=await r.instantiator(n):Gx(r)?r=await r.default(n):(jx(r)&&(r=r.data),Ux(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await Hx(r)(n):r=await Vx(r)(n):Wx(r)?r=await sl(r)(n):r instanceof WebAssembly.Module?r=await sl(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await sl(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Rs=t(),Rs}function sl(e){return t=>WebAssembly.instantiate(e,t)}function Hx(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Vx(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var fp;function zx(e){fp=e}function qx(){return fp}async function ll(e){return e&&await Es(e),{createScanner(t){return new il(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new pp(t)}}}var ul=rr({});_s(ul,cl);p();p();var oe=class extends Error{constructor(e){super(e),this.name="ShikiError"}};p();function no(e,t){let n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[o,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[o]=s:o===r&&Object.assign(n,s);return n}function Dt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function xp(e){return Array.isArray(e)?e:[e]}async function dl(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function ro(e){return!e||["plaintext","txt","text","plain"].includes(e)}function pl(e){return e==="ansi"||ro(e)}function oo(e){return e==="none"}function fl(e){return oo(e)}var Kx=/(\r?\n)/g;function sr(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(Kx),r=0,o=[];for(let s=0;s<n.length;s+=2){let i=t?n[s]+(n[s+1]||""):n[s];o.push([i,r]),r+=n[s].length,r+=n[s+1]?.length||0}return o}var mp={light:"#333333",dark:"#bbbbbb"},hp={light:"#fffffe",dark:"#1e1e1e"},gp="__shiki_resolved";function Is(e){if(e?.[gp])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let a=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?mp.light:mp.dark),n||(n=t.type==="light"?hp.light:hp.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let o=0,s=new Map;function i(a){if(s.has(a))return s.get(a);o+=1;let l=`#${o.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?i(a):(s.set(a,l),l)}t.settings=t.settings.map(a=>{let l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),c=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!c)return a;let u={...a,settings:{...a.settings}};if(l){let d=i(a.settings.foreground);t.colorReplacements[d]=a.settings.foreground,u.settings.foreground=d}if(c){let d=i(a.settings.background);t.colorReplacements[d]=a.settings.background,u.settings.background=d}return u});for(let a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){let l=i(t.colors[a]);t.colorReplacements[l]=t.colors[a],t.colors[a]=l}return Object.defineProperty(t,gp,{enumerable:!1,writable:!1,value:!0}),t}async function bp(e){return[...new Set((await Promise.all(e.filter(t=>!pl(t)).map(async t=>await dl(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function wp(e){return(await Promise.all(e.map(async t=>fl(t)?null:Is(await dl(t))))).filter(t=>!!t)}function kp(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new oe(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Xx=class extends rp{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Is(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Vr.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=kp(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,t.size)for(let o of t)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,o])=>!o);if(n.length){let r=t.filter(([o,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(o=>!n.includes(o));throw new oe(`Missing languages ${n.map(([o])=>`\`${o}\``).join(", ")}, required by ${r.map(([o])=>`\`${o}\``).join(", ")}`)}for(let[r,o]of t)this._resolver.addLanguage(o);for(let[r,o]of t)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let n of t)this._langGraph.set(n,this._langMap.get(n))}},Jx=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let o=t.slice(0,r).join(".");n=[...n,...this._injections.get(o)||[]]}return n}},to=0;function ml(e){to+=1,e.warnings!==!1&&to>=10&&to%10===0&&console.warn(`[Shiki] ${to} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new oe("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Is),o=new Xx(new Jx(e.engine,n),r,n,e.langAlias),s;function i(S){return kp(S,e.langAlias)}function a(S){k();let R=o.getGrammar(typeof S=="string"?S:S.name);if(!R)throw new oe(`Language \`${S}\` not found, you may need to load it first`);return R}function l(S){if(S==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};k();let R=o.getTheme(S);if(!R)throw new oe(`Theme \`${S}\` not found, you may need to load it first`);return R}function c(S){k();let R=l(S);return s!==S&&(o.setTheme(R),s=S),{theme:R,colorMap:o.getColorMap()}}function u(){return k(),o.getLoadedThemes()}function d(){return k(),o.getLoadedLanguages()}function m(...S){k(),o.loadLanguages(S.flat(1))}async function h(...S){return m(await bp(S))}function f(...S){k();for(let R of S.flat(1))o.loadTheme(R)}async function g(...S){return k(),f(await wp(S))}function k(){if(t)throw new oe("Shiki instance has been disposed")}function b(){t||(t=!0,o.dispose(),to-=1)}return{setTheme:c,getTheme:l,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:g,loadThemeSync:f,dispose:b,[Symbol.dispose]:b}}async function hl(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([wp(e.themes||[]),bp(e.langs||[]),e.engine]);return ml({...e,themes:t,langs:n,engine:r})}var Sp=new WeakMap;function so(e,t){Sp.set(e,t)}function ir(e){return Sp.get(e)}var Ps=class Tp{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new Tp(Object.fromEntries(xp(n).map(r=>[r,Ts])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,o]=t;this.lang=r,this._stacks={[o]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Zx(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Zx(e){let t=[],n=new Set;function r(o){if(n.has(o))return;n.add(o);let s=o?.nameScopesList?.scopeName;s&&t.push(s),o.parent&&r(o.parent)}return r(e),t}function Yx(e,t){if(!(e instanceof Ps))throw new oe("Invalid grammar state");return e.getInternalStack(t)}var Qx=/,/,eb=/ /;function gl(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(ro(e.resolveLangAlias(n.lang||"text"))||oo(r))return sr(t).map(a=>[{content:a[0],offset:a[1]}]);let{theme:o,colorMap:s}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new oe(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new oe(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return _p(t,i,o,s,n)}function Cp(...e){if(e.length===2)return ir(e[1]);let[t,n,r={}]=e,{lang:o="text",theme:s=t.getLoadedThemes()[0]}=r;if(ro(o)||oo(s))throw new oe("Plain language does not have grammar state");if(o==="ansi")throw new oe("ANSI language does not have grammar state");let{theme:i,colorMap:a}=t.setTheme(s),l=t.getLanguage(o);return new Ps(yl(n,l,i,a,r).stateStack,l.name,i.name)}function _p(e,t,n,r,o){let s=yl(e,t,n,r,o),i=new Ps(s.stateStack,t.name,n.name);return so(s.tokens,i),s.tokens}function yl(e,t,n,r,o){let s=no(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=o,c=sr(e),u=o.grammarState?Yx(o.grammarState,n.name)??Ts:o.grammarContextCode!=null?yl(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ts,d=[],m=[];for(let h=0,f=c.length;h<f;h++){let[g,k]=c[h];if(g===""){d=[],m.push([]);continue}if(i>0&&g.length>=i){d=[],m.push([{content:g,offset:k,color:"",fontStyle:0}]);continue}let b,S,R;l&&l!=="tokenType"&&(b=t.tokenizeLine(g,u,a),S=b.tokens,R=0);let v=t.tokenizeLine2(g,u,a),_=v.tokens.length/2;for(let B=0;B<_;B++){let j=v.tokens[2*B],D=B+1<_?v.tokens[2*B+2]:g.length;if(j===D)continue;let C=v.tokens[2*B+1],J=Dt(r[nn.getForeground(C)],s),M=nn.getFontStyle(C),U={content:g.substring(j,D),offset:k+j,color:J,fontStyle:M};if(l==="tokenType")U.type=nn.getTokenType(C);else if(l){let N=[];if(l!=="scopeName")for(let ne of n.settings){let H;switch(typeof ne.scope){case"string":H=ne.scope.split(Qx).map(se=>se.trim());break;case"object":H=ne.scope;break;default:continue}N.push({settings:ne,selectors:H.map(se=>se.split(eb))})}U.explanation=[];let ie=0;for(;j+ie<D;){let ne=S[R],H=g.substring(ne.startIndex,ne.endIndex);ie+=H.length,U.explanation.push({content:H,scopes:l==="scopeName"?tb(ne.scopes):nb(N,ne.scopes)}),R+=1}}d.push(U)}m.push(d),d=[],u=v.ruleStack}return{tokens:m,stateStack:u}}function tb(e){return e.map(t=>({scopeName:t}))}function nb(e,t){let n=[];for(let r=0,o=t.length;r<o;r++){let s=t[r];n[r]={scopeName:s,themeMatches:ob(e,s,t.slice(0,r))}}return n}function yp(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function rb(e,t,n){if(!yp(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)yp(e[r],n[o])&&(r-=1),o-=1;return r===-1}function ob(e,t,n){let r=[];for(let{selectors:o,settings:s}of e)for(let i of o)if(rb(i,t,n)){r.push(s);break}return r}function Ls(e,t,n,r=gl){let o=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),s=o.map(c=>{let u=r(e,t,{...n,theme:c.theme});return{tokens:u,state:ir(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=sb(...s.map(c=>c.tokens)),a=i[0].map((c,u)=>c.map((d,m)=>{let h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),i.forEach((f,g)=>{let{content:k,explanation:b,offset:S,...R}=f[u][m];h.variants[o[g].color]=R}),h})),l=s[0].state?new Ps(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return l&&so(a,l),a}function sb(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let o=e.map(l=>l[r]),s=t.map(()=>[]);t.forEach((l,c)=>l.push(s[c]));let i=o.map(()=>0),a=o.map(l=>l[0]);for(;a.every(l=>l);){let l=Math.min(...a.map(c=>c.content.length));for(let c=0;c<n;c++){let u=a[c];u.content.length===l?(s[c].push(u),i[c]+=1,a[c]=o[c][i[c]]):(s[c].push({...u,content:u.content.slice(0,l)}),a[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return t}p();p();p();var Rp=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];p();p();p();var Nt=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Nt.prototype.normal={};Nt.prototype.property={};Nt.prototype.space=void 0;function xl(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Nt(n,r,t)}p();p();p();function io(e){return e.toLowerCase()}p();p();var Ae=class{constructor(t,n){this.attribute=n,this.property=t}};Ae.prototype.attribute="";Ae.prototype.booleanish=!1;Ae.prototype.boolean=!1;Ae.prototype.commaOrSpaceSeparated=!1;Ae.prototype.commaSeparated=!1;Ae.prototype.defined=!1;Ae.prototype.mustUseProperty=!1;Ae.prototype.number=!1;Ae.prototype.overloadedBoolean=!1;Ae.prototype.property="";Ae.prototype.spaceSeparated=!1;Ae.prototype.space=void 0;var ao={};nd(ao,{boolean:()=>X,booleanish:()=>pe,commaOrSpaceSeparated:()=>Ge,commaSeparated:()=>Mt,number:()=>I,overloadedBoolean:()=>$s,spaceSeparated:()=>re});p();var ib=0,X=_n(),pe=_n(),$s=_n(),I=_n(),re=_n(),Mt=_n(),Ge=_n();function _n(){return 2**++ib}var bl=Object.keys(ao),Rn=class extends Ae{constructor(t,n,r,o){let s=-1;if(super(t,n),vp(this,"space",o),typeof r=="number")for(;++s<bl.length;){let i=bl[s];vp(this,bl[s],(r&ao[i])===ao[i])}}};Rn.prototype.defined=!0;function vp(e,t,n){n&&(e[t]=n)}function it(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let s=new Rn(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[io(r)]=r,n[io(s.attribute)]=r}return new Nt(t,n,e.space)}var wl=it({properties:{ariaActiveDescendant:null,ariaAtomic:pe,ariaAutoComplete:null,ariaBusy:pe,ariaChecked:pe,ariaColCount:I,ariaColIndex:I,ariaColSpan:I,ariaControls:re,ariaCurrent:null,ariaDescribedBy:re,ariaDetails:null,ariaDisabled:pe,ariaDropEffect:re,ariaErrorMessage:null,ariaExpanded:pe,ariaFlowTo:re,ariaGrabbed:pe,ariaHasPopup:null,ariaHidden:pe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:re,ariaLevel:I,ariaLive:null,ariaModal:pe,ariaMultiLine:pe,ariaMultiSelectable:pe,ariaOrientation:null,ariaOwns:re,ariaPlaceholder:null,ariaPosInSet:I,ariaPressed:pe,ariaReadOnly:pe,ariaRelevant:null,ariaRequired:pe,ariaRoleDescription:re,ariaRowCount:I,ariaRowIndex:I,ariaRowSpan:I,ariaSelected:pe,ariaSetSize:I,ariaSort:null,ariaValueMax:I,ariaValueMin:I,ariaValueNow:I,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});p();p();p();function Os(e,t){return t in e?e[t]:t}function Ds(e,t){return Os(e,t.toLowerCase())}var Ap=it({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Mt,acceptCharset:re,accessKey:re,action:null,allow:null,allowFullScreen:X,allowPaymentRequest:X,allowUserMedia:X,alpha:X,alt:null,as:null,async:X,autoCapitalize:null,autoComplete:re,autoFocus:X,autoPlay:X,blocking:re,capture:null,charSet:null,checked:X,cite:null,className:re,closedBy:null,colorSpace:null,cols:I,colSpan:I,command:null,commandFor:null,content:null,contentEditable:pe,controls:X,controlsList:re,coords:I|Mt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:X,defer:X,dir:null,dirName:null,disabled:X,download:$s,draggable:pe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:X,formTarget:null,headers:re,height:I,hidden:$s,high:I,href:null,hrefLang:null,htmlFor:re,httpEquiv:re,id:null,imageSizes:null,imageSrcSet:null,inert:X,inputMode:null,integrity:null,is:null,isMap:X,itemId:null,itemProp:re,itemRef:re,itemScope:X,itemType:re,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:X,low:I,manifest:null,max:null,maxLength:I,media:null,method:null,min:null,minLength:I,multiple:X,muted:X,name:null,nonce:null,noModule:X,noValidate:X,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:X,optimum:I,pattern:null,ping:re,placeholder:null,playsInline:X,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:X,referrerPolicy:null,rel:re,required:X,reversed:X,rows:I,rowSpan:I,sandbox:re,scope:null,scoped:X,seamless:X,selected:X,shadowRootClonable:X,shadowRootCustomElementRegistry:X,shadowRootDelegatesFocus:X,shadowRootMode:null,shadowRootSerializable:X,shape:null,size:I,sizes:null,slot:null,span:I,spellCheck:pe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:I,step:null,style:null,tabIndex:I,target:null,title:null,translate:null,type:null,typeMustMatch:X,useMap:null,value:pe,width:I,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:re,axis:null,background:null,bgColor:null,border:I,borderColor:null,bottomMargin:I,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:X,declare:X,event:null,face:null,frame:null,frameBorder:null,hSpace:I,leftMargin:I,link:null,longDesc:null,lowSrc:null,marginHeight:I,marginWidth:I,noResize:X,noHref:X,noShade:X,noWrap:X,object:null,profile:null,prompt:null,rev:null,rightMargin:I,rules:null,scheme:null,scrolling:pe,standby:null,summary:null,text:null,topMargin:I,valueType:null,version:null,vAlign:null,vLink:null,vSpace:I,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:X,disablePictureInPicture:X,disableRemotePlayback:X,exportParts:Mt,part:re,prefix:null,property:null,results:I,security:null,unselectable:null},space:"html",transform:Ds});p();var Ep=it({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ge,accentHeight:I,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:I,amplitude:I,arabicForm:null,ascent:I,attributeName:null,attributeType:null,azimuth:I,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:I,by:null,calcMode:null,capHeight:I,className:re,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:I,diffuseConstant:I,direction:null,display:null,dur:null,divisor:I,dominantBaseline:null,download:X,dx:null,dy:null,edgeMode:null,editable:null,elevation:I,enableBackground:null,end:null,event:null,exponent:I,externalResourcesRequired:null,fill:null,fillOpacity:I,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Mt,g2:Mt,glyphName:Mt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:I,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:I,horizOriginX:I,horizOriginY:I,id:null,ideographic:I,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:I,k:I,k1:I,k2:I,k3:I,k4:I,kernelMatrix:Ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:I,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:I,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:I,overlineThickness:I,paintOrder:null,panose1:null,path:null,pathLength:I,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:re,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:I,pointsAtY:I,pointsAtZ:I,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ge,rev:Ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ge,requiredFeatures:Ge,requiredFonts:Ge,requiredFormats:Ge,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:I,specularExponent:I,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:I,strikethroughThickness:I,string:null,stroke:null,strokeDashArray:Ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:I,strokeOpacity:I,strokeWidth:null,style:null,surfaceScale:I,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ge,tabIndex:I,tableValues:null,target:null,targetX:I,targetY:I,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:I,underlineThickness:I,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:I,values:null,vAlphabetic:I,vMathematical:I,vectorEffect:null,vHanging:I,vIdeographic:I,version:null,vertAdvY:I,vertOriginX:I,vertOriginY:I,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:I,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Os});p();var kl=it({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});p();var Sl=it({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ds});p();var Tl=it({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});p();var ab=/[A-Z]/g,Ip=/-[a-z]/g,lb=/^data[-\w.:]+$/i;function Cl(e,t){let n=io(t),r=t,o=Ae;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&lb.test(t)){if(t.charAt(4)==="-"){let s=t.slice(5).replace(Ip,ub);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{let s=t.slice(4);if(!Ip.test(s)){let i=s.replace(ab,cb);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=Rn}return new o(r,t)}function cb(e){return"-"+e.toLowerCase()}function ub(e){return e.charAt(1).toUpperCase()}var Pp=xl([wl,Ap,kl,Sl,Tl],"html"),Ns=xl([wl,Ep,kl,Sl,Tl],"svg");p();p();var Lp={}.hasOwnProperty;function $p(e,t){let n=t||{};function r(o,...s){let i=r.invalid,a=r.handlers;if(o&&Lp.call(o,e)){let l=String(o[e]);i=Lp.call(a,l)?a[l]:r.unknown}if(i)return i.call(this,o,...s)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}p();p();p();var db=/["&'<>`]/g,pb=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,fb=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,mb=/[|\\{}()[\]^$+*?.]/g,Op=new WeakMap;function Dp(e,t){if(e=e.replace(t.subset?hb(t.subset):db,r),t.subset||t.escapeOnly)return e;return e.replace(pb,n).replace(fb,r);function n(o,s,i){return t.format((o.charCodeAt(0)-55296)*1024+o.charCodeAt(1)-56320+65536,i.charCodeAt(s+2),t)}function r(o,s,i){return t.format(o.charCodeAt(0),i.charCodeAt(s+1),t)}}function hb(e){let t=Op.get(e);return t||(t=gb(e),Op.set(e,t)),t}function gb(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(mb,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}p();p();var yb=/[\dA-Fa-f]/;function Np(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!yb.test(String.fromCharCode(t))?r:r+";"}p();var xb=/\d/;function Mp(e,t,n){let r="&#"+String(e);return n&&t&&!xb.test(String.fromCharCode(t))?r:r+";"}p();p();var Bp=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];p();var Ms={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};p();var Fp=["cent","copy","divide","gt","lt","not","para","times"];var Gp={}.hasOwnProperty,_l={},Bs;for(Bs in Ms)Gp.call(Ms,Bs)&&(_l[Ms[Bs]]=Bs);var bb=/[^\dA-Za-z]/;function jp(e,t,n,r){let o=String.fromCharCode(e);if(Gp.call(_l,o)){let s=_l[o],i="&"+s;return n&&Bp.includes(s)&&!Fp.includes(s)&&(!r||t&&t!==61&&bb.test(String.fromCharCode(t)))?i:i+";"}return""}function Up(e,t,n){let r=Np(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=jp(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){let s=Mp(e,t,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Bt(e,t){return Dp(e,Object.assign({format:Up},t))}var wb=/^>|^->|<!--|-->|--!>|<!-$/g,kb=[">"],Sb=["<",">"];function Wp(e,t,n,r){return r.settings.bogusComments?"<?"+Bt(e.value,Object.assign({},r.settings.characterReferences,{subset:kb}))+">":"<!--"+e.value.replace(wb,o)+"-->";function o(s){return Bt(s,Object.assign({},r.settings.characterReferences,{subset:Sb}))}}p();function Hp(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}p();p();function Rl(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}p();function Vp(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}p();function zp(e){return e.join(" ").trim()}p();p();p();var Tb=/[ \t\n\f\r]/g;function vn(e){return typeof e=="object"?e.type==="text"?qp(e.value):!1:qp(e)}function qp(e){return e.replace(Tb,"")===""}p();var he=Kp(1),vl=Kp(-1),Cb=[];function Kp(e){return t;function t(n,r,o){let s=n?n.children:Cb,i=(r||0)+e,a=s[i];if(!o)for(;a&&vn(a);)i+=e,a=s[i];return a}}p();var _b={}.hasOwnProperty;function Fs(e){return t;function t(n,r,o){return _b.call(e,n.tagName)&&e[n.tagName](n,r,o)}}var lo=Fs({body:vb,caption:Al,colgroup:Al,dd:Pb,dt:Ib,head:Al,html:Rb,li:Eb,optgroup:Lb,option:$b,p:Ab,rp:Xp,rt:Xp,tbody:Db,td:Jp,tfoot:Nb,th:Jp,thead:Ob,tr:Mb});function Al(e,t,n){let r=he(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&vn(r.value.charAt(0)))}function Rb(e,t,n){let r=he(n,t);return!r||r.type!=="comment"}function vb(e,t,n){let r=he(n,t);return!r||r.type!=="comment"}function Ab(e,t,n){let r=he(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function Eb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="li"}function Ib(e,t,n){let r=he(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Pb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Xp(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Lb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function $b(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Ob(e,t,n){let r=he(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Db(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Nb(e,t,n){return!he(n,t)}function Mb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Jp(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}p();var Zp=Fs({body:Gb,colgroup:jb,head:Fb,html:Bb,tbody:Ub});function Bb(e){let t=he(e,-1);return!t||t.type!=="comment"}function Fb(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let n=e.children[0];return!n||n.type==="element"}function Gb(e){let t=he(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&vn(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function jb(e,t,n){let r=vl(n,t),o=he(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&lo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function Ub(e,t,n){let r=vl(n,t),o=he(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&lo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}var Gs={name:[[`
27
26
  \f\r &/=>`.split(""),`
28
27
  \f\r "&'/=>\``.split("")],[`\0
29
28
  \f\r "&'/<=>`.split(""),`\0
@@ -31,10 +30,10 @@ import{a as kn,b as ka,c as tn,d as Yn,e as kt,f as Sa,h as Ta}from"./chunk-V3LN
31
30
  \f\r &>`.split(""),`\0
32
31
  \f\r "&'<=>\``.split("")],[`\0
33
32
  \f\r "&'<=>\``.split(""),`\0
34
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Kp(e,t,n,r){let o=r.schema,s=o.space==="svg"?!1:r.settings.omitOptionalTags,i=o.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),a=[],l;o.space==="html"&&e.tagName==="svg"&&(r.schema=Ds);let c=Fb(r,e.properties),u=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,u&&(i=!1),(c||!s||!qp(e,t,n))&&(a.push("<",e.tagName,c?" "+c:""),i&&(o.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(u),!i&&(!s||!co(e,t,n))&&a.push("</"+e.tagName+">"),a.join("")}function Fb(e,t){let n=[],r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){let s=Gb(e,o,t[o]);s&&n.push(s)}}for(;++r<n.length;){let s=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&s!=='"'&&s!=="'"&&(n[r]+=" ")}return n.join("")}function Gb(e,t,n){let r=_l(e.schema,t),o=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,i=e.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";let l=Bt(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Fs.name[o][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?jp:Up)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(a=Bt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Fs.unquoted[o][s]}))),a!==n&&(e.settings.quoteSmart&&Rl(n,i)>Rl(n,e.alternative)&&(i=e.alternative),a=i+Bt(n,Object.assign({},e.settings.characterReferences,{subset:(i==="'"?Fs.single:Fs.double)[o][s],attribute:!0}))+i),l+(a&&"="+a))}p();p();var jb=["<","&"];function Gs(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Bt(e.value,Object.assign({},r.settings.characterReferences,{subset:jb}))}function Xp(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Gs(e,t,n,r)}p();function Jp(e,t,n,r){return r.all(e)}var Zp=Ep("type",{invalid:Ub,unknown:Wb,handlers:{comment:Fp,doctype:Gp,element:Kp,raw:Xp,root:Jp,text:Gs}});function Ub(e){throw new Error("Expected node, not `"+e+"`")}function Wb(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var Hb={},Vb={},zb=[];function Il(e,t){let n=t||Hb,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:qb,all:Kb,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Sp,characterReferences:n.characterReferences||Vb,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Ds:Rp,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function qb(e,t,n){return Zp(e,t,n,this)}function Kb(e){let t=[],n=e&&e.children||zb,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var Yp=/\s+/g;function tf(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Yp)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Yp);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}var Xb=/:?lang=["']([^"']+)["']/g,Jb=/(?:```|~~~)([\w-]+)/g,Zb=/\\begin\{([\w-]+)\}/g,Yb=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function Qb(e){let t=lr(e,!0).map(([o])=>o);function n(o){if(o===e.length)return{line:t.length-1,character:t.at(-1).length};let s=o,i=0;for(let a of t){if(s<a.length)break;s-=a.length,i++}return{line:i,character:s}}function r(o,s){let i=0;for(let a=0;a<o;a++)i+=t[a].length;return i+=s,i}return{lines:t,indexToPos:n,posToIndex:r}}function nf(e,t,n){let r=new Set;for(let s of e.matchAll(Xb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Jb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Zb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Yb)){let i=s[1].toLowerCase().trim(),a=i.includes("/")?i.split("/").pop():i;a&&r.add(a)}if(!n)return[...r];let o=n.getBundledLanguages();return[...r].filter(s=>s&&o[s])}var ew=["color","background-color"];function tw(e,t){let n=0,r=[];for(let o of t)o>n&&r.push({...e,content:e.content.slice(n,o),offset:e.offset+n}),n=o;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function nw(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,o)=>r-o);return n.length?e.map(r=>r.flatMap(o=>{let s=n.filter(i=>o.offset<i&&i<o.offset+o.content.length).map(i=>i-o.offset).sort((i,a)=>i-a);return s.length?tw(o,s):o})):e}function rw(e,t,n,r,o="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>js(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,d)=>{let m=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+t[u]+(d==="color"?"":m)};return i.forEach((u,d)=>{for(let m of a){let h=u[m]||"inherit";if(d===0&&r&&ew.includes(m))if(r==="light-dark()"&&i.length>1){let f=t.findIndex(b=>b==="light"),g=t.findIndex(b=>b==="dark");if(f===-1||g===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');l[m]=`light-dark(${i[f][m]||"inherit"}, ${i[g][m]||"inherit"})`,o==="css-vars"&&(l[c(d,m)]=h)}else l[m]=h;else o==="css-vars"&&(l[c(d,m)]=h)}}),s.htmlStyle=l,s}function js(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&de.Italic&&(t["font-style"]="italic"),e.fontStyle&de.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&de.Underline&&n.push("underline"),e.fontStyle&de.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Ll(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function ow(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new re(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...o.indexToPos(a),offset:a}}else{let l=o.lines[a.line];if(l===void 0)throw new re(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${o.lines.length}`);let c=a.character;if(c<0&&(c=l.length+c),c<0||c>l.length)throw new re(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${l.length}`);return{...a,character:c,offset:o.posToIndex(a.line,c)}}};var r=s;let o=Qb(n.source),i=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));sw(i),e.set(n.meta,{decorations:i,converter:o,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return nw(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),o=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(o.length!==r.converter.lines.length)throw new re(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(u,d,m,h){let f=o[u],g="",b=-1,w=-1;if(d===0&&(b=0),m===0&&(w=0),m===Number.POSITIVE_INFINITY&&(w=f.children.length),b===-1||w===-1)for(let v=0;v<f.children.length;v++)g+=rf(f.children[v]),b===-1&&g.length===d&&(b=v+1),w===-1&&g.length===m&&(w=v+1);if(b===-1)throw new re(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(w===-1)throw new re(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let S=f.children.slice(b,w);if(!h.alwaysWrap&&S.length===f.children.length)a(f,h,"line");else if(!h.alwaysWrap&&S.length===1&&S[0].type==="element")a(S[0],h,"token");else{let v={type:"element",tagName:"span",properties:{},children:S};a(v,h,"wrapper"),f.children.splice(b,S.length,v)}}function i(u,d){o[u]=a(o[u],d,"line")}function a(u,d,m){let h=d.properties||{},f=d.transform||(g=>g);return u.tagName=d.tagName||"span",u.properties={...u.properties,...h,class:u.properties.class},d.properties?.class&&tf(u,d.properties.class),u=f(u,m)||u,u}let l=[],c=r.decorations.sort((u,d)=>d.start.offset-u.start.offset||u.end.offset-d.end.offset);for(let u of c){let{start:d,end:m}=u;if(d.line===m.line)s(d.line,d.character,m.character,u);else if(d.line<m.line){s(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let h=d.line+1;h<m.line;h++)l.unshift(()=>i(h,u));s(m.line,0,m.character,u)}}l.forEach(u=>u())}}}function sw(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new re(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let o=e[r],s=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,i=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,a=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,l=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(s||i||a||l){if(s&&i||a&&l||a&&n.start.offset===n.end.offset||i&&o.start.offset===o.end.offset)continue;throw new re(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function rf(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(rf).join(""):""}var iw=[ow()];function Us(e){let t=aw(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...iw]}function aw(e){let t=[],n=[],r=[];for(let o of e)switch(o.enforce){case"pre":t.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:t,post:n,normal:r}}var En=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Pl={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function lw(e,t){let n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Qp(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function cw(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)Pl[r]&&t.push({type:"setDecoration",value:Pl[r]});else if(r<=29){let o=Pl[r-20];o&&(t.push({type:"resetDecoration",value:o}),o==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:En[r-30]}});else if(r===38){let o=Qp(e);o&&t.push({type:"setForegroundColor",value:o})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:En[r-40]}});else if(r===48){let o=Qp(e);o&&t.push({type:"setBackgroundColor",value:o})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:En[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:En[r-100+8]}})}return t}function uw(){let e=null,t=null,n=new Set;return{parse(r){let o=[],s=0;do{let i=lw(r,s),a=i.sequence?r.substring(s,i.startPosition):r.substring(s);if(a.length>0&&o.push({value:a,foreground:e,background:t,decorations:new Set(n)}),i.sequence){let l=cw(i.sequence);for(let c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(let c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}s=i.position}while(s<r.length);return o}}}var dw={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function pw(e=dw){function t(a){return e[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let c=0;c<En.length;c++)r.push(t(En[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let d=0;d<6;d++)r.push(n([a[c],a[u],a[d]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function s(a){return o()[a]}function i(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:i}}var fw=/#([0-9a-f]{3,8})/i,mw=/var\((--[\w-]+-ansi-[\w-]+)\)/,hw={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function gw(e,t,n){let r=ro(e,n),o=lr(t),s=pw(Object.fromEntries(En.map(a=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||hw[a]]}))),i=uw();return o.map(a=>i.parse(a[0]).map(l=>{let c,u;l.decorations.has("reverse")?(c=l.background?s.value(l.background):e.bg,u=l.foreground?s.value(l.foreground):e.fg):(c=l.foreground?s.value(l.foreground):e.fg,u=l.background?s.value(l.background):void 0),c=Dt(c,r),u=Dt(u,r),l.decorations.has("dim")&&(c=yw(c));let d=de.None;return l.decorations.has("bold")&&(d|=de.Bold),l.decorations.has("italic")&&(d|=de.Italic),l.decorations.has("underline")&&(d|=de.Underline),l.decorations.has("strikethrough")&&(d|=de.Strikethrough),{content:l.value,offset:a[1],color:c,bgColor:u,fontStyle:d}}))}function yw(e){let t=e.match(fw);if(t){let r=t[1];if(r.length===8){let o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){let o=r[0],s=r[1],i=r[2],a=r[3];return`#${o}${o}${s}${s}${i}${i}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let o=r[0],s=r[1],i=r[2];return`#${o}${o}${s}${s}${i}${i}80`}}}let n=e.match(mw);return n?`var(${n[1]}-dim)`:e}function $l(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!oo(r)&&!so(o)&&r==="ansi"){let{theme:s}=e.setTheme(o);return gw(s,t,n)}return yl(e,t,n)}function Ws(e,t,n){let r,o,s,i,a,l;if("themes"in n){let{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:d="css-vars"}=n,m=Object.entries(n.themes).filter(w=>w[1]).map(w=>({color:w[0],theme:w[1]})).sort((w,S)=>w.color===c?-1:S.color===c?1:0);if(m.length===0)throw new re("`themes` option must not be empty");let h=Ps(e,t,n,$l);if(l=cr(h),c&&c!=="light-dark()"&&!m.some(w=>w.color===c))throw new re(`\`themes\` option must contain the defaultColor key \`${c}\``);let f=m.map(w=>e.getTheme(w.theme)),g=m.map(w=>w.color);s=h.map(w=>w.map(S=>rw(S,g,u,c,d))),l&&io(s,l);let b=m.map(w=>ro(w.theme,n));o=ef(m,f,b,u,c,"fg",d),r=ef(m,f,b,u,c,"bg",d),i=`shiki-themes ${f.map(w=>w.name).join(" ")}`,a=c?void 0:[o,r].join(";")}else if("theme"in n){let c=ro(n.theme,n);s=$l(e,t,n);let u=e.getTheme(n.theme);r=Dt(u.bg,c),o=Dt(u.fg,c),i=u.name,l=cr(s)}else throw new re("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:o,bg:r,themeName:i,rootStyle:a,grammarState:l}}function ef(e,t,n,r,o,s,i){return e.map((a,l)=>{let c=Dt(t[l][s],n[l])||"inherit",u=`${r+a.color}${s==="bg"?"-bg":""}:${c}`;if(l===0&&o){if(o==="light-dark()"&&e.length>1){let d=e.findIndex(h=>h.color==="light"),m=e.findIndex(h=>h.color==="dark");if(d===-1||m===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Dt(t[d][s],n[d])||"inherit"}, ${Dt(t[m][s],n[m])||"inherit"});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}var of=/^\s+$/,xw=/^(\s*)(.*?)(\s*)$/;function Hs(e,t,n,r={meta:{},options:n,codeToHast:(o,s)=>Hs(e,o,s),codeToTokens:(o,s)=>Ws(e,o,s)}){let o=t;for(let f of Us(n))o=f.preprocess?.call(r,o,n)||o;let{tokens:s,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=Ws(e,o,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=ww(s):d==="never"&&(s=kw(s)),m&&(s=Sw(s));let h={...r,get source(){return o}};for(let f of Us(n))s=f.tokens?.call(h,s)||s;return bw(s,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},h,u)}function bw(e,t,n,r=cr(e)){let o=Us(t),s=[],i={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t,c={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?c.style=t.rootStyle:c.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(let[g,b]of Object.entries(t.meta||{}))g.startsWith("_")||(c[g]=b);let u={type:"element",tagName:"pre",properties:c,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},m=[],h={...n,structure:a,addClassToHast:tf,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return i},get pre(){return u},get code(){return d},get lines(){return m}};if(e.forEach((g,b)=>{b&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
35
- `}));let w={type:"element",tagName:"span",properties:{class:"line"},children:[]},S=0;for(let v of g){let _={type:"element",tagName:"span",properties:{...v.htmlAttrs},children:[{type:"text",value:v.content}]},E=Ll(v.htmlStyle||js(v));E&&(_.properties.style=E);for(let M of o)_=M?.span?.call(h,_,b+1,S,w,v)||_;a==="inline"?i.children.push(_):a==="classic"&&w.children.push(_),S+=v.content.length}if(a==="classic"){for(let v of o)w=v?.line?.call(h,w,b+1)||w;m.push(w),s.push(w)}else a==="inline"&&m.push(w)}),a==="classic"){for(let g of o)d=g?.code?.call(h,d)||d;u.children.push(d);for(let g of o)u=g?.pre?.call(h,u)||u;i.children.push(u)}else if(a==="inline"){let g=[],b={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let S of i.children)S.type==="element"&&S.tagName==="br"?(g.push(b),b={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(S.type==="element"||S.type==="text")&&b.children.push(S);g.push(b);let w={type:"element",tagName:"code",properties:{},children:g};for(let S of o)w=S?.code?.call(h,w)||w;i.children=[];for(let S=0;S<w.children.length;S++){S>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});let v=w.children[S];v.type==="element"&&i.children.push(...v.children)}}let f=i;for(let g of o)f=g?.root?.call(h,f)||f;return r&&io(f,r),f}function ww(e){return e.map(t=>{let n=[],r="",o;return t.forEach((s,i)=>{let a=!(s.fontStyle&&(s.fontStyle&de.Underline||s.fontStyle&de.Strikethrough));a&&of.test(s.content)&&t[i+1]?(o===void 0&&(o=s.offset),r+=s.content):r?(a?n.push({...s,offset:o,content:r+s.content}):n.push({content:r,offset:o},s),o=void 0,r=""):n.push(s)}),n})}function kw(e){return e.map(t=>t.flatMap(n=>{if(of.test(n.content))return n;let r=n.content.match(xw);if(!r)return n;let[,o,s,i]=r;if(!o&&!i)return n;let a=[{...n,offset:n.offset+o.length,content:s}];return o&&a.unshift({content:o,offset:n.offset}),i&&a.push({content:i,offset:n.offset+o.length+s.length}),a}))}function Sw(e){return e.map(t=>{let n=[];for(let r of t){if(n.length===0){n.push({...r});continue}let o=n.at(-1),s=Ll(o.htmlStyle||js(o)),i=Ll(r.htmlStyle||js(r)),a=o.fontStyle&&(o.fontStyle&de.Underline||o.fontStyle&de.Strikethrough),l=r.fontStyle&&(r.fontStyle&de.Underline||r.fontStyle&de.Strikethrough);!a&&!l&&s===i?o.content+=r.content:n.push({...r})}return n})}var Tw=Il;function Cw(e,t,n){let r={meta:{},options:n,codeToHast:(s,i)=>Hs(e,s,i),codeToTokens:(s,i)=>Ws(e,s,i)},o=Tw(Hs(e,t,n,r));for(let s of Us(n))o=s.postprocess?.call(r,o,n)||o;return o}async function _w(e){let t=await gl(e);return{getLastGrammarState:(...n)=>wp(t,...n),codeToTokensBase:(n,r)=>$l(t,n,r),codeToTokensWithThemes:(n,r)=>Ps(t,n,r),codeToTokens:(n,r)=>Ws(t,n,r),codeToHast:(n,r)=>Hs(t,n,r),codeToHtml:(n,r)=>Cw(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function sf(e){let t=e.langs,n=e.themes,r=e.engine;async function o(s){function i(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,fl(d))return[];let m=t[d];if(!m)throw new re(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}function a(d){if(ml(d))return"none";if(typeof d=="string"){let m=n[d];if(!m)throw new re(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}let l=(s.themes??[]).map(d=>a(d)),c=(s.langs??[]).map(d=>i(d)),u=await _w({engine:s.engine??r(),...s,themes:l,langs:c});return{...u,loadLanguage(...d){return u.loadLanguage(...d.map(i))},loadTheme(...d){return u.loadTheme(...d.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return o}function vw(e){let t;async function n(r={}){if(t){let o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}else{t=e({...r,themes:[],langs:[]});let o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}}return n}function af(e,t){let n=vw(e);async function r(o,s){let i=await n({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),a=await t?.guessEmbeddedLanguages?.(o,s.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(o){return n(o)},async codeToHtml(o,s){return(await r(o,s)).codeToHtml(o,s)},async codeToHast(o,s){return(await r(o,s)).codeToHast(o,s)},async codeToTokens(o,s){return(await r(o,s)).codeToTokens(o,s)},async codeToTokensBase(o,s){return(await r(o,s)).codeToTokensBase(o,s)},async codeToTokensWithThemes(o,s){return(await r(o,s)).codeToTokensWithThemes(o,s)},async getLastGrammarState(o,s){return(await n({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(o,s)}}}var lf=ir({bundledLanguages:()=>Qr,bundledLanguagesAlias:()=>Yr,bundledLanguagesBase:()=>Zr,bundledLanguagesInfo:()=>ar,bundledThemes:()=>to,bundledThemesInfo:()=>eo,codeToHast:()=>Dl,codeToHtml:()=>Ol,codeToTokens:()=>Nl,codeToTokensBase:()=>uo,codeToTokensWithThemes:()=>Ml,createHighlighter:()=>Vs,getLastGrammarState:()=>Bl,getSingletonHighlighter:()=>po}),Vs=sf({langs:Qr,themes:to,engine:()=>(0,dl.createOnigurumaEngine)(import("./wasm-FXCISVGQ.js"))}),{codeToHtml:Ol,codeToHast:Dl,codeToTokens:Nl,codeToTokensBase:uo,codeToTokensWithThemes:Ml,getSingletonHighlighter:po,getLastGrammarState:Bl}=af(Vs,{guessEmbeddedLanguages:nf});p();p();var cf=class{patterns;options;regexps;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:o}=t;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(s=>{if(typeof s!="string")return s;let i=r?.get(s);if(i){if(i instanceof RegExp)return i;if(n)return null;throw i}try{let a=o(s);return r?.set(s,a),a}catch(a){if(r?.set(s,a),n)return null;throw a}})}findNextMatchSync(e,t,n){let r=typeof e=="string"?e:e.content,o=[];function s(i,a,l=0){return{index:i,captureIndices:a.indices.map(c=>c==null?{start:4294967295,end:4294967295,length:0}:{start:c[0]+l,end:c[1]+l,length:c[1]-c[0]})}}for(let i=0;i<this.regexps.length;i++){let a=this.regexps[i];if(a)try{a.lastIndex=t;let l=a.exec(r);if(!l)continue;if(l.index===t)return s(i,l,0);o.push([i,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(o.length){let i=Math.min(...o.map(a=>a[1].index));for(let[a,l,c]of o)if(l.index===i)return s(a,l,c)}return null}};p();p();p();p();p();function rn(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function uf(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var fo=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),we=String.raw;function Ft(e,t){if(e==null)throw new Error(t??"Value expected");return e}var gf=we`\[\^?`,yf=`c.? | C(?:-.?)?|${we`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${we`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${we`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${we`o\{[^\}]*\}?`}|${we`\d{1,3}`}`,Gl=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,zs=new RegExp(we`
33
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Yp(e,t,n,r){let o=r.schema,s=o.space==="svg"?!1:r.settings.omitOptionalTags,i=o.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),a=[],l;o.space==="html"&&e.tagName==="svg"&&(r.schema=Ns);let c=Wb(r,e.properties),u=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,u&&(i=!1),(c||!s||!Zp(e,t,n))&&(a.push("<",e.tagName,c?" "+c:""),i&&(o.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(u),!i&&(!s||!lo(e,t,n))&&a.push("</"+e.tagName+">"),a.join("")}function Wb(e,t){let n=[],r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){let s=Hb(e,o,t[o]);s&&n.push(s)}}for(;++r<n.length;){let s=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&s!=='"'&&s!=="'"&&(n[r]+=" ")}return n.join("")}function Hb(e,t,n){let r=Cl(e.schema,t),o=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,i=e.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";let l=Bt(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Gs.name[o][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Vp:zp)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(a=Bt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Gs.unquoted[o][s]}))),a!==n&&(e.settings.quoteSmart&&Rl(n,i)>Rl(n,e.alternative)&&(i=e.alternative),a=i+Bt(n,Object.assign({},e.settings.characterReferences,{subset:(i==="'"?Gs.single:Gs.double)[o][s],attribute:!0}))+i),l+(a&&"="+a))}p();p();var Vb=["<","&"];function js(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Bt(e.value,Object.assign({},r.settings.characterReferences,{subset:Vb}))}function Qp(e,t,n,r){return r.settings.allowDangerousHtml?e.value:js(e,t,n,r)}p();function ef(e,t,n,r){return r.all(e)}var tf=$p("type",{invalid:zb,unknown:qb,handlers:{comment:Wp,doctype:Hp,element:Yp,raw:Qp,root:ef,text:js}});function zb(e){throw new Error("Expected node, not `"+e+"`")}function qb(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var Kb={},Xb={},Jb=[];function El(e,t){let n=t||Kb,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Zb,all:Yb,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Rp,characterReferences:n.characterReferences||Xb,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Ns:Pp,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Zb(e,t,n){return tf(e,t,n,this)}function Yb(e){let t=[],n=e&&e.children||Jb,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var nf=/\s+/g;function sf(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(nf)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(nf);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}var Qb=/:?lang=["']([^"']+)["']/g,ew=/(?:```|~~~)([\w-]+)/g,tw=/\\begin\{([\w-]+)\}/g,nw=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function rw(e){let t=sr(e,!0).map(([o])=>o);function n(o){if(o===e.length)return{line:t.length-1,character:t.at(-1).length};let s=o,i=0;for(let a of t){if(s<a.length)break;s-=a.length,i++}return{line:i,character:s}}function r(o,s){let i=0;for(let a=0;a<o;a++)i+=t[a].length;return i+=s,i}return{lines:t,indexToPos:n,posToIndex:r}}function af(e,t,n){let r=new Set;for(let s of e.matchAll(Qb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(ew)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(tw)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(nw)){let i=s[1].toLowerCase().trim(),a=i.includes("/")?i.split("/").pop():i;a&&r.add(a)}if(!n)return[...r];let o=n.getBundledLanguages();return[...r].filter(s=>s&&o[s])}var ow=["color","background-color"];function sw(e,t){let n=0,r=[];for(let o of t)o>n&&r.push({...e,content:e.content.slice(n,o),offset:e.offset+n}),n=o;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function iw(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,o)=>r-o);return n.length?e.map(r=>r.flatMap(o=>{let s=n.filter(i=>o.offset<i&&i<o.offset+o.content.length).map(i=>i-o.offset).sort((i,a)=>i-a);return s.length?sw(o,s):o})):e}function aw(e,t,n,r,o="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>Us(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,d)=>{let m=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+t[u]+(d==="color"?"":m)};return i.forEach((u,d)=>{for(let m of a){let h=u[m]||"inherit";if(d===0&&r&&ow.includes(m))if(r==="light-dark()"&&i.length>1){let f=t.findIndex(k=>k==="light"),g=t.findIndex(k=>k==="dark");if(f===-1||g===-1)throw new oe('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');l[m]=`light-dark(${i[f][m]||"inherit"}, ${i[g][m]||"inherit"})`,o==="css-vars"&&(l[c(d,m)]=h)}else l[m]=h;else o==="css-vars"&&(l[c(d,m)]=h)}}),s.htmlStyle=l,s}function Us(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&de.Italic&&(t["font-style"]="italic"),e.fontStyle&de.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&de.Underline&&n.push("underline"),e.fontStyle&de.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Pl(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function lw(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new oe(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...o.indexToPos(a),offset:a}}else{let l=o.lines[a.line];if(l===void 0)throw new oe(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${o.lines.length}`);let c=a.character;if(c<0&&(c=l.length+c),c<0||c>l.length)throw new oe(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${l.length}`);return{...a,character:c,offset:o.posToIndex(a.line,c)}}};var r=s;let o=rw(n.source),i=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));cw(i),e.set(n.meta,{decorations:i,converter:o,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return iw(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),o=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(o.length!==r.converter.lines.length)throw new oe(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(u,d,m,h){let f=o[u],g="",k=-1,b=-1;if(d===0&&(k=0),m===0&&(b=0),m===Number.POSITIVE_INFINITY&&(b=f.children.length),k===-1||b===-1)for(let R=0;R<f.children.length;R++)g+=lf(f.children[R]),k===-1&&g.length===d&&(k=R+1),b===-1&&g.length===m&&(b=R+1);if(k===-1)throw new oe(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(b===-1)throw new oe(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let S=f.children.slice(k,b);if(!h.alwaysWrap&&S.length===f.children.length)a(f,h,"line");else if(!h.alwaysWrap&&S.length===1&&S[0].type==="element")a(S[0],h,"token");else{let R={type:"element",tagName:"span",properties:{},children:S};a(R,h,"wrapper"),f.children.splice(k,S.length,R)}}function i(u,d){o[u]=a(o[u],d,"line")}function a(u,d,m){let h=d.properties||{},f=d.transform||(g=>g);return u.tagName=d.tagName||"span",u.properties={...u.properties,...h,class:u.properties.class},d.properties?.class&&sf(u,d.properties.class),u=f(u,m)||u,u}let l=[],c=r.decorations.sort((u,d)=>d.start.offset-u.start.offset||u.end.offset-d.end.offset);for(let u of c){let{start:d,end:m}=u;if(d.line===m.line)s(d.line,d.character,m.character,u);else if(d.line<m.line){s(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let h=d.line+1;h<m.line;h++)l.unshift(()=>i(h,u));s(m.line,0,m.character,u)}}l.forEach(u=>u())}}}function cw(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new oe(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let o=e[r],s=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,i=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,a=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,l=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(s||i||a||l){if(s&&i||a&&l||a&&n.start.offset===n.end.offset||i&&o.start.offset===o.end.offset)continue;throw new oe(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function lf(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(lf).join(""):""}var uw=[lw()];function Ws(e){let t=dw(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...uw]}function dw(e){let t=[],n=[],r=[];for(let o of e)switch(o.enforce){case"pre":t.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:t,post:n,normal:r}}var An=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Il={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function pw(e,t){let n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function rf(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function fw(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)Il[r]&&t.push({type:"setDecoration",value:Il[r]});else if(r<=29){let o=Il[r-20];o&&(t.push({type:"resetDecoration",value:o}),o==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:An[r-30]}});else if(r===38){let o=rf(e);o&&t.push({type:"setForegroundColor",value:o})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:An[r-40]}});else if(r===48){let o=rf(e);o&&t.push({type:"setBackgroundColor",value:o})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:An[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:An[r-100+8]}})}return t}function mw(){let e=null,t=null,n=new Set;return{parse(r){let o=[],s=0;do{let i=pw(r,s),a=i.sequence?r.substring(s,i.startPosition):r.substring(s);if(a.length>0&&o.push({value:a,foreground:e,background:t,decorations:new Set(n)}),i.sequence){let l=fw(i.sequence);for(let c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(let c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}s=i.position}while(s<r.length);return o}}}var hw={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function gw(e=hw){function t(a){return e[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let c=0;c<An.length;c++)r.push(t(An[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let d=0;d<6;d++)r.push(n([a[c],a[u],a[d]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function s(a){return o()[a]}function i(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:i}}var yw=/#([0-9a-f]{3,8})/i,xw=/var\((--[\w-]+-ansi-[\w-]+)\)/,bw={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function ww(e,t,n){let r=no(e,n),o=sr(t),s=gw(Object.fromEntries(An.map(a=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||bw[a]]}))),i=mw();return o.map(a=>i.parse(a[0]).map(l=>{let c,u;l.decorations.has("reverse")?(c=l.background?s.value(l.background):e.bg,u=l.foreground?s.value(l.foreground):e.fg):(c=l.foreground?s.value(l.foreground):e.fg,u=l.background?s.value(l.background):void 0),c=Dt(c,r),u=Dt(u,r),l.decorations.has("dim")&&(c=kw(c));let d=de.None;return l.decorations.has("bold")&&(d|=de.Bold),l.decorations.has("italic")&&(d|=de.Italic),l.decorations.has("underline")&&(d|=de.Underline),l.decorations.has("strikethrough")&&(d|=de.Strikethrough),{content:l.value,offset:a[1],color:c,bgColor:u,fontStyle:d}}))}function kw(e){let t=e.match(yw);if(t){let r=t[1];if(r.length===8){let o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){let o=r[0],s=r[1],i=r[2],a=r[3];return`#${o}${o}${s}${s}${i}${i}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let o=r[0],s=r[1],i=r[2];return`#${o}${o}${s}${s}${i}${i}80`}}}let n=e.match(xw);return n?`var(${n[1]}-dim)`:e}function Ll(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!ro(r)&&!oo(o)&&r==="ansi"){let{theme:s}=e.setTheme(o);return ww(s,t,n)}return gl(e,t,n)}function Hs(e,t,n){let r,o,s,i,a,l;if("themes"in n){let{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:d="css-vars"}=n,m=Object.entries(n.themes).filter(b=>b[1]).map(b=>({color:b[0],theme:b[1]})).sort((b,S)=>b.color===c?-1:S.color===c?1:0);if(m.length===0)throw new oe("`themes` option must not be empty");let h=Ls(e,t,n,Ll);if(l=ir(h),c&&c!=="light-dark()"&&!m.some(b=>b.color===c))throw new oe(`\`themes\` option must contain the defaultColor key \`${c}\``);let f=m.map(b=>e.getTheme(b.theme)),g=m.map(b=>b.color);s=h.map(b=>b.map(S=>aw(S,g,u,c,d))),l&&so(s,l);let k=m.map(b=>no(b.theme,n));o=of(m,f,k,u,c,"fg",d),r=of(m,f,k,u,c,"bg",d),i=`shiki-themes ${f.map(b=>b.name).join(" ")}`,a=c?void 0:[o,r].join(";")}else if("theme"in n){let c=no(n.theme,n);s=Ll(e,t,n);let u=e.getTheme(n.theme);r=Dt(u.bg,c),o=Dt(u.fg,c),i=u.name,l=ir(s)}else throw new oe("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:o,bg:r,themeName:i,rootStyle:a,grammarState:l}}function of(e,t,n,r,o,s,i){return e.map((a,l)=>{let c=Dt(t[l][s],n[l])||"inherit",u=`${r+a.color}${s==="bg"?"-bg":""}:${c}`;if(l===0&&o){if(o==="light-dark()"&&e.length>1){let d=e.findIndex(h=>h.color==="light"),m=e.findIndex(h=>h.color==="dark");if(d===-1||m===-1)throw new oe('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Dt(t[d][s],n[d])||"inherit"}, ${Dt(t[m][s],n[m])||"inherit"});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}var cf=/^\s+$/,Sw=/^(\s*)(.*?)(\s*)$/;function Vs(e,t,n,r={meta:{},options:n,codeToHast:(o,s)=>Vs(e,o,s),codeToTokens:(o,s)=>Hs(e,o,s)}){let o=t;for(let f of Ws(n))o=f.preprocess?.call(r,o,n)||o;let{tokens:s,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=Hs(e,o,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=Cw(s):d==="never"&&(s=_w(s)),m&&(s=Rw(s));let h={...r,get source(){return o}};for(let f of Ws(n))s=f.tokens?.call(h,s)||s;return Tw(s,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},h,u)}function Tw(e,t,n,r=ir(e)){let o=Ws(t),s=[],i={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t,c={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?c.style=t.rootStyle:c.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(let[g,k]of Object.entries(t.meta||{}))g.startsWith("_")||(c[g]=k);let u={type:"element",tagName:"pre",properties:c,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},m=[],h={...n,structure:a,addClassToHast:sf,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return i},get pre(){return u},get code(){return d},get lines(){return m}};if(e.forEach((g,k)=>{k&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
34
+ `}));let b={type:"element",tagName:"span",properties:{class:"line"},children:[]},S=0;for(let R of g){let v={type:"element",tagName:"span",properties:{...R.htmlAttrs},children:[{type:"text",value:R.content}]},_=Pl(R.htmlStyle||Us(R));_&&(v.properties.style=_);for(let B of o)v=B?.span?.call(h,v,k+1,S,b,R)||v;a==="inline"?i.children.push(v):a==="classic"&&b.children.push(v),S+=R.content.length}if(a==="classic"){for(let R of o)b=R?.line?.call(h,b,k+1)||b;m.push(b),s.push(b)}else a==="inline"&&m.push(b)}),a==="classic"){for(let g of o)d=g?.code?.call(h,d)||d;u.children.push(d);for(let g of o)u=g?.pre?.call(h,u)||u;i.children.push(u)}else if(a==="inline"){let g=[],k={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let S of i.children)S.type==="element"&&S.tagName==="br"?(g.push(k),k={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(S.type==="element"||S.type==="text")&&k.children.push(S);g.push(k);let b={type:"element",tagName:"code",properties:{},children:g};for(let S of o)b=S?.code?.call(h,b)||b;i.children=[];for(let S=0;S<b.children.length;S++){S>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});let R=b.children[S];R.type==="element"&&i.children.push(...R.children)}}let f=i;for(let g of o)f=g?.root?.call(h,f)||f;return r&&so(f,r),f}function Cw(e){return e.map(t=>{let n=[],r="",o;return t.forEach((s,i)=>{let a=!(s.fontStyle&&(s.fontStyle&de.Underline||s.fontStyle&de.Strikethrough));a&&cf.test(s.content)&&t[i+1]?(o===void 0&&(o=s.offset),r+=s.content):r?(a?n.push({...s,offset:o,content:r+s.content}):n.push({content:r,offset:o},s),o=void 0,r=""):n.push(s)}),n})}function _w(e){return e.map(t=>t.flatMap(n=>{if(cf.test(n.content))return n;let r=n.content.match(Sw);if(!r)return n;let[,o,s,i]=r;if(!o&&!i)return n;let a=[{...n,offset:n.offset+o.length,content:s}];return o&&a.unshift({content:o,offset:n.offset}),i&&a.push({content:i,offset:n.offset+o.length+s.length}),a}))}function Rw(e){return e.map(t=>{let n=[];for(let r of t){if(n.length===0){n.push({...r});continue}let o=n.at(-1),s=Pl(o.htmlStyle||Us(o)),i=Pl(r.htmlStyle||Us(r)),a=o.fontStyle&&(o.fontStyle&de.Underline||o.fontStyle&de.Strikethrough),l=r.fontStyle&&(r.fontStyle&de.Underline||r.fontStyle&de.Strikethrough);!a&&!l&&s===i?o.content+=r.content:n.push({...r})}return n})}var vw=El;function Aw(e,t,n){let r={meta:{},options:n,codeToHast:(s,i)=>Vs(e,s,i),codeToTokens:(s,i)=>Hs(e,s,i)},o=vw(Vs(e,t,n,r));for(let s of Ws(n))o=s.postprocess?.call(r,o,n)||o;return o}async function Ew(e){let t=await hl(e);return{getLastGrammarState:(...n)=>Cp(t,...n),codeToTokensBase:(n,r)=>Ll(t,n,r),codeToTokensWithThemes:(n,r)=>Ls(t,n,r),codeToTokens:(n,r)=>Hs(t,n,r),codeToHast:(n,r)=>Vs(t,n,r),codeToHtml:(n,r)=>Aw(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function uf(e){let t=e.langs,n=e.themes,r=e.engine;async function o(s){function i(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,pl(d))return[];let m=t[d];if(!m)throw new oe(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}function a(d){if(fl(d))return"none";if(typeof d=="string"){let m=n[d];if(!m)throw new oe(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}let l=(s.themes??[]).map(d=>a(d)),c=(s.langs??[]).map(d=>i(d)),u=await Ew({engine:s.engine??r(),...s,themes:l,langs:c});return{...u,loadLanguage(...d){return u.loadLanguage(...d.map(i))},loadTheme(...d){return u.loadTheme(...d.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return o}function Iw(e){let t;async function n(r={}){if(t){let o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}else{t=e({...r,themes:[],langs:[]});let o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}}return n}function df(e,t){let n=Iw(e);async function r(o,s){let i=await n({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),a=await t?.guessEmbeddedLanguages?.(o,s.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(o){return n(o)},async codeToHtml(o,s){return(await r(o,s)).codeToHtml(o,s)},async codeToHast(o,s){return(await r(o,s)).codeToHast(o,s)},async codeToTokens(o,s){return(await r(o,s)).codeToTokens(o,s)},async codeToTokensBase(o,s){return(await r(o,s)).codeToTokensBase(o,s)},async codeToTokensWithThemes(o,s){return(await r(o,s)).codeToTokensWithThemes(o,s)},async getLastGrammarState(o,s){return(await n({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(o,s)}}}var pf=rr({bundledLanguages:()=>Yr,bundledLanguagesAlias:()=>Zr,bundledLanguagesBase:()=>Jr,bundledLanguagesInfo:()=>or,bundledThemes:()=>eo,bundledThemesInfo:()=>Qr,codeToHast:()=>Ol,codeToHtml:()=>$l,codeToTokens:()=>Dl,codeToTokensBase:()=>co,codeToTokensWithThemes:()=>Nl,createHighlighter:()=>zs,getLastGrammarState:()=>Ml,getSingletonHighlighter:()=>uo}),zs=uf({langs:Yr,themes:eo,engine:()=>(0,ul.createOnigurumaEngine)(import("./wasm-FXCISVGQ.js"))}),{codeToHtml:$l,codeToHast:Ol,codeToTokens:Dl,codeToTokensBase:co,codeToTokensWithThemes:Nl,getSingletonHighlighter:uo,getLastGrammarState:Ml}=df(zs,{guessEmbeddedLanguages:af});p();p();var ff=class{patterns;options;regexps;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:o}=t;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(s=>{if(typeof s!="string")return s;let i=r?.get(s);if(i){if(i instanceof RegExp)return i;if(n)return null;throw i}try{let a=o(s);return r?.set(s,a),a}catch(a){if(r?.set(s,a),n)return null;throw a}})}findNextMatchSync(e,t,n){let r=typeof e=="string"?e:e.content,o=[];function s(i,a,l=0){return{index:i,captureIndices:a.indices.map(c=>c==null?{start:4294967295,end:4294967295,length:0}:{start:c[0]+l,end:c[1]+l,length:c[1]-c[0]})}}for(let i=0;i<this.regexps.length;i++){let a=this.regexps[i];if(a)try{a.lastIndex=t;let l=a.exec(r);if(!l)continue;if(l.index===t)return s(i,l,0);o.push([i,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(o.length){let i=Math.min(...o.map(a=>a[1].index));for(let[a,l,c]of o)if(l.index===i)return s(a,l,c)}return null}};p();p();p();p();p();function rn(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function mf(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var po=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),ke=String.raw;function Ft(e,t){if(e==null)throw new Error(t??"Value expected");return e}var wf=ke`\[\^?`,kf=`c.? | C(?:-.?)?|${ke`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${ke`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${ke`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${ke`o\{[^\}]*\}?`}|${ke`\d{1,3}`}`,Fl=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,qs=new RegExp(ke`
36
35
  \\ (?:
37
- ${yf}
36
+ ${kf}
38
37
  | [gk]<[^>]*>?
39
38
  | [gk]'[^']*'?
40
39
  | .
@@ -51,20 +50,20 @@ import{a as kn,b as ka,c as tn,d as Yn,e as kt,f as Sa,h as Ta}from"./chunk-V3LN
51
50
  )?
52
51
  | \*[^\)]*\)?
53
52
  )?
54
- | (?:${Gl.source})+
55
- | ${gf}
53
+ | (?:${Fl.source})+
54
+ | ${wf}
56
55
  | .
57
- `.replace(/\s+/g,""),"gsu"),Fl=new RegExp(we`
56
+ `.replace(/\s+/g,""),"gsu"),Bl=new RegExp(ke`
58
57
  \\ (?:
59
- ${yf}
58
+ ${kf}
60
59
  | .
61
60
  )
62
61
  | \[:(?:\^?\p{Alpha}+|\^):\]
63
- | ${gf}
62
+ | ${wf}
64
63
  | &&
65
64
  | .
66
- `.replace(/\s+/g,""),"gsu");function xf(e,t={}){let n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");let r=Vw(n.flags),o=[r.extended],s={captureGroup:n.rules.captureGroup,getCurrentModX(){return o.at(-1)},numOpenGroups:0,popModX(){o.pop()},pushModX(d){o.push(d)},replaceCurrentModX(d){o[o.length-1]=d},singleline:n.rules.singleline},i=[],a;for(zs.lastIndex=0;a=zs.exec(e);){let d=Rw(s,e,a[0],zs.lastIndex);d.tokens?i.push(...d.tokens):d.token&&i.push(d.token),d.lastIndex!==void 0&&(zs.lastIndex=d.lastIndex)}let l=[],c=0;i.filter(d=>d.type==="GroupOpen").forEach(d=>{d.kind==="capturing"?d.number=++c:d.raw==="("&&l.push(d)}),c||l.forEach((d,m)=>{d.kind="capturing",d.number=m+1});let u=c||l.length;return{tokens:i.map(d=>d.type==="EscapedNumber"?qw(d,u):d).flat(),flags:r}}function Rw(e,t,n,r){let[o,s]=n;if(n==="["||n==="[^"){let i=Aw(t,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(o==="\\"){if("AbBGyYzZ".includes(s))return{token:df(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Bw(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:wf(n)}}if(s==="K")return{token:kf("keep",n)};if(s==="N"||s==="R")return{token:In("newline",n,{negate:s==="N"})};if(s==="O")return{token:In("any",n)};if(s==="X")return{token:In("text_segment",n)};let i=bf(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(o==="("){if(s==="*")return{token:Uw(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:jw(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:ur("group",n)};if(n==="(?>")return{token:ur("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:ur(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ur("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:ur("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Dw(n)}}if(e.getCurrentModX()){if(n==="#"){let i=t.indexOf(`
67
- `,r);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(n)){let i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(t)?i.lastIndex:r}}}if(n===".")return{token:In("dot",n)};if(n==="^"||n==="$"){let i=e.singleline?{"^":we`\A`,$:we`\Z`}[n]:n;return{token:df(i,n)}}return n==="|"?{token:Iw(n)}:Gl.test(n)?{tokens:Kw(n)}:{token:Gt(rn(n),n)}}function Aw(e,t,n){let r=[pf(t[1]==="^",t)],o=1,s;for(Fl.lastIndex=n;s=Fl.exec(e);){let i=s[0];if(i[0]==="["&&i[1]!==":")o++,r.push(pf(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Gt(93,i));else if(o--,r.push(Pw(i)),!o)break}else{let a=Ew(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Fl.lastIndex||e.length}}function Ew(e){if(e[0]==="\\")return bf(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!fo.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return In("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Lw(e):e==="&&"?$w(e):Gt(rn(e),e)}function bf(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Gw(e);if("dDhHsSwW".includes(n))return Ww(e);if(e.startsWith(we`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Hw(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{let r=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),o=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),s=new TextEncoder;return[...o].map(i=>{let a=[...s.encode(i)].map(l=>`\\x${l.toString(16)}`).join("");return Gt(rn(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Gt(zw(e),e);if(ff.has(n))return Gt(ff.get(n),e);if(/\d/.test(n))return Ow(t,e);if(e==="\\")throw new Error(we`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Gt(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Iw(e){return{type:"Alternator",raw:e}}function df(e,t){return{type:"Assertion",kind:e,raw:t}}function wf(e){return{type:"Backreference",raw:e}}function Gt(e,t){return{type:"Character",value:e,raw:t}}function Pw(e){return{type:"CharacterClassClose",raw:e}}function Lw(e){return{type:"CharacterClassHyphen",raw:e}}function $w(e){return{type:"CharacterClassIntersector",raw:e}}function pf(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function In(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function kf(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Ft(n.flags),raw:t}}function Ow(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Dw(e){return{type:"GroupClose",raw:e}}function ur(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Nw(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Mw(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Bw(e){return{type:"Subroutine",raw:e}}var Fw=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),ff=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Gw(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Gt(rn(t.toUpperCase())-64,e)}function jw(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";let o=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),s=hf(n),i=hf(r),a={};if(s&&(a.enable=s),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(o),kf("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,ur("group",e,{...(s||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function Uw(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:o}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let s=o?o.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[i,a,l]=s,c=Fw.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof i=="string")throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(s.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return Nw(c,r??null,o?.split(",")??null,e)}function mf(e){let t=null,n,r;if(e[0]==="{"){let{minStr:o,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,i=1e5;if(+o>i||s&&+s>i)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+o,r=s===void 0?+o:s===""?1/0:+s,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Mw(t,n,r,e)}function Ww(e){let t=e[1].toLowerCase();return In({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Hw(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return In("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function hf(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Vw(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function zw(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function qw(e,t){let{raw:n,inCharClass:r}=e,o=n.slice(1);if(!r&&(o!=="0"&&o.length===1||o[0]!=="0"&&+o<=t))return[wf(n)];let s=[],i=o.match(/^[0-7]+|\d/g);for(let a=0;a<i.length;a++){let l=i[a],c;if(a===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(we`Octal encoded byte above 177 unsupported "${n}"`)}else c=rn(l);s.push(Gt(c,(a===0?"\\":"")+l))}return s}function Kw(e){let t=[],n=new RegExp(Gl,"gy"),r;for(;r=n.exec(e);){let o=r[0];if(o[0]==="{"){let s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(o);if(s){let{min:i,max:a}=s.groups;if(+i>+a&&o.endsWith("?")){n.lastIndex--,t.push(mf(o.slice(0,-1)));continue}}}t.push(mf(o))}return t}p();function qs(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function Sf(e){return Xw.has(e.type)}var Xw=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Xs(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=xf(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(m,h)=>{let f=r.tokens[s.nextIndex];switch(s.parent=m,s.nextIndex++,f.type){case"Alternator":return jt();case"Assertion":return Jw(f);case"Backreference":return Zw(f,s);case"Character":return dr(f.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return Yw(f,s,h);case"CharacterClassOpen":return Qw(f,s,h);case"CharacterSet":return ek(f,s);case"Directive":return ik(f.kind,{flags:f.flags});case"GroupOpen":return tk(f,s,h);case"NamedCallout":return lk(f.kind,f.tag,f.arguments);case"Quantifier":return nk(f,s);case"Subroutine":return rk(f,s);default:throw new Error(`Unexpected token type "${f.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:o},i=uk(ak(r.flags)),a=i.body[0];for(;s.nextIndex<r.tokens.length;){let m=o(a,{});m.type==="Alternative"?(i.body.push(m),a=m):a.body.push(m)}let{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:d}=s;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:m}of d)if(typeof m=="number"){if(m>l.length)throw new Error("Subroutine uses a group number that's not defined");m&&(l[m-1].isSubroutined=!0)}else if(u.has(m)){if(u.get(m).length>1)throw new Error(we`Subroutine uses a duplicate group name "\g<${m}>"`);u.get(m)[0].isSubroutined=!0}else throw new Error(we`Subroutine uses a group name that's not defined "\g<${m}>"`);return i}function Jw({kind:e}){return Js(Ft({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===we`\B`||e===we`\Y`})}function Zw({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),o=(s,i=!1)=>{let a=t.capturingGroups.length,l=!1;if(s>a)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Ks(i?a+1-s:s,{orphan:l})};if(n){let s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(s)return o(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Ks(r)}return o(+r)}function Yw(e,t,n){let{tokens:r,walk:o}=t,s=t.parent,i=s.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){let l=o(s,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&l.type==="Character")return s.body.pop(),sk(i,l);throw new Error("Invalid character class range")}return dr(rn("-"))}function Qw({negate:e},t,n){let{tokens:r,walk:o}=t,s=[mo()],i=r[t.nextIndex],a=_f(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")s.push(mo()),t.nextIndex++;else{let c=s.at(-1);c.body.push(o(c,n))}a=_f(r[t.nextIndex],i)}let l=mo({negate:e});return s.length===1?l.body=s[0].body:(l.kind="intersection",l.body=s.map(c=>c.body.length===1?c.body[0]:c)),t.nextIndex++,l}function ek({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i}=r;if(e==="property"){let a=pr(n);if(fo.has(a)&&!i?.has(a))e="posix",n=a;else return Pn(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i})}return e==="posix"?ck(n,{negate:t}):Zs(e,{negate:t})}function tk(e,t,n){let{tokens:r,capturingGroups:o,namedGroupsByName:s,skipLookbehindValidation:i,walk:a}=t,l=dk(e),c=l.type==="AbsenceFunction",u=Cf(l),d=u&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&uf(s,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let m=vf(r[t.nextIndex]);for(;m.type!=="GroupClose";){if(m.type==="Alternator")l.body.push(jt()),t.nextIndex++;else{let h=l.body.at(-1),f=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(h.body.push(f),(u||n.isInLookbehind)&&!i){let g="Lookbehind includes a pattern not allowed by Oniguruma";if(d||n.isInNegLookbehind){if(Tf(f)||f.type==="CapturingGroup")throw new Error(g)}else if(Tf(f)||Cf(f)&&f.negate)throw new Error(g)}}m=vf(r[t.nextIndex])}return t.nextIndex++,l}function nk({kind:e,min:t,max:n},r){let o=r.parent,s=o.body.at(-1);if(!s||!Sf(s))throw new Error("Quantifier requires a repeatable token");let i=Ul(e,t,n,s);return o.body.pop(),i}function rk({raw:e},t){let{capturingGroups:n,subroutines:r}=t,o=e.slice(3,-1),s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(o);if(s){let a=+s.groups.num,l=n.length;if(t.hasNumberedRef=!0,o={"":a,"+":l+a,"-":l+1-a}[s.groups.sign],o<1)throw new Error("Invalid subroutine number")}else o==="0"&&(o=0);let i=Wl(o);return r.push(i),i}function ok(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:ho(t?.body)}}function jt(e){return{type:"Alternative",body:Rf(e?.body)}}function Js(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function Ks(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function jl(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!pk(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:ho(t?.body)}}function dr(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function mo(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Rf(e?.body)}}function sk(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Zs(e,t){let n=!!t?.negate,r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function ik(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Ft(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function ak(e){return{type:"Flags",...e}}function Ze(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:ho(e?.body)}}function on(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:ho(e?.body)}}function lk(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function ck(e,t){let n=!!t?.negate;if(!fo.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function Ul(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function uk(e,t){return{type:"Regex",body:ho(t?.body),flags:e}}function Wl(e){return{type:"Subroutine",ref:e}}function Pn(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(pr(e));if(!r){if(n.normalizeUnknownPropertyNames)r=fk(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(we`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function dk({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return ok("repeater");case"atomic":return Ze({atomic:!0});case"capturing":return jl(o,{name:n});case"group":return Ze({flags:e});case"lookahead":case"lookbehind":return on({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function ho(e){if(e===void 0)e=[jt()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Rf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Tf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Cf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function pk(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function fk(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function pr(e){return e.replace(/[- _]+/g,"").toLowerCase()}function _f(e,t){let n=t;return Ft(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function vf(e){return Ft(e,"Unclosed group")}p();function Ln(e,t,n=null){function r(s,i){for(let a=0;a<s.length;a++){let l=o(s[a],i,a,s);a=Math.max(-1,a+l)}}function o(s,i=null,a=null,l=null){let c=0,u=!1,d={node:s,parent:i,key:a,container:l,root:e,remove(){Ys(l).splice(Math.max(0,fr(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Ys(l).splice(fr(a)+1)},removeAllPrevSiblings(){let w=fr(a)+c;return c-=w,Ys(l).splice(0,Math.max(0,w))},replaceWith(w,S={}){let v=!!S.traverse;l?l[Math.max(0,fr(a)+c)]=w:Ft(i,"Can't replace root node")[a]=w,v&&o(w,i,a,l),u=!0},replaceWithMultiple(w,S={}){let v=!!S.traverse;if(Ys(l).splice(Math.max(0,fr(a)+c),1,...w),c+=w.length-1,v){let _=0;for(let E=0;E<w.length;E++)_+=o(w[E],i,fr(a)+E+_,l)}u=!0},skip(){u=!0}},{type:m}=s,h=t["*"],f=t[m],g=typeof h=="function"?h:h?.enter,b=typeof f=="function"?f:f?.enter;if(g?.(d,n),b?.(d,n),!u)switch(m){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(s.min,s,"min"),o(s.max,s,"max");break;case"Quantifier":o(s.body,s,"body");break;case"Regex":r(s.body,s),o(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return f?.exit?.(d,n),h?.exit?.(d,n),c}return o(e),e}function Ys(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function fr(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}p();p();p();var Af=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Ef(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function If(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}p();var Ue=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function go(e,t,n,r){let o=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1],i=0,a="";for(let l of e.matchAll(o)){let{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===Ue.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?Ue.CHAR_CLASS:Ue.DEFAULT,negated:s[s.length-1]}):a+=n;continue}c[0]==="["?(i++,s.push(c[1]==="^")):c==="]"&&i&&(i--,s.pop()),a+=c}return a}function Hl(e,t,n,r){go(e,t,n,r)}function mk(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let o=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");o.lastIndex=n;let s=0,i;for(;i=o.exec(e);){let{0:a,groups:{$skip:l}}=i;if(!l&&(!r||r===Ue.DEFAULT==!s))return i;a==="["?s++:a==="]"&&s&&s--,o.lastIndex==i.index&&o.lastIndex++}return null}function yo(e,t,n){return!!mk(e,t,0,n)}function Pf(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,s=1,i;for(;i=n.exec(e);){let[a]=i;if(a==="[")o++;else if(o)a==="]"&&o--;else if(a==="(")s++;else if(a===")"&&(s--,!s)){r=i.index;break}}return e.slice(t,r)}var Lf=new RegExp(String.raw`(?<noncapturingStart>${Af})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function zl(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let o="(?>",s="(?:(?=(",i=[0],a=[],l=0,c=0,u=NaN,d;do{d=!1;let m=0,h=0,f=!1,g;for(Lf.lastIndex=Number.isNaN(u)?0:u+s.length;g=Lf.exec(e);){let{0:b,index:w,groups:{capturingStart:S,noncapturingStart:v}}=g;if(b==="[")m++;else if(m)b==="]"&&m--;else if(b===o&&!f)u=w,f=!0;else if(f&&v)h++;else if(S)f?h++:(l++,i.push(l+c));else if(b===")"&&f){if(!h){c++;let _=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+o.length,w)}))<$$${_}>)${e.slice(w+1)}`,d=!0,a.push(_),Ef(n,_),r.size){let E=new Map;r.forEach((M,U)=>{E.set(U>=_?U+1:U,M.map(T=>T>=_?T+1:T))}),r=E}break}h--}}}while(d);return n.push(...a),e=go(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:m,groups:{backrefNum:h,wrappedBackrefNum:f}})=>{if(h){let g=+h;if(g>i.length-1)throw new Error(`Backref "${m}" greater than number of captures`);return`\\${i[g]}`}return`\\${f}`},Ue.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var $f=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Vl=new RegExp(String.raw`
65
+ `.replace(/\s+/g,""),"gsu");function Sf(e,t={}){let n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");let r=Xw(n.flags),o=[r.extended],s={captureGroup:n.rules.captureGroup,getCurrentModX(){return o.at(-1)},numOpenGroups:0,popModX(){o.pop()},pushModX(d){o.push(d)},replaceCurrentModX(d){o[o.length-1]=d},singleline:n.rules.singleline},i=[],a;for(qs.lastIndex=0;a=qs.exec(e);){let d=Pw(s,e,a[0],qs.lastIndex);d.tokens?i.push(...d.tokens):d.token&&i.push(d.token),d.lastIndex!==void 0&&(qs.lastIndex=d.lastIndex)}let l=[],c=0;i.filter(d=>d.type==="GroupOpen").forEach(d=>{d.kind==="capturing"?d.number=++c:d.raw==="("&&l.push(d)}),c||l.forEach((d,m)=>{d.kind="capturing",d.number=m+1});let u=c||l.length;return{tokens:i.map(d=>d.type==="EscapedNumber"?Zw(d,u):d).flat(),flags:r}}function Pw(e,t,n,r){let[o,s]=n;if(n==="["||n==="[^"){let i=Lw(t,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(o==="\\"){if("AbBGyYzZ".includes(s))return{token:hf(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Uw(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Cf(n)}}if(s==="K")return{token:_f("keep",n)};if(s==="N"||s==="R")return{token:En("newline",n,{negate:s==="N"})};if(s==="O")return{token:En("any",n)};if(s==="X")return{token:En("text_segment",n)};let i=Tf(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(o==="("){if(s==="*")return{token:zw(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:Vw(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:ar("group",n)};if(n==="(?>")return{token:ar("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:ar(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ar("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:ar("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Fw(n)}}if(e.getCurrentModX()){if(n==="#"){let i=t.indexOf(`
66
+ `,r);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(n)){let i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(t)?i.lastIndex:r}}}if(n===".")return{token:En("dot",n)};if(n==="^"||n==="$"){let i=e.singleline?{"^":ke`\A`,$:ke`\Z`}[n]:n;return{token:hf(i,n)}}return n==="|"?{token:Ow(n)}:Fl.test(n)?{tokens:Yw(n)}:{token:Gt(rn(n),n)}}function Lw(e,t,n){let r=[gf(t[1]==="^",t)],o=1,s;for(Bl.lastIndex=n;s=Bl.exec(e);){let i=s[0];if(i[0]==="["&&i[1]!==":")o++,r.push(gf(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Gt(93,i));else if(o--,r.push(Dw(i)),!o)break}else{let a=$w(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Bl.lastIndex||e.length}}function $w(e){if(e[0]==="\\")return Tf(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!po.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return En("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Nw(e):e==="&&"?Mw(e):Gt(rn(e),e)}function Tf(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Hw(e);if("dDhHsSwW".includes(n))return qw(e);if(e.startsWith(ke`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Kw(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{let r=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),o=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),s=new TextEncoder;return[...o].map(i=>{let a=[...s.encode(i)].map(l=>`\\x${l.toString(16)}`).join("");return Gt(rn(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Gt(Jw(e),e);if(yf.has(n))return Gt(yf.get(n),e);if(/\d/.test(n))return Bw(t,e);if(e==="\\")throw new Error(ke`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Gt(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Ow(e){return{type:"Alternator",raw:e}}function hf(e,t){return{type:"Assertion",kind:e,raw:t}}function Cf(e){return{type:"Backreference",raw:e}}function Gt(e,t){return{type:"Character",value:e,raw:t}}function Dw(e){return{type:"CharacterClassClose",raw:e}}function Nw(e){return{type:"CharacterClassHyphen",raw:e}}function Mw(e){return{type:"CharacterClassIntersector",raw:e}}function gf(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function En(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function _f(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Ft(n.flags),raw:t}}function Bw(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Fw(e){return{type:"GroupClose",raw:e}}function ar(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Gw(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function jw(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Uw(e){return{type:"Subroutine",raw:e}}var Ww=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),yf=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Hw(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Gt(rn(t.toUpperCase())-64,e)}function Vw(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";let o=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),s=bf(n),i=bf(r),a={};if(s&&(a.enable=s),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(o),_f("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,ar("group",e,{...(s||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function zw(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:o}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let s=o?o.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[i,a,l]=s,c=Ww.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof i=="string")throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(s.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return Gw(c,r??null,o?.split(",")??null,e)}function xf(e){let t=null,n,r;if(e[0]==="{"){let{minStr:o,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,i=1e5;if(+o>i||s&&+s>i)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+o,r=s===void 0?+o:s===""?1/0:+s,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return jw(t,n,r,e)}function qw(e){let t=e[1].toLowerCase();return En({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Kw(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return En("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function bf(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Xw(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function Jw(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Zw(e,t){let{raw:n,inCharClass:r}=e,o=n.slice(1);if(!r&&(o!=="0"&&o.length===1||o[0]!=="0"&&+o<=t))return[Cf(n)];let s=[],i=o.match(/^[0-7]+|\d/g);for(let a=0;a<i.length;a++){let l=i[a],c;if(a===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(ke`Octal encoded byte above 177 unsupported "${n}"`)}else c=rn(l);s.push(Gt(c,(a===0?"\\":"")+l))}return s}function Yw(e){let t=[],n=new RegExp(Fl,"gy"),r;for(;r=n.exec(e);){let o=r[0];if(o[0]==="{"){let s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(o);if(s){let{min:i,max:a}=s.groups;if(+i>+a&&o.endsWith("?")){n.lastIndex--,t.push(xf(o.slice(0,-1)));continue}}}t.push(xf(o))}return t}p();function Ks(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function Rf(e){return Qw.has(e.type)}var Qw=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Js(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Sf(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(m,h)=>{let f=r.tokens[s.nextIndex];switch(s.parent=m,s.nextIndex++,f.type){case"Alternator":return jt();case"Assertion":return ek(f);case"Backreference":return tk(f,s);case"Character":return lr(f.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return nk(f,s,h);case"CharacterClassOpen":return rk(f,s,h);case"CharacterSet":return ok(f,s);case"Directive":return uk(f.kind,{flags:f.flags});case"GroupOpen":return sk(f,s,h);case"NamedCallout":return pk(f.kind,f.tag,f.arguments);case"Quantifier":return ik(f,s);case"Subroutine":return ak(f,s);default:throw new Error(`Unexpected token type "${f.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:o},i=mk(dk(r.flags)),a=i.body[0];for(;s.nextIndex<r.tokens.length;){let m=o(a,{});m.type==="Alternative"?(i.body.push(m),a=m):a.body.push(m)}let{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:d}=s;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:m}of d)if(typeof m=="number"){if(m>l.length)throw new Error("Subroutine uses a group number that's not defined");m&&(l[m-1].isSubroutined=!0)}else if(u.has(m)){if(u.get(m).length>1)throw new Error(ke`Subroutine uses a duplicate group name "\g<${m}>"`);u.get(m)[0].isSubroutined=!0}else throw new Error(ke`Subroutine uses a group name that's not defined "\g<${m}>"`);return i}function ek({kind:e}){return Zs(Ft({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===ke`\B`||e===ke`\Y`})}function tk({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),o=(s,i=!1)=>{let a=t.capturingGroups.length,l=!1;if(s>a)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Xs(i?a+1-s:s,{orphan:l})};if(n){let s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(s)return o(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Xs(r)}return o(+r)}function nk(e,t,n){let{tokens:r,walk:o}=t,s=t.parent,i=s.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){let l=o(s,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&l.type==="Character")return s.body.pop(),ck(i,l);throw new Error("Invalid character class range")}return lr(rn("-"))}function rk({negate:e},t,n){let{tokens:r,walk:o}=t,s=[fo()],i=r[t.nextIndex],a=Ef(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")s.push(fo()),t.nextIndex++;else{let c=s.at(-1);c.body.push(o(c,n))}a=Ef(r[t.nextIndex],i)}let l=fo({negate:e});return s.length===1?l.body=s[0].body:(l.kind="intersection",l.body=s.map(c=>c.body.length===1?c.body[0]:c)),t.nextIndex++,l}function ok({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i}=r;if(e==="property"){let a=cr(n);if(po.has(a)&&!i?.has(a))e="posix",n=a;else return In(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i})}return e==="posix"?fk(n,{negate:t}):Ys(e,{negate:t})}function sk(e,t,n){let{tokens:r,capturingGroups:o,namedGroupsByName:s,skipLookbehindValidation:i,walk:a}=t,l=hk(e),c=l.type==="AbsenceFunction",u=Af(l),d=u&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&mf(s,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let m=If(r[t.nextIndex]);for(;m.type!=="GroupClose";){if(m.type==="Alternator")l.body.push(jt()),t.nextIndex++;else{let h=l.body.at(-1),f=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(h.body.push(f),(u||n.isInLookbehind)&&!i){let g="Lookbehind includes a pattern not allowed by Oniguruma";if(d||n.isInNegLookbehind){if(vf(f)||f.type==="CapturingGroup")throw new Error(g)}else if(vf(f)||Af(f)&&f.negate)throw new Error(g)}}m=If(r[t.nextIndex])}return t.nextIndex++,l}function ik({kind:e,min:t,max:n},r){let o=r.parent,s=o.body.at(-1);if(!s||!Rf(s))throw new Error("Quantifier requires a repeatable token");let i=jl(e,t,n,s);return o.body.pop(),i}function ak({raw:e},t){let{capturingGroups:n,subroutines:r}=t,o=e.slice(3,-1),s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(o);if(s){let a=+s.groups.num,l=n.length;if(t.hasNumberedRef=!0,o={"":a,"+":l+a,"-":l+1-a}[s.groups.sign],o<1)throw new Error("Invalid subroutine number")}else o==="0"&&(o=0);let i=Ul(o);return r.push(i),i}function lk(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:mo(t?.body)}}function jt(e){return{type:"Alternative",body:Pf(e?.body)}}function Zs(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function Xs(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function Gl(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!gk(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:mo(t?.body)}}function lr(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function fo(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Pf(e?.body)}}function ck(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Ys(e,t){let n=!!t?.negate,r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function uk(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Ft(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function dk(e){return{type:"Flags",...e}}function Ze(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:mo(e?.body)}}function on(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:mo(e?.body)}}function pk(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function fk(e,t){let n=!!t?.negate;if(!po.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function jl(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function mk(e,t){return{type:"Regex",body:mo(t?.body),flags:e}}function Ul(e){return{type:"Subroutine",ref:e}}function In(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(cr(e));if(!r){if(n.normalizeUnknownPropertyNames)r=yk(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(ke`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function hk({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return lk("repeater");case"atomic":return Ze({atomic:!0});case"capturing":return Gl(o,{name:n});case"group":return Ze({flags:e});case"lookahead":case"lookbehind":return on({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function mo(e){if(e===void 0)e=[jt()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Pf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function vf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Af(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function gk(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function yk(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function cr(e){return e.replace(/[- _]+/g,"").toLowerCase()}function Ef(e,t){let n=t;return Ft(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function If(e){return Ft(e,"Unclosed group")}p();function Pn(e,t,n=null){function r(s,i){for(let a=0;a<s.length;a++){let l=o(s[a],i,a,s);a=Math.max(-1,a+l)}}function o(s,i=null,a=null,l=null){let c=0,u=!1,d={node:s,parent:i,key:a,container:l,root:e,remove(){Qs(l).splice(Math.max(0,ur(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Qs(l).splice(ur(a)+1)},removeAllPrevSiblings(){let b=ur(a)+c;return c-=b,Qs(l).splice(0,Math.max(0,b))},replaceWith(b,S={}){let R=!!S.traverse;l?l[Math.max(0,ur(a)+c)]=b:Ft(i,"Can't replace root node")[a]=b,R&&o(b,i,a,l),u=!0},replaceWithMultiple(b,S={}){let R=!!S.traverse;if(Qs(l).splice(Math.max(0,ur(a)+c),1,...b),c+=b.length-1,R){let v=0;for(let _=0;_<b.length;_++)v+=o(b[_],i,ur(a)+_+v,l)}u=!0},skip(){u=!0}},{type:m}=s,h=t["*"],f=t[m],g=typeof h=="function"?h:h?.enter,k=typeof f=="function"?f:f?.enter;if(g?.(d,n),k?.(d,n),!u)switch(m){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(s.min,s,"min"),o(s.max,s,"max");break;case"Quantifier":o(s.body,s,"body");break;case"Regex":r(s.body,s),o(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return f?.exit?.(d,n),h?.exit?.(d,n),c}return o(e),e}function Qs(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function ur(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}p();p();p();var Lf=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function $f(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Of(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}p();var je=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function ho(e,t,n,r){let o=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1],i=0,a="";for(let l of e.matchAll(o)){let{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===je.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?je.CHAR_CLASS:je.DEFAULT,negated:s[s.length-1]}):a+=n;continue}c[0]==="["?(i++,s.push(c[1]==="^")):c==="]"&&i&&(i--,s.pop()),a+=c}return a}function Wl(e,t,n,r){ho(e,t,n,r)}function xk(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let o=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");o.lastIndex=n;let s=0,i;for(;i=o.exec(e);){let{0:a,groups:{$skip:l}}=i;if(!l&&(!r||r===je.DEFAULT==!s))return i;a==="["?s++:a==="]"&&s&&s--,o.lastIndex==i.index&&o.lastIndex++}return null}function go(e,t,n){return!!xk(e,t,0,n)}function Df(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,s=1,i;for(;i=n.exec(e);){let[a]=i;if(a==="[")o++;else if(o)a==="]"&&o--;else if(a==="(")s++;else if(a===")"&&(s--,!s)){r=i.index;break}}return e.slice(t,r)}var Nf=new RegExp(String.raw`(?<noncapturingStart>${Lf})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Vl(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let o="(?>",s="(?:(?=(",i=[0],a=[],l=0,c=0,u=NaN,d;do{d=!1;let m=0,h=0,f=!1,g;for(Nf.lastIndex=Number.isNaN(u)?0:u+s.length;g=Nf.exec(e);){let{0:k,index:b,groups:{capturingStart:S,noncapturingStart:R}}=g;if(k==="[")m++;else if(m)k==="]"&&m--;else if(k===o&&!f)u=b,f=!0;else if(f&&R)h++;else if(S)f?h++:(l++,i.push(l+c));else if(k===")"&&f){if(!h){c++;let v=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+o.length,b)}))<$$${v}>)${e.slice(b+1)}`,d=!0,a.push(v),$f(n,v),r.size){let _=new Map;r.forEach((B,j)=>{_.set(j>=v?j+1:j,B.map(D=>D>=v?D+1:D))}),r=_}break}h--}}}while(d);return n.push(...a),e=ho(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:m,groups:{backrefNum:h,wrappedBackrefNum:f}})=>{if(h){let g=+h;if(g>i.length-1)throw new Error(`Backref "${m}" greater than number of captures`);return`\\${i[g]}`}return`\\${f}`},je.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var Mf=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Hl=new RegExp(String.raw`
68
67
  \\(?: \d+
69
68
  | c[A-Za-z]
70
69
  | [gk]<[^>]+>
@@ -77,9 +76,9 @@ import{a as kn,b as ka,c as tn,d as Yn,e as kt,f as Sa,h as Ta}from"./chunk-V3LN
77
76
  | [A-Za-z\-]+:
78
77
  | \(DEFINE\)
79
78
  ))?
80
- | (?<qBase>${$f})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
79
+ | (?<qBase>${Mf})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
81
80
  | \\?.
82
- `.replace(/\s+/g,""),"gsu");function ql(e){if(!new RegExp(`${$f}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,o="",s=0,i;for(Vl.lastIndex=0;i=Vl.exec(e);){let{0:a,index:l,groups:{qBase:c,qMod:u,invalidQ:d}}=i;if(a==="[")s||(r=l),s++;else if(a==="]")s?s--:r=null;else if(!s)if(u==="+"&&o&&!o.startsWith("(")){if(d)throw new Error(`Invalid quantifier "${a}"`);let m=-1;if(/^\{\d+\}$/.test(c))e=If(e,l+c.length,u,"");else{if(o===")"||o==="]"){let h=o===")"?n:r;if(h===null)throw new Error(`Invalid unmatched "${o}"`);e=`${e.slice(0,h)}(?>${e.slice(h,l)}${c})${e.slice(l+a.length)}`}else e=`${e.slice(0,l-o.length)}(?>${o}${c})${e.slice(l+a.length)}`;m+=4}Vl.lastIndex+=m}else a[0]==="("?t.push(l):a===")"&&(n=t.length?t.pop():null);o=a}return{pattern:e}}p();p();var at=String.raw,hk=at`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Xl=at`\(\?R=(?<rDepth>[^\)]+)\)|${hk}`,Qs=at`\(\?<(?![=!])(?<captureName>[^>]+)>`,Bf=at`${Qs}|(?<unnamed>\()(?!\?)`,$n=new RegExp(at`${Qs}|${Xl}|\(\?|\\?.`,"gsu"),Kl="Cannot use multiple overlapping recursions";function Ff(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},o=t?.captureTransfers??new Map;if(!new RegExp(Xl,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:n};if(r==="plugin"&&yo(e,at`\(\?\(DEFINE\)`,Ue.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let s=[],i=yo(e,at`\\[1-9]`,Ue.DEFAULT),a=new Map,l=[],c=!1,u=0,d=0,m;for($n.lastIndex=0;m=$n.exec(e);){let{0:h,groups:{captureName:f,rDepth:g,gRNameOrNum:b,gRDepth:w}}=m;if(h==="[")u++;else if(u)h==="]"&&u--;else if(g){if(Of(g),c)throw new Error(Kl);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let S=e.slice(0,m.index),v=e.slice($n.lastIndex);if(yo(v,Xl,Ue.DEFAULT))throw new Error(Kl);let _=+g-1;e=Df(S,v,_,!1,n,s,d),o=Mf(o,S,_,s.length,0,d);break}else if(b){Of(w);let S=!1;for(let $ of l)if($.name===b||$.num===+b){if(S=!0,$.hasRecursedWithin)throw new Error(Kl);break}if(!S)throw new Error(at`Recursive \g cannot be used outside the referenced group "${r==="external"?b:at`\g<${b}&R=${w}>`}"`);let v=a.get(b),_=Pf(e,v);if(i&&yo(_,at`${Qs}|\((?!\?)`,Ue.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let E=e.slice(v,m.index),M=_.slice(E.length+h.length),U=s.length,T=+w-1,N=Df(E,M,T,!0,n,s,d);o=Mf(o,E,T,s.length-U,U,d);let F=e.slice(0,v),q=e.slice(v+_.length);e=`${F}${N}${q}`,$n.lastIndex+=N.length-h.length-E.length-M.length,l.forEach($=>$.hasRecursedWithin=!0),c=!0}else if(f)d++,a.set(String(d),$n.lastIndex),a.set(f,$n.lastIndex),l.push({num:d,name:f});else if(h[0]==="("){let S=h==="(";S&&(d++,a.set(String(d),$n.lastIndex)),l.push(S?{num:d}:{})}else h===")"&&l.pop()}return n.push(...s),{pattern:e,captureTransfers:o,hiddenCaptures:n}}function Of(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function Df(e,t,n,r,o,s,i){let a=new Set;r&&Hl(e+t,Qs,({groups:{captureName:c}})=>{a.add(c)},Ue.DEFAULT);let l=[n,r?a:null,o,s,i];return`${e}${Nf(`(?:${e}`,"forward",...l)}(?:)${Nf(`${t})`,"backward",...l)}${t}`}function Nf(e,t,n,r,o,s,i){let l=u=>t==="forward"?u+2:n-u+2-1,c="";for(let u=0;u<n;u++){let d=l(u);c+=go(e,at`${Bf}|\\k<(?<backref>[^>]+)>`,({0:m,groups:{captureName:h,unnamed:f,backref:g}})=>{if(g&&r&&!r.has(g))return m;let b=`_$${d}`;if(f||h){let w=i+s.length+1;return s.push(w),gk(o,w),f?m:`(?<${h}${b}>`}return at`\k<${g}${b}>`},Ue.DEFAULT)}return c}function gk(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Mf(e,t,n,r,o,s){if(e.size&&r){let i=0;Hl(t,Bf,()=>i++,Ue.DEFAULT);let a=s-i+o,l=new Map;return e.forEach((c,u)=>{let d=(r-i*n)/n,m=i*n,h=u>a+i?u+r:u,f=[];for(let g of c)if(g<=a)f.push(g);else if(g>a+i+d)f.push(g+r);else if(g<=a+i)for(let b=0;b<=n;b++)f.push(g+i*b);else for(let b=0;b<=n;b++)f.push(g+m+d*b);l.set(h,f)}),l}return e}var Ce=String.fromCodePoint,J=String.raw,ht={},ti=globalThis.RegExp;ht.flagGroups=(()=>{try{new ti("(?i:)")}catch{return!1}return!0})();ht.unicodeSets=(()=>{try{new ti("[[]]","v")}catch{return!1}return!0})();ht.bugFlagVLiteralHyphenIsRange=ht.unicodeSets?(()=>{try{new ti(J`[\d\-a]`,"v")}catch{return!0}return!1})():!1;ht.bugNestedClassIgnoresNegation=ht.unicodeSets&&new ti("[[^a]]","v").test("a");function ei(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function xo(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function ec(e,t){return Gf[e]>=Gf[t]}function yk(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Gf={ES2025:2025,ES2024:2024,ES2018:2018},xk={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function Vf(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!xk[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=ht.flagGroups?"ES2025":ht.unicodeSets?"ES2024":"ES2018"),t}var bk="[ -\r ]",wk=new Set([Ce(304),Ce(305)]),Ut=J`[\p{L}\p{M}\p{N}\p{Pc}]`;function zf(e){if(wk.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),o=Tk.get(n),s=kk.get(n),i=Sk.get(n);return[...r].length===1&&t.add(r),i&&t.add(i),o&&t.add(o),t.add(n),s&&t.add(s),[...t]}var nc=new Map(`C Other
81
+ `.replace(/\s+/g,""),"gsu");function zl(e){if(!new RegExp(`${Mf}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,o="",s=0,i;for(Hl.lastIndex=0;i=Hl.exec(e);){let{0:a,index:l,groups:{qBase:c,qMod:u,invalidQ:d}}=i;if(a==="[")s||(r=l),s++;else if(a==="]")s?s--:r=null;else if(!s)if(u==="+"&&o&&!o.startsWith("(")){if(d)throw new Error(`Invalid quantifier "${a}"`);let m=-1;if(/^\{\d+\}$/.test(c))e=Of(e,l+c.length,u,"");else{if(o===")"||o==="]"){let h=o===")"?n:r;if(h===null)throw new Error(`Invalid unmatched "${o}"`);e=`${e.slice(0,h)}(?>${e.slice(h,l)}${c})${e.slice(l+a.length)}`}else e=`${e.slice(0,l-o.length)}(?>${o}${c})${e.slice(l+a.length)}`;m+=4}Hl.lastIndex+=m}else a[0]==="("?t.push(l):a===")"&&(n=t.length?t.pop():null);o=a}return{pattern:e}}p();p();var at=String.raw,bk=at`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Kl=at`\(\?R=(?<rDepth>[^\)]+)\)|${bk}`,ei=at`\(\?<(?![=!])(?<captureName>[^>]+)>`,Uf=at`${ei}|(?<unnamed>\()(?!\?)`,Ln=new RegExp(at`${ei}|${Kl}|\(\?|\\?.`,"gsu"),ql="Cannot use multiple overlapping recursions";function Wf(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},o=t?.captureTransfers??new Map;if(!new RegExp(Kl,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:n};if(r==="plugin"&&go(e,at`\(\?\(DEFINE\)`,je.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let s=[],i=go(e,at`\\[1-9]`,je.DEFAULT),a=new Map,l=[],c=!1,u=0,d=0,m;for(Ln.lastIndex=0;m=Ln.exec(e);){let{0:h,groups:{captureName:f,rDepth:g,gRNameOrNum:k,gRDepth:b}}=m;if(h==="[")u++;else if(u)h==="]"&&u--;else if(g){if(Bf(g),c)throw new Error(ql);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let S=e.slice(0,m.index),R=e.slice(Ln.lastIndex);if(go(R,Kl,je.DEFAULT))throw new Error(ql);let v=+g-1;e=Ff(S,R,v,!1,n,s,d),o=jf(o,S,v,s.length,0,d);break}else if(k){Bf(b);let S=!1;for(let U of l)if(U.name===k||U.num===+k){if(S=!0,U.hasRecursedWithin)throw new Error(ql);break}if(!S)throw new Error(at`Recursive \g cannot be used outside the referenced group "${r==="external"?k:at`\g<${k}&R=${b}>`}"`);let R=a.get(k),v=Df(e,R);if(i&&go(v,at`${ei}|\((?!\?)`,je.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let _=e.slice(R,m.index),B=v.slice(_.length+h.length),j=s.length,D=+b-1,C=Ff(_,B,D,!0,n,s,d);o=jf(o,_,D,s.length-j,j,d);let J=e.slice(0,R),M=e.slice(R+v.length);e=`${J}${C}${M}`,Ln.lastIndex+=C.length-h.length-_.length-B.length,l.forEach(U=>U.hasRecursedWithin=!0),c=!0}else if(f)d++,a.set(String(d),Ln.lastIndex),a.set(f,Ln.lastIndex),l.push({num:d,name:f});else if(h[0]==="("){let S=h==="(";S&&(d++,a.set(String(d),Ln.lastIndex)),l.push(S?{num:d}:{})}else h===")"&&l.pop()}return n.push(...s),{pattern:e,captureTransfers:o,hiddenCaptures:n}}function Bf(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function Ff(e,t,n,r,o,s,i){let a=new Set;r&&Wl(e+t,ei,({groups:{captureName:c}})=>{a.add(c)},je.DEFAULT);let l=[n,r?a:null,o,s,i];return`${e}${Gf(`(?:${e}`,"forward",...l)}(?:)${Gf(`${t})`,"backward",...l)}${t}`}function Gf(e,t,n,r,o,s,i){let l=u=>t==="forward"?u+2:n-u+2-1,c="";for(let u=0;u<n;u++){let d=l(u);c+=ho(e,at`${Uf}|\\k<(?<backref>[^>]+)>`,({0:m,groups:{captureName:h,unnamed:f,backref:g}})=>{if(g&&r&&!r.has(g))return m;let k=`_$${d}`;if(f||h){let b=i+s.length+1;return s.push(b),wk(o,b),f?m:`(?<${h}${k}>`}return at`\k<${g}${k}>`},je.DEFAULT)}return c}function wk(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function jf(e,t,n,r,o,s){if(e.size&&r){let i=0;Wl(t,Uf,()=>i++,je.DEFAULT);let a=s-i+o,l=new Map;return e.forEach((c,u)=>{let d=(r-i*n)/n,m=i*n,h=u>a+i?u+r:u,f=[];for(let g of c)if(g<=a)f.push(g);else if(g>a+i+d)f.push(g+r);else if(g<=a+i)for(let k=0;k<=n;k++)f.push(g+i*k);else for(let k=0;k<=n;k++)f.push(g+m+d*k);l.set(h,f)}),l}return e}var Ce=String.fromCodePoint,Z=String.raw,ht={},ni=globalThis.RegExp;ht.flagGroups=(()=>{try{new ni("(?i:)")}catch{return!1}return!0})();ht.unicodeSets=(()=>{try{new ni("[[]]","v")}catch{return!1}return!0})();ht.bugFlagVLiteralHyphenIsRange=ht.unicodeSets?(()=>{try{new ni(Z`[\d\-a]`,"v")}catch{return!0}return!1})():!1;ht.bugNestedClassIgnoresNegation=ht.unicodeSets&&new ni("[[^a]]","v").test("a");function ti(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function yo(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Ql(e,t){return Hf[e]>=Hf[t]}function kk(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Hf={ES2025:2025,ES2024:2024,ES2018:2018},Sk={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function Xf(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!Sk[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=ht.flagGroups?"ES2025":ht.unicodeSets?"ES2024":"ES2018"),t}var Tk="[ -\r ]",Ck=new Set([Ce(304),Ce(305)]),Ut=Z`[\p{L}\p{M}\p{N}\p{Pc}]`;function Jf(e){if(Ck.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),o=vk.get(n),s=_k.get(n),i=Rk.get(n);return[...r].length===1&&t.add(r),i&&t.add(i),o&&t.add(o),t.add(n),s&&t.add(s),[...t]}var tc=new Map(`C Other
83
82
  Cc Control cntrl
84
83
  Cf Format
85
84
  Cn Unassigned
@@ -169,24 +168,28 @@ Uppercase Upper
169
168
  Variation_Selector VS
170
169
  White_Space space
171
170
  XID_Continue XIDC
172
- XID_Start XIDS`.split(/\s/).map(e=>[pr(e),e])),kk=new Map([["s",Ce(383)],[Ce(383),"s"]]),Sk=new Map([[Ce(223),Ce(7838)],[Ce(107),Ce(8490)],[Ce(229),Ce(8491)],[Ce(969),Ce(8486)]]),Tk=new Map([sn(453),sn(456),sn(459),sn(498),...Jl(8072,8079),...Jl(8088,8095),...Jl(8104,8111),sn(8124),sn(8140),sn(8188)]),Ck=new Map([["alnum",J`[\p{Alpha}\p{Nd}]`],["alpha",J`\p{Alpha}`],["ascii",J`\p{ASCII}`],["blank",J`[\p{Zs}\t]`],["cntrl",J`\p{Cc}`],["digit",J`\p{Nd}`],["graph",J`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",J`\p{Lower}`],["print",J`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",J`[\p{P}\p{S}]`],["space",J`\p{space}`],["upper",J`\p{Upper}`],["word",J`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",J`\p{AHex}`]]);function _k(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function sn(e){let t=Ce(e);return[t.toLowerCase(),t]}function Jl(e,t){return _k(e,t).map(n=>sn(n))}var qf=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function vk(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};Kf(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:ec(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Ln(e,Rk,r);let o={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},s={currentFlags:o,prevFlags:null,globalFlags:o,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};Ln(e,Ak,s);let i={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return Ln(e,Ek,i),e._originMap=s.groupOriginByCopy,e._strategy=r.strategy,e}var Rk={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:o}=e;if(o==="repeater"){let s=Ze();s.body[0].body.push(on({negate:!0,body:r}),Pn("Any"));let i=Ze();i.body[0].body.push(Ul("greedy",0,1/0,s)),n(ge(i,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let o=e.body.filter(s=>s.kind==="flags");for(let s=n+1;s<t.body.length;s++){let i=t.body[s];xo(r,i,[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Jf(t.get(e));if(n){let r=Ze({flags:n});r.body[0].body=e.body,e.body=[ge(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:o,remove:s,replaceWith:i},a){let{kind:l,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:m,wordIsAscii:h}=a;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")i(ge(on({body:[jt({body:[Js("string_end")]}),jt({body:[dr(10)]})]}),t));else if(l==="line_start")i(ge(Wt(J`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(m.has(e))o.flags.sticky=!0,s();else{let f=r[n-1];if(f&&Dk(f))i(ge(on({negate:!0}),t));else{if(d)throw new Error(J`Uses "\G" in a way that requires a subclass`);i(an(Js("string_start"),t)),a.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")i(ge(Wt(J`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!h&&!u){let f=`(?:(?<=${Ut})(?!${Ut})|(?<!${Ut})(?=${Ut}))`,g=`(?:(?<=${Ut})(?=${Ut})|(?<!${Ut})(?!${Ut}))`;i(ge(Wt(c?g:f),t))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Yl(n)&&(n=Zl(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Yl(r)&&(r=Zl(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){let r=mo({body:[e]});n(ge(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:o,digitIsAscii:s,spaceIsAscii:i,wordIsAscii:a}){let{kind:l,negate:c,value:u}=e;if(s&&(l==="digit"||u==="digit")){n(an(Zs("digit",{negate:c}),t));return}if(i&&(l==="space"||u==="space")){n(ge(Ql(Wt(bk),c),t));return}if(a&&(l==="word"||u==="word")){n(an(Zs("word",{negate:c}),t));return}if(l==="any")n(an(Pn("Any"),t));else if(l==="digit")n(an(Pn("Nd",{negate:c}),t));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(J`Use of "\X" requires non-strict accuracy`);let d="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",m=J`\p{RI}{2}|${d}(?:\u200D${d})*`;n(ge(Wt(J`(?>\r\n|${o?J`\p{RGI_Emoji}`:m}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(an(Pn("AHex",{negate:c}),t));else if(l==="newline")n(ge(Wt(c?`[^
171
+ XID_Start XIDS`.split(/\s/).map(e=>[cr(e),e])),_k=new Map([["s",Ce(383)],[Ce(383),"s"]]),Rk=new Map([[Ce(223),Ce(7838)],[Ce(107),Ce(8490)],[Ce(229),Ce(8491)],[Ce(969),Ce(8486)]]),vk=new Map([sn(453),sn(456),sn(459),sn(498),...Xl(8072,8079),...Xl(8088,8095),...Xl(8104,8111),sn(8124),sn(8140),sn(8188)]),Ak=new Map([["alnum",Z`[\p{Alpha}\p{Nd}]`],["alpha",Z`\p{Alpha}`],["ascii",Z`\p{ASCII}`],["blank",Z`[\p{Zs}\t]`],["cntrl",Z`\p{Cc}`],["digit",Z`\p{Nd}`],["graph",Z`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Z`\p{Lower}`],["print",Z`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Z`[\p{P}\p{S}]`],["space",Z`\p{space}`],["upper",Z`\p{Upper}`],["word",Z`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Z`\p{AHex}`]]);function Ek(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function sn(e){let t=Ce(e);return[t.toLowerCase(),t]}function Xl(e,t){return Ek(e,t).map(n=>sn(n))}var Zf=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Ik(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};Yf(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Ql(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Pn(e,Pk,r);let o={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},s={currentFlags:o,prevFlags:null,globalFlags:o,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};Pn(e,Lk,s);let i={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return Pn(e,$k,i),e._originMap=s.groupOriginByCopy,e._strategy=r.strategy,e}var Pk={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:o}=e;if(o==="repeater"){let s=Ze();s.body[0].body.push(on({negate:!0,body:r}),In("Any"));let i=Ze();i.body[0].body.push(jl("greedy",0,1/0,s)),n(ge(i,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let o=e.body.filter(s=>s.kind==="flags");for(let s=n+1;s<t.body.length;s++){let i=t.body[s];yo(r,i,[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=em(t.get(e));if(n){let r=Ze({flags:n});r.body[0].body=e.body,e.body=[ge(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:o,remove:s,replaceWith:i},a){let{kind:l,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:m,wordIsAscii:h}=a;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")i(ge(on({body:[jt({body:[Zs("string_end")]}),jt({body:[lr(10)]})]}),t));else if(l==="line_start")i(ge(Wt(Z`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(m.has(e))o.flags.sticky=!0,s();else{let f=r[n-1];if(f&&Fk(f))i(ge(on({negate:!0}),t));else{if(d)throw new Error(Z`Uses "\G" in a way that requires a subclass`);i(an(Zs("string_start"),t)),a.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")i(ge(Wt(Z`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!h&&!u){let f=`(?:(?<=${Ut})(?!${Ut})|(?<!${Ut})(?=${Ut}))`,g=`(?:(?<=${Ut})(?=${Ut})|(?<!${Ut})(?!${Ut}))`;i(ge(Wt(c?g:f),t))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Zl(n)&&(n=Jl(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Zl(r)&&(r=Jl(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){let r=fo({body:[e]});n(ge(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:o,digitIsAscii:s,spaceIsAscii:i,wordIsAscii:a}){let{kind:l,negate:c,value:u}=e;if(s&&(l==="digit"||u==="digit")){n(an(Ys("digit",{negate:c}),t));return}if(i&&(l==="space"||u==="space")){n(ge(Yl(Wt(Tk),c),t));return}if(a&&(l==="word"||u==="word")){n(an(Ys("word",{negate:c}),t));return}if(l==="any")n(an(In("Any"),t));else if(l==="digit")n(an(In("Nd",{negate:c}),t));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(Z`Use of "\X" requires non-strict accuracy`);let d="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",m=Z`\p{RI}{2}|${d}(?:\u200D${d})*`;n(ge(Wt(Z`(?>\r\n|${o?Z`\p{RGI_Emoji}`:m}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(an(In("AHex",{negate:c}),t));else if(l==="newline")n(ge(Wt(c?`[^
173
172
  ]`:`(?>\r
174
173
  ?|[
175
- \v\f\x85\u2028\u2029])`),t));else if(l==="posix")if(!o&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let d={graph:"!-~",print:" -~"}[u];c&&(d=`\0-${Ce(d.codePointAt(0)-1)}${Ce(d.codePointAt(2)+1)}-\u{10FFFF}`),n(ge(Wt(`[${d}]`),t))}else n(ge(Ql(Wt(Ck.get(u)),c),t));else if(l==="property")nc.has(pr(u))||(e.key="sc");else if(l==="space")n(an(Pn("space",{negate:c}),t));else if(l==="word")n(ge(Ql(Wt(Ut),c),t));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:o,removeAllPrevSiblings:s,removeAllNextSiblings:i}){let{kind:a,flags:l}=e;if(a==="flags")if(!l.enable&&!l.disable)r();else{let c=Ze({flags:l});c.body[0].body=i(),o(ge(c,t),{traverse:!0})}else if(a==="keep"){let c=n.body[0],d=n.body.length===1&&qs(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(t.parent!==d||d.body.length>1)throw new Error(J`Uses "\K" in a way that's unsupported`);let m=on({behind:!0});m.body[0].body=s(),o(ge(m,t))}else throw new Error(`Unexpected directive kind "${a}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(ge(on({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=Ze();t.body[0].body.push(e.body),e.body=ge(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,o=!1;for(let s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{let i=Yf(s.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):o=!0}r&&!o&&n.forEach(s=>t.add(s))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(J`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Yl(n)&&(n=Zl(n,t),e.ref=n)}},Ak={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:o}=e;r||n.set(e,[...t.get(o).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:o,groupsByName:s,multiplexCapturesToLeftByRef:i,openRefs:a,reffedNodesByReferencer:l}){let c=o.get(e);if(c&&a.has(e.number)){let d=an(jf(e.number),t);l.set(d,a.get(e.number)),n(d);return}a.set(e.number,e),i.set(e.number,[]),e.name&&xo(i,e.name,[]);let u=i.get(e.name??e.number);for(let d=0;d<u.length;d++){let m=u[d];if(c===m.node||c&&c===m.origin||e===m.origin){u.splice(d,1);break}}if(i.get(e.number).push({node:e,origin:c}),e.name&&i.get(e.name).push({node:e,origin:c}),e.name){let d=xo(s,e.name,new Map),m=!1;if(c)m=!0;else for(let h of d.values())if(!h.hasDuplicateNameToRemove){m=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:m})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=ei(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:o,ref:s}=e;if(o){let u=t;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===s||u.number===s)););r.reffedNodesByReferencer.set(e,u);return}let i=r.subroutineRefMap.get(s),a=s===0,l=a?jf(0):Xf(i,r.groupOriginByCopy,null),c=l;if(!a){let u=Jf(Lk(i,m=>m.type==="Group"&&!!m.flags)),d=u?ei(r.globalFlags,u):r.globalFlags;Ik(d,r.currentFlags)||(c=Ze({flags:$k(d)}),c.body[0].body.push(l))}n(ge(c,t),{traverse:!a})}},Ek={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let s=r.reffedNodesByReferencer.get(e).filter(i=>Pk(i,e));if(!s.length)n(ge(on({negate:!0}),t));else if(s.length>1){let i=Ze({atomic:!0,body:s.reverse().map(a=>jt({body:[Ks(a.number)]}))});n(ge(i,t))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){let o=jl();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Kf(e){Ln(e,{"*"({node:t,parent:n}){t.parent=n}})}function Ik(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Pk(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=Zf(n.parent);for(let o of r){if(o===n)break;if(o===e||Qf(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Xf(e,t,n,r){let o=Array.isArray(e)?[]:{};for(let[s,i]of Object.entries(e))s==="parent"?o.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?o[s]=Xf(i,t,o,n):(s==="type"&&i==="CapturingGroup"&&t.set(o,t.get(e)??e),o[s]=i);return o}function jf(e){let t=Wl(e);return t.isRecursive=!0,t}function Lk(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Zl(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function Jf(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(o=>{r.enable?.[o]&&(delete n.disable[o],n.enable[o]=!0),r.disable?.[o]&&(n.disable[o]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function $k({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Zf(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Yf(e){let t=e.find(n=>n.kind==="search_start"||Nk(n,{negate:!1})||!Ok(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){let n=[];for(let r of t.body){let o=Yf(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function Qf(e,t){let n=Zf(e)??[];for(let r of n)if(r===t||Qf(r,t))return!0;return!1}function Ok({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Dk(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function Nk(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&qs(e.body[0],{type:"Assertion",kind:"search_start"})}function Yl(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Wt(e,t){let r=Xs(e,{...t,unicodePropertyMap:nc}).body;return r.length>1||r[0].body.length>1?Ze({body:r}):r[0].body[0]}function Ql(e,t){return e.negate=t,e}function an(e,t){return e.parent=t,e}function ge(e,t){return Kf(e),e.parent=t,e}function Mk(e,t){let n=Vf(t),r=ec(n.target,"ES2024"),o=ec(n.target,"ES2025"),s=n.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,a=null;if(!o){let h=[e.flags.ignoreCase];Ln(e,Bk,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(f){h.push(f)},setHasCasedChar(){h.at(-1)?i=!0:a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!a)},c=e,u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!o&&i&&a),useFlagMods:o,useFlagV:r,verbose:n.verbose};function d(h){return u.lastNode=c,c=h,yk(Fk[h.type],`Unexpected node type "${h.type}"`)(h,u,d)}let m={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return r||(delete m.options.force.v,m.options.disable.v=!0,m.options.unicodeSetsPlugin=null),m._captureTransfers=new Map,m._hiddenCaptures=[],u.captureMap.forEach((h,f)=>{h.hidden&&m._hiddenCaptures.push(f),h.transferTo&&xo(m._captureTransfers,h.transferTo,[]).push(f)}),m}var Bk={"*":{enter({node:e},t){if(Wf(e)){let n=t.getCurrentModI();t.pushModI(e.flags?ei({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Wf(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){rc(Ce(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),em(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&qf.has(e.value)&&t.setHasCasedChar()}},Fk={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?J`\B`:J`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){let{body:r,name:o,number:s}=e,i={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(i.hidden=!0,s>a.number&&(i.transferTo=a.number)),t.captureMap.set(s,i),`(${o?`?<${o}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=Ce(e),r=mr(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&rc(n)){let o=zf(n);return t.inCharClass?o.join(""):o.length>1?`[${o.join("")}]`:o[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:o,parent:s}=e,{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(Hf)&&(i=[dr(45),...i.filter(c=>!Hf(c))]);let a=()=>`[${o?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ht.bugNestedClassIgnoresNegation)&&!o){let u=i.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){let d=Ze(),m=d.body[0];return d.parent=s,m.parent=d,i=i.filter(h=>!u.includes(h)),e.body=i,i.length?(e.parent=m,m.body.push(e)):d.body.pop(),u.forEach(h=>{let f=jt({body:[h]});h.parent=f,f.parent=d,d.body.push(f)}),n(d)}}t.inCharClass=!0;let c=a();return t.inCharClass=!1,c}let l=i[0];if(r==="union"&&!o&&l&&((!t.useFlagV||!t.verbose)&&s.kind==="union"&&!(ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&s.kind==="intersection"&&i.length===1&&l.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,o={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},s=mr(n,o),i=mr(r,o),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=em(e);Hk(l).forEach(u=>{a.add(Array.isArray(u)?`${mr(u[0],o)}-${mr(u[1],o)}`:mr(u,o))})}return`${s}-${i}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},o){if(e==="dot")return o.currentFlags.dotAll?o.appliedGlobalFlags.dotAll||o.useFlagMods?".":"[^]":J`[^\n]`;if(e==="digit")return t?J`\D`:J`\d`;if(e==="property"){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&qf.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?J`\P`:J`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?J`\W`:J`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},o,s){let i=o.currentFlags;n&&(o.currentFlags=ei(i,n));let a=t.map(s).join("|"),l=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?a:`(?${Vk(e,n,o.useFlagMods)}${a})`;return o.currentFlags=i,l},LookaroundAssertion({body:e,kind:t,negate:n},r,o){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(o).join("|")})`},Quantifier(e,t,n){return n(e.body)+zk(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");let r=n.recursionLimit;return t===0?`(?R=${r})`:J`\g<${t}&R=${r}>`}},Gk=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),jk=new Set(["-","\\","]","^","["]),Uk=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Uf=new Map([[9,J`\t`],[10,J`\n`],[11,J`\v`],[12,J`\f`],[13,J`\r`],[8232,J`\u2028`],[8233,J`\u2029`],[65279,J`\uFEFF`]]),Wk=new RegExp("^\\p{Cased}$","u");function rc(e){return Wk.test(e)}function em(e,t){let n=!!t?.firstOnly,r=e.min.value,o=e.max.value,s=[];if(r<65&&(o===65535||o>=131071)||r===65536&&o>=131071)return s;for(let i=r;i<=o;i++){let a=Ce(i);if(!rc(a))continue;let l=zf(a).filter(c=>{let u=c.codePointAt(0);return u<r||u>o});if(l.length&&(s.push(...l),n))break}return s}function mr(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Uf.has(e))return Uf.get(e);if(e<32||e>126&&e<160||e>262143||t&&qk(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=n?r?Uk:jk:Gk,s=Ce(e);return(o.has(s)?"\\":"")+s}function Hk(e){let t=e.map(o=>o.codePointAt(0)).sort((o,s)=>o-s),n=[],r=null;for(let o=0;o<t.length;o++)t[o+1]===t[o]+1?r??=t[o]:r===null?n.push(t[o]):(n.push([r,t[o]]),r=null);return n}function Vk(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:o,disable:s}=t;r=(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${r}:`}function zk({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function Wf({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function qk(e){return e>47&&e<58}function Hf({type:e,value:t}){return e==="Character"&&t===45}var Kk=class tc extends RegExp{#e=new Map;#n=null;#r;#s=null;#t=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let o=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");let s=t;super(s,n),this.#r=s.source,s instanceof tc&&(this.#e=s.#e,this.#s=s.#s,this.#t=s.#t,this.rawOptions=s.rawOptions)}else{let s={hiddenCaptures:[],strategy:null,transfers:[],...r};super(o?"":t,n),this.#r=t,this.#e=Jk(s.hiddenCaptures,s.transfers),this.#t=s.strategy,this.rawOptions=r??{}}o||(this.#n=this)}exec(t){if(!this.#n){let{lazyCompile:o,...s}=this.rawOptions;this.#n=new tc(this.#r,this.flags,s)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#t==="clip_search"&&n&&r){this.lastIndex=0;let o=this.#c(t.slice(r));return o&&(Xk(o,r,t,this.hasIndices),this.lastIndex+=r),o}return this.#c(t)}#c(t){this.#n.lastIndex=this.lastIndex;let n=super.exec.call(this.#n,t);if(this.lastIndex=this.#n.lastIndex,!n||!this.#e.size)return n;let r=[...n];n.length=1;let o;this.hasIndices&&(o=[...n.indices],n.indices.length=1);let s=[0];for(let i=1;i<r.length;i++){let{hidden:a,transferTo:l}=this.#e.get(i)??{};if(a?s.push(null):(s.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(o[i])),l&&r[i]!==void 0){let c=s[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[i],this.hasIndices&&(n.indices[c]=o[i]),n.groups){this.#s||(this.#s=Zk(this.source));let u=this.#s.get(l);u&&(n.groups[u]=r[i],this.hasIndices&&(n.indices.groups[u]=o[i]))}}}return n}};function Xk(e,t,n,r){if(e.index+=t,e.input=n,r){let o=e.indices;for(let i=0;i<o.length;i++){let a=o[i];a&&(o[i]=[a[0]+t,a[1]+t])}let s=o.groups;s&&Object.keys(s).forEach(i=>{let a=s[i];a&&(s[i]=[a[0]+t,a[1]+t])})}}function Jk(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,o]of t)for(let s of o)xo(n,s,{}).transferTo=r;return n}function Zk(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,o=0,s;for(;s=t.exec(e);){let{0:i,groups:{capture:a,name:l}}=s;i==="["?r++:r?i==="]"&&r--:a&&(o++,l&&n.set(o,l))}return n}function tm(e,t){let n=Yk(e,t);return n.options?new Kk(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Yk(e,t){let n=Vf(t),r=Xs(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:nc}),o=vk(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=Mk(o,n),i=Ff(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),a=ql(i.pattern),l=zl(a.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{let u=l.hiddenCaptures.sort((f,g)=>f-g),d=Array.from(l.captureTransfers),m=o._strategy,h=c.pattern.length>=n.lazyCompileLength;(u.length||d.length||m||h)&&(c.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...m&&{strategy:m},...h&&{lazyCompile:h}})}return c}function ni(e,t){return tm(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function oc(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>ni(n,{target:t.target}),{createScanner(n){return new cf(n,t)},createString(n){return{content:n}}}}Cs(ir({bundledLanguages:()=>Qr,bundledLanguagesAlias:()=>Yr,bundledLanguagesBase:()=>Zr,bundledLanguagesInfo:()=>ar,bundledThemes:()=>to,bundledThemesInfo:()=>eo,codeToHast:()=>Dl,codeToHtml:()=>Ol,codeToTokens:()=>Nl,codeToTokensBase:()=>uo,codeToTokensWithThemes:()=>Ml,createHighlighter:()=>Vs,createJavaScriptRegexEngine:()=>oc,createOnigurumaEngine:()=>cl,defaultJavaScriptRegexConstructor:()=>ni,getLastGrammarState:()=>Bl,getSingletonHighlighter:()=>po,loadWasm:()=>As}),lf);var Qk=/#/;function e0(e){return e=e.replace(Qk,""),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===4&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),e.length===6&&(e=`${e}ff`),e.toLowerCase()}function t0(e){return e=e0(e),{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:Number.parseInt(e.slice(6,8),16)/255}}function nm(e,t,n){return[e,t,n].map(r=>{let o=r.toString(16);return o.length===1?`0${o}`:o}).join("")}function n0(e,t="dark"){let{r:n,g:r,b:o,a:s}=t0(e);return t==="dark"?nm(n*s,r*s,o*s):nm(n*s+255*(1-s),r*s+255*(1-s),o*s+255*(1-s))}async function sc(e,t,n){let r="",o=await uo(e,{lang:t,theme:n}),s=(await po()).getTheme(n);for(let i of o){for(let a of i){let l=a.content,c=a.color||s.fg;c&&(l=sr.hex(n0(c,s.type))(l)),a.fontStyle&&(a.fontStyle&de.Bold&&(l=sr.bold(l)),a.fontStyle&de.Italic&&(l=sr.italic(l)),a.fontStyle&de.Underline&&(l=sr.underline(l)),a.fontStyle&de.Strikethrough&&(l=sr.strikethrough(l))),r+=l}r+=`
176
- `}return r}p();var om={".ts":"typescript",".tsx":"tsx",".cts":"typescript",".mts":"typescript",".js":"javascript",".jsx":"jsx",".cjs":"javascript",".mjs":"javascript",".vue":"vue",".svelte":"svelte",".astro":"astro",".css":"css",".scss":"scss",".less":"less",".html":"html",".htm":"html",".xml":"xml",".svg":"xml",".json":"json",".jsonc":"json",".md":"markdown",".mdx":"markdown",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".sh":"bash",".bash":"bash",".zsh":"bash",".py":"python",".rb":"ruby",".rs":"rust",".go":"go",".java":"java",".kt":"kotlin",".swift":"swift",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cs":"csharp",".php":"php",".sql":"sql",".graphql":"graphql",".dockerfile":"dockerfile",".lua":"lua",".r":"r",".dart":"dart",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hs":"haskell",".scala":"scala",".pl":"perl"},rm={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".bashrc":"bash",".zshrc":"bash",".profile":"bash"};function sm(e){let t=e.split(/[\\/]/).pop()??"";if(rm[t])return rm[t];let n=t.lastIndexOf(".");if(n<0)return;let r=t.slice(n).toLowerCase();return om[r]}var zL=new Set(Object.keys(om));p();function am(e,t){if(!e)return 1e3;let n=e.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return 1e3;let r=n[0],o=t.toLowerCase();if(o===r)return 0;if(o.startsWith(r))return 5;let s=o.indexOf(r);return s>=0?s+10:null}function lm(e,t){let n=e.toLowerCase(),r=t.toLowerCase(),o=n.split(/\s+/).filter(Boolean);return o.length===0?!0:o.every(s=>r.includes(s))}function ic(e,t){let n=[];for(let r of t){if(!lm(e,r))continue;let o=am(e,r);o!==null&&n.push({path:r,score:o})}return n.sort((r,o)=>r.score-o.score),n}var ri=10;function bo(e,t){let n=e.match(/(?:^|\s)@([^@]*)$/);if(!n)return null;let o=(n[1]??"").toLowerCase().trim();if(!o)return e.startsWith("@")?[...t]:[];let s=ic(o,t);return s.length===0?[]:s[0]?.path.toLowerCase()===o?[]:s.map(i=>i.path)}var im="\x1B[0m";function cm(e){return e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510}function r0(e){let t=0;for(let n=0;n<e.length;){let o=e[n].charCodeAt(0);if(o===27&&n+1<e.length&&e[n+1]==="["){for(n+=2;n<e.length;){let i=e.charCodeAt(n);if(n++,i>=64&&i<=126)break}continue}if(o===27&&n+1<e.length&&e[n+1]==="]"){for(n+=2;n<e.length;){let i=e.charCodeAt(n);if(i===7){n++;break}if(i===27&&n+1<e.length&&e[n+1]==="\\"){n+=2;break}n++}continue}let s=e.codePointAt(n);t+=cm(s)?2:1,n+=s>65535?2:1}return t}function um(e,t){if(t<=0)return"";if(r0(e)<=t)return e;let r=t-1;if(r<=0)return"\u2026"+im;let o="",s=0;for(let i=0;i<e.length;){let l=e[i].charCodeAt(0);if(l===27&&i+1<e.length&&e[i+1]==="["){let d=i;for(i+=2;i<e.length;){let m=e.charCodeAt(i);if(i++,m>=64&&m<=126)break}o+=e.slice(d,i);continue}if(l===27&&i+1<e.length&&e[i+1]==="]"){let d=i;for(i+=2;i<e.length;){let m=e.charCodeAt(i);if(m===7){i++;break}if(m===27&&i+1<e.length&&e[i+1]==="\\"){i+=2;break}i++}o+=e.slice(d,i);continue}let c=e.codePointAt(i),u=cm(c)?2:1;if(s+u>r)break;o+=String.fromCodePoint(c),s+=u,i+=c>65535?2:1}return o+"\u2026"+im}import{jsx as Ht,jsxs as oi}from"react/jsx-runtime";var i0="github-dark",a0=512*1024,pm=4e3;var ac="#808080",lc="#ff4444",dm=512;async function l0(e,t,n){let{stat:r,readFile:o}=await import("fs/promises"),{join:s}=await import("path"),i=s(t,e),a;try{a=await r(i)}catch(h){return{kind:"error",message:h instanceof Error?h.message:String(h)}}if(!a.isFile())return{kind:"error",message:"\u4E0D\u662F\u6587\u4EF6"};try{let f=await(await import("fs/promises")).open(i,"r");try{let g=Buffer.alloc(dm),{bytesRead:b}=await f.read(g,0,dm,0);for(let w=0;w<b;w++)if(g[w]===0)return{kind:"binary"}}finally{await f.close()}}catch{}let l=a.size>a0,c=l?pm:a.size,u;try{u=(await o(i)).subarray(0,c).toString("utf8")}catch(h){return{kind:"error",message:h instanceof Error?h.message:String(h)}}if(n.cancelled)return{kind:"idle"};let d=sm(e),m;if(d)try{m=await sc(u,d,i0)}catch(h){return{kind:"error",message:`\u9AD8\u4EAE\u5931\u8D25: ${h instanceof Error?h.message:String(h)}`}}else m=u;return n.cancelled?{kind:"idle"}:{kind:"ready",ansi:m,truncated:l}}function si({relativePath:e,cwd:t,width:n,maxLines:r}){let[o,s]=s0({kind:"idle"});if(o0(()=>{if(!e){s({kind:"idle"});return}let f={cancelled:!1};return s({kind:"loading"}),l0(e,t,f).then(g=>{f.cancelled||s(g)}),()=>{f.cancelled=!0}},[e,t]),!e)return Ht(hr,{flexDirection:"column",paddingX:1,children:Ht(On,{color:ac,dimColor:!0,children:"\u2190 \u9009\u62E9\u5DE6\u4FA7\u6587\u4EF6\u67E5\u770B\u9AD8\u4EAE\u4EE3\u7801"})});if(o.kind==="loading"||o.kind==="idle")return Ht(hr,{flexDirection:"column",paddingX:1,children:Ht(On,{color:ac,children:"\u2699 \u52A0\u8F7D\u4E2D\u2026"})});if(o.kind==="binary")return Ht(hr,{flexDirection:"column",paddingX:1,children:Ht(On,{color:lc,children:"\u26A0 \u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"})});if(o.kind==="too-large")return Ht(hr,{flexDirection:"column",paddingX:1,children:oi(On,{color:lc,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF08",o.bytes," \u5B57\u8282\uFF09\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"]})});if(o.kind==="error")return Ht(hr,{flexDirection:"column",paddingX:1,children:oi(On,{color:lc,children:["\u26A0 \u8BFB\u53D6\u5931\u8D25: ",o.message]})});let i=Math.max(n-4,8),a=o.truncated?1:0,l=Math.max(r-a,1),c=o.ansi.split(`
177
- `),u=c.length>l,d=u?c.slice(0,Math.max(l-1,0)):c,m=d.map(f=>um(f,i)).join(`
174
+ \v\f\x85\u2028\u2029])`),t));else if(l==="posix")if(!o&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let d={graph:"!-~",print:" -~"}[u];c&&(d=`\0-${Ce(d.codePointAt(0)-1)}${Ce(d.codePointAt(2)+1)}-\u{10FFFF}`),n(ge(Wt(`[${d}]`),t))}else n(ge(Yl(Wt(Ak.get(u)),c),t));else if(l==="property")tc.has(cr(u))||(e.key="sc");else if(l==="space")n(an(In("space",{negate:c}),t));else if(l==="word")n(ge(Yl(Wt(Ut),c),t));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:o,removeAllPrevSiblings:s,removeAllNextSiblings:i}){let{kind:a,flags:l}=e;if(a==="flags")if(!l.enable&&!l.disable)r();else{let c=Ze({flags:l});c.body[0].body=i(),o(ge(c,t),{traverse:!0})}else if(a==="keep"){let c=n.body[0],d=n.body.length===1&&Ks(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(t.parent!==d||d.body.length>1)throw new Error(Z`Uses "\K" in a way that's unsupported`);let m=on({behind:!0});m.body[0].body=s(),o(ge(m,t))}else throw new Error(`Unexpected directive kind "${a}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(ge(on({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=Ze();t.body[0].body.push(e.body),e.body=ge(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,o=!1;for(let s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{let i=nm(s.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):o=!0}r&&!o&&n.forEach(s=>t.add(s))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(Z`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Zl(n)&&(n=Jl(n,t),e.ref=n)}},Lk={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:o}=e;r||n.set(e,[...t.get(o).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:o,groupsByName:s,multiplexCapturesToLeftByRef:i,openRefs:a,reffedNodesByReferencer:l}){let c=o.get(e);if(c&&a.has(e.number)){let d=an(Vf(e.number),t);l.set(d,a.get(e.number)),n(d);return}a.set(e.number,e),i.set(e.number,[]),e.name&&yo(i,e.name,[]);let u=i.get(e.name??e.number);for(let d=0;d<u.length;d++){let m=u[d];if(c===m.node||c&&c===m.origin||e===m.origin){u.splice(d,1);break}}if(i.get(e.number).push({node:e,origin:c}),e.name&&i.get(e.name).push({node:e,origin:c}),e.name){let d=yo(s,e.name,new Map),m=!1;if(c)m=!0;else for(let h of d.values())if(!h.hasDuplicateNameToRemove){m=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:m})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=ti(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:o,ref:s}=e;if(o){let u=t;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===s||u.number===s)););r.reffedNodesByReferencer.set(e,u);return}let i=r.subroutineRefMap.get(s),a=s===0,l=a?Vf(0):Qf(i,r.groupOriginByCopy,null),c=l;if(!a){let u=em(Nk(i,m=>m.type==="Group"&&!!m.flags)),d=u?ti(r.globalFlags,u):r.globalFlags;Ok(d,r.currentFlags)||(c=Ze({flags:Mk(d)}),c.body[0].body.push(l))}n(ge(c,t),{traverse:!a})}},$k={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let s=r.reffedNodesByReferencer.get(e).filter(i=>Dk(i,e));if(!s.length)n(ge(on({negate:!0}),t));else if(s.length>1){let i=Ze({atomic:!0,body:s.reverse().map(a=>jt({body:[Xs(a.number)]}))});n(ge(i,t))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){let o=Gl();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Yf(e){Pn(e,{"*"({node:t,parent:n}){t.parent=n}})}function Ok(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Dk(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=tm(n.parent);for(let o of r){if(o===n)break;if(o===e||rm(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Qf(e,t,n,r){let o=Array.isArray(e)?[]:{};for(let[s,i]of Object.entries(e))s==="parent"?o.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?o[s]=Qf(i,t,o,n):(s==="type"&&i==="CapturingGroup"&&t.set(o,t.get(e)??e),o[s]=i);return o}function Vf(e){let t=Ul(e);return t.isRecursive=!0,t}function Nk(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Jl(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function em(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(o=>{r.enable?.[o]&&(delete n.disable[o],n.enable[o]=!0),r.disable?.[o]&&(n.disable[o]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Mk({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function tm(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function nm(e){let t=e.find(n=>n.kind==="search_start"||Gk(n,{negate:!1})||!Bk(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){let n=[];for(let r of t.body){let o=nm(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function rm(e,t){let n=tm(e)??[];for(let r of n)if(r===t||rm(r,t))return!0;return!1}function Bk({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Fk(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function Gk(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Ks(e.body[0],{type:"Assertion",kind:"search_start"})}function Zl(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Wt(e,t){let r=Js(e,{...t,unicodePropertyMap:tc}).body;return r.length>1||r[0].body.length>1?Ze({body:r}):r[0].body[0]}function Yl(e,t){return e.negate=t,e}function an(e,t){return e.parent=t,e}function ge(e,t){return Yf(e),e.parent=t,e}function jk(e,t){let n=Xf(t),r=Ql(n.target,"ES2024"),o=Ql(n.target,"ES2025"),s=n.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,a=null;if(!o){let h=[e.flags.ignoreCase];Pn(e,Uk,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(f){h.push(f)},setHasCasedChar(){h.at(-1)?i=!0:a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!a)},c=e,u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!o&&i&&a),useFlagMods:o,useFlagV:r,verbose:n.verbose};function d(h){return u.lastNode=c,c=h,kk(Wk[h.type],`Unexpected node type "${h.type}"`)(h,u,d)}let m={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return r||(delete m.options.force.v,m.options.disable.v=!0,m.options.unicodeSetsPlugin=null),m._captureTransfers=new Map,m._hiddenCaptures=[],u.captureMap.forEach((h,f)=>{h.hidden&&m._hiddenCaptures.push(f),h.transferTo&&yo(m._captureTransfers,h.transferTo,[]).push(f)}),m}var Uk={"*":{enter({node:e},t){if(qf(e)){let n=t.getCurrentModI();t.pushModI(e.flags?ti({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){qf(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){nc(Ce(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),om(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&Zf.has(e.value)&&t.setHasCasedChar()}},Wk={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?Z`\B`:Z`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){let{body:r,name:o,number:s}=e,i={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(i.hidden=!0,s>a.number&&(i.transferTo=a.number)),t.captureMap.set(s,i),`(${o?`?<${o}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=Ce(e),r=dr(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&nc(n)){let o=Jf(n);return t.inCharClass?o.join(""):o.length>1?`[${o.join("")}]`:o[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:o,parent:s}=e,{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(Kf)&&(i=[lr(45),...i.filter(c=>!Kf(c))]);let a=()=>`[${o?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ht.bugNestedClassIgnoresNegation)&&!o){let u=i.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){let d=Ze(),m=d.body[0];return d.parent=s,m.parent=d,i=i.filter(h=>!u.includes(h)),e.body=i,i.length?(e.parent=m,m.body.push(e)):d.body.pop(),u.forEach(h=>{let f=jt({body:[h]});h.parent=f,f.parent=d,d.body.push(f)}),n(d)}}t.inCharClass=!0;let c=a();return t.inCharClass=!1,c}let l=i[0];if(r==="union"&&!o&&l&&((!t.useFlagV||!t.verbose)&&s.kind==="union"&&!(ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&s.kind==="intersection"&&i.length===1&&l.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,o={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},s=dr(n,o),i=dr(r,o),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=om(e);Kk(l).forEach(u=>{a.add(Array.isArray(u)?`${dr(u[0],o)}-${dr(u[1],o)}`:dr(u,o))})}return`${s}-${i}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},o){if(e==="dot")return o.currentFlags.dotAll?o.appliedGlobalFlags.dotAll||o.useFlagMods?".":"[^]":Z`[^\n]`;if(e==="digit")return t?Z`\D`:Z`\d`;if(e==="property"){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&Zf.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Z`\P`:Z`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?Z`\W`:Z`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},o,s){let i=o.currentFlags;n&&(o.currentFlags=ti(i,n));let a=t.map(s).join("|"),l=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?a:`(?${Xk(e,n,o.useFlagMods)}${a})`;return o.currentFlags=i,l},LookaroundAssertion({body:e,kind:t,negate:n},r,o){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(o).join("|")})`},Quantifier(e,t,n){return n(e.body)+Jk(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");let r=n.recursionLimit;return t===0?`(?R=${r})`:Z`\g<${t}&R=${r}>`}},Hk=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Vk=new Set(["-","\\","]","^","["]),zk=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),zf=new Map([[9,Z`\t`],[10,Z`\n`],[11,Z`\v`],[12,Z`\f`],[13,Z`\r`],[8232,Z`\u2028`],[8233,Z`\u2029`],[65279,Z`\uFEFF`]]),qk=new RegExp("^\\p{Cased}$","u");function nc(e){return qk.test(e)}function om(e,t){let n=!!t?.firstOnly,r=e.min.value,o=e.max.value,s=[];if(r<65&&(o===65535||o>=131071)||r===65536&&o>=131071)return s;for(let i=r;i<=o;i++){let a=Ce(i);if(!nc(a))continue;let l=Jf(a).filter(c=>{let u=c.codePointAt(0);return u<r||u>o});if(l.length&&(s.push(...l),n))break}return s}function dr(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(zf.has(e))return zf.get(e);if(e<32||e>126&&e<160||e>262143||t&&Zk(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=n?r?zk:Vk:Hk,s=Ce(e);return(o.has(s)?"\\":"")+s}function Kk(e){let t=e.map(o=>o.codePointAt(0)).sort((o,s)=>o-s),n=[],r=null;for(let o=0;o<t.length;o++)t[o+1]===t[o]+1?r??=t[o]:r===null?n.push(t[o]):(n.push([r,t[o]]),r=null);return n}function Xk(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:o,disable:s}=t;r=(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${r}:`}function Jk({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function qf({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function Zk(e){return e>47&&e<58}function Kf({type:e,value:t}){return e==="Character"&&t===45}var Yk=class ec extends RegExp{#e=new Map;#n=null;#r;#s=null;#t=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let o=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");let s=t;super(s,n),this.#r=s.source,s instanceof ec&&(this.#e=s.#e,this.#s=s.#s,this.#t=s.#t,this.rawOptions=s.rawOptions)}else{let s={hiddenCaptures:[],strategy:null,transfers:[],...r};super(o?"":t,n),this.#r=t,this.#e=e0(s.hiddenCaptures,s.transfers),this.#t=s.strategy,this.rawOptions=r??{}}o||(this.#n=this)}exec(t){if(!this.#n){let{lazyCompile:o,...s}=this.rawOptions;this.#n=new ec(this.#r,this.flags,s)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#t==="clip_search"&&n&&r){this.lastIndex=0;let o=this.#u(t.slice(r));return o&&(Qk(o,r,t,this.hasIndices),this.lastIndex+=r),o}return this.#u(t)}#u(t){this.#n.lastIndex=this.lastIndex;let n=super.exec.call(this.#n,t);if(this.lastIndex=this.#n.lastIndex,!n||!this.#e.size)return n;let r=[...n];n.length=1;let o;this.hasIndices&&(o=[...n.indices],n.indices.length=1);let s=[0];for(let i=1;i<r.length;i++){let{hidden:a,transferTo:l}=this.#e.get(i)??{};if(a?s.push(null):(s.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(o[i])),l&&r[i]!==void 0){let c=s[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[i],this.hasIndices&&(n.indices[c]=o[i]),n.groups){this.#s||(this.#s=t0(this.source));let u=this.#s.get(l);u&&(n.groups[u]=r[i],this.hasIndices&&(n.indices.groups[u]=o[i]))}}}return n}};function Qk(e,t,n,r){if(e.index+=t,e.input=n,r){let o=e.indices;for(let i=0;i<o.length;i++){let a=o[i];a&&(o[i]=[a[0]+t,a[1]+t])}let s=o.groups;s&&Object.keys(s).forEach(i=>{let a=s[i];a&&(s[i]=[a[0]+t,a[1]+t])})}}function e0(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,o]of t)for(let s of o)yo(n,s,{}).transferTo=r;return n}function t0(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,o=0,s;for(;s=t.exec(e);){let{0:i,groups:{capture:a,name:l}}=s;i==="["?r++:r?i==="]"&&r--:a&&(o++,l&&n.set(o,l))}return n}function sm(e,t){let n=n0(e,t);return n.options?new Yk(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function n0(e,t){let n=Xf(t),r=Js(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:tc}),o=Ik(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=jk(o,n),i=Wf(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),a=zl(i.pattern),l=Vl(a.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{let u=l.hiddenCaptures.sort((f,g)=>f-g),d=Array.from(l.captureTransfers),m=o._strategy,h=c.pattern.length>=n.lazyCompileLength;(u.length||d.length||m||h)&&(c.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...m&&{strategy:m},...h&&{lazyCompile:h}})}return c}function ri(e,t){return sm(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function rc(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>ri(n,{target:t.target}),{createScanner(n){return new ff(n,t)},createString(n){return{content:n}}}}_s(rr({bundledLanguages:()=>Yr,bundledLanguagesAlias:()=>Zr,bundledLanguagesBase:()=>Jr,bundledLanguagesInfo:()=>or,bundledThemes:()=>eo,bundledThemesInfo:()=>Qr,codeToHast:()=>Ol,codeToHtml:()=>$l,codeToTokens:()=>Dl,codeToTokensBase:()=>co,codeToTokensWithThemes:()=>Nl,createHighlighter:()=>zs,createJavaScriptRegexEngine:()=>rc,createOnigurumaEngine:()=>ll,defaultJavaScriptRegexConstructor:()=>ri,getLastGrammarState:()=>Ml,getSingletonHighlighter:()=>uo,loadWasm:()=>Es}),pf);var r0=/#/;function o0(e){return e=e.replace(r0,""),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===4&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),e.length===6&&(e=`${e}ff`),e.toLowerCase()}function s0(e){return e=o0(e),{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:Number.parseInt(e.slice(6,8),16)/255}}function im(e,t,n){return[e,t,n].map(r=>{let o=r.toString(16);return o.length===1?`0${o}`:o}).join("")}function i0(e,t="dark"){let{r:n,g:r,b:o,a:s}=s0(e);return t==="dark"?im(n*s,r*s,o*s):im(n*s+255*(1-s),r*s+255*(1-s),o*s+255*(1-s))}async function xo(e,t,n){let r="",o=await co(e,{lang:t,theme:n}),s=(await uo()).getTheme(n);for(let i of o){for(let a of i){let l=a.content,c=a.color||s.fg;c&&(l=nr.hex(i0(c,s.type))(l)),a.fontStyle&&(a.fontStyle&de.Bold&&(l=nr.bold(l)),a.fontStyle&de.Italic&&(l=nr.italic(l)),a.fontStyle&de.Underline&&(l=nr.underline(l)),a.fontStyle&de.Strikethrough&&(l=nr.strikethrough(l))),r+=l}r+=`
175
+ `}return r}p();var lm={".ts":"typescript",".tsx":"tsx",".cts":"typescript",".mts":"typescript",".js":"javascript",".jsx":"jsx",".cjs":"javascript",".mjs":"javascript",".vue":"vue",".svelte":"svelte",".astro":"astro",".css":"css",".scss":"scss",".less":"less",".html":"html",".htm":"html",".xml":"xml",".svg":"xml",".json":"json",".jsonc":"json",".md":"markdown",".mdx":"markdown",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".sh":"bash",".bash":"bash",".zsh":"bash",".py":"python",".rb":"ruby",".rs":"rust",".go":"go",".java":"java",".kt":"kotlin",".swift":"swift",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cs":"csharp",".php":"php",".sql":"sql",".graphql":"graphql",".dockerfile":"dockerfile",".lua":"lua",".r":"r",".dart":"dart",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hs":"haskell",".scala":"scala",".pl":"perl"},am={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".bashrc":"bash",".zshrc":"bash",".profile":"bash"};function oi(e){let t=e.split(/[\\/]/).pop()??"";if(am[t])return am[t];let n=t.lastIndexOf(".");if(n<0)return;let r=t.slice(n).toLowerCase();return lm[r]}var r$=new Set(Object.keys(lm));var a0="github-dark",l0="\x1B[32m+\x1B[39m",c0="\x1B[31m-\x1B[39m",u0="\x1B[90m \x1B[39m",d0="\x1B[36m",um="\x1B[0m";function p0(e){let t=e.split(`
176
+ `),n=[];for(let r of t)if(!(r.startsWith("---")||r.startsWith("+++"))){if(r.startsWith("@@")){n.push({kind:"hunk-header",raw:r});continue}r.startsWith("+")?n.push({kind:"add",raw:r}):r.startsWith("-")?n.push({kind:"remove",raw:r}):n.push({kind:"context",raw:r})}return n}async function dm(e,t){if(!e)return[];let n=p0(e);if(n.length===0)return[];let r=oi(t),o=[];for(let u=0;u<n.length;u++)n[u].kind!=="hunk-header"&&o.push(u);if(o.length===0)return n.map(cm);if(!r)return null;let s=o.map(u=>{let d=n[u].raw;return d.length>0?d.slice(1):""}),i=s.join(`
177
+ `),a;try{a=await xo(i,r,a0)}catch{return null}let l=a.split(`
178
+ `),c=l.length>0&&l[l.length-1]===""?l.slice(0,-1):l;return c.length!==s.length?null:n.map((u,d)=>{if(u.kind==="hunk-header")return cm(u);let m=o.indexOf(d),h=c[m]??"";return{kind:u.kind,ansi:`${f0(u.kind)}${h}${um}`}})}function f0(e){switch(e){case"add":return l0;case"remove":return c0;case"context":return u0;case"hunk-header":return""}}function cm(e){return{kind:e.kind,ansi:`${d0}${e.raw}${um}`}}function pm(e){let t=[];for(let n of e.split(`
179
+ `))n.startsWith("---")||n.startsWith("+++")||(n.startsWith("@@")?t.push({kind:"hunk-header",ansi:"",raw:n}):n.startsWith("+")?t.push({kind:"add",ansi:"",raw:n}):n.startsWith("-")?t.push({kind:"remove",ansi:"",raw:n}):t.push({kind:"context",ansi:"",raw:n}));return t}import{jsx as wo,jsxs as si}from"react/jsx-runtime";function g0(e){let[t,n]=h0(()=>e.patch?pm(e.patch):[]);return m0(()=>{if(!e.patch){n([]);return}let r={cancelled:!1};return dm(e.patch,e.filePath).then(o=>{r.cancelled||o&&n(o)}).catch(()=>{}),()=>{r.cancelled=!0}},[e.patch,e.filePath]),t}function sc({diff:e}){let{patch:t,additions:n,deletions:r,existedBefore:o,filePath:s}=e,i=g0(e);if(!t||t.length===0)return null;let a=s.replace(/\\/g,"/").split("/").pop()??s;return si(oc,{flexDirection:"column",marginTop:1,children:[si(oc,{flexDirection:"row",gap:1,children:[si(bo,{bold:!0,color:"#00ffff",children:["\u{1F4DD} ",o?"\u4FEE\u6539":"\u65B0\u5EFA",":"]}),wo(bo,{bold:!0,children:a}),si(bo,{color:"#555555",children:["(+",n," -",r,")"]})]}),wo(oc,{flexDirection:"column",marginLeft:2,children:i.map((l,c)=>wo(y0,{line:l},c))})]})}function y0({line:e}){if(e.ansi.length>0)return wo(bo,{children:e.ansi});let t=x0[e.kind];return wo(bo,{color:t,children:e.raw??""})}var x0={add:"#22c55e",remove:"#ef4444",context:"#6b7280","hunk-header":"#00cccc"};p();import{Box as ic,Text as ac}from"ink";import{jsx as ii,jsxs as fm}from"react/jsx-runtime";var b0="#00bfff";function lc({skills:e,input:t,selectedIndex:n}){let r=t.match(/(?:^|\s)\/([^/]*)$/);if(!r)return null;let o=r[1].toLowerCase().trim();if(e.length===0)return null;let s=!o&&t.startsWith("/")?e.slice(0,3):e.filter(i=>i.name.toLowerCase().includes(o)).slice(0,3);return o&&s.some(i=>i.name.toLowerCase()===o)||s.length===0?null:fm(ic,{flexDirection:"column",marginLeft:4,marginTop:1,children:[ii(ac,{color:"#808080",dimColor:!0,children:"\u652F\u6301\u7684 Skill\uFF1A"}),s.map((i,a)=>ii(ic,{children:fm(ac,{color:a===n?b0:"#808080",children:[a===n?" \u203A ":" ",i.name]})},i.name)),ii(ic,{marginTop:1,children:ii(ac,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as ln,Text as fr}from"ink";import{useEffect as R0,useState as v0}from"react";p();import{Box as pr,Text as $n}from"ink";import{useEffect as k0,useState as S0}from"react";p();function hm(e,t){if(!e)return 1e3;let n=e.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return 1e3;let r=n[0],o=t.toLowerCase();if(o===r)return 0;if(o.startsWith(r))return 5;let s=o.indexOf(r);return s>=0?s+10:null}function gm(e,t){let n=e.toLowerCase(),r=t.toLowerCase(),o=n.split(/\s+/).filter(Boolean);return o.length===0?!0:o.every(s=>r.includes(s))}function cc(e,t){let n=[];for(let r of t){if(!gm(e,r))continue;let o=hm(e,r);o!==null&&n.push({path:r,score:o})}return n.sort((r,o)=>r.score-o.score),n}var ai=10;function ko(e,t){let n=e.match(/(?:^|\s)@([^@]*)$/);if(!n)return null;let o=(n[1]??"").toLowerCase().trim();if(!o)return e.startsWith("@")?[...t]:[];let s=cc(o,t);return s.length===0?[]:s[0]?.path.toLowerCase()===o?[]:s.map(i=>i.path)}var mm="\x1B[0m";function ym(e){return e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510}function w0(e){let t=0;for(let n=0;n<e.length;){let o=e[n].charCodeAt(0);if(o===27&&n+1<e.length&&e[n+1]==="["){for(n+=2;n<e.length;){let i=e.charCodeAt(n);if(n++,i>=64&&i<=126)break}continue}if(o===27&&n+1<e.length&&e[n+1]==="]"){for(n+=2;n<e.length;){let i=e.charCodeAt(n);if(i===7){n++;break}if(i===27&&n+1<e.length&&e[n+1]==="\\"){n+=2;break}n++}continue}let s=e.codePointAt(n);t+=ym(s)?2:1,n+=s>65535?2:1}return t}function xm(e,t){if(t<=0)return"";if(w0(e)<=t)return e;let r=t-1;if(r<=0)return"\u2026"+mm;let o="",s=0;for(let i=0;i<e.length;){let l=e[i].charCodeAt(0);if(l===27&&i+1<e.length&&e[i+1]==="["){let d=i;for(i+=2;i<e.length;){let m=e.charCodeAt(i);if(i++,m>=64&&m<=126)break}o+=e.slice(d,i);continue}if(l===27&&i+1<e.length&&e[i+1]==="]"){let d=i;for(i+=2;i<e.length;){let m=e.charCodeAt(i);if(m===7){i++;break}if(m===27&&i+1<e.length&&e[i+1]==="\\"){i+=2;break}i++}o+=e.slice(d,i);continue}let c=e.codePointAt(i),u=ym(c)?2:1;if(s+u>r)break;o+=String.fromCodePoint(c),s+=u,i+=c>65535?2:1}return o+"\u2026"+mm}import{jsx as Ht,jsxs as li}from"react/jsx-runtime";var T0="github-dark",C0=512*1024,wm=4e3;var uc="#808080",dc="#ff4444",bm=512;async function _0(e,t,n){let{stat:r,readFile:o}=await import("fs/promises"),{join:s}=await import("path"),i=s(t,e),a;try{a=await r(i)}catch(h){return{kind:"error",message:h instanceof Error?h.message:String(h)}}if(!a.isFile())return{kind:"error",message:"\u4E0D\u662F\u6587\u4EF6"};try{let f=await(await import("fs/promises")).open(i,"r");try{let g=Buffer.alloc(bm),{bytesRead:k}=await f.read(g,0,bm,0);for(let b=0;b<k;b++)if(g[b]===0)return{kind:"binary"}}finally{await f.close()}}catch{}let l=a.size>C0,c=l?wm:a.size,u;try{u=(await o(i)).subarray(0,c).toString("utf8")}catch(h){return{kind:"error",message:h instanceof Error?h.message:String(h)}}if(n.cancelled)return{kind:"idle"};let d=oi(e),m;if(d)try{m=await xo(u,d,T0)}catch(h){return{kind:"error",message:`\u9AD8\u4EAE\u5931\u8D25: ${h instanceof Error?h.message:String(h)}`}}else m=u;return n.cancelled?{kind:"idle"}:{kind:"ready",ansi:m,truncated:l}}function ci({relativePath:e,cwd:t,width:n,maxLines:r}){let[o,s]=S0({kind:"idle"});if(k0(()=>{if(!e){s({kind:"idle"});return}let f={cancelled:!1};return s({kind:"loading"}),_0(e,t,f).then(g=>{f.cancelled||s(g)}),()=>{f.cancelled=!0}},[e,t]),!e)return Ht(pr,{flexDirection:"column",paddingX:1,children:Ht($n,{color:uc,dimColor:!0,children:"\u2190 \u9009\u62E9\u5DE6\u4FA7\u6587\u4EF6\u67E5\u770B\u9AD8\u4EAE\u4EE3\u7801"})});if(o.kind==="loading"||o.kind==="idle")return Ht(pr,{flexDirection:"column",paddingX:1,children:Ht($n,{color:uc,children:"\u2699 \u52A0\u8F7D\u4E2D\u2026"})});if(o.kind==="binary")return Ht(pr,{flexDirection:"column",paddingX:1,children:Ht($n,{color:dc,children:"\u26A0 \u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"})});if(o.kind==="too-large")return Ht(pr,{flexDirection:"column",paddingX:1,children:li($n,{color:dc,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF08",o.bytes," \u5B57\u8282\uFF09\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"]})});if(o.kind==="error")return Ht(pr,{flexDirection:"column",paddingX:1,children:li($n,{color:dc,children:["\u26A0 \u8BFB\u53D6\u5931\u8D25: ",o.message]})});let i=Math.max(n-4,8),a=o.truncated?1:0,l=Math.max(r-a,1),c=o.ansi.split(`
180
+ `),u=c.length>l,d=u?c.slice(0,Math.max(l-1,0)):c,m=d.map(f=>xm(f,i)).join(`
178
181
  `),h=u&&l>0?`${m}
179
- \u2026 \u4EE5\u4E0B ${c.length-d.length} \u884C\u672A\u663E\u793A`:m;return oi(hr,{flexDirection:"column",paddingX:1,children:[o.truncated&&oi(On,{color:ac,dimColor:!0,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF0C\u4EC5\u663E\u793A\u524D ",pm," \u5B57\u8282"]}),Ht(On,{children:h})]})}import{jsx as Dn,jsxs as cn}from"react/jsx-runtime";var fm="#00ff41",yr="#808080",cc=4,d0=60,p0=20;function f0(e,t){return t<=0?"":e.length<=t?e:t<=1?"\u2026":e.slice(0,t-1)+"\u2026"}function uc({files:e,input:t,selectedIndex:n,cwd:r,width:o}){let s=bo(t,e);if(!s||s.length===0)return null;let i=ri,a=Math.max(1,Math.ceil(s.length/i)),[l,c]=u0(0);c0(()=>{c(v=>v<0||v>=s.length?Math.floor(n/i)*i:n<v?Math.max(0,Math.floor(n/i)*i):n>=v+i?Math.floor(n/i)*i:v)},[n,s.length,i]);let u=l,d=s.slice(u,u+i);if(!(o>=d0))return cn(ln,{flexDirection:"column",marginLeft:cc,marginTop:1,children:[cn(gr,{color:yr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),d.map((v,_)=>{let M=u+_===n;return Dn(ln,{children:cn(gr,{color:M?fm:yr,children:[M?" \u203A ":" ",v]})},v)})]});let h=o-cc,f=Math.max(Math.floor(h/3),p0),g=Math.max(h-f-1,20),b=10,w=n>=0&&n<s.length?s[n]??null:null,S=Math.max(f-2,4);return cn(ln,{flexDirection:"row",paddingLeft:cc,marginTop:1,children:[cn(ln,{flexDirection:"column",width:f,flexShrink:0,children:[cn(gr,{color:yr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),Dn(ln,{flexDirection:"column",marginTop:1,children:d.map((v,_)=>{let M=u+_===n;return cn(gr,{color:M?fm:yr,bold:M,children:[M?"\u25B8 ":" ",f0(v,S)]},v)})})]}),Dn(ln,{width:1,flexShrink:0,children:Dn(gr,{color:yr,children:"\u2502"})}),cn(ln,{flexDirection:"column",width:g,flexShrink:0,children:[Dn(gr,{color:yr,dimColor:!0,children:w?`\u{1F4C4} ${w}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),Dn(ln,{flexDirection:"column",marginTop:1,children:Dn(si,{relativePath:w,cwd:r,width:g,maxLines:b})})]})]})}p();import{Box as Rt,Text as Nn,useInput as m0}from"ink";import h0 from"ink-text-input";import{useEffect as mm,useMemo as g0,useState as dc}from"react";import{jsx as lt,jsxs as Mn}from"react/jsx-runtime";var y0="#00ff41",wo="#808080",ii="#00ffff",At=ri;function hm({files:e,cwd:t,width:n,height:r,onPick:o,onClose:s}){let[i,a]=dc(""),[l,c]=dc(0),u=g0(()=>i.trim()?ic(i,e):[],[i,e]),d=Math.max(1,Math.ceil(u.length/At)),[m,h]=dc(0);mm(()=>{h(0),c(0)},[i]),mm(()=>{h(E=>u.length===0?0:E<0||E>=u.length?Math.floor(l/At)*At:l<E?Math.max(0,Math.floor(l/At)*At):l>=E+At?Math.floor(l/At)*At:E)},[l,u.length]);let f=m,g=u.slice(f,f+At),b=l>=f&&l<f+g.length?l-f:0;m0((E,M)=>{if(M.ctrl&&E==="p"){s();return}if(M.escape){s();return}if(M.upArrow){if(u.length===0)return;c(U=>(U-1+u.length)%u.length);return}if(M.downArrow){if(u.length===0)return;c(U=>(U+1)%u.length);return}if(M.return){let U=u[l];U&&o(U.path);return}},{isActive:!0});let w=Math.max(Math.floor(n/3),24),S=Math.max(n-w-1,20),v=Math.max(r-11,4),_=u[l]?.path??null;return Mn(Rt,{flexDirection:"column",height:r,children:[Mn(Rt,{flexDirection:"row",borderStyle:"round",borderColor:ii,paddingX:1,children:[lt(Nn,{bold:!0,color:ii,children:"\u{1F50D} "}),lt(Rt,{flexGrow:1,children:lt(h0,{value:i,onChange:a,placeholder:"\u8F93\u5165\u6587\u4EF6\u540D"})})]}),Mn(Rt,{flexDirection:"row",flexGrow:1,marginTop:1,children:[Mn(Rt,{flexDirection:"column",width:w,borderStyle:"single",borderColor:ii,paddingX:1,flexShrink:0,children:[Mn(Nn,{color:wo,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6 (",u.length," \u6761)",d>1?` \xB7 ${Math.floor(m/At)+1}/${d}`:""]}),lt(Rt,{flexDirection:"column",marginTop:1,children:g.length===0?lt(Nn,{color:wo,dimColor:!0,children:i.trim()?e.length===0?"\uFF08\u9879\u76EE\u65E0\u6587\u4EF6\uFF09":"\uFF08\u65E0\u5339\u914D\uFF09":"\uFF08\u8F93\u5165\u5173\u952E\u5B57\u5F00\u59CB\u5339\u914D\uFF09"}):g.map((E,M)=>{let U=M===b;return Mn(Nn,{color:U?y0:void 0,bold:U,children:[U?"\u25B8 ":" ",E.path]},E.path)})})]}),lt(Rt,{width:1,flexShrink:0,children:lt(Nn,{color:wo,children:"\u2502"})}),Mn(Rt,{flexDirection:"column",width:S,borderStyle:"single",borderColor:ii,flexShrink:0,children:[lt(Nn,{color:wo,dimColor:!0,children:_?`\u{1F4C4} ${_}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),lt(Rt,{flexDirection:"column",marginTop:1,children:lt(si,{relativePath:_,cwd:t,width:S,maxLines:v})})]})]}),lt(Rt,{marginTop:1,children:lt(Nn,{color:wo,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u56DE\u586B\u8DEF\u5F84\u5230\u8F93\u5165\u6846 \xB7 Esc / Ctrl+P \u5173\u95ED"})})]})}p();import{Text as Bn,useInput as x0}from"ink";import{jsx as ko,jsxs as gm}from"react/jsx-runtime";function ym({value:e,onChange:t,onSubmit:n,placeholder:r="",focus:o=!0}){if(x0((s,i)=>{if(o&&!(i.upArrow||i.downArrow||i.leftArrow||i.rightArrow)&&!(i.pageDown||i.pageUp||i.home||i.end)){if(i.return){n?.(e);return}if(!i.escape&&!i.tab&&!(i.shift&&i.tab)&&!i.ctrl){if(i.backspace||i.delete){t(e.slice(0,-1));return}s&&t(e+s)}}},{isActive:o}),!o)return!e&&r?ko(Bn,{dimColor:!0,children:r}):ko(Bn,{children:e});if(!e&&r){let s=r[0],i=r.slice(1);return gm(Bn,{children:[ko(Bn,{inverse:!0,children:s}),ko(Bn,{dimColor:!0,children:i})]})}return gm(Bn,{children:[e,ko(Bn,{inverse:!0,children:" "})]})}p();p();function pc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function b0(e){return e.replace(/<skill_content/g,"&lt;skill_content").replace(/<\/skill_content/g,"&lt;/skill_content")}function ai(e,t){let n=pc(e.name),r=pc(e.source),o=pc(e.directoryPath),s=b0(t.trim());return`<skill_content name="${n}">
182
+ \u2026 \u4EE5\u4E0B ${c.length-d.length} \u884C\u672A\u663E\u793A`:m;return li(pr,{flexDirection:"column",paddingX:1,children:[o.truncated&&li($n,{color:uc,dimColor:!0,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF0C\u4EC5\u663E\u793A\u524D ",wm," \u5B57\u8282"]}),Ht($n,{children:h})]})}import{jsx as On,jsxs as cn}from"react/jsx-runtime";var km="#00ff41",mr="#808080",pc=4,A0=60,E0=20;function I0(e,t){return t<=0?"":e.length<=t?e:t<=1?"\u2026":e.slice(0,t-1)+"\u2026"}function fc({files:e,input:t,selectedIndex:n,cwd:r,width:o}){let s=ko(t,e);if(!s||s.length===0)return null;let i=ai,a=Math.max(1,Math.ceil(s.length/i)),[l,c]=v0(0);R0(()=>{c(R=>R<0||R>=s.length?Math.floor(n/i)*i:n<R?Math.max(0,Math.floor(n/i)*i):n>=R+i?Math.floor(n/i)*i:R)},[n,s.length,i]);let u=l,d=s.slice(u,u+i);if(!(o>=A0))return cn(ln,{flexDirection:"column",marginLeft:pc,marginTop:1,children:[cn(fr,{color:mr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),d.map((R,v)=>{let B=u+v===n;return On(ln,{children:cn(fr,{color:B?km:mr,children:[B?" \u203A ":" ",R]})},R)})]});let h=o-pc,f=Math.max(Math.floor(h/3),E0),g=Math.max(h-f-1,20),k=10,b=n>=0&&n<s.length?s[n]??null:null,S=Math.max(f-2,4);return cn(ln,{flexDirection:"row",paddingLeft:pc,marginTop:1,children:[cn(ln,{flexDirection:"column",width:f,flexShrink:0,children:[cn(fr,{color:mr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),On(ln,{flexDirection:"column",marginTop:1,children:d.map((R,v)=>{let B=u+v===n;return cn(fr,{color:B?km:mr,bold:B,children:[B?"\u25B8 ":" ",I0(R,S)]},R)})})]}),On(ln,{width:1,flexShrink:0,children:On(fr,{color:mr,children:"\u2502"})}),cn(ln,{flexDirection:"column",width:g,flexShrink:0,children:[On(fr,{color:mr,dimColor:!0,children:b?`\u{1F4C4} ${b}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),On(ln,{flexDirection:"column",marginTop:1,children:On(ci,{relativePath:b,cwd:r,width:g,maxLines:k})})]})]})}p();import{Box as vt,Text as Dn,useInput as P0}from"ink";import L0 from"ink-text-input";import{useEffect as Sm,useMemo as $0,useState as mc}from"react";import{jsx as lt,jsxs as Nn}from"react/jsx-runtime";var O0="#00ff41",So="#808080",ui="#00ffff",At=ai;function Tm({files:e,cwd:t,width:n,height:r,onPick:o,onClose:s}){let[i,a]=mc(""),[l,c]=mc(0),u=$0(()=>i.trim()?cc(i,e):[],[i,e]),d=Math.max(1,Math.ceil(u.length/At)),[m,h]=mc(0);Sm(()=>{h(0),c(0)},[i]),Sm(()=>{h(_=>u.length===0?0:_<0||_>=u.length?Math.floor(l/At)*At:l<_?Math.max(0,Math.floor(l/At)*At):l>=_+At?Math.floor(l/At)*At:_)},[l,u.length]);let f=m,g=u.slice(f,f+At),k=l>=f&&l<f+g.length?l-f:0;P0((_,B)=>{if(B.ctrl&&_==="p"){s();return}if(B.escape){s();return}if(B.upArrow){if(u.length===0)return;c(j=>(j-1+u.length)%u.length);return}if(B.downArrow){if(u.length===0)return;c(j=>(j+1)%u.length);return}if(B.return){let j=u[l];j&&o(j.path);return}},{isActive:!0});let b=Math.max(Math.floor(n/3),24),S=Math.max(n-b-1,20),R=Math.max(r-11,4),v=u[l]?.path??null;return Nn(vt,{flexDirection:"column",height:r,children:[Nn(vt,{flexDirection:"row",borderStyle:"round",borderColor:ui,paddingX:1,children:[lt(Dn,{bold:!0,color:ui,children:"\u{1F50D} "}),lt(vt,{flexGrow:1,children:lt(L0,{value:i,onChange:a,placeholder:"\u8F93\u5165\u6587\u4EF6\u540D"})})]}),Nn(vt,{flexDirection:"row",flexGrow:1,marginTop:1,children:[Nn(vt,{flexDirection:"column",width:b,borderStyle:"single",borderColor:ui,paddingX:1,flexShrink:0,children:[Nn(Dn,{color:So,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6 (",u.length," \u6761)",d>1?` \xB7 ${Math.floor(m/At)+1}/${d}`:""]}),lt(vt,{flexDirection:"column",marginTop:1,children:g.length===0?lt(Dn,{color:So,dimColor:!0,children:i.trim()?e.length===0?"\uFF08\u9879\u76EE\u65E0\u6587\u4EF6\uFF09":"\uFF08\u65E0\u5339\u914D\uFF09":"\uFF08\u8F93\u5165\u5173\u952E\u5B57\u5F00\u59CB\u5339\u914D\uFF09"}):g.map((_,B)=>{let j=B===k;return Nn(Dn,{color:j?O0:void 0,bold:j,children:[j?"\u25B8 ":" ",_.path]},_.path)})})]}),lt(vt,{width:1,flexShrink:0,children:lt(Dn,{color:So,children:"\u2502"})}),Nn(vt,{flexDirection:"column",width:S,borderStyle:"single",borderColor:ui,flexShrink:0,children:[lt(Dn,{color:So,dimColor:!0,children:v?`\u{1F4C4} ${v}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),lt(vt,{flexDirection:"column",marginTop:1,children:lt(ci,{relativePath:v,cwd:t,width:S,maxLines:R})})]})]}),lt(vt,{marginTop:1,children:lt(Dn,{color:So,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u56DE\u586B\u8DEF\u5F84\u5230\u8F93\u5165\u6846 \xB7 Esc / Ctrl+P \u5173\u95ED"})})]})}p();import{Text as Mn,useInput as D0}from"ink";import{jsx as To,jsxs as Cm}from"react/jsx-runtime";function _m({value:e,onChange:t,onSubmit:n,placeholder:r="",focus:o=!0}){if(D0((s,i)=>{if(o&&!(i.upArrow||i.downArrow||i.leftArrow||i.rightArrow)&&!(i.pageDown||i.pageUp||i.home||i.end)){if(i.return){n?.(e);return}if(!i.escape&&!i.tab&&!(i.shift&&i.tab)&&!i.ctrl){if(i.backspace||i.delete){t(e.slice(0,-1));return}s&&t(e+s)}}},{isActive:o}),!o)return!e&&r?To(Mn,{dimColor:!0,children:r}):To(Mn,{children:e});if(!e&&r){let s=r[0],i=r.slice(1);return Cm(Mn,{children:[To(Mn,{inverse:!0,children:s}),To(Mn,{dimColor:!0,children:i})]})}return Cm(Mn,{children:[e,To(Mn,{inverse:!0,children:" "})]})}p();p();function hc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function N0(e){return e.replace(/<skill_content/g,"&lt;skill_content").replace(/<\/skill_content/g,"&lt;/skill_content")}function di(e,t){let n=hc(e.name),r=hc(e.source),o=hc(e.directoryPath),s=N0(t.trim());return`<skill_content name="${n}">
180
183
  <source>${r}</source>
181
184
  <directory>${o}</directory>
182
185
  Relative paths in this skill resolve against <directory>.
183
186
 
184
187
  ${s}
185
188
  </skill_content>
186
- `}var w0=/^\/(\S+)(?:\s+(.*))?$/;async function xm(e,t){let n=w0.exec(e);if(!n)return{kind:"no-match"};let r=n[1],o=(n[2]??"").trim(),s=t.find(l=>l.name===r);if(!s)return{kind:"no-match"};let i;try{i=await ls(s.skillFilePath)}catch(l){return{kind:"error",message:l instanceof Error?l.message:String(l)}}let a=ai(s,i);return{kind:"text",text:o?`${a}
189
+ `}var M0=/^\/(\S+)(?:\s+(.*))?$/;async function Rm(e,t){let n=M0.exec(e);if(!n)return{kind:"no-match"};let r=n[1],o=(n[2]??"").trim(),s=t.find(l=>l.name===r);if(!s)return{kind:"no-match"};let i;try{i=await ds(s.skillFilePath)}catch(l){return{kind:"error",message:l instanceof Error?l.message:String(l)}}let a=di(s,i);return{kind:"text",text:o?`${a}
187
190
 
188
- ${o}`:a}}p();import{Box as fc,Text as Fn}from"ink";import k0 from"ink-spinner";import{jsx as Et,jsxs as wm}from"react/jsx-runtime";function bm(e){switch(e){case"pending":return"\u2610";case"done":return"\u2611";case"failed":return"\u2717";case"skipped":return"\u2298";case"running":return"\u25B6"}}function S0({status:e}){return e==="running"?Et(Fn,{color:"cyan",children:Et(k0,{type:"dots"})}):e==="done"?Et(Fn,{color:"green",children:"\u2705"}):e==="failed"?Et(Fn,{color:"red",children:bm(e)}):Et(Fn,{dimColor:!0,children:bm(e)})}function mc({items:e}){return e.length===0?null:wm(fc,{flexDirection:"column",marginTop:1,children:[Et(fc,{children:Et(Fn,{dimColor:!0,children:"\u{1F527} \u4EFB\u52A1\u8FDB\u5EA6"})}),e.map(t=>wm(fc,{children:[Et(Fn,{dimColor:!0,children:" "}),Et(S0,{status:t.status}),Et(Fn,{dimColor:!0,children:` ${t.content}`})]},t.id))]})}p();import{Box as Be,Text as ke}from"ink";import T0 from"ink-spinner";import{useMemo as km}from"react";import{Fragment as I0,jsx as ye,jsxs as _e}from"react/jsx-runtime";function C0(e){if(e.phase==="idle")return 0;if(e.phase==="done"||e.phase==="error")return 100;let t=e.progress;if(!t)return 5;if(t.type==="start")return 10;if(t.type==="summary_delta"){let n=Math.min(t.totalSoFar.length/800,1);return Math.min(10+n*80,90)}return t.type==="fallback"?95:5}function _0(e){if(e.phase==="error")return{icon:"\u2717",text:"\u538B\u7F29\u51FA\u9519",color:"#ff6347"};if(e.phase==="done")return e.strategy==="fallback"?{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210\uFF08\u672C\u5730\u515C\u5E95\uFF09",color:"#ff9800"}:{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210",color:"#00ff41"};let t=e.progress;return t?t.type==="start"?{icon:"\u280B",text:`\u51C6\u5907\u6458\u8981 ${t.droppedTurns} \u4E2A\u65E7\u56DE\u5408...`,color:"#00ffff"}:t.type==="summary_delta"?{icon:"\u280B",text:"\u8C03\u7528 LLM \u751F\u6210\u6458\u8981...",color:"#00ffff"}:t.type==="fallback"?{icon:"\u26A0",text:`LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\uFF1A${t.reason}`,color:"#ff9800"}:{icon:"\u280B",text:"\u538B\u7F29\u4E2D...",color:"#00ffff"}:{icon:"\u280B",text:"\u51C6\u5907\u538B\u7F29...",color:"#00ffff"}}function v0({percent:e,color:t}){let r=Math.round(e/100*24),o=24-r;return _e(ke,{children:[ye(ke,{color:t,children:"\u2588".repeat(r)}),ye(ke,{color:"#444444",children:"\u2591".repeat(o)}),_e(ke,{color:t,children:[" ",e.toFixed(0),"%"]})]})}function R0({state:e}){let t=(()=>{if(e.phase==="idle")return 0;if(e.phase==="error"){let o=e.progress;return o?.type==="summary_delta"||o?.type==="start"?1:2}if(e.phase==="done")return 3;let r=e.progress;return!r||r.type==="start"?0:r.type==="summary_delta"?1:(r.type==="fallback",2)})(),n=["\u542F\u52A8","LLM \u6458\u8981","\u5E94\u7528\u538B\u7F29","\u5B8C\u6210"];return ye(Be,{children:n.map((r,o)=>{let s=o===t,i=o<t;return _e(Be,{marginRight:1,children:[_e(ke,{color:i?"#00ff41":s?"#00ffff":"#444444",children:[i?"\u2713":s?"\u25B8":"\xB7"," ",r]}),o<n.length-1&&ye(ke,{color:"#444444",children:" \u2192 "})]},r)})})}function A0({text:e,contentWidth:t}){let r=Math.max(t-6,20);if(!e)return ye(ke,{dimColor:!0,children:" (\u7B49\u5F85 LLM \u8F93\u51FA...)"});let s=E0(e,r).slice(-4);return ye(Be,{flexDirection:"column",children:s.map((i,a)=>_e(ke,{dimColor:!0,children:[" ",i]},a))})}function E0(e,t){if(e==="")return[];if(t<=0)return[e];let n=[];for(let r of e.split(`
189
- `)){if(r.length===0){n.push("");continue}let o="",s=0;for(let i of r){let l=i.codePointAt(0)>11904?2:1;s+l>t&&o.length>0?(n.push(o),o=i,s=l):(o+=i,s+=l)}o.length>0&&n.push(o)}return n}function Sm(e){return e.toLocaleString()}function hc({state:e,contentWidth:t}){let n=km(()=>C0(e),[e]),r=km(()=>_0(e),[e]),o=e.progress?.type==="summary_delta"?e.progress.totalSoFar:e.progress?.type==="fallback"?e.progress.fallbackSummary:(e.phase==="done"&&e.strategy==="summary",""),s=e.phase==="done"&&e.strategy==="summary"?e.progress?.type==="summary_delta"?e.progress.totalSoFar:"":o,i=e.phase==="error"?"#ff6347":"#00ffff";return ye(Be,{flexDirection:"column",marginTop:1,children:_e(Be,{flexDirection:"row",children:[ye(Be,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),_e(Be,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[_e(Be,{children:[ye(ke,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),ye(Be,{flexGrow:1}),e.phase==="running"&&_e(ke,{color:r.color,children:[ye(T0,{type:"dots"})," ",r.text]}),e.phase==="done"&&_e(ke,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&_e(ke,{color:r.color,children:[r.icon," ",r.text]})]}),_e(Be,{marginTop:1,children:[ye(ke,{color:"#808080",children:"\u8FDB\u5EA6: "}),ye(v0,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),ye(Be,{marginTop:1,children:ye(R0,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&_e(Be,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&_e(ke,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&_e(ke,{color:"#ff9800",children:["\u{1F4E6} token: ",Sm(e.beforeTokens),e.afterTokens!==void 0&&_e(I0,{children:[" \u2192 ",ye(ke,{color:"#00ff41",bold:!0,children:Sm(e.afterTokens)}),_e(ke,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&_e(Be,{marginTop:1,flexDirection:"column",children:[ye(ke,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),ye(A0,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&ye(Be,{marginTop:1,children:ye(ke,{color:"#ff9800",children:"\u26A0 LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\u6458\u8981\u3002\u538B\u7F29\u5DF2\u751F\u6548\u4F46\u6458\u8981\u8D28\u91CF\u8F83\u4F4E\u3002"})}),e.phase==="error"&&e.errorMessage&&ye(Be,{marginTop:1,children:_e(ke,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var Tm={name:"dskcode",version:"0.1.48",keywords:["cli","ink","commander","deepseek","asciichart"],description:"A DeepSeek-native AI coding agent for your terminal",type:"module",bin:{dskcode:"dist/index.js"},exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist","README.md","LICENSE","!dist/**/*.map"],scripts:{dev:"tsup --watch",debug:"npm run build && node dist/index.js",build:"tsup",obfuscate:"node scripts/obfuscate.mjs","build:clean":"node scripts/clean-sourcemaps.mjs","type-check":"tsc --noEmit",format:"prettier --write src/ tests/","format:check":"prettier --check src/ tests/",test:"vitest run --exclude 'tests/checkpoint.test.ts' --exclude 'tests/session-rewind.test.ts'","test:checkpoint":"vitest run tests/checkpoint.test.ts tests/session-rewind.test.ts",prepublishOnly:"npm run build && npm run test && npm run build:clean"},dependencies:{asciichart:"^1.5.25",chalk:"^5.6.2",commander:"^13.1.0",handlebars:"^4.7.9",ink:"^7.1.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0",react:"^19.2.7",ws:"^8.21.0",yaml:"^2.6.0",zod:"^3.25.76"},devDependencies:{"@shikijs/cli":"^4.3.1","@types/node":"^22.14.0","@types/react":"^19.2.17","@types/ws":"^8.18.1","javascript-obfuscator":"^4.1.1",prettier:"^3.5.3",tsup:"^8.4.0",typescript:"^5.8.3",vitest:"^3.1.1"},engines:{node:">=22.0.0"},license:"MIT"};var So=Tm.version;p();p();var li=class{#e=new Map;#n=new Map;register(t,n){this.#e.set(t,n)}get(t,n){if(!ka(n.model))throw new Sa(n.model);let r=`${t}:${n.baseUrl}:${n.model}`,o=this.#n.get(r);if(o)return o;let s=this.#e.get(t);if(!s){let a=[...this.#e.keys()].join(", ");throw new Error(`\u672A\u6CE8\u518C\u7684 Provider: "${t}"\u3002\u53EF\u7528: ${a}`)}let i=s(n);return this.#n.set(r,i),i}list(){return[...this.#e.keys()]}clear(){this.#n.clear()}},gc=new li;gc.register("deepseek",e=>new Ta({apiKey:e.apiKey,baseUrl:e.baseUrl,model:e.model}));function yc(e){return gc.get(e.name,e)}p();p();import vm from"handlebars";var Cm=`\u4F60\u662F dskcode\uFF0C\u4E00\u4E2A\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u7EC8\u7AEF\u4E2D\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u5F00\u53D1\u8005\u7F16\u5199\u3001\u7406\u89E3\u3001\u8C03\u8BD5\u548C\u91CD\u6784\u4EE3\u7801\u3002\r
191
+ ${o}`:a}}p();import{Box as gc,Text as Bn}from"ink";import B0 from"ink-spinner";import{jsx as Et,jsxs as Am}from"react/jsx-runtime";function vm(e){switch(e){case"pending":return"\u2610";case"done":return"\u2611";case"failed":return"\u2717";case"skipped":return"\u2298";case"running":return"\u25B6"}}function F0({status:e}){return e==="running"?Et(Bn,{color:"cyan",children:Et(B0,{type:"dots"})}):e==="done"?Et(Bn,{color:"green",children:"\u2705"}):e==="failed"?Et(Bn,{color:"red",children:vm(e)}):Et(Bn,{dimColor:!0,children:vm(e)})}function yc({items:e}){return e.length===0?null:Am(gc,{flexDirection:"column",marginTop:1,children:[Et(gc,{children:Et(Bn,{dimColor:!0,children:"\u{1F527} \u4EFB\u52A1\u8FDB\u5EA6"})}),e.map(t=>Am(gc,{children:[Et(Bn,{dimColor:!0,children:" "}),Et(F0,{status:t.status}),Et(Bn,{dimColor:!0,children:` ${t.content}`})]},t.id))]})}p();import{Box as Be,Text as Se}from"ink";import G0 from"ink-spinner";import{useMemo as Em}from"react";import{Fragment as q0,jsx as ye,jsxs as _e}from"react/jsx-runtime";function j0(e){if(e.phase==="idle")return 0;if(e.phase==="done"||e.phase==="error")return 100;let t=e.progress;if(!t)return 5;if(t.type==="start")return 10;if(t.type==="summary_delta"){let n=Math.min(t.totalSoFar.length/800,1);return Math.min(10+n*80,90)}return t.type==="fallback"?95:5}function U0(e){if(e.phase==="error")return{icon:"\u2717",text:"\u538B\u7F29\u51FA\u9519",color:"#ff6347"};if(e.phase==="done")return e.strategy==="fallback"?{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210\uFF08\u672C\u5730\u515C\u5E95\uFF09",color:"#ff9800"}:{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210",color:"#00ff41"};let t=e.progress;return t?t.type==="start"?{icon:"\u280B",text:`\u51C6\u5907\u6458\u8981 ${t.droppedTurns} \u4E2A\u65E7\u56DE\u5408...`,color:"#00ffff"}:t.type==="summary_delta"?{icon:"\u280B",text:"\u8C03\u7528 LLM \u751F\u6210\u6458\u8981...",color:"#00ffff"}:t.type==="fallback"?{icon:"\u26A0",text:`LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\uFF1A${t.reason}`,color:"#ff9800"}:{icon:"\u280B",text:"\u538B\u7F29\u4E2D...",color:"#00ffff"}:{icon:"\u280B",text:"\u51C6\u5907\u538B\u7F29...",color:"#00ffff"}}function W0({percent:e,color:t}){let r=Math.round(e/100*24),o=24-r;return _e(Se,{children:[ye(Se,{color:t,children:"\u2588".repeat(r)}),ye(Se,{color:"#444444",children:"\u2591".repeat(o)}),_e(Se,{color:t,children:[" ",e.toFixed(0),"%"]})]})}function H0({state:e}){let t=(()=>{if(e.phase==="idle")return 0;if(e.phase==="error"){let o=e.progress;return o?.type==="summary_delta"||o?.type==="start"?1:2}if(e.phase==="done")return 3;let r=e.progress;return!r||r.type==="start"?0:r.type==="summary_delta"?1:(r.type==="fallback",2)})(),n=["\u542F\u52A8","LLM \u6458\u8981","\u5E94\u7528\u538B\u7F29","\u5B8C\u6210"];return ye(Be,{children:n.map((r,o)=>{let s=o===t,i=o<t;return _e(Be,{marginRight:1,children:[_e(Se,{color:i?"#00ff41":s?"#00ffff":"#444444",children:[i?"\u2713":s?"\u25B8":"\xB7"," ",r]}),o<n.length-1&&ye(Se,{color:"#444444",children:" \u2192 "})]},r)})})}function V0({text:e,contentWidth:t}){let r=Math.max(t-6,20);if(!e)return ye(Se,{dimColor:!0,children:" (\u7B49\u5F85 LLM \u8F93\u51FA...)"});let s=z0(e,r).slice(-4);return ye(Be,{flexDirection:"column",children:s.map((i,a)=>_e(Se,{dimColor:!0,children:[" ",i]},a))})}function z0(e,t){if(e==="")return[];if(t<=0)return[e];let n=[];for(let r of e.split(`
192
+ `)){if(r.length===0){n.push("");continue}let o="",s=0;for(let i of r){let l=i.codePointAt(0)>11904?2:1;s+l>t&&o.length>0?(n.push(o),o=i,s=l):(o+=i,s+=l)}o.length>0&&n.push(o)}return n}function Im(e){return e.toLocaleString()}function xc({state:e,contentWidth:t}){let n=Em(()=>j0(e),[e]),r=Em(()=>U0(e),[e]),o=e.progress?.type==="summary_delta"?e.progress.totalSoFar:e.progress?.type==="fallback"?e.progress.fallbackSummary:(e.phase==="done"&&e.strategy==="summary",""),s=e.phase==="done"&&e.strategy==="summary"?e.progress?.type==="summary_delta"?e.progress.totalSoFar:"":o,i=e.phase==="error"?"#ff6347":"#00ffff";return ye(Be,{flexDirection:"column",marginTop:1,children:_e(Be,{flexDirection:"row",children:[ye(Be,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),_e(Be,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[_e(Be,{children:[ye(Se,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),ye(Be,{flexGrow:1}),e.phase==="running"&&_e(Se,{color:r.color,children:[ye(G0,{type:"dots"})," ",r.text]}),e.phase==="done"&&_e(Se,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&_e(Se,{color:r.color,children:[r.icon," ",r.text]})]}),_e(Be,{marginTop:1,children:[ye(Se,{color:"#808080",children:"\u8FDB\u5EA6: "}),ye(W0,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),ye(Be,{marginTop:1,children:ye(H0,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&_e(Be,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&_e(Se,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&_e(Se,{color:"#ff9800",children:["\u{1F4E6} token: ",Im(e.beforeTokens),e.afterTokens!==void 0&&_e(q0,{children:[" \u2192 ",ye(Se,{color:"#00ff41",bold:!0,children:Im(e.afterTokens)}),_e(Se,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&_e(Be,{marginTop:1,flexDirection:"column",children:[ye(Se,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),ye(V0,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&ye(Be,{marginTop:1,children:ye(Se,{color:"#ff9800",children:"\u26A0 LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\u6458\u8981\u3002\u538B\u7F29\u5DF2\u751F\u6548\u4F46\u6458\u8981\u8D28\u91CF\u8F83\u4F4E\u3002"})}),e.phase==="error"&&e.errorMessage&&ye(Be,{marginTop:1,children:_e(Se,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var Pm={name:"dskcode",version:"0.1.50",keywords:["cli","ink","commander","deepseek","asciichart"],description:"A DeepSeek-native AI coding agent for your terminal",type:"module",bin:{dskcode:"dist/index.js"},exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist","README.md","LICENSE","!dist/**/*.map"],scripts:{dev:"tsup --watch",debug:"npm run build && node dist/index.js",build:"tsup",obfuscate:"node scripts/obfuscate.mjs","build:clean":"node scripts/clean-sourcemaps.mjs","type-check":"tsc --noEmit",format:"prettier --write src/ tests/","format:check":"prettier --check src/ tests/",test:"vitest run --exclude 'tests/checkpoint.test.ts' --exclude 'tests/session-rewind.test.ts'","test:checkpoint":"vitest run tests/checkpoint.test.ts tests/session-rewind.test.ts",prepublishOnly:"npm run build && npm run test && npm run build:clean"},dependencies:{asciichart:"^1.5.25",chalk:"^5.6.2",commander:"^13.1.0",handlebars:"^4.7.9",ink:"^7.1.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0",react:"^19.2.7",ws:"^8.21.0",yaml:"^2.6.0",zod:"^3.25.76"},devDependencies:{"@shikijs/cli":"^4.3.1","@types/node":"^22.14.0","@types/react":"^19.2.17","@types/ws":"^8.18.1","javascript-obfuscator":"^4.1.1",prettier:"^3.5.3",tsup:"^8.4.0",typescript:"^5.8.3",vitest:"^3.1.1"},engines:{node:">=22.0.0"},license:"MIT"};var Co=Pm.version;p();p();var pi=class{#e=new Map;#n=new Map;register(t,n){this.#e.set(t,n)}get(t,n){if(!_a(n.model))throw new Ra(n.model);let r=`${t}:${n.baseUrl}:${n.model}`,o=this.#n.get(r);if(o)return o;let s=this.#e.get(t);if(!s){let a=[...this.#e.keys()].join(", ");throw new Error(`\u672A\u6CE8\u518C\u7684 Provider: "${t}"\u3002\u53EF\u7528: ${a}`)}let i=s(n);return this.#n.set(r,i),i}list(){return[...this.#e.keys()]}clear(){this.#n.clear()}},bc=new pi;bc.register("deepseek",e=>new va({apiKey:e.apiKey,baseUrl:e.baseUrl,model:e.model}));function wc(e){return bc.get(e.name,e)}p();p();import Om from"handlebars";var Lm=`\u4F60\u662F dskcode\uFF0C\u4E00\u4E2A\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u7EC8\u7AEF\u4E2D\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u5F00\u53D1\u8005\u7F16\u5199\u3001\u7406\u89E3\u3001\u8C03\u8BD5\u548C\u91CD\u6784\u4EE3\u7801\u3002\r
190
193
  \r
191
194
  ## \u6838\u5FC3\u539F\u5219\r
192
195
  - \u56DE\u7B54\u4F7F\u7528\u4E2D\u6587\uFF0C\u4EE3\u7801\u6807\u8BC6\u7B26\u4FDD\u6301\u82F1\u6587\r
@@ -361,7 +364,7 @@ ${o}`:a}}p();import{Box as fc,Text as Fn}from"ink";import k0 from"ink-spinner";i
361
364
  - \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r
362
365
  - \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r
363
366
  - \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r
364
- `;var _m=`\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r
367
+ `;var $m=`\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r
365
368
  \r
366
369
  \u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C**\u4F60\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u80FD\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u64CD\u4F5C**\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u7528\u6237\u7406\u89E3\u4EE3\u7801\u3001\u8BBE\u8BA1\u67B6\u6784\u3001\u89C4\u5212\u4EFB\u52A1\u3001\u8BC4\u4F30\u65B9\u6848\u3002\r
367
370
  \r
@@ -461,7 +464,7 @@ ${o}`:a}}p();import{Box as fc,Text as Fn}from"ink";import k0 from"ink-spinner";i
461
464
  - \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r
462
465
  - \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r
463
466
  - \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r
464
- `;var O0=vm.compile(Cm),D0=vm.compile(_m);function N0(e){return e.map(t=>{let n=t.parameters&&Object.keys(t.parameters.properties??{}).join(", ");return{name:t.name,description:t.description,params:n||void 0}})}function Rm(e){let t=new Date,n=t.toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric",weekday:"long"}),r=t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return{model:e.model,maxToolRounds:e.maxToolRounds,cwd:e.cwd,date:n,time:r,tools:e.tools?N0(e.tools):void 0,projectContext:e.projectContext??void 0,skills:e.availableSkills,hasSkills:(e.availableSkills?.length??0)>0}}function Am(e){return O0(Rm(e))}function Em(e){return D0(Rm(e))}p();function Pm(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Yn(t)+10}function ci(e){let t=[],n=null;for(let r of e)r.role==="user"?(n&&t.push(n),n=[r]):(n||(n=[]),n.push(r));return n&&n.length>0&&t.push(n),t}function Im(e){let t=0;for(let n of e)t+=Pm(n);return t}function Lm(e,t){let r=tn(t.model).contextWindow-t.reservedForOutput,o=Yn(t.systemPrompt),s=r-o,i=ci(e),a=[],l=0;for(let f=i.length-1;f>=0&&l<t.preserveRecentRounds;f--)a.unshift(i[f]),l++;let c=a.flat();for(let f of c)s-=Pm(f);if(s<0){for(;a.length>1&&s<0;){let f=a.shift();s+=Im(f)}return[a.flat(),!0]}let u=i.slice(0,i.length-a.length),d=[];for(let f=u.length-1;f>=0;f--){let g=Im(u[f]);if(s-g<0)break;s-=g,d.unshift(u[f])}let m=[...d,...a].flat(),h=m.length<e.length;return[m,h]}function $m(e,t){return[{role:"system",content:e},...t]}p();var bc=.85,wc=6,ui=8,M0="[history-summary]",B0=`\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u5BF9\u8BDD\u6458\u8981\u52A9\u624B\u3002\u4F60\u7684\u4EFB\u52A1\u662F\u628A\u591A\u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u4E2D\u6587\u6458\u8981\u3002
467
+ `;var Z0=Om.compile(Lm),Y0=Om.compile($m);function Q0(e){return e.map(t=>{let n=t.parameters&&Object.keys(t.parameters.properties??{}).join(", ");return{name:t.name,description:t.description,params:n||void 0}})}function Dm(e){let t=new Date,n=t.toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric",weekday:"long"}),r=t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return{model:e.model,maxToolRounds:e.maxToolRounds,cwd:e.cwd,date:n,time:r,tools:e.tools?Q0(e.tools):void 0,projectContext:e.projectContext??void 0,skills:e.availableSkills,hasSkills:(e.availableSkills?.length??0)>0}}function Nm(e){return Z0(Dm(e))}function Mm(e){return Y0(Dm(e))}p();function Fm(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Jn(t)+10}function fi(e){let t=[],n=null;for(let r of e)r.role==="user"?(n&&t.push(n),n=[r]):(n||(n=[]),n.push(r));return n&&n.length>0&&t.push(n),t}function Bm(e){let t=0;for(let n of e)t+=Fm(n);return t}function Gm(e,t){let r=tn(t.model).contextWindow-t.reservedForOutput,o=Jn(t.systemPrompt),s=r-o,i=fi(e),a=[],l=0;for(let f=i.length-1;f>=0&&l<t.preserveRecentRounds;f--)a.unshift(i[f]),l++;let c=a.flat();for(let f of c)s-=Fm(f);if(s<0){for(;a.length>1&&s<0;){let f=a.shift();s+=Bm(f)}return[a.flat(),!0]}let u=i.slice(0,i.length-a.length),d=[];for(let f=u.length-1;f>=0;f--){let g=Bm(u[f]);if(s-g<0)break;s-=g,d.unshift(u[f])}let m=[...d,...a].flat(),h=m.length<e.length;return[m,h]}function jm(e,t){return[{role:"system",content:e},...t]}p();var Sc=.85,Tc=6,mi=8,eS="[history-summary]",tS=`\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u5BF9\u8BDD\u6458\u8981\u52A9\u624B\u3002\u4F60\u7684\u4EFB\u52A1\u662F\u628A\u591A\u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u4E2D\u6587\u6458\u8981\u3002
465
468
 
466
469
  \u6458\u8981\u5FC5\u987B\u4FDD\u7559\u4EE5\u4E0B\u4FE1\u606F\uFF08\u6309\u91CD\u8981\u6027\u6392\u5E8F\uFF09\uFF1A
467
470
  1. \u7528\u6237\u7684\u6838\u5FC3\u76EE\u6807\u4E0E\u6700\u7EC8\u610F\u56FE
@@ -476,21 +479,21 @@ ${o}`:a}}p();import{Box as fc,Text as Fn}from"ink";import k0 from"ink-spinner";i
476
479
  - \u6BCF\u6761\u4FE1\u606F\u72EC\u7ACB\u6210\u884C\uFF0C\u65B9\u4FBF\u540E\u7EED\u6309\u884C\u89E3\u6790
477
480
  - \u603B\u957F\u5EA6\u63A7\u5236\u5728 2000 \u5B57\u4EE5\u5185
478
481
  - \u4E0D\u9700\u8981\u5BA2\u5957\u8BDD\u3001\u4E0D\u9700\u8981"\u4EE5\u4E0B\u662F\u6458\u8981"\u7B49\u5F00\u5934
479
- `,Om=500,F0=60;function G0(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Yn(t)+10}function xc(e){let t=0;for(let n of e)t+=G0(n);return t}function kc(e,t){let n=xc(e),r=t>0?n/t:0;return{messageCount:e.length,estimatedTokens:n,contextWindow:t,ratio:r,headroom:t-n}}function Nm(e,t){let n=ci(e),r=t.minTurnsToCompact??ui;if(n.length<r)return!1;let o=t.autoCompactRatio??bc;return kc(e,t.contextWindow).ratio>=o}function j0(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(`--- \u7B2C ${n+1} \u56DE\u5408 ---`);for(let o of r){let s=`[${o.role}]`,i=o.content.length>Om?o.content.slice(0,Om)+`\u2026(\u5DF2\u622A\u65AD,\u539F\u957F ${o.content.length})`:o.content;if(t.push(`${s} ${i}`),o.toolCalls)for(let a of o.toolCalls)t.push(` tool_call: ${a.name}(${a.arguments})`)}}return t.join(`
480
- `)}function Dm(e){let t=["\u3010\u672C\u5730\u6458\u8981\uFF08LLM \u8C03\u7528\u5931\u8D25\u65F6\u515C\u5E95\uFF09\u3011"];for(let n=0;n<e.length;n++){let r=e[n],o=r.find(i=>i.role==="user");if(o){let i=o.content.slice(0,F0);t.push(`\u56DE\u5408${n+1} \u7528\u6237: ${i}`)}let s=[];for(let i of r)if(i.toolCalls)for(let a of i.toolCalls)s.push({name:a.name,argsRaw:a.arguments});if(s.length>0){let i=s.map(a=>{let l=or(a.argsRaw);return l.ok?us(a.name,jr(l.args)):`${a.name}(\u89E3\u6790\u5931\u8D25)`});t.push(` \u8C03\u7528\u5DE5\u5177: ${i.join("; ")}`)}}return t.join(`
481
- `)}async function U0(e,t){if(e.length===0)return"";let n=j0(e);try{let r=[{role:"system",content:B0},{role:"user",content:`\u8BF7\u628A\u4EE5\u4E0B ${e.length} \u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u6458\u8981\uFF1A
482
+ `,Um=500,nS=60;function rS(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Jn(t)+10}function kc(e){let t=0;for(let n of e)t+=rS(n);return t}function Cc(e,t){let n=kc(e),r=t>0?n/t:0;return{messageCount:e.length,estimatedTokens:n,contextWindow:t,ratio:r,headroom:t-n}}function Hm(e,t){let n=fi(e),r=t.minTurnsToCompact??mi;if(n.length<r)return!1;let o=t.autoCompactRatio??Sc;return Cc(e,t.contextWindow).ratio>=o}function oS(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(`--- \u7B2C ${n+1} \u56DE\u5408 ---`);for(let o of r){let s=`[${o.role}]`,i=o.content.length>Um?o.content.slice(0,Um)+`\u2026(\u5DF2\u622A\u65AD,\u539F\u957F ${o.content.length})`:o.content;if(t.push(`${s} ${i}`),o.toolCalls)for(let a of o.toolCalls)t.push(` tool_call: ${a.name}(${a.arguments})`)}}return t.join(`
483
+ `)}function Wm(e){let t=["\u3010\u672C\u5730\u6458\u8981\uFF08LLM \u8C03\u7528\u5931\u8D25\u65F6\u515C\u5E95\uFF09\u3011"];for(let n=0;n<e.length;n++){let r=e[n],o=r.find(i=>i.role==="user");if(o){let i=o.content.slice(0,nS);t.push(`\u56DE\u5408${n+1} \u7528\u6237: ${i}`)}let s=[];for(let i of r)if(i.toolCalls)for(let a of i.toolCalls)s.push({name:a.name,argsRaw:a.arguments});if(s.length>0){let i=s.map(a=>{let l=tr(a.argsRaw);return l.ok?fs(a.name,Gr(l.args)):`${a.name}(\u89E3\u6790\u5931\u8D25)`});t.push(` \u8C03\u7528\u5DE5\u5177: ${i.join("; ")}`)}}return t.join(`
484
+ `)}async function sS(e,t){if(e.length===0)return"";let n=oS(e);try{let r=[{role:"system",content:tS},{role:"user",content:`\u8BF7\u628A\u4EE5\u4E0B ${e.length} \u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u6458\u8981\uFF1A
482
485
 
483
- ${n}`}],o=t.provider.chat(r,{...t.signal?{signal:t.signal}:{},temperature:.2}),s="";for await(let i of o)if(i.content&&(s+=i.content,t.onProgress))try{t.onProgress({type:"summary_delta",delta:i.content,totalSoFar:s})}catch{}if(!s.trim()){let i=Dm(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:"LLM \u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32",fallbackSummary:i})}catch{}return i}return s.trim()}catch(r){let o=r instanceof Error?r.message:String(r),s=Dm(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:o,fallbackSummary:s})}catch{}return s}}function W0(e){return{role:"system",content:`${M0}
484
- ${e}`}}async function Sc(e,t){let n=xc(e),r=ci(e),o=t.minTurnsToCompact??ui,s=t.preserveRecentRounds??wc;if(r.length<o)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};if(r.length<=s)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};let i=r.length-s,a=r.slice(0,i),l=r.slice(i);if(t.onProgress)try{t.onProgress({type:"start",droppedTurns:a.length,beforeTokens:n})}catch{}let c=await U0(a,t),u=[W0(c)];for(let m of l)for(let h of m)u.push(h);let d=xc(u);if(t.onProgress)try{t.onProgress({type:"done",droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d})}catch{}return{messages:u,summary:c,droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d}}p();var un=class{#e=new Map;#n;#r;#s;static ALL_TOOL_NAMES=[];constructor(t){this.#n=new Set(t?.disabledTools??[]),this.#r=t?.featureFlagChecker??(()=>!0),this.#s=t?.provider}register(t){return this.registerErased(Oe(t))}registerErased(t){if(this.#e.has(t.name))throw new Error(`\u5DE5\u5177 "${t.name}" \u5DF2\u6CE8\u518C\uFF0C\u4E0D\u80FD\u91CD\u590D\u6CE8\u518C`);return this.#e.set(t.name,t),this}registerAll(t){for(let n of t)this.registerErased(n);return this}unregister(t){return this.#e.delete(t)}get(t){if(this.#t(t))return this.#e.get(t)}list(){let t=[];for(let[n,r]of this.#e)this.#t(n)&&t.push(r);return t}listByKind(t){return this.list().filter(n=>n.kind===t)}listReadTools(){return this.listByKind("read")}listWriteTools(){return this.list().filter(t=>!Qn(t.kind))}names(){return[...this.#e.keys()]}has(t){return this.#e.has(t)}isEnabled(t){return this.#e.has(t)&&this.#t(t)}disable(t){this.#n.add(t)}enable(t){this.#n.delete(t)}kindOf(t){return this.#e.get(t)?.kind}async execute(t,n,r){let o=this.get(t);if(!o)return{success:!1,data:`\u5DE5\u5177 "${t}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`,error:"TOOL_NOT_FOUND"};try{return await o.execute(n,r)}catch(s){let i=s instanceof Error?s.message:String(s);return{success:!1,data:`\u5DE5\u5177 "${t}" \u6267\u884C\u5F02\u5E38\uFF1A${i}`,error:"EXECUTION_ERROR"}}}#t(t){let n=this.#e.get(t);return!(!n||this.#n.has(t)||!this.#r(t)||this.#s&&n.supportedProviders.length>0&&!n.supportedProviders.includes(this.#s))}};p();p();p();import{z as KO}from"zod";function Tc(e,t){let n=t.safeParse(e);if(n.success)return{ok:!0,issues:[]};let r=n.error.issues.map(o=>H0(o,e));return{ok:r.length===0,issues:r}}function H0(e,t){let n=V0(e.path),r=z0(e),o=q0(t,e.path),s=K0(n,r,o,e);return{path:n,expected:r,received:o,message:s}}function V0(e){if(e.length===0)return"$";let t="$";for(let n of e)typeof n=="number"?t+=`[${n}]`:typeof n=="string"?t+=`.${n}`:t+="[]";return t}function z0(e){switch(e.code){case"invalid_type":return e.expected;case"too_small":{let t=e.type,n=e.minimum;return t==="string"?`length >= ${n}`:t==="array"?`length >= ${n}`:t==="number"?`>= ${n}`:`>= ${n}`}case"too_big":{let t=e.type,n=e.maximum;return t==="string"?`length <= ${n}`:t==="array"?`length <= ${n}`:t==="number"?`<= ${n}`:`<= ${n}`}case"invalid_enum_value":return`enum[${e.options.map(n=>JSON.stringify(n)).join(",")}]`;case"invalid_string":return`string ${e.validation}`;case"unrecognized_keys":return`\u672A\u5728 schema \u4E2D\u5B9A\u4E49: ${e.keys.join(",")}`;case"invalid_literal":{let t=e.expected;return`literal[${JSON.stringify(t)}]`}default:return e.code}}function q0(e,t){let n=e;for(let r of t){if(n==null||typeof n!="object")return"undefined";if(typeof r=="number"){if(!Array.isArray(n))return"undefined";n=n[r]}else if(typeof r=="string")n=n[r];else return"undefined"}return n===null?"null":n===void 0?"undefined":typeof n=="string"?n.length>60?JSON.stringify(n.slice(0,57)+"..."):JSON.stringify(n):typeof n=="number"||typeof n=="boolean"?JSON.stringify(n):Array.isArray(n)?`array(len=${n.length})`:typeof n=="object"?`object{keys=${Object.keys(n).length}}`:typeof n}function K0(e,t,n,r){if(r.code==="invalid_type")return`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="too_small"){let o=r.type,s=r.minimum;return o==="string"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="too_big"){let o=r.type,s=r.maximum;return o==="string"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="invalid_enum_value")return`${e} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="unrecognized_keys"){let o=r.keys;return`${e} \u4E0D\u5141\u8BB8\u952E: ${o.join(", ")}`}return r.code==="invalid_literal"?`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`:r.code==="invalid_string"?`${e} \u4E0D\u5339\u914D ${t}`:`${e} ${r.message}\uFF08\u671F\u671B ${t}\uFF0C\u5B9E\u9645 ${n}\uFF09`}function Mm(e,t){if(X0(t))return Tc(e,t);let n=[];return Gm(t)?t.type!==void 0&&t.type!=="object"?{ok:!0,issues:n}:(Bm(e,t,"$",n),{ok:n.length===0,issues:n}):{ok:!0,issues:n}}function X0(e){if(e===null||typeof e!="object")return!1;let t=e;return"_def"in t&&typeof t.parse=="function"&&typeof t.safeParse=="function"}function Bm(e,t,n,r){if(!Gm(e)){r.push({path:n,expected:"object",received:dn(e),message:`${n} \u5E94\u4E3A object\uFF0C\u5B9E\u9645\u4E3A ${dn(e)}`});return}for(let i of t.required??[])i in e||r.push({path:`${n}.${i}`,expected:"present",received:"missing",message:`${n}.${i} \u662F\u5FC5\u586B\u5B57\u6BB5`});let o=t.properties??{},s=t.additionalProperties;for(let[i,a]of Object.entries(e)){let l=o[i];if(l===void 0){s===!1&&r.push({path:`${n}.${i}`,expected:"\u672A\u5728 schema \u4E2D\u5B9A\u4E49",received:dn(a),message:`${n}.${i} \u4E0D\u5728\u5141\u8BB8\u5B57\u6BB5\u4E2D`});continue}Fm(a,l,`${n}.${i}`,r)}}function Fm(e,t,n,r){if(t.type!==void 0){let o=Z0(e);if(!Y0(o,t.type)){r.push({path:n,expected:t.type,received:dn(e),message:`${n} \u5E94\u4E3A ${t.type}\uFF0C\u5B9E\u9645\u4E3A ${o}`});return}}if(t.enum&&t.enum.length>0&&(J0(e)?t.enum.includes(e)||r.push({path:n,expected:`enum[${t.enum.map(o=>JSON.stringify(o)).join(",")}]`,received:dn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${JSON.stringify(e)}`}):r.push({path:n,expected:`enum[${t.enum.map(o=>JSON.stringify(o)).join(",")}]`,received:dn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${dn(e)}`})),typeof e=="number"&&(t.minimum!==void 0&&e<t.minimum&&r.push({path:n,expected:`>= ${t.minimum}`,received:String(e),message:`${n} \u5E94 >= ${t.minimum}\uFF0C\u5B9E\u9645\u4E3A ${e}`}),t.maximum!==void 0&&e>t.maximum&&r.push({path:n,expected:`<= ${t.maximum}`,received:String(e),message:`${n} \u5E94 <= ${t.maximum}\uFF0C\u5B9E\u9645\u4E3A ${e}`})),typeof e=="string"&&(t.minLength!==void 0&&e.length<t.minLength&&r.push({path:n,expected:`length >= ${t.minLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 >= ${t.minLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.maxLength!==void 0&&e.length>t.maxLength&&r.push({path:n,expected:`length <= ${t.maxLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 <= ${t.maxLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.pattern!==void 0))try{new RegExp(t.pattern).test(e)||r.push({path:n,expected:`pattern ${t.pattern}`,received:dn(e),message:`${n} \u4E0D\u5339\u914D pattern ${t.pattern}`})}catch{}if(t.properties!==void 0&&Bm(e,t,n,r),t.items!==void 0&&Array.isArray(e))for(let o=0;o<e.length;o++)Fm(e[o],t.items,`${n}[${o}]`,r)}function Gm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function J0(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Z0(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e}function Y0(e,t){return e===t||t==="integer"&&e==="number"||t==="number"&&e==="integer"}function dn(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string"){let t=e.length>60?e.slice(0,57)+"...":e;return JSON.stringify(t)}return typeof e=="number"||typeof e=="boolean"?JSON.stringify(e):Array.isArray(e)?`array(len=${e.length})`:typeof e=="object"?`object{keys=${Object.keys(e).length}}`:typeof e}var di=class{#e;#n;#r;#s;constructor(t){this.#e=t.registry,this.#n=t.gate,this.#r={cwd:t.baseCtx.cwd,signal:t.baseCtx.signal,writeRoots:t.baseCtx.writeRoots,...t.baseCtx.timeout!==void 0?{timeout:t.baseCtx.timeout}:{}},this.#s=t.maxParallel??8}async executeBatch(t){return t.length===0?{items:[],records:[]}:this.#t(t)&&t.length>1?this.#c(t):this.#p(t)}#t(t){return t.every(n=>{let r=this.#e.get(n.name);return r?Qn(r.kind):!0})}async#c(t){let n=[],r=[];for(let o=0;o<t.length;o+=this.#s){let s=t.slice(o,o+this.#s),i=await Promise.all(s.map(a=>this.#i(a)));for(let a of i)n.push(a.item),a.record.success||r.push(a.record)}return{items:n,records:r}}async#p(t){let n=[],r=[];for(let o of t){let s=await this.#i(o);if(n.push(s.item),!s.record.success&&(r.push(s.record),s.record.error==="GATE_DENIED"&&s.item.result.denial?.source==="user_prompt"))break}return{items:n,records:r}}async#i(t){let n=t.name,r=Date.now(),o=this.#e.get(n);if(!o){let u=`\u5DE5\u5177 "${n}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"TOOL_NOT_FOUND"}},record:{name:n,success:!1,error:"TOOL_NOT_FOUND",timestamp:r}}}let s=or(t.arguments??"");if(!s.ok){if(s.reason==="PARTIAL"){let d=`\u5DE5\u5177 "${n}" \u53C2\u6570\u5C1A\u672A\u6536\u5168\uFF0C\u672C\u8F6E\u8DF3\u8FC7\uFF08\u6D41\u5F0F\u5206\u7247\u5BFC\u81F4\uFF09\uFF1A${s.hint}`;return{item:{name:n,callId:t.id,result:{success:!1,data:d,error:"PARTIAL_JSON"}},record:{name:n,success:!1,error:"PARTIAL_JSON",timestamp:r}}}let u=`\u5DE5\u5177 "${n}" \u53C2\u6570\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${s.error}
485
- \u539F\u6587: ${s.raw.slice(0,200)}`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"INVALID_JSON"}},record:{name:n,success:!1,error:"INVALID_JSON",timestamp:r}}}let i=s.args,a,l=o.schema??o.parameters;if(l){let u=Mm(i,l);u.ok||(a=u.issues)}if(!await this.#n.check(n,i)){let u=this.#n.lastDenial,d=u?`Permission to run tool denied by user (${u.reason})\u3002\u8BF7\u52FF\u5C1D\u8BD5\u7528\u5176\u4ED6\u65B9\u5F0F\u4FEE\u6539\u540C\u4E00\u4E2A\u6587\u4EF6\u6216\u7ED5\u8FC7\u6B64\u51B3\u5B9A\uFF1B\u5982\u9700\u7EE7\u7EED\uFF0C\u8BF7\u5148\u4E0E\u7528\u6237\u786E\u8BA4\u3002`:"Permission to run tool denied by user\u3002\u8BF7\u52FF\u5C1D\u8BD5\u7528\u5176\u4ED6\u65B9\u5F0F\u4FEE\u6539\u540C\u4E00\u4E2A\u6587\u4EF6\u6216\u7ED5\u8FC7\u6B64\u51B3\u5B9A\uFF1B\u5982\u9700\u7EE7\u7EED\uFF0C\u8BF7\u5148\u4E0E\u7528\u6237\u786E\u8BA4\u3002";return{item:{name:n,callId:t.id,result:{success:!1,data:d,error:"GATE_DENIED",...u?{denial:u}:{}}},record:{name:n,success:!1,error:"GATE_DENIED",timestamp:r}}}if(!Qn(o.kind)){let u=o.preview;if(typeof u=="function")try{await u(i,this.#r)}catch{}}try{let u=await this.#d(o,i);if(a&&a.length>0){let m=a.map(f=>` - ${f.message}`).join(`
486
- `),h=u.success?"[schema \u8B66\u544A]":"[schema \u95EE\u9898]";u={...u,data:`${u.data}
486
+ ${n}`}],o=t.provider.chat(r,{...t.signal?{signal:t.signal}:{},temperature:.2}),s="";for await(let i of o)if(i.content&&(s+=i.content,t.onProgress))try{t.onProgress({type:"summary_delta",delta:i.content,totalSoFar:s})}catch{}if(!s.trim()){let i=Wm(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:"LLM \u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32",fallbackSummary:i})}catch{}return i}return s.trim()}catch(r){let o=r instanceof Error?r.message:String(r),s=Wm(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:o,fallbackSummary:s})}catch{}return s}}function iS(e){return{role:"system",content:`${eS}
487
+ ${e}`}}async function _c(e,t){let n=kc(e),r=fi(e),o=t.minTurnsToCompact??mi,s=t.preserveRecentRounds??Tc;if(r.length<o)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};if(r.length<=s)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};let i=r.length-s,a=r.slice(0,i),l=r.slice(i);if(t.onProgress)try{t.onProgress({type:"start",droppedTurns:a.length,beforeTokens:n})}catch{}let c=await sS(a,t),u=[iS(c)];for(let m of l)for(let h of m)u.push(h);let d=kc(u);if(t.onProgress)try{t.onProgress({type:"done",droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d})}catch{}return{messages:u,summary:c,droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d}}p();var un=class{#e=new Map;#n;#r;#s;static ALL_TOOL_NAMES=[];constructor(t){this.#n=new Set(t?.disabledTools??[]),this.#r=t?.featureFlagChecker??(()=>!0),this.#s=t?.provider}register(t){return this.registerErased(Oe(t))}registerErased(t){if(this.#e.has(t.name))throw new Error(`\u5DE5\u5177 "${t.name}" \u5DF2\u6CE8\u518C\uFF0C\u4E0D\u80FD\u91CD\u590D\u6CE8\u518C`);return this.#e.set(t.name,t),this}registerAll(t){for(let n of t)this.registerErased(n);return this}unregister(t){return this.#e.delete(t)}get(t){if(this.#t(t))return this.#e.get(t)}list(){let t=[];for(let[n,r]of this.#e)this.#t(n)&&t.push(r);return t}listByKind(t){return this.list().filter(n=>n.kind===t)}listReadTools(){return this.listByKind("read")}listWriteTools(){return this.list().filter(t=>!Sn(t.kind))}names(){return[...this.#e.keys()]}has(t){return this.#e.has(t)}isEnabled(t){return this.#e.has(t)&&this.#t(t)}disable(t){this.#n.add(t)}enable(t){this.#n.delete(t)}kindOf(t){return this.#e.get(t)?.kind}async execute(t,n,r){let o=this.get(t);if(!o)return{success:!1,data:`\u5DE5\u5177 "${t}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`,error:"TOOL_NOT_FOUND"};try{return await o.execute(n,r)}catch(s){let i=s instanceof Error?s.message:String(s);return{success:!1,data:`\u5DE5\u5177 "${t}" \u6267\u884C\u5F02\u5E38\uFF1A${i}`,error:"EXECUTION_ERROR"}}}#t(t){let n=this.#e.get(t);return!(!n||this.#n.has(t)||!this.#r(t)||this.#s&&n.supportedProviders.length>0&&!n.supportedProviders.includes(this.#s))}};p();p();p();import{z as bD}from"zod";function Rc(e,t){let n=t.safeParse(e);if(n.success)return{ok:!0,issues:[]};let r=n.error.issues.map(o=>aS(o,e));return{ok:r.length===0,issues:r}}function aS(e,t){let n=lS(e.path),r=cS(e),o=uS(t,e.path),s=dS(n,r,o,e);return{path:n,expected:r,received:o,message:s}}function lS(e){if(e.length===0)return"$";let t="$";for(let n of e)typeof n=="number"?t+=`[${n}]`:typeof n=="string"?t+=`.${n}`:t+="[]";return t}function cS(e){switch(e.code){case"invalid_type":return e.expected;case"too_small":{let t=e.type,n=e.minimum;return t==="string"?`length >= ${n}`:t==="array"?`length >= ${n}`:t==="number"?`>= ${n}`:`>= ${n}`}case"too_big":{let t=e.type,n=e.maximum;return t==="string"?`length <= ${n}`:t==="array"?`length <= ${n}`:t==="number"?`<= ${n}`:`<= ${n}`}case"invalid_enum_value":return`enum[${e.options.map(n=>JSON.stringify(n)).join(",")}]`;case"invalid_string":return`string ${e.validation}`;case"unrecognized_keys":return`\u672A\u5728 schema \u4E2D\u5B9A\u4E49: ${e.keys.join(",")}`;case"invalid_literal":{let t=e.expected;return`literal[${JSON.stringify(t)}]`}default:return e.code}}function uS(e,t){let n=e;for(let r of t){if(n==null||typeof n!="object")return"undefined";if(typeof r=="number"){if(!Array.isArray(n))return"undefined";n=n[r]}else if(typeof r=="string")n=n[r];else return"undefined"}return n===null?"null":n===void 0?"undefined":typeof n=="string"?n.length>60?JSON.stringify(n.slice(0,57)+"..."):JSON.stringify(n):typeof n=="number"||typeof n=="boolean"?JSON.stringify(n):Array.isArray(n)?`array(len=${n.length})`:typeof n=="object"?`object{keys=${Object.keys(n).length}}`:typeof n}function dS(e,t,n,r){if(r.code==="invalid_type")return`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="too_small"){let o=r.type,s=r.minimum;return o==="string"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="too_big"){let o=r.type,s=r.maximum;return o==="string"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="invalid_enum_value")return`${e} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="unrecognized_keys"){let o=r.keys;return`${e} \u4E0D\u5141\u8BB8\u952E: ${o.join(", ")}`}return r.code==="invalid_literal"?`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`:r.code==="invalid_string"?`${e} \u4E0D\u5339\u914D ${t}`:`${e} ${r.message}\uFF08\u671F\u671B ${t}\uFF0C\u5B9E\u9645 ${n}\uFF09`}function Vm(e,t){if(pS(t))return Rc(e,t);let n=[];return Ac(t)?t.type!==void 0&&t.type!=="object"?{ok:!0,issues:n}:(zm(e,t,"$",n),{ok:n.length===0,issues:n}):{ok:!0,issues:n}}function pS(e){if(e===null||typeof e!="object")return!1;let t=e;return"_def"in t&&typeof t.parse=="function"&&typeof t.safeParse=="function"}function zm(e,t,n,r){if(!Ac(e)){r.push({path:n,expected:"object",received:dn(e),message:`${n} \u5E94\u4E3A object\uFF0C\u5B9E\u9645\u4E3A ${dn(e)}`});return}for(let i of t.required??[])i in e||r.push({path:`${n}.${i}`,expected:"present",received:"missing",message:`${n}.${i} \u662F\u5FC5\u586B\u5B57\u6BB5`});let o=t.properties??{},s=t.additionalProperties;for(let[i,a]of Object.entries(e)){let l=o[i];if(l===void 0){s===!1?r.push({path:`${n}.${i}`,expected:"\u672A\u5728 schema \u4E2D\u5B9A\u4E49",received:dn(a),message:`${n}.${i} \u4E0D\u5728\u5141\u8BB8\u5B57\u6BB5\u4E2D`}):Ac(s)&&vc(a,s,`${n}.${i}`,r);continue}vc(a,l,`${n}.${i}`,r)}}function vc(e,t,n,r){if(t.type!==void 0){let o=mS(e);if(!hS(o,t.type)){r.push({path:n,expected:t.type,received:dn(e),message:`${n} \u5E94\u4E3A ${t.type}\uFF0C\u5B9E\u9645\u4E3A ${o}`});return}}if(t.enum&&t.enum.length>0){let o=`enum[${t.enum.map(s=>JSON.stringify(s)).join(",")}]`;fS(e)?t.enum.includes(e)||r.push({path:n,expected:o,received:dn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${JSON.stringify(e)}`}):r.push({path:n,expected:o,received:dn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${dn(e)}`})}if(typeof e=="number"&&(t.minimum!==void 0&&e<t.minimum&&r.push({path:n,expected:`>= ${t.minimum}`,received:String(e),message:`${n} \u5E94 >= ${t.minimum}\uFF0C\u5B9E\u9645\u4E3A ${e}`}),t.maximum!==void 0&&e>t.maximum&&r.push({path:n,expected:`<= ${t.maximum}`,received:String(e),message:`${n} \u5E94 <= ${t.maximum}\uFF0C\u5B9E\u9645\u4E3A ${e}`})),typeof e=="string"&&(t.minLength!==void 0&&e.length<t.minLength&&r.push({path:n,expected:`length >= ${t.minLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 >= ${t.minLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.maxLength!==void 0&&e.length>t.maxLength&&r.push({path:n,expected:`length <= ${t.maxLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 <= ${t.maxLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.pattern!==void 0))try{new RegExp(t.pattern).test(e)||r.push({path:n,expected:`pattern ${t.pattern}`,received:dn(e),message:`${n} \u4E0D\u5339\u914D pattern ${t.pattern}`})}catch{}if(t.properties!==void 0&&zm(e,t,n,r),t.items!==void 0&&Array.isArray(e))for(let o=0;o<e.length;o++)vc(e[o],t.items,`${n}[${o}]`,r)}function Ac(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fS(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function mS(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e}function hS(e,t){return e===t||t==="integer"&&e==="number"||t==="number"&&e==="integer"}function dn(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string"){let t=e.length>60?e.slice(0,57)+"...":e;return JSON.stringify(t)}return typeof e=="number"||typeof e=="boolean"?JSON.stringify(e):Array.isArray(e)?`array(len=${e.length})`:typeof e=="object"?`object{keys=${Object.keys(e).length}}`:typeof e}var hi=class{#e;#n;#r;#s;constructor(t){this.#e=t.registry,this.#n=t.gate,this.#r={cwd:t.baseCtx.cwd,signal:t.baseCtx.signal,writeRoots:t.baseCtx.writeRoots,...t.baseCtx.timeout!==void 0?{timeout:t.baseCtx.timeout}:{}},this.#s=t.maxParallel??8}async executeBatch(t){return t.length===0?{items:[],records:[]}:this.#t(t)&&t.length>1?this.#u(t):this.#p(t)}#t(t){return t.every(n=>{let r=this.#e.get(n.name);return r?Sn(r.kind):!0})}async#u(t){let n=[],r=[];for(let o=0;o<t.length;o+=this.#s){let s=t.slice(o,o+this.#s),i=await Promise.all(s.map(a=>this.#i(a)));for(let a of i)n.push(a.item),a.record.success||r.push(a.record)}return{items:n,records:r}}async#p(t){let n=[],r=[];for(let o of t){let s=await this.#i(o);if(n.push(s.item),!s.record.success&&(r.push(s.record),s.record.error==="GATE_DENIED"&&s.item.result.denial?.source==="user_prompt"))break}return{items:n,records:r}}async#i(t){let n=t.name,r=Date.now(),o=this.#e.get(n);if(!o){let c=`\u5DE5\u5177 "${n}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`;return{item:{name:n,callId:t.id,result:{success:!1,data:c,error:"TOOL_NOT_FOUND"}},record:{name:n,success:!1,error:"TOOL_NOT_FOUND",timestamp:r}}}let s=tr(t.arguments??"");if(!s.ok){if(s.reason==="PARTIAL"){let u=`\u5DE5\u5177 "${n}" \u53C2\u6570\u5C1A\u672A\u6536\u5168\uFF0C\u672C\u8F6E\u8DF3\u8FC7\uFF08\u6D41\u5F0F\u5206\u7247\u5BFC\u81F4\uFF09\uFF1A${s.hint}`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"PARTIAL_JSON"}},record:{name:n,success:!1,error:"PARTIAL_JSON",timestamp:r}}}let c=`\u5DE5\u5177 "${n}" \u53C2\u6570\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${s.error}
488
+ \u539F\u6587: ${s.raw.slice(0,200)}`;return{item:{name:n,callId:t.id,result:{success:!1,data:c,error:"INVALID_JSON"}},record:{name:n,success:!1,error:"INVALID_JSON",timestamp:r}}}let i=s.args,a,l=o.schema??o.parameters;if(l){let c=Vm(i,l);c.ok||(a=c.issues)}if(!Sn(o.kind)&&!await this.#n.check(n,i)){let u=this.#n.lastDenial,d=u?`Permission to run tool denied by user (${u.reason})\u3002\u8BF7\u52FF\u5C1D\u8BD5\u7528\u5176\u4ED6\u65B9\u5F0F\u4FEE\u6539\u540C\u4E00\u4E2A\u6587\u4EF6\u6216\u7ED5\u8FC7\u6B64\u51B3\u5B9A\uFF1B\u5982\u9700\u7EE7\u7EED\uFF0C\u8BF7\u5148\u4E0E\u7528\u6237\u786E\u8BA4\u3002`:"Permission to run tool denied by user\u3002\u8BF7\u52FF\u5C1D\u8BD5\u7528\u5176\u4ED6\u65B9\u5F0F\u4FEE\u6539\u540C\u4E00\u4E2A\u6587\u4EF6\u6216\u7ED5\u8FC7\u6B64\u51B3\u5B9A\uFF1B\u5982\u9700\u7EE7\u7EED\uFF0C\u8BF7\u5148\u4E0E\u7528\u6237\u786E\u8BA4\u3002";return{item:{name:n,callId:t.id,result:{success:!1,data:d,error:"GATE_DENIED",...u?{denial:u}:{}}},record:{name:n,success:!1,error:"GATE_DENIED",timestamp:r}}}if(!Sn(o.kind)){let c=o.preview;if(typeof c=="function")try{await c(i,this.#r)}catch{}}try{let c=await this.#d(o,i);if(a&&a.length>0){let d=a.map(h=>` - ${h.message}`).join(`
489
+ `),m=c.success?"[schema \u8B66\u544A]":"[schema \u95EE\u9898]";c={...c,data:`${c.data}
487
490
 
488
- ${h} \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A
489
- ${m}`,issues:a}}let d={name:n,success:u.success,error:u.error,timestamp:r,...a?{issues:a}:{}};return{item:{name:n,callId:t.id,result:u},record:d}}catch(u){let d=u instanceof Error?u.message:String(u),m={success:!1,data:`\u5DE5\u5177 "${n}" \u6267\u884C\u5F02\u5E38\uFF1A${d}`,error:"EXECUTION_ERROR"};return{item:{name:n,callId:t.id,result:m},record:{name:n,success:!1,error:"EXECUTION_ERROR",timestamp:r}}}}async#d(t,n){return t.execute(n,this.#r)}};p();var pi=class{#e;constructor(t={}){this.#e=t.threshold??3}shouldBreak(t,n){if(t.length<this.#e)return!1;let r=t.slice(-this.#e);if(r.length<this.#e)return!1;let o=r[0];return r.every(i=>i.name===o.name&&i.error===o.error&&!i.success)?n.some(i=>i.name===o.name):!1}};p();var fi=class{#e;#n;#r;constructor(t={}){this.#e=t.repeatThreshold??2,this.#n=t.maxReflections??5,this.#r=t.maxHintChars??800}analyze(t,n){let r=[];for(let o of t){if(o.result.success)continue;let s=this.#s(o)??this.#t(o)??this.#c(o)??this.#p(o)??this.#i(o,n.writeRoots)??this.#o(o);if(s&&r.push(s),r.length>=this.#n)break}return r}injectIntoPrompt(t,n){if(n.length===0)return t;let o=["## \u26A0\uFE0F \u4E0A\u4E00\u8F6E\u5DE5\u5177\u8C03\u7528\u7684\u53CD\u601D","\u4EE5\u4E0B\u662F\u672C\u8F6E\u5DE5\u5177\u6267\u884C\u5931\u8D25\u7684\u539F\u56E0\u5206\u6790\u3002\u8BF7\u5728\u4E0B\u4E00\u6B21\u8C03\u7528\u524D\u5148\u89E3\u51B3\u8FD9\u4E9B\u95EE\u9898\uFF0C\u4E0D\u8981\u91CD\u590D\u76F8\u540C\u7684\u9519\u8BEF\u8C03\u7528\u3002",...n.map(s=>{let i=this.#d(s.hint);return`- \u5DE5\u5177 \`${s.toolName}\` \u5931\u8D25\uFF1A${i}`})].join(`
491
+ ${m} \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A
492
+ ${d}`,issues:a}}let u={name:n,success:c.success,error:c.error,timestamp:r,...a?{issues:a}:{}};return{item:{name:n,callId:t.id,result:c},record:u}}catch(c){let u=c instanceof Error?c.message:String(c),d={success:!1,data:`\u5DE5\u5177 "${n}" \u6267\u884C\u5F02\u5E38\uFF1A${u}`,error:"EXECUTION_ERROR"};return{item:{name:n,callId:t.id,result:d},record:{name:n,success:!1,error:"EXECUTION_ERROR",timestamp:r}}}}async#d(t,n){return t.execute(n,this.#r)}};p();var gi=class{#e;constructor(t={}){this.#e=t.threshold??3}shouldBreak(t,n){if(t.length<this.#e)return!1;let r=t.slice(-this.#e);if(r.length<this.#e)return!1;let o=r[0];return r.every(i=>i.name===o.name&&i.error===o.error&&!i.success)?n.some(i=>i.name===o.name):!1}};p();var yi=class{#e;#n;#r;constructor(t={}){this.#e=t.repeatThreshold??2,this.#n=t.maxReflections??5,this.#r=t.maxHintChars??800}analyze(t,n){let r=[];for(let o of t){if(o.result.success)continue;let s=this.#s(o)??this.#t(o)??this.#u(o)??this.#p(o)??this.#i(o,n.writeRoots)??this.#o(o);if(s&&r.push(s),r.length>=this.#n)break}return r}injectIntoPrompt(t,n){if(n.length===0)return t;let o=["## \u26A0\uFE0F \u4E0A\u4E00\u8F6E\u5DE5\u5177\u8C03\u7528\u7684\u53CD\u601D","\u4EE5\u4E0B\u662F\u672C\u8F6E\u5DE5\u5177\u6267\u884C\u5931\u8D25\u7684\u539F\u56E0\u5206\u6790\u3002\u8BF7\u5728\u4E0B\u4E00\u6B21\u8C03\u7528\u524D\u5148\u89E3\u51B3\u8FD9\u4E9B\u95EE\u9898\uFF0C\u4E0D\u8981\u91CD\u590D\u76F8\u540C\u7684\u9519\u8BEF\u8C03\u7528\u3002",...n.map(s=>{let i=this.#d(s.hint);return`- \u5DE5\u5177 \`${s.toolName}\` \u5931\u8D25\uFF1A${i}`})].join(`
490
493
  `);return t+`
491
494
 
492
- `+o}#s(t){let n=t.recentSameTool;if(n.length<this.#e)return null;let r=n.slice(-this.#e),o=r[0];if(!r.every(i=>!i.success&&i.error===o.error))return null;let s=o.error??"\u672A\u77E5\u9519\u8BEF";return{category:"repeated_failure",toolName:t.name,hint:`\u4F60\u5DF2\u8FDE\u7EED ${this.#e} \u6B21\u8C03\u7528 \`${t.name}\` \u5931\u8D25\uFF08\u9519\u8BEF\uFF1A${s}\uFF09\u3002\u8BF7\u5148 \`read_file\` \u770B\u6E05\u73B0\u573A\u6216\u6362\u5176\u4ED6\u5DE5\u5177\uFF0C\u4E0D\u8981\u7EE7\u7EED\u540C\u6837\u7684\u9519\u8BEF\u8C03\u7528\u3002`}}#t(t){let n=t.result.error==="TOOL_NOT_FOUND",r=t.result.data??"",o=r.includes("ENOENT")||r.includes("No such file")||/\bnot found\b/i.test(r);return!n&&!o?null:{category:"file_not_found",toolName:t.name,hint:`\`${t.name}\` \u5931\u8D25\uFF1A\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\u8BF7\u5148\u7528 \`ls\` / \`glob\` \u770B\u4E00\u4E0B\u76EE\u5F55\u7ED3\u6784\uFF0C\u6216\u786E\u8BA4\u8DEF\u5F84\u62FC\u5199\uFF08\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u89C1 system prompt\uFF09\u3002`}}#c(t){if(!(t.result.error==="TEXT_NOT_FOUND"||t.result.error==="TEXT_MULTIPLE_MATCHES"))return null;let o=t.result.error==="TEXT_MULTIPLE_MATCHES"?`\`${t.name}\`\uFF1Aold_text \u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\u3002\u8BF7\u8865\u5145\u4E0A\u4E0B\u6587\u8BA9 old_text \u552F\u4E00\uFF0C\u6216\u6539\u7528 multi_edit \u7684 replaceAll\u3002`:`\`${t.name}\`\uFF1A\u672A\u627E\u5230 old_text\u3002\u8BF7\u91CD\u65B0 \`read_file\` \u770B\u5F53\u524D\u5185\u5BB9\uFF0C\u9010\u5B57\u590D\u5236\u8981\u66FF\u6362\u7684\u7247\u6BB5\uFF08\u6CE8\u610F\u7F29\u8FDB\u4E0E\u7A7A\u683C\uFF09\uFF1B\u884C\u5C3E\u5DF2\u505A CRLF \u5F52\u4E00\u5316\uFF0C\u65E0\u9700\u624B\u5199 \\r\\n\u3002`;return{category:"text_not_found",toolName:t.name,hint:o}}#p(t){let n=t.result.error==="GATE_DENIED",r=t.result.data??"",o=r.includes("EACCES")||/\bpermission\b/i.test(r)||/\bdenied\b/i.test(r);return!n&&!o?null:{category:"permission_denied",toolName:t.name,hint:`\`${t.name}\` \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\u3002\u8BF7\u68C0\u67E5\uFF1A1) \u8DEF\u5F84\u662F\u5426\u5728\u5141\u8BB8\u6839\u76EE\u5F55\u5185\uFF1B2) \u662F\u5426\u9700\u8981\u5207\u6362\u6388\u6743\u6A21\u5F0F\uFF1B3) \u6539\u7528\u5176\u4ED6\u4E0D\u9700\u8981\u6743\u9650\u7684\u5DE5\u5177\u3002`}}#i(t,n){if(!(t.kind==="edit"||t.kind==="delete"||t.kind==="move")||t.result.error!=="OUTSIDE_WRITE_ROOTS")return null;let o=n[0]??"<\u672A\u914D\u7F6E>";return{category:"out_of_write_root",toolName:t.name,hint:`\`${t.name}\` \u662F\u5199\u64CD\u4F5C\u4F46\u76EE\u6807\u8DEF\u5F84\u4E0D\u5728\u5141\u8BB8\u7684\u6839\u76EE\u5F55\u5185\u3002\u8BF7\u6539\u7528 \`${o}\` \u4E0B\u7684\u8DEF\u5F84\uFF0C\u6216\u8C03\u6574\u9879\u76EE\u7684 \`writeRoots\` \u914D\u7F6E\u3002`}}#d(t){return t.length<=this.#r?t:t.slice(0,this.#r-3)+"..."}#o(t){let n=t.result.issues;if(!n||n.length===0)return null;let r=n.slice(0,3).map(s=>s.message).join("; "),o=n.length>3?`\uFF08\u53E6\u6709 ${n.length-3} \u6761\uFF09`:"";return{category:"invalid_args",toolName:t.name,hint:`\`${t.name}\` \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A${r}${o}\u3002\u8BF7\u68C0\u67E5\u5FC5\u586B\u5B57\u6BB5\u3001\u7C7B\u578B\u4E0E enum \u767D\u540D\u5355\u3002`}}};p();function jm(e,t){return(t==="plan"?e.listReadTools():e.list()).map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:r.parameters}}))}p();var mi=class{#e=[];#n=0;add(t,n=[]){for(let o of n)if(!this.#e.find(s=>s.id===o))throw new Error(`todo \u4F9D\u8D56 #${o} \u4E0D\u5B58\u5728\uFF08\u5DF2\u5206\u914D\u7684 id: ${this.#e.map(s=>s.id).join(", ")||"(\u7A7A)"}\uFF09`);let r=this.#n++;return this.#e.push({id:r,content:t,status:"pending",deps:[...n],updatedAt:Date.now()}),r}resetForRetry(t){let n=this.#r(t);return!n||n.status!=="failed"?!1:(n.status="pending",n.evidence=void 0,n.updatedAt=Date.now(),!0)}markRunning(t){let n=this.#r(t);return!n||n.status!=="pending"||!this.#s(n.deps)?!1:(n.status="running",n.updatedAt=Date.now(),!0)}markDone(t,n){let r=this.#r(t);return!r||r.status!=="running"&&r.status!=="pending"?!1:(r.status="done",n!==void 0&&(r.evidence=n),r.updatedAt=Date.now(),!0)}markFailed(t,n){let r=this.#r(t);return!r||r.status==="done"?!1:(r.status="failed",r.evidence=n,r.updatedAt=Date.now(),!0)}markSkipped(t,n){let r=this.#r(t);return!r||r.status==="done"||r.status==="failed"?!1:(r.status="skipped",r.evidence=n,r.updatedAt=Date.now(),!0)}pending(){return this.#e.filter(t=>t.status==="pending"&&this.#s(t.deps))}unfinished(){return this.#e.filter(t=>t.status==="pending"||t.status==="running"||t.status==="failed")}isAllTerminated(){return this.#e.every(t=>t.status==="done"||t.status==="failed"||t.status==="skipped")}get items(){return this.#e.map(t=>({...t}))}toMarkdown(t=20){if(this.#e.length===0)return"";let n=this.#e.filter(l=>l.status==="pending"||l.status==="running"||l.status==="failed"),o=[...this.#e.filter(l=>l.status==="done"||l.status==="skipped")].sort((l,c)=>c.updatedAt-l.updatedAt),s=o.length>t,i=s?o.slice(0,Math.max(0,t-n.length)):o,a=[...n,...i].map(l=>{let c=this.#t(l.status),u=l.deps.length>0?` (\u4F9D\u8D56: #${l.deps.join(", #")})`:"",d=l.evidence?` \u2014 ${l.evidence}`:"";return`- ${c} #${l.id} ${l.content}${u}${d}`});if(s){let l=o.length-i.length;a.push(`- ...\uFF08\u53E6\u6709 ${l} \u6761\u5DF2\u5B8C\u6210\u5DF2\u6298\u53E0\uFF09`)}return["## \u{1F4CB} \u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6",...a,"","\u89C4\u5219\uFF1A\u6309\u987A\u5E8F\u63A8\u8FDB\uFF1B\u672A\u5B8C\u6210\u4F9D\u8D56\u65F6\u4E0D\u8981\u8DF3\u6B65\uFF1B\u5B8C\u6210\u8BF7\u8C03\u7528 todo_mark_done\uFF0C\u5931\u8D25\u8BF7\u8C03\u7528 todo_mark_failed\uFF1B\u91CD\u8BD5\u5931\u8D25\u9879\u5148\u8C03 todo_retry \u518D\u91CD\u8DD1\u3002"].join(`
493
- `)}#r(t){return this.#e.find(n=>n.id===t)}#s(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#t(t){switch(t){case"pending":return"\u2610";case"running":return"\u25B6";case"done":return"\u2705";case"failed":return"\u274C";case"skipped":return"\u23ED"}}};p();function Um(e){return[Q0(e),eS(e),tS(e),nS(e),rS(e)]}function Q0(e){return{name:"todo_add",kind:"other",description:`\u26A0\uFE0F \u3010\u590D\u6742\u4EFB\u52A1\u7B2C\u4E00\u6B65\u3011\u6DFB\u52A0\u4E00\u4E2A\u5F85\u529E\u5230\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3002
495
+ `+o}#s(t){let n=t.recentSameTool;if(n.length<this.#e)return null;let r=n.slice(-this.#e),o=r[0];if(!r.every(i=>!i.success&&i.error===o.error))return null;let s=o.error??"\u672A\u77E5\u9519\u8BEF";return{category:"repeated_failure",toolName:t.name,hint:`\u4F60\u5DF2\u8FDE\u7EED ${this.#e} \u6B21\u8C03\u7528 \`${t.name}\` \u5931\u8D25\uFF08\u9519\u8BEF\uFF1A${s}\uFF09\u3002\u8BF7\u5148 \`read_file\` \u770B\u6E05\u73B0\u573A\u6216\u6362\u5176\u4ED6\u5DE5\u5177\uFF0C\u4E0D\u8981\u7EE7\u7EED\u540C\u6837\u7684\u9519\u8BEF\u8C03\u7528\u3002`}}#t(t){let n=t.result.error==="TOOL_NOT_FOUND",r=t.result.data??"",o=r.includes("ENOENT")||r.includes("No such file")||/\bnot found\b/i.test(r);return!n&&!o?null:{category:"file_not_found",toolName:t.name,hint:`\`${t.name}\` \u5931\u8D25\uFF1A\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\u8BF7\u5148\u7528 \`ls\` / \`glob\` \u770B\u4E00\u4E0B\u76EE\u5F55\u7ED3\u6784\uFF0C\u6216\u786E\u8BA4\u8DEF\u5F84\u62FC\u5199\uFF08\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u89C1 system prompt\uFF09\u3002`}}#u(t){if(!(t.result.error==="TEXT_NOT_FOUND"||t.result.error==="TEXT_MULTIPLE_MATCHES"))return null;let o=t.result.error==="TEXT_MULTIPLE_MATCHES"?`\`${t.name}\`\uFF1Aold_text \u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\u3002\u8BF7\u8865\u5145\u4E0A\u4E0B\u6587\u8BA9 old_text \u552F\u4E00\uFF0C\u6216\u6539\u7528 multi_edit \u7684 replaceAll\u3002`:`\`${t.name}\`\uFF1A\u672A\u627E\u5230 old_text\u3002\u8BF7\u91CD\u65B0 \`read_file\` \u770B\u5F53\u524D\u5185\u5BB9\uFF0C\u9010\u5B57\u590D\u5236\u8981\u66FF\u6362\u7684\u7247\u6BB5\uFF08\u6CE8\u610F\u7F29\u8FDB\u4E0E\u7A7A\u683C\uFF09\uFF1B\u884C\u5C3E\u5DF2\u505A CRLF \u5F52\u4E00\u5316\uFF0C\u65E0\u9700\u624B\u5199 \\r\\n\u3002`;return{category:"text_not_found",toolName:t.name,hint:o}}#p(t){let n=t.result.error==="GATE_DENIED",r=t.result.data??"",o=r.includes("EACCES")||/\bpermission\b/i.test(r)||/\bdenied\b/i.test(r);return!n&&!o?null:{category:"permission_denied",toolName:t.name,hint:`\`${t.name}\` \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\u3002\u8BF7\u68C0\u67E5\uFF1A1) \u8DEF\u5F84\u662F\u5426\u5728\u5141\u8BB8\u6839\u76EE\u5F55\u5185\uFF1B2) \u662F\u5426\u9700\u8981\u5207\u6362\u6388\u6743\u6A21\u5F0F\uFF1B3) \u6539\u7528\u5176\u4ED6\u4E0D\u9700\u8981\u6743\u9650\u7684\u5DE5\u5177\u3002`}}#i(t,n){if(!(t.kind==="edit"||t.kind==="delete"||t.kind==="move")||t.result.error!=="OUTSIDE_WRITE_ROOTS")return null;let o=n[0]??"<\u672A\u914D\u7F6E>";return{category:"out_of_write_root",toolName:t.name,hint:`\`${t.name}\` \u662F\u5199\u64CD\u4F5C\u4F46\u76EE\u6807\u8DEF\u5F84\u4E0D\u5728\u5141\u8BB8\u7684\u6839\u76EE\u5F55\u5185\u3002\u8BF7\u6539\u7528 \`${o}\` \u4E0B\u7684\u8DEF\u5F84\uFF0C\u6216\u8C03\u6574\u9879\u76EE\u7684 \`writeRoots\` \u914D\u7F6E\u3002`}}#d(t){return t.length<=this.#r?t:t.slice(0,this.#r-3)+"..."}#o(t){let n=t.result.issues;if(!n||n.length===0)return null;let r=n.slice(0,3).map(s=>s.message).join("; "),o=n.length>3?`\uFF08\u53E6\u6709 ${n.length-3} \u6761\uFF09`:"";return{category:"invalid_args",toolName:t.name,hint:`\`${t.name}\` \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A${r}${o}\u3002\u8BF7\u68C0\u67E5\u5FC5\u586B\u5B57\u6BB5\u3001\u7C7B\u578B\u4E0E enum \u767D\u540D\u5355\u3002`}}};p();function qm(e,t){return(t==="plan"?e.listReadTools():e.list()).map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:r.parameters}}))}p();var xi=class{#e=[];#n=0;add(t,n=[]){for(let o of n)if(!this.#e.find(s=>s.id===o))throw new Error(`todo \u4F9D\u8D56 #${o} \u4E0D\u5B58\u5728\uFF08\u5DF2\u5206\u914D\u7684 id: ${this.#e.map(s=>s.id).join(", ")||"(\u7A7A)"}\uFF09`);let r=this.#n++;return this.#e.push({id:r,content:t,status:"pending",deps:[...n],updatedAt:Date.now()}),r}resetForRetry(t){let n=this.#r(t);return!n||n.status!=="failed"?!1:(n.status="pending",n.evidence=void 0,n.updatedAt=Date.now(),!0)}markRunning(t){let n=this.#r(t);return!n||n.status!=="pending"||!this.#s(n.deps)?!1:(n.status="running",n.updatedAt=Date.now(),!0)}markDone(t,n){let r=this.#r(t);return!r||r.status!=="running"&&r.status!=="pending"?!1:(r.status="done",n!==void 0&&(r.evidence=n),r.updatedAt=Date.now(),!0)}markFailed(t,n){let r=this.#r(t);return!r||r.status==="done"?!1:(r.status="failed",r.evidence=n,r.updatedAt=Date.now(),!0)}markSkipped(t,n){let r=this.#r(t);return!r||r.status==="done"||r.status==="failed"?!1:(r.status="skipped",r.evidence=n,r.updatedAt=Date.now(),!0)}pending(){return this.#e.filter(t=>t.status==="pending"&&this.#s(t.deps))}unfinished(){return this.#e.filter(t=>t.status==="pending"||t.status==="running"||t.status==="failed")}isAllTerminated(){return this.#e.every(t=>t.status==="done"||t.status==="failed"||t.status==="skipped")}get items(){return this.#e.map(t=>({...t}))}toMarkdown(t=20){if(this.#e.length===0)return"";let n=this.#e.filter(l=>l.status==="pending"||l.status==="running"||l.status==="failed"),o=[...this.#e.filter(l=>l.status==="done"||l.status==="skipped")].sort((l,c)=>c.updatedAt-l.updatedAt),s=o.length>t,i=s?o.slice(0,Math.max(0,t-n.length)):o,a=[...n,...i].map(l=>{let c=this.#t(l.status),u=l.deps.length>0?` (\u4F9D\u8D56: #${l.deps.join(", #")})`:"",d=l.evidence?` \u2014 ${l.evidence}`:"";return`- ${c} #${l.id} ${l.content}${u}${d}`});if(s){let l=o.length-i.length;a.push(`- ...\uFF08\u53E6\u6709 ${l} \u6761\u5DF2\u5B8C\u6210\u5DF2\u6298\u53E0\uFF09`)}return["## \u{1F4CB} \u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6",...a,"","\u89C4\u5219\uFF1A\u6309\u987A\u5E8F\u63A8\u8FDB\uFF1B\u672A\u5B8C\u6210\u4F9D\u8D56\u65F6\u4E0D\u8981\u8DF3\u6B65\uFF1B\u5B8C\u6210\u8BF7\u8C03\u7528 todo_mark_done\uFF0C\u5931\u8D25\u8BF7\u8C03\u7528 todo_mark_failed\uFF1B\u91CD\u8BD5\u5931\u8D25\u9879\u5148\u8C03 todo_retry \u518D\u91CD\u8DD1\u3002"].join(`
496
+ `)}#r(t){return this.#e.find(n=>n.id===t)}#s(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#t(t){switch(t){case"pending":return"\u2610";case"running":return"\u25B6";case"done":return"\u2705";case"failed":return"\u274C";case"skipped":return"\u23ED"}}};p();function Km(e){return[gS(e),yS(e),xS(e),bS(e),wS(e)]}function gS(e){return{name:"todo_add",kind:"other",description:`\u26A0\uFE0F \u3010\u590D\u6742\u4EFB\u52A1\u7B2C\u4E00\u6B65\u3011\u6DFB\u52A0\u4E00\u4E2A\u5F85\u529E\u5230\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3002
494
497
 
495
498
  \u4EC0\u4E48\u60C5\u51B5\u4E0B\u8C03\u6211\uFF1A
496
499
  - \u9700\u8981\u591A\u6B65\u624D\u80FD\u5B8C\u6210\uFF08\u6539\u591A\u4E2A\u6587\u4EF6 / \u8DE8\u591A\u8F6E\uFF09
@@ -502,105 +505,106 @@ ${m}`,issues:a}}let d={name:n,success:u.success,error:u.error,timestamp:r,...a?{
502
505
 
503
506
  \u7528\u6CD5\uFF1A\u6BCF\u6B21\u52A0\u4E00\u4E2A step\uFF0C\u591A\u6B65\u5C31\u8C03\u591A\u6B21\u3002\u6709\u4F9D\u8D56\u5173\u7CFB\u4F20 deps=[\u524D\u6B65 id]\u3002\u8FD4\u56DE\u5206\u914D\u7684 id\uFF0C\u540E\u7EED\u7528 todo_mark_done / todo_mark_failed \u5F15\u7528\u3002
504
507
 
505
- \u793A\u4F8B\uFF1A\u7528\u6237\u8BF4\u300C\u628A X \u6539\u6210 Y\u300D\u2192 \u8C03 1) todo_add("\u8BFB X") 2) todo_add("\u6539 X", deps=[0]) 3) todo_add("\u68C0\u67E5\u6539\u52A8", deps=[1])`,parameters:{type:"object",properties:{content:{type:"string",description:"\u6B65\u9AA4\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF0C\u5EFA\u8BAE\u7B80\u6D01\uFF09"},deps:{type:"array",description:"\u4F9D\u8D56\u7684 todo id \u6570\u7EC4\uFF08\u8FD9\u4E9B\u90FD done \u540E\u672C\u9879\u624D\u53EF\u6267\u884C\uFF09",items:{type:"number"}}},required:["content"],additionalProperties:!1},async execute(t){if(typeof t?.content!="string"||t.content.length===0)return{success:!1,data:"\u7F3A\u5C11 content \u53C2\u6570",error:"INVALID_ARGS"};let n=Array.isArray(t.deps)?t.deps.filter(r=>typeof r=="number"):[];try{let r=e.add(t.content,n);return{success:!0,data:`\u5DF2\u6DFB\u52A0 todo #${r}\uFF1A${t.content}${n.length>0?`\uFF08\u4F9D\u8D56: ${n.join(", ")})`:""}`,summary:`\u{1F4CB} \u6DFB\u52A0 #${r}`}}catch(r){return{success:!1,data:r instanceof Error?r.message:String(r),error:"TODO_DEPS_INVALID"}}}}}function eS(e){return{name:"todo_mark_running",kind:"other",description:`\u628A todo \u4ECE pending \u63A8\u8FDB\u5230 running\uFF0C\u8868\u793A\u4F60\u300C\u6B63\u5728\u505A\u300D\u8FD9\u4E00\u6B65\u3002
508
+ \u793A\u4F8B\uFF1A\u7528\u6237\u8BF4\u300C\u628A X \u6539\u6210 Y\u300D\u2192 \u8C03 1) todo_add("\u8BFB X") 2) todo_add("\u6539 X", deps=[0]) 3) todo_add("\u68C0\u67E5\u6539\u52A8", deps=[1])`,parameters:{type:"object",properties:{content:{type:"string",description:"\u6B65\u9AA4\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF0C\u5EFA\u8BAE\u7B80\u6D01\uFF09"},deps:{type:"array",description:"\u4F9D\u8D56\u7684 todo id \u6570\u7EC4\uFF08\u8FD9\u4E9B\u90FD done \u540E\u672C\u9879\u624D\u53EF\u6267\u884C\uFF09",items:{type:"number"}}},required:["content"],additionalProperties:!1},async execute(t){if(typeof t?.content!="string"||t.content.length===0)return{success:!1,data:"\u7F3A\u5C11 content \u53C2\u6570",error:"INVALID_ARGS"};let n=Array.isArray(t.deps)?t.deps.filter(r=>typeof r=="number"):[];try{let r=e.add(t.content,n);return{success:!0,data:`\u5DF2\u6DFB\u52A0 todo #${r}\uFF1A${t.content}${n.length>0?`\uFF08\u4F9D\u8D56: ${n.join(", ")})`:""}`,summary:`\u{1F4CB} \u6DFB\u52A0 #${r}`}}catch(r){return{success:!1,data:r instanceof Error?r.message:String(r),error:"TODO_DEPS_INVALID"}}}}}function yS(e){return{name:"todo_mark_running",kind:"other",description:`\u628A todo \u4ECE pending \u63A8\u8FDB\u5230 running\uFF0C\u8868\u793A\u4F60\u300C\u6B63\u5728\u505A\u300D\u8FD9\u4E00\u6B65\u3002
506
509
  \u524D\u63D0\uFF1A\u8BE5 todo \u5B58\u5728\u3001\u5F53\u524D\u662F pending\u3001\u4E14\u6240\u6709 deps \u5DF2 done \u6216 skipped\u3002
507
510
  \u5DE5\u4F5C\u6D41\uFF1A\u5148\u8C03 todo_mark_running\uFF0C\u518D\u53BB\u8C03\u5B9E\u9645\u7684\u5DE5\u5177\uFF08read_file / edit_file \u7B49\uFF09\uFF0C\u6700\u540E\u7528 todo_mark_done \u6216 todo_mark_failed \u6536\u5C3E\u3002
508
- **\u4E0D\u8981\u8DF3\u8FC7 mark_running \u76F4\u63A5 mark_done** \u2014 \u4F1A\u7834\u574F\u4F9D\u8D56\u68C0\u67E5\uFF0C\u4E0B\u6E38\u6B65\u9AA4\u53EF\u80FD\u8BEF\u4EE5\u4E3A\u4F9D\u8D56\u5DF2\u6EE1\u8DB3\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="pending"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 pending \u53EF\u4EE5\u63A8\u8FDB\u5230 running`,error:"TODO_INVALID_STATE"}:e.markRunning(t.id)?{success:!0,data:`\u5DF2\u5F00\u59CB todo #${t.id}\uFF1A${n.content}`,summary:`\u25B6 \u5F00\u59CB #${t.id}`}:{success:!1,data:`todo #${t.id} \u4F9D\u8D56\u672A\u5168\u90E8\u5B8C\u6210\uFF08\u4F9D\u8D56: #${n.deps.join(", #")}\uFF09`,error:"TODO_DEPS_NOT_READY"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function tS(e){return{name:"todo_mark_done",kind:"other",description:`\u628A todo \u6807\u8BB0\u4E3A\u5B8C\u6210\u3002evidence \u586B\u300C\u5B8C\u6210\u8BC1\u636E\u300D\uFF08\u5982\u300C\u8BFB\u5230 120 \u884C\u300D\u3001\u300Ctypecheck \u901A\u8FC7\u300D\u3001\u300Cedit \u6210\u529F\u300D\uFF09\uFF0C\u4E0D\u586B\u4E5F\u884C\u3002
509
- \u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},evidence:{type:"string",description:"\u5B8C\u6210\u8BC1\u636E\uFF08\u4E00\u53E5\u8BDD\uFF0C\u53EF\u9009\uFF09"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_done\uFF1B\u5982\u9700\u91CD\u8BD5\u8BF7\u5148 todo_retry`,error:"TODO_INVALID_STATE"}:e.markDone(t.id,t.evidence)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5B8C\u6210${t.evidence?`\uFF1A${t.evidence}`:""}`,summary:`\u2705 \u5B8C\u6210 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function nS(e){return{name:"todo_mark_failed",kind:"other",description:`\u628A todo \u6807\u8BB0\u4E3A\u5931\u8D25\uFF0Creason \u586B\u300C\u5931\u8D25\u539F\u56E0\u300D\uFF08\u5982\u300Cold_text \u62FC\u9519\u300D\u3001\u300C\u6587\u4EF6\u4E0D\u5B58\u5728\u300D\uFF09\u3002
511
+ **\u4E0D\u8981\u8DF3\u8FC7 mark_running \u76F4\u63A5 mark_done** \u2014 \u4F1A\u7834\u574F\u4F9D\u8D56\u68C0\u67E5\uFF0C\u4E0B\u6E38\u6B65\u9AA4\u53EF\u80FD\u8BEF\u4EE5\u4E3A\u4F9D\u8D56\u5DF2\u6EE1\u8DB3\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="pending"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 pending \u53EF\u4EE5\u63A8\u8FDB\u5230 running`,error:"TODO_INVALID_STATE"}:e.markRunning(t.id)?{success:!0,data:`\u5DF2\u5F00\u59CB todo #${t.id}\uFF1A${n.content}`,summary:`\u25B6 \u5F00\u59CB #${t.id}`}:{success:!1,data:`todo #${t.id} \u4F9D\u8D56\u672A\u5168\u90E8\u5B8C\u6210\uFF08\u4F9D\u8D56: #${n.deps.join(", #")}\uFF09`,error:"TODO_DEPS_NOT_READY"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function xS(e){return{name:"todo_mark_done",kind:"other",description:`\u628A todo \u6807\u8BB0\u4E3A\u5B8C\u6210\u3002evidence \u586B\u300C\u5B8C\u6210\u8BC1\u636E\u300D\uFF08\u5982\u300C\u8BFB\u5230 120 \u884C\u300D\u3001\u300Ctypecheck \u901A\u8FC7\u300D\u3001\u300Cedit \u6210\u529F\u300D\uFF09\uFF0C\u4E0D\u586B\u4E5F\u884C\u3002
512
+ \u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},evidence:{type:"string",description:"\u5B8C\u6210\u8BC1\u636E\uFF08\u4E00\u53E5\u8BDD\uFF0C\u53EF\u9009\uFF09"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_done\uFF1B\u5982\u9700\u91CD\u8BD5\u8BF7\u5148 todo_retry`,error:"TODO_INVALID_STATE"}:e.markDone(t.id,t.evidence)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5B8C\u6210${t.evidence?`\uFF1A${t.evidence}`:""}`,summary:`\u2705 \u5B8C\u6210 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function bS(e){return{name:"todo_mark_failed",kind:"other",description:`\u628A todo \u6807\u8BB0\u4E3A\u5931\u8D25\uFF0Creason \u586B\u300C\u5931\u8D25\u539F\u56E0\u300D\uFF08\u5982\u300Cold_text \u62FC\u9519\u300D\u3001\u300C\u6587\u4EF6\u4E0D\u5B58\u5728\u300D\uFF09\u3002
510
513
  \u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002
511
- \u8C03\u7528\u540E\u8BE5 step \u72B6\u6001\u53D8\u4E3A failed\u3002\u60F3\u91CD\u8BD5\uFF1A\u8C03 todo_retry(id) \u91CD\u7F6E\u56DE pending\uFF0C\u518D mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 mark_done\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},reason:{type:"string",description:"\u5931\u8D25\u539F\u56E0\uFF08\u4E00\u53E5\u8BDD\uFF09"}},required:["id","reason"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};if(typeof t?.reason!="string")return{success:!1,data:"\u7F3A\u5C11 reason \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_failed`,error:"TODO_INVALID_STATE"}:e.markFailed(t.id,t.reason)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5931\u8D25\uFF1A${t.reason}`,summary:`\u274C \u5931\u8D25 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function rS(e){return{name:"todo_retry",kind:"other",description:`\u628A\u5931\u8D25\u7684 todo \u91CD\u7F6E\u56DE pending\uFF08\u6E05\u7A7A evidence\uFF09\uFF0C\u7136\u540E\u4F60\u53EF\u4EE5\u91CD\u65B0\u8D70 todo_mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 todo_mark_done \u7684\u6D41\u7A0B\u3002
512
- \u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F failed\u3002done / skipped / running \u4E0D\u5141\u8BB8\u91CD\u8BD5\uFF08done \u4E0D\u53EF\u53CD\u6094\u3001running \u5E94\u5148 mark_failed\uFF09\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="failed"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 failed \u53EF\u4EE5\u91CD\u8BD5`,error:"TODO_INVALID_STATE"}:e.resetForRetry(t.id)?{success:!0,data:`\u5DF2\u91CD\u7F6E todo #${t.id} \u4E3A pending\uFF0C\u53EF\u91CD\u65B0\u8DD1`,summary:`\u{1F504} \u91CD\u8BD5 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}p();p();import{execFile as oS}from"child_process";import{promisify as sS}from"util";var gi=sS(oS),yi={windowsHide:!0};async function Cc(e){try{return await gi("git",["rev-parse","--is-inside-work-tree"],{cwd:e,...yi}),!0}catch{return!1}}async function Wm(e){try{return await gi("git",["rev-parse","--verify","HEAD"],{cwd:e,...yi}),!0}catch{return!1}}async function iS(e){return(await gi("git",["status","--porcelain"],{cwd:e,...yi})).stdout.trim().length>0}async function It(e,t){try{let{stdout:n}=await gi("git",e,{cwd:t,...yi});return n}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`git ${e.join(" ")} \u5931\u8D25: ${r}`)}}async function hi(e){return(await It(["stash","list","--format=%H"],e)).split(`
513
- `).map(n=>n.trim()).filter(Boolean)}async function _c(e){let t=Date.now();if(!await Cc(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!1};if(!await Wm(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};if(!await iS(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};let r=await hi(e);await It(["stash","push","-m",`dskcode-cp-${t}`,"-u"],e);let o=await hi(e);if(o.length===0)throw new Error("git stash push \u672A\u80FD\u521B\u5EFA stash entry");let s=o.find(i=>!r.includes(i))??o[0];return await It(["stash","apply",s],e),{stashSha:s,timestamp:t,cwd:e,isGitRepo:!0}}async function vc(e){if(!e.isGitRepo)throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!e.stashSha)throw new Error("\u68C0\u67E5\u70B9\u4E3A\u7A7A\uFF08\u5DE5\u4F5C\u533A\u539F\u672C\u5C31\u5E72\u51C0\uFF09\uFF0C\u65E0\u9700\u6062\u590D");let{cwd:t,stashSha:n}=e,r=await hi(t);if(!r.includes(n))throw new Error("\u68C0\u67E5\u70B9\u5DF2\u5931\u6548\uFF08stash entry \u5DF2\u88AB\u6D88\u8D39\u6216 GC\uFF09\uFF0C\u65E0\u6CD5\u6062\u590D");await It(["checkout","--","."],t),await It(["clean","-fd"],t),await It(["stash","apply",n],t);let o=r.indexOf(n);o>=0&&await It(["stash","drop",`stash@{${o}}`],t)}async function Rc(e){if(!await Cc(e))throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!await Wm(e))throw new Error("\u4ED3\u5E93\u65E0 commit\uFF0C\u65E0\u6CD5\u6062\u590D");await It(["checkout","--","."],e),await It(["clean","-fd"],e)}async function xi(e){if(!e.isGitRepo||!e.stashSha)return;let{cwd:t,stashSha:n}=e,r;try{r=await hi(t)}catch{return}let o=r.indexOf(n);if(!(o<0))try{await It(["stash","drop",`stash@{${o}}`],t)}catch{}}p();p();import{mkdir as aS,readFile as Hm,writeFile as lS,readdir as cS,unlink as uS,rename as dS}from"fs/promises";import{join as xr}from"path";import{randomUUID as pS}from"crypto";function Vm(){let e=process.env.HOME??process.env.USERPROFILE??"~";return xr(e,".dskcode","sessions")}var Gn=class{#e;constructor(t){this.#e=t??Vm()}get dir(){return this.#e}async save(t){await aS(this.#e,{recursive:!0});let n=xr(this.#e,`${t.id}.json`),r=xr(this.#e,`.${t.id}.json.tmp`);await lS(r,JSON.stringify(t,null,2),"utf-8"),await dS(r,n)}async load(t){let n=xr(this.#e,`${t}.json`);try{let r=await Hm(n,"utf-8");return JSON.parse(r)}catch(r){if(Ac(r))return null;throw r}}async list(){let t;try{t=await cS(this.#e)}catch(r){if(Ac(r))return[];throw r}let n=[];for(let r of t)if(!(!r.endsWith(".json")||r.startsWith(".")))try{let o=await Hm(xr(this.#e,r),"utf-8"),s=JSON.parse(o);n.push({id:s.id,title:s.title||"\uFF08\u65E0\u6807\u9898\uFF09",updatedAt:s.updatedAt,cwd:s.cwd,messageCount:s.messages?.length??0})}catch{}return n.sort((r,o)=>o.updatedAt-r.updatedAt)}async delete(t){let n=xr(this.#e,`${t}.json`);try{await uS(n)}catch(r){if(!Ac(r))throw r}}async exists(t){return await this.load(t)!==null}static newId(){return pS()}};function Ac(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}p();p();import{readFile as yS,stat as xS}from"fs/promises";import{open as bS}from"fs/promises";import{relative as wS}from"path";p();import{resolve as To,relative as Km,isAbsolute as fS}from"path";import{realpath as zm}from"fs/promises";import{spawn as mS}from"child_process";import Xm from"process";var Jm=3e4,hS=5e4,ND=10*1024*1024,bi=Xm.platform==="win32";function br(e){return e.startsWith("@")?e.slice(1):e}function Ye(e,t){let n=br(e),r=fS(n)?n:To(t,n);return To(r)}async function qm(e){try{return await zm(e)}catch{let t=To(e,"..");try{let n=await zm(t);return To(n,Km(t,e))}catch{return To(e)}}}async function Vt(e,t){if(e.length===0)return{ok:!0};let n=await qm(t);for(let r of e){let o=await qm(r),s=Km(o,n);if(!s.startsWith("..")&&s!==""&&!s.startsWith("/")&&!s.startsWith("\\"))return{ok:!0};if(n===o)return{ok:!0}}return{ok:!1,error:`\u8DEF\u5F84 "${t}" \u4E0D\u5728\u5141\u8BB8\u7684\u5199\u5165\u8303\u56F4\u5185 ${e.join(", ")}`}}function We(e,t=hS){return e.length<=t?e:`${e.slice(0,t)}
514
+ \u8C03\u7528\u540E\u8BE5 step \u72B6\u6001\u53D8\u4E3A failed\u3002\u60F3\u91CD\u8BD5\uFF1A\u8C03 todo_retry(id) \u91CD\u7F6E\u56DE pending\uFF0C\u518D mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 mark_done\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},reason:{type:"string",description:"\u5931\u8D25\u539F\u56E0\uFF08\u4E00\u53E5\u8BDD\uFF09"}},required:["id","reason"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};if(typeof t?.reason!="string")return{success:!1,data:"\u7F3A\u5C11 reason \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_failed`,error:"TODO_INVALID_STATE"}:e.markFailed(t.id,t.reason)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5931\u8D25\uFF1A${t.reason}`,summary:`\u274C \u5931\u8D25 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function wS(e){return{name:"todo_retry",kind:"other",description:`\u628A\u5931\u8D25\u7684 todo \u91CD\u7F6E\u56DE pending\uFF08\u6E05\u7A7A evidence\uFF09\uFF0C\u7136\u540E\u4F60\u53EF\u4EE5\u91CD\u65B0\u8D70 todo_mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 todo_mark_done \u7684\u6D41\u7A0B\u3002
515
+ \u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F failed\u3002done / skipped / running \u4E0D\u5141\u8BB8\u91CD\u8BD5\uFF08done \u4E0D\u53EF\u53CD\u6094\u3001running \u5E94\u5148 mark_failed\uFF09\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="failed"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 failed \u53EF\u4EE5\u91CD\u8BD5`,error:"TODO_INVALID_STATE"}:e.resetForRetry(t.id)?{success:!0,data:`\u5DF2\u91CD\u7F6E todo #${t.id} \u4E3A pending\uFF0C\u53EF\u91CD\u65B0\u8DD1`,summary:`\u{1F504} \u91CD\u8BD5 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}p();p();import{execFile as kS}from"child_process";import{promisify as SS}from"util";var wi=SS(kS),ki={windowsHide:!0};async function Ec(e){try{return await wi("git",["rev-parse","--is-inside-work-tree"],{cwd:e,...ki}),!0}catch{return!1}}async function Xm(e){try{return await wi("git",["rev-parse","--verify","HEAD"],{cwd:e,...ki}),!0}catch{return!1}}async function TS(e){return(await wi("git",["status","--porcelain"],{cwd:e,...ki})).stdout.trim().length>0}async function It(e,t){try{let{stdout:n}=await wi("git",e,{cwd:t,...ki});return n}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`git ${e.join(" ")} \u5931\u8D25: ${r}`)}}async function bi(e){return(await It(["stash","list","--format=%H"],e)).split(`
516
+ `).map(n=>n.trim()).filter(Boolean)}async function Ic(e){let t=Date.now();if(!await Ec(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!1};if(!await Xm(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};if(!await TS(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};let r=await bi(e);await It(["stash","push","-m",`dskcode-cp-${t}`,"-u"],e);let o=await bi(e);if(o.length===0)throw new Error("git stash push \u672A\u80FD\u521B\u5EFA stash entry");let s=o.find(i=>!r.includes(i))??o[0];return await It(["stash","apply",s],e),{stashSha:s,timestamp:t,cwd:e,isGitRepo:!0}}async function Pc(e){if(!e.isGitRepo)throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!e.stashSha)throw new Error("\u68C0\u67E5\u70B9\u4E3A\u7A7A\uFF08\u5DE5\u4F5C\u533A\u539F\u672C\u5C31\u5E72\u51C0\uFF09\uFF0C\u65E0\u9700\u6062\u590D");let{cwd:t,stashSha:n}=e,r=await bi(t);if(!r.includes(n))throw new Error("\u68C0\u67E5\u70B9\u5DF2\u5931\u6548\uFF08stash entry \u5DF2\u88AB\u6D88\u8D39\u6216 GC\uFF09\uFF0C\u65E0\u6CD5\u6062\u590D");await It(["checkout","--","."],t),await It(["clean","-fd"],t),await It(["stash","apply",n],t);let o=r.indexOf(n);o>=0&&await It(["stash","drop",`stash@{${o}}`],t)}async function Lc(e){if(!await Ec(e))throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!await Xm(e))throw new Error("\u4ED3\u5E93\u65E0 commit\uFF0C\u65E0\u6CD5\u6062\u590D");await It(["checkout","--","."],e),await It(["clean","-fd"],e)}async function Si(e){if(!e.isGitRepo||!e.stashSha)return;let{cwd:t,stashSha:n}=e,r;try{r=await bi(t)}catch{return}let o=r.indexOf(n);if(!(o<0))try{await It(["stash","drop",`stash@{${o}}`],t)}catch{}}p();p();import{mkdir as CS,readFile as Jm,writeFile as _S,readdir as RS,unlink as vS,rename as AS}from"fs/promises";import{join as hr}from"path";import{randomUUID as ES}from"crypto";function Zm(){let e=process.env.HOME??process.env.USERPROFILE??"~";return hr(e,".dskcode","sessions")}var Fn=class{#e;constructor(t){this.#e=t??Zm()}get dir(){return this.#e}async save(t){await CS(this.#e,{recursive:!0});let n=hr(this.#e,`${t.id}.json`),r=hr(this.#e,`.${t.id}.json.tmp`);await _S(r,JSON.stringify(t,null,2),"utf-8"),await AS(r,n)}async load(t){let n=hr(this.#e,`${t}.json`);try{let r=await Jm(n,"utf-8");return JSON.parse(r)}catch(r){if($c(r))return null;throw r}}async list(){let t;try{t=await RS(this.#e)}catch(r){if($c(r))return[];throw r}let n=[];for(let r of t)if(!(!r.endsWith(".json")||r.startsWith(".")))try{let o=await Jm(hr(this.#e,r),"utf-8"),s=JSON.parse(o);n.push({id:s.id,title:s.title||"\uFF08\u65E0\u6807\u9898\uFF09",updatedAt:s.updatedAt,cwd:s.cwd,messageCount:s.messages?.length??0})}catch{}return n.sort((r,o)=>o.updatedAt-r.updatedAt)}async delete(t){let n=hr(this.#e,`${t}.json`);try{await vS(n)}catch(r){if(!$c(r))throw r}}async exists(t){return await this.load(t)!==null}static newId(){return ES()}};function $c(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}p();p();import{readFile as $S,stat as OS,open as DS}from"fs/promises";import{relative as NS}from"path";p();import{resolve as _o,relative as eh,isAbsolute as IS}from"path";import{realpath as Ym}from"fs/promises";import{spawn as PS}from"child_process";import th from"process";var nh=3e4,rh=5e4,aN=10*1024*1024,Ti=th.platform==="win32";function gr(e){return e.startsWith("@")?e.slice(1):e}function Ye(e,t){let n=gr(e),r=IS(n)?n:_o(t,n);return _o(r)}async function Qm(e){try{return await Ym(e)}catch{let t=_o(e,"..");try{let n=await Ym(t);return _o(n,eh(t,e))}catch{return _o(e)}}}async function Vt(e,t){if(e.length===0)return{ok:!0};let n=await Qm(t);for(let r of e){let o=await Qm(r);if(n===o)return{ok:!0};let s=eh(o,n);if(!s.startsWith("..")&&s!==""&&!s.startsWith("/")&&!s.startsWith("\\"))return{ok:!0}}return{ok:!1,error:`\u8DEF\u5F84 "${t}" \u4E0D\u5728\u5141\u8BB8\u7684\u5199\u5165\u8303\u56F4\u5185 ${e.join(", ")}`}}function Ue(e,t=rh){return e.length<=t?e:`${e.slice(0,t)}
514
517
 
515
- ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u5171 ${String(e.length)} \u5B57\u7B26]`}function Ec(){return Jm}async function Ic(e,t,n,r=Jm,o,s){return new Promise(i=>{let a,l,c;s?(a=e,l=t,c=!1,bi&&a==="cmd"&&l[0]==="/c"&&(l=["/c",`chcp 65001 >nul && ${l[1]??""}`])):(c=!bi,a=bi?"cmd":e,l=bi?["/c",e,...t]:t);let u=mS(a,l,{cwd:n,shell:c,env:{...Xm.env},stdio:["pipe","pipe","pipe"]}),d="",m="";u.stdout.on("data",f=>{d+=f.toString("utf8")}),u.stderr.on("data",f=>{m+=f.toString("utf8")});let h=setTimeout(()=>{u.kill("SIGTERM"),setTimeout(()=>{u.kill("SIGKILL")},5e3)},r);o&&(o.aborted&&u.kill("SIGTERM"),o.addEventListener("abort",()=>{u.kill("SIGTERM")},{once:!0})),u.on("close",f=>{clearTimeout(h),i({stdout:d,stderr:m,exitCode:f})}),u.on("error",f=>{clearTimeout(h),m+=`
516
- \u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${f.message}`,i({stdout:d,stderr:m,exitCode:null})})})}p();import{writeFile as gS}from"fs/promises";function Zm(e){if(e.length===0)return`
518
+ ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u5171 ${String(e.length)} \u5B57\u7B26]`}function Oc(){return nh}async function Dc(e,t,n,r=nh,o,s){return new Promise(i=>{let a,l,c;s?(a=e,l=t,c=!1,Ti&&a==="cmd"&&l[0]==="/c"&&(l=["/c",`chcp 65001 >nul && ${l[1]??""}`])):(c=!Ti,a=Ti?"cmd":e,l=Ti?["/c",e,...t]:t);let u=PS(a,l,{cwd:n,shell:c,env:{...th.env},stdio:["pipe","pipe","pipe"]}),d=5*rh,m=`
519
+ ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u4E22\u5F03\u540E\u7EED\u5185\u5BB9]`,h="",f="",g=!1,k=!1,b=(_,B)=>{let j=_==="stdout";if(j?g:k)return;let D=(j?h:f)+B;if(D.length<=d){j?h=D:f=D;return}let C=D.slice(0,d)+m;j?(h=C,g=!0,u.stdout?.removeAllListeners("data")):(f=C,k=!0,u.stderr?.removeAllListeners("data"))};u.stdout.on("data",_=>{b("stdout",_.toString("utf8"))}),u.stderr.on("data",_=>{b("stderr",_.toString("utf8"))});let S=null,R=null,v=()=>{S!==null&&(clearTimeout(S),S=null),R!==null&&(clearTimeout(R),R=null)};S=setTimeout(()=>{u.kill("SIGTERM"),S=null,R=setTimeout(()=>{u.kill("SIGKILL"),R=null},5e3)},r),o&&(o.aborted&&u.kill("SIGTERM"),o.addEventListener("abort",()=>{u.kill("SIGTERM")},{once:!0})),u.on("close",_=>{v(),i({stdout:h,stderr:f,exitCode:_})}),u.on("error",_=>{v(),f+=`
520
+ \u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${_.message}`,i({stdout:h,stderr:f,exitCode:null})})})}p();import{writeFile as LS}from"fs/promises";function oh(e){if(e.length===0)return`
517
521
  `;let t=e.indexOf(`\r
518
522
  `),n=e.indexOf(`
519
523
  `);return t!==-1&&(n===-1||t<=n)?`\r
520
524
  `:`
521
- `}function Ym(e){return e.endsWith(`
525
+ `}function sh(e){return e.endsWith(`
522
526
  `)||e.endsWith(`\r
523
- `)}function Ge(e){return e.includes("\r")?e.replace(/\r\n/g,`
527
+ `)}function We(e){return e.includes("\r")?e.replace(/\r\n/g,`
524
528
  `).replace(/\r/g,`
525
- `):e}function pn(e,t){let n=Zm(e),r=t.replace(/\r\n/g,`
529
+ `):e}function pn(e,t){let n=oh(e),r=t.replace(/\r\n/g,`
526
530
  `).split(`
527
- `),o=Ym(e),s=r.length>0&&r[r.length-1]==="",i=r.join(n);return o&&!s&&(i+=n),!o&&s&&i.endsWith(n)&&(i=i.slice(0,-n.length)),i}async function Pc(e,t,n){let r=t.length>0?pn(t,n):n;await gS(e,r,"utf-8")}async function kS(e){let t=await bS(e,"r");try{let n=Buffer.alloc(8192),{bytesRead:r}=await t.read(n,0,8192,0);return n.subarray(0,r).includes(0)}finally{await t.close()}}var Lc={name:"read_file",kind:"read",description:"\u8BFB\u53D6\u6307\u5B9A\u8DEF\u5F84\u7684\u6587\u4EF6\u5185\u5BB9\u3002\u652F\u6301\u884C\u53F7\u8303\u56F4\u9009\u62E9\uFF0C\u8F93\u51FA\u5E26\u884C\u53F7\u3002\u9002\u7528\u4E8E\u67E5\u770B\u6E90\u4EE3\u7801\u3001\u914D\u7F6E\u6587\u4EF6\u7B49\u6587\u672C\u6587\u4EF6\u3002\u81EA\u52A8\u62D2\u7EDD\u4E8C\u8FDB\u5236\u6587\u4EF6\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},startLine:{type:"number",description:"\u8D77\u59CB\u884C\u53F7\uFF08\u4ECE 1 \u5F00\u59CB\uFF09\uFF0C\u9ED8\u8BA4\u4E3A 1"},endLine:{type:"number",description:"\u7ED3\u675F\u884C\u53F7\uFF08\u5305\u542B\uFF09\uFF0C\u9ED8\u8BA4\u5230\u6587\u4EF6\u672B\u5C3E"}},required:["path"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);try{let r=await xS(n),o=10*1024*1024;if(r.size>o)return{success:!1,data:`\u6587\u4EF6\u8FC7\u5927\uFF08${(r.size/1024/1024).toFixed(1)}MB\uFF09\uFF0C\u8D85\u8FC7 10MB \u9650\u5236`,error:"FILE_TOO_LARGE"};if(r.isDirectory())return{success:!1,data:`"${n}" \u662F\u4E00\u4E2A\u76EE\u5F55\uFF0C\u8BF7\u4F7F\u7528 ls \u5DE5\u5177\u67E5\u770B\u76EE\u5F55\u5185\u5BB9`,error:"IS_DIRECTORY"};if(r.size>0&&await kS(n))return{success:!1,data:`"${n}" \u770B\u8D77\u6765\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u8BFB\u53D6`,error:"BINARY_FILE"};let s=await yS(n,"utf-8"),i=Ge(s).split(`
528
- `);i.length>0&&i[i.length-1]===""&&s.endsWith(`
529
- `)&&i.pop();let a=Math.max(1,e.startLine??1)-1,l=e.endLine?Math.min(e.endLine,i.length):i.length,c=i.slice(a,l),u=String(l).length,d=c.map((b,w)=>`${String(a+w+1).padStart(u," ")}\u2192${b}`).join(`
530
- `),m=i.length-l,h=m>0?`
531
+ `),o=sh(e),s=r.length>0&&r[r.length-1]==="",i=r.join(n);return o&&!s&&(i+=n),!o&&s&&i.endsWith(n)&&(i=i.slice(0,-n.length)),i}async function Nc(e,t,n){let r=t.length>0?pn(t,n):n;await LS(e,r,"utf-8")}async function MS(e){let t=await DS(e,"r");try{let n=Buffer.alloc(8192),{bytesRead:r}=await t.read(n,0,8192,0);return n.subarray(0,r).includes(0)}finally{await t.close()}}var Mc={name:"read_file",kind:"read",description:"\u8BFB\u53D6\u6307\u5B9A\u8DEF\u5F84\u7684\u6587\u4EF6\u5185\u5BB9\u3002\u652F\u6301\u884C\u53F7\u8303\u56F4\u9009\u62E9\uFF0C\u8F93\u51FA\u5E26\u884C\u53F7\u3002\u9002\u7528\u4E8E\u67E5\u770B\u6E90\u4EE3\u7801\u3001\u914D\u7F6E\u6587\u4EF6\u7B49\u6587\u672C\u6587\u4EF6\u3002\u81EA\u52A8\u62D2\u7EDD\u4E8C\u8FDB\u5236\u6587\u4EF6\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},startLine:{type:"number",description:"\u8D77\u59CB\u884C\u53F7\uFF08\u4ECE 1 \u5F00\u59CB\uFF09\uFF0C\u9ED8\u8BA4\u4E3A 1"},endLine:{type:"number",description:"\u7ED3\u675F\u884C\u53F7\uFF08\u5305\u542B\uFF09\uFF0C\u9ED8\u8BA4\u5230\u6587\u4EF6\u672B\u5C3E"}},required:["path"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd),r=NS(t.cwd,n).replace(/\\/g,"/");try{let o=await OS(n),s=10*1024*1024;if(o.size>s)return{success:!1,data:`\u6587\u4EF6\u8FC7\u5927\uFF08${(o.size/1024/1024).toFixed(1)}MB\uFF09\uFF0C\u8D85\u8FC7 10MB \u9650\u5236`,error:"FILE_TOO_LARGE"};if(o.isDirectory())return{success:!1,data:`"${n}" \u662F\u4E00\u4E2A\u76EE\u5F55\uFF0C\u8BF7\u4F7F\u7528 ls \u5DE5\u5177\u67E5\u770B\u76EE\u5F55\u5185\u5BB9`,error:"IS_DIRECTORY"};if(o.size>0&&await MS(n))return{success:!1,data:`"${n}" \u770B\u8D77\u6765\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u8BFB\u53D6`,error:"BINARY_FILE"};if(o.size===0)return{success:!0,data:"(\u7A7A\u6587\u4EF6)",summary:`\u{1F4D6} ${r}\uFF080 \u884C\uFF09`};let i=await $S(n,"utf-8"),a=We(i).split(`
532
+ `),l=a.length>0&&a[a.length-1]===""&&i.endsWith(`
533
+ `)?a.slice(0,-1):a,c=Math.max(1,e.startLine??1)-1,u=e.endLine?Math.min(e.endLine,l.length):l.length,d=l.slice(c,u),m=String(u).length,h=d.map((b,S)=>`${String(c+S+1).padStart(m," ")}\u2192${b}`).join(`
534
+ `),f=l.length-u,g=f>0?`
531
535
 
532
- [\u8FD8\u6709 ${m} \u884C\uFF1B\u4F7F\u7528 startLine=${l+1} \u7EE7\u7EED\u67E5\u770B]`:"",f=wS(t.cwd,n).replace(/\\/g,"/"),g=a>0||l<i.length?`\u7B2C ${a+1}-${l} \u884C`:`${i.length} \u884C`;return{success:!0,data:We(d)+h,summary:`\u{1F4D6} ${f}\uFF08${g}\uFF09`}}catch(r){return{success:!1,data:`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"READ_ERROR"}}}};p();import{mkdir as AS,readFile as ES}from"fs/promises";import{dirname as IS,relative as PS,basename as LS}from"path";p();function wi(e){if(e.length===0)return{lines:[],eol:`
536
+ [\u8FD8\u6709 ${f} \u884C\uFF1B\u4F7F\u7528 startLine=${u+1} \u7EE7\u7EED\u67E5\u770B]`:"",k=c>0||u<l.length?`\u7B2C ${c+1}-${u} \u884C`:`${l.length} \u884C`;return{success:!0,data:Ue(h)+g,summary:`\u{1F4D6} ${r}\uFF08${k}\uFF09`}}catch(o){return{success:!1,data:`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"READ_ERROR"}}}};p();import{mkdir as HS,readFile as VS}from"fs/promises";import{dirname as zS,relative as qS,basename as KS}from"path";p();function Ci(e){if(e.length===0)return{lines:[],eol:`
533
537
  `,eofStyle:"no-eol"};let t=e.indexOf(`\r
534
538
  `),n=e.indexOf(`
535
- `),r;t!==-1&&(n===-1||t<=n)?r=`\r
536
- `:r=`
537
- `;let o=e.split(r),s;return e.endsWith(r)?(o.length>0&&o[o.length-1]===""&&o.pop(),s="lf"):s="no-eol",{lines:o,eol:r,eofStyle:s}}function SS(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map(l=>({op:"add",line:l}));if(r===0)return e.map(l=>({op:"remove",line:l}));let o=[],s=n+r,i=new Array(2*s+2).fill(-1),a=s;i[a+1]=0;for(let l=0;l<=s;l++){let c=new Map,u=-l,d=l;for(let m=u;m<=d;m+=2){let h=m+a,f;m===-l||m!==l&&i[h-1]<i[h+1]?f=i[h+1]:f=i[h-1]+1;let g=f-m;for(;f<n&&g<r&&e[f]===t[g];)f++,g++;if(i[h]=f,c.set(m,f),f>=n&&g>=r)return o.push(c),TS(o,n,r,e,t,a)}o.push(c)}return e.map(l=>({op:"remove",line:l})).concat(t.map(l=>({op:"add",line:l})))}function TS(e,t,n,r,o,s){let i=[],a=t,l=n;for(let c=e.length-1;c>=1;c--){let u=a-l,d=e[c-1],m=d.get(u-1),h=d.get(u+1),f;u===-c?f=u+1:u===c?f=u-1:(m??-1)<(h??-1)?f=u+1:f=u-1;let g=d.get(f)??0,b=g-f;if(f===u-1){for(;a>g+1&&l>b;)a--,l--,i.unshift({op:"equal",line:r[a]});a>g&&(a--,i.unshift({op:"remove",line:r[a]}))}else{for(;a>g&&l>b+1;)a--,l--,i.unshift({op:"equal",line:r[a]});l>b&&(l--,i.unshift({op:"add",line:o[l]}))}}for(;a>0&&l>0;)a--,l--,i.unshift({op:"equal",line:r[a]});return i}var $c=3;function CS(e){if(e.length===0)return[];let t=[];for(let o=0;o<e.length;o++)e[o].op!=="equal"&&t.push(o);if(t.length===0)return[];let n=[[t[0]]];for(let o=1;o<t.length;o++){let s=n[n.length-1],i=s[s.length-1],a=t[o],l=0;for(let c=i+1;c<a;c++)e[c].op==="equal"&&l++;l<=2*$c?s.push(a):n.push([a])}let r=[];for(let o of n){let s=o[0],i=o[o.length-1],a=Math.max(0,s-$c),l=Math.min(e.length-1,i+$c),c=e.slice(a,l+1),u=0,d=0;for(let f=0;f<a;f++){let g=e[f];(g.op==="equal"||g.op==="remove")&&u++,(g.op==="equal"||g.op==="add")&&d++}let m=0,h=0;for(let f of c)(f.op==="equal"||f.op==="remove")&&m++,(f.op==="equal"||f.op==="add")&&h++;r.push({oldStart:u+1,oldCount:m,newStart:d+1,newCount:h,lines:c})}return r}function _S(e,t){if(e.length===0)return"";let n=[],r=Oc(t);n.push(`--- a/${r}`),n.push(`+++ b/${r}`);for(let o of e){n.push(`@@ -${String(o.oldStart)},${String(o.oldCount)} +${String(o.newStart)},${String(o.newCount)} @@`);for(let s of o.lines)switch(s.op){case"equal":n.push(` ${s.line}`);break;case"remove":n.push(`-${s.line}`);break;case"add":n.push(`+${s.line}`);break}}return n.join(`
538
- `)}function vS(e,t){let n=Oc(t),r=[];r.push("--- /dev/null"),r.push(`+++ b/${n}`),r.push(`@@ -0,0 +1,${String(e.length)} @@`);for(let o of e)r.push(`+${o}`);return r.join(`
539
- `)}function RS(e,t){let n=Oc(t),r=[];r.push(`--- a/${n}`),r.push("+++ /dev/null"),r.push(`@@ -1,${String(e.length)} +0,0 @@`);for(let o of e)r.push(`-${o}`);return r.join(`
540
- `)}function Oc(e){return e.replace(/\\/g,"/").split("/").pop()??e}function zt(e,t,n){if(e===t)return{filePath:n,patch:"",existedBefore:e.length>0,additions:0,deletions:0};if(e.length===0){let u=wi(t),d=vS(u.lines,n);return{filePath:n,patch:d,existedBefore:!1,additions:u.lines.length,deletions:0}}if(t.length===0){let u=wi(e),d=RS(u.lines,n);return{filePath:n,patch:d,existedBefore:!0,additions:0,deletions:u.lines.length}}let r=wi(e),o=wi(t),s=SS(r.lines,o.lines),i=0,a=0;for(let u of s)u.op==="add"&&i++,u.op==="remove"&&a++;let l=CS(s),c=_S(l,n);return{filePath:n,patch:c,existedBefore:!0,additions:i,deletions:a}}var Dc={name:"write_file",kind:"edit",description:"\u521B\u5EFA\u6216\u8986\u76D6\u6587\u4EF6\u3002\u5982\u679C\u7236\u76EE\u5F55\u4E0D\u5B58\u5728\u4F1A\u81EA\u52A8\u521B\u5EFA\u3002\u9002\u7528\u4E8E\u521B\u5EFA\u65B0\u6587\u4EF6\u6216\u5B8C\u5168\u66FF\u6362\u6587\u4EF6\u5185\u5BB9\u3002\u8BF7\u52FF\u7528\u6B64\u5DE5\u5177\u521B\u5EFA _temp_\u3001_debug_ \u7B49\u7528\u4E8E\u8BCA\u65AD/\u8C03\u8BD5\u7684\u4E34\u65F6\u6587\u4EF6\u2014\u2014\u5982\u9700\u8BCA\u65AD\u8BF7\u6539\u7528 bash \u5DE5\u5177\u5185\u8054\u811A\u672C\uFF08node -e\uFF09\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},content:{type:"string",description:"\u8981\u5199\u5165\u7684\u6587\u4EF6\u5185\u5BB9"}},required:["path","content"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(e.content===void 0||e.content===null)return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 content",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);try{if(t.writeRoots&&t.writeRoots.length>0){let h=await Vt(t.writeRoots,n);if(!h.ok)return{success:!1,data:h.error,error:"OUTSIDE_WRITE_ROOTS"}}let r="",o=!1;try{r=await ES(n,"utf-8"),o=!0}catch{}await AS(IS(n),{recursive:!0});let s=e.content;await Pc(n,r,s);let i=zt(r,s,n);i.existedBefore=o;let a=s.split(`
541
- `).length,l=Buffer.byteLength(s,"utf-8"),c=o?"\u5DF2\u4FEE\u6539":"\u5DF2\u521B\u5EFA",u=o?`\uFF0C+${i.additions} -${i.deletions}`:`\uFF0C+${i.additions} \u884C\uFF08\u65B0\u5EFA\uFF09`,d=LS(n),m=o?`\u{1F4DD} \u4FEE\u6539: ${d} (+${i.additions} -${i.deletions})`:`\u{1F4DD} \u65B0\u5EFA: ${d} (+${i.additions} \u884C)`;return{success:!0,data:`\u6587\u4EF6${c}\uFF1A${PS(t.cwd,n).replace(/\\/g,"/")}\uFF08${a} \u884C\uFF0C${l} \u5B57\u8282${u}\uFF09`,summary:m,diff:i}}catch(r){return{success:!1,data:`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"WRITE_ERROR"}}}};p();import{readFile as $S}from"fs/promises";import{writeFile as OS}from"fs/promises";import{basename as DS}from"path";var Nc={name:"edit_file",kind:"edit",description:"\u5BF9\u6587\u4EF6\u8FDB\u884C\u7CBE\u786E\u5B57\u7B26\u4E32\u66FF\u6362\u3002\u67E5\u627E\u6587\u4EF6\u4E2D\u7684 old_text \u5E76\u66FF\u6362\u4E3A new_text\u3002\u5982\u679C old_text \u51FA\u73B0\u591A\u6B21\u6216\u672A\u627E\u5230\u5219\u62A5\u9519\u3002\u9002\u7528\u4E8E\u5C0F\u8303\u56F4\u7CBE\u786E\u4FEE\u6539\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},old_text:{type:"string",description:"\u8981\u67E5\u627E\u7684\u539F\u59CB\u6587\u672C\uFF08\u7CBE\u786E\u5339\u914D\uFF09"},new_text:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"}},required:["path","old_text","new_text"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(typeof e.old_text!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 old_text",error:"INVALID_ARGS"};if(typeof e.new_text!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 new_text",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await Vt(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await $S(n,"utf-8"),o=Ge(r),s=Ge(e.old_text),i=o.indexOf(s);if(i===-1)return{success:!1,data:"\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\u3002\u8BF7\u786E\u8BA4 old_text \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF08\u5305\u62EC\u7F29\u8FDB\u548C\u7A7A\u683C\uFF09\u3002",error:"TEXT_NOT_FOUND"};if(o.indexOf(s,i+1)!==-1)return{success:!1,data:"\u8981\u66FF\u6362\u7684\u6587\u672C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\uFF0C\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4EE5\u7CBE\u786E\u5B9A\u4F4D\u3002",error:"TEXT_MULTIPLE_MATCHES"};let l=o.slice(0,i)+Ge(e.new_text)+o.slice(i+s.length),c=pn(r,l);await OS(n,c,"utf-8");let u=zt(r,c,n);u.existedBefore=!0;let m=o.slice(0,i).split(`
542
- `).length,h=s.split(`
543
- `).length,f=Ge(e.new_text).split(`
544
- `).length,g=`+${u.additions} -${u.deletions}`,b=`\u{1F4DD} \u4FEE\u6539: ${DS(n)} (+${u.additions} -${u.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
545
- \u66FF\u6362\u4F4D\u7F6E\uFF1A\u7B2C ${m} \u884C
546
- ${h} \u884C \u2192 ${f} \u884C
547
- \u53D8\u66F4\uFF1A${g}`,summary:b,diff:u}}catch(r){return{success:!1,data:`\u7F16\u8F91\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EDIT_ERROR"}}}};p();import{readFile as NS}from"fs/promises";import{writeFile as MS}from"fs/promises";import{basename as BS}from"path";var Mc={name:"multi_edit",kind:"edit",description:"\u5BF9\u6587\u4EF6\u8FDB\u884C\u539F\u5B50\u6279\u91CF\u66FF\u6362\u7F16\u8F91\u3002\u5728\u4E00\u4E2A\u8BF7\u6C42\u4E2D\u6267\u884C\u591A\u4E2A\u7CBE\u786E\u66FF\u6362\uFF0C\u4EFB\u4E00\u5931\u8D25\u5219\u5168\u90E8\u56DE\u6EDA\u3002\u652F\u6301 replaceAll \u53C2\u6570\u505A\u5168\u5C40\u66FF\u6362\u3002\u9002\u7528\u4E8E\u9700\u8981\u540C\u65F6\u4FEE\u6539\u6587\u4EF6\u591A\u5904\u7684\u573A\u666F\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},edits:{type:"array",description:"\u6709\u5E8F\u7684\u7F16\u8F91\u6B65\u9AA4\u5217\u8868\u3002\u6BCF\u4E2A\u6B65\u9AA4\u5305\u542B oldText\uFF08\u7CBE\u786E\u5339\u914D\uFF09\u3001newText\uFF08\u66FF\u6362\u5185\u5BB9\uFF09\u548C\u53EF\u9009\u7684 replaceAll\uFF08\u662F\u5426\u66FF\u6362\u6240\u6709\u5339\u914D\u9879\uFF09",items:{type:"object",properties:{oldText:{type:"string",description:"\u8981\u67E5\u627E\u7684\u539F\u59CB\u6587\u672C\uFF08\u7CBE\u786E\u5339\u914D\uFF09"},newText:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"},replaceAll:{type:"boolean",description:"\u662F\u5426\u66FF\u6362\u6240\u6709\u5339\u914D\u9879\uFF0C\u9ED8\u8BA4 false"}},required:["oldText","newText"],additionalProperties:!1}}},required:["path","edits"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(!Array.isArray(e.edits)||e.edits.length===0)return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 edits\uFF08\u975E\u7A7A\u6570\u7EC4\uFF09",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await Vt(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await NS(n,"utf-8"),o=Ge(r);for(let a=0;a<e.edits.length;a++){let l=e.edits[a];if(typeof l.oldText!="string")return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u7F3A\u5C11\u6709\u6548\u7684 oldText`,error:"INVALID_STEP_ARGS"};if(typeof l.newText!="string")return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u7F3A\u5C11\u6709\u6548\u7684 newText`,error:"INVALID_STEP_ARGS"};let c=Ge(l.oldText),u=Ge(l.newText);if(l.replaceAll){let d=0,m=-1;for(;(m=o.indexOf(c,m+1))!==-1;)d++;if(d===0)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\uFF0C\u8BF7\u786E\u8BA4 oldText \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4`,error:"TEXT_NOT_FOUND"};o=o.split(c).join(u)}else{let d=o.indexOf(c);if(d===-1)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\u3002\u8BF7\u786E\u8BA4 oldText \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF08\u5305\u62EC\u7F29\u8FDB\u548C\u7A7A\u683C\uFF09\u3002`,error:"TEXT_NOT_FOUND"};if(o.indexOf(c,d+1)!==-1)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u8981\u66FF\u6362\u7684\u6587\u672C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\uFF0C\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4EE5\u7CBE\u786E\u5B9A\u4F4D\uFF0C\u6216\u8BBE\u7F6E replaceAll=true`,error:"TEXT_MULTIPLE_MATCHES"};o=o.slice(0,d)+u+o.slice(d+c.length)}}let s=pn(r,o);await MS(n,s,"utf-8");let i=zt(r,s,n);return i.existedBefore=!0,{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
539
+ `),r=t!==-1&&(n===-1||t<=n)?`\r
540
+ `:`
541
+ `,o=e.split(r),s;return e.endsWith(r)?(o.length>0&&o[o.length-1]===""&&o.pop(),s="lf"):s="no-eol",{lines:o,eol:r,eofStyle:s}}function BS(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map(l=>({op:"add",line:l}));if(r===0)return e.map(l=>({op:"remove",line:l}));let o=[],s=n+r,i=new Array(2*s+2).fill(-1),a=s;i[a+1]=0;for(let l=0;l<=s;l++){let c=new Map,u=-l,d=l;for(let m=u;m<=d;m+=2){let h=m+a,f;m===-l||m!==l&&i[h-1]<i[h+1]?f=i[h+1]:f=i[h-1]+1;let g=f-m;for(;f<n&&g<r&&e[f]===t[g];)f++,g++;if(i[h]=f,c.set(m,f),f>=n&&g>=r)return o.push(c),FS(o,n,r,e,t,a)}o.push(c)}return e.map(l=>({op:"remove",line:l})).concat(t.map(l=>({op:"add",line:l})))}function FS(e,t,n,r,o,s){let i=[],a=t,l=n;for(let c=e.length-1;c>=1;c--){let u=a-l,d=e[c-1],m=d.get(u-1),h=d.get(u+1),f;u===-c?f=u+1:u===c?f=u-1:(m??-1)<(h??-1)?f=u+1:f=u-1;let g=d.get(f)??0,k=g-f;if(f===u-1){for(;a>g+1&&l>k;)a--,l--,i.unshift({op:"equal",line:r[a]});a>g&&(a--,i.unshift({op:"remove",line:r[a]}))}else{for(;a>g&&l>k+1;)a--,l--,i.unshift({op:"equal",line:r[a]});l>k&&(l--,i.unshift({op:"add",line:o[l]}))}}for(;a>0&&l>0;)a--,l--,i.unshift({op:"equal",line:r[a]});return i}var Bc=3;function GS(e){if(e.length===0)return[];let t=[];for(let o=0;o<e.length;o++)e[o].op!=="equal"&&t.push(o);if(t.length===0)return[];let n=[[t[0]]];for(let o=1;o<t.length;o++){let s=n[n.length-1],i=s[s.length-1],a=t[o],l=0;for(let c=i+1;c<a;c++)e[c].op==="equal"&&l++;l<=2*Bc?s.push(a):n.push([a])}let r=[];for(let o of n){let s=o[0],i=o[o.length-1],a=Math.max(0,s-Bc),l=Math.min(e.length-1,i+Bc),c=e.slice(a,l+1),u=0,d=0;for(let f=0;f<a;f++){let g=e[f];(g.op==="equal"||g.op==="remove")&&u++,(g.op==="equal"||g.op==="add")&&d++}let m=0,h=0;for(let f of c)(f.op==="equal"||f.op==="remove")&&m++,(f.op==="equal"||f.op==="add")&&h++;r.push({oldStart:u+1,oldCount:m,newStart:d+1,newCount:h,lines:c})}return r}function jS(e,t){if(e.length===0)return"";let n=[],r=Fc(t);n.push(`--- a/${r}`),n.push(`+++ b/${r}`);for(let o of e){n.push(`@@ -${String(o.oldStart)},${String(o.oldCount)} +${String(o.newStart)},${String(o.newCount)} @@`);for(let s of o.lines)switch(s.op){case"equal":n.push(` ${s.line}`);break;case"remove":n.push(`-${s.line}`);break;case"add":n.push(`+${s.line}`);break}}return n.join(`
542
+ `)}function US(e,t){let n=Fc(t),r=[];r.push("--- /dev/null"),r.push(`+++ b/${n}`),r.push(`@@ -0,0 +1,${String(e.length)} @@`);for(let o of e)r.push(`+${o}`);return r.join(`
543
+ `)}function WS(e,t){let n=Fc(t),r=[];r.push(`--- a/${n}`),r.push("+++ /dev/null"),r.push(`@@ -1,${String(e.length)} +0,0 @@`);for(let o of e)r.push(`-${o}`);return r.join(`
544
+ `)}function Fc(e){return e.replace(/\\/g,"/").split("/").pop()??e}function zt(e,t,n){if(e===t)return{filePath:n,patch:"",existedBefore:e.length>0,additions:0,deletions:0};if(e.length===0){let u=Ci(t),d=US(u.lines,n);return{filePath:n,patch:d,existedBefore:!1,additions:u.lines.length,deletions:0}}if(t.length===0){let u=Ci(e),d=WS(u.lines,n);return{filePath:n,patch:d,existedBefore:!0,additions:0,deletions:u.lines.length}}let r=Ci(e),o=Ci(t),s=BS(r.lines,o.lines),i=0,a=0;for(let u of s)u.op==="add"&&i++,u.op==="remove"&&a++;let l=GS(s),c=jS(l,n);return{filePath:n,patch:c,existedBefore:!0,additions:i,deletions:a}}var Gc={name:"write_file",kind:"edit",description:"\u521B\u5EFA\u6216\u8986\u76D6\u6587\u4EF6\u3002\u5982\u679C\u7236\u76EE\u5F55\u4E0D\u5B58\u5728\u4F1A\u81EA\u52A8\u521B\u5EFA\u3002\u9002\u7528\u4E8E\u521B\u5EFA\u65B0\u6587\u4EF6\u6216\u5B8C\u5168\u66FF\u6362\u6587\u4EF6\u5185\u5BB9\u3002\u8BF7\u52FF\u7528\u6B64\u5DE5\u5177\u521B\u5EFA _temp_\u3001_debug_ \u7B49\u7528\u4E8E\u8BCA\u65AD/\u8C03\u8BD5\u7684\u4E34\u65F6\u6587\u4EF6\u2014\u2014\u5982\u9700\u8BCA\u65AD\u8BF7\u6539\u7528 bash \u5DE5\u5177\u5185\u8054\u811A\u672C\uFF08node -e\uFF09\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},content:{type:"string",description:"\u8981\u5199\u5165\u7684\u6587\u4EF6\u5185\u5BB9"}},required:["path","content"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(e.content===void 0||e.content===null)return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 content",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);try{if(t.writeRoots&&t.writeRoots.length>0){let h=await Vt(t.writeRoots,n);if(!h.ok)return{success:!1,data:h.error,error:"OUTSIDE_WRITE_ROOTS"}}let r="",o=!1;try{r=await VS(n,"utf-8"),o=!0}catch{}await HS(zS(n),{recursive:!0});let s=e.content;await Nc(n,r,s);let i=zt(r,s,n);i.existedBefore=o;let a=s.split(`
545
+ `).length,l=Buffer.byteLength(s,"utf-8"),c=o?"\u5DF2\u4FEE\u6539":"\u5DF2\u521B\u5EFA",u=o?`\uFF0C+${i.additions} -${i.deletions}`:`\uFF0C+${i.additions} \u884C\uFF08\u65B0\u5EFA\uFF09`,d=KS(n),m=o?`\u{1F4DD} \u4FEE\u6539: ${d} (+${i.additions} -${i.deletions})`:`\u{1F4DD} \u65B0\u5EFA: ${d} (+${i.additions} \u884C)`;return{success:!0,data:`\u6587\u4EF6${c}\uFF1A${qS(t.cwd,n).replace(/\\/g,"/")}\uFF08${a} \u884C\uFF0C${l} \u5B57\u8282${u}\uFF09`,summary:m,diff:i}}catch(r){return{success:!1,data:`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"WRITE_ERROR"}}}};p();import{readFile as XS,writeFile as JS}from"fs/promises";import{basename as ZS}from"path";var jc={name:"edit_file",kind:"edit",description:"\u5BF9\u6587\u4EF6\u8FDB\u884C\u7CBE\u786E\u5B57\u7B26\u4E32\u66FF\u6362\u3002\u67E5\u627E\u6587\u4EF6\u4E2D\u7684 old_text \u5E76\u66FF\u6362\u4E3A new_text\u3002\u5982\u679C old_text \u51FA\u73B0\u591A\u6B21\u6216\u672A\u627E\u5230\u5219\u62A5\u9519\u3002\u9002\u7528\u4E8E\u5C0F\u8303\u56F4\u7CBE\u786E\u4FEE\u6539\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},old_text:{type:"string",description:"\u8981\u67E5\u627E\u7684\u539F\u59CB\u6587\u672C\uFF08\u7CBE\u786E\u5339\u914D\uFF09"},new_text:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"}},required:["path","old_text","new_text"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(typeof e.old_text!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 old_text",error:"INVALID_ARGS"};if(typeof e.new_text!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 new_text",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await Vt(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await XS(n,"utf-8"),o=We(r),s=We(e.old_text),i=We(e.new_text),a=o.indexOf(s);if(a===-1)return{success:!1,data:"\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\u3002\u8BF7\u786E\u8BA4 old_text \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF08\u5305\u62EC\u7F29\u8FDB\u548C\u7A7A\u683C\uFF09\u3002",error:"TEXT_NOT_FOUND"};if(o.indexOf(s,a+1)!==-1)return{success:!1,data:"\u8981\u66FF\u6362\u7684\u6587\u672C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\uFF0C\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4EE5\u7CBE\u786E\u5B9A\u4F4D\u3002",error:"TEXT_MULTIPLE_MATCHES"};let c=o.slice(0,a)+i+o.slice(a+s.length),u=pn(r,c);await JS(n,u,"utf-8");let d=zt(r,u,n);d.existedBefore=!0;let h=o.slice(0,a).split(`
546
+ `).length,f=s.split(`
547
+ `).length,g=i.split(`
548
+ `).length,k=`+${d.additions} -${d.deletions}`,b=`\u{1F4DD} \u4FEE\u6539: ${ZS(n)} (+${d.additions} -${d.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
549
+ \u66FF\u6362\u4F4D\u7F6E\uFF1A\u7B2C ${h} \u884C
550
+ ${f} \u884C \u2192 ${g} \u884C
551
+ \u53D8\u66F4\uFF1A${k}`,summary:b,diff:d}}catch(r){return{success:!1,data:`\u7F16\u8F91\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EDIT_ERROR"}}}};p();import{readFile as YS,writeFile as QS}from"fs/promises";import{basename as eT}from"path";var Uc={name:"multi_edit",kind:"edit",description:"\u5BF9\u6587\u4EF6\u8FDB\u884C\u539F\u5B50\u6279\u91CF\u66FF\u6362\u7F16\u8F91\u3002\u5728\u4E00\u4E2A\u8BF7\u6C42\u4E2D\u6267\u884C\u591A\u4E2A\u7CBE\u786E\u66FF\u6362\uFF0C\u4EFB\u4E00\u5931\u8D25\u5219\u5168\u90E8\u56DE\u6EDA\u3002\u652F\u6301 replaceAll \u53C2\u6570\u505A\u5168\u5C40\u66FF\u6362\u3002\u9002\u7528\u4E8E\u9700\u8981\u540C\u65F6\u4FEE\u6539\u6587\u4EF6\u591A\u5904\u7684\u573A\u666F\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},edits:{type:"array",description:"\u6709\u5E8F\u7684\u7F16\u8F91\u6B65\u9AA4\u5217\u8868\u3002\u6BCF\u4E2A\u6B65\u9AA4\u5305\u542B oldText\uFF08\u7CBE\u786E\u5339\u914D\uFF09\u3001newText\uFF08\u66FF\u6362\u5185\u5BB9\uFF09\u548C\u53EF\u9009\u7684 replaceAll\uFF08\u662F\u5426\u66FF\u6362\u6240\u6709\u5339\u914D\u9879\uFF09",items:{type:"object",properties:{oldText:{type:"string",description:"\u8981\u67E5\u627E\u7684\u539F\u59CB\u6587\u672C\uFF08\u7CBE\u786E\u5339\u914D\uFF09"},newText:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"},replaceAll:{type:"boolean",description:"\u662F\u5426\u66FF\u6362\u6240\u6709\u5339\u914D\u9879\uFF0C\u9ED8\u8BA4 false"}},required:["oldText","newText"],additionalProperties:!1}}},required:["path","edits"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(!Array.isArray(e.edits)||e.edits.length===0)return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 edits\uFF08\u975E\u7A7A\u6570\u7EC4\uFF09",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await Vt(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await YS(n,"utf-8"),o=We(r);for(let a=0;a<e.edits.length;a++){let l=e.edits[a];if(typeof l.oldText!="string")return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u7F3A\u5C11\u6709\u6548\u7684 oldText`,error:"INVALID_STEP_ARGS"};if(typeof l.newText!="string")return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u7F3A\u5C11\u6709\u6548\u7684 newText`,error:"INVALID_STEP_ARGS"};let c=We(l.oldText),u=We(l.newText);if(l.replaceAll){if(!o.includes(c))return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\uFF0C\u8BF7\u786E\u8BA4 oldText \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4`,error:"TEXT_NOT_FOUND"};o=o.split(c).join(u)}else{let d=o.indexOf(c);if(d===-1)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\u3002\u8BF7\u786E\u8BA4 oldText \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF08\u5305\u62EC\u7F29\u8FDB\u548C\u7A7A\u683C\uFF09\u3002`,error:"TEXT_NOT_FOUND"};if(o.indexOf(c,d+1)!==-1)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u8981\u66FF\u6362\u7684\u6587\u672C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\uFF0C\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4EE5\u7CBE\u786E\u5B9A\u4F4D\uFF0C\u6216\u8BBE\u7F6E replaceAll=true`,error:"TEXT_MULTIPLE_MATCHES"};o=o.slice(0,d)+u+o.slice(d+c.length)}}let s=pn(r,o);await QS(n,s,"utf-8");let i=zt(r,s,n);return i.existedBefore=!0,{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
548
552
  \u5171\u6267\u884C ${e.edits.length} \u6B65\u66FF\u6362
549
- \u53D8\u66F4\uFF1A+${i.additions} -${i.deletions}`,summary:`\u{1F4DD} \u4FEE\u6539: ${BS(n)} (${e.edits.length} \u6B65, +${i.additions} -${i.deletions})`,diff:i}}catch(r){return{success:!1,data:`\u6279\u91CF\u7F16\u8F91\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"MULTI_EDIT_ERROR"}}}};p();import{readFile as FS}from"fs/promises";import{writeFile as GS}from"fs/promises";import{basename as jS}from"path";function Qm(e,t,n){let r=Ge(t),o=[];for(let s=0;s<e.length;s++)Ge(e[s])===r&&o.push(s);return o.length===0?{error:`\u672A\u627E\u5230 "${n}" \u951A\u70B9\u884C\uFF0C\u8BF7\u786E\u8BA4\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4`}:o.length>1?{error:`"${n}" \u951A\u70B9\u884C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0 ${o.length} \u6B21\uFF0C\u8BF7\u4F7F\u7528\u66F4\u552F\u4E00\u7684\u884C\u5185\u5BB9`}:{line:o[0]}}var Bc={name:"delete_range",kind:"edit",description:"\u5220\u9664\u6587\u4EF6\u4E2D\u4E24\u4E2A\u951A\u70B9\u884C\u4E4B\u95F4\u7684\u5185\u5BB9\u3002\u901A\u8FC7\u4E24\u4E2A\u552F\u4E00\u7684\u884C\u5185\u5BB9\u7CBE\u786E\u5B9A\u4F4D\u8303\u56F4\u3002\u9002\u7528\u4E8E\u5220\u9664\u65B9\u6CD5\u3001\u4EE3\u7801\u5757\u3001\u914D\u7F6E\u6BB5\u7B49\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},startAnchor:{type:"string",description:"\u5220\u9664\u8303\u56F4\u7684\u8D77\u59CB\u6807\u8BB0\u884C\u5185\u5BB9\uFF08\u5FC5\u987B\u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u7CBE\u786E\u5339\u914D\u6574\u884C\uFF09"},endAnchor:{type:"string",description:"\u5220\u9664\u8303\u56F4\u7684\u7ED3\u675F\u6807\u8BB0\u884C\u5185\u5BB9\uFF08\u5FC5\u987B\u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u7CBE\u786E\u5339\u914D\u6574\u884C\uFF0C\u987B\u5728 start_anchor \u4E4B\u540E\uFF09"},inclusive:{type:"boolean",description:"\u662F\u5426\u5305\u542B\u951A\u70B9\u884C\u672C\u8EAB\uFF0C\u9ED8\u8BA4 false\uFF08\u53EA\u5220\u9664\u4E24\u884C\u4E4B\u95F4\u7684\u5185\u5BB9\uFF09"}},required:["path","startAnchor","endAnchor"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(typeof e.startAnchor!="string")return{success:!1,data:"\u7F3A\u5C11\u6709\u6548\u53C2\u6570 startAnchor",error:"INVALID_ARGS"};if(typeof e.endAnchor!="string")return{success:!1,data:"\u7F3A\u5C11\u6709\u6548\u53C2\u6570 endAnchor",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd),r=e.inclusive??!1;if(t.writeRoots&&t.writeRoots.length>0){let o=await Vt(t.writeRoots,n);if(!o.ok)return{success:!1,data:o.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let o=await FS(n,"utf-8"),s=Ge(o).split(`
550
- `),i=Qm(s,e.startAnchor,"start_anchor");if("error"in i)return{success:!1,data:i.error,error:"ANCHOR_NOT_FOUND"};let a=Qm(s,e.endAnchor,"end_anchor");if("error"in a)return{success:!1,data:a.error,error:"ANCHOR_NOT_FOUND"};let l=i.line,c=a.line;if(l>=c)return{success:!1,data:"end_anchor \u5FC5\u987B\u5728 start_anchor \u4E4B\u540E",error:"ANCHOR_ORDER_ERROR"};let u=r?l:l+1,d=r?c:c-1;if(u>d)return{success:!1,data:"\u5220\u9664\u8303\u56F4\u4E3A\u7A7A\uFF08\u4E24\u884C\u951A\u70B9\u76F8\u90BB\u4E14 inclusive=false\uFF09",error:"EMPTY_RANGE"};let h=[...s.slice(0,u),...s.slice(d+1)].join(`
551
- `),f=pn(o,h);await GS(n,f,"utf-8");let g=zt(o,f,n);g.existedBefore=!0;let b=d-u+1,w=`\u{1F4DD} \u4FEE\u6539: ${jS(n)} (\u5220 ${b} \u884C, +${g.additions} -${g.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
552
- \u5220\u9664\u884C\u8303\u56F4\uFF1A\u7B2C ${u+1} \u884C ~ \u7B2C ${d+1} \u884C\uFF08\u5171 ${b} \u884C\uFF09
553
- \u53D8\u66F4\uFF1A+${g.additions} -${g.deletions}`,summary:w,diff:g}}catch(o){return{success:!1,data:`\u5220\u9664\u8303\u56F4\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"DELETE_RANGE_ERROR"}}}};p();import wr from"process";import{existsSync as eh}from"fs";import{join as th}from"path";var US=wr.platform==="win32";function WS(){if(!US)return{bin:"sh",args:["-c"],label:"sh",hint:"\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002"};let e=wr.env.DSKCODE_BASH;if(e&&eh(e))return{bin:e,args:["-c"],label:"Git Bash",hint:nh};let t=[wr.env.ProgramFiles,wr.env["ProgramFiles(x86)"],wr.env.LOCALAPPDATA?th(wr.env.LOCALAPPDATA,"Programs"):null,"D:\\Program Files","E:\\Program Files"].filter(n=>!!n);for(let n of t)for(let r of["Git\\bin\\bash.exe","Git\\usr\\bin\\bash.exe"]){let o=th(n,r);if(eh(o))return{bin:o,args:["-c"],label:"Git Bash",hint:nh}}return{bin:"cmd",args:["/c"],label:"cmd.exe",hint:"\u5F53\u524D shell \u662F Windows cmd.exe\u3002\u8BF7\u4F7F\u7528 cmd \u8BED\u6CD5\uFF1A\u8DEF\u5F84\u7528\u53CD\u659C\u6760\u6216\u6B63\u659C\u6760\u5747\u53EF\u3001\u547D\u4EE4\u94FE\u7528 & \u6216\u6362\u884C\uFF0C\u907F\u514D\u4F7F\u7528 pwd/ls/&& \u7B49 Unix \u547D\u4EE4\u3002"}}var nh="\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002",Co=WS();var Fc={name:"bash",kind:"other",description:["\u5728 shell \u4E2D\u6267\u884C\u547D\u4EE4\uFF0C\u8FD4\u56DE stdout / stderr / \u9000\u51FA\u7801\u3002\u652F\u6301\u8D85\u65F6\u63A7\u5236\u548C\u4FE1\u53F7\u4E2D\u6B62\u3002",`\u5F53\u524D shell\uFF1A${Co.label}\u3002${Co.hint}`,"\u8BFB\u53D6\u6587\u4EF6\u8BF7\u4F18\u5148\u4F7F\u7528 read_file \u5DE5\u5177\uFF0C\u4E0D\u8981\u7528 cat/type/Get-Content\uFF1B","\u641C\u7D22\u4EE3\u7801\u7528 grep / glob\uFF0C\u5217\u76EE\u5F55\u7528 ls\u2014\u2014\u8FD9\u4E9B\u4E13\u7528\u5DE5\u5177\u5728\u6240\u6709\u5E73\u53F0\u90FD\u53EF\u7528\u4E14\u65E0\u9700\u5173\u5FC3 shell \u8BED\u6CD5\u3002"].join(""),parameters:{type:"object",properties:{command:{type:"string",description:`\u8981\u6267\u884C\u7684 shell \u547D\u4EE4\uFF08\u5F53\u524D shell\uFF1A${Co.label}\uFF09`},timeout:{type:"number",description:"\u6267\u884C\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 30000"}},required:["command"],additionalProperties:!1},async execute(e,t){if(!e?.command||typeof e.command!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 command",error:"INVALID_ARGS"};let n=e.timeout??t.timeout??Ec();try{let r=Co.bin??"cmd",o=[...Co.args,e.command],s=await Ic(r,o,t.cwd,n,t.signal,!0),i=[];s.stdout&&i.push(We(s.stdout)),s.stderr&&i.push(`[stderr]
554
- ${We(s.stderr)}`);let a=s.exitCode===0,l=i.length>0?i.join(`
553
+ \u53D8\u66F4\uFF1A+${i.additions} -${i.deletions}`,summary:`\u{1F4DD} \u4FEE\u6539: ${eT(n)} (${e.edits.length} \u6B65, +${i.additions} -${i.deletions})`,diff:i}}catch(r){return{success:!1,data:`\u6279\u91CF\u7F16\u8F91\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"MULTI_EDIT_ERROR"}}}};p();import{readFile as tT}from"fs/promises";import{writeFile as nT}from"fs/promises";import{basename as rT}from"path";function ih(e,t,n){let r=We(t),o=[];for(let s=0;s<e.length;s++)We(e[s])===r&&o.push(s);return o.length===0?{error:`\u672A\u627E\u5230 "${n}" \u951A\u70B9\u884C\uFF0C\u8BF7\u786E\u8BA4\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4`}:o.length>1?{error:`"${n}" \u951A\u70B9\u884C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0 ${o.length} \u6B21\uFF0C\u8BF7\u4F7F\u7528\u66F4\u552F\u4E00\u7684\u884C\u5185\u5BB9`}:{line:o[0]}}var Wc={name:"delete_range",kind:"edit",description:"\u5220\u9664\u6587\u4EF6\u4E2D\u4E24\u4E2A\u951A\u70B9\u884C\u4E4B\u95F4\u7684\u5185\u5BB9\u3002\u901A\u8FC7\u4E24\u4E2A\u552F\u4E00\u7684\u884C\u5185\u5BB9\u7CBE\u786E\u5B9A\u4F4D\u8303\u56F4\u3002\u9002\u7528\u4E8E\u5220\u9664\u65B9\u6CD5\u3001\u4EE3\u7801\u5757\u3001\u914D\u7F6E\u6BB5\u7B49\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},startAnchor:{type:"string",description:"\u5220\u9664\u8303\u56F4\u7684\u8D77\u59CB\u6807\u8BB0\u884C\u5185\u5BB9\uFF08\u5FC5\u987B\u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u7CBE\u786E\u5339\u914D\u6574\u884C\uFF09"},endAnchor:{type:"string",description:"\u5220\u9664\u8303\u56F4\u7684\u7ED3\u675F\u6807\u8BB0\u884C\u5185\u5BB9\uFF08\u5FC5\u987B\u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u7CBE\u786E\u5339\u914D\u6574\u884C\uFF0C\u987B\u5728 start_anchor \u4E4B\u540E\uFF09"},inclusive:{type:"boolean",description:"\u662F\u5426\u5305\u542B\u951A\u70B9\u884C\u672C\u8EAB\uFF0C\u9ED8\u8BA4 false\uFF08\u53EA\u5220\u9664\u4E24\u884C\u4E4B\u95F4\u7684\u5185\u5BB9\uFF09"}},required:["path","startAnchor","endAnchor"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(typeof e.startAnchor!="string")return{success:!1,data:"\u7F3A\u5C11\u6709\u6548\u53C2\u6570 startAnchor",error:"INVALID_ARGS"};if(typeof e.endAnchor!="string")return{success:!1,data:"\u7F3A\u5C11\u6709\u6548\u53C2\u6570 endAnchor",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd),r=e.inclusive??!1;if(t.writeRoots&&t.writeRoots.length>0){let o=await Vt(t.writeRoots,n);if(!o.ok)return{success:!1,data:o.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let o=await tT(n,"utf-8"),s=We(o).split(`
554
+ `),i=ih(s,e.startAnchor,"start_anchor");if("error"in i)return{success:!1,data:i.error,error:"ANCHOR_NOT_FOUND"};let a=ih(s,e.endAnchor,"end_anchor");if("error"in a)return{success:!1,data:a.error,error:"ANCHOR_NOT_FOUND"};let l=i.line,c=a.line;if(l>=c)return{success:!1,data:"end_anchor \u5FC5\u987B\u5728 start_anchor \u4E4B\u540E",error:"ANCHOR_ORDER_ERROR"};let u=r?l:l+1,d=r?c:c-1;if(u>d)return{success:!1,data:"\u5220\u9664\u8303\u56F4\u4E3A\u7A7A\uFF08\u4E24\u884C\u951A\u70B9\u76F8\u90BB\u4E14 inclusive=false\uFF09",error:"EMPTY_RANGE"};let h=[...s.slice(0,u),...s.slice(d+1)].join(`
555
+ `),f=pn(o,h);await nT(n,f,"utf-8");let g=zt(o,f,n);g.existedBefore=!0;let k=d-u+1,b=`\u{1F4DD} \u4FEE\u6539: ${rT(n)} (\u5220 ${k} \u884C, +${g.additions} -${g.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
556
+ \u5220\u9664\u884C\u8303\u56F4\uFF1A\u7B2C ${u+1} \u884C ~ \u7B2C ${d+1} \u884C\uFF08\u5171 ${k} \u884C\uFF09
557
+ \u53D8\u66F4\uFF1A+${g.additions} -${g.deletions}`,summary:b,diff:g}}catch(o){return{success:!1,data:`\u5220\u9664\u8303\u56F4\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"DELETE_RANGE_ERROR"}}}};p();import yr from"process";import{existsSync as ah}from"fs";import{join as lh}from"path";var oT=yr.platform==="win32";function sT(){if(!oT)return{bin:"sh",args:["-c"],label:"sh",hint:"\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002"};let e=yr.env.DSKCODE_BASH;if(e&&ah(e))return{bin:e,args:["-c"],label:"Git Bash",hint:ch};let t=[yr.env.ProgramFiles,yr.env["ProgramFiles(x86)"],yr.env.LOCALAPPDATA?lh(yr.env.LOCALAPPDATA,"Programs"):null,"D:\\Program Files","E:\\Program Files"].filter(n=>!!n);for(let n of t)for(let r of["Git\\bin\\bash.exe","Git\\usr\\bin\\bash.exe"]){let o=lh(n,r);if(ah(o))return{bin:o,args:["-c"],label:"Git Bash",hint:ch}}return{bin:"cmd",args:["/c"],label:"cmd.exe",hint:"\u5F53\u524D shell \u662F Windows cmd.exe\u3002\u8BF7\u4F7F\u7528 cmd \u8BED\u6CD5\uFF1A\u8DEF\u5F84\u7528\u53CD\u659C\u6760\u6216\u6B63\u659C\u6760\u5747\u53EF\u3001\u547D\u4EE4\u94FE\u7528 & \u6216\u6362\u884C\uFF0C\u907F\u514D\u4F7F\u7528 pwd/ls/&& \u7B49 Unix \u547D\u4EE4\u3002"}}var ch="\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002",Ro=sT();var Hc={name:"bash",kind:"other",description:["\u5728 shell \u4E2D\u6267\u884C\u547D\u4EE4\uFF0C\u8FD4\u56DE stdout / stderr / \u9000\u51FA\u7801\u3002\u652F\u6301\u8D85\u65F6\u63A7\u5236\u548C\u4FE1\u53F7\u4E2D\u6B62\u3002",`\u5F53\u524D shell\uFF1A${Ro.label}\u3002${Ro.hint}`,"\u8BFB\u53D6\u6587\u4EF6\u8BF7\u4F18\u5148\u4F7F\u7528 read_file \u5DE5\u5177\uFF0C\u4E0D\u8981\u7528 cat/type/Get-Content\uFF1B","\u641C\u7D22\u4EE3\u7801\u7528 grep / glob\uFF0C\u5217\u76EE\u5F55\u7528 ls\u2014\u2014\u8FD9\u4E9B\u4E13\u7528\u5DE5\u5177\u5728\u6240\u6709\u5E73\u53F0\u90FD\u53EF\u7528\u4E14\u65E0\u9700\u5173\u5FC3 shell \u8BED\u6CD5\u3002"].join(""),parameters:{type:"object",properties:{command:{type:"string",description:`\u8981\u6267\u884C\u7684 shell \u547D\u4EE4\uFF08\u5F53\u524D shell\uFF1A${Ro.label}\uFF09`},timeout:{type:"number",description:"\u6267\u884C\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 30000"}},required:["command"],additionalProperties:!1},async execute(e,t){if(!e?.command||typeof e.command!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 command",error:"INVALID_ARGS"};let n=e.timeout??t.timeout??Oc();try{let r=Ro.bin??"cmd",o=[...Ro.args,e.command],s=await Dc(r,o,t.cwd,n,t.signal,!0),i=[];s.stdout&&i.push(Ue(s.stdout)),s.stderr&&i.push(`[stderr]
558
+ ${Ue(s.stderr)}`);let a=s.exitCode===0,l=i.length>0?i.join(`
555
559
  `):"(\u65E0\u8F93\u51FA)",u=`\u{1F527} $ ${e.command.length>60?e.command.slice(0,57)+"...":e.command}\uFF08exit ${s.exitCode??"\u672A\u77E5"}\uFF09`;return{success:a,data:`${l}
556
- [\u9000\u51FA\u7801: ${s.exitCode??"\u672A\u77E5"}]`,summary:u,error:a?void 0:`EXIT_CODE_${s.exitCode??"UNKNOWN"}`}}catch(r){return{success:!1,data:`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EXECUTION_ERROR"}}}};p();import{readdir as HS,stat as VS}from"fs/promises";import{join as rh,relative as zS,isAbsolute as qS}from"path";function KS(e){let t=e;return t=t.replace(/\*\*\//g,"<<GLOBSTAR_SLASH>>"),t=t.replace(/\*\*/g,"<<GLOBSTAR>>"),t=t.replace(/\?/g,"<<QUESTION>>"),t=t.replace(/[.+^${}()|[\]\\]/g,"\\$&"),t=t.replace(/\*/g,"[^/]*"),t=t.replace(/<<GLOBSTAR_SLASH>>/g,"(.*/)?"),t=t.replace(/<<GLOBSTAR>>/g,".*"),t=t.replace(/<<QUESTION>>/g,"[^/]"),new RegExp(`^${t}$`,"i")}async function oh(e,t){let n=[],r;try{r=await HS(e,{withFileTypes:!0})}catch{return n}for(let o of r){if(o.isDirectory()&&(o.name==="node_modules"||o.name===".git"))continue;let s=rh(e,o.name),i=zS(t,s);o.isDirectory()?n.push(...await oh(s,t)):n.push(i)}return n}var Gc={name:"glob",kind:"read",description:"\u6309\u6A21\u5F0F\u641C\u7D22\u6587\u4EF6\u8DEF\u5F84\u3002\u652F\u6301 *\uFF08\u5339\u914D\u6587\u4EF6\u540D\u90E8\u5206\uFF09\u548C **\uFF08\u5339\u914D\u591A\u5C42\u76EE\u5F55\uFF09\u901A\u914D\u7B26\u3002\u81EA\u52A8\u8DF3\u8FC7 node_modules \u548C .git \u76EE\u5F55\u3002",parameters:{type:"object",properties:{pattern:{type:"string",description:"\u641C\u7D22\u6A21\u5F0F\uFF08\u652F\u6301 * \u548C ** \u901A\u914D\u7B26\uFF0C\u5982 **/*.ts\u3001src/**/*.test.ts\uFF09"},directory:{type:"string",description:"\u641C\u7D22\u7684\u8D77\u59CB\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"}},required:["pattern"],additionalProperties:!1},async execute(e,t){if(!e?.pattern||typeof e.pattern!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 pattern",error:"INVALID_ARGS"};let n=e.directory?br(e.directory):void 0,r=n?qS(n)?n:rh(t.cwd,n):t.cwd,o=KS(e.pattern);try{if(!(await VS(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let a=(await oh(r,r)).filter(m=>o.test(m));if(a.length===0)return{success:!0,data:`\u672A\u627E\u5230\u5339\u914D "${e.pattern}" \u7684\u6587\u4EF6`,summary:`${e.pattern} \u2192 0 \u4E2A\u6587\u4EF6`};let l=200,u=a.slice(0,l).join(`
560
+ [\u9000\u51FA\u7801: ${s.exitCode??"\u672A\u77E5"}]`,summary:u,error:a?void 0:`EXIT_CODE_${s.exitCode??"UNKNOWN"}`}}catch(r){return{success:!1,data:`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EXECUTION_ERROR"}}}};p();import{readdir as iT,stat as aT}from"fs/promises";import{join as uh,relative as lT,isAbsolute as cT}from"path";function uT(e){let t=e;return t=t.replace(/\*\*\//g,"<<GLOBSTAR_SLASH>>"),t=t.replace(/\*\*/g,"<<GLOBSTAR>>"),t=t.replace(/\?/g,"<<QUESTION>>"),t=t.replace(/[.+^${}()|[\]\\]/g,"\\$&"),t=t.replace(/\*/g,"[^/]*"),t=t.replace(/<<GLOBSTAR_SLASH>>/g,"(.*/)?"),t=t.replace(/<<GLOBSTAR>>/g,".*"),t=t.replace(/<<QUESTION>>/g,"[^/]"),new RegExp(`^${t}$`,"i")}async function dh(e,t){let n=[],r;try{r=await iT(e,{withFileTypes:!0})}catch{return n}for(let o of r){if(o.isDirectory()&&(o.name==="node_modules"||o.name===".git"))continue;let s=uh(e,o.name),i=lT(t,s);o.isDirectory()?n.push(...await dh(s,t)):n.push(i)}return n}var Vc={name:"glob",kind:"read",description:"\u6309\u6A21\u5F0F\u641C\u7D22\u6587\u4EF6\u8DEF\u5F84\u3002\u652F\u6301 *\uFF08\u5339\u914D\u6587\u4EF6\u540D\u90E8\u5206\uFF09\u548C **\uFF08\u5339\u914D\u591A\u5C42\u76EE\u5F55\uFF09\u901A\u914D\u7B26\u3002\u81EA\u52A8\u8DF3\u8FC7 node_modules \u548C .git \u76EE\u5F55\u3002",parameters:{type:"object",properties:{pattern:{type:"string",description:"\u641C\u7D22\u6A21\u5F0F\uFF08\u652F\u6301 * \u548C ** \u901A\u914D\u7B26\uFF0C\u5982 **/*.ts\u3001src/**/*.test.ts\uFF09"},directory:{type:"string",description:"\u641C\u7D22\u7684\u8D77\u59CB\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"}},required:["pattern"],additionalProperties:!1},async execute(e,t){if(!e?.pattern||typeof e.pattern!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 pattern",error:"INVALID_ARGS"};let n=e.directory?gr(e.directory):void 0,r=n?cT(n)?n:uh(t.cwd,n):t.cwd,o=uT(e.pattern);try{if(!(await aT(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let a=(await dh(r,r)).filter(m=>o.test(m));if(a.length===0)return{success:!0,data:`\u672A\u627E\u5230\u5339\u914D "${e.pattern}" \u7684\u6587\u4EF6`,summary:`${e.pattern} \u2192 0 \u4E2A\u6587\u4EF6`};let l=200,u=a.slice(0,l).join(`
557
561
  `),d=a.length>l?`
558
562
 
559
- ... \u5171 ${a.length} \u4E2A\u6587\u4EF6\uFF0C\u53EA\u663E\u793A\u524D ${l} \u4E2A`:"";return{success:!0,data:We(u+d),summary:`${e.pattern} \u2192 ${a.length} \u4E2A\u6587\u4EF6`}}catch(s){return{success:!1,data:`\u6587\u4EF6\u641C\u7D22\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"GLOB_ERROR"}}}};p();import{readdir as XS,readFile as JS,stat as ZS}from"fs/promises";import{join as sh,relative as YS,isAbsolute as QS}from"path";async function ih(e,t,n=200){let r=[],o;try{o=await XS(e,{withFileTypes:!0})}catch{return r}for(let s of o){if(r.length>=n)break;if(s.isDirectory()&&(s.name==="node_modules"||s.name===".git"||s.name==="dist"))continue;let i=sh(e,s.name);if(s.isDirectory())r.push(...await ih(i,t,n-r.length));else{if(t&&!s.name.endsWith(`.${t}`))continue;r.push(i)}}return r}var jc={name:"grep",kind:"read",description:"\u5728\u6587\u4EF6\u5185\u5BB9\u4E2D\u641C\u7D22\u6B63\u5219\u8868\u8FBE\u5F0F\u3002\u8FD4\u56DE\u5339\u914D\u884C\u7684\u6587\u4EF6\u8DEF\u5F84\u3001\u884C\u53F7\u548C\u5185\u5BB9\u3002\u652F\u6301\u5927\u5C0F\u5199\u654F\u611F\u3001\u6587\u4EF6\u6269\u5C55\u540D\u8FC7\u6EE4\u3002",parameters:{type:"object",properties:{pattern:{type:"string",description:"\u6B63\u5219\u8868\u8FBE\u5F0F\u641C\u7D22\u6A21\u5F0F"},directory:{type:"string",description:"\u641C\u7D22\u7684\u76EE\u5F55\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"},include:{type:"string",description:"\u6587\u4EF6\u6269\u5C55\u540D\u8FC7\u6EE4\uFF08\u5982 ts\u3001json\uFF09\uFF0C\u4E0D\u542B\u70B9\u53F7"},case_sensitive:{type:"boolean",description:"\u662F\u5426\u5927\u5C0F\u5199\u654F\u611F\uFF0C\u9ED8\u8BA4 false"},max_files:{type:"number",description:"\u6700\u5927\u641C\u7D22\u6587\u4EF6\u6570\uFF0C\u9ED8\u8BA4 200"}},required:["pattern"],additionalProperties:!1},async execute(e,t){if(!e?.pattern||typeof e.pattern!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 pattern",error:"INVALID_ARGS"};let n=e.directory?br(e.directory):void 0,r=n?QS(n)?n:sh(t.cwd,n):t.cwd,o=e.max_files??200;try{let s=e.case_sensitive?"g":"gi",i=new RegExp(e.pattern,s);if(!(await ZS(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let l=await ih(r,e.include,o),c=[];for(let h of l)try{let g=(await JS(h,"utf-8")).split(`
560
- `),b=YS(r,h);for(let w=0;w<g.length&&!(i.test(g[w]??"")&&(i.lastIndex=0,c.push({file:b,line:w+1,content:g[w]}),c.length>=500));w++);if(c.length>=500)break}catch{continue}if(c.length===0)return{success:!0,data:`\u672A\u627E\u5230\u5339\u914D "${e.pattern}" \u7684\u5185\u5BB9`,summary:`\u{1F50D} "${e.pattern}" \u2192 0 \u6761\u547D\u4E2D`};let u=c.map(h=>`${h.file}:${h.line}: ${h.content}`).join(`
561
- `),d=new Set(c.map(h=>h.file)),m=`\u{1F50D} "${e.pattern}" \u2192 ${c.length} \u6761\u547D\u4E2D / ${d.size} \u4E2A\u6587\u4EF6`;return{success:!0,data:We(u),summary:m}}catch(s){return{success:!1,data:`\u5185\u5BB9\u641C\u7D22\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"GREP_ERROR"}}}};p();import{readdir as eT,stat as tT}from"fs/promises";import{join as nT,relative as ah}from"path";var Uc={name:"ls",kind:"read",description:"\u5217\u51FA\u76EE\u5F55\u5185\u5BB9\u3002\u663E\u793A\u6761\u76EE\u7C7B\u578B\uFF08\u6587\u4EF6/\u76EE\u5F55/\u94FE\u63A5\uFF09\u548C\u5927\u5C0F\u3002\u53EF\u9009\u62E9\u662F\u5426\u663E\u793A\u9690\u85CF\u6587\u4EF6\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u76EE\u5F55\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u76EE\u5F55"},all:{type:"boolean",description:"\u662F\u5426\u663E\u793A\u9690\u85CF\u6587\u4EF6\uFF08\u4EE5 . \u5F00\u5934\u7684\u6587\u4EF6\uFF09\uFF0C\u9ED8\u8BA4 false"}},required:[],additionalProperties:!1},async execute(e,t){let n=e.path?Ye(e.path,t.cwd):t.cwd,r=e.all??!1;try{let o=await eT(n,{withFileTypes:!0}),s=[],i=[...o].toSorted((l,c)=>l.isDirectory()!==c.isDirectory()?l.isDirectory()?-1:1:l.name.localeCompare(c.name));for(let l of i){if(!r&&l.name.startsWith("."))continue;let c=l.isDirectory()?"DIR":l.isSymbolicLink()?"LINK":"FILE",u="";if(c==="FILE")try{let m=await tT(nT(n,l.name));m.size<1024?u=`${m.size}B`:m.size<1024*1024?u=`${(m.size/1024).toFixed(1)}KB`:u=`${(m.size/1024/1024).toFixed(1)}MB`}catch{u="?"}let d=c==="DIR"?"\u{1F4C1}":c==="LINK"?"\u{1F517}":"\u{1F4C4}";s.push(`${d} ${l.name}${u?` (${u})`:""}`)}if(s.length===0)return{success:!0,data:"\u76EE\u5F55\u4E3A\u7A7A",summary:`\u{1F4C2} ${ah(t.cwd,n).replace(/\\/g,"/")}\uFF08\u7A7A\uFF09`};let a=ah(t.cwd,n).replace(/\\/g,"/");return{success:!0,data:We(`\u76EE\u5F55\uFF1A${n}
563
+ ... \u5171 ${a.length} \u4E2A\u6587\u4EF6\uFF0C\u53EA\u663E\u793A\u524D ${l} \u4E2A`:"";return{success:!0,data:Ue(u+d),summary:`${e.pattern} \u2192 ${a.length} \u4E2A\u6587\u4EF6`}}catch(s){return{success:!1,data:`\u6587\u4EF6\u641C\u7D22\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"GLOB_ERROR"}}}};p();import{readdir as dT,readFile as pT,stat as fT}from"fs/promises";import{join as ph,relative as mT,isAbsolute as hT}from"path";async function fh(e,t,n=200){let r=[],o;try{o=await dT(e,{withFileTypes:!0})}catch{return r}for(let s of o){if(r.length>=n)break;if(s.isDirectory()&&(s.name==="node_modules"||s.name===".git"||s.name==="dist"))continue;let i=ph(e,s.name);if(s.isDirectory())r.push(...await fh(i,t,n-r.length));else{if(t&&!s.name.endsWith(`.${t}`))continue;r.push(i)}}return r}var zc={name:"grep",kind:"read",description:"\u5728\u6587\u4EF6\u5185\u5BB9\u4E2D\u641C\u7D22\u6B63\u5219\u8868\u8FBE\u5F0F\u3002\u8FD4\u56DE\u5339\u914D\u884C\u7684\u6587\u4EF6\u8DEF\u5F84\u3001\u884C\u53F7\u548C\u5185\u5BB9\u3002\u652F\u6301\u5927\u5C0F\u5199\u654F\u611F\u3001\u6587\u4EF6\u6269\u5C55\u540D\u8FC7\u6EE4\u3002",parameters:{type:"object",properties:{pattern:{type:"string",description:"\u6B63\u5219\u8868\u8FBE\u5F0F\u641C\u7D22\u6A21\u5F0F"},directory:{type:"string",description:"\u641C\u7D22\u7684\u76EE\u5F55\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"},include:{type:"string",description:"\u6587\u4EF6\u6269\u5C55\u540D\u8FC7\u6EE4\uFF08\u5982 ts\u3001json\uFF09\uFF0C\u4E0D\u542B\u70B9\u53F7"},case_sensitive:{type:"boolean",description:"\u662F\u5426\u5927\u5C0F\u5199\u654F\u611F\uFF0C\u9ED8\u8BA4 false"},max_files:{type:"number",description:"\u6700\u5927\u641C\u7D22\u6587\u4EF6\u6570\uFF0C\u9ED8\u8BA4 200"}},required:["pattern"],additionalProperties:!1},async execute(e,t){if(!e?.pattern||typeof e.pattern!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 pattern",error:"INVALID_ARGS"};let n=e.directory?gr(e.directory):void 0,r=n?hT(n)?n:ph(t.cwd,n):t.cwd,o=e.max_files??200;try{let s=e.case_sensitive?"g":"gi",i=new RegExp(e.pattern,s);if(!(await fT(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let l=await fh(r,e.include,o),c=[];for(let h of l)try{let g=(await pT(h,"utf-8")).split(`
564
+ `),k=mT(r,h);for(let b=0;b<g.length&&!(i.test(g[b]??"")&&(i.lastIndex=0,c.push({file:k,line:b+1,content:g[b]}),c.length>=500));b++);if(c.length>=500)break}catch{continue}if(c.length===0)return{success:!0,data:`\u672A\u627E\u5230\u5339\u914D "${e.pattern}" \u7684\u5185\u5BB9`,summary:`\u{1F50D} "${e.pattern}" \u2192 0 \u6761\u547D\u4E2D`};let u=c.map(h=>`${h.file}:${h.line}: ${h.content}`).join(`
565
+ `),d=new Set(c.map(h=>h.file)),m=`\u{1F50D} "${e.pattern}" \u2192 ${c.length} \u6761\u547D\u4E2D / ${d.size} \u4E2A\u6587\u4EF6`;return{success:!0,data:Ue(u),summary:m}}catch(s){return{success:!1,data:`\u5185\u5BB9\u641C\u7D22\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"GREP_ERROR"}}}};p();import{readdir as gT,stat as yT}from"fs/promises";import{join as xT,relative as mh}from"path";var qc={name:"ls",kind:"read",description:"\u5217\u51FA\u76EE\u5F55\u5185\u5BB9\u3002\u663E\u793A\u6761\u76EE\u7C7B\u578B\uFF08\u6587\u4EF6/\u76EE\u5F55/\u94FE\u63A5\uFF09\u548C\u5927\u5C0F\u3002\u53EF\u9009\u62E9\u662F\u5426\u663E\u793A\u9690\u85CF\u6587\u4EF6\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u76EE\u5F55\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u76EE\u5F55"},all:{type:"boolean",description:"\u662F\u5426\u663E\u793A\u9690\u85CF\u6587\u4EF6\uFF08\u4EE5 . \u5F00\u5934\u7684\u6587\u4EF6\uFF09\uFF0C\u9ED8\u8BA4 false"}},required:[],additionalProperties:!1},async execute(e,t){let n=e.path?Ye(e.path,t.cwd):t.cwd,r=e.all??!1;try{let o=await gT(n,{withFileTypes:!0}),s=[],i=[...o].toSorted((l,c)=>l.isDirectory()!==c.isDirectory()?l.isDirectory()?-1:1:l.name.localeCompare(c.name));for(let l of i){if(!r&&l.name.startsWith("."))continue;let c=l.isDirectory()?"DIR":l.isSymbolicLink()?"LINK":"FILE",u="";if(c==="FILE")try{let m=await yT(xT(n,l.name));m.size<1024?u=`${m.size}B`:m.size<1024*1024?u=`${(m.size/1024).toFixed(1)}KB`:u=`${(m.size/1024/1024).toFixed(1)}MB`}catch{u="?"}let d=c==="DIR"?"\u{1F4C1}":c==="LINK"?"\u{1F517}":"\u{1F4C4}";s.push(`${d} ${l.name}${u?` (${u})`:""}`)}if(s.length===0)return{success:!0,data:"\u76EE\u5F55\u4E3A\u7A7A",summary:`\u{1F4C2} ${mh(t.cwd,n).replace(/\\/g,"/")}\uFF08\u7A7A\uFF09`};let a=mh(t.cwd,n).replace(/\\/g,"/");return{success:!0,data:Ue(`\u76EE\u5F55\uFF1A${n}
562
566
  ${s.join(`
563
- `)}`),summary:`\u{1F4C2} ${a}\uFF08${s.length} \u9879\uFF09`}}catch(o){return{success:!1,data:`\u5217\u76EE\u5F55\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"LS_ERROR"}}}};p();var Wc={name:"fetch",kind:"read",description:"\u53D1\u8D77 HTTP \u8BF7\u6C42\u5E76\u8FD4\u56DE\u54CD\u5E94\u5185\u5BB9\u3002\u652F\u6301\u81EA\u5B9A\u4E49\u65B9\u6CD5\u548C\u8BF7\u6C42\u5934\u3002\u9002\u7528\u4E8E\u83B7\u53D6\u7F51\u9875\u5185\u5BB9\u3001API \u8C03\u7528\u7B49\u573A\u666F\u3002",parameters:{type:"object",properties:{url:{type:"string",description:"\u8BF7\u6C42\u7684 URL"},method:{type:"string",description:"HTTP \u65B9\u6CD5\uFF08GET\u3001POST\u3001PUT\u3001DELETE \u7B49\uFF09\uFF0C\u9ED8\u8BA4 GET"},headers:{type:"object",description:"\u8BF7\u6C42\u5934\u952E\u503C\u5BF9",additionalProperties:{type:"string"}},body:{type:"string",description:"\u8BF7\u6C42\u4F53\u5185\u5BB9\uFF08POST/PUT \u65F6\u4F7F\u7528\uFF09"},max_length:{type:"number",description:"\u54CD\u5E94\u5185\u5BB9\u6700\u5927\u957F\u5EA6\uFF08\u5B57\u7B26\uFF09\uFF0C\u9ED8\u8BA4 50000"}},required:["url"],additionalProperties:!1},async execute(e,t){if(!e?.url||typeof e.url!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 url",error:"INVALID_ARGS"};let n=(e.method??"GET").toUpperCase(),r=3e4,o=e.max_length??5e4;try{let s={method:n,headers:e.headers??{},signal:t.signal??AbortSignal.timeout(r)};e.body&&(n==="POST"||n==="PUT"||n==="PATCH")&&(s.headers["Content-Type"]??="application/json",s.body=e.body);let i=await fetch(e.url,s),a=i.headers.get("content-type")??"unknown",l=`${i.status} ${i.statusText}`,c;try{c=await i.text()}catch{c="(\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u4F53)"}let u=We(c,o),d=`\u72B6\u6001: ${l}
567
+ `)}`),summary:`\u{1F4C2} ${a}\uFF08${s.length} \u9879\uFF09`}}catch(o){return{success:!1,data:`\u5217\u76EE\u5F55\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"LS_ERROR"}}}};p();var Kc={name:"fetch",kind:"read",description:"\u53D1\u8D77 HTTP \u8BF7\u6C42\u5E76\u8FD4\u56DE\u54CD\u5E94\u5185\u5BB9\u3002\u652F\u6301\u81EA\u5B9A\u4E49\u65B9\u6CD5\u548C\u8BF7\u6C42\u5934\u3002\u9002\u7528\u4E8E\u83B7\u53D6\u7F51\u9875\u5185\u5BB9\u3001API \u8C03\u7528\u7B49\u573A\u666F\u3002",parameters:{type:"object",properties:{url:{type:"string",description:"\u8BF7\u6C42\u7684 URL"},method:{type:"string",description:"HTTP \u65B9\u6CD5\uFF08GET\u3001POST\u3001PUT\u3001DELETE \u7B49\uFF09\uFF0C\u9ED8\u8BA4 GET"},headers:{type:"object",description:"\u8BF7\u6C42\u5934\u952E\u503C\u5BF9",additionalProperties:{type:"string"}},body:{type:"string",description:"\u8BF7\u6C42\u4F53\u5185\u5BB9\uFF08POST/PUT \u65F6\u4F7F\u7528\uFF09"},max_length:{type:"number",description:"\u54CD\u5E94\u5185\u5BB9\u6700\u5927\u957F\u5EA6\uFF08\u5B57\u7B26\uFF09\uFF0C\u9ED8\u8BA4 50000"}},required:["url"],additionalProperties:!1},async execute(e,t){if(!e?.url||typeof e.url!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 url",error:"INVALID_ARGS"};let n=(e.method??"GET").toUpperCase(),r=3e4,o=e.max_length??5e4;try{let s={method:n,headers:e.headers??{},signal:t.signal??AbortSignal.timeout(r)};e.body&&(n==="POST"||n==="PUT"||n==="PATCH")&&(s.headers["Content-Type"]??="application/json",s.body=e.body);let i=await fetch(e.url,s),a=i.headers.get("content-type")??"unknown",l=`${i.status} ${i.statusText}`,c;try{c=await i.text()}catch{c="(\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u4F53)"}let u=Ue(c,o),d=`\u72B6\u6001: ${l}
564
568
  \u5185\u5BB9\u7C7B\u578B: ${a}`,m=c.length>0?`
565
569
  ---
566
- `:"",h=e.url.length>60?e.url.slice(0,57)+"...":e.url,f=`\u{1F310} ${n} ${h} \u2192 ${i.status}`;return{success:i.ok,data:`${d}${m}${u}`,summary:f,error:i.ok?void 0:`HTTP_${i.status}`}}catch(s){return s instanceof DOMException&&s.name==="AbortError"?{success:!1,data:"\u8BF7\u6C42\u88AB\u4E2D\u6B62",error:"ABORTED"}:s instanceof TypeError&&s.message.includes("fetch")?{success:!1,data:`\u7F51\u7EDC\u9519\u8BEF\uFF1A${s.message}`,error:"NETWORK_ERROR"}:{success:!1,data:`HTTP \u8BF7\u6C42\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"FETCH_ERROR"}}}};p();import{z as lh}from"zod";var ch=lh.object({name:lh.string().min(1,"skill \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A").describe("Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>")});function Hc(e){return{name:"skill",kind:"other",description:"\u6309\u540D\u79F0\u52A0\u8F7D skill \u7684\u5B8C\u6574\u5185\u5BB9\u5230\u4E0A\u4E0B\u6587\u3002\u5F53\u7528\u6237\u8BF7\u6C42\u5339\u914D\u67D0\u4E2A skill \u7684 description \u65F6\u8C03\u7528\u672C\u5DE5\u5177\u3002",parameters:{type:"object",properties:{name:{type:"string",description:"Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>"}},required:["name"],additionalProperties:!1},schema:ch,async execute(t,n){let r=e.getSkills(),o=r.find(s=>s.name===t.name&&!s.disableModelInvocation);if(!o){let s=r.filter(i=>!i.disableModelInvocation).map(i=>i.name).join(", ");return{success:!1,data:`Skill "${t.name}" \u4E0D\u5B58\u5728\u3002\u53EF\u7528\uFF1A${s||"(\u65E0)"}`,error:"SKILL_NOT_FOUND",summary:`Skill \u4E0D\u5B58\u5728\uFF1A${t.name}`}}try{let s=await e.readBody(o);return{success:!0,data:ai(o,s),summary:`\u5DF2\u52A0\u8F7D skill: ${o.name}`}}catch(s){return{success:!1,data:`\u8BFB\u53D6 skill body \u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"SKILL_READ_FAILED",summary:`\u8BFB\u53D6 skill \u5931\u8D25\uFF1A${o.name}`}}},initialTitle(t){return`\`${t.name}\` Skill`}}}var Vc=[Oe(Lc),Oe(Dc),Oe(Nc),Oe(Mc),Oe(Bc),Oe(Fc),Oe(Gc),Oe(jc),Oe(Uc),Oe(Wc)];p();function uh(e,t={}){let n=t.maxBytes??as,r=[...e].toSorted((l,c)=>l.skillFilePath.localeCompare(c.skillFilePath)),o=[],s=[],i=0,a=!1;for(let l of r){if(l.disableModelInvocation)continue;let c=Buffer.byteLength(l.name,"utf8")+Buffer.byteLength(l.description,"utf8");!a&&i+c<=n?(i+=c,o.push({name:l.name,description:l.description,location:l.skillFilePath,source:l.source})):(a=!0,s.push(l))}return{catalog:o,dropped:s}}p();p();var kr=String.raw`(?:--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?\s+|-[a-zA-Z]+\s+)*`,_o=String.raw`(?:--\s+)?`,vo=String.raw`(?:\s+--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?|\s+-[a-zA-Z]+)*`,Ro=String.raw`(?:[\s;&|]|$)`,rT=[new RegExp(String.raw`\brm\s+${kr}${_o}/\*?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}~/?\*?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}\$\{?HOME\}?(?:/|\*)?(?:[^\s/]*\*)?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}\.(?:/\*?|/\.\.?/?\*?|\*)?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}\.\.(?:/\*?|/\.\.?/?\*?|\*)?${vo}${Ro}`),new RegExp(String.raw`\bmkfs(?:\.\w+)?\s+(?:-[\w]+\s+)*/dev/(?:sd[a-z]\d*|nvme\w+|hd[a-z]\d*|vd[a-z]\d*|mmcblk\d+)\b`),new RegExp(String.raw`\bdd\s+[^|;&]*\s+of=/dev/(?:sd[a-z]|nvme\w+|hd[a-z]|vd[a-z]|mmcblk\d+)\b`),new RegExp(String.raw`\bchmod\s+${kr}-R\s+777?\s+/(?:\s|$|;|&&|\|\||\*)`),new RegExp(String.raw`\bcurl\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bwget\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bgit\s+push\s+(?:[^|;&]*\s)?--?(?:force|f)\b[^|;&]*\b(?:origin\s+)?(?:main|master)\b`)];function ph(e){if(typeof e!="string"||e.length===0)return!1;if(dh(e))return!0;let t=oT(e);for(let n of t)if(dh(n))return!0;return!1}function dh(e){for(let t of rT)if(t.test(e))return!0;return!1}function oT(e){let t=[],n=/(?:&&|\|\||;|\n)/g,r=0,o;for(;(o=n.exec(e))!==null;){let i=e.slice(r,o.index).trim();i.length>0&&t.push(i),r=o.index+o[0].length}let s=e.slice(r).trim();return s.length>0&&t.push(s),t}var jn=class{#e=void 0;async check(t,n){if(t!=="bash")return this.#e=void 0,!0;if(typeof n!="object"||n===null)return this.#e=void 0,!0;let r=n.command;return typeof r!="string"?(this.#e=void 0,!0):ph(r)?(this.#e={source:"hardcoded_blacklist",reason:"\u547D\u4EE4\u547D\u4E2D\u786C\u7F16\u7801\u707E\u96BE\u6A21\u5F0F\uFF1A"+r,hint:"\u8BF7\u6362\u79CD\u7B49\u6548\u4F46\u5B89\u5168\u7684\u5199\u6CD5\u3002\u8BE5\u89C4\u5219\u4E0D\u53EF\u88AB\u914D\u7F6E\u8986\u76D6\u3002"},!1):(this.#e=void 0,!0)}get lastDenial(){return this.#e}};p();var fn=class{#e;constructor(t){this.#e=t}async check(t,n){for(let r of this.#e)if(!await r.check(t,n))return!1;return!0}get lastDenial(){for(let t of this.#e){let n=t.lastDenial;if(n)return n}}get size(){return this.#e.length}};var Ao=class e{#e=[];#n;#r;#s;#t;#c=new AbortController;#p;#i;#d;#o=null;#a=new Map;#m=[];#f="code";#u;#x;#h;#g=null;#l;#w=!1;#y;#k;#S;constructor(t,n=[],r,o){this.#n=t,n instanceof un?this.#r=n:(this.#r=new un,this.#r.registerAll(n)),this.#s=r??new Me;let s;if(o?.permissions){let i=o.permissions,a=i.engine??new td([]);s=new fn([new jn,new nd({engine:a,grants:i.grants,prompt:i.prompt,defaultDecision:i.defaultDecision})])}else s=o?.gate??new Ca;if(this.#t={cwd:o?.cwd??process.cwd(),maxToolRounds:o?.maxToolRounds??20,reservedForOutput:o?.reservedForOutput??4096,preserveRecentRounds:o?.preserveRecentRounds??10,autoCompactRatio:o?.autoCompactRatio??bc,preserveRecentRoundsOnCompact:o?.preserveRecentRoundsOnCompact??wc,minTurnsToCompact:o?.minTurnsToCompact??ui,projectContext:o?.projectContext,gate:s,writeRoots:o?.writeRoots??[o?.cwd??process.cwd()],enableCheckpoint:o?.enableCheckpoint??!0,enableLog:o?.enableLog??!0,enableReflection:o?.enableReflection!==!1,enableHarness:o?.enableHarness!==!1,enableAutoCompact:o?.enableAutoCompact!==!1},this.#p=o?.sessionId??Gn.newId(),this.#i=o?.store===!1?null:o?.store??new Gn,this.#d=Date.now(),this.#u=new en(this.#p,this.#t.cwd,{enabled:this.#t.enableLog}),this.#u.logSessionStart(this.#p,this.#t.cwd,this.#n.model(),this.#f),this.#x=new pi({threshold:3}),this.#h=this.#t.enableReflection?new fi:null,this.#t.enableHarness){let i=new mi;this.#l=i;for(let a of Um(i))this.#r.registerErased(Oe(a))}else this.#l=null;this.#y=o?.skills??[],this.#k=()=>this.#y,this.#S=o?.skillCatalogBudgetBytes??as,this.#y.length>0&&this.#r.register(Hc({getSkills:this.#k,readBody:async i=>ls(i.skillFilePath)}))}get messages(){return this.#e}get accumulatedCost(){return this.#s.sessionTotalCost}get costTracker(){return this.#s}get model(){return this.#n.model()}get toolRegistry(){return this.#r}get mode(){return this.#f}get id(){return this.#p}get store(){return this.#i}get createdAt(){return this.#d}setMode(t){return this.#f=t,this.#f}async*chat(t,n){this.#e.push({role:"user",content:t}),this.#u.logUserMessage(t);let r=this.#e.length-1;if(this.#t.enableCheckpoint)try{let l=await _c(this.#t.cwd);this.#a.set(r,l)}catch{}if(this.#t.enableAutoCompact){let l=await this.#C();l&&(yield{type:"compaction",droppedTurns:l.droppedTurns,keptTurns:l.keptTurns,beforeTokens:l.beforeTokens,afterTokens:l.afterTokens,strategy:l.strategy})}let o=Date.now(),s=0,i=this.#R();this.#w=!1;try{for(;s<this.#t.maxToolRounds;){let l=this.#A();if(this.#h&&this.#g){let T=this.#h.analyze(this.#g,{writeRoots:this.#t.writeRoots,cwd:this.#t.cwd});T.length>0&&(l=this.#h.injectIntoPrompt(l,T),this.#u.logReflections(T.map(N=>({category:N.category,toolName:N.toolName,hint:N.hint})))),this.#g=null}let[c]=Lm([...this.#e],{model:this.#n.model(),reservedForOutput:this.#t.reservedForOutput,systemPrompt:l,preserveRecentRounds:this.#t.preserveRecentRounds}),u=$m(l,c),d=jm(this.#r,this.#f),m=this.#n.chat(u,{signal:this.#c.signal,tools:d.length>0?d:void 0,thinkingAllowed:n?.thinkingAllowed,thinkingEffort:n?.thinkingEffort,responseFormat:n?.responseFormat,toolChoice:n?.toolChoice}),h=this.#n.model(),f="",g="",b,w,S=null,v=0;for(let T of u)v+=this.#n.countTokens(T.content)+10;let _=0,E=300;for await(let T of m){if(T.reasoningContent&&(g+=T.reasoningContent,yield{type:"reasoning_delta",content:T.reasoningContent}),T.content){f+=T.content,yield{type:"text_delta",content:T.content};let N=Date.now();if(N-_>=E){_=N;let F=this.#n.countTokens(f),q={promptTokens:v,completionTokens:F},$=kt(q,h);yield{type:"usage",usage:q,model:h,cost:$.totalCost,estimated:!0}}}if(T.toolCalls&&T.toolCalls.length>0&&(w=T.toolCalls),T.usage){b=T.usage;let N=kt(T.usage,h);yield{type:"usage",usage:T.usage,model:h,cost:N.totalCost,estimated:!1}}T.finishReason&&(S=T.finishReason)}if(f&&!b){let T=this.#n.countTokens(f),N={promptTokens:v,completionTokens:T},F=kt(N,h);yield{type:"usage",usage:N,model:h,cost:F.totalCost,estimated:!0}}if(b){this.#s.record(b,h);let T=kt(b,h);this.#u.logUsage(h,b.promptTokens,b.completionTokens,b.cachedPromptTokens,T.totalCost,s),yield{type:"usage",usage:b,model:h}}let M={role:"assistant",content:f};if(w&&w.length>0&&(M.toolCalls=w),this.#e.push(M),this.#u.logAssistantText(f,s),g&&this.#u.logReasoning(g,s),w&&w.length>0){yield{type:"tool_calls",calls:w};for(let F of w)this.#u.logToolCall(F.name,F.id,F.arguments,s);if(this.#x.shouldBreak(this.#m,w)){let F=`
570
+ `:"",h=e.url.length>60?e.url.slice(0,57)+"...":e.url,f=`\u{1F310} ${n} ${h} \u2192 ${i.status}`;return{success:i.ok,data:`${d}${m}${u}`,summary:f,error:i.ok?void 0:`HTTP_${i.status}`}}catch(s){return s instanceof DOMException&&s.name==="AbortError"?{success:!1,data:"\u8BF7\u6C42\u88AB\u4E2D\u6B62",error:"ABORTED"}:s instanceof TypeError&&s.message.includes("fetch")?{success:!1,data:`\u7F51\u7EDC\u9519\u8BEF\uFF1A${s.message}`,error:"NETWORK_ERROR"}:{success:!1,data:`HTTP \u8BF7\u6C42\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"FETCH_ERROR"}}}};p();import{z as hh}from"zod";var gh=hh.object({name:hh.string().min(1,"skill \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A").describe("Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>")});function Xc(e){return{name:"skill",kind:"other",description:"\u6309\u540D\u79F0\u52A0\u8F7D skill \u7684\u5B8C\u6574\u5185\u5BB9\u5230\u4E0A\u4E0B\u6587\u3002\u5F53\u7528\u6237\u8BF7\u6C42\u5339\u914D\u67D0\u4E2A skill \u7684 description \u65F6\u8C03\u7528\u672C\u5DE5\u5177\u3002",parameters:{type:"object",properties:{name:{type:"string",description:"Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>"}},required:["name"],additionalProperties:!1},schema:gh,async execute(t,n){let r=e.getSkills(),o=r.find(s=>s.name===t.name&&!s.disableModelInvocation);if(!o){let s=r.filter(i=>!i.disableModelInvocation).map(i=>i.name).join(", ");return{success:!1,data:`Skill "${t.name}" \u4E0D\u5B58\u5728\u3002\u53EF\u7528\uFF1A${s||"(\u65E0)"}`,error:"SKILL_NOT_FOUND",summary:`Skill \u4E0D\u5B58\u5728\uFF1A${t.name}`}}try{let s=await e.readBody(o);return{success:!0,data:di(o,s),summary:`\u5DF2\u52A0\u8F7D skill: ${o.name}`}}catch(s){return{success:!1,data:`\u8BFB\u53D6 skill body \u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"SKILL_READ_FAILED",summary:`\u8BFB\u53D6 skill \u5931\u8D25\uFF1A${o.name}`}}},initialTitle(t){return`\`${t.name}\` Skill`}}}var Jc=[Oe(Mc),Oe(Gc),Oe(jc),Oe(Uc),Oe(Wc),Oe(Hc),Oe(Vc),Oe(zc),Oe(qc),Oe(Kc)];p();function yh(e,t={}){let n=t.maxBytes??us,r=[...e].toSorted((l,c)=>l.skillFilePath.localeCompare(c.skillFilePath)),o=[],s=[],i=0,a=!1;for(let l of r){if(l.disableModelInvocation)continue;let c=Buffer.byteLength(l.name,"utf8")+Buffer.byteLength(l.description,"utf8");!a&&i+c<=n?(i+=c,o.push({name:l.name,description:l.description,location:l.skillFilePath,source:l.source})):(a=!0,s.push(l))}return{catalog:o,dropped:s}}p();p();var xr=String.raw`(?:--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?\s+|-[a-zA-Z]+\s+)*`,vo=String.raw`(?:--\s+)?`,Ao=String.raw`(?:\s+--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?|\s+-[a-zA-Z]+)*`,Eo=String.raw`(?:[\s;&|]|$)`,bT=[new RegExp(String.raw`\brm\s+${xr}${vo}/\*?${Ao}${Eo}`),new RegExp(String.raw`\brm\s+${xr}${vo}~/?\*?${Ao}${Eo}`),new RegExp(String.raw`\brm\s+${xr}${vo}\$\{?HOME\}?(?:/|\*)?(?:[^\s/]*\*)?${Ao}${Eo}`),new RegExp(String.raw`\brm\s+${xr}${vo}\.(?:/\*?|/\.\.?/?\*?|\*)?${Ao}${Eo}`),new RegExp(String.raw`\brm\s+${xr}${vo}\.\.(?:/\*?|/\.\.?/?\*?|\*)?${Ao}${Eo}`),new RegExp(String.raw`\bmkfs(?:\.\w+)?\s+(?:-[\w]+\s+)*/dev/(?:sd[a-z]\d*|nvme\w+|hd[a-z]\d*|vd[a-z]\d*|mmcblk\d+)\b`),new RegExp(String.raw`\bdd\s+[^|;&]*\s+of=/dev/(?:sd[a-z]|nvme\w+|hd[a-z]|vd[a-z]|mmcblk\d+)\b`),new RegExp(String.raw`\bchmod\s+${xr}-R\s+777?\s+/(?:\s|$|;|&&|\|\||\*)`),new RegExp(String.raw`\bcurl\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bwget\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bgit\s+push\s+(?:[^|;&]*\s)?--?(?:force|f)\b[^|;&]*\b(?:origin\s+)?(?:main|master)\b`)];function bh(e){if(typeof e!="string"||e.length===0)return!1;if(xh(e))return!0;let t=wT(e);for(let n of t)if(xh(n))return!0;return!1}function xh(e){for(let t of bT)if(t.test(e))return!0;return!1}function wT(e){let t=[],n=/(?:&&|\|\||;|\n)/g,r=0,o;for(;(o=n.exec(e))!==null;){let i=e.slice(r,o.index).trim();i.length>0&&t.push(i),r=o.index+o[0].length}let s=e.slice(r).trim();return s.length>0&&t.push(s),t}var Gn=class{#e=void 0;async check(t,n){if(t!=="bash")return this.#e=void 0,!0;if(typeof n!="object"||n===null)return this.#e=void 0,!0;let r=n.command;return typeof r!="string"?(this.#e=void 0,!0):bh(r)?(this.#e={source:"hardcoded_blacklist",reason:"\u547D\u4EE4\u547D\u4E2D\u786C\u7F16\u7801\u707E\u96BE\u6A21\u5F0F\uFF1A"+r,hint:"\u8BF7\u6362\u79CD\u7B49\u6548\u4F46\u5B89\u5168\u7684\u5199\u6CD5\u3002\u8BE5\u89C4\u5219\u4E0D\u53EF\u88AB\u914D\u7F6E\u8986\u76D6\u3002"},!1):(this.#e=void 0,!0)}get lastDenial(){return this.#e}};p();var fn=class{#e;constructor(t){this.#e=t}async check(t,n){for(let r of this.#e)if(!await r.check(t,n))return!1;return!0}get lastDenial(){for(let t of this.#e){let n=t.lastDenial;if(n)return n}}get size(){return this.#e.length}};function kT(e){let t=-1;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.role==="assistant"&&i.toolCalls&&i.toolCalls.length>0){t=s;break}if(i.role==="system")break}if(t<0)return 0;let n=e[t].toolCalls??[],r=new Set;for(let s=t+1;s<e.length;s++){let i=e[s];i.role==="tool"&&i.toolCallId&&r.add(i.toolCallId)}let o=0;for(let s of n)!s.id||r.has(s.id)||(e.splice(t+1+o,0,{role:"tool",content:"[\u4E0A\u8F6E\u88AB\u6253\u65AD\uFF0C\u672A\u6267\u884C\u3002\u8BF7\u6839\u636E\u4E0A\u4E0B\u6587\u81EA\u884C\u5224\u65AD\u662F\u5426\u9700\u8981\u91CD\u8BD5\u6216\u8C03\u6574\u8C03\u7528\u3002]",toolCallId:s.id,name:s.name}),o++);return o}var Io=class e{#e=[];#n;#r;#s;#t;#u=new AbortController;#p;#i;#d;#o=null;#a=new Map;#m=[];#f="code";#l;#x;#h;#g=null;#c;#w=!1;#y;#k;#S;constructor(t,n=[],r,o){this.#n=t,n instanceof un?this.#r=n:(this.#r=new un,this.#r.registerAll(n)),this.#s=r??new Me;let s;if(o?.permissions){let i=o.permissions,a=i.engine??new id([]);s=new fn([new Gn,new ad({engine:a,grants:i.grants,prompt:i.prompt,defaultDecision:i.defaultDecision})])}else s=o?.gate??new Aa;if(this.#t={cwd:o?.cwd??process.cwd(),maxToolRounds:o?.maxToolRounds??20,reservedForOutput:o?.reservedForOutput??4096,preserveRecentRounds:o?.preserveRecentRounds??10,autoCompactRatio:o?.autoCompactRatio??Sc,preserveRecentRoundsOnCompact:o?.preserveRecentRoundsOnCompact??Tc,minTurnsToCompact:o?.minTurnsToCompact??mi,projectContext:o?.projectContext,gate:s,writeRoots:o?.writeRoots??[o?.cwd??process.cwd()],enableCheckpoint:o?.enableCheckpoint??!0,enableLog:o?.enableLog??!0,enableReflection:o?.enableReflection!==!1,enableHarness:o?.enableHarness!==!1,enableAutoCompact:o?.enableAutoCompact!==!1},this.#p=o?.sessionId??Fn.newId(),this.#i=o?.store===!1?null:o?.store??new Fn,this.#d=Date.now(),this.#l=new en(this.#p,this.#t.cwd,{enabled:this.#t.enableLog}),this.#l.logSessionStart(this.#p,this.#t.cwd,this.#n.model(),this.#f),this.#x=new gi({threshold:3}),this.#h=this.#t.enableReflection?new yi:null,this.#t.enableHarness){let i=new xi;this.#c=i;for(let a of Km(i))this.#r.registerErased(Oe(a))}else this.#c=null;this.#y=o?.skills??[],this.#k=()=>this.#y,this.#S=o?.skillCatalogBudgetBytes??us,this.#y.length>0&&this.#r.register(Xc({getSkills:this.#k,readBody:async i=>ds(i.skillFilePath)}))}get messages(){return this.#e}get accumulatedCost(){return this.#s.sessionTotalCost}get costTracker(){return this.#s}get model(){return this.#n.model()}get toolRegistry(){return this.#r}get mode(){return this.#f}get id(){return this.#p}get store(){return this.#i}get createdAt(){return this.#d}setMode(t){return this.#f=t,this.#f}async*chat(t,n){let r=kT(this.#e);r>0&&this.#l.logError(`\u515C\u5E95\u4FEE\u590D\u4E86 ${r} \u6761 orphan tool_calls\uFF08\u4E0A\u8F6E\u88AB\u4E2D\u65AD\uFF09`,void 0),this.#e.push({role:"user",content:t}),this.#l.logUserMessage(t);let o=this.#e.length-1;if(this.#t.enableCheckpoint)try{let c=await Ic(this.#t.cwd);this.#a.set(o,c)}catch{}if(this.#t.enableAutoCompact){let c=await this.#C();c&&(yield{type:"compaction",droppedTurns:c.droppedTurns,keptTurns:c.keptTurns,beforeTokens:c.beforeTokens,afterTokens:c.afterTokens,strategy:c.strategy})}let s=Date.now(),i=0,a=this.#v();this.#w=!1;try{for(;i<this.#t.maxToolRounds;){let c=this.#A();if(this.#h&&this.#g){let C=this.#h.analyze(this.#g,{writeRoots:this.#t.writeRoots,cwd:this.#t.cwd});C.length>0&&(c=this.#h.injectIntoPrompt(c,C),this.#l.logReflections(C.map(J=>({category:J.category,toolName:J.toolName,hint:J.hint})))),this.#g=null}let[u]=Gm([...this.#e],{model:this.#n.model(),reservedForOutput:this.#t.reservedForOutput,systemPrompt:c,preserveRecentRounds:this.#t.preserveRecentRounds}),d=jm(c,u),m=qm(this.#r,this.#f),h=this.#n.chat(d,{signal:this.#u.signal,tools:m.length>0?m:void 0,thinkingAllowed:n?.thinkingAllowed,thinkingEffort:n?.thinkingEffort,responseFormat:n?.responseFormat,toolChoice:n?.toolChoice}),f=this.#n.model(),g="",k="",b,S,R=null,v=0;for(let C of d)v+=this.#n.countTokens(C.content)+10;let _=0,B=300;for await(let C of h){if(C.reasoningContent&&(k+=C.reasoningContent,yield{type:"reasoning_delta",content:C.reasoningContent}),C.content){g+=C.content,yield{type:"text_delta",content:C.content};let J=Date.now();if(J-_>=B){_=J;let M=this.#n.countTokens(g),U={promptTokens:v,completionTokens:M},N=kt(U,f);yield{type:"usage",usage:U,model:f,cost:N.totalCost,estimated:!0}}}if(C.toolCalls&&C.toolCalls.length>0&&(S=C.toolCalls),C.usage){b=C.usage;let J=kt(C.usage,f);yield{type:"usage",usage:C.usage,model:f,cost:J.totalCost,estimated:!1}}C.finishReason&&(R=C.finishReason)}if(g&&!b){let C=this.#n.countTokens(g),J={promptTokens:v,completionTokens:C},M=kt(J,f);yield{type:"usage",usage:J,model:f,cost:M.totalCost,estimated:!0}}if(b){this.#s.record(b,f);let C=kt(b,f);this.#l.logUsage(f,b.promptTokens,b.completionTokens,b.cachedPromptTokens,C.totalCost,i),yield{type:"usage",usage:b,model:f}}let j={role:"assistant",content:g};if(S&&S.length>0&&(j.toolCalls=S),this.#e.push(j),this.#l.logAssistantText(g,i),k&&this.#l.logReasoning(k,i),S&&S.length>0){yield{type:"tool_calls",calls:S};for(let M of S)this.#l.logToolCall(M.name,M.id,M.arguments,i);if(this.#x.shouldBreak(this.#m,S)){let M=`
567
571
  \u26A0\uFE0F \u540C\u4E00\u5DE5\u5177\u91CD\u590D\u51FA\u9519\uFF0C\u5DF2\u5F3A\u5236\u5207\u6362\u7B56\u7565
568
- `;yield{type:"text_delta",content:F},M.toolCalls=void 0,M.content+=F,this.#m=[],s++;continue}let N=await i.executeBatch(w);this.#m=N.records,this.#g=N.items.map(F=>{let q=this.#r.get(F.name);return{name:F.name,result:F.result,kind:q?.kind??"other",recentSameTool:N.records.filter($=>$.name===F.name).map($=>({success:$.success,error:$.error}))}});for(let F of N.items){let q=F.name.startsWith("todo_")&&this.#l?this.#l.items.map(oe=>({...oe})):void 0;yield{type:"tool_result",name:F.name,result:F.result,todoSnapshot:q,callId:F.callId},this.#u.logToolResult(F.name,F.callId,F.result.success,F.result.data,F.result.error,void 0,s);let $=F.result.data;F.result.diff&&F.result.diff.patch&&($+=`
572
+ `;yield{type:"text_delta",content:M},j.toolCalls=void 0,j.content+=M,this.#m=[],i++;continue}let J=await a.executeBatch(S);this.#m=J.records,this.#g=J.items.map(M=>{let U=this.#r.get(M.name);return{name:M.name,result:M.result,kind:U?.kind??"other",recentSameTool:J.records.filter(N=>N.name===M.name).map(N=>({success:N.success,error:N.error}))}});for(let M of J.items){let U=M.name.startsWith("todo_")&&this.#c?this.#c.items.map(ie=>({...ie})):void 0;yield{type:"tool_result",name:M.name,result:M.result,todoSnapshot:U,callId:M.callId},this.#l.logToolResult(M.name,M.callId,M.result.success,M.result.data,M.result.error,void 0,i);let N=M.result.data;M.result.diff&&M.result.diff.patch&&(N+=`
569
573
 
570
- ${F.result.diff.patch}`),this.#e.push({role:"tool",content:$,toolCallId:F.callId,name:F.name})}this.#E(N.items),s++;continue}let U=!1;if(this.#l){for(let T of this.#l.items)T.status==="running"&&(this.#l.markDone(T.id,"LLM \u5DF2\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"),U=!0);if(U){let T=this.#l.items.map(N=>({...N}));yield{type:"tool_result",name:"todo_mark_done",result:{success:!0,data:"\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"},todoSnapshot:T}}}this.#l&&this.#l.items.length>0&&this.#l.isAllTerminated()&&this.#e.push({role:"user",content:"[\u7CFB\u7EDF] \u5168\u90E8 todo \u5DF2\u5B8C\u6210\u3002\u8BF7\u505A\u4E00\u6B21\u4EFB\u52A1\u81EA\u68C0\uFF1A\u91CD\u65B0\u8BFB\u53D6\u672C\u6B21\u4FEE\u6539\u8FC7\u7684\u6587\u4EF6\uFF0C\u786E\u8BA4\u6539\u52A8\u6B63\u786E\u65E0\u8BEF\u3001\u7C7B\u578B\u517C\u5BB9\u3001\u6CA1\u6709\u9057\u6F0F\u3002\u5982\u6709\u95EE\u9898\u8BF7\u65B0\u589E todo \u4FEE\u590D\uFF1B\u786E\u8BA4\u65E0\u8BEF\u540E\u8F93\u51FA\u6700\u7EC8\u603B\u7ED3\u3002"});break}}catch(l){if(l instanceof DOMException&&l.name==="AbortError"||l instanceof Error&&l.name==="AbortError")return;this.#u.logError(l instanceof Error?l.message:String(l),l instanceof Error?l.stack:void 0),yield{type:"error",error:l instanceof Error?l:new Error(String(l))};return}let a=Date.now()-o;this.#u.logTurnDone(a,s),this.#b(),await this.#s.flush().catch(()=>{}),yield{type:"done",elapsed:a}}abort(){this.#c.abort(),this.#o&&(clearTimeout(this.#o),this.#o=null)}async flushLog(){await this.#u.flush()}reset(){this.#e.length=0,this.#s.resetSession(),this.#m=[],this.#a.clear(),this.#g=null}getContextStats(){let t=tn(this.#n.model());return kc(this.#e,t.contextWindow)}async compact(t){let n=tn(this.#n.model()),r=await Sc(this.#e,{contextWindow:n.contextWindow,autoCompactRatio:this.#t.autoCompactRatio,preserveRecentRounds:this.#t.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#t.minTurnsToCompact,provider:this.#n,signal:this.#c.signal,...t?{onProgress:t}:{}});if(r.droppedTurns>0){this.#e.length=0;for(let o of r.messages)this.#e.push(o);this.#a.clear(),this.#b()}return r}async#C(){let n={contextWindow:tn(this.#n.model()).contextWindow,autoCompactRatio:this.#t.autoCompactRatio,preserveRecentRounds:this.#t.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#t.minTurnsToCompact,provider:this.#n,signal:this.#c.signal};if(!Nm(this.#e,n))return null;let r=await Sc(this.#e,n);if(r.droppedTurns===0)return null;let o=r.summary.includes("\u672C\u5730\u6458\u8981")?"fallback":"summary";this.#e.length=0;for(let s of r.messages)this.#e.push(s);return this.#a.clear(),this.#b(),{...r,strategy:o}}async persistNow(){this.#o&&(clearTimeout(this.#o),this.#o=null),await this.#T()}#b(){if(this.#i){if(this.#o){this.#o.refresh();return}this.#o=setTimeout(()=>{this.#o=null,this.#T()},500),this.#o.unref()}}async#T(){if(!this.#i)return;let t={id:this.#p,title:this.#_(),createdAt:this.#d,updatedAt:Date.now(),cwd:this.#t.cwd,model:this.#n.model(),messages:this.#v(),totalCost:this.#s.sessionTotalCost};try{await this.#i.save(t)}catch(n){console.error("[Session] \u6301\u4E45\u5316\u5931\u8D25:",n)}}#_(){for(let t of this.#e)if(t.role==="user"&&t.content.trim())return t.content.trim().slice(0,40);return"\u65B0\u4F1A\u8BDD"}#v(){return this.#e.map((t,n)=>{let r=this.#a.get(n);return t.role==="user"&&r?{...t,checkpoint:r}:{...t}})}static async resume(t,n,r=[],o,s){let i=s?.store===!1?null:s?.store??new Gn;if(!i)throw new Error("resume \u9700\u8981\u542F\u7528\u6301\u4E45\u5316\uFF08options.store \u4E0D\u80FD\u4E3A false\uFF09");let a=await i.load(t);if(!a)throw new Error(`\u4F1A\u8BDD ${t} \u4E0D\u5B58\u5728`);let l=new e(n,r,o,{...s,sessionId:t,store:i});for(let c of a.messages)l.#e.push({role:c.role,content:c.content,toolCallId:c.toolCallId,name:c.name,toolCalls:c.toolCalls});for(let c=0;c<a.messages.length;c++){let u=a.messages[c]?.checkpoint;u&&l.#a.set(c,u)}return l.#d=a.createdAt,l}listCheckpoints(){let t=[];for(let[n,r]of this.#a){let o=this.#e[n];!o||o.role!=="user"||t.push({index:n,preview:o.content.slice(0,80),timestamp:r.timestamp,isGitRepo:r.isGitRepo})}return t.sort((n,r)=>n.index-r.index)}async rewind(t){if(t<0||t>=this.#e.length)return{ok:!1,error:`\u65E0\u6548\u7684\u6D88\u606F\u7D22\u5F15 ${t}`};let n=this.#e[t];if(!n||n.role!=="user")return{ok:!1,error:`\u7D22\u5F15 ${t} \u4E0D\u662F user \u6D88\u606F`};let r=this.#a.get(t);if(!r)return{ok:!1,error:"\u8BE5\u6D88\u606F\u6CA1\u6709\u68C0\u67E5\u70B9"};this.#e.length=t+1;let o=[];for(let[i,a]of this.#a)i>t&&(o.push(a),this.#a.delete(i));let s=!1;if(r.isGitRepo)try{r.stashSha?await vc(r):await Rc(this.#t.cwd),s=!0}catch(i){return{ok:!1,error:`\u5BF9\u8BDD\u5DF2\u622A\u65AD\u4F46\u6587\u4EF6\u6062\u590D\u5931\u8D25\uFF1A${i instanceof Error?i.message:String(i)}`}}this.#a.delete(t);for(let i of o)xi(i);return this.#b(),{ok:!0,fileRestored:s}}hasCheckpoints(){return this.listCheckpoints().length>0}get gate(){return this.#t.gate}async delete(){this.#i&&await this.#i.delete(this.#p);for(let t of this.#a.values())xi(t);this.#a.clear(),this.#u.logSessionEnd(Date.now()-this.#d),await this.#u.flush()}#R(){return new di({registry:this.#r,gate:this.#t.gate,baseCtx:{cwd:this.#t.cwd,signal:this.#c.signal,writeRoots:this.#t.writeRoots}})}#A(){let n=this.#r.list().map(a=>({name:a.name,description:a.description,parameters:a.parameters})),{catalog:r}=this.#y.length>0?uh(this.#y,{maxBytes:this.#S}):{catalog:[]},o=r.length>0?r.map(a=>({name:a.name,description:a.description,location:a.location})):void 0,s={model:this.#n.model(),maxToolRounds:this.#t.maxToolRounds,tools:n.length>0?n:void 0,projectContext:this.#t.projectContext??void 0,cwd:this.#t.cwd,availableSkills:o},i;return this.#f==="plan"?i=Em(s):i=Am(s),this.#l&&this.#l.items.length>0&&(i=i+`
574
+ ${M.result.diff.patch}`),this.#e.push({role:"tool",content:N,toolCallId:M.callId,name:M.name})}this.#E(J.items),i++;continue}let D=!1;if(this.#c){for(let C of this.#c.items)C.status==="running"&&(this.#c.markDone(C.id,"LLM \u5DF2\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"),D=!0);if(D){let C=this.#c.items.map(J=>({...J}));yield{type:"tool_result",name:"todo_mark_done",result:{success:!0,data:"\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"},todoSnapshot:C}}}this.#c&&this.#c.items.length>0&&this.#c.isAllTerminated()&&this.#e.push({role:"user",content:"[\u7CFB\u7EDF] \u5168\u90E8 todo \u5DF2\u5B8C\u6210\u3002\u8BF7\u505A\u4E00\u6B21\u4EFB\u52A1\u81EA\u68C0\uFF1A\u91CD\u65B0\u8BFB\u53D6\u672C\u6B21\u4FEE\u6539\u8FC7\u7684\u6587\u4EF6\uFF0C\u786E\u8BA4\u6539\u52A8\u6B63\u786E\u65E0\u8BEF\u3001\u7C7B\u578B\u517C\u5BB9\u3001\u6CA1\u6709\u9057\u6F0F\u3002\u5982\u6709\u95EE\u9898\u8BF7\u65B0\u589E todo \u4FEE\u590D\uFF1B\u786E\u8BA4\u65E0\u8BEF\u540E\u8F93\u51FA\u6700\u7EC8\u603B\u7ED3\u3002"});break}}catch(c){if(c instanceof DOMException&&c.name==="AbortError"||c instanceof Error&&c.name==="AbortError")return;this.#l.logError(c instanceof Error?c.message:String(c),c instanceof Error?c.stack:void 0),yield{type:"error",error:c instanceof Error?c:new Error(String(c))};return}let l=Date.now()-s;this.#l.logTurnDone(l,i),this.#b(),await this.#s.flush().catch(()=>{}),yield{type:"done",elapsed:l}}abort(){this.#u.abort(),this.#o&&(clearTimeout(this.#o),this.#o=null)}async flushLog(){await this.#l.flush()}async drainLog(){await this.#l.drain()}reset(){this.#e.length=0,this.#s.resetSession(),this.#m=[],this.#a.clear(),this.#g=null}getContextStats(){let t=tn(this.#n.model());return Cc(this.#e,t.contextWindow)}async compact(t){let n=tn(this.#n.model()),r=await _c(this.#e,{contextWindow:n.contextWindow,autoCompactRatio:this.#t.autoCompactRatio,preserveRecentRounds:this.#t.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#t.minTurnsToCompact,provider:this.#n,signal:this.#u.signal,...t?{onProgress:t}:{}});if(r.droppedTurns>0){this.#e.length=0;for(let o of r.messages)this.#e.push(o);this.#a.clear(),this.#b()}return r}async#C(){let n={contextWindow:tn(this.#n.model()).contextWindow,autoCompactRatio:this.#t.autoCompactRatio,preserveRecentRounds:this.#t.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#t.minTurnsToCompact,provider:this.#n,signal:this.#u.signal};if(!Hm(this.#e,n))return null;let r=await _c(this.#e,n);if(r.droppedTurns===0)return null;let o=r.summary.includes("\u672C\u5730\u6458\u8981")?"fallback":"summary";this.#e.length=0;for(let s of r.messages)this.#e.push(s);return this.#a.clear(),this.#b(),{...r,strategy:o}}async persistNow(){this.#o&&(clearTimeout(this.#o),this.#o=null),await this.#T()}#b(){if(this.#i){if(this.#o){this.#o.refresh();return}this.#o=setTimeout(()=>{this.#o=null,this.#T()},500),this.#o.unref()}}async#T(){if(!this.#i)return;let t={id:this.#p,title:this.#_(),createdAt:this.#d,updatedAt:Date.now(),cwd:this.#t.cwd,model:this.#n.model(),messages:this.#R(),totalCost:this.#s.sessionTotalCost};try{await this.#i.save(t)}catch(n){console.error("[Session] \u6301\u4E45\u5316\u5931\u8D25:",n)}}#_(){for(let t of this.#e)if(t.role==="user"&&t.content.trim())return t.content.trim().slice(0,40);return"\u65B0\u4F1A\u8BDD"}#R(){return this.#e.map((t,n)=>{let r=this.#a.get(n);return t.role==="user"&&r?{...t,checkpoint:r}:{...t}})}static async resume(t,n,r=[],o,s){let i=s?.store===!1?null:s?.store??new Fn;if(!i)throw new Error("resume \u9700\u8981\u542F\u7528\u6301\u4E45\u5316\uFF08options.store \u4E0D\u80FD\u4E3A false\uFF09");let a=await i.load(t);if(!a)throw new Error(`\u4F1A\u8BDD ${t} \u4E0D\u5B58\u5728`);let l=new e(n,r,o,{...s,sessionId:t,store:i});for(let c of a.messages)l.#e.push({role:c.role,content:c.content,toolCallId:c.toolCallId,name:c.name,toolCalls:c.toolCalls});for(let c=0;c<a.messages.length;c++){let u=a.messages[c]?.checkpoint;u&&l.#a.set(c,u)}return l.#d=a.createdAt,l}listCheckpoints(){let t=[];for(let[n,r]of this.#a){let o=this.#e[n];!o||o.role!=="user"||t.push({index:n,preview:o.content.slice(0,80),timestamp:r.timestamp,isGitRepo:r.isGitRepo})}return t.sort((n,r)=>n.index-r.index)}async rewind(t){if(t<0||t>=this.#e.length)return{ok:!1,error:`\u65E0\u6548\u7684\u6D88\u606F\u7D22\u5F15 ${t}`};let n=this.#e[t];if(!n||n.role!=="user")return{ok:!1,error:`\u7D22\u5F15 ${t} \u4E0D\u662F user \u6D88\u606F`};let r=this.#a.get(t);if(!r)return{ok:!1,error:"\u8BE5\u6D88\u606F\u6CA1\u6709\u68C0\u67E5\u70B9"};this.#e.length=t+1;let o=[];for(let[i,a]of this.#a)i>t&&(o.push(a),this.#a.delete(i));let s=!1;if(r.isGitRepo)try{r.stashSha?await Pc(r):await Lc(this.#t.cwd),s=!0}catch(i){return{ok:!1,error:`\u5BF9\u8BDD\u5DF2\u622A\u65AD\u4F46\u6587\u4EF6\u6062\u590D\u5931\u8D25\uFF1A${i instanceof Error?i.message:String(i)}`}}this.#a.delete(t);for(let i of o)Si(i);return this.#b(),{ok:!0,fileRestored:s}}hasCheckpoints(){return this.listCheckpoints().length>0}get gate(){return this.#t.gate}async delete(){this.#i&&await this.#i.delete(this.#p);for(let t of this.#a.values())Si(t);this.#a.clear(),this.#l.logSessionEnd(Date.now()-this.#d),await this.#l.flush()}#v(){return new hi({registry:this.#r,gate:this.#t.gate,baseCtx:{cwd:this.#t.cwd,signal:this.#u.signal,writeRoots:this.#t.writeRoots}})}#A(){let n=this.#r.list().map(a=>({name:a.name,description:a.description,parameters:a.parameters})),{catalog:r}=this.#y.length>0?yh(this.#y,{maxBytes:this.#S}):{catalog:[]},o=r.length>0?r.map(a=>({name:a.name,description:a.description,location:a.location})):void 0,s={model:this.#n.model(),maxToolRounds:this.#t.maxToolRounds,tools:n.length>0?n:void 0,projectContext:this.#t.projectContext??void 0,cwd:this.#t.cwd,availableSkills:o},i;return this.#f==="plan"?i=Mm(s):i=Nm(s),this.#c&&this.#c.items.length>0&&(i=i+`
571
575
 
572
- `+this.#l.toMarkdown()),i}#E(t){!this.#l||this.#l.items.length>0||this.#w||!t.some(r=>!r.name.startsWith("todo_"))||(this.#w=!0,this.#e.push({role:"user",content:`[\u7CFB\u7EDF\u63D0\u793A] \u4F60\u8FD8\u6CA1\u6709 todo \u8FC7\uFF0C\u4F46\u5DF2\u7ECF\u8C03\u4E86\u5177\u4F53\u5DE5\u5177\u3002
576
+ `+this.#c.toMarkdown()),i}#E(t){!this.#c||this.#c.items.length>0||this.#w||!t.some(r=>!r.name.startsWith("todo_"))||(this.#w=!0,this.#e.push({role:"user",content:`[\u7CFB\u7EDF\u63D0\u793A] \u4F60\u8FD8\u6CA1\u6709 todo \u8FC7\uFF0C\u4F46\u5DF2\u7ECF\u8C03\u4E86\u5177\u4F53\u5DE5\u5177\u3002
573
577
  \u8BF7\u56DE\u987E\u4F60\u521A\u505A\u7684\u4E8B\uFF1A\u8FD9\u662F\u300C\u7B80\u5355\u300D\u4EFB\u52A1\uFF081 \u8F6E 1 \u5DE5\u5177\u80FD\u5B8C\u6210\uFF09\u8FD8\u662F\u300C\u590D\u6742\u300D\u4EFB\u52A1\uFF1F
574
578
  \u5982\u679C\u662F\u590D\u6742\uFF08\u6539\u4E86/\u521B\u5EFA\u4E86/\u8981\u8BFB\u540E\u6539/\u8DE8\u591A\u79CD\u5DE5\u5177\uFF09\uFF0C\u8BF7\u505C\u4E0B\uFF0C\u5148\u8C03 todo_add \u62C6\u89E3 3-7 \u6B65\u518D\u7EE7\u7EED\u3002
575
579
  \u5982\u679C\u662F\u7B80\u5355\uFF0C\u5FFD\u7565\u672C\u63D0\u793A\u3002
576
- \uFF08\u672C\u63D0\u793A\u672C\u4F1A\u8BDD\u4EC5\u53D1\u4E00\u6B21\uFF0C\u540E\u7EED\u4E0D\u518D\u63D0\u9192\u3002\uFF09`}))}};p();p();var zc=[[0,255,65],[0,255,255],[189,147,249]],qc=[[255,245,180],[255,210,80],[255,150,50]],Kc=[[255,191,0],[210,140,60],[175,70,40]],Un={idlePhaseStep:.06,idleInterval:200,streamingPhaseStep:.2,streamingInterval:200,cmdTipPhaseStep:.2,cmdTipInterval:200},sT=new Set([" ","~",".","\u3002","\uFF01","\u{1F447}"]);function iT(e,t){let n=t.length,r=e*(n-1),o=Math.min(Math.floor(r),n-2),s=r-o,i=t[o],a=t[o+1];if(!i||!a)return"#808080";let l=Math.round(i[0]+(a[0]-i[0])*s),c=Math.round(i[1]+(a[1]-i[1])*s),u=Math.round(i[2]+(a[2]-i[2])*s);return`#${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}function Wn(e,t,n){let r=e.length;return r===0?[]:e.split("").map((o,s)=>{if(sT.has(o))return"";let i=(s/(r-1)+t)%1;return iT(i,n)})}p();function fh(e){return e.map(t=>t.trim()).filter(t=>t.length>0).join(`
577
- `)}p();import{Box as aT,Text as lT}from"ink";import{useEffect as cT,useRef as uT,useState as dT}from"react";import{jsx as gT,jsxs as hT}from"react/jsx-runtime";var pT=[" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584 \u2584\u2584"," \u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2580\u2588\u2588\u2588\u2580\u2580","\u2580\u2588 \u2580\u2580\u2588\u2588\u2588\u2584 \u2588\u2588\u2588\u2588"," \u2580\u2588\u2584 \u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2580"," \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2580\u2580\u2580\u2580\u2580"],Xc=22,fT=120,mT="#6185f6";function mh({panelWidth:e}){let t=uT(e),[n,r]=dT(0);cT(()=>{let l=setInterval(()=>{t.current-=1,t.current<=-Xc&&(t.current=e),r(c=>c+1)},fT);return()=>clearInterval(l)},[e]);let o=t.current;if(o>=e)return null;let s=Math.max(0,-o),i=Math.max(0,o+Xc-e),a=Math.max(0,o);return gT(aT,{flexDirection:"column",alignItems:"flex-start",children:pT.map((l,c)=>hT(lT,{color:mT,bold:!0,children:[" ".repeat(a),l.slice(s,Xc-i)]},c))})}p();import{Box as ki,Text as Qe,useInput as yT}from"ink";import{useState as xT}from"react";import{jsx as gt,jsxs as Sr}from"react/jsx-runtime";var Eo=[{number:"1",value:"yes",label:"Yes \u4EC5\u672C\u6B21",color:"green"},{number:"2",value:"no",label:"No \u62D2\u7EDD",color:"red"},{number:"3",value:"always",label:"Always \u672C\u4F1A\u8BDD\u540C\u7C7B\u64CD\u4F5C\u81EA\u52A8\u653E\u884C",color:"cyan"}];function hh({pending:e,onResponse:t}){let[n,r]=xT(0);if(yT((s,i)=>{if(e){if(i.escape){t("no");return}if(i.return){let a=Eo[n];a&&t(a.value);return}if(i.leftArrow){r(a=>(a-1+Eo.length)%Eo.length);return}if(i.rightArrow){r(a=>(a+1)%Eo.length);return}if(s==="1"){t("yes");return}if(s==="2"){t("no");return}if(s==="3"){t("always");return}}},{isActive:!!e}),!e)return null;let{ctx:o}=e;return Sr(ki,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,marginTop:1,children:[gt(Qe,{bold:!0,color:"yellow",children:"\u{1F510} \u6743\u9650\u5BA1\u6279"}),Sr(ki,{flexDirection:"column",marginLeft:2,marginTop:1,children:[Sr(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u5DE5\u5177\uFF1A"}),gt(Qe,{bold:!0,children:o.toolName}),gt(Qe,{dimColor:!0,children:" \uFF08\u5199\u64CD\u4F5C\u786E\u8BA4\uFF09"})]}),Sr(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u539F\u56E0\uFF1A"}),gt(Qe,{children:o.reason})]}),o.toolName==="bash"&&Sr(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u547D\u4EE4\uFF1A"}),gt(Qe,{color:"cyan",children:bT(o)})]})]}),gt(ki,{flexDirection:"row",marginTop:1,gap:2,children:Eo.map((s,i)=>Sr(Qe,{color:i===n?s.color:"gray",bold:i===n,inverse:i===n,children:[" ","[",s.number,"] ",s.label," "]},s.value))}),gt(ki,{marginTop:1,children:gt(Qe,{dimColor:!0,children:"\u2190/\u2192 \u5207\u6362 \xB7 1/2/3 \u76F4\u63A5\u9009 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u62D2\u7EDD"})})]})}function bT(e){if(typeof e.args!="object"||e.args===null)return"(\u65E0\u53C2\u6570)";let n=e.args.command;return typeof n!="string"?"(\u975E\u547D\u4EE4)":n.length<=60?n:n.slice(0,57)+"..."}p();p();import{EventEmitter as CT}from"events";import{randomUUID as yh}from"crypto";import _T from"ws";p();import{gunzipSync as wT,gzipSync as Jc}from"zlib";var kT=1,ST=1,mn={FULL_REQUEST:1,AUDIO_ONLY:2,SERVER_RESPONSE:9,ERROR:15},Hn={NO_SEQUENCE:0,POSITIVE_SEQUENCE:1,LAST_PACKET_NO_SEQ:2,NEGATIVE_SEQUENCE:3,HAS_EVENT:4},Zc={JSON:1},Yc={GZIP:1};function Si(e,t,n,r){let o=Buffer.alloc(4);o[0]=kT<<4|ST,o[1]=e<<4|t&15,o[2]=Zc.JSON<<4|Yc.GZIP,o[3]=0;let s=Buffer.alloc(4);s.writeInt32BE(n);let i=Buffer.alloc(4);return i.writeUInt32BE(r.length),Buffer.concat([o,s,i,r])}function Qc(e,t){let n=Buffer.from(JSON.stringify(e),"utf8"),r=Jc(n);return Si(mn.FULL_REQUEST,Hn.POSITIVE_SEQUENCE,t,r)}function eu(e,t){return Si(mn.AUDIO_ONLY,Hn.POSITIVE_SEQUENCE,t,Jc(e))}function tu(e){return Si(mn.AUDIO_ONLY,Hn.NEGATIVE_SEQUENCE,-Math.abs(e),Jc(Buffer.alloc(0)))}function nu(e){let t={messageType:"unknown",seq:0,isLast:!1,event:0,code:0,body:null,raw:e};if(e.length<4)return t;let n=e[0],r=e[1],o=e[2],s=n&15,i=r>>4,a=r&15,l=o>>4,c=o&15,u=i===mn.SERVER_RESPONSE?"full_response":i===mn.AUDIO_ONLY?"audio_only":i===mn.ERROR?"error":"unknown",d=e.subarray(s*4),m=0;a&Hn.POSITIVE_SEQUENCE&&(m=d.readInt32BE(0),d=d.subarray(4));let h=(a&Hn.LAST_PACKET_NO_SEQ)!==0,f=0;a&Hn.HAS_EVENT&&(f=d.readInt32BE(0),d=d.subarray(4));let g=0;i===mn.ERROR&&(g=d.readInt32BE(0),d=d.subarray(4)),d.length>=4&&(d=d.subarray(4));let b=TT(d,c,l);return{messageType:u,seq:m,isLast:h,event:f,code:g,body:b,raw:e}}function TT(e,t,n){if(e.length===0)return null;let r=e;if(t===Yc.GZIP)try{r=wT(e)}catch{return null}return n===Zc.JSON||r.length>0&&r[0]===123?gh(r):null}function gh(e){try{return JSON.parse(e.toString("utf8"))}catch{return null}}function ru(e){return{user:{uid:e.user.uid,platform:e.user.platform??"Linux",sdk_version:e.user.sdkVersion??"0.1.x"},audio:{format:e.audio.format,codec:e.audio.codec,rate:e.audio.rate,bits:e.audio.bits,channel:e.audio.channel},request:{model_name:e.request.modelName,enable_itn:e.request.enableItn,enable_punc:e.request.enablePunc,enable_ddc:e.request.enableDdc,show_utterances:e.request.showUtterances}}}var vT="wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async",RT="volc.bigasr.sauc.duration",AT=(e,t)=>Reflect.construct(_T,[e,t]),Ti=class extends CT{config;url;resourceId;ws=null;seq=1;started=!1;ended=!1;opened=!1;constructor(t){super(),this.config=t,this.url=t.url??vT,this.resourceId=t.resourceId??RT}connect(){return new Promise((t,n)=>{if(this.ws){n(new Error("VolcAsrClient: \u91CD\u590D\u8C03\u7528 connect()"));return}let r={"X-Api-Resource-Id":this.resourceId,"X-Api-Request-Id":yh(),"X-Api-Access-Key":this.config.accessKey,"X-Api-App-Key":this.config.appId,"X-Api-Sequence":"-1"},o=this.config.wsFactory??AT,s;try{s=o(this.url,{headers:r})}catch(l){n(l instanceof Error?l:new Error(String(l)));return}this.ws=s;let i=()=>{if(!this.opened){this.opened=!0;try{this.sendStart(),this.emit("log","\u2705 \u63E1\u624B\u6210\u529F\uFF0C\u8D77\u59CB\u5305\u5DF2\u53D1"),this.emit("open"),t()}catch(l){n(l instanceof Error?l:new Error(String(l)))}}},a=l=>{this.ended||(this.opened?this.emit("error",-1,l.message):n(l))};s.on("open",i),s.on("error",a),s.on("message",l=>this.onMessage(l)),s.on("close",(l,c)=>this.onClose(l,c))})}sendAudio(t){if(!this.ws||!this.started||this.ended)return;let n=eu(t,this.seq++);this.ws.send(n)}end(){if(!this.ws||this.ended)return;this.ended=!0;let t=tu(this.seq);this.ws.send(t),setTimeout(()=>{try{this.ws?.close()}catch{}},1500)}abort(){if(this.ws){this.ended=!0;try{this.ws.close()}catch{}}}sendStart(){if(!this.ws)return;let t=ru({user:{uid:`dskcode-cli-${yh().slice(0,8)}`},audio:{format:this.config.format??"pcm",codec:this.config.codec??"raw",rate:this.config.sampleRate??16e3,bits:this.config.bits??16,channel:this.config.channel??1},request:{modelName:"bigmodel",enableItn:this.config.enableItn??!0,enablePunc:this.config.enablePunc??!0,enableDdc:this.config.enableDdc??!1,showUtterances:this.config.showUtterances??!0}}),n=Qc(t,this.seq++);this.ws.send(n),this.started=!0}onMessage(t){let n=typeof t=="string"?Buffer.from(t):t,r=nu(n);this.handleResponse(r)}handleResponse(t){if(t.messageType==="error"){let r=t.body?.error??`ASR error code=${t.code}`;this.emit("error",t.code,r);return}if(t.messageType!=="full_response")return;let n=t.body?.result;if(n)if(n.utterances&&n.utterances.length>0)for(let r of n.utterances)r.definite?this.emit("final",r.text):this.emit("partial",r.text);else n.text&&this.emit("partial",n.text)}onClose(t,n){this.ws=null,this.emit("close"),this.emit("log",`\u8FDE\u63A5\u5173\u95ED code=${t} reason=${n?.toString("utf8")||""}`)}};function ou(e){return new Ti(e)}p();import{EventEmitter as $T}from"events";p();import{spawn as ET}from"child_process";import{platform as su}from"os";var iu=(e,t)=>ET(e,t,{stdio:["ignore","pipe","pipe"]}),IT={ffmpeg:["D:\\ffmpeg\\ffmpeg-8.1.2-essentials_build\\bin\\ffmpeg.exe","C:\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files (x86)\\ffmpeg\\bin\\ffmpeg.exe","/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg","/usr/bin/ffmpeg"],sox:["C:\\Program Files (x86)\\sox-14-4-2\\sox.exe","/opt/homebrew/bin/sox","/usr/local/bin/sox","/usr/bin/sox"],arecord:["/usr/bin/arecord","/usr/local/bin/arecord"]};function PT(e,t,n){return new Promise(r=>{let o;try{o=t(e,["-version"])}catch{r(!1);return}let s=setTimeout(()=>{try{o.kill()}catch{}r(!1)},n);o.on("close",i=>{clearTimeout(s),r(i===0)}),o.on("error",()=>{clearTimeout(s),r(!1)})})}var xh={name:"ffmpeg",binary:"ffmpeg",buildArgs:e=>{let t=su();return t==="win32"?["-f","dshow","-i",`audio=${e??"Microphone"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:t==="darwin"?["-f","avfoundation","-i",`:${e??"0"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:["-f","alsa","-i",e??"default","-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]},listWindowsAudioDevices:async(e,t)=>new Promise(n=>{let r="",o;try{o=e(t,["-list_devices","true","-f","dshow","-i","dummy"])}catch{n(null);return}o.stderr?.on("data",s=>{r+=s.toString("utf8")}),o.on("close",()=>{let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)}),o.on("error",()=>n(null)),setTimeout(()=>{try{o.kill()}catch{}let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)},1e4)})},bh={name:"sox",binary:"sox",buildArgs:e=>su()==="win32"||e!==void 0?["-q","-r","16000","-c","1","-t","waveaudio",e??"-d","-t","raw","-"]:["-q","-r","16000","-c","1","-t","waveaudio","-d","-t","raw","-"]},wh={name:"arecord",binary:"arecord",buildArgs:e=>["-q","-f","S16_LE","-r","16000","-c","1",e?["-D",e]:[],"-t","raw"].flat()};async function au(e,t){let n=e==="auto"?[xh,bh,wh]:[xh,bh,wh].filter(r=>r.name===e);for(let r of n){let o=await LT(r.binary,t);if(o)return{...r,binary:o}}throw new Error(`\u672A\u627E\u5230\u53EF\u7528\u7684\u5F55\u97F3\u9A71\u52A8\uFF08driver=${e}\uFF09\u3002\u8BF7\u5B89\u88C5 ffmpeg / sox / arecord \u4E4B\u4E00\u3002\u8BE6\u89C1 docs/\u8BED\u97F3\u8BC6\u522Bvoice\u547D\u4EE4\u63A5\u5165.md \xA712.1\u3002`)}async function LT(e,t){let n=IT[e]??[];for(let r of[e,...n])if(await PT(r,t,1500))return r;return null}async function kh(e,t){return su()!=="win32"||!e.listWindowsAudioDevices?null:e.listWindowsAudioDevices(t,e.binary)}var OT=200,DT=60,NT=16e3,MT=16,BT=1,FT=NT*(MT/8)*BT,Ci=class extends $T{options;proc=null;driver=null;buf=[];bufSize=0;chunkBytes;started=!1;stopped=!1;maxDurationTimer=null;constructor(t={}){super(),this.options={chunkMs:t.chunkMs??OT,maxDurationSec:t.maxDurationSec??DT,driver:t.driver??"auto",deviceName:t.deviceName,spawner:t.spawner},this.chunkBytes=Math.floor(FT*this.options.chunkMs/1e3)}async start(){if(this.started)throw new Error("VoiceCapture: \u91CD\u590D\u8C03\u7528 start()");this.started=!0,this.stopped=!1;let t=this.options.spawner??iu;this.driver=await au(this.options.driver,t),this.emit("log",`\u4F7F\u7528\u5F55\u97F3\u9A71\u52A8: ${this.driver.name}`);let n=this.options.deviceName;if(!n){let s=await kh(this.driver,t);s&&(n=s,this.emit("log",`\u68C0\u6D4B\u5230\u9EA6\u514B\u98CE\u8BBE\u5907: ${n}`))}let r=this.driver.buildArgs(n);this.emit("log",`\u542F\u52A8\u5B50\u8FDB\u7A0B: ${this.driver.binary} ${r.join(" ")}`);let o;try{o=t(this.driver.binary,r)}catch(s){throw this.started=!1,s instanceof Error?s:new Error(String(s))}this.proc=o,o.stdout?.on("data",s=>this.ingest(s)),o.on("error",s=>{this.emit("error",s)}),o.on("close",s=>{if(this.bufSize>0){let i=Buffer.concat(this.buf,this.bufSize);this.emit("data",i),this.buf=[],this.bufSize=0}if(this.started=!1,this.proc=null,!this.stopped&&s!==0&&s!==null){this.emit("error",new Error(`\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5F02\u5E38\u9000\u51FA code=${s}\uFF08\u53EF\u80FD\u662F\u8BBE\u5907\u540D\u9519\u8BEF\u6216\u6743\u9650\u88AB\u62D2\uFF09`));return}this.emit("end")}),this.options.maxDurationSec>0&&(this.maxDurationTimer=setTimeout(()=>{this.emit("log",`\u5DF2\u8FBE ${this.options.maxDurationSec}s \u4E0A\u9650\uFF0C\u81EA\u52A8\u505C\u6B62`),this.stop()},this.options.maxDurationSec*1e3))}stop(){if(!(!this.proc||this.stopped)){this.stopped=!0,this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null);try{this.proc.kill()}catch(t){this.emit("error",t instanceof Error?t:new Error(`kill \u5B50\u8FDB\u7A0B\u5931\u8D25: ${String(t)}`))}}}abort(){if(this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.proc)try{this.proc.kill()}catch{}this.started=!1}isRecording(){return this.started}ingest(t){for(this.buf.push(t),this.bufSize+=t.length;this.bufSize>=this.chunkBytes;){let n=Buffer.concat(this.buf),r=n.subarray(0,this.chunkBytes);this.buf=[n.subarray(this.chunkBytes)],this.bufSize=n.length-this.chunkBytes,this.emit("data",r)}}};function lu(e={}){return new Ci(e)}p();import{EventEmitter as GT}from"events";var _i=class extends GT{config;phase="idle";asr=null;cap=null;connecting=!1;lastError=null;constructor(t){super(),this.config=t}async start(){if(this.phase!=="idle"&&this.phase!=="error"){this.emit("log",`\u5DF2\u7ECF\u5728 ${this.phase} \u72B6\u6001\uFF0C\u5FFD\u7565 start()`);return}this.connecting=!0,this.lastError=null,this.setPhase("connecting");let n=(this.config.asrFactory??(()=>jT(this.config.asr)))();this.asr=n,this.bindAsrEvents(n);try{await n.connect()}catch(s){this.lastError=`\u8FDE\u63A5 ASR \u5931\u8D25: ${Sh(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}let o=(this.config.recorderOptions?.captureFactory??UT)();this.cap=o,this.bindCapEvents(o);try{await o.start()}catch(s){this.lastError=`\u542F\u52A8\u5F55\u97F3\u5931\u8D25: ${Sh(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}this.connecting=!1,this.setPhase("recording")}stop(){if(this.phase!=="recording"&&this.phase!=="connecting"&&this.phase!=="finalizing"){this.emit("log",`\u5F53\u524D phase=${this.phase}\uFF0C\u5FFD\u7565 stop()`);return}if(this.phase==="finalizing"){this.abort();return}this.setPhase("finalizing"),this.cap&&this.cap.isRecording()&&this.cap.stop()}abort(){this.setPhase("error"),this.cleanup()}getPhase(){return this.phase}getLastError(){return this.lastError}setPhase(t){this.phase!==t&&(this.phase=t,this.emit("phase",t))}bindAsrEvents(t){t.on("partial",n=>this.emit("partial",n)),t.on("final",n=>this.emit("final",n)),t.on("error",(n,r)=>{this.lastError=`ASR \u9519\u8BEF: ${r}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("close",()=>{this.emit("log","ASR WebSocket \u5DF2\u5173\u95ED"),(this.phase==="recording"||this.phase==="finalizing")&&(this.setPhase("idle"),this.cleanup())}),t.on("log",n=>this.emit("log",`[asr] ${n}`))}bindCapEvents(t){t.on("data",n=>{this.asr&&this.phase==="recording"&&this.asr.sendAudio(n)}),t.on("error",n=>{this.lastError=`\u5F55\u97F3\u9519\u8BEF: ${n.message}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("end",()=>{if(this.emit("log","\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5DF2\u7ED3\u675F"),this.asr)try{this.asr.end()}catch{}}),t.on("log",n=>this.emit("log",`[rec] ${n}`))}cleanup(){try{this.asr?.abort()}catch{}try{this.cap?.abort()}catch{}this.asr=null,this.cap=null}};function jT(e){return ou({appId:e.appId,accessKey:e.accessKey,resourceId:e.resourceId})}function UT(){return lu()}function Sh(e){return e instanceof Error?e.message:String(e)}function cu(e){return new _i(e)}import{Fragment as vh,jsx as O,jsxs as K}from"react/jsx-runtime";var uu={thinking:{icon:"\u{1F9E0}",label:"\u601D\u8003\u4E2D",color:"#ff9800"},generating:{icon:"\u2728",label:"\u751F\u6210\u4E2D",color:"#00ff41"},calling_tools:{icon:"\u{1F6E0}",label:"\u8C03\u7528\u5DE5\u5177",color:"#f59e0b"},executing_tools:{icon:"\u26A1",label:"\u6267\u884C\u5DE5\u5177",color:"#00ffff"}};function zT(e){return e==="edit_file"||e==="write_file"||e==="multi_edit"||e==="delete_range"}function Ch(e){if(!e)return;let t=e.filter(n=>!n.name.startsWith("todo_"));return t.length>0?t:void 0}var fu=new Map;function $e(e,t){fu.set(e,t)}function Rh(){return fu}$e("/exit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/quit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/help",{desc:"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F",handler:()=>{let e=Rh(),t=["\u53EF\u7528\u547D\u4EE4\uFF1A"];for(let[n,r]of e)t.push(` ${n.padEnd(16)}${r.desc}`);return{kind:"text",content:t.join(`
578
- `)}}});$e("/clear",{desc:"\u6E05\u7A7A\u5BF9\u8BDD\u5386\u53F2",handler:()=>({kind:"clear"})});$e("/version",{desc:"\u663E\u793A\u7248\u672C\u4FE1\u606F",handler:()=>({kind:"text",content:`dskcode v${So}`})});$e("/model",{desc:"\u5207\u6362\u6A21\u578B",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /model \u8FDB\u5165\u9009\u62E9\u754C\u9762"})});$e("/thinking",{desc:"\u5207\u6362\u6DF1\u5EA6\u601D\u8003\u6A21\u5F0F",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /thinking \u5207\u6362"})});$e("/effort",{desc:"\u5207\u6362\u63A8\u7406\u7B49\u7EA7 High/Max",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /effort \u5207\u6362"})});$e("/game",{desc:"\u542F\u52A8\u6E38\u620F",handler:()=>({kind:"navigate",target:"game"})});$e("/stock",{desc:"\u67E5\u770B\u80A1\u7968\u884C\u60C5",handler:()=>({kind:"navigate",target:"stock"})});$e("/plan",{desc:"\u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08Shift+Tab\uFF09",handler:()=>({kind:"text",content:"\u8F93\u5165 /plan \u6216\u6309 Shift+Tab \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F"})});$e("/code",{desc:"\u5207\u6362\u56DE\u4EE3\u7801\u6A21\u5F0F\uFF08Shift+Tab\uFF09",handler:()=>({kind:"text",content:"\u8F93\u5165 /code \u6216\u6309 Shift+Tab \u5207\u6362\u56DE\u4EE3\u7801\u6A21\u5F0F"})});$e("/rewind",{desc:"\u56DE\u9000\u5230\u5386\u53F2\u68C0\u67E5\u70B9\uFF081 = \u6700\u65B0\uFF09",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /rewind \u67E5\u770B\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u5217\u8868\uFF0C\u6216 /rewind <\u5E8F\u53F7> \u76F4\u63A5\u56DE\u9000\uFF081 = \u6700\u65B0\uFF0C2 = \u4E0A\u4E00\u6B21\uFF0C\u4F9D\u6B64\u7C7B\u63A8\uFF09"})});$e("/compact",{desc:"\u538B\u7F29\u4E0A\u4E0B\u6587\uFF1A\u6458\u8981\u65E7\u56DE\u5408\u5E76\u4FDD\u7559\u6700\u8FD1 N \u8F6E",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /compact \u624B\u52A8\u538B\u7F29\u4E0A\u4E0B\u6587\uFF08\u9700\u5F53\u524D\u4E0D\u5904\u4E8E\u751F\u6210\u4E2D\uFF09"})});$e("/voice",{desc:"\u8BED\u97F3\u8F93\u5165\uFF08F2 \u6216 /voice \u542F\u52A8\uFF0CESC \u53D6\u6D88\uFF09",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /voice \u6216\u6309 F2 \u542F\u52A8\u8BED\u97F3\u8BC6\u522B"})});$e("/permissions",{desc:"\u67E5\u770B\u5F53\u524D\u6743\u9650\u89C4\u5219\u4E0E\u4F1A\u8BDD grants\uFF08v0.6\uFF09",handler:()=>({kind:"permissions"})});var qT=["\u8BA9\u5B50\u5F39\u98DE\u4E00\u4F1A\u513F...","\u9A6C\u4E0A\u5C31\u597D...","\u6B63\u5728\u618B\u5927\u62DB...","\u7A0D\u7B49\u4E00\u4E0B\u4E0B~","\u7801\u5B57\u4E2D...","\u8111\u5B50\u8F6C\u5F97\u98DE\u5FEB..."],_h=["\u60F3\u5E72\u5565\uFF1F\u76F4\u63A5\u8BF4~","\u6765\u5427\uFF0C\u5429\u5490\u70B9\u5565","\u968F\u65F6\u5F85\u547D...","\u6233\u8FD9\u91CC\u5F00\u804A...","\u7B49\u4F60\u5F00\u53E3...","\u5C3D\u7BA1\u4F7F\u5524~"];function du(e){return e[Math.floor(Math.random()*e.length)]}function mu({skillCount:e,skills:t=[],files:n=[],toolCount:r,verbose:o,apiKey:s,baseUrl:i,costTracker:a,model:l="deepseek-v4-flash",permissionsConfig:c,voiceConfig:u,configReloadEpoch:d,thinkingEnabledFromConfig:m,thinkingEffortFromConfig:h,verboseFromConfig:f,onLaunchGame:g,onLaunchStock:b}){let S=(typeof process.stdout.columns=="number"?process.stdout.columns:80)-2,v=Math.max(Math.floor(S/3),30),_=S-v-1,[E,M]=z(0),[U,T]=z([]),[N,F]=z(0),[q,$]=z(""),[oe,le]=z(null),ee=ae(null),[W,se]=z(null),[ce,zn]=z(!1),[qn,Eu]=z(null),[Pe,hg]=z("idle"),[$i,Oi]=z(""),Oo=ae(null),[Ar,Di]=z(null),[ie,Do]=z(!1),[Er,Pt]=z(null),[hn,Ni]=z(""),[gn,gg]=z(()=>du(_h)),[Mi,Bi]=z([]),No=ae(0),[Fi,Gi]=z([]),Mo=ae(0),[ji,Ui]=z(""),[Wi,Hi]=z([]),[Bo,Vi]=z([]),[yg,Iu]=z(()=>new Map),[Pu,Lu]=z(void 0),[QC,$u]=z(void 0),[Ou,Du]=z(void 0),[tt,zi]=z(l),[Nu,Mu]=z(void 0),[qi,Fo]=z(void 0),[yn,Go]=z([]),[e_,t_]=z(""),[Bu,jo]=z(!0),Xt=ae(null),Ir=ae(-1),[Jt,Uo]=z("code"),[Kn,Fu]=z(!0),[Pr,Gu]=z("high"),[Ki]=z("text"),[Lr,Wo]=z(void 0),ju=Th(()=>U.reduce((C,k)=>k.assistantDetail?.cost?C+k.assistantDetail.cost:C,0),[U]),$r=U.length>0,xg=ie&&Wi.length>0,bt=Array.from(Rh()).filter(([C])=>C!=="/exit"&&C!=="/quit").map(([C,k])=>({name:C,desc:k.desc})),[Ho,bg]=z(0),[Xi,Ji]=z([]),Vo=ae(0),[Or,Zi]=z(0),[Xn,zo]=z(0),[Uu,Yi]=z(0),[xn,qo]=z(!1),[Dr,Ko]=z(0),[bn,wg]=z([]),[Qi,Wu]=z(!1),[Nr,Xo]=z(!1),[Hu,ea]=z("idle"),ta=ae(!1),wt=ae(null),[Zt,na]=z(!1),[Jo,Zo]=z(0),Yt=["deepseek-v4-flash","deepseek-v4-pro"],[Vu,Qt]=z({phase:"idle",progress:null}),Ne=ae(null),Jn=ae(void 0),ue=ae(null),ra=ae(null),zu=ae([]),Yo=ae(""),Qo=ae([]),es=ae([]),ts=ae(new Map),[kg,qu]=z(null),oa=ae(null),sa=ct(C=>new Promise(k=>{oa.current=k,qu({ctx:C,resolve:k})}),[]),Sg=ct(C=>{let k=oa.current;oa.current=null,qu(null),k?.(C)},[]),ia=ae(void 0),aa=ae(void 0),la=ae(void 0),ca=ae(void 0),ns=ae(void 0);Se(()=>{Zi(0),zo(0)},[q]),Se(()=>()=>{wt.current&&(clearTimeout(wt.current),wt.current=null),Ne.current&&(clearTimeout(Ne.current),Ne.current=null),ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),Se(()=>{if(oe==null)return;let C=setTimeout(()=>le(null),5e3);return ee.current=C,()=>clearTimeout(C)},[oe]),Se(()=>{d===void 0||d===0||le(Date.now())},[d]),Se(()=>{l&&zi(l)},[l]),Se(()=>{m!==void 0&&Fu(m)},[m]),Se(()=>{h!==void 0&&Gu(h)},[h]),Se(()=>{let C=()=>{let I=ue.current;if(!I){Di(null);return}try{let V=I.getContextStats();Di({tokens:V.estimatedTokens,ratio:V.ratio,contextWindow:V.contextWindow})}catch{Di(null)}};C();let k=setInterval(C,3e3);return()=>clearInterval(k)},[]),Se(()=>{if(Xt.current&&(clearTimeout(Xt.current),Xt.current=null),yn.length===0){jo(!1);return}yn.some(k=>k.status==="pending"||k.status==="running"||k.status==="failed")?jo(!0):(Ir.current=Math.max(...yn.map(k=>k.id)),Xt.current=setTimeout(()=>{jo(!1),Xt.current=null},2e3))},[yn]);let ua=ct(C=>{let k=C.match(/(?:^|\s)\/([^/]*)$/);if(!k)return[];let I=k[1].toLowerCase().trim();if(!I)return C.startsWith("/")?t.slice(0,3):[];let V=t.filter(P=>P.name.toLowerCase().includes(I)).slice(0,3);return V.some(P=>P.name.toLowerCase()===I)?[]:V},[t]),Ku=ct(C=>bo(C,n)??[],[n]),rs=ct((C,k)=>{let I=bo(C,n);if(!I||I.length===0)return!1;let V=I[k];if(!V)return!1;let P=C.lastIndexOf("@");return P<0?!1:($(C.slice(0,P)+"@"+V+" "),Yi(te=>te+1),zo(0),!0)},[n]);function Tg(C){let k=[];for(let I of C.messages)I.role==="user"?k.push({role:"user",content:I.content}):I.role==="assistant"?k.push({role:"assistant",content:I.content,assistantDetail:{content:I.content,toolCalls:Ch(I.toolCalls)}}):I.role==="tool"&&k.push({role:"tool",content:I.content});T(k),F(I=>I+1)}let da=ct(async(C,k)=>{let I=ue.current;if(I){Wu(!0),Do(!0),Pt("thinking"),Ni("\u23EA \u6B63\u5728\u56DE\u9000\u5230\u68C0\u67E5\u70B9\u2026"),$("");try{let V=await I.rewind(C.index);if(V.ok){Tg(I);let P=V.fileRestored?"\uFF0C\u5DE5\u4F5C\u533A\u6587\u4EF6\u5DF2\u6062\u590D":"\uFF08\u4EC5\u5BF9\u8BDD\u56DE\u9000\uFF0C\u672A\u6062\u590D\u6587\u4EF6\uFF09";T(te=>[...te,{role:"assistant",content:`\u23EA \u5DF2\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #${k}${P}\u3002`}])}else T(P=>[...P,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5931\u8D25\uFF1A${V.error}`}])}catch(V){let P=V instanceof Error?V.message:String(V);T(te=>[...te,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5F02\u5E38\uFF1A${P}`}])}finally{Wu(!1),Do(!1),Pt(null),Ni("")}}},[]),pa=ct(async()=>{if(!u||!u.resolved){let k=u?.missing?.join(", ")??"appId, accessKey";T(I=>[...I,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u672A\u914D\u7F6E\uFF08\u7F3A ${k}\uFF09\u3002
580
+ \uFF08\u672C\u63D0\u793A\u672C\u4F1A\u8BDD\u4EC5\u53D1\u4E00\u6B21\uFF0C\u540E\u7EED\u4E0D\u518D\u63D0\u9192\u3002\uFF09`}))}};p();p();var Zc=[[0,255,65],[0,255,255],[189,147,249]],Yc=[[255,245,180],[255,210,80],[255,150,50]],Qc=[[255,191,0],[210,140,60],[175,70,40]],jn={idlePhaseStep:.06,idleInterval:200,streamingPhaseStep:.2,streamingInterval:200,cmdTipPhaseStep:.2,cmdTipInterval:200},ST=new Set([" ","~",".","\u3002","\uFF01","\u{1F447}"]);function TT(e,t){let n=t.length,r=e*(n-1),o=Math.min(Math.floor(r),n-2),s=r-o,i=t[o],a=t[o+1];if(!i||!a)return"#808080";let l=Math.round(i[0]+(a[0]-i[0])*s),c=Math.round(i[1]+(a[1]-i[1])*s),u=Math.round(i[2]+(a[2]-i[2])*s);return`#${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}function Un(e,t,n){let r=e.length;return r===0?[]:e.split("").map((o,s)=>{if(ST.has(o))return"";let i=(s/(r-1)+t)%1;return TT(i,n)})}p();function wh(e){return e.map(t=>t.trim()).filter(t=>t.length>0).join(`
581
+ `)}p();import{Box as CT,Text as _T}from"ink";import{useEffect as RT,useRef as vT,useState as AT}from"react";import{jsx as $T,jsxs as LT}from"react/jsx-runtime";var ET=[" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584 \u2584\u2584"," \u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2580\u2588\u2588\u2588\u2580\u2580","\u2580\u2588 \u2580\u2580\u2588\u2588\u2588\u2584 \u2588\u2588\u2588\u2588"," \u2580\u2588\u2584 \u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2580"," \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2580\u2580\u2580\u2580\u2580"],eu=22,IT=120,PT="#6185f6";function kh({panelWidth:e}){let t=vT(e),[n,r]=AT(0);RT(()=>{let l=setInterval(()=>{t.current-=1,t.current<=-eu&&(t.current=e),r(c=>c+1)},IT);return()=>clearInterval(l)},[e]);let o=t.current;if(o>=e)return null;let s=Math.max(0,-o),i=Math.max(0,o+eu-e),a=Math.max(0,o);return $T(CT,{flexDirection:"column",alignItems:"flex-start",children:ET.map((l,c)=>LT(_T,{color:PT,bold:!0,children:[" ".repeat(a),l.slice(s,eu-i)]},c))})}p();import{Box as _i,Text as Qe,useInput as OT}from"ink";import{useState as DT}from"react";import{jsx as gt,jsxs as br}from"react/jsx-runtime";var Po=[{number:"1",value:"yes",label:"Yes \u4EC5\u672C\u6B21",color:"green"},{number:"2",value:"no",label:"No \u62D2\u7EDD",color:"red"},{number:"3",value:"always",label:"Always \u672C\u4F1A\u8BDD\u540C\u7C7B\u64CD\u4F5C\u81EA\u52A8\u653E\u884C",color:"cyan"}];function Sh({pending:e,onResponse:t}){let[n,r]=DT(0);if(OT((s,i)=>{if(e){if(i.escape){t("no");return}if(i.return){let a=Po[n];a&&t(a.value);return}if(i.leftArrow){r(a=>(a-1+Po.length)%Po.length);return}if(i.rightArrow){r(a=>(a+1)%Po.length);return}if(s==="1"){t("yes");return}if(s==="2"){t("no");return}if(s==="3"){t("always");return}}},{isActive:!!e}),!e)return null;let{ctx:o}=e;return br(_i,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,marginTop:1,children:[gt(Qe,{bold:!0,color:"yellow",children:"\u{1F510} \u6743\u9650\u5BA1\u6279"}),br(_i,{flexDirection:"column",marginLeft:2,marginTop:1,children:[br(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u5DE5\u5177\uFF1A"}),gt(Qe,{bold:!0,children:o.toolName}),gt(Qe,{dimColor:!0,children:" \uFF08\u5199\u64CD\u4F5C\u786E\u8BA4\uFF09"})]}),br(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u539F\u56E0\uFF1A"}),gt(Qe,{children:o.reason})]}),o.toolName==="bash"&&br(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u547D\u4EE4\uFF1A"}),gt(Qe,{color:"cyan",children:NT(o)})]})]}),gt(_i,{flexDirection:"row",marginTop:1,gap:2,children:Po.map((s,i)=>br(Qe,{color:i===n?s.color:"gray",bold:i===n,inverse:i===n,children:[" ","[",s.number,"] ",s.label," "]},s.value))}),gt(_i,{marginTop:1,children:gt(Qe,{dimColor:!0,children:"\u2190/\u2192 \u5207\u6362 \xB7 1/2/3 \u76F4\u63A5\u9009 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u62D2\u7EDD"})})]})}function NT(e){if(typeof e.args!="object"||e.args===null)return"(\u65E0\u53C2\u6570)";let n=e.args.command;return typeof n!="string"?"(\u975E\u547D\u4EE4)":n.length<=60?n:n.slice(0,57)+"..."}p();p();import{EventEmitter as jT}from"events";import{randomUUID as Ch}from"crypto";import UT from"ws";p();import{gunzipSync as MT,gzipSync as tu}from"zlib";var BT=1,FT=1,mn={FULL_REQUEST:1,AUDIO_ONLY:2,SERVER_RESPONSE:9,ERROR:15},Wn={NO_SEQUENCE:0,POSITIVE_SEQUENCE:1,LAST_PACKET_NO_SEQ:2,NEGATIVE_SEQUENCE:3,HAS_EVENT:4},nu={JSON:1},ru={GZIP:1};function Ri(e,t,n,r){let o=Buffer.alloc(4);o[0]=BT<<4|FT,o[1]=e<<4|t&15,o[2]=nu.JSON<<4|ru.GZIP,o[3]=0;let s=Buffer.alloc(4);s.writeInt32BE(n);let i=Buffer.alloc(4);return i.writeUInt32BE(r.length),Buffer.concat([o,s,i,r])}function ou(e,t){let n=Buffer.from(JSON.stringify(e),"utf8"),r=tu(n);return Ri(mn.FULL_REQUEST,Wn.POSITIVE_SEQUENCE,t,r)}function su(e,t){return Ri(mn.AUDIO_ONLY,Wn.POSITIVE_SEQUENCE,t,tu(e))}function iu(e){return Ri(mn.AUDIO_ONLY,Wn.NEGATIVE_SEQUENCE,-Math.abs(e),tu(Buffer.alloc(0)))}function au(e){let t={messageType:"unknown",seq:0,isLast:!1,event:0,code:0,body:null,raw:e};if(e.length<4)return t;let n=e[0],r=e[1],o=e[2],s=n&15,i=r>>4,a=r&15,l=o>>4,c=o&15,u=i===mn.SERVER_RESPONSE?"full_response":i===mn.AUDIO_ONLY?"audio_only":i===mn.ERROR?"error":"unknown",d=e.subarray(s*4),m=0;a&Wn.POSITIVE_SEQUENCE&&(m=d.readInt32BE(0),d=d.subarray(4));let h=(a&Wn.LAST_PACKET_NO_SEQ)!==0,f=0;a&Wn.HAS_EVENT&&(f=d.readInt32BE(0),d=d.subarray(4));let g=0;i===mn.ERROR&&(g=d.readInt32BE(0),d=d.subarray(4)),d.length>=4&&(d=d.subarray(4));let k=GT(d,c,l);return{messageType:u,seq:m,isLast:h,event:f,code:g,body:k,raw:e}}function GT(e,t,n){if(e.length===0)return null;let r=e;if(t===ru.GZIP)try{r=MT(e)}catch{return null}return n===nu.JSON||r.length>0&&r[0]===123?Th(r):null}function Th(e){try{return JSON.parse(e.toString("utf8"))}catch{return null}}function lu(e){return{user:{uid:e.user.uid,platform:e.user.platform??"Linux",sdk_version:e.user.sdkVersion??"0.1.x"},audio:{format:e.audio.format,codec:e.audio.codec,rate:e.audio.rate,bits:e.audio.bits,channel:e.audio.channel},request:{model_name:e.request.modelName,enable_itn:e.request.enableItn,enable_punc:e.request.enablePunc,enable_ddc:e.request.enableDdc,show_utterances:e.request.showUtterances}}}var WT="wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async",HT="volc.bigasr.sauc.duration",VT=(e,t)=>Reflect.construct(UT,[e,t]),vi=class extends jT{config;url;resourceId;ws=null;seq=1;started=!1;ended=!1;opened=!1;constructor(t){super(),this.config=t,this.url=t.url??WT,this.resourceId=t.resourceId??HT}connect(){return new Promise((t,n)=>{if(this.ws){n(new Error("VolcAsrClient: \u91CD\u590D\u8C03\u7528 connect()"));return}let r={"X-Api-Resource-Id":this.resourceId,"X-Api-Request-Id":Ch(),"X-Api-Access-Key":this.config.accessKey,"X-Api-App-Key":this.config.appId,"X-Api-Sequence":"-1"},o=this.config.wsFactory??VT,s;try{s=o(this.url,{headers:r})}catch(l){n(l instanceof Error?l:new Error(String(l)));return}this.ws=s;let i=()=>{if(!this.opened){this.opened=!0;try{this.sendStart(),this.emit("log","\u2705 \u63E1\u624B\u6210\u529F\uFF0C\u8D77\u59CB\u5305\u5DF2\u53D1"),this.emit("open"),t()}catch(l){n(l instanceof Error?l:new Error(String(l)))}}},a=l=>{this.ended||(this.opened?this.emit("error",-1,l.message):n(l))};s.on("open",i),s.on("error",a),s.on("message",l=>this.onMessage(l)),s.on("close",(l,c)=>this.onClose(l,c))})}sendAudio(t){if(!this.ws||!this.started||this.ended)return;let n=su(t,this.seq++);this.ws.send(n)}end(){if(!this.ws||this.ended)return;this.ended=!0;let t=iu(this.seq);this.ws.send(t),setTimeout(()=>{try{this.ws?.close()}catch{}},1500)}abort(){if(this.ws){this.ended=!0;try{this.ws.close()}catch{}}}sendStart(){if(!this.ws)return;let t=lu({user:{uid:`dskcode-cli-${Ch().slice(0,8)}`},audio:{format:this.config.format??"pcm",codec:this.config.codec??"raw",rate:this.config.sampleRate??16e3,bits:this.config.bits??16,channel:this.config.channel??1},request:{modelName:"bigmodel",enableItn:this.config.enableItn??!0,enablePunc:this.config.enablePunc??!0,enableDdc:this.config.enableDdc??!1,showUtterances:this.config.showUtterances??!0}}),n=ou(t,this.seq++);this.ws.send(n),this.started=!0}onMessage(t){let n=typeof t=="string"?Buffer.from(t):t,r=au(n);this.handleResponse(r)}handleResponse(t){if(t.messageType==="error"){let r=t.body?.error??`ASR error code=${t.code}`;this.emit("error",t.code,r);return}if(t.messageType!=="full_response")return;let n=t.body?.result;if(n)if(n.utterances&&n.utterances.length>0)for(let r of n.utterances)r.definite?this.emit("final",r.text):this.emit("partial",r.text);else n.text&&this.emit("partial",n.text)}onClose(t,n){this.ws=null,this.emit("close"),this.emit("log",`\u8FDE\u63A5\u5173\u95ED code=${t} reason=${n?.toString("utf8")||""}`)}};function cu(e){return new vi(e)}p();import{EventEmitter as JT}from"events";p();import{spawn as zT}from"child_process";import{platform as uu}from"os";var du=(e,t)=>zT(e,t,{stdio:["ignore","pipe","pipe"]}),qT={ffmpeg:["D:\\ffmpeg\\ffmpeg-8.1.2-essentials_build\\bin\\ffmpeg.exe","C:\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files (x86)\\ffmpeg\\bin\\ffmpeg.exe","/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg","/usr/bin/ffmpeg"],sox:["C:\\Program Files (x86)\\sox-14-4-2\\sox.exe","/opt/homebrew/bin/sox","/usr/local/bin/sox","/usr/bin/sox"],arecord:["/usr/bin/arecord","/usr/local/bin/arecord"]};function KT(e,t,n){return new Promise(r=>{let o;try{o=t(e,["-version"])}catch{r(!1);return}let s=setTimeout(()=>{try{o.kill()}catch{}r(!1)},n);o.on("close",i=>{clearTimeout(s),r(i===0)}),o.on("error",()=>{clearTimeout(s),r(!1)})})}var _h={name:"ffmpeg",binary:"ffmpeg",buildArgs:e=>{let t=uu();return t==="win32"?["-f","dshow","-i",`audio=${e??"Microphone"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:t==="darwin"?["-f","avfoundation","-i",`:${e??"0"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:["-f","alsa","-i",e??"default","-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]},listWindowsAudioDevices:async(e,t)=>new Promise(n=>{let r="",o;try{o=e(t,["-list_devices","true","-f","dshow","-i","dummy"])}catch{n(null);return}o.stderr?.on("data",s=>{r+=s.toString("utf8")}),o.on("close",()=>{let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)}),o.on("error",()=>n(null)),setTimeout(()=>{try{o.kill()}catch{}let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)},1e4)})},Rh={name:"sox",binary:"sox",buildArgs:e=>uu()==="win32"||e!==void 0?["-q","-r","16000","-c","1","-t","waveaudio",e??"-d","-t","raw","-"]:["-q","-r","16000","-c","1","-t","waveaudio","-d","-t","raw","-"]},vh={name:"arecord",binary:"arecord",buildArgs:e=>["-q","-f","S16_LE","-r","16000","-c","1",e?["-D",e]:[],"-t","raw"].flat()};async function pu(e,t){let n=e==="auto"?[_h,Rh,vh]:[_h,Rh,vh].filter(r=>r.name===e);for(let r of n){let o=await XT(r.binary,t);if(o)return{...r,binary:o}}throw new Error(`\u672A\u627E\u5230\u53EF\u7528\u7684\u5F55\u97F3\u9A71\u52A8\uFF08driver=${e}\uFF09\u3002\u8BF7\u5B89\u88C5 ffmpeg / sox / arecord \u4E4B\u4E00\u3002\u8BE6\u89C1 docs/\u8BED\u97F3\u8BC6\u522Bvoice\u547D\u4EE4\u63A5\u5165.md \xA712.1\u3002`)}async function XT(e,t){let n=qT[e]??[];for(let r of[e,...n])if(await KT(r,t,1500))return r;return null}async function Ah(e,t){return uu()!=="win32"||!e.listWindowsAudioDevices?null:e.listWindowsAudioDevices(t,e.binary)}var ZT=200,YT=60,QT=16e3,eC=16,tC=1,nC=QT*(eC/8)*tC,Ai=class extends JT{options;proc=null;driver=null;buf=[];bufSize=0;chunkBytes;started=!1;stopped=!1;maxDurationTimer=null;constructor(t={}){super(),this.options={chunkMs:t.chunkMs??ZT,maxDurationSec:t.maxDurationSec??YT,driver:t.driver??"auto",deviceName:t.deviceName,spawner:t.spawner},this.chunkBytes=Math.floor(nC*this.options.chunkMs/1e3)}async start(){if(this.started)throw new Error("VoiceCapture: \u91CD\u590D\u8C03\u7528 start()");this.started=!0,this.stopped=!1;let t=this.options.spawner??du;this.driver=await pu(this.options.driver,t),this.emit("log",`\u4F7F\u7528\u5F55\u97F3\u9A71\u52A8: ${this.driver.name}`);let n=this.options.deviceName;if(!n){let s=await Ah(this.driver,t);s&&(n=s,this.emit("log",`\u68C0\u6D4B\u5230\u9EA6\u514B\u98CE\u8BBE\u5907: ${n}`))}let r=this.driver.buildArgs(n);this.emit("log",`\u542F\u52A8\u5B50\u8FDB\u7A0B: ${this.driver.binary} ${r.join(" ")}`);let o;try{o=t(this.driver.binary,r)}catch(s){throw this.started=!1,s instanceof Error?s:new Error(String(s))}this.proc=o,o.stdout?.on("data",s=>this.ingest(s)),o.on("error",s=>{this.emit("error",s)}),o.on("close",s=>{if(this.bufSize>0){let i=Buffer.concat(this.buf,this.bufSize);this.emit("data",i),this.buf=[],this.bufSize=0}if(this.started=!1,this.proc=null,!this.stopped&&s!==0&&s!==null){this.emit("error",new Error(`\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5F02\u5E38\u9000\u51FA code=${s}\uFF08\u53EF\u80FD\u662F\u8BBE\u5907\u540D\u9519\u8BEF\u6216\u6743\u9650\u88AB\u62D2\uFF09`));return}this.emit("end")}),this.options.maxDurationSec>0&&(this.maxDurationTimer=setTimeout(()=>{this.emit("log",`\u5DF2\u8FBE ${this.options.maxDurationSec}s \u4E0A\u9650\uFF0C\u81EA\u52A8\u505C\u6B62`),this.stop()},this.options.maxDurationSec*1e3))}stop(){if(!(!this.proc||this.stopped)){this.stopped=!0,this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null);try{this.proc.kill()}catch(t){this.emit("error",t instanceof Error?t:new Error(`kill \u5B50\u8FDB\u7A0B\u5931\u8D25: ${String(t)}`))}}}abort(){if(this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.proc)try{this.proc.kill()}catch{}this.started=!1}isRecording(){return this.started}ingest(t){for(this.buf.push(t),this.bufSize+=t.length;this.bufSize>=this.chunkBytes;){let n=Buffer.concat(this.buf),r=n.subarray(0,this.chunkBytes);this.buf=[n.subarray(this.chunkBytes)],this.bufSize=n.length-this.chunkBytes,this.emit("data",r)}}};function fu(e={}){return new Ai(e)}p();import{EventEmitter as rC}from"events";var Ei=class extends rC{config;phase="idle";asr=null;cap=null;connecting=!1;lastError=null;constructor(t){super(),this.config=t}async start(){if(this.phase!=="idle"&&this.phase!=="error"){this.emit("log",`\u5DF2\u7ECF\u5728 ${this.phase} \u72B6\u6001\uFF0C\u5FFD\u7565 start()`);return}this.connecting=!0,this.lastError=null,this.setPhase("connecting");let n=(this.config.asrFactory??(()=>oC(this.config.asr)))();this.asr=n,this.bindAsrEvents(n);try{await n.connect()}catch(s){this.lastError=`\u8FDE\u63A5 ASR \u5931\u8D25: ${Eh(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}let o=(this.config.recorderOptions?.captureFactory??sC)();this.cap=o,this.bindCapEvents(o);try{await o.start()}catch(s){this.lastError=`\u542F\u52A8\u5F55\u97F3\u5931\u8D25: ${Eh(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}this.connecting=!1,this.setPhase("recording")}stop(){if(this.phase!=="recording"&&this.phase!=="connecting"&&this.phase!=="finalizing"){this.emit("log",`\u5F53\u524D phase=${this.phase}\uFF0C\u5FFD\u7565 stop()`);return}if(this.phase==="finalizing"){this.abort();return}this.setPhase("finalizing"),this.cap&&this.cap.isRecording()&&this.cap.stop()}abort(){this.setPhase("error"),this.cleanup()}getPhase(){return this.phase}getLastError(){return this.lastError}setPhase(t){this.phase!==t&&(this.phase=t,this.emit("phase",t))}bindAsrEvents(t){t.on("partial",n=>this.emit("partial",n)),t.on("final",n=>this.emit("final",n)),t.on("error",(n,r)=>{this.lastError=`ASR \u9519\u8BEF: ${r}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("close",()=>{this.emit("log","ASR WebSocket \u5DF2\u5173\u95ED"),(this.phase==="recording"||this.phase==="finalizing")&&(this.setPhase("idle"),this.cleanup())}),t.on("log",n=>this.emit("log",`[asr] ${n}`))}bindCapEvents(t){t.on("data",n=>{this.asr&&this.phase==="recording"&&this.asr.sendAudio(n)}),t.on("error",n=>{this.lastError=`\u5F55\u97F3\u9519\u8BEF: ${n.message}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("end",()=>{if(this.emit("log","\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5DF2\u7ED3\u675F"),this.asr)try{this.asr.end()}catch{}}),t.on("log",n=>this.emit("log",`[rec] ${n}`))}cleanup(){try{this.asr?.abort()}catch{}try{this.cap?.abort()}catch{}this.asr=null,this.cap=null}};function oC(e){return cu({appId:e.appId,accessKey:e.accessKey,resourceId:e.resourceId})}function sC(){return fu()}function Eh(e){return e instanceof Error?e.message:String(e)}function mu(e){return new Ei(e)}import{Fragment as $h,jsx as $,jsxs as K}from"react/jsx-runtime";var hu={thinking:{icon:"\u{1F9E0}",label:"\u601D\u8003\u4E2D",color:"#ff9800"},generating:{icon:"\u2728",label:"\u751F\u6210\u4E2D",color:"#00ff41"},calling_tools:{icon:"\u{1F6E0}",label:"\u8C03\u7528\u5DE5\u5177",color:"#f59e0b"},executing_tools:{icon:"\u26A1",label:"\u6267\u884C\u5DE5\u5177",color:"#00ffff"}};function cC(e){return e==="edit_file"||e==="write_file"||e==="multi_edit"||e==="delete_range"}function Ph(e){if(!e)return;let t=e.filter(n=>!n.name.startsWith("todo_"));return t.length>0?t:void 0}var xu=new Map;function $e(e,t){xu.set(e,t)}function Oh(){return xu}$e("/exit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/quit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/help",{desc:"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F",handler:()=>{let e=Oh(),t=["\u53EF\u7528\u547D\u4EE4\uFF1A"];for(let[n,r]of e)t.push(` ${n.padEnd(16)}${r.desc}`);return{kind:"text",content:t.join(`
582
+ `)}}});$e("/clear",{desc:"\u6E05\u7A7A\u5BF9\u8BDD\u5386\u53F2",handler:()=>({kind:"clear"})});$e("/version",{desc:"\u663E\u793A\u7248\u672C\u4FE1\u606F",handler:()=>({kind:"text",content:`dskcode v${Co}`})});$e("/model",{desc:"\u5207\u6362\u6A21\u578B",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /model \u8FDB\u5165\u9009\u62E9\u754C\u9762"})});$e("/thinking",{desc:"\u5207\u6362\u6DF1\u5EA6\u601D\u8003\u6A21\u5F0F",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /thinking \u5207\u6362"})});$e("/effort",{desc:"\u5207\u6362\u63A8\u7406\u7B49\u7EA7 High/Max",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /effort \u5207\u6362"})});$e("/game",{desc:"\u542F\u52A8\u6E38\u620F",handler:()=>({kind:"navigate",target:"game"})});$e("/stock",{desc:"\u67E5\u770B\u80A1\u7968\u884C\u60C5",handler:()=>({kind:"navigate",target:"stock"})});$e("/plan",{desc:"\u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08Shift+Tab\uFF09",handler:()=>({kind:"text",content:"\u8F93\u5165 /plan \u6216\u6309 Shift+Tab \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F"})});$e("/code",{desc:"\u5207\u6362\u56DE\u4EE3\u7801\u6A21\u5F0F\uFF08Shift+Tab\uFF09",handler:()=>({kind:"text",content:"\u8F93\u5165 /code \u6216\u6309 Shift+Tab \u5207\u6362\u56DE\u4EE3\u7801\u6A21\u5F0F"})});$e("/rewind",{desc:"\u56DE\u9000\u5230\u5386\u53F2\u68C0\u67E5\u70B9\uFF081 = \u6700\u65B0\uFF09",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /rewind \u67E5\u770B\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u5217\u8868\uFF0C\u6216 /rewind <\u5E8F\u53F7> \u76F4\u63A5\u56DE\u9000\uFF081 = \u6700\u65B0\uFF0C2 = \u4E0A\u4E00\u6B21\uFF0C\u4F9D\u6B64\u7C7B\u63A8\uFF09"})});$e("/compact",{desc:"\u538B\u7F29\u4E0A\u4E0B\u6587\uFF1A\u6458\u8981\u65E7\u56DE\u5408\u5E76\u4FDD\u7559\u6700\u8FD1 N \u8F6E",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /compact \u624B\u52A8\u538B\u7F29\u4E0A\u4E0B\u6587\uFF08\u9700\u5F53\u524D\u4E0D\u5904\u4E8E\u751F\u6210\u4E2D\uFF09"})});$e("/voice",{desc:"\u8BED\u97F3\u8F93\u5165\uFF08F2 \u6216 /voice \u542F\u52A8\uFF0CESC \u53D6\u6D88\uFF09",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /voice \u6216\u6309 F2 \u542F\u52A8\u8BED\u97F3\u8BC6\u522B"})});$e("/permissions",{desc:"\u67E5\u770B\u5F53\u524D\u6743\u9650\u89C4\u5219\u4E0E\u4F1A\u8BDD grants\uFF08v0.6\uFF09",handler:()=>({kind:"permissions"})});var uC=["\u8BA9\u5B50\u5F39\u98DE\u4E00\u4F1A\u513F...","\u9A6C\u4E0A\u5C31\u597D...","\u6B63\u5728\u618B\u5927\u62DB...","\u7A0D\u7B49\u4E00\u4E0B\u4E0B~","\u7801\u5B57\u4E2D...","\u8111\u5B50\u8F6C\u5F97\u98DE\u5FEB..."],Lh=["\u60F3\u5E72\u5565\uFF1F\u76F4\u63A5\u8BF4~","\u6765\u5427\uFF0C\u5429\u5490\u70B9\u5565","\u968F\u65F6\u5F85\u547D...","\u6233\u8FD9\u91CC\u5F00\u804A...","\u7B49\u4F60\u5F00\u53E3...","\u5C3D\u7BA1\u4F7F\u5524~"];function gu(e){return e[Math.floor(Math.random()*e.length)]}function bu({skillCount:e,skills:t=[],files:n=[],toolCount:r,verbose:o,apiKey:s,baseUrl:i,costTracker:a,model:l="deepseek-v4-flash",permissionsConfig:c,voiceConfig:u,configReloadEpoch:d,thinkingEnabledFromConfig:m,thinkingEffortFromConfig:h,verboseFromConfig:f,onLaunchGame:g,onLaunchStock:k,permissionBroker:b}){let R=(typeof process.stdout.columns=="number"?process.stdout.columns:80)-2,v=Math.max(Math.floor(R/3),30),_=R-v-1,[B,j]=q(0),[D,C]=q([]),[J,M]=q(0),[U,N]=q(""),[ie,ne]=q(null),H=le(null),[se,ce]=q(null),[_r,Vn]=q(!1),[Ou,Du]=q(null),[Pe,Sg]=q("idle"),[Mi,Bi]=q(""),No=le(null),[Rr,Fi]=q(null),[ae,Mo]=q(!1),[vr,Pt]=q(null),[hn,Gi]=q(""),[gn,Tg]=q(()=>gu(Lh)),[ji,Ui]=q([]),Bo=le(0),[Wi,Hi]=q([]),Fo=le(0),[Vi,zi]=q(""),[qi,Ki]=q([]),[Go,Xi]=q([]),[Cg,Nu]=q(()=>new Map),[Mu,Bu]=q(void 0),[g_,Fu]=q(void 0),[Gu,ju]=q(void 0),[tt,Ji]=q(l),[Uu,Wu]=q(void 0),[Zi,jo]=q(void 0),[yn,Uo]=q([]),[y_,x_]=q(""),[Hu,Wo]=q(!0),Xt=le(null),Ar=le(-1),[Jt,Ho]=q("code"),[zn,Vu]=q(!0),[Er,zu]=q("high"),[Yi]=q("text"),[Ir,Vo]=q(void 0),qu=Ih(()=>D.reduce((T,w)=>w.assistantDetail?.cost?T+w.assistantDetail.cost:T,0),[D]),Pr=D.length>0,_g=ae&&qi.length>0,bt=Array.from(Oh()).filter(([T])=>T!=="/exit"&&T!=="/quit").map(([T,w])=>({name:T,desc:w.desc})),[zo,Rg]=q(0),[Qi,ea]=q([]),qo=le(0),[Lr,ta]=q(0),[qn,Ko]=q(0),[Ku,na]=q(0),[xn,Xo]=q(!1),[$r,Jo]=q(0),[bn,vg]=q([]),[ra,Xu]=q(!1),[Or,Zo]=q(!1),[Ju,oa]=q("idle"),sa=le(!1),wt=le(null),[Zt,ia]=q(!1),[Yo,Qo]=q(0),Yt=["deepseek-v4-flash","deepseek-v4-pro"],[Zu,Qt]=q({phase:"idle",progress:null}),Ne=le(null),Kn=le(void 0),ue=le(null),aa=le(null),Yu=le([]),es=le(""),ts=le([]),ns=le([]),rs=le(new Map),[la,os]=q(null),Dr=le(null),ca=ct(T=>{if(b){let{requestId:w,promise:E}=b.register(T);return Dr.current=null,os({requestId:w,ctx:T,resolve:()=>{}}),E}return new Promise(w=>{Dr.current=w,os({ctx:T,resolve:w})})},[b]),Ag=ct(T=>{let w=la?.requestId,E=Dr.current;os(null),Dr.current=null,b&&w?b.respond(w,T,"terminal"):E?.(T)},[b,la]);xe(()=>b?b.onResolved(w=>{os(E=>E&&E.requestId===w.requestId?null:E),Dr.current=null}):void 0,[b]);let ua=le(void 0),da=le(void 0),pa=le(void 0),fa=le(void 0),ss=le(void 0);xe(()=>{ta(0),Ko(0)},[U]),xe(()=>()=>{wt.current&&(clearTimeout(wt.current),wt.current=null),Ne.current&&(clearTimeout(Ne.current),Ne.current=null),H.current&&(clearTimeout(H.current),H.current=null)},[]),xe(()=>{if(ie==null)return;let T=setTimeout(()=>ne(null),5e3);return H.current=T,()=>clearTimeout(T)},[ie]),xe(()=>{d===void 0||d===0||ne(Date.now())},[d]),xe(()=>{l&&Ji(l)},[l]),xe(()=>{m!==void 0&&Vu(m)},[m]),xe(()=>{h!==void 0&&zu(h)},[h]),xe(()=>{let T=()=>{let E=ue.current;if(!E){Fi(null);return}try{let z=E.getContextStats();Fi({tokens:z.estimatedTokens,ratio:z.ratio,contextWindow:z.contextWindow})}catch{Fi(null)}};T();let w=setInterval(T,3e3);return()=>clearInterval(w)},[]),xe(()=>{if(Xt.current&&(clearTimeout(Xt.current),Xt.current=null),yn.length===0){Wo(!1);return}yn.some(w=>w.status==="pending"||w.status==="running"||w.status==="failed")?Wo(!0):(Ar.current=Math.max(...yn.map(w=>w.id)),Xt.current=setTimeout(()=>{Wo(!1),Xt.current=null},2e3))},[yn]);let ma=ct(T=>{let w=T.match(/(?:^|\s)\/([^/]*)$/);if(!w)return[];let E=w[1].toLowerCase().trim();if(!E)return T.startsWith("/")?t.slice(0,3):[];let z=t.filter(P=>P.name.toLowerCase().includes(E)).slice(0,3);return z.some(P=>P.name.toLowerCase()===E)?[]:z},[t]),Qu=ct(T=>ko(T,n)??[],[n]),is=ct((T,w)=>{let E=ko(T,n);if(!E||E.length===0)return!1;let z=E[w];if(!z)return!1;let P=T.lastIndexOf("@");return P<0?!1:(N(T.slice(0,P)+"@"+z+" "),na(te=>te+1),Ko(0),!0)},[n]);function Eg(T){let w=[];for(let E of T.messages)E.role==="user"?w.push({role:"user",content:E.content}):E.role==="assistant"?w.push({role:"assistant",content:E.content,assistantDetail:{content:E.content,toolCalls:Ph(E.toolCalls)}}):E.role==="tool"&&w.push({role:"tool",content:E.content});C(w),M(E=>E+1)}let ha=ct(async(T,w)=>{let E=ue.current;if(E){Xu(!0),Mo(!0),Pt("thinking"),Gi("\u23EA \u6B63\u5728\u56DE\u9000\u5230\u68C0\u67E5\u70B9\u2026"),N("");try{let z=await E.rewind(T.index);if(z.ok){Eg(E);let P=z.fileRestored?"\uFF0C\u5DE5\u4F5C\u533A\u6587\u4EF6\u5DF2\u6062\u590D":"\uFF08\u4EC5\u5BF9\u8BDD\u56DE\u9000\uFF0C\u672A\u6062\u590D\u6587\u4EF6\uFF09";C(te=>[...te,{role:"assistant",content:`\u23EA \u5DF2\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #${w}${P}\u3002`}])}else C(P=>[...P,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5931\u8D25\uFF1A${z.error}`}])}catch(z){let P=z instanceof Error?z.message:String(z);C(te=>[...te,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5F02\u5E38\uFF1A${P}`}])}finally{Xu(!1),Mo(!1),Pt(null),Gi("")}}},[]),ga=ct(async()=>{if(!u||!u.resolved){let w=u?.missing?.join(", ")??"appId, accessKey";C(E=>[...E,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u672A\u914D\u7F6E\uFF08\u7F3A ${w}\uFF09\u3002
579
583
  \u8BF7\u5230\u706B\u5C71\u63A7\u5236\u53F0 https://console.volcengine.com/speech \u5F00\u901A\u201C\u8BED\u97F3\u8BC6\u522B-\u5927\u6A21\u578B\u7248\u201D\uFF0C
580
584
  \u7136\u540E\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF VOLC_ASR_APP_ID \u548C VOLC_ASR_ACCESS_KEY\uFF0C
581
- \u6216\u5728 ~/.dskcode/settings.json \u6DFB\u52A0 voice \u6BB5\u3002`}]);return}if(Pe!=="idle"&&Pe!=="error")return;Oi("");let C=cu({asr:{appId:u.config.appId,accessKey:u.config.accessKey,resourceId:u.config.resourceId}});C.on("phase",k=>hg(k)),C.on("partial",k=>Oi(k)),C.on("final",k=>{$(I=>I?I+k:k),Oi("")}),C.on("error",k=>{T(I=>[...I,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u51FA\u9519: ${k}`}])}),C.on("log",k=>{o&&console.error(`[voice] ${k}`)}),Oo.current=C,await C.start()},[u,Pe,o]),fa=ct(()=>{Oo.current?.stop()},[]),ma=ct(()=>{Pe==="recording"||Pe==="connecting"?fa():(Pe==="idle"||Pe==="error")&&pa()},[Pe,pa,fa]),{doubleCtrlC:Cg,handleCtrlC:Xu}=Sn(()=>{if(Oo.current)try{Oo.current.abort()}catch{}let C=ue.current;C?C.flushLog().finally(()=>process.exit(0)):process.exit(0)});WT(ct((C,k)=>{if(Nr){k.ctrl&&C==="p"&&Xo(!1);return}if(xn){if(k.upArrow)Ko(P=>(P-1+bn.length)%bn.length);else if(k.downArrow)Ko(P=>(P+1)%bn.length);else if(k.return){let P=bn[Dr];qo(!1),P&&da(P,Dr+1)}else k.escape&&(qo(!1),T(P=>[...P,{role:"assistant",content:"\u5DF2\u53D6\u6D88\u56DE\u9000\u3002"}]));return}if(Zt){if(k.upArrow)Zo(P=>(P-1+Yt.length)%Yt.length);else if(k.downArrow)Zo(P=>(P+1)%Yt.length);else if(k.return){let P=Yt[Jo];P===tt?T(te=>[...te,{role:"assistant",content:`\u5DF2\u7ECF\u5728\u4F7F\u7528 ${kn[P].displayName}`}]):(zi(P),ue.current?.reset(),Yu(P).catch(()=>{}),T(te=>[...te,{role:"assistant",content:`\u6A21\u578B\u5DF2\u5207\u6362\u4E3A ${kn[P].displayName}\uFF08${P}\uFF09`}])),na(!1)}else k.escape&&na(!1);return}let I=Ku(q),V=I.length===0?ua(q):[];if(I.length>0){if(k.upArrow){zo(P=>(P-1+I.length)%I.length);return}if(k.downArrow){zo(P=>(P+1)%I.length);return}if(k.tab){rs(q,Xn);return}}if(V.length>0){if(k.upArrow){Zi(P=>(P-1+V.length)%V.length);return}if(k.downArrow){Zi(P=>(P+1)%V.length);return}if(k.tab){let P=V[Or];if(P){let te=q.lastIndexOf("/");te>=0&&($(q.slice(0,te)+"/"+P.name+" "),Yi(D=>D+1))}return}}if(Zt){k.upArrow||k.downArrow;return}if(k.ctrl&&C==="c"){ie?ra.current?.abort():Xu();return}if(k.ctrl&&C==="p"&&!ie&&!xn&&!Zt){Xo(!0);return}if(k.escape&&(Pe==="recording"||Pe==="connecting"||Pe==="finalizing")){fa();return}if(k.shift&&k.tab){if(!ie){let P=Jt==="plan"?"code":"plan";Uo(P),ue.current?.setMode(P),Wo(void 0),ue.current?.reset(),T(te=>[...te,{role:"assistant",content:P==="plan"?`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
585
+ \u6216\u5728 ~/.dskcode/settings.json \u6DFB\u52A0 voice \u6BB5\u3002`}]);return}if(Pe!=="idle"&&Pe!=="error")return;Bi("");let T=mu({asr:{appId:u.config.appId,accessKey:u.config.accessKey,resourceId:u.config.resourceId}});T.on("phase",w=>Sg(w)),T.on("partial",w=>Bi(w)),T.on("final",w=>{N(E=>E?E+w:w),Bi("")}),T.on("error",w=>{C(E=>[...E,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u51FA\u9519: ${w}`}])}),T.on("log",w=>{o&&console.error(`[voice] ${w}`)}),No.current=T,await T.start()},[u,Pe,o]),ya=ct(()=>{No.current?.stop()},[]),xa=ct(()=>{Pe==="recording"||Pe==="connecting"?ya():(Pe==="idle"||Pe==="error")&&ga()},[Pe,ga,ya]),{doubleCtrlC:Ig,handleCtrlC:ed}=Tn(()=>{if(No.current)try{No.current.abort()}catch{}let T=ue.current;T?T.flushLog().finally(()=>process.exit(0)):process.exit(0)});iC(ct((T,w)=>{if(Or){w.ctrl&&T==="p"&&Zo(!1);return}if(xn){if(w.upArrow)Jo(P=>(P-1+bn.length)%bn.length);else if(w.downArrow)Jo(P=>(P+1)%bn.length);else if(w.return){let P=bn[$r];Xo(!1),P&&ha(P,$r+1)}else w.escape&&(Xo(!1),C(P=>[...P,{role:"assistant",content:"\u5DF2\u53D6\u6D88\u56DE\u9000\u3002"}]));return}if(Zt){if(w.upArrow)Qo(P=>(P-1+Yt.length)%Yt.length);else if(w.downArrow)Qo(P=>(P+1)%Yt.length);else if(w.return){let P=Yt[Yo];P===tt?C(te=>[...te,{role:"assistant",content:`\u5DF2\u7ECF\u5728\u4F7F\u7528 ${kn[P].displayName}`}]):(Ji(P),ue.current?.reset(),rd(P).catch(()=>{}),C(te=>[...te,{role:"assistant",content:`\u6A21\u578B\u5DF2\u5207\u6362\u4E3A ${kn[P].displayName}\uFF08${P}\uFF09`}])),ia(!1)}else w.escape&&ia(!1);return}let E=Qu(U),z=E.length===0?ma(U):[];if(E.length>0){if(w.upArrow){Ko(P=>(P-1+E.length)%E.length);return}if(w.downArrow){Ko(P=>(P+1)%E.length);return}if(w.tab){is(U,qn);return}}if(z.length>0){if(w.upArrow){ta(P=>(P-1+z.length)%z.length);return}if(w.downArrow){ta(P=>(P+1)%z.length);return}if(w.tab){let P=z[Lr];if(P){let te=U.lastIndexOf("/");te>=0&&(N(U.slice(0,te)+"/"+P.name+" "),na(O=>O+1))}return}}if(Zt){w.upArrow||w.downArrow;return}if(w.ctrl&&T==="c"){ae?aa.current?.abort():ed();return}if(w.ctrl&&T==="p"&&!ae&&!xn&&!Zt){Zo(!0);return}if(w.escape&&(Pe==="recording"||Pe==="connecting"||Pe==="finalizing")){ya();return}if(w.shift&&w.tab){if(!ae){let P=Jt==="plan"?"code":"plan";Ho(P),ue.current?.setMode(P),Vo(void 0),ue.current?.reset(),C(te=>[...te,{role:"assistant",content:P==="plan"?`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
582
586
 
583
587
  \u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C\u6211\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u4F1A\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u3002`:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
584
588
 
585
- \u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002`}])}return}!q&&!ie&&C&&$(C)},[Zt,Jo,Yt,tt,ie,Xu,q,t,Or,Xn,ua,Ku,rs,Jt,Uo,xn,Dr,bn,da,ma])),Se(()=>{if(!process.stdin.isTTY)return;let C=Buffer.alloc(0),k=[Buffer.from([27,79,81]),Buffer.from([27,91,49,50,126]),Buffer.from([27,91,91,66])],I=V=>{let P=Buffer.isBuffer(V)?V:Buffer.from(V,"binary");C=Buffer.concat([C,P]),C.length>16&&(C=C.subarray(C.length-16));for(let te of k)if(C.includes(te)){C=Buffer.alloc(0),!ie&&!xn&&!Zt&&ma();return}};return process.stdin.on("data",I),()=>{process.stdin.off("data",I)}},[ie,xn,Zt,ma]),Se(()=>{if(bt.length<=1)return;let C=setInterval(()=>{bg(k=>(k+1)%bt.length)},2e3);return()=>clearInterval(C)},[bt.length]),Se(()=>{let C=bt[Ho%bt.length];if(!C){Ji([]);return}let k=`${C.name} ${C.desc}`;Vo.current=0,Ji(Wn(k,1,qc));let I=setInterval(()=>{Vo.current=(Vo.current+Un.cmdTipPhaseStep)%1,Ji(Wn(k,1-Vo.current,qc))},Un.cmdTipInterval);return()=>clearInterval(I)},[Ho,bt.length]),Se(()=>{let C=setInterval(()=>{M(k=>(k+1)%Gr.length)},500);return()=>clearInterval(C)},[]),Se(()=>{let C=!1;if(!s||!i)return;let k=yc({name:"deepseek",apiKey:s,baseUrl:i,model:tt}),I=a??new Me,V=new un;return V.registerAll(Vc),(async()=>{let P=new jn,te=[];try{let{loadAllSkills:D}=await import("./loader-GPVLJCXF.js"),R=await D(process.cwd());if(te=R.skills,zu.current=R.skills,o&&R.errors.length>0)for(let L of R.errors)console.warn(` \u26A0 ${L.message} (${L.skillFilePath})`)}catch(D){o&&console.warn(` \u26A0 \u52A0\u8F7D skill \u5931\u8D25\uFF1A${D instanceof Error?D.message:String(D)}`)}if(c){let{permissionsFromConfig:D}=await import("./permissions-loader-YST5MXNS.js"),{InteractiveGate:R}=await import("./interactive-gate-XKNHF4ZY.js"),L=D(c);if(!C){let j=new R({engine:L.engine,grants:void 0,prompt:sa,defaultDecision:"confirm"}),Z=new Ao(k,V,I,{cwd:process.cwd(),gate:new fn([new jn,j]),skills:te});ue.current=Z,is.register({id:Z.id,cwd:process.cwd(),chat:(ft,Zn)=>Z.chat(ft,Zn)},()=>Z.flushLog(),{onRemoteUserInput:async(ft,Zn)=>{if(!Mr.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await Mr.current(ft,Zn,{displayText:ft})}})}if(o&&L.warnings.length>0)for(let j of L.warnings)console.warn(` \u26A0 ${j}`)}else{let{WriteConfirmGate:D}=await import("./write-gate-HEFJJQX6.js");if(!C){let R=new D(V,sa),L=new Ao(k,V,I,{cwd:process.cwd(),gate:new fn([P,R]),skills:te});ue.current=L,is.register({id:L.id,cwd:process.cwd(),chat:(j,Z)=>L.chat(j,Z)},()=>L.flushLog(),{onRemoteUserInput:async(j,Z)=>{if(!Mr.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await Mr.current(j,Z,{displayText:j})}})}}})(),()=>{C=!0,ue.current&&is.unregister(ue.current.id),ue.current=null}},[s,i,tt,a,sa,o]),Se(()=>{if(!s||!i)return;let C=!1;return zn(!0),import("./deepseek-X6USE3PW.js").then(({DeepSeekProvider:k})=>new k({apiKey:s,baseUrl:i,model:"deepseek-v4-flash"}).getBalance()).then(k=>{if(C)return;let I=k.balances.find(V=>V.currency==="CNY");I&&se(I.totalBalance)}).catch(()=>{}).finally(()=>{C||zn(!1)}),()=>{C=!0}},[s,i]),Se(()=>{if(!a)return;let C=!1,k,I=()=>{Eu(a.todayTotalCost)};return a.load().then(()=>{C||(I(),k=setInterval(I,5e3))}).catch(()=>{}),()=>{C=!0,k&&clearInterval(k)}},[a]),Se(()=>{if(ie||!gn){Bi([]);return}No.current=0,Bi(Wn(gn,1,zc));let C=setInterval(()=>{No.current=(No.current+Un.idlePhaseStep)%1,Bi(Wn(gn,1-No.current,zc))},Un.idleInterval);return()=>clearInterval(C)},[ie,gn]),Se(()=>{if(!ie||!hn){Gi([]);return}Mo.current=0,Gi(Wn(hn,1,Kc));let C=setInterval(()=>{Mo.current=(Mo.current+Un.streamingPhaseStep)%1,Gi(Wn(hn,1-Mo.current,Kc))},Un.streamingInterval);return()=>clearInterval(C)},[ie,hn]);let os=ct(async(C,k,I)=>{let V=ue.current;if(!V){T(D=>[...D,{role:"user",content:I.displayText},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]);return}let P=k==="chrome"?`\u{1F310} [chrome] ${I.displayText}`:k==="api"?`\u{1F50C} [api] ${I.displayText}`:k==="test"?`\u{1F9EA} [test] ${I.displayText}`:I.displayText;T(D=>[...D,{role:"user",content:P}]),Do(!0),Pt("thinking"),Ni(du(qT)),Ui(""),Hi([]),Vi([]),Lu(void 0),$u(void 0),Du(void 0),Mu(void 0),Fo(void 0),Iu(new Map),ts.current=new Map,Yo.current="",Qo.current=[],es.current=[],ia.current=void 0,aa.current=void 0,la.current=void 0,ca.current=void 0,ns.current=void 0,ta.current=!1,ea("idle"),wt.current&&(clearTimeout(wt.current),wt.current=null),Go([]),Xt.current&&(clearTimeout(Xt.current),Xt.current=null),jo(!1),Qt({phase:"idle",progress:null}),Jn.current=void 0,Ne.current&&(clearTimeout(Ne.current),Ne.current=null);let te=new AbortController;ra.current=te;try{for await(let D of V.chat(C,{thinkingAllowed:I.thinkingAllowed,thinkingEffort:I.thinkingEffort,...I.responseFormat?{responseFormat:I.responseFormat}:{},...I.toolChoice?{toolChoice:I.toolChoice}:{}})){if(te.signal.aborted)break;switch(D.type){case"text_delta":Pt("generating"),Ui(R=>{let L=R+D.content;return Yo.current=L,L});break;case"reasoning_delta":Pt("thinking"),Hi(R=>{let L=R[R.length-1],j=L!==void 0?[...R.slice(0,-1),L+D.content]:[...R,D.content];return Qo.current=j,j});break;case"tool_calls":Pt("calling_tools"),Vi(R=>{let L=[...R,...D.calls];return es.current=L,L});for(let R of D.calls)if(zT(R.name)){ta.current=!0;break}break;case"tool_result":Pt("executing_tools"),setTimeout(()=>Pt("thinking"),300),Ui(""),Yo.current="",Hi(R=>{let L=[...R,""];return Qo.current=L,L}),Vi([]),es.current=[];{let R=D.callId??`${D.name}#${D.result.data.length}`;Iu(L=>{let j=new Map(L);return j.set(R,{success:D.result.success,...D.result.error?{error:D.result.error}:{},...D.result.denial?{denial:D.result.denial}:{}}),ts.current=j,j})}{let R=D.result;if(D.name.startsWith("todo_")&&D.todoSnapshot){let L=[...D.todoSnapshot];L.length>0&&L.every(Z=>Z.status==="done"||Z.status==="failed"||Z.status==="skipped")?(Ir.current=Math.max(...L.map(Z=>Z.id)),Go(L)):Ir.current>=0?Go(L.filter(Z=>Z.id>Ir.current)):Go(L)}else{let L=R.success?R.summary??`\u2705 ${D.name}: ${R.data.slice(0,500)}${R.data.length>500?"...":""}`:`\u274C ${D.name}: ${R.error??"\u6267\u884C\u5931\u8D25"}`;T(j=>[...j,{role:"tool",content:L,diff:R.diff}])}}break;case"usage":Lu(D.usage),Mu(D.model),ia.current=D.usage,ca.current=D.model;{let R=kt(D.usage,D.model);Du(R.totalCost),la.current=R.totalCost}break;case"done":$u(D.elapsed),aa.current=D.elapsed;break;case"error":Fo(D.error.message),ns.current=D.error.message;break}}}catch(D){let R=D instanceof Error?D.message:String(D);Fo(R),ns.current=R}finally{Do(!1),Pt(null),gg(du(_h)),ra.current=null;let D=Yo.current,R=Qo.current.map(Z=>Z.trim()).filter(Z=>Z.length>0),L=Ch(es.current),j=ns.current;if(D||L||j){let Z={content:j?`\u26A0 \u8BF7\u6C42\u51FA\u9519\uFF1A${j}`:D||"",...R.length>0?{reasoning:R}:{},toolCalls:L,toolResults:ts.current.size>0?new Map(ts.current):void 0,usage:ia.current,elapsed:aa.current,cost:la.current,model:ca.current};T(ft=>[...ft,{role:"assistant",content:Z.content,assistantDetail:Z}])}ta.current&&!j&&(ea("pending"),wt.current&&clearTimeout(wt.current),wt.current=setTimeout(()=>{ea(Z=>Z==="pending"?"visible":Z),wt.current=null},2e3))}},[]),Mr=ae(null);Se(()=>{Mr.current=os},[os]);let Ju=ct(async C=>{if(rs(C,Xn))return;let k=C.trim();if(!k)return;let I=k;if(k.startsWith("/")&&k.length>1){let P=k.toLowerCase();if(P==="/rewind"||P.startsWith("/rewind ")){if(ie||Qi){let j=Qi?"\u56DE\u9000\u4E2D":"\u751F\u6210\u4E2D";T(Z=>[...Z,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6B63\u5728${j}\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /rewind\u3002`}]),$("");return}if(!ue.current){T(j=>[...j,{role:"user",content:k},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u56DE\u9000\u3002"}]),$("");return}let R=ue.current.listCheckpoints();if(R.length===0){T(j=>[...j,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6CA1\u6709\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u3002
586
- \u53EA\u6709\u5728 git \u4ED3\u5E93\u5185\u4E14\u53D1\u751F\u8FC7\u5BF9\u8BDD\u540E\u624D\u4F1A\u751F\u6210\u68C0\u67E5\u70B9\u3002`}]),$("");return}let L=k.split(/\s+/);if(L.length>=2){let j=Number(L[1]);if(!Number.isInteger(j)||j<1||j>R.length){T(ft=>[...ft,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u65E0\u6548\u7684\u5E8F\u53F7\u300C${L[1]}\u300D\u3002\u53EF\u7528\u8303\u56F4 1~${R.length}\uFF081 \u8868\u793A\u6700\u65B0\uFF09\u3002`}]),$("");return}let Z=R[R.length-j];$(""),await da(Z,j);return}wg([...R].reverse()),Ko(0),qo(!0),T(j=>[...j,{role:"user",content:k},{role:"assistant",content:`\u23F7\u2191\u2193 \u9009\u62E9\u68C0\u67E5\u70B9\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88\uFF08\u5171 ${R.length} \u4E2A\u53EF\u56DE\u9000\u4F4D\u7F6E\uFF09`}]),$("");return}if(P==="/compact"){if(ie){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u26A0 \u6B63\u5728\u751F\u6210\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /compact\u3002"}]),$("");return}if(!ue.current){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u538B\u7F29\u3002"}]),$("");return}$(""),T(R=>[...R,{role:"user",content:k}]),Qt({phase:"running",progress:null,beforeTokens:void 0,afterTokens:void 0,droppedTurns:void 0,keptTurns:void 0,strategy:void 0,errorMessage:void 0});try{let R=await ue.current.compact(L=>{Qt(j=>{if(L.type==="start")return{...j,phase:"running",progress:L,beforeTokens:L.beforeTokens,droppedTurns:L.droppedTurns};if(L.type==="summary_delta")return{...j,phase:"running",progress:L};if(L.type==="fallback")return Jn.current="fallback",{...j,phase:"running",progress:L,strategy:"fallback"};if(L.type==="done"){let Z=Jn.current==="fallback"?"fallback":"summary";return Jn.current=Z,{...j,phase:"done",progress:L,droppedTurns:L.droppedTurns,keptTurns:L.keptTurns,beforeTokens:L.beforeTokens,afterTokens:L.afterTokens,strategy:Z}}return j})});R.droppedTurns===0?(Qt(L=>({...L,phase:"done",progress:L.progress,droppedTurns:0,keptTurns:R.keptTurns,beforeTokens:R.beforeTokens,afterTokens:R.afterTokens,strategy:void 0})),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{Qt({phase:"idle",progress:null}),T(L=>[...L,{role:"assistant",content:"\u2139 \u5F53\u524D\u5BF9\u8BDD\u592A\u77ED\uFF0C\u65E0\u9700\u538B\u7F29\uFF08\u5C11\u4E8E\u6700\u5C0F\u56DE\u5408\u6570 \u6216 \u90FD\u5728\u4FDD\u7559\u533A\u5185\uFF09\u3002"}])},2500)):(Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{let L=((R.beforeTokens-R.afterTokens)/Math.max(R.beforeTokens,1)*100).toFixed(1),j=Jn.current==="fallback"?`
587
- \u26A0 \u6458\u8981\u4E3A\u672C\u5730\u5151\u5E95\uFF08LLM \u4E0D\u53EF\u7528\uFF09`:"";Qt({phase:"idle",progress:null}),Jn.current=void 0,T(Z=>[...Z,{role:"assistant",content:`\u2714 \u538B\u7F29\u5B8C\u6210\uFF1A${R.droppedTurns} \u56DE\u5408 \u2192 ${R.keptTurns} \u56DE\u5408\uFF08\u8282\u7701 ${L}% token\uFF09${j}`}])},4e3))}catch(R){let L=R instanceof Error?R.message:String(R);Qt(j=>({...j,phase:"error",errorMessage:L})),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{Qt({phase:"idle",progress:null}),T(j=>[...j,{role:"assistant",content:`\u26A0 \u538B\u7F29\u5931\u8D25\uFF1A${L}`}])},3e3)}return}if(P==="/model"){let R=Yt.indexOf(tt);Zo(R>=0?R:0),na(!0),$("");return}if(P==="/voice"){$(""),pa();return}if(P==="/thinking"){Fu(R=>!R),T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u6DF1\u5EA6\u601D\u8003\u5DF2${Kn?"\u5173\u95ED":"\u5F00\u542F"}`}]),$("");return}if(P==="/effort"){let R=Pr==="high"?"max":"high";Gu(R),T(L=>[...L,{role:"user",content:k},{role:"assistant",content:`\u63A8\u7406\u7B49\u7EA7\u5DF2\u5207\u6362\u4E3A ${R==="high"?"High":"Max"}`}]),$("");return}if(P==="/plan"){Jt==="plan"?T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u8BA1\u5212\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002"}]):(Uo("plan"),ue.current?.setMode("plan"),Wo(void 0),T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**
589
+ \u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002`}])}return}!U&&!ae&&T&&N(T)},[Zt,Yo,Yt,tt,ae,ed,U,t,Lr,qn,ma,Qu,is,Jt,Ho,xn,$r,bn,ha,xa])),xe(()=>{if(!process.stdin.isTTY)return;let T=Buffer.alloc(0),w=[Buffer.from([27,79,81]),Buffer.from([27,91,49,50,126]),Buffer.from([27,91,91,66])],E=z=>{let P=Buffer.isBuffer(z)?z:Buffer.from(z,"binary");T=Buffer.concat([T,P]),T.length>16&&(T=T.subarray(T.length-16));for(let te of w)if(T.includes(te)){T=Buffer.alloc(0),!ae&&!xn&&!Zt&&xa();return}};return process.stdin.on("data",E),()=>{process.stdin.off("data",E)}},[ae,xn,Zt,xa]),xe(()=>{if(bt.length<=1)return;let T=setInterval(()=>{Rg(w=>(w+1)%bt.length)},2e3);return()=>clearInterval(T)},[bt.length]),xe(()=>{let T=bt[zo%bt.length];if(!T){ea([]);return}let w=`${T.name} ${T.desc}`;qo.current=0,ea(Un(w,1,Yc));let E=setInterval(()=>{qo.current=(qo.current+jn.cmdTipPhaseStep)%1,ea(Un(w,1-qo.current,Yc))},jn.cmdTipInterval);return()=>clearInterval(E)},[zo,bt.length]),xe(()=>{let T=setInterval(()=>{j(w=>(w+1)%Fr.length)},500);return()=>clearInterval(T)},[]),xe(()=>{let T=!1;if(!s||!i)return;let w=wc({name:"deepseek",apiKey:s,baseUrl:i,model:tt}),E=a??new Me,z=new un;return z.registerAll(Jc),(async()=>{let P=new Gn,te=[];try{let{loadAllSkills:O}=await import("./loader-GPVLJCXF.js"),A=await O(process.cwd());if(te=A.skills,Yu.current=A.skills,o&&A.errors.length>0)for(let L of A.errors)console.warn(` \u26A0 ${L.message} (${L.skillFilePath})`)}catch(O){o&&console.warn(` \u26A0 \u52A0\u8F7D skill \u5931\u8D25\uFF1A${O instanceof Error?O.message:String(O)}`)}if(c){let{permissionsFromConfig:O}=await import("./permissions-loader-YST5MXNS.js"),{InteractiveGate:A}=await import("./interactive-gate-WMAYTMZ6.js"),L=O(c);if(!T){let W=new A({engine:L.engine,grants:void 0,prompt:ca,defaultDecision:"confirm"}),Y=new Io(w,z,E,{cwd:process.cwd(),gate:new fn([new Gn,W]),skills:te});ue.current=Y,cs.register({id:Y.id,cwd:process.cwd(),chat:(ft,Xn)=>Y.chat(ft,Xn)},()=>Y.drainLog(),{onRemoteUserInput:async(ft,Xn)=>{if(!Nr.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await Nr.current(ft,Xn,{displayText:ft})}})}if(o&&L.warnings.length>0)for(let W of L.warnings)console.warn(` \u26A0 ${W}`)}else{let{WriteConfirmGate:O}=await import("./write-gate-HEFJJQX6.js");if(!T){let A=new O(z,ca),L=new Io(w,z,E,{cwd:process.cwd(),gate:new fn([P,A]),skills:te});ue.current=L,cs.register({id:L.id,cwd:process.cwd(),chat:(W,Y)=>L.chat(W,Y)},()=>L.drainLog(),{onRemoteUserInput:async(W,Y)=>{if(!Nr.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await Nr.current(W,Y,{displayText:W})}})}}})(),()=>{T=!0,ue.current&&cs.unregister(ue.current.id),ue.current=null}},[s,i,tt,a,ca,o]),xe(()=>{if(!s||!i)return;let T=!1;return Vn(!0),import("./deepseek-X6USE3PW.js").then(({DeepSeekProvider:w})=>new w({apiKey:s,baseUrl:i,model:"deepseek-v4-flash"}).getBalance()).then(w=>{if(T)return;let E=w.balances.find(z=>z.currency==="CNY");E&&ce(E.totalBalance)}).catch(()=>{}).finally(()=>{T||Vn(!1)}),()=>{T=!0}},[s,i]),xe(()=>{if(!a)return;let T=!1,w,E=()=>{Du(a.todayTotalCost)};return a.load().then(()=>{T||(E(),w=setInterval(E,5e3))}).catch(()=>{}),()=>{T=!0,w&&clearInterval(w)}},[a]),xe(()=>{if(ae||!gn){Ui([]);return}Bo.current=0,Ui(Un(gn,1,Zc));let T=setInterval(()=>{Bo.current=(Bo.current+jn.idlePhaseStep)%1,Ui(Un(gn,1-Bo.current,Zc))},jn.idleInterval);return()=>clearInterval(T)},[ae,gn]),xe(()=>{if(!ae||!hn){Hi([]);return}Fo.current=0,Hi(Un(hn,1,Qc));let T=setInterval(()=>{Fo.current=(Fo.current+jn.streamingPhaseStep)%1,Hi(Un(hn,1-Fo.current,Qc))},jn.streamingInterval);return()=>clearInterval(T)},[ae,hn]);let as=ct(async(T,w,E)=>{let z=ue.current;if(!z){C(O=>[...O,{role:"user",content:E.displayText},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]);return}let P=w==="chrome"?`\u{1F310} [chrome] ${E.displayText}`:w==="api"?`\u{1F50C} [api] ${E.displayText}`:w==="test"?`\u{1F9EA} [test] ${E.displayText}`:E.displayText;C(O=>[...O,{role:"user",content:P}]),Mo(!0),Pt("thinking"),Gi(gu(uC)),zi(""),Ki([]),Xi([]),Bu(void 0),Fu(void 0),ju(void 0),Wu(void 0),jo(void 0),Nu(new Map),rs.current=new Map,es.current="",ts.current=[],ns.current=[],ua.current=void 0,da.current=void 0,pa.current=void 0,fa.current=void 0,ss.current=void 0,sa.current=!1,oa("idle"),wt.current&&(clearTimeout(wt.current),wt.current=null),Uo([]),Xt.current&&(clearTimeout(Xt.current),Xt.current=null),Wo(!1),Qt({phase:"idle",progress:null}),Kn.current=void 0,Ne.current&&(clearTimeout(Ne.current),Ne.current=null);let te=new AbortController;aa.current=te;try{for await(let O of z.chat(T,{thinkingAllowed:E.thinkingAllowed,thinkingEffort:E.thinkingEffort,...E.responseFormat?{responseFormat:E.responseFormat}:{},...E.toolChoice?{toolChoice:E.toolChoice}:{}})){if(te.signal.aborted)break;switch(O.type){case"text_delta":Pt("generating"),zi(A=>{let L=A+O.content;return es.current=L,L});break;case"reasoning_delta":Pt("thinking"),Ki(A=>{let L=A[A.length-1],W=L!==void 0?[...A.slice(0,-1),L+O.content]:[...A,O.content];return ts.current=W,W});break;case"tool_calls":Pt("calling_tools"),Xi(A=>{let L=[...A,...O.calls];return ns.current=L,L});for(let A of O.calls)if(cC(A.name)){sa.current=!0;break}break;case"tool_result":Pt("executing_tools"),setTimeout(()=>Pt("thinking"),300),zi(""),es.current="",Ki(A=>{let L=[...A,""];return ts.current=L,L}),Xi([]),ns.current=[];{let A=O.callId??`${O.name}#${O.result.data.length}`;Nu(L=>{let W=new Map(L);return W.set(A,{success:O.result.success,...O.result.error?{error:O.result.error}:{},...O.result.denial?{denial:O.result.denial}:{}}),rs.current=W,W})}{let A=O.result;if(O.name.startsWith("todo_")&&O.todoSnapshot){let L=[...O.todoSnapshot];L.length>0&&L.every(Y=>Y.status==="done"||Y.status==="failed"||Y.status==="skipped")?(Ar.current=Math.max(...L.map(Y=>Y.id)),Uo(L)):Ar.current>=0?Uo(L.filter(Y=>Y.id>Ar.current)):Uo(L)}else{let L=A.success?A.summary??`\u2705 ${O.name}: ${A.data.slice(0,500)}${A.data.length>500?"...":""}`:`\u274C ${O.name}: ${A.error??"\u6267\u884C\u5931\u8D25"}`;C(W=>[...W,{role:"tool",content:L,diff:A.diff}])}}break;case"usage":Bu(O.usage),Wu(O.model),ua.current=O.usage,fa.current=O.model;{let A=kt(O.usage,O.model);ju(A.totalCost),pa.current=A.totalCost}break;case"done":Fu(O.elapsed),da.current=O.elapsed;break;case"error":jo(O.error.message),ss.current=O.error.message;break}}}catch(O){let A=O instanceof Error?O.message:String(O);jo(A),ss.current=A}finally{Mo(!1),Pt(null),Tg(gu(Lh)),aa.current=null;let O=es.current,A=ts.current.map(Y=>Y.trim()).filter(Y=>Y.length>0),L=Ph(ns.current),W=ss.current;if(O||L||W){let Y={content:W?`\u26A0 \u8BF7\u6C42\u51FA\u9519\uFF1A${W}`:O||"",...A.length>0?{reasoning:A}:{},toolCalls:L,toolResults:rs.current.size>0?new Map(rs.current):void 0,usage:ua.current,elapsed:da.current,cost:pa.current,model:fa.current};C(ft=>[...ft,{role:"assistant",content:Y.content,assistantDetail:Y}])}sa.current&&!W&&(oa("pending"),wt.current&&clearTimeout(wt.current),wt.current=setTimeout(()=>{oa(Y=>Y==="pending"?"visible":Y),wt.current=null},2e3))}},[]),Nr=le(null);xe(()=>{Nr.current=as},[as]);let td=ct(async T=>{if(is(T,qn))return;let w=T.trim();if(!w)return;let E=w;if(w.startsWith("/")&&w.length>1){let P=w.toLowerCase();if(P==="/rewind"||P.startsWith("/rewind ")){if(ae||ra){let W=ra?"\u56DE\u9000\u4E2D":"\u751F\u6210\u4E2D";C(Y=>[...Y,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u6B63\u5728${W}\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /rewind\u3002`}]),N("");return}if(!ue.current){C(W=>[...W,{role:"user",content:w},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u56DE\u9000\u3002"}]),N("");return}let A=ue.current.listCheckpoints();if(A.length===0){C(W=>[...W,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u6CA1\u6709\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u3002
590
+ \u53EA\u6709\u5728 git \u4ED3\u5E93\u5185\u4E14\u53D1\u751F\u8FC7\u5BF9\u8BDD\u540E\u624D\u4F1A\u751F\u6210\u68C0\u67E5\u70B9\u3002`}]),N("");return}let L=w.split(/\s+/);if(L.length>=2){let W=Number(L[1]);if(!Number.isInteger(W)||W<1||W>A.length){C(ft=>[...ft,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u65E0\u6548\u7684\u5E8F\u53F7\u300C${L[1]}\u300D\u3002\u53EF\u7528\u8303\u56F4 1~${A.length}\uFF081 \u8868\u793A\u6700\u65B0\uFF09\u3002`}]),N("");return}let Y=A[A.length-W];N(""),await ha(Y,W);return}vg([...A].reverse()),Jo(0),Xo(!0),C(W=>[...W,{role:"user",content:w},{role:"assistant",content:`\u23F7\u2191\u2193 \u9009\u62E9\u68C0\u67E5\u70B9\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88\uFF08\u5171 ${A.length} \u4E2A\u53EF\u56DE\u9000\u4F4D\u7F6E\uFF09`}]),N("");return}if(P==="/compact"){if(ae){C(A=>[...A,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u6B63\u5728\u751F\u6210\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /compact\u3002"}]),N("");return}if(!ue.current){C(A=>[...A,{role:"user",content:w},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u538B\u7F29\u3002"}]),N("");return}N(""),C(A=>[...A,{role:"user",content:w}]),Qt({phase:"running",progress:null,beforeTokens:void 0,afterTokens:void 0,droppedTurns:void 0,keptTurns:void 0,strategy:void 0,errorMessage:void 0});try{let A=await ue.current.compact(L=>{Qt(W=>{if(L.type==="start")return{...W,phase:"running",progress:L,beforeTokens:L.beforeTokens,droppedTurns:L.droppedTurns};if(L.type==="summary_delta")return{...W,phase:"running",progress:L};if(L.type==="fallback")return Kn.current="fallback",{...W,phase:"running",progress:L,strategy:"fallback"};if(L.type==="done"){let Y=Kn.current==="fallback"?"fallback":"summary";return Kn.current=Y,{...W,phase:"done",progress:L,droppedTurns:L.droppedTurns,keptTurns:L.keptTurns,beforeTokens:L.beforeTokens,afterTokens:L.afterTokens,strategy:Y}}return W})});A.droppedTurns===0?(Qt(L=>({...L,phase:"done",progress:L.progress,droppedTurns:0,keptTurns:A.keptTurns,beforeTokens:A.beforeTokens,afterTokens:A.afterTokens,strategy:void 0})),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{Qt({phase:"idle",progress:null}),C(L=>[...L,{role:"assistant",content:"\u2139 \u5F53\u524D\u5BF9\u8BDD\u592A\u77ED\uFF0C\u65E0\u9700\u538B\u7F29\uFF08\u5C11\u4E8E\u6700\u5C0F\u56DE\u5408\u6570 \u6216 \u90FD\u5728\u4FDD\u7559\u533A\u5185\uFF09\u3002"}])},2500)):(Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{let L=((A.beforeTokens-A.afterTokens)/Math.max(A.beforeTokens,1)*100).toFixed(1),W=Kn.current==="fallback"?`
591
+ \u26A0 \u6458\u8981\u4E3A\u672C\u5730\u5151\u5E95\uFF08LLM \u4E0D\u53EF\u7528\uFF09`:"";Qt({phase:"idle",progress:null}),Kn.current=void 0,C(Y=>[...Y,{role:"assistant",content:`\u2714 \u538B\u7F29\u5B8C\u6210\uFF1A${A.droppedTurns} \u56DE\u5408 \u2192 ${A.keptTurns} \u56DE\u5408\uFF08\u8282\u7701 ${L}% token\uFF09${W}`}])},4e3))}catch(A){let L=A instanceof Error?A.message:String(A);Qt(W=>({...W,phase:"error",errorMessage:L})),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{Qt({phase:"idle",progress:null}),C(W=>[...W,{role:"assistant",content:`\u26A0 \u538B\u7F29\u5931\u8D25\uFF1A${L}`}])},3e3)}return}if(P==="/model"){let A=Yt.indexOf(tt);Qo(A>=0?A:0),ia(!0),N("");return}if(P==="/voice"){N(""),ga();return}if(P==="/thinking"){Vu(A=>!A),C(A=>[...A,{role:"user",content:w},{role:"assistant",content:`\u6DF1\u5EA6\u601D\u8003\u5DF2${zn?"\u5173\u95ED":"\u5F00\u542F"}`}]),N("");return}if(P==="/effort"){let A=Er==="high"?"max":"high";zu(A),C(L=>[...L,{role:"user",content:w},{role:"assistant",content:`\u63A8\u7406\u7B49\u7EA7\u5DF2\u5207\u6362\u4E3A ${A==="high"?"High":"Max"}`}]),N("");return}if(P==="/plan"){Jt==="plan"?C(A=>[...A,{role:"user",content:w},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u8BA1\u5212\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002"}]):(Ho("plan"),ue.current?.setMode("plan"),Vo(void 0),C(A=>[...A,{role:"user",content:w},{role:"assistant",content:`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**
588
592
 
589
593
  \u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C\u6211\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u4F1A\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u3002
590
- \u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002`}]),ue.current?.reset()),$("");return}if(P==="/code"){Jt==="code"?T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u4EE3\u7801\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /plan \u5207\u56DE\u8BA1\u5212\u6A21\u5F0F\u3002"}]):(Uo("code"),ue.current?.setMode("code"),Wo(void 0),T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**
594
+ \u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002`}]),ue.current?.reset()),N("");return}if(P==="/code"){Jt==="code"?C(A=>[...A,{role:"user",content:w},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u4EE3\u7801\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /plan \u5207\u56DE\u8BA1\u5212\u6A21\u5F0F\u3002"}]):(Ho("code"),ue.current?.setMode("code"),Vo(void 0),C(A=>[...A,{role:"user",content:w},{role:"assistant",content:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**
591
595
 
592
596
  \u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002
593
- \u8F93\u5165 /plan \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08\u53EA\u8BFB\u5206\u6790\uFF09\u3002`}]),ue.current?.reset()),$("");return}if(P==="/tools"){let R=Lr===void 0?"none":Lr==="none"?"required":Lr==="required"?"auto":void 0;Wo(R);let L=R===void 0?"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09":R==="none"?"\u7981\u6B62\u8C03\u7528":R==="required"?"\u5F3A\u5236\u8C03\u7528":"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09";T(j=>[...j,{role:"user",content:k},{role:"assistant",content:`\u5DE5\u5177\u8C03\u7528\u7B56\u7565\u5DF2\u5207\u6362\u4E3A ${L}`}]),$("");return}let te=fu.get(P);if(te){let R=te.handler();switch(R.kind){case"exit":await ue.current?.flushLog(),process.exit(0);return;case"clear":T([]),F(L=>L+1),$(""),Fo(void 0),process.stdout.write("\x1B[2J\x1B[H\x1B[3J"),ue.current?.reset(),Ir.current=-1;return;case"navigate":$(""),R.target==="game"?g?.():R.target==="stock"&&b?.();return;case"text":T(L=>[...L,{role:"user",content:k},{role:"assistant",content:R.content}]),$("");return;case"permissions":{let L=ue.current;if(!L){T(nt=>[...nt,{role:"user",content:k},{role:"assistant",content:"Session \u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}]),$("");return}let j=L.gate,Z=[],ft=0,Zn="",ss="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09";if(j instanceof fn){let nt=j.gates;Zn=nt.length===0?"(\u7A7A)":`\u5171 ${nt.length} \u4E2A`;try{let ha=(await import("./interactive-gate-XKNHF4ZY.js")).InteractiveGate;for(let Br of nt)Br instanceof ha&&(Z=Br.engine.rules,ft=Br.grants.size,ss="\u89C4\u5219\u5F15\u64CE")}catch{}Z.length===0&&(ss="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09")}else ss="\u672A\u77E5";let mt=[];if(mt.push("\u{1F4CB} \u5F53\u524D\u6743\u9650\u7CFB\u7EDF\u72B6\u6001\uFF1A"),mt.push(` Gate \u94FE\uFF1A${Zn}`),mt.push(` \u6A21\u5F0F\uFF1A${ss??"\u672A\u77E5"}`),Z.length===0)mt.push(" \u89C4\u5219\u6570\uFF1A0\uFF08\u9ED8\u8BA4\u6A21\u5F0F\uFF1A\u8BFB/\u7EC8\u7AEF\u76F4\u63A5\u653E\u884C\uFF0C\u6539\u6587\u4EF6\u9700\u786E\u8BA4\uFF09");else{mt.push(` \u89C4\u5219\u6570\uFF1A${Z.length}`);for(let nt=0;nt<Z.length;nt++){let wn=Z[nt],ha=wn.match?JSON.stringify(wn.match):"(\u5168\u90E8\u5339\u914D)",Br=wn.reason?` \u2014 ${wn.reason}`:"";mt.push(` ${nt+1}. ${wn.tool} \u2192 ${wn.action}\uFF08${ha}\uFF09${Br}`)}}mt.push(` \u4F1A\u8BDD grants\uFF1A${ft} \u4E2A\uFF08"always" \u6279\u51C6\u7684\u5DE5\u5177\u8C03\u7528\uFF09`),mt.push(""),mt.push("\u914D\u7F6E\u6587\u4EF6\uFF1A~/.dskcode/permissions.json\uFF08\u5168\u5C40\uFF09"),mt.push(" .dskcode/permissions.json\uFF08\u9879\u76EE\u7EA7\uFF0C\u9879\u76EE\u7EA7\u4F18\u5148\uFF09"),T(nt=>[...nt,{role:"user",content:k},{role:"assistant",content:mt.join(`
594
- `)}]),$("");return}}}let D=await xm(k,zu.current);if(D.kind==="no-match"){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u672A\u77E5\u547D\u4EE4\uFF1A${k}\u3002\u8F93\u5165 /help \u67E5\u770B\u3002`}]),$("");return}if(D.kind==="error"){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6FC0\u6D3B skill \u5931\u8D25\uFF1A${D.message}`}]),$("");return}I=D.text}if(!ue.current){T(P=>[...P,{role:"user",content:k},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]),$("");return}let V=I!==k?(()=>{let P=/^\/(\S+)(?:\s+(.*))?$/.exec(k),te=P?.[1]??"",D=(P?.[2]??"").trim();return D?`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${te} \u2014 ${D}`:`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${te}`})():k;await os(I,"local",{displayText:V,thinkingAllowed:Kn||void 0,thinkingEffort:Kn?Pr:void 0,responseFormat:Ki!=="text"?Ki:void 0,toolChoice:Lr})},[g,b,ji,Wi,Bo,t,Or,ua,Kn,Pr,Ki,Lr,tt,Jt,ie,Qi,rs,Xn,os]);Se(()=>{!ie&&a&&Eu(a.todayTotalCost)},[ie,a]);let _g=Th(()=>K(H,{flexDirection:"column",flexGrow:1,children:[K(H,{flexDirection:"column",flexGrow:1,children:[!$r&&K(H,{flexDirection:"column",alignItems:"flex-start",flexGrow:1,paddingBottom:1,children:[bt.length>0&&(()=>{let C=bt[Ho%bt.length];if(!C)return null;let k=`${C.name} ${C.desc}`;return K(H,{marginTop:1,alignSelf:"center",children:[O(G,{color:"#808080",children:"\u{1F4A1} "}),Xi.length>0?k.split("").map((I,V)=>O(G,{color:Xi[V]||void 0,children:I},V)):O(G,{color:"#808080",children:k})]})})(),O(H,{flexGrow:1}),O(mh,{panelWidth:_})]}),K(H,{flexDirection:"column",marginTop:1,children:[O(HT,{items:U,children:(C,k)=>{if(C.role==="user")return K(H,{marginTop:1,flexDirection:"row",children:[O(H,{width:1,backgroundColor:"#FF8C00",flexShrink:0}),O(H,{flexGrow:1,paddingLeft:1,children:K(H,{flexDirection:"row",children:[O(H,{width:4,flexShrink:0,children:O(G,{bold:!0,color:"#FF8C00",children:"\u{1F4AC}"})}),O(H,{flexGrow:1,children:O(G,{wrap:"wrap",children:C.content})})]})})]},k);if(C.role==="tool")return K(H,{marginTop:1,flexDirection:"row",children:[O(H,{width:1,backgroundColor:"#666666",flexShrink:0}),K(H,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[K(H,{flexDirection:"row",children:[O(H,{width:4,flexShrink:0,children:O(G,{dimColor:!0,children:"\u{1F527}"})}),O(H,{flexGrow:1,children:O(G,{dimColor:!0,wrap:"wrap",children:C.content})})]}),C.diff&&O(Ua,{diff:C.diff})]})]},k);let I=C.assistantDetail;return O(ps,{content:C.content,toolCalls:I?.toolCalls,isStreaming:!1,usage:I?.usage,elapsed:I?.elapsed,cost:I?.cost,model:I?.model,toolResults:I?.toolResults},k)}},N),ie&&O(ps,{content:ji,toolCalls:Bo.length>0?Bo:void 0,isStreaming:!0,usage:Pu,cost:Ou,model:Nu,toolResults:yg}),Vu.phase!=="idle"&&O(hc,{state:Vu,contentWidth:_}),oe!==null&&O(H,{borderStyle:"single",borderColor:"cyan",paddingX:1,marginBottom:1,children:O(G,{color:"cyan",children:"\u27F3 \u914D\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D\uFF08\u8FD0\u884C\u65F6\u751F\u6548\uFF09"})}),O(hh,{pending:kg,onResponse:Sg}),!ie&&qi&&O(H,{marginTop:1,marginLeft:3,children:K(G,{color:"red",children:["\u26A0 ",qi]})})]}),Bu&&yn.length>0&&O(mc,{items:yn})]}),Zt?K(H,{marginTop:1,flexDirection:"column",children:[O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)}),K(H,{flexDirection:"column",marginTop:1,children:[O(G,{bold:!0,color:"#00ffff",children:"\u9009\u62E9\u6A21\u578B\uFF1A"}),Yt.map((C,k)=>{let I=kn[C],V=C===tt,P=k===Jo,te=P?" > ":" ",D=V?" (\u5F53\u524D)":"";return K(H,{children:[K(G,{color:P?"#00ff41":void 0,bold:P,children:[te,I.displayName,D]}),P&&K(G,{color:"#808080",children:[" \u2014 ",C]})]},C)}),O(H,{marginTop:1,children:O(G,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})]}):xn?K(H,{marginTop:1,flexDirection:"column",children:[O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)}),K(H,{flexDirection:"column",marginTop:1,children:[O(G,{bold:!0,color:"#ff9800",children:"\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A"}),bn.map((C,k)=>{let I=k===Dr,V=I?" > ":" ",P=new Date(C.timestamp).toLocaleTimeString(),te=C.preview||"(\u7A7A)",D=C.isGitRepo?"":" [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";return O(H,{children:K(G,{color:I?"#ff9800":void 0,bold:I,children:[V,"#",k+1," ",P," `",te,D,"`"]})},C.index)}),O(H,{marginTop:1,children:O(G,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})]}):K(vh,{children:[($r||Jt==="plan")&&ie&&Er?O(H,{marginTop:1,justifyContent:"center",children:K(G,{bold:!0,color:uu[Er].color,children:[uu[Er].icon," ",uu[Er].label," ",O(VT,{type:"dots"})]})}):Hu==="visible"?O(H,{marginTop:1,justifyContent:"center",children:O(G,{color:"#808080",children:"\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539"})}):Ar&&Ar.ratio>.85?O(H,{marginTop:1,justifyContent:"center",children:K(G,{color:"#ff9800",children:["\u{1F4DA} \u4E0A\u4E0B\u6587\u5DF2\u7528 ",(Ar.ratio*100).toFixed(0),"%\uFF0C\u8F93\u5165 /compact \u53EF\u624B\u52A8\u538B\u7F29"]})}):null,O(H,{marginTop:1,children:O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})}),K(H,{children:[O(H,{width:4,flexShrink:0,children:O(G,{bold:!0,color:"#00ff41",children:"\u26A1"})}),K(H,{flexGrow:1,children:[Nr?O(G,{color:"#808080",children:"Ctrl+P \u6587\u4EF6\u641C\u7D22\u4E2D\u2026\uFF08Esc \u53D6\u6D88\uFF09"}):!q&&!ie&&gn&&Mi.length>0?O(G,{children:gn.split("").map((C,k)=>O(G,{color:Mi[k]??void 0,children:C},k))}):!q&&ie&&hn&&Fi.length>0?O(G,{children:hn.split("").map((C,k)=>O(G,{color:Fi[k]??void 0,children:C},k))}):O(ym,{value:q,onChange:$,onSubmit:Ju,placeholder:"",focus:!Nr},Uu),Pe!=="idle"&&K(H,{children:[K(G,{color:Pe==="error"?"red":"cyan",children:[Pe==="connecting"&&"\u25CC \u6B63\u5728\u8FDE\u63A5 ASR \u670D\u52A1...",Pe==="recording"&&`\u25CF \u5F55\u97F3\u4E2D ${$i}`,Pe==="finalizing"&&`\u25CC \u7B49\u5F85\u670D\u52A1\u7AEF\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C ${$i}`,Pe==="error"&&`\u2717 \u9519\u8BEF ${$i}`]}),O(G,{dimColor:!0,children:" (\u518D\u6309 F2 \u7ED3\u675F\uFF0CESC \u53D6\u6D88)"})]})]})]}),O(H,{children:O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})}),O(Va,{skills:t,input:q,selectedIndex:Or}),O(uc,{files:n,input:q,selectedIndex:Xn,cwd:process.cwd(),width:_})]})]}),[U,N,ie,ji,Bo,Pu,Ou,Nu,qi,yn,Bu,Zt,Yt,tt,Jo,zi,Zo,xn,bn,Dr,qo,Ko,Hu,$r,Jt,Er,gn,Mi,hn,Fi,q,$,_,Ju,t,Or,n,Xn,Uu,bt,Ho,Xi]),vg=typeof process.stdout.rows=="number"?Math.max(process.stdout.rows-4,10):24,Rg=C=>{$(k=>`${k.endsWith(" ")||k.length===0?k:k+" "}@${C} `),Yi(k=>k+1),Xo(!1)};return K(H,{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[Nr&&O(hm,{files:n,cwd:process.cwd(),width:S,height:vg,onPick:Rg,onClose:()=>Xo(!1)}),!Nr&&K(vh,{children:[K(H,{flexDirection:"row",flexGrow:1,children:[O(H,{width:v,flexShrink:0,flexDirection:"column",children:O(H,{paddingX:1,flexDirection:"column",flexGrow:1,justifyContent:$r?"flex-end":"center",children:$r?xg?O(G,{dimColor:!0,wrap:"wrap",children:(()=>{let C=fh(Wi),k=11,V=C.split(`
595
- `).slice(-k);for(;V.length<k;)V.unshift("");return V.join(`
596
- `)})()}):K(H,{flexDirection:"column",alignItems:"center",children:[O(G,{color:"#00ffff",bold:!0,children:"\u{1F4AC} \u5BF9\u8BDD\u8FDB\u884C\u4E2D"}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#00ff41",children:["\u{1F4DD} \u6D88\u606F ",U.length," \u6761"]}),ju>0&&K(G,{color:"cyan",children:["\u{1F4B0} \u4F1A\u8BDD \xA5",ju.toFixed(4)]}),Ar&&O(JT,{stats:Ar})]}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#808080",children:["\u{1F527} ",kn[tt]?.displayName??tt]}),Kn&&K(G,{color:"#ff9800",children:["\u{1F9E0} ",Pr==="max"?"Max":"High"]})]}),W!==null&&O(H,{marginTop:1,children:K(G,{color:"yellow",children:["\u{1F4B0} \xA5",W.toFixed(2)]})})]}):K(H,{flexDirection:"column",alignItems:"center",children:[Ia.map((C,k)=>{let I=(k+E)%Gr.length;return O(G,{bold:!0,color:Gr[I],children:C},k)}),O(H,{marginTop:1,children:K(G,{color:"#808080",children:["\u{1F4E6} v",So]})}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#00ff41",children:["\u2714 ",e," Skills"]}),K(G,{color:"#00ffff",children:["\u2139 ",r," \u5DE5\u5177"]}),K(G,{color:"#00ffff",children:["\u{1F527} ",kn[tt]?.displayName??tt]}),Kn&&K(G,{color:"#ff9800",children:["\u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",Pr==="max"?"Max":"High"]}),Jt==="plan"&&O(G,{color:"#ff69b4",bold:!0,children:"\u{1F4CB} \u8BA1\u5212\u6A21\u5F0F"})]}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[W!==null?K(G,{color:"yellow",children:["\u{1F4B0} \u4F59\u989D \xA5",W.toFixed(2)]}):ce?O(G,{color:"yellow",children:"\u23F3 \u67E5\u8BE2\u4F59\u989D..."}):null,qn!==null&&K(G,{color:"cyan",children:["\u{1F4CA} \u4ECA\u65E5 \xA5",qn.toFixed(2)]})]}),o&&O(G,{color:"#ff1493",children:"\u26A1 Verbose"})]})})}),_g]}),Cg&&!ie&&O(H,{marginTop:1,children:O(G,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})}),ie&&O(H,{marginTop:1,children:O(G,{color:"yellow",dimColor:!0,children:" \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42"})})]})]})}var pu=12;function KT(e){return e>=.85?"danger":e>=.6?"warning":"safe"}function XT(e){switch(e){case"danger":return"#ff6347";case"warning":return"#ffcc00";case"safe":return"#00ff41"}}function JT({stats:e}){let t=KT(e.ratio),n=XT(t),r=Math.min(pu,Math.max(e.ratio>0?1:0,Math.round(e.ratio*pu))),o=pu-r;return K(G,{color:n,children:["\u{1F4DA} ",O(G,{color:n,children:"\u2588".repeat(r)}),O(G,{color:"#444444",children:"\u2591".repeat(o)})," ",(e.ratio*100).toFixed(1),"%"]})}p();import{Box as qt,Text as Vn,useInput as ZT}from"ink";import{useState as YT,useCallback as QT}from"react";import{jsx as He,jsxs as Ah}from"react/jsx-runtime";function vi({games:e,onSelect:t,onExit:n,onBackToChat:r}){let[o,s]=YT(0),i=r??n??(()=>process.exit(0)),{doubleCtrlC:a,handleCtrlC:l}=Sn(i);return ZT(QT((c,u)=>{if(c==="c"&&u.ctrl){l();return}if(e.length!==0)if(u.upArrow||c==="k")s(d=>d>0?d-1:e.length-1);else if(u.downArrow||c==="j")s(d=>d<e.length-1?d+1:0);else if(u.return){let d=e[o];d&&t(d)}else(u.escape||c==="q")&&(r?r():n?.())},[e,o,t,n,r,l])),Ah(qt,{flexDirection:"column",children:[He(qt,{marginBottom:1,children:He(Vn,{bold:!0,color:"#00ffff",children:"\u{1F3AE} \u6E38\u620F\u5217\u8868"})}),He(qt,{flexDirection:"column",children:e.map((c,u)=>{let d=u===o;return Ah(qt,{flexDirection:"row",children:[He(qt,{width:3,flexShrink:0,children:d?He(Vn,{bold:!0,color:"#00ff41",children:"\u25B8 "}):He(Vn,{children:" "})}),He(qt,{width:20,flexShrink:0,children:He(Vn,{bold:!0,color:d?"#00ff41":"#ffffff",children:c.name})}),He(qt,{children:He(Vn,{color:"#888888",children:c.description})})]},c.id)})}),He(qt,{marginTop:1,children:He(Vn,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE"})}),a&&He(qt,{marginTop:1,children:He(Vn,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}p();p();var hu=new Map;function Ri(e){hu.set(e.id,e)}function Eh(e){return hu.get(e)}function Io(){return Array.from(hu.values())}p();import{Box as Ve,Text as xe,useInput as eC,render as tC}from"ink";import{useState as gu,useEffect as nC,useRef as Ih,useCallback as yu}from"react";import{jsx as fe,jsxs as ze}from"react/jsx-runtime";var ut=40,Tr=18,Cr=9,Ph=[166,214,76,69],xu=[{rows:4,cols:8,bw:3,desc:"\u7ECF\u5178 4\xD78",pattern:()=>!0},{rows:3,cols:8,bw:3,desc:"\u8F7B\u677E 3 \u5C42",pattern:()=>!0},{rows:6,cols:8,bw:3,desc:"\u539A\u5899 6 \u5C42",pattern:()=>!0},{rows:4,cols:8,bw:3,desc:"\u68CB\u76D8\u683C",pattern:(e,t)=>(e+t)%2===0},{rows:4,cols:8,bw:3,desc:"\u91D1\u5B57\u5854",pattern:(e,t,n,r)=>e>=t&&e<r-t},{rows:4,cols:8,bw:3,desc:"\u4EA4\u9519\u6392\u5217",pattern:(e,t)=>t%2===0||e>=1&&e<=6},{rows:4,cols:8,bw:3,desc:"\u4E2D\u7A7A\u8FB9\u6846",pattern:(e,t,n,r)=>t===0||t===n-1||e===0||e===r-1},{rows:4,cols:10,bw:2,desc:"\u5BC6\u96C6 10 \u5217",pattern:()=>!0},{rows:7,cols:8,bw:3,desc:"\u9AD8\u5899 7 \u5C42",pattern:()=>!0},{rows:8,cols:8,bw:3,desc:"\u6EE1\u5C4F 8 \u5C42",pattern:()=>!0}];function bu(e){return xu[(e-1)%xu.length]}function rC(e){let t=bu(e),n=[],r=2,o=t.cols*t.bw+(t.cols-1)*r,s=Math.floor((ut-o)/2),i=t.bw+r;for(let a=0;a<t.rows;a++)for(let l=0;l<t.cols;l++)t.pattern(l,a,t.rows,t.cols)&&n.push({x:s+l*i,y:2+a*2,w:t.bw,alive:!0});return n}function Lh(e){let t=bu(e),n=t.cols*t.bw+(t.cols-1)*2,r=Math.floor((ut-n)/2);return{level:e,bricks:rC(e),paddleX:Math.floor(ut/2)-Math.floor(Cr/2),ball:{x:ut/2,y:Tr-3},ballDir:{x:1,y:-1},score:0,lives:3,gameOver:!1,win:!1,paused:!1}}function oC(e){if(e.paused||e.gameOver||e.win)return;if(e.ball.x+=e.ballDir.x,e.ball.y+=e.ballDir.y,e.ball.x<=0&&(e.ball.x=0,e.ballDir.x=1),e.ball.x>=ut-1&&(e.ball.x=ut-1,e.ballDir.x=-1),e.ball.y<=0&&(e.ball.y=0,e.ballDir.y=1),e.ball.y===Tr-1&&e.ball.x>=e.paddleX&&e.ball.x<=e.paddleX+Cr){e.ballDir.y=-1;let n=(e.ball.x-e.paddleX)/Cr;e.ballDir.x=n<.5?-1:1}e.ball.y>Tr&&(e.lives--,e.lives<=0?e.gameOver=!0:(e.ball={x:ut/2,y:Tr-3},e.ballDir={x:1,y:-1},e.paddleX=Math.floor(ut/2)-Math.floor(Cr/2)));let t=e.bricks.find(n=>n.alive?e.ball.x>=n.x&&e.ball.x<n.x+n.w&&e.ball.y>=n.y&&e.ball.y<n.y+1:!1);t&&(t.alive=!1,e.score+=10,e.ballDir.y=-e.ballDir.y),e.bricks.every(n=>!n.alive)&&(e.win=!0)}function sC(e){let t=[];function n(r,o){let s=Math.floor((o-2)/2);if(s>=0&&e.bricks.find(a=>a.y===o&&a.alive&&r>=a.x&&r<a.x+a.w))return s%Ph.length}for(let r=0;r<Tr;r++){let o="";for(let s=0;s<ut;s++){let i=e.ball.x===s&&e.ball.y===r,a=r===Tr-1&&s>=e.paddleX&&s<e.paddleX+Cr,l=n(s,r);i?o+="\x1B[97m\u25CF\x1B[0m":a?o+="\x1B[94m\u2584\x1B[0m":l!==void 0?o+=`\x1B[38;5;${Ph[l]}m\u2580\x1B[0m`:o+=" "}t.push(o)}return t.map(r=>`\u2502${r}\u2502`).join(`
597
- `)}function iC({onExit:e}){let[t,n]=gu(1),[r,o]=gu(!0),s=Ih(Lh(t)),[i,a]=gu(0),l=Ih(e);l.current=e,nC(()=>{if(r)return;let g=setInterval(()=>{oC(s.current),a(b=>b+1)},80);return()=>clearInterval(g)},[r]);let c=yu(g=>{let b=g??s.current.level;s.current=Lh(b),n(b),o(!1),a(0)},[]),u=yu(()=>{o(!0)},[]);eC(yu((g,b)=>{let w=s.current;if(r){g>="1"&&g<="9"?c(Number(g)):g==="0"?c(10):(b.escape||g==="q")&&l.current();return}b.leftArrow?(w.paddleX=Math.max(0,w.paddleX-1),a(S=>S+1)):b.rightArrow?(w.paddleX=Math.min(ut-Cr,w.paddleX+1),a(S=>S+1)):g==="p"||g===" "?w.paused=!w.paused:g==="r"?(w.gameOver||w.win)&&c():g==="l"?(w.gameOver||w.win)&&u():(g==="q"||b.escape)&&l.current()},[r,c,u]));let d=s.current,m=d.bricks.filter(g=>g.alive).length,h=sC(d),f=bu(d.level);return ze(Ve,{flexDirection:"column",children:[ze(Ve,{flexDirection:"row",children:[fe(Ve,{width:20,children:ze(xe,{children:["\u5173\u5361 ",d.level,": ",fe(xe,{color:"cyan",children:f.desc})]})}),fe(Ve,{width:12,children:ze(xe,{children:["\u5206\u6570: ",fe(xe,{color:"yellow",children:String(d.score).padStart(3,"0")})]})}),fe(Ve,{width:12,children:ze(xe,{children:["\u751F\u547D: ",fe(xe,{color:"red",children:"\u2665".repeat(Math.max(0,d.lives))})]})}),fe(Ve,{width:10,children:ze(xe,{children:["\u7816\u5757: ",fe(xe,{color:"cyan",children:m})]})}),fe(Ve,{children:ze(xe,{color:d.paused?"gray":"green",children:["[",d.paused?"\u6682\u505C":"\u8FD0\u884C\u4E2D","]"]})})]}),ze(Ve,{flexDirection:"column",children:[ze(xe,{children:["\u250C","\u2500".repeat(ut),"\u2510"]}),fe(xe,{children:r?" \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m":h}),ze(xe,{children:["\u2514","\u2500".repeat(ut),"\u2518"]})]}),r&&ze(Ve,{marginTop:1,flexDirection:"column",children:[fe(xe,{bold:!0,color:"yellow",children:"\u9009\u62E9\u5173\u5361"}),fe(Ve,{flexDirection:"row",flexWrap:"wrap",children:xu.map((g,b)=>fe(Ve,{width:22,children:ze(xe,{children:[fe(xe,{color:t===b+1?"green":"white",children:b+1===10?"0":String(b+1)}),". ",g.desc," (",g.rows,"\xD7",g.cols,")"]})},b))}),fe(Ve,{marginTop:1,children:fe(xe,{dimColor:!0,children:"\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA"})})]}),!r&&(d.gameOver||d.win)&&ze(Ve,{marginTop:1,children:[fe(xe,{bold:!0,color:d.gameOver?"red":"green",children:d.gameOver?"\u6E38\u620F\u7ED3\u675F\uFF01":"\u606D\u559C\u901A\u5173\uFF01"}),ze(xe,{children:[" \u5206\u6570: ",fe(xe,{color:"yellow",children:d.score})]})]}),!r&&fe(Ve,{marginTop:1,children:d.gameOver||d.win?fe(xe,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA"}):fe(xe,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA"})})]})}var $h={id:"brick-breaker",name:"Brick Breaker",description:"\u7ECF\u5178\u6253\u7816\u5757\u6E38\u620F\uFF0C10 \u4E2A\u5173\u5361\u53EF\u9009\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=tC(fe(iC,{onExit:()=>{t(),e()}}))})}};p();import{Box as _r,Text as et,useInput as aC,render as lC}from"ink";import{useState as Oh,useEffect as Dh,useRef as Nh,useCallback as cC}from"react";import{jsx as yt,jsxs as Kt}from"react/jsx-runtime";var dt=66,Gh=20,ku=6,uC=10,vr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Mh={0:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],1:[" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],2:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],3:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],4:["\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],5:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],6:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],7:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],8:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],9:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "]};function dC(e){let t=["","","","",""];for(let r of e){let o=Mh[r]??Mh[0];for(let s=0;s<5;s++)t[s]+=" "+(o[s]??"")}let n=6;return t.map(r=>" ".repeat(n)+r)}function wu(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`${t};${n};${r}`}var Bh=["react","vue","next","node","axios","express","lodash","jquery","webpack","vite","babel","eslint","prettier","tailwind","bootstrap","sass","less","postcss","redux","pinia","vuex","router","nestjs","socket","graphql","rest","grpc","prisma","typeorm","html","css","jsx","tsx","dom","spa","ssr","csr","pwa","component","prop","hook","composable","directive","filter","mixin","template","render","virtual","diff","patch","hydration","responsive","flexbox","grid","animation","transition","api","route","middleware","controller","service","module","dto","entity","schema","migration","seeder","factory","auth","jwt","oauth","session","cookie","token","cors","cache","redis","mq","rabbit","kafka","nats","sql","mysql","pg","sqlite","mongo","redis","orm","table","index","query","join","union","group","order","where","having","limit","offset","insert","update","delete","docker","nginx","linux","bash","shell","yaml","toml","ci","cd","deploy","rollback","release","build","test","lint","format","stage","commit","branch","merge","rebase","array","stack","queue","tree","graph","list","map","set","sort","search","filter","reduce","map","async","await","promise","callback","closure","proxy","reflect","decorator","create","read","update","delete","crud","parse","stringify","encode","decode","transform","validate","format","parse","upload","download","export","import","backup","restore","string","number","boolean","object","array","tuple","enum","interface","type","class","function","method","property","public","private","static","readonly","optional","abstract","const","let","var","void","null","undef","never","any","config","logger","monitor","metric","alert","webhook","endpoint","payload","header","status","timeout","retry","fallback","circuit","breaker","throttle","debounce","scroll","resize","click","hover","focus","blur"];function pC(e){let t;do t=Bh[Math.floor(Math.random()*Bh.length)];while(e.has(t));return t}function Fh(){return{words:[],score:0,lives:3,speed:.3,spawnTimer:0,gameOver:!1,paused:!1,typed:"",target:null,combo:0,message:"",messageTimer:0,usedWords:new Set}}function Ai(e){let t=null;for(let n of e.words)(!t||n.col<t.col)&&(t=n);return t?.text??null}function fC(e){if(e.paused||e.gameOver)return;if(e.spawnTimer++,e.spawnTimer>=Math.max(20,50-Math.floor(e.speed*15))&&(e.spawnTimer=0,e.words.length<uC)){let r=new Set(e.usedWords);for(let a of e.words)r.add(a.text);let o=pC(r),s=new Set(e.words.map(a=>a.row)),i=-1;for(let a=ku;a<Gh;a++)if(!s.has(a)){i=a;break}i>=0&&(e.words.push({text:o,row:i,col:dt-1}),e.usedWords.add(o))}for(let r of e.words)r.col-=e.speed;let t=e.words.length;e.words=e.words.filter(r=>r.col>-r.text.length);let n=t-e.words.length;n>0&&(e.lives-=n,e.typed="",e.target=Ai(e),e.lives<=0&&(e.gameOver=!0,e.words=[])),e.target=Ai(e),e.messageTimer>0&&(e.messageTimer--,e.messageTimer<=0&&(e.message=""))}function mC(e,t,n,r){let o=[];for(let s=0;s<Gh;s++){let i="";if(s<ku){if(s<5){let a=(t[s]??"").padEnd(dt);i=`\x1B[38;2;${wu(n)}m${a}\x1B[0m`}else if(s===5){if(e.combo>=3){let a=`${e.combo}\u8FDE\u51FB!`,l=Math.floor((dt-a.length)/2),c=vr[e.combo%vr.length],u=" ".repeat(l)+a+" ".repeat(dt-l-a.length);i=`\x1B[38;2;${wu(c)}m${u}\x1B[0m`}else if(e.paused){let l=Math.floor((dt-2)/2);i=" ".repeat(l)+"\u6682\u505C",i=i.padEnd(dt)}}i=i.padEnd(dt)}else if(s===ku&&r){let a=Math.floor((dt-r.length)/2),l=" ".repeat(a)+r+" ".repeat(dt-a-r.length),c=vr[Math.floor(Math.random()*vr.length)];i=`\x1B[38;2;${wu(c)}m${l}\x1B[0m`}else for(let a=0;a<dt;a++){let l=e.words.find(c=>{let u=a-Math.floor(c.col);return u>=0&&u<c.text.length&&c.row===s});if(l){let c=a-Math.floor(l.col),u=l.text[c],d=l.text===e.target,m=e.target===l.text?e.typed.length:0,h=d&&c<m;d?i+=h?`\x1B[92m${u}\x1B[0m`:`\x1B[97m${u}\x1B[0m`:i+=`\x1B[90m${u}\x1B[0m`}else i+=" "}o.push(i)}return o}function hC({onExit:e}){let t=Nh(Fh()),[n,r]=Oh(0),[o,s]=Oh(0),i=Nh(e);i.current=e,Dh(()=>{let m=setInterval(()=>{s(h=>(h+1)%vr.length)},400);return()=>clearInterval(m)},[]),Dh(()=>{let m=setInterval(()=>{fC(t.current),r(h=>h+1)},60);return()=>clearInterval(m)},[]),aC(cC((m,h)=>{let f=t.current;if(f.gameOver){m==="r"?(t.current=Fh(),r(0)):(m==="q"||h.escape)&&i.current();return}if(m==="p"&&h.ctrl||m===" "){f.paused=!f.paused;return}if(m==="q"&&h.ctrl||h.escape){i.current();return}if(!f.paused&&m.length===1&&m>="a"&&m<="z"&&(f.target||(f.target=Ai(f)),f.target))if(f.target[f.typed.length]===m){if(f.typed+=m,f.typed===f.target){f.words=f.words.filter(E=>E.text!==f.target),f.combo++;let b=f.score,w=f.target.length,S=f.combo>=3?f.score:0;f.score+=w+S,f.speed=f.speed+.02;let v=Math.floor(b/500);Math.floor(f.score/500)>v&&(f.speed+=.15),f.score>=1e5&&b<1e5&&(f.message="\u606D\u559C\u901A\u5173! \u96BE\u5EA6\u6700\u5927\u5316!",f.messageTimer=100),f.typed="",f.target=Ai(f)}}else f.combo=0},[]));let a=t.current,l=vr[o],c=String(a.score).padStart(5,"0"),u=dC(c),d=mC(a,u,l,a.message);return Kt(_r,{flexDirection:"column",paddingX:1,children:[yt(_r,{flexDirection:"row",children:Kt(et,{children:["\u751F\u547D ",yt(et,{color:"red",children:"\u2665".repeat(Math.max(0,a.lives))})," ","\u901F\u5EA6 ",Kt(et,{color:"cyan",children:["Lv.",Math.floor(a.speed*10)]})]})}),!a.gameOver&&a.target&&yt(_r,{marginTop:1,children:Kt(et,{children:["\u6253\u5B57: ",yt(et,{color:"green",children:a.typed}),yt(et,{color:"white",children:a.target.slice(a.typed.length)})]})}),Kt(_r,{flexDirection:"column",marginTop:1,children:[Kt(et,{children:["\u250C","\u2500".repeat(dt),"\u2510"]}),d.map((m,h)=>yt(et,{children:`\u2502${m}\u2502`},h)),Kt(et,{children:["\u2514","\u2500".repeat(dt),"\u2518"]})]}),a.gameOver&&Kt(_r,{marginTop:1,children:[yt(et,{bold:!0,color:"red",children:"\u6E38\u620F\u7ED3\u675F\uFF01"}),Kt(et,{children:[" \u5F97\u5206: ",yt(et,{color:"yellow",children:a.score})," r \u91CD\u5F00 q \u9000\u51FA"]})]}),yt(_r,{marginTop:1,children:yt(et,{dimColor:!0,children:"\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA"})})]})}var jh={id:"coder-check",name:"Coder Check",description:"\u6781\u901F\u6253\u5B57\u6E38\u620F\uFF0C\u8F93\u5165\u5355\u8BCD\u6D88\u9664\u5B83\u4EEC\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=lC(yt(hC,{onExit:()=>{t(),e()}}))})}};p();p();function gC(e,t){return e==="UP"&&t==="DOWN"||e==="DOWN"&&t==="UP"||e==="LEFT"&&t==="RIGHT"||e==="RIGHT"&&t==="LEFT"}function Su(e,t){return e.x===t.x&&e.y===t.y}function yC(e,t){switch(t){case"UP":return{x:e.x,y:e.y-1};case"DOWN":return{x:e.x,y:e.y+1};case"LEFT":return{x:e.x-1,y:e.y};case"RIGHT":return{x:e.x+1,y:e.y}}}function xC(e,t){return{x:(e.x%t.width+t.width)%t.width,y:(e.y%t.height+t.height)%t.height}}function Tu(e,t,n,r=[]){let o=new Set(e.map(a=>`${a.x},${a.y}`));for(let a of r)o.add(`${a.x},${a.y}`);let s=t.width*t.height;if(o.size>=s)return null;let i;do i={x:Math.floor(Math.random()*t.width),y:Math.floor(Math.random()*t.height)};while(o.has(`${i.x},${i.y}`));return{position:i,type:n,...n==="special"?{spawnedAt:Date.now()}:{}}}function Cu(e){let t=Math.floor(e.width/2),n=Math.floor(e.height/2),r=[{x:t,y:n},{x:t-1,y:n},{x:t-2,y:n}],o=Tu(r,e,"normal");return{snake:r,direction:"RIGHT",nextDirection:"RIGHT",food:o,specialFood:null,score:0,speedLevel:1,isGameOver:!1,isPaused:!1,wallWrap:Math.random()<.5,tickInterval:e.initialSpeed}}function Wh(e,t){e.direction=e.nextDirection;let n=e.snake[0],r=yC(n,e.direction);if(r.x<0||r.x>=t.width||r.y<0||r.y>=t.height)if(e.wallWrap)r=xC(r,t);else{e.isGameOver=!0;return}let s=Su(r,e.food.position),i=e.specialFood!==null&&Su(r,e.specialFood.position),l=s||i?e.snake:e.snake.slice(0,-1);for(let c of l)if(Su(r,c)){e.isGameOver=!0;return}if(e.snake.unshift(r),s){e.score+=1,Uh(e,t);let c=e.specialFood?[e.specialFood.position]:[],u=Tu(e.snake,t,"normal",c);if(u)e.food=u;else{e.isGameOver=!0;return}e.specialFood===null&&Math.random()<.25&&(e.specialFood=Tu(e.snake,t,"special",[e.food.position]))}else i?(e.score+=3,Uh(e,t),e.specialFood=null):e.snake.pop();e.specialFood?.spawnedAt!==void 0&&Date.now()-e.specialFood.spawnedAt>5e3&&(e.specialFood=null)}function Uh(e,t){let n=Math.floor(e.score/t.scorePerLevel)+1;e.speedLevel=n,e.tickInterval=Math.max(t.minSpeed,t.initialSpeed-(n-1)*t.speedDecrement)}function Hh(e,t){gC(t,e.direction)||(e.nextDirection=t)}p();import Ee from"chalk";var Vh=2,bC=" ",wC="\u2593",kC="\u2593",SC="\u25C6",TC="\u2605",Po="\x1B[",CC=`${Po}?25l`,_C=`${Po}?25h`,zh=`${Po}H`;function qh(){process.stdout.write(CC)}function Kh(){process.stdout.write(_C)}function Xh(){process.stdout.write(`${Po}2J${zh}`)}function vC(e,t){switch(t){case"snake-head":return Ee.greenBright(e);case"snake-body":return Ee.green(e);case"normal-food":return Ee.red(e);case"special-food":return Ee.yellow(e);case"empty":return e}}function Jh(e,t){let n=RC(e,t);process.stdout.write(`${Po}2J${zh}`+n.join(`
598
- `))}function RC(e,t){let{width:n,height:r}=t,o=[],s=Array.from({length:r},()=>Array(n).fill("empty"));for(let l=1;l<e.snake.length;l++){let c=e.snake[l];c.y>=0&&c.y<r&&c.x>=0&&c.x<n&&(s[c.y][c.x]="snake-body")}let i=e.snake[0];i.y>=0&&i.y<r&&i.x>=0&&i.x<n&&(s[i.y][i.x]="snake-head");let a=e.food.position;if(s[a.y][a.x]==="empty"&&(s[a.y][a.x]="normal-food"),e.specialFood){let l=e.specialFood.position;s[l.y][l.x]==="empty"&&(s[l.y][l.x]="special-food")}o.push(" "+Ee.gray("\u2554"+"\u2550\u2550".repeat(n)+"\u2557"));for(let l=0;l<r;l++){let c=" "+Ee.gray("\u2551");for(let u=0;u<n;u++){let d=s[l][u],m;switch(d){case"snake-head":m=kC.repeat(Vh);break;case"snake-body":m=wC.repeat(Vh);break;case"normal-food":m=SC+" ";break;case"special-food":m=TC+" ";break;default:m=bC}c+=vC(m,d)}c+=Ee.gray("\u2551"),o.push(c)}if(o.push(" "+Ee.gray("\u255A"+"\u2550\u2550".repeat(n)+"\u255D")),o.push(""),o.push(` ${Ee.cyan("\u5206\u6570")}: ${e.score} ${Ee.cyan("\u957F\u5EA6")}: ${e.snake.length} ${Ee.cyan("\u901F\u5EA6")}: Lv.${e.speedLevel} ${Ee.cyan("\u8FB9\u754C")}: ${e.wallWrap?"\u7A7F\u5899":"\u649E\u5899"}`),e.specialFood?.spawnedAt!==void 0){let l=Math.ceil((5e3-(Date.now()-e.specialFood.spawnedAt))/1e3);l>0&&o.push(` ${Ee.yellow(`\u2B50 \u7279\u6B8A\u98DF\u7269 ${l} \u79D2\u540E\u6D88\u5931`)}`)}return o.push(` ${Ee.gray("W/A/S/D \u6216 \u65B9\u5411\u952E\u79FB\u52A8 | P \u6682\u505C | M \u5207\u6362\u6A21\u5F0F | Q \u9000\u51FA")}`),e.isPaused&&(o.push(""),o.push(` ${Ee.yellow("\u23F8 \u5DF2\u6682\u505C \u2014 \u6309 P \u7EE7\u7EED")}`)),e.isGameOver&&(o.push(""),o.push(` ${Ee.red.bold("\u{1F480} \u6E38\u620F\u7ED3\u675F!")} ${Ee.cyan("\u6700\u7EC8\u5206\u6570: "+e.score)}`),o.push(` ${Ee.gray("\u6309 R \u91CD\u65B0\u5F00\u59CB | \u6309 Q \u9000\u51FA")}`)),o}p();import*as Zh from"readline";var AC={up:"UP",w:"UP",W:"UP",down:"DOWN",s:"DOWN",S:"DOWN",left:"LEFT",a:"LEFT",A:"LEFT",right:"RIGHT",d:"RIGHT",D:"RIGHT"};function Yh(e,t,n){Zh.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0);let r=(o,s)=>{if(!s||!s.name)return;let{name:i,ctrl:a}=s;if(a&&(i==="c"||i==="d")){t();return}if(i==="q"){t();return}let l=e.state;if(l.isGameOver){i==="r"&&(e.state=n());return}if(i==="p"){l.isPaused=!l.isPaused;return}if(i==="m"){l.wallWrap=!l.wallWrap;return}let c=AC[i];c&&Hh(l,c)};return process.stdin.on("keypress",r),()=>{process.stdin.removeListener("keypress",r),process.stdin.isTTY&&process.stdin.setRawMode(!1)}}var Ei={width:20,height:16,initialSpeed:180,minSpeed:60,speedDecrement:10,scorePerLevel:5},EC=200,IC={id:"snake",name:"Big Snake",description:"\u7ECF\u5178\u8D2A\u5403\u86C7\uFF0C\u53CC\u98DF\u7269\u7CFB\u7EDF\u3001\u96BE\u5EA6\u9012\u589E\u3001\u7A7F\u5899/\u649E\u5899\u6A21\u5F0F",play:async()=>{let e={state:Cu(Ei)};return new Promise(t=>{let n=Yh(e,()=>{r=!0,clearTimeout(o),Kh(),n(),t()},()=>Cu(Ei));Xh(),qh();let r=!1,o;function s(){if(r)return;let i=e.state;!i.isGameOver&&!i.isPaused&&Wh(i,Ei),Jh(i,Ei);let a=i.isGameOver||i.isPaused?EC:i.tickInterval;o=setTimeout(s,a)}o=setTimeout(s,0)})}},Qh=IC;function _u(){return Ri($h),Ri(jh),Ri(Qh),Io()}import{render as pg}from"ink";import xt from"chalk";p();p();import{Box as Y,Text as Q,useInput as PC}from"ink";import{useState as pt,useCallback as eg,useEffect as Lo,useMemo as LC}from"react";import vu from"asciichart";import $C from"os";import{join as OC}from"path";import{jsx as B,jsxs as Ie}from"react/jsx-runtime";var tg=OC($C.homedir(),".dskcode","settings.json");function DC(e){let t=e.replace(/\\/g,"/");return process.platform==="win32"?"file://"+t.replace(/^([a-zA-Z]:)/,"/$1"):"file://"+t}function NC(e,t){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}var MC="https://web.ifzq.gtimg.cn/appstock/app/minute/query?code={code}&r=0.1";function ng(e){return e.startsWith("sh")||e.startsWith("sz")?e:/^60|^68|^51/.test(e)?"sh"+e:/^00|^30|^39/.test(e)?"sz"+e:"sh"+e}async function rg(e){let t=MC.replace("{code}",ng(e));try{let r=await(await fetch(t)).json();if(r.code!==0)return null;let o=ng(e),s=r.data?.[o];if(!s)return null;let i=s.data?.data??[],a=[];for(let d of i){let m=d.split(" ");if(m.length>=2){let h=parseFloat(m[1]);isNaN(h)||a.push(h)}}let l=o,c=s.qt?.[l],u=null;return c&&c.length>=35&&(u={code:e,name:c[1]??"",price:parseFloat(c[3]??"0"),changePercent:parseFloat(c[32]??"0"),changeAmount:parseFloat(c[31]??"0"),high:parseFloat(c[33]??"0"),low:parseFloat(c[34]??"0"),volume:parseInt(c[6]??"0",10),amount:parseFloat(c[37]??"0")*1e4}),{prices:a,quote:u,date:s.data?.date??""}}catch{return null}}var og=new Map;function sg(e,t){og.set(e,t)}var BC=[{code:"000001",name:"\u4E0A\u8BC1\u6307\u6570",price:3150,changePercent:.35,changeAmount:11.02,high:3160,low:3140,volume:28543e4,amount:156e10},{code:"601899",name:"\u7D2B\u91D1\u77FF\u4E1A",price:18.2,changePercent:1.85,changeAmount:.33,high:18.45,low:17.9,volume:59615384,amount:1085e7},{code:"399006",name:"\u521B\u4E1A\u677F\u6307",price:1820,changePercent:-.52,changeAmount:-9.5,high:1835,low:1815,volume:9865e4,amount:1824e7}];async function FC(e){let n=(await Promise.all(e.map(async r=>{let o=await rg(r);return o?.quote?(o.prices.length>0&&sg(r,o.prices),o.quote):null}))).filter(r=>r!==null);return n.length>0?n:BC}function Ii(e){return e>=100?e.toFixed(2):e.toFixed(3)}function GC(e){return e>=1e12?(e/1e12).toFixed(2)+"\u4E07\u4EBF":e>=1e8?(e/1e8).toFixed(2)+"\u4EBF":e>=1e4?(e/1e4).toFixed(1)+"\u4E07":e.toLocaleString()}function jC(e,t=60){return e.length<=t?e:e.slice(e.length-t)}function Pi({codes:e,onExit:t,onBackToChat:n}){let[r,o]=pt([]),[s,i]=pt(0),[a,l]=pt(!0),[c,u]=pt(""),[d,m]=pt(null),[h,f]=pt(null),[g,b]=pt(!1),[w,S]=pt(10),[v,_]=pt(5),[E,M]=pt(()=>new Date().toLocaleTimeString("zh-CN",{hour12:!1})),[U,T]=pt(!1),[N,F]=pt("default"),q=LC(()=>N==="default"?r:[...r].toSorted((W,se)=>N==="desc"?se.changePercent-W.changePercent:W.changePercent-se.changePercent),[r,N]),{doubleCtrlC:$,handleCtrlC:oe}=Sn(t);Lo(()=>{let W=setInterval(()=>{M(new Date().toLocaleTimeString("zh-CN",{hour12:!1}))},1e3);return()=>clearInterval(W)},[]);let le=eg(async()=>{l(!0);try{let W=await FC(e??[]);o(W),u(new Date().toLocaleTimeString())}catch{}l(!1)},[e]);if(Lo(()=>{le()},[le]),Lo(()=>{let W=setInterval(()=>{_(se=>se<=1?(le(),5):se-1)},1e3);return()=>clearInterval(W)},[le]),Lo(()=>{if(d){let W=()=>{og.delete(d.code),rg(d.code).then(ce=>{ce&&ce.prices.length>0&&(sg(d.code,ce.prices),f(ce.prices))})};W(),S(10);let se=setInterval(W,1e4);return()=>clearInterval(se)}f(null),b(!1)},[d]),Lo(()=>{if(!d)return;let W=setInterval(()=>{S(se=>se>0?se-1:10)},1e3);return()=>clearInterval(W)},[d]),PC(eg((W,se)=>{if(W==="c"&&se.ctrl){oe();return}if(d){(se.escape||W==="q"||W===" ")&&m(null);return}if(r.length!==0)if(se.upArrow||W==="k")i(ce=>ce>0?ce-1:r.length-1);else if(se.downArrow||W==="j")i(ce=>ce<r.length-1?ce+1:0);else if(se.return){let ce=r[s];ce&&m(ce)}else se.escape||W==="q"?n?n():t():W==="r"?(_(5),le()):W==="o"?F(ce=>ce==="default"?"desc":ce==="desc"?"asc":"default"):W==="h"&&T(ce=>!ce)},[r,s,d,t,n,le,oe,T])),d)return g?B(Y,{paddingLeft:1,children:B(Q,{dimColor:!0,children:" \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..."})}):UC(d,()=>m(null),h??void 0,w,E);let ee=W=>U?{dimColor:!0}:{color:W};return Ie(Y,{flexDirection:"column",children:[Ie(Y,{marginBottom:1,justifyContent:"space-between",children:[B(Q,{bold:!0,...ee("#00ffff"),children:" \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7"}),Ie(Q,{dimColor:!0,children:[" \u{1F550} ",E]}),B(Q,{dimColor:!0,children:a?" \u27F3 \u5237\u65B0\u4E2D...":` ${v}s \u540E\u81EA\u52A8\u5237\u65B0`})]}),Ie(Y,{children:[B(Y,{width:3}),B(Y,{width:9,children:B(Q,{dimColor:!0,children:"\u4EE3\u7801"})}),B(Y,{width:16,children:B(Q,{dimColor:!0,children:"\u540D\u79F0"})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6700\u65B0\u4EF7"})}),B(Y,{width:12,children:Ie(Q,{dimColor:!0,children:["\u6DA8\u8DCC\u5E45",N==="desc"?" \u25BC":N==="asc"?" \u25B2":""]})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6DA8\u8DCC\u989D"})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6700\u9AD8"})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6700\u4F4E"})}),B(Y,{children:B(Q,{dimColor:!0,children:"\u6210\u4EA4\u989D"})})]}),B(Y,{children:B(Q,{dimColor:!0,children:" "+"\u2500".repeat(100)})}),B(Y,{flexDirection:"column",children:q.map((W,se)=>{let ce=se===s,zn=W.changePercent>=0,qn=zn?"#ff1493":"#00ff41";return Ie(Y,{children:[B(Y,{width:3,flexShrink:0,children:ce?B(Q,{bold:!0,...ee("#00ffff"),children:"\u25B8 "}):B(Q,{children:" "})}),B(Y,{width:9,children:B(Q,{bold:!0,...ee(ce?"#00ffff":"#ffffff"),children:W.code})}),B(Y,{width:16,children:B(Q,{...ee(ce?"#ffffff":"#cccccc"),children:W.name})}),B(Y,{width:12,children:B(Q,{bold:!0,...ee(qn),children:Ii(W.price)})}),B(Y,{width:12,children:Ie(Q,{...ee(qn),children:[zn?"+":"",W.changePercent.toFixed(2),"%"]})}),B(Y,{width:12,children:Ie(Q,{...ee(qn),children:[zn?"+":"",W.changeAmount.toFixed(3)]})}),B(Y,{width:12,children:B(Q,{...ee("#cccccc"),children:Ii(W.high)})}),B(Y,{width:12,children:B(Q,{...ee("#888888"),children:Ii(W.low)})}),B(Y,{children:B(Q,{...ee("#888888"),children:GC(W.amount)})})]},W.code)})}),B(Y,{marginTop:1,children:B(Q,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u8BE6\u60C5 r \u624B\u52A8\u5237\u65B0 o \u6392\u5E8F h \u7F6E\u7070/\u6062\u590D q \u8FD4\u56DE"})}),Ie(Y,{children:[B(Q,{dimColor:!0,children:` \u6700\u540E\u66F4\u65B0: ${c} \u7F16\u8F91\u81EA\u9009\u80A1: `}),B(Q,{...ee("#c792ea"),children:NC(DC(tg),tg)})]}),$&&B(Y,{marginTop:1,children:B(Q,{bold:!0,...ee("#ff1493"),children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}function UC(e,t,n,r=10,o){let s=e.changePercent>=0,i=s?"#ff1493":"#00ff41",a=s?"\u25B2":"\u25BC",l=[];if(n&&n.length>0){let c=s?vu.red:vu.green,u=jC(n,60),d=vu.plot(u,{height:10,colors:[c]});d=d.replaceAll("\u256D","\u250C").replaceAll("\u256E","\u2510").replaceAll("\u2570","\u2514").replaceAll("\u256F","\u2518"),l=d.split(`
599
- `)}return Ie(Y,{flexDirection:"column",paddingLeft:1,children:[Ie(Y,{marginBottom:1,justifyContent:"space-between",children:[Ie(Y,{children:[Ie(Q,{bold:!0,color:"#00ffff",children:[" \u{1F4CA} ",e.name," "]}),B(Q,{dimColor:!0,children:e.code}),o&&Ie(Q,{dimColor:!0,children:[" \u{1F550} ",o]})]}),B(Q,{dimColor:!0,children:`${r}s \u540E\u5237\u65B0`})]}),Ie(Y,{children:[B(Y,{width:16,children:B(Q,{bold:!0,color:"#888888",children:"\u5F53\u524D\u4EF7"})}),B(Y,{children:Ie(Q,{bold:!0,color:i,children:[a," ",Ii(e.price)]})})]}),Ie(Y,{children:[B(Y,{width:16,children:B(Q,{color:"#888888",children:"\u6DA8\u8DCC\u5E45"})}),B(Y,{children:Ie(Q,{color:i,children:[s?"+":"",e.changePercent.toFixed(2),"%"," ",s?"+":"",e.changeAmount.toFixed(3)]})})]}),l.length>0&&B(Y,{marginTop:1,flexDirection:"column",children:l.map((c,u)=>B(Y,{children:B(Q,{color:i,children:c||" "})},u))}),B(Y,{marginTop:1,children:B(Q,{dimColor:!0,children:" Space/q \u8FD4\u56DE\u5217\u8868"})})]})}p();import{readdir as WC,realpath as HC}from"fs/promises";import{join as ig,relative as VC}from"path";var zC=new Set(["node_modules",".git",".svn",".hg",".dskcode",".claude","dist","build",".next",".turbo",".nx","coverage",".cache",".nyc_output",".vscode",".idea","__pycache__",".venv","venv",".tox","target","vendor","bower_components","jspm_packages"]);async function ag(e,t,n=1/0,r){let o=t??e,s=r??new Set;try{let d=await HC(o);if(s.has(d))return[];s.add(d)}catch{}let i;try{i=await WC(o,{withFileTypes:!0})}catch{return[]}let a=[],l=[];for(let d of i){let m=d.name;zC.has(m)||m.startsWith(".")||(d.isDirectory()?l.push(m):d.isFile()&&a.push(VC(e,ig(o,m))))}let c=t===void 0?n:Math.max(0,n-1),u=c<=1?[]:await Promise.all(l.map(d=>ag(e,ig(o,d),c,s)));for(let d of u)a.push(...d);return a}var qC=8;async function lg(e){return ag(e,void 0,qC)}import{jsx as Rr}from"react/jsx-runtime";var ZC=["chat","run","setup","init","completion","game","stock","config-ui"];function fg(){let e=new KC;return e.exitOverride(),e.name("dskcode").description("\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\u7EC8\u7AEF\u5DE5\u5177").version(So,"-V, --version","\u663E\u793A\u7248\u672C\u53F7").option("--verbose","\u5F00\u542F\u8BE6\u7EC6\u65E5\u5FD7\u8F93\u51FA").option("--config <path>","\u6307\u5B9A\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84").option("--dir <path>","\u6307\u5B9A\u5DE5\u4F5C\u5B50\u76EE\u5F55\uFF0C@ \u63D0\u793A\u4EC5\u663E\u793A\u8BE5\u76EE\u5F55\u4E0B\u7684\u6587\u4EF6").option("--no-config-ui","\u4E0D\u62C9\u8D77\u672C\u5730 ws server\uFF08\u9ED8\u8BA4\u4E0E chat \u5E76\u53D1\u62C9\u8D77\uFF09").option("--ws","\u8DF3\u8FC7 chat\uFF0C\u76F4\u63A5\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF08\u9ED8\u8BA4 54006 \u7AEF\u53E3\uFF0C\u4F9B Chrome \u6269\u5C55\u8FDE\u63A5\uFF09"),e.helpInformation=()=>od(e),e.hook("preAction",async(t,n)=>{let r=await rd.call(t);n.dskcodeCtx=r}),e.command("chat").description("\u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD\u4F1A\u8BDD(\u65E0\u53C2\u8FD0\u884C `dskcode` \u7B49\u4EF7\u4E8E\u6B64\u547D\u4EE4)").action(async function(){await ug(this)}),e.action(async function(){let t=this;if(t.opts().ws){let{startConfigUi:r}=await import("./config-ui-LWC4GWEV.js");await r({});return}await ug(t)}),e.command("run").description("\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1").argument("[prompt...]","\u4EFB\u52A1\u63CF\u8FF0").option("--model <name>","\u6307\u5B9A\u4F7F\u7528\u7684\u6A21\u578B").action(async function(t){console.log("dskcode run \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C07\u7AE0\uFF09")}),e.command("setup").description("\u8FD0\u884C\u914D\u7F6E\u5411\u5BFC").option("--export","\u4EE5 JSON \u683C\u5F0F\u5BFC\u51FA\u914D\u7F6E").option("--test","\u6D4B\u8BD5 API Key \u8FDE\u901A\u6027").action(async function(){console.log("dskcode setup \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C14\u7AE0\uFF09")}),e.command("init").description("\u5728\u5F53\u524D\u9879\u76EE\u4E0B\u751F\u6210\u9879\u76EE\u8BB0\u5FC6\u6587\u4EF6\uFF08AGENTS.md\uFF09").action(async function(){console.log("dskcode init \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C11\u7AE0\uFF09")}),e.command("completion").description("\u8F93\u51FA shell \u81EA\u52A8\u8865\u5168\u914D\u7F6E\u8BF4\u660E\uFF08bash/zsh\uFF09").argument("[shell]","shell \u7C7B\u578B",/^(bash|zsh)$/i).action(async function(t){if(!t){console.log("\u8BF7\u6307\u5B9A shell \u7C7B\u578B\uFF1Adskcode completion bash \u6216 dskcode completion zsh");return}console.log(t==="bash"?`# dskcode bash \u81EA\u52A8\u8865\u5168
597
+ \u8F93\u5165 /plan \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08\u53EA\u8BFB\u5206\u6790\uFF09\u3002`}]),ue.current?.reset()),N("");return}if(P==="/tools"){let A=Ir===void 0?"none":Ir==="none"?"required":Ir==="required"?"auto":void 0;Vo(A);let L=A===void 0?"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09":A==="none"?"\u7981\u6B62\u8C03\u7528":A==="required"?"\u5F3A\u5236\u8C03\u7528":"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09";C(W=>[...W,{role:"user",content:w},{role:"assistant",content:`\u5DE5\u5177\u8C03\u7528\u7B56\u7565\u5DF2\u5207\u6362\u4E3A ${L}`}]),N("");return}let te=xu.get(P);if(te){let A=te.handler();switch(A.kind){case"exit":await ue.current?.flushLog(),process.exit(0);return;case"clear":C([]),M(L=>L+1),N(""),jo(void 0),process.stdout.write("\x1B[2J\x1B[H\x1B[3J"),ue.current?.reset(),Ar.current=-1;return;case"navigate":N(""),A.target==="game"?g?.():A.target==="stock"&&k?.();return;case"text":C(L=>[...L,{role:"user",content:w},{role:"assistant",content:A.content}]),N("");return;case"permissions":{let L=ue.current;if(!L){C(nt=>[...nt,{role:"user",content:w},{role:"assistant",content:"Session \u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}]),N("");return}let W=L.gate,Y=[],ft=0,Xn="",ls="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09";if(W instanceof fn){let nt=W.gates;Xn=nt.length===0?"(\u7A7A)":`\u5171 ${nt.length} \u4E2A`;try{let ba=(await import("./interactive-gate-WMAYTMZ6.js")).InteractiveGate;for(let Mr of nt)Mr instanceof ba&&(Y=Mr.engine.rules,ft=Mr.grants.size,ls="\u89C4\u5219\u5F15\u64CE")}catch{}Y.length===0&&(ls="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09")}else ls="\u672A\u77E5";let mt=[];if(mt.push("\u{1F4CB} \u5F53\u524D\u6743\u9650\u7CFB\u7EDF\u72B6\u6001\uFF1A"),mt.push(` Gate \u94FE\uFF1A${Xn}`),mt.push(` \u6A21\u5F0F\uFF1A${ls??"\u672A\u77E5"}`),Y.length===0)mt.push(" \u89C4\u5219\u6570\uFF1A0\uFF08\u9ED8\u8BA4\u6A21\u5F0F\uFF1A\u8BFB/\u7EC8\u7AEF\u76F4\u63A5\u653E\u884C\uFF0C\u6539\u6587\u4EF6\u9700\u786E\u8BA4\uFF09");else{mt.push(` \u89C4\u5219\u6570\uFF1A${Y.length}`);for(let nt=0;nt<Y.length;nt++){let wn=Y[nt],ba=wn.match?JSON.stringify(wn.match):"(\u5168\u90E8\u5339\u914D)",Mr=wn.reason?` \u2014 ${wn.reason}`:"";mt.push(` ${nt+1}. ${wn.tool} \u2192 ${wn.action}\uFF08${ba}\uFF09${Mr}`)}}mt.push(` \u4F1A\u8BDD grants\uFF1A${ft} \u4E2A\uFF08"always" \u6279\u51C6\u7684\u5DE5\u5177\u8C03\u7528\uFF09`),mt.push(""),mt.push("\u914D\u7F6E\u6587\u4EF6\uFF1A~/.dskcode/permissions.json\uFF08\u5168\u5C40\uFF09"),mt.push(" .dskcode/permissions.json\uFF08\u9879\u76EE\u7EA7\uFF0C\u9879\u76EE\u7EA7\u4F18\u5148\uFF09"),C(nt=>[...nt,{role:"user",content:w},{role:"assistant",content:mt.join(`
598
+ `)}]),N("");return}}}let O=await Rm(w,Yu.current);if(O.kind==="no-match"){C(A=>[...A,{role:"user",content:w},{role:"assistant",content:`\u672A\u77E5\u547D\u4EE4\uFF1A${w}\u3002\u8F93\u5165 /help \u67E5\u770B\u3002`}]),N("");return}if(O.kind==="error"){C(A=>[...A,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u6FC0\u6D3B skill \u5931\u8D25\uFF1A${O.message}`}]),N("");return}E=O.text}if(!ue.current){C(P=>[...P,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]),N("");return}if(ae){C(P=>[...P,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u751F\u6210\u4E2D\uFF0C\u8BF7\u7B49\u5F85\u672C\u8F6E\u7ED3\u675F\u518D\u53D1\u65B0\u6D88\u606F\u3002\u5982\u9700\u4E2D\u6B62\u672C\u8F6E\uFF0C\u6309 Ctrl+C\u3002"}]),N("");return}let z=E!==w?(()=>{let P=/^\/(\S+)(?:\s+(.*))?$/.exec(w),te=P?.[1]??"",O=(P?.[2]??"").trim();return O?`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${te} \u2014 ${O}`:`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${te}`})():w;N(""),await as(E,"local",{displayText:z,thinkingAllowed:zn||void 0,thinkingEffort:zn?Er:void 0,responseFormat:Yi!=="text"?Yi:void 0,toolChoice:Ir})},[g,k,Vi,qi,Go,t,Lr,ma,zn,Er,Yi,Ir,tt,Jt,ae,ra,is,qn,as]);xe(()=>{!ae&&a&&Du(a.todayTotalCost)},[ae,a]);let Pg=Ih(()=>K(V,{flexDirection:"column",flexGrow:1,children:[K(V,{flexDirection:"column",flexGrow:1,children:[!Pr&&K(V,{flexDirection:"column",alignItems:"flex-start",flexGrow:1,paddingBottom:1,children:[bt.length>0&&(()=>{let T=bt[zo%bt.length];if(!T)return null;let w=`${T.name} ${T.desc}`;return K(V,{marginTop:1,alignSelf:"center",children:[$(G,{color:"#808080",children:"\u{1F4A1} "}),Qi.length>0?w.split("").map((E,z)=>$(G,{color:Qi[z]||void 0,children:E},z)):$(G,{color:"#808080",children:w})]})})(),$(V,{flexGrow:1}),$(kh,{panelWidth:_})]}),K(V,{flexDirection:"column",marginTop:1,children:[$(aC,{items:D,children:(T,w)=>{if(T.role==="user")return K(V,{marginTop:1,flexDirection:"row",children:[$(V,{width:1,backgroundColor:"#FF8C00",flexShrink:0}),$(V,{flexGrow:1,paddingLeft:1,children:K(V,{flexDirection:"row",children:[$(V,{width:4,flexShrink:0,children:$(G,{bold:!0,color:"#FF8C00",children:"\u{1F4AC}"})}),$(V,{flexGrow:1,children:$(G,{wrap:"wrap",children:T.content})})]})})]},w);if(T.role==="tool")return K(V,{marginTop:1,flexDirection:"row",children:[$(V,{width:1,backgroundColor:"#666666",flexShrink:0}),K(V,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[K(V,{flexDirection:"row",children:[$(V,{width:4,flexShrink:0,children:$(G,{dimColor:!0,children:"\u{1F527}"})}),$(V,{flexGrow:1,children:$(G,{dimColor:!0,wrap:"wrap",children:T.content})})]}),T.diff&&$(sc,{diff:T.diff})]})]},w);let E=T.assistantDetail;return $(hs,{content:T.content,toolCalls:E?.toolCalls,isStreaming:!1,usage:E?.usage,elapsed:E?.elapsed,cost:E?.cost,model:E?.model,toolResults:E?.toolResults},w)}},J),ae&&$(hs,{content:Vi,toolCalls:Go.length>0?Go:void 0,isStreaming:!0,usage:Mu,cost:Gu,model:Uu,toolResults:Cg}),Zu.phase!=="idle"&&$(xc,{state:Zu,contentWidth:_}),ie!==null&&$(V,{borderStyle:"single",borderColor:"cyan",paddingX:1,marginBottom:1,children:$(G,{color:"cyan",children:"\u27F3 \u914D\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D\uFF08\u8FD0\u884C\u65F6\u751F\u6548\uFF09"})}),$(Sh,{pending:la,onResponse:Ag}),!ae&&Zi&&$(V,{marginTop:1,marginLeft:3,children:K(G,{color:"red",children:["\u26A0 ",Zi]})})]}),Hu&&yn.length>0&&$(yc,{items:yn})]}),Zt?K(V,{marginTop:1,flexDirection:"column",children:[$(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)}),K(V,{flexDirection:"column",marginTop:1,children:[$(G,{bold:!0,color:"#00ffff",children:"\u9009\u62E9\u6A21\u578B\uFF1A"}),Yt.map((T,w)=>{let E=kn[T],z=T===tt,P=w===Yo,te=P?" > ":" ",O=z?" (\u5F53\u524D)":"";return K(V,{children:[K(G,{color:P?"#00ff41":void 0,bold:P,children:[te,E.displayName,O]}),P&&K(G,{color:"#808080",children:[" \u2014 ",T]})]},T)}),$(V,{marginTop:1,children:$(G,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),$(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})]}):xn?K(V,{marginTop:1,flexDirection:"column",children:[$(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)}),K(V,{flexDirection:"column",marginTop:1,children:[$(G,{bold:!0,color:"#ff9800",children:"\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A"}),bn.map((T,w)=>{let E=w===$r,z=E?" > ":" ",P=new Date(T.timestamp).toLocaleTimeString(),te=T.preview||"(\u7A7A)",O=T.isGitRepo?"":" [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";return $(V,{children:K(G,{color:E?"#ff9800":void 0,bold:E,children:[z,"#",w+1," ",P," `",te,O,"`"]})},T.index)}),$(V,{marginTop:1,children:$(G,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),$(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})]}):K($h,{children:[(Pr||Jt==="plan")&&ae&&vr?$(V,{marginTop:1,justifyContent:"center",children:K(G,{bold:!0,color:hu[vr].color,children:[hu[vr].icon," ",hu[vr].label," ",$(lC,{type:"dots"})]})}):Ju==="visible"?$(V,{marginTop:1,justifyContent:"center",children:$(G,{color:"#808080",children:"\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539"})}):Rr&&Rr.ratio>.85?$(V,{marginTop:1,justifyContent:"center",children:K(G,{color:"#ff9800",children:["\u{1F4DA} \u4E0A\u4E0B\u6587\u5DF2\u7528 ",(Rr.ratio*100).toFixed(0),"%\uFF0C\u8F93\u5165 /compact \u53EF\u624B\u52A8\u538B\u7F29"]})}):null,$(V,{marginTop:1,children:$(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})}),K(V,{children:[$(V,{width:4,flexShrink:0,children:$(G,{bold:!0,color:"#00ff41",children:"\u26A1"})}),K(V,{flexGrow:1,children:[Or?$(G,{color:"#808080",children:"Ctrl+P \u6587\u4EF6\u641C\u7D22\u4E2D\u2026\uFF08Esc \u53D6\u6D88\uFF09"}):!U&&!ae&&gn&&ji.length>0?$(G,{children:gn.split("").map((T,w)=>$(G,{color:ji[w]??void 0,children:T},w))}):!U&&ae&&hn&&Wi.length>0?$(G,{children:hn.split("").map((T,w)=>$(G,{color:Wi[w]??void 0,children:T},w))}):$(_m,{value:U,onChange:N,onSubmit:td,placeholder:"",focus:!Or},Ku),Pe!=="idle"&&K(V,{children:[K(G,{color:Pe==="error"?"red":"cyan",children:[Pe==="connecting"&&"\u25CC \u6B63\u5728\u8FDE\u63A5 ASR \u670D\u52A1...",Pe==="recording"&&`\u25CF \u5F55\u97F3\u4E2D ${Mi}`,Pe==="finalizing"&&`\u25CC \u7B49\u5F85\u670D\u52A1\u7AEF\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C ${Mi}`,Pe==="error"&&`\u2717 \u9519\u8BEF ${Mi}`]}),$(G,{dimColor:!0,children:" (\u518D\u6309 F2 \u7ED3\u675F\uFF0CESC \u53D6\u6D88)"})]})]})]}),$(V,{children:$(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})}),$(lc,{skills:t,input:U,selectedIndex:Lr}),$(fc,{files:n,input:U,selectedIndex:qn,cwd:process.cwd(),width:_})]})]}),[D,J,ae,Vi,Go,Mu,Gu,Uu,Zi,yn,Hu,Zt,Yt,tt,Yo,Ji,Qo,xn,bn,$r,Xo,Jo,Ju,Pr,Jt,vr,gn,ji,hn,Wi,U,N,_,td,t,Lr,n,qn,Ku,bt,zo,Qi]),Lg=typeof process.stdout.rows=="number"?Math.max(process.stdout.rows-4,10):24,$g=T=>{N(w=>`${w.endsWith(" ")||w.length===0?w:w+" "}@${T} `),na(w=>w+1),Zo(!1)};return K(V,{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[Or&&$(Tm,{files:n,cwd:process.cwd(),width:R,height:Lg,onPick:$g,onClose:()=>Zo(!1)}),!Or&&K($h,{children:[K(V,{flexDirection:"row",flexGrow:1,children:[$(V,{width:v,flexShrink:0,flexDirection:"column",children:$(V,{paddingX:1,flexDirection:"column",flexGrow:1,justifyContent:Pr?"flex-end":"center",children:Pr?_g?$(G,{dimColor:!0,wrap:"wrap",children:(()=>{let T=wh(qi),w=11,z=T.split(`
599
+ `).slice(-w);for(;z.length<w;)z.unshift("");return z.join(`
600
+ `)})()}):K(V,{flexDirection:"column",alignItems:"center",children:[$(G,{color:"#00ffff",bold:!0,children:"\u{1F4AC} \u5BF9\u8BDD\u8FDB\u884C\u4E2D"}),K(V,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#00ff41",children:["\u{1F4DD} \u6D88\u606F ",D.length," \u6761"]}),qu>0&&K(G,{color:"cyan",children:["\u{1F4B0} \u4F1A\u8BDD \xA5",qu.toFixed(4)]}),Rr&&$(fC,{stats:Rr})]}),K(V,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#808080",children:["\u{1F527} ",kn[tt]?.displayName??tt]}),zn&&K(G,{color:"#ff9800",children:["\u{1F9E0} ",Er==="max"?"Max":"High"]})]}),se!==null&&$(V,{marginTop:1,children:K(G,{color:"yellow",children:["\u{1F4B0} \xA5",se.toFixed(2)]})})]}):K(V,{flexDirection:"column",alignItems:"center",children:[Oa.map((T,w)=>{let E=(w+B)%Fr.length;return $(G,{bold:!0,color:Fr[E],children:T},w)}),$(V,{marginTop:1,children:K(G,{color:"#808080",children:["\u{1F4E6} v",Co]})}),K(V,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#00ff41",children:["\u2714 ",e," Skills"]}),K(G,{color:"#00ffff",children:["\u2139 ",r," \u5DE5\u5177"]}),K(G,{color:"#00ffff",children:["\u{1F527} ",kn[tt]?.displayName??tt]}),zn&&K(G,{color:"#ff9800",children:["\u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",Er==="max"?"Max":"High"]}),Jt==="plan"&&$(G,{color:"#ff69b4",bold:!0,children:"\u{1F4CB} \u8BA1\u5212\u6A21\u5F0F"})]}),K(V,{marginTop:1,flexDirection:"column",alignItems:"center",children:[se!==null?K(G,{color:"yellow",children:["\u{1F4B0} \u4F59\u989D \xA5",se.toFixed(2)]}):_r?$(G,{color:"yellow",children:"\u23F3 \u67E5\u8BE2\u4F59\u989D..."}):null,Ou!==null&&K(G,{color:"cyan",children:["\u{1F4CA} \u4ECA\u65E5 \xA5",Ou.toFixed(2)]})]}),o&&$(G,{color:"#ff1493",children:"\u26A1 Verbose"})]})})}),Pg]}),Ig&&!ae&&$(V,{marginTop:1,children:$(G,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})}),ae&&$(V,{marginTop:1,children:$(G,{color:"yellow",dimColor:!0,children:" \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42"})})]})]})}var yu=12;function dC(e){return e>=.85?"danger":e>=.6?"warning":"safe"}function pC(e){switch(e){case"danger":return"#ff6347";case"warning":return"#ffcc00";case"safe":return"#00ff41"}}function fC({stats:e}){let t=dC(e.ratio),n=pC(t),r=Math.min(yu,Math.max(e.ratio>0?1:0,Math.round(e.ratio*yu))),o=yu-r;return K(G,{color:n,children:["\u{1F4DA} ",$(G,{color:n,children:"\u2588".repeat(r)}),$(G,{color:"#444444",children:"\u2591".repeat(o)})," ",(e.ratio*100).toFixed(1),"%"]})}p();import{Box as qt,Text as Hn,useInput as mC}from"ink";import{useState as hC,useCallback as gC}from"react";import{jsx as He,jsxs as Dh}from"react/jsx-runtime";function Ii({games:e,onSelect:t,onExit:n,onBackToChat:r}){let[o,s]=hC(0),i=r??n??(()=>process.exit(0)),{doubleCtrlC:a,handleCtrlC:l}=Tn(i);return mC(gC((c,u)=>{if(c==="c"&&u.ctrl){l();return}if(e.length!==0)if(u.upArrow||c==="k")s(d=>d>0?d-1:e.length-1);else if(u.downArrow||c==="j")s(d=>d<e.length-1?d+1:0);else if(u.return){let d=e[o];d&&t(d)}else(u.escape||c==="q")&&(r?r():n?.())},[e,o,t,n,r,l])),Dh(qt,{flexDirection:"column",children:[He(qt,{marginBottom:1,children:He(Hn,{bold:!0,color:"#00ffff",children:"\u{1F3AE} \u6E38\u620F\u5217\u8868"})}),He(qt,{flexDirection:"column",children:e.map((c,u)=>{let d=u===o;return Dh(qt,{flexDirection:"row",children:[He(qt,{width:3,flexShrink:0,children:d?He(Hn,{bold:!0,color:"#00ff41",children:"\u25B8 "}):He(Hn,{children:" "})}),He(qt,{width:20,flexShrink:0,children:He(Hn,{bold:!0,color:d?"#00ff41":"#ffffff",children:c.name})}),He(qt,{children:He(Hn,{color:"#888888",children:c.description})})]},c.id)})}),He(qt,{marginTop:1,children:He(Hn,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE"})}),a&&He(qt,{marginTop:1,children:He(Hn,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}p();p();var wu=new Map;function Pi(e){wu.set(e.id,e)}function Nh(e){return wu.get(e)}function Lo(){return Array.from(wu.values())}p();import{Box as Ve,Text as be,useInput as yC,render as xC}from"ink";import{useState as ku,useEffect as bC,useRef as Mh,useCallback as Su}from"react";import{jsx as fe,jsxs as ze}from"react/jsx-runtime";var ut=40,wr=18,kr=9,Bh=[166,214,76,69],Tu=[{rows:4,cols:8,bw:3,desc:"\u7ECF\u5178 4\xD78",pattern:()=>!0},{rows:3,cols:8,bw:3,desc:"\u8F7B\u677E 3 \u5C42",pattern:()=>!0},{rows:6,cols:8,bw:3,desc:"\u539A\u5899 6 \u5C42",pattern:()=>!0},{rows:4,cols:8,bw:3,desc:"\u68CB\u76D8\u683C",pattern:(e,t)=>(e+t)%2===0},{rows:4,cols:8,bw:3,desc:"\u91D1\u5B57\u5854",pattern:(e,t,n,r)=>e>=t&&e<r-t},{rows:4,cols:8,bw:3,desc:"\u4EA4\u9519\u6392\u5217",pattern:(e,t)=>t%2===0||e>=1&&e<=6},{rows:4,cols:8,bw:3,desc:"\u4E2D\u7A7A\u8FB9\u6846",pattern:(e,t,n,r)=>t===0||t===n-1||e===0||e===r-1},{rows:4,cols:10,bw:2,desc:"\u5BC6\u96C6 10 \u5217",pattern:()=>!0},{rows:7,cols:8,bw:3,desc:"\u9AD8\u5899 7 \u5C42",pattern:()=>!0},{rows:8,cols:8,bw:3,desc:"\u6EE1\u5C4F 8 \u5C42",pattern:()=>!0}];function Cu(e){return Tu[(e-1)%Tu.length]}function wC(e){let t=Cu(e),n=[],r=2,o=t.cols*t.bw+(t.cols-1)*r,s=Math.floor((ut-o)/2),i=t.bw+r;for(let a=0;a<t.rows;a++)for(let l=0;l<t.cols;l++)t.pattern(l,a,t.rows,t.cols)&&n.push({x:s+l*i,y:2+a*2,w:t.bw,alive:!0});return n}function Fh(e){let t=Cu(e),n=t.cols*t.bw+(t.cols-1)*2,r=Math.floor((ut-n)/2);return{level:e,bricks:wC(e),paddleX:Math.floor(ut/2)-Math.floor(kr/2),ball:{x:ut/2,y:wr-3},ballDir:{x:1,y:-1},score:0,lives:3,gameOver:!1,win:!1,paused:!1}}function kC(e){if(e.paused||e.gameOver||e.win)return;if(e.ball.x+=e.ballDir.x,e.ball.y+=e.ballDir.y,e.ball.x<=0&&(e.ball.x=0,e.ballDir.x=1),e.ball.x>=ut-1&&(e.ball.x=ut-1,e.ballDir.x=-1),e.ball.y<=0&&(e.ball.y=0,e.ballDir.y=1),e.ball.y===wr-1&&e.ball.x>=e.paddleX&&e.ball.x<=e.paddleX+kr){e.ballDir.y=-1;let n=(e.ball.x-e.paddleX)/kr;e.ballDir.x=n<.5?-1:1}e.ball.y>wr&&(e.lives--,e.lives<=0?e.gameOver=!0:(e.ball={x:ut/2,y:wr-3},e.ballDir={x:1,y:-1},e.paddleX=Math.floor(ut/2)-Math.floor(kr/2)));let t=e.bricks.find(n=>n.alive?e.ball.x>=n.x&&e.ball.x<n.x+n.w&&e.ball.y>=n.y&&e.ball.y<n.y+1:!1);t&&(t.alive=!1,e.score+=10,e.ballDir.y=-e.ballDir.y),e.bricks.every(n=>!n.alive)&&(e.win=!0)}function SC(e){let t=[];function n(r,o){let s=Math.floor((o-2)/2);if(s>=0&&e.bricks.find(a=>a.y===o&&a.alive&&r>=a.x&&r<a.x+a.w))return s%Bh.length}for(let r=0;r<wr;r++){let o="";for(let s=0;s<ut;s++){let i=e.ball.x===s&&e.ball.y===r,a=r===wr-1&&s>=e.paddleX&&s<e.paddleX+kr,l=n(s,r);i?o+="\x1B[97m\u25CF\x1B[0m":a?o+="\x1B[94m\u2584\x1B[0m":l!==void 0?o+=`\x1B[38;5;${Bh[l]}m\u2580\x1B[0m`:o+=" "}t.push(o)}return t.map(r=>`\u2502${r}\u2502`).join(`
601
+ `)}function TC({onExit:e}){let[t,n]=ku(1),[r,o]=ku(!0),s=Mh(Fh(t)),[i,a]=ku(0),l=Mh(e);l.current=e,bC(()=>{if(r)return;let g=setInterval(()=>{kC(s.current),a(k=>k+1)},80);return()=>clearInterval(g)},[r]);let c=Su(g=>{let k=g??s.current.level;s.current=Fh(k),n(k),o(!1),a(0)},[]),u=Su(()=>{o(!0)},[]);yC(Su((g,k)=>{let b=s.current;if(r){g>="1"&&g<="9"?c(Number(g)):g==="0"?c(10):(k.escape||g==="q")&&l.current();return}k.leftArrow?(b.paddleX=Math.max(0,b.paddleX-1),a(S=>S+1)):k.rightArrow?(b.paddleX=Math.min(ut-kr,b.paddleX+1),a(S=>S+1)):g==="p"||g===" "?b.paused=!b.paused:g==="r"?(b.gameOver||b.win)&&c():g==="l"?(b.gameOver||b.win)&&u():(g==="q"||k.escape)&&l.current()},[r,c,u]));let d=s.current,m=d.bricks.filter(g=>g.alive).length,h=SC(d),f=Cu(d.level);return ze(Ve,{flexDirection:"column",children:[ze(Ve,{flexDirection:"row",children:[fe(Ve,{width:20,children:ze(be,{children:["\u5173\u5361 ",d.level,": ",fe(be,{color:"cyan",children:f.desc})]})}),fe(Ve,{width:12,children:ze(be,{children:["\u5206\u6570: ",fe(be,{color:"yellow",children:String(d.score).padStart(3,"0")})]})}),fe(Ve,{width:12,children:ze(be,{children:["\u751F\u547D: ",fe(be,{color:"red",children:"\u2665".repeat(Math.max(0,d.lives))})]})}),fe(Ve,{width:10,children:ze(be,{children:["\u7816\u5757: ",fe(be,{color:"cyan",children:m})]})}),fe(Ve,{children:ze(be,{color:d.paused?"gray":"green",children:["[",d.paused?"\u6682\u505C":"\u8FD0\u884C\u4E2D","]"]})})]}),ze(Ve,{flexDirection:"column",children:[ze(be,{children:["\u250C","\u2500".repeat(ut),"\u2510"]}),fe(be,{children:r?" \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m":h}),ze(be,{children:["\u2514","\u2500".repeat(ut),"\u2518"]})]}),r&&ze(Ve,{marginTop:1,flexDirection:"column",children:[fe(be,{bold:!0,color:"yellow",children:"\u9009\u62E9\u5173\u5361"}),fe(Ve,{flexDirection:"row",flexWrap:"wrap",children:Tu.map((g,k)=>fe(Ve,{width:22,children:ze(be,{children:[fe(be,{color:t===k+1?"green":"white",children:k+1===10?"0":String(k+1)}),". ",g.desc," (",g.rows,"\xD7",g.cols,")"]})},k))}),fe(Ve,{marginTop:1,children:fe(be,{dimColor:!0,children:"\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA"})})]}),!r&&(d.gameOver||d.win)&&ze(Ve,{marginTop:1,children:[fe(be,{bold:!0,color:d.gameOver?"red":"green",children:d.gameOver?"\u6E38\u620F\u7ED3\u675F\uFF01":"\u606D\u559C\u901A\u5173\uFF01"}),ze(be,{children:[" \u5206\u6570: ",fe(be,{color:"yellow",children:d.score})]})]}),!r&&fe(Ve,{marginTop:1,children:d.gameOver||d.win?fe(be,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA"}):fe(be,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA"})})]})}var Gh={id:"brick-breaker",name:"Brick Breaker",description:"\u7ECF\u5178\u6253\u7816\u5757\u6E38\u620F\uFF0C10 \u4E2A\u5173\u5361\u53EF\u9009\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=xC(fe(TC,{onExit:()=>{t(),e()}}))})}};p();import{Box as Sr,Text as et,useInput as CC,render as _C}from"ink";import{useState as jh,useEffect as Uh,useRef as Wh,useCallback as RC}from"react";import{jsx as yt,jsxs as Kt}from"react/jsx-runtime";var dt=66,qh=20,Ru=6,vC=10,Tr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Hh={0:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],1:[" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],2:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],3:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],4:["\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],5:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],6:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],7:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],8:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],9:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "]};function AC(e){let t=["","","","",""];for(let r of e){let o=Hh[r]??Hh[0];for(let s=0;s<5;s++)t[s]+=" "+(o[s]??"")}let n=6;return t.map(r=>" ".repeat(n)+r)}function _u(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`${t};${n};${r}`}var Vh=["react","vue","next","node","axios","express","lodash","jquery","webpack","vite","babel","eslint","prettier","tailwind","bootstrap","sass","less","postcss","redux","pinia","vuex","router","nestjs","socket","graphql","rest","grpc","prisma","typeorm","html","css","jsx","tsx","dom","spa","ssr","csr","pwa","component","prop","hook","composable","directive","filter","mixin","template","render","virtual","diff","patch","hydration","responsive","flexbox","grid","animation","transition","api","route","middleware","controller","service","module","dto","entity","schema","migration","seeder","factory","auth","jwt","oauth","session","cookie","token","cors","cache","redis","mq","rabbit","kafka","nats","sql","mysql","pg","sqlite","mongo","redis","orm","table","index","query","join","union","group","order","where","having","limit","offset","insert","update","delete","docker","nginx","linux","bash","shell","yaml","toml","ci","cd","deploy","rollback","release","build","test","lint","format","stage","commit","branch","merge","rebase","array","stack","queue","tree","graph","list","map","set","sort","search","filter","reduce","map","async","await","promise","callback","closure","proxy","reflect","decorator","create","read","update","delete","crud","parse","stringify","encode","decode","transform","validate","format","parse","upload","download","export","import","backup","restore","string","number","boolean","object","array","tuple","enum","interface","type","class","function","method","property","public","private","static","readonly","optional","abstract","const","let","var","void","null","undef","never","any","config","logger","monitor","metric","alert","webhook","endpoint","payload","header","status","timeout","retry","fallback","circuit","breaker","throttle","debounce","scroll","resize","click","hover","focus","blur"];function EC(e){let t;do t=Vh[Math.floor(Math.random()*Vh.length)];while(e.has(t));return t}function zh(){return{words:[],score:0,lives:3,speed:.3,spawnTimer:0,gameOver:!1,paused:!1,typed:"",target:null,combo:0,message:"",messageTimer:0,usedWords:new Set}}function Li(e){let t=null;for(let n of e.words)(!t||n.col<t.col)&&(t=n);return t?.text??null}function IC(e){if(e.paused||e.gameOver)return;if(e.spawnTimer++,e.spawnTimer>=Math.max(20,50-Math.floor(e.speed*15))&&(e.spawnTimer=0,e.words.length<vC)){let r=new Set(e.usedWords);for(let a of e.words)r.add(a.text);let o=EC(r),s=new Set(e.words.map(a=>a.row)),i=-1;for(let a=Ru;a<qh;a++)if(!s.has(a)){i=a;break}i>=0&&(e.words.push({text:o,row:i,col:dt-1}),e.usedWords.add(o))}for(let r of e.words)r.col-=e.speed;let t=e.words.length;e.words=e.words.filter(r=>r.col>-r.text.length);let n=t-e.words.length;n>0&&(e.lives-=n,e.typed="",e.target=Li(e),e.lives<=0&&(e.gameOver=!0,e.words=[])),e.target=Li(e),e.messageTimer>0&&(e.messageTimer--,e.messageTimer<=0&&(e.message=""))}function PC(e,t,n,r){let o=[];for(let s=0;s<qh;s++){let i="";if(s<Ru){if(s<5){let a=(t[s]??"").padEnd(dt);i=`\x1B[38;2;${_u(n)}m${a}\x1B[0m`}else if(s===5){if(e.combo>=3){let a=`${e.combo}\u8FDE\u51FB!`,l=Math.floor((dt-a.length)/2),c=Tr[e.combo%Tr.length],u=" ".repeat(l)+a+" ".repeat(dt-l-a.length);i=`\x1B[38;2;${_u(c)}m${u}\x1B[0m`}else if(e.paused){let l=Math.floor((dt-2)/2);i=" ".repeat(l)+"\u6682\u505C",i=i.padEnd(dt)}}i=i.padEnd(dt)}else if(s===Ru&&r){let a=Math.floor((dt-r.length)/2),l=" ".repeat(a)+r+" ".repeat(dt-a-r.length),c=Tr[Math.floor(Math.random()*Tr.length)];i=`\x1B[38;2;${_u(c)}m${l}\x1B[0m`}else for(let a=0;a<dt;a++){let l=e.words.find(c=>{let u=a-Math.floor(c.col);return u>=0&&u<c.text.length&&c.row===s});if(l){let c=a-Math.floor(l.col),u=l.text[c],d=l.text===e.target,m=e.target===l.text?e.typed.length:0,h=d&&c<m;d?i+=h?`\x1B[92m${u}\x1B[0m`:`\x1B[97m${u}\x1B[0m`:i+=`\x1B[90m${u}\x1B[0m`}else i+=" "}o.push(i)}return o}function LC({onExit:e}){let t=Wh(zh()),[n,r]=jh(0),[o,s]=jh(0),i=Wh(e);i.current=e,Uh(()=>{let m=setInterval(()=>{s(h=>(h+1)%Tr.length)},400);return()=>clearInterval(m)},[]),Uh(()=>{let m=setInterval(()=>{IC(t.current),r(h=>h+1)},60);return()=>clearInterval(m)},[]),CC(RC((m,h)=>{let f=t.current;if(f.gameOver){m==="r"?(t.current=zh(),r(0)):(m==="q"||h.escape)&&i.current();return}if(m==="p"&&h.ctrl||m===" "){f.paused=!f.paused;return}if(m==="q"&&h.ctrl||h.escape){i.current();return}if(!f.paused&&m.length===1&&m>="a"&&m<="z"&&(f.target||(f.target=Li(f)),f.target))if(f.target[f.typed.length]===m){if(f.typed+=m,f.typed===f.target){f.words=f.words.filter(_=>_.text!==f.target),f.combo++;let k=f.score,b=f.target.length,S=f.combo>=3?f.score:0;f.score+=b+S,f.speed=f.speed+.02;let R=Math.floor(k/500);Math.floor(f.score/500)>R&&(f.speed+=.15),f.score>=1e5&&k<1e5&&(f.message="\u606D\u559C\u901A\u5173! \u96BE\u5EA6\u6700\u5927\u5316!",f.messageTimer=100),f.typed="",f.target=Li(f)}}else f.combo=0},[]));let a=t.current,l=Tr[o],c=String(a.score).padStart(5,"0"),u=AC(c),d=PC(a,u,l,a.message);return Kt(Sr,{flexDirection:"column",paddingX:1,children:[yt(Sr,{flexDirection:"row",children:Kt(et,{children:["\u751F\u547D ",yt(et,{color:"red",children:"\u2665".repeat(Math.max(0,a.lives))})," ","\u901F\u5EA6 ",Kt(et,{color:"cyan",children:["Lv.",Math.floor(a.speed*10)]})]})}),!a.gameOver&&a.target&&yt(Sr,{marginTop:1,children:Kt(et,{children:["\u6253\u5B57: ",yt(et,{color:"green",children:a.typed}),yt(et,{color:"white",children:a.target.slice(a.typed.length)})]})}),Kt(Sr,{flexDirection:"column",marginTop:1,children:[Kt(et,{children:["\u250C","\u2500".repeat(dt),"\u2510"]}),d.map((m,h)=>yt(et,{children:`\u2502${m}\u2502`},h)),Kt(et,{children:["\u2514","\u2500".repeat(dt),"\u2518"]})]}),a.gameOver&&Kt(Sr,{marginTop:1,children:[yt(et,{bold:!0,color:"red",children:"\u6E38\u620F\u7ED3\u675F\uFF01"}),Kt(et,{children:[" \u5F97\u5206: ",yt(et,{color:"yellow",children:a.score})," r \u91CD\u5F00 q \u9000\u51FA"]})]}),yt(Sr,{marginTop:1,children:yt(et,{dimColor:!0,children:"\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA"})})]})}var Kh={id:"coder-check",name:"Coder Check",description:"\u6781\u901F\u6253\u5B57\u6E38\u620F\uFF0C\u8F93\u5165\u5355\u8BCD\u6D88\u9664\u5B83\u4EEC\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=_C(yt(LC,{onExit:()=>{t(),e()}}))})}};p();p();function $C(e,t){return e==="UP"&&t==="DOWN"||e==="DOWN"&&t==="UP"||e==="LEFT"&&t==="RIGHT"||e==="RIGHT"&&t==="LEFT"}function vu(e,t){return e.x===t.x&&e.y===t.y}function OC(e,t){switch(t){case"UP":return{x:e.x,y:e.y-1};case"DOWN":return{x:e.x,y:e.y+1};case"LEFT":return{x:e.x-1,y:e.y};case"RIGHT":return{x:e.x+1,y:e.y}}}function DC(e,t){return{x:(e.x%t.width+t.width)%t.width,y:(e.y%t.height+t.height)%t.height}}function Au(e,t,n,r=[]){let o=new Set(e.map(a=>`${a.x},${a.y}`));for(let a of r)o.add(`${a.x},${a.y}`);let s=t.width*t.height;if(o.size>=s)return null;let i;do i={x:Math.floor(Math.random()*t.width),y:Math.floor(Math.random()*t.height)};while(o.has(`${i.x},${i.y}`));return{position:i,type:n,...n==="special"?{spawnedAt:Date.now()}:{}}}function Eu(e){let t=Math.floor(e.width/2),n=Math.floor(e.height/2),r=[{x:t,y:n},{x:t-1,y:n},{x:t-2,y:n}],o=Au(r,e,"normal");return{snake:r,direction:"RIGHT",nextDirection:"RIGHT",food:o,specialFood:null,score:0,speedLevel:1,isGameOver:!1,isPaused:!1,wallWrap:Math.random()<.5,tickInterval:e.initialSpeed}}function Jh(e,t){e.direction=e.nextDirection;let n=e.snake[0],r=OC(n,e.direction);if(r.x<0||r.x>=t.width||r.y<0||r.y>=t.height)if(e.wallWrap)r=DC(r,t);else{e.isGameOver=!0;return}let s=vu(r,e.food.position),i=e.specialFood!==null&&vu(r,e.specialFood.position),l=s||i?e.snake:e.snake.slice(0,-1);for(let c of l)if(vu(r,c)){e.isGameOver=!0;return}if(e.snake.unshift(r),s){e.score+=1,Xh(e,t);let c=e.specialFood?[e.specialFood.position]:[],u=Au(e.snake,t,"normal",c);if(u)e.food=u;else{e.isGameOver=!0;return}e.specialFood===null&&Math.random()<.25&&(e.specialFood=Au(e.snake,t,"special",[e.food.position]))}else i?(e.score+=3,Xh(e,t),e.specialFood=null):e.snake.pop();e.specialFood?.spawnedAt!==void 0&&Date.now()-e.specialFood.spawnedAt>5e3&&(e.specialFood=null)}function Xh(e,t){let n=Math.floor(e.score/t.scorePerLevel)+1;e.speedLevel=n,e.tickInterval=Math.max(t.minSpeed,t.initialSpeed-(n-1)*t.speedDecrement)}function Zh(e,t){$C(t,e.direction)||(e.nextDirection=t)}p();import Ee from"chalk";var Yh=2,NC=" ",MC="\u2593",BC="\u2593",FC="\u25C6",GC="\u2605",$o="\x1B[",jC=`${$o}?25l`,UC=`${$o}?25h`,Qh=`${$o}H`;function eg(){process.stdout.write(jC)}function tg(){process.stdout.write(UC)}function ng(){process.stdout.write(`${$o}2J${Qh}`)}function WC(e,t){switch(t){case"snake-head":return Ee.greenBright(e);case"snake-body":return Ee.green(e);case"normal-food":return Ee.red(e);case"special-food":return Ee.yellow(e);case"empty":return e}}function rg(e,t){let n=HC(e,t);process.stdout.write(`${$o}2J${Qh}`+n.join(`
602
+ `))}function HC(e,t){let{width:n,height:r}=t,o=[],s=Array.from({length:r},()=>Array(n).fill("empty"));for(let l=1;l<e.snake.length;l++){let c=e.snake[l];c.y>=0&&c.y<r&&c.x>=0&&c.x<n&&(s[c.y][c.x]="snake-body")}let i=e.snake[0];i.y>=0&&i.y<r&&i.x>=0&&i.x<n&&(s[i.y][i.x]="snake-head");let a=e.food.position;if(s[a.y][a.x]==="empty"&&(s[a.y][a.x]="normal-food"),e.specialFood){let l=e.specialFood.position;s[l.y][l.x]==="empty"&&(s[l.y][l.x]="special-food")}o.push(" "+Ee.gray("\u2554"+"\u2550\u2550".repeat(n)+"\u2557"));for(let l=0;l<r;l++){let c=" "+Ee.gray("\u2551");for(let u=0;u<n;u++){let d=s[l][u],m;switch(d){case"snake-head":m=BC.repeat(Yh);break;case"snake-body":m=MC.repeat(Yh);break;case"normal-food":m=FC+" ";break;case"special-food":m=GC+" ";break;default:m=NC}c+=WC(m,d)}c+=Ee.gray("\u2551"),o.push(c)}if(o.push(" "+Ee.gray("\u255A"+"\u2550\u2550".repeat(n)+"\u255D")),o.push(""),o.push(` ${Ee.cyan("\u5206\u6570")}: ${e.score} ${Ee.cyan("\u957F\u5EA6")}: ${e.snake.length} ${Ee.cyan("\u901F\u5EA6")}: Lv.${e.speedLevel} ${Ee.cyan("\u8FB9\u754C")}: ${e.wallWrap?"\u7A7F\u5899":"\u649E\u5899"}`),e.specialFood?.spawnedAt!==void 0){let l=Math.ceil((5e3-(Date.now()-e.specialFood.spawnedAt))/1e3);l>0&&o.push(` ${Ee.yellow(`\u2B50 \u7279\u6B8A\u98DF\u7269 ${l} \u79D2\u540E\u6D88\u5931`)}`)}return o.push(` ${Ee.gray("W/A/S/D \u6216 \u65B9\u5411\u952E\u79FB\u52A8 | P \u6682\u505C | M \u5207\u6362\u6A21\u5F0F | Q \u9000\u51FA")}`),e.isPaused&&(o.push(""),o.push(` ${Ee.yellow("\u23F8 \u5DF2\u6682\u505C \u2014 \u6309 P \u7EE7\u7EED")}`)),e.isGameOver&&(o.push(""),o.push(` ${Ee.red.bold("\u{1F480} \u6E38\u620F\u7ED3\u675F!")} ${Ee.cyan("\u6700\u7EC8\u5206\u6570: "+e.score)}`),o.push(` ${Ee.gray("\u6309 R \u91CD\u65B0\u5F00\u59CB | \u6309 Q \u9000\u51FA")}`)),o}p();import*as og from"readline";var VC={up:"UP",w:"UP",W:"UP",down:"DOWN",s:"DOWN",S:"DOWN",left:"LEFT",a:"LEFT",A:"LEFT",right:"RIGHT",d:"RIGHT",D:"RIGHT"};function sg(e,t,n){og.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0);let r=(o,s)=>{if(!s||!s.name)return;let{name:i,ctrl:a}=s;if(a&&(i==="c"||i==="d")){t();return}if(i==="q"){t();return}let l=e.state;if(l.isGameOver){i==="r"&&(e.state=n());return}if(i==="p"){l.isPaused=!l.isPaused;return}if(i==="m"){l.wallWrap=!l.wallWrap;return}let c=VC[i];c&&Zh(l,c)};return process.stdin.on("keypress",r),()=>{process.stdin.removeListener("keypress",r),process.stdin.isTTY&&process.stdin.setRawMode(!1)}}var $i={width:20,height:16,initialSpeed:180,minSpeed:60,speedDecrement:10,scorePerLevel:5},zC=200,qC={id:"snake",name:"Big Snake",description:"\u7ECF\u5178\u8D2A\u5403\u86C7\uFF0C\u53CC\u98DF\u7269\u7CFB\u7EDF\u3001\u96BE\u5EA6\u9012\u589E\u3001\u7A7F\u5899/\u649E\u5899\u6A21\u5F0F",play:async()=>{let e={state:Eu($i)};return new Promise(t=>{let n=sg(e,()=>{r=!0,clearTimeout(o),tg(),n(),t()},()=>Eu($i));ng(),eg();let r=!1,o;function s(){if(r)return;let i=e.state;!i.isGameOver&&!i.isPaused&&Jh(i,$i),rg(i,$i);let a=i.isGameOver||i.isPaused?zC:i.tickInterval;o=setTimeout(s,a)}o=setTimeout(s,0)})}},ig=qC;function Iu(){return Pi(Gh),Pi(Kh),Pi(ig),Lo()}import{render as bg}from"ink";import xt from"chalk";p();p();import{Box as Q,Text as ee,useInput as KC}from"ink";import{useState as pt,useCallback as ag,useEffect as Oo,useMemo as XC}from"react";import Pu from"asciichart";import JC from"os";import{join as ZC}from"path";import{jsx as F,jsxs as Ie}from"react/jsx-runtime";var lg=ZC(JC.homedir(),".dskcode","settings.json");function YC(e){let t=e.replace(/\\/g,"/");return process.platform==="win32"?"file://"+t.replace(/^([a-zA-Z]:)/,"/$1"):"file://"+t}function QC(e,t){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}var e_="https://web.ifzq.gtimg.cn/appstock/app/minute/query?code={code}&r=0.1";function cg(e){return e.startsWith("sh")||e.startsWith("sz")?e:/^60|^68|^51/.test(e)?"sh"+e:/^00|^30|^39/.test(e)?"sz"+e:"sh"+e}async function ug(e){let t=e_.replace("{code}",cg(e));try{let r=await(await fetch(t)).json();if(r.code!==0)return null;let o=cg(e),s=r.data?.[o];if(!s)return null;let i=s.data?.data??[],a=[];for(let d of i){let m=d.split(" ");if(m.length>=2){let h=parseFloat(m[1]);isNaN(h)||a.push(h)}}let l=o,c=s.qt?.[l],u=null;return c&&c.length>=35&&(u={code:e,name:c[1]??"",price:parseFloat(c[3]??"0"),changePercent:parseFloat(c[32]??"0"),changeAmount:parseFloat(c[31]??"0"),high:parseFloat(c[33]??"0"),low:parseFloat(c[34]??"0"),volume:parseInt(c[6]??"0",10),amount:parseFloat(c[37]??"0")*1e4}),{prices:a,quote:u,date:s.data?.date??""}}catch{return null}}var dg=new Map;function pg(e,t){dg.set(e,t)}var t_=[{code:"000001",name:"\u4E0A\u8BC1\u6307\u6570",price:3150,changePercent:.35,changeAmount:11.02,high:3160,low:3140,volume:28543e4,amount:156e10},{code:"601899",name:"\u7D2B\u91D1\u77FF\u4E1A",price:18.2,changePercent:1.85,changeAmount:.33,high:18.45,low:17.9,volume:59615384,amount:1085e7},{code:"399006",name:"\u521B\u4E1A\u677F\u6307",price:1820,changePercent:-.52,changeAmount:-9.5,high:1835,low:1815,volume:9865e4,amount:1824e7}];async function n_(e){let n=(await Promise.all(e.map(async r=>{let o=await ug(r);return o?.quote?(o.prices.length>0&&pg(r,o.prices),o.quote):null}))).filter(r=>r!==null);return n.length>0?n:t_}function Oi(e){return e>=100?e.toFixed(2):e.toFixed(3)}function r_(e){return e>=1e12?(e/1e12).toFixed(2)+"\u4E07\u4EBF":e>=1e8?(e/1e8).toFixed(2)+"\u4EBF":e>=1e4?(e/1e4).toFixed(1)+"\u4E07":e.toLocaleString()}function o_(e,t=60){return e.length<=t?e:e.slice(e.length-t)}function Di({codes:e,onExit:t,onBackToChat:n}){let[r,o]=pt([]),[s,i]=pt(0),[a,l]=pt(!0),[c,u]=pt(""),[d,m]=pt(null),[h,f]=pt(null),[g,k]=pt(!1),[b,S]=pt(10),[R,v]=pt(5),[_,B]=pt(()=>new Date().toLocaleTimeString("zh-CN",{hour12:!1})),[j,D]=pt(!1),[C,J]=pt("default"),M=XC(()=>C==="default"?r:[...r].toSorted((H,se)=>C==="desc"?se.changePercent-H.changePercent:H.changePercent-se.changePercent),[r,C]),{doubleCtrlC:U,handleCtrlC:N}=Tn(t);Oo(()=>{let H=setInterval(()=>{B(new Date().toLocaleTimeString("zh-CN",{hour12:!1}))},1e3);return()=>clearInterval(H)},[]);let ie=ag(async()=>{l(!0);try{let H=await n_(e??[]);o(H),u(new Date().toLocaleTimeString())}catch{}l(!1)},[e]);if(Oo(()=>{ie()},[ie]),Oo(()=>{let H=setInterval(()=>{v(se=>se<=1?(ie(),5):se-1)},1e3);return()=>clearInterval(H)},[ie]),Oo(()=>{if(d){let H=()=>{dg.delete(d.code),ug(d.code).then(ce=>{ce&&ce.prices.length>0&&(pg(d.code,ce.prices),f(ce.prices))})};H(),S(10);let se=setInterval(H,1e4);return()=>clearInterval(se)}f(null),k(!1)},[d]),Oo(()=>{if(!d)return;let H=setInterval(()=>{S(se=>se>0?se-1:10)},1e3);return()=>clearInterval(H)},[d]),KC(ag((H,se)=>{if(H==="c"&&se.ctrl){N();return}if(d){(se.escape||H==="q"||H===" ")&&m(null);return}if(r.length!==0)if(se.upArrow||H==="k")i(ce=>ce>0?ce-1:r.length-1);else if(se.downArrow||H==="j")i(ce=>ce<r.length-1?ce+1:0);else if(se.return){let ce=r[s];ce&&m(ce)}else se.escape||H==="q"?n?n():t():H==="r"?(v(5),ie()):H==="o"?J(ce=>ce==="default"?"desc":ce==="desc"?"asc":"default"):H==="h"&&D(ce=>!ce)},[r,s,d,t,n,ie,N,D])),d)return g?F(Q,{paddingLeft:1,children:F(ee,{dimColor:!0,children:" \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..."})}):s_(d,()=>m(null),h??void 0,b,_);let ne=H=>j?{dimColor:!0}:{color:H};return Ie(Q,{flexDirection:"column",children:[Ie(Q,{marginBottom:1,justifyContent:"space-between",children:[F(ee,{bold:!0,...ne("#00ffff"),children:" \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7"}),Ie(ee,{dimColor:!0,children:[" \u{1F550} ",_]}),F(ee,{dimColor:!0,children:a?" \u27F3 \u5237\u65B0\u4E2D...":` ${R}s \u540E\u81EA\u52A8\u5237\u65B0`})]}),Ie(Q,{children:[F(Q,{width:3}),F(Q,{width:9,children:F(ee,{dimColor:!0,children:"\u4EE3\u7801"})}),F(Q,{width:16,children:F(ee,{dimColor:!0,children:"\u540D\u79F0"})}),F(Q,{width:12,children:F(ee,{dimColor:!0,children:"\u6700\u65B0\u4EF7"})}),F(Q,{width:12,children:Ie(ee,{dimColor:!0,children:["\u6DA8\u8DCC\u5E45",C==="desc"?" \u25BC":C==="asc"?" \u25B2":""]})}),F(Q,{width:12,children:F(ee,{dimColor:!0,children:"\u6DA8\u8DCC\u989D"})}),F(Q,{width:12,children:F(ee,{dimColor:!0,children:"\u6700\u9AD8"})}),F(Q,{width:12,children:F(ee,{dimColor:!0,children:"\u6700\u4F4E"})}),F(Q,{children:F(ee,{dimColor:!0,children:"\u6210\u4EA4\u989D"})})]}),F(Q,{children:F(ee,{dimColor:!0,children:" "+"\u2500".repeat(100)})}),F(Q,{flexDirection:"column",children:M.map((H,se)=>{let ce=se===s,_r=H.changePercent>=0,Vn=_r?"#ff1493":"#00ff41";return Ie(Q,{children:[F(Q,{width:3,flexShrink:0,children:ce?F(ee,{bold:!0,...ne("#00ffff"),children:"\u25B8 "}):F(ee,{children:" "})}),F(Q,{width:9,children:F(ee,{bold:!0,...ne(ce?"#00ffff":"#ffffff"),children:H.code})}),F(Q,{width:16,children:F(ee,{...ne(ce?"#ffffff":"#cccccc"),children:H.name})}),F(Q,{width:12,children:F(ee,{bold:!0,...ne(Vn),children:Oi(H.price)})}),F(Q,{width:12,children:Ie(ee,{...ne(Vn),children:[_r?"+":"",H.changePercent.toFixed(2),"%"]})}),F(Q,{width:12,children:Ie(ee,{...ne(Vn),children:[_r?"+":"",H.changeAmount.toFixed(3)]})}),F(Q,{width:12,children:F(ee,{...ne("#cccccc"),children:Oi(H.high)})}),F(Q,{width:12,children:F(ee,{...ne("#888888"),children:Oi(H.low)})}),F(Q,{children:F(ee,{...ne("#888888"),children:r_(H.amount)})})]},H.code)})}),F(Q,{marginTop:1,children:F(ee,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u8BE6\u60C5 r \u624B\u52A8\u5237\u65B0 o \u6392\u5E8F h \u7F6E\u7070/\u6062\u590D q \u8FD4\u56DE"})}),Ie(Q,{children:[F(ee,{dimColor:!0,children:` \u6700\u540E\u66F4\u65B0: ${c} \u7F16\u8F91\u81EA\u9009\u80A1: `}),F(ee,{...ne("#c792ea"),children:QC(YC(lg),lg)})]}),U&&F(Q,{marginTop:1,children:F(ee,{bold:!0,...ne("#ff1493"),children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}function s_(e,t,n,r=10,o){let s=e.changePercent>=0,i=s?"#ff1493":"#00ff41",a=s?"\u25B2":"\u25BC",l=[];if(n&&n.length>0){let c=s?Pu.red:Pu.green,u=o_(n,60),d=Pu.plot(u,{height:10,colors:[c]});d=d.replaceAll("\u256D","\u250C").replaceAll("\u256E","\u2510").replaceAll("\u2570","\u2514").replaceAll("\u256F","\u2518"),l=d.split(`
603
+ `)}return Ie(Q,{flexDirection:"column",paddingLeft:1,children:[Ie(Q,{marginBottom:1,justifyContent:"space-between",children:[Ie(Q,{children:[Ie(ee,{bold:!0,color:"#00ffff",children:[" \u{1F4CA} ",e.name," "]}),F(ee,{dimColor:!0,children:e.code}),o&&Ie(ee,{dimColor:!0,children:[" \u{1F550} ",o]})]}),F(ee,{dimColor:!0,children:`${r}s \u540E\u5237\u65B0`})]}),Ie(Q,{children:[F(Q,{width:16,children:F(ee,{bold:!0,color:"#888888",children:"\u5F53\u524D\u4EF7"})}),F(Q,{children:Ie(ee,{bold:!0,color:i,children:[a," ",Oi(e.price)]})})]}),Ie(Q,{children:[F(Q,{width:16,children:F(ee,{color:"#888888",children:"\u6DA8\u8DCC\u5E45"})}),F(Q,{children:Ie(ee,{color:i,children:[s?"+":"",e.changePercent.toFixed(2),"%"," ",s?"+":"",e.changeAmount.toFixed(3)]})})]}),l.length>0&&F(Q,{marginTop:1,flexDirection:"column",children:l.map((c,u)=>F(Q,{children:F(ee,{color:i,children:c||" "})},u))}),F(Q,{marginTop:1,children:F(ee,{dimColor:!0,children:" Space/q \u8FD4\u56DE\u5217\u8868"})})]})}p();import{readdir as i_,realpath as a_}from"fs/promises";import{join as fg,relative as l_}from"path";var c_=new Set(["node_modules",".git",".svn",".hg",".dskcode",".claude","dist","build",".next",".turbo",".nx","coverage",".cache",".nyc_output",".vscode",".idea","__pycache__",".venv","venv",".tox","target","vendor","bower_components","jspm_packages"]);async function mg(e,t,n=1/0,r){let o=t??e,s=r??new Set;try{let d=await a_(o);if(s.has(d))return[];s.add(d)}catch{}let i;try{i=await i_(o,{withFileTypes:!0})}catch{return[]}let a=[],l=[];for(let d of i){let m=d.name;c_.has(m)||m.startsWith(".")||(d.isDirectory()?l.push(m):d.isFile()&&a.push(l_(e,fg(o,m))))}let c=t===void 0?n:Math.max(0,n-1),u=c<=1?[]:await Promise.all(l.map(d=>mg(e,fg(o,d),c,s)));for(let d of u)a.push(...d);return a}var u_=8;async function hg(e){return mg(e,void 0,u_)}import{jsx as Cr}from"react/jsx-runtime";var m_=["chat","run","setup","init","completion","game","stock","config-ui"];function wg(){let e=new d_;return e.exitOverride(),e.name("dskcode").description("\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\u7EC8\u7AEF\u5DE5\u5177").version(Co,"-V, --version","\u663E\u793A\u7248\u672C\u53F7").option("--verbose","\u5F00\u542F\u8BE6\u7EC6\u65E5\u5FD7\u8F93\u51FA").option("--config <path>","\u6307\u5B9A\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84").option("--dir <path>","\u6307\u5B9A\u5DE5\u4F5C\u5B50\u76EE\u5F55\uFF0C@ \u63D0\u793A\u4EC5\u663E\u793A\u8BE5\u76EE\u5F55\u4E0B\u7684\u6587\u4EF6").option("--no-config-ui","\u4E0D\u62C9\u8D77\u672C\u5730 ws server\uFF08\u9ED8\u8BA4\u4E0E chat \u5E76\u53D1\u62C9\u8D77\uFF09").option("--ws","\u8DF3\u8FC7 chat\uFF0C\u76F4\u63A5\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF08\u9ED8\u8BA4 54006 \u7AEF\u53E3\uFF0C\u4F9B Chrome \u6269\u5C55\u8FDE\u63A5\uFF09"),e.helpInformation=()=>cd(e),e.hook("preAction",async(t,n)=>{let r=await ld.call(t);n.dskcodeCtx=r}),e.command("chat").description("\u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD\u4F1A\u8BDD(\u65E0\u53C2\u8FD0\u884C `dskcode` \u7B49\u4EF7\u4E8E\u6B64\u547D\u4EE4)").action(async function(){await yg(this)}),e.action(async function(){let t=this;if(t.opts().ws){let{startConfigUi:r}=await import("./config-ui-ESM4R7PB.js");await r({});return}await yg(t)}),e.command("run").description("\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1").argument("[prompt...]","\u4EFB\u52A1\u63CF\u8FF0").option("--model <name>","\u6307\u5B9A\u4F7F\u7528\u7684\u6A21\u578B").action(async function(t){console.log("dskcode run \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C07\u7AE0\uFF09")}),e.command("setup").description("\u8FD0\u884C\u914D\u7F6E\u5411\u5BFC").option("--export","\u4EE5 JSON \u683C\u5F0F\u5BFC\u51FA\u914D\u7F6E").option("--test","\u6D4B\u8BD5 API Key \u8FDE\u901A\u6027").action(async function(){console.log("dskcode setup \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C14\u7AE0\uFF09")}),e.command("init").description("\u5728\u5F53\u524D\u9879\u76EE\u4E0B\u751F\u6210\u9879\u76EE\u8BB0\u5FC6\u6587\u4EF6\uFF08AGENTS.md\uFF09").action(async function(){console.log("dskcode init \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C11\u7AE0\uFF09")}),e.command("completion").description("\u8F93\u51FA shell \u81EA\u52A8\u8865\u5168\u914D\u7F6E\u8BF4\u660E\uFF08bash/zsh\uFF09").argument("[shell]","shell \u7C7B\u578B",/^(bash|zsh)$/i).action(async function(t){if(!t){console.log("\u8BF7\u6307\u5B9A shell \u7C7B\u578B\uFF1Adskcode completion bash \u6216 dskcode completion zsh");return}console.log(t==="bash"?`# dskcode bash \u81EA\u52A8\u8865\u5168
600
604
  _dskcode_completion() {
601
605
  local cur=\${COMP_WORDS[COMP_CWORD]}
602
606
  if [[ \${COMP_CWORD} -eq 1 ]]; then
603
- COMPREPLY=( $(compgen -W "${ZC.join(" ")}" -- "\${cur}") )
607
+ COMPREPLY=( $(compgen -W "${m_.join(" ")}" -- "\${cur}") )
604
608
  return 0
605
609
  fi
606
610
  COMPREPLY=( $(compgen -W "--verbose --config --model" -- "\${cur}") )
@@ -619,15 +623,15 @@ _dskcode_completion() {
619
623
  )
620
624
  _describe 'dskcode commands' commands
621
625
  }
622
- compdef _dskcode_completion dskcode`)}),e.command("stock").description("\u67E5\u770B\u81EA\u9009\u80A1\u5B9E\u65F6\u884C\u60C5").argument("[codes...]","\u80A1\u7968\u4EE3\u7801\uFF08\u7A7A\u683C\u5206\u9694\uFF09\uFF0C\u5982 513090 600519").action(async function(t){let n=this.dskcodeCtx,r=process.env.HOME??process.env.USERPROFILE??"~",o=dg(r,".dskcode","settings.json"),s=!1;try{let c=await JC(o,"utf-8"),d=JSON.parse(c).stock;s=Array.isArray(d?.symbols)&&d.symbols.length>0}catch{}if(!s){let u=await ba([{code:"sh000001"},{code:"sz399300"},{code:"sh601899"}]);console.log(`${xt.green("\u2714")} \u5DF2\u751F\u6210\u81EA\u9009\u80A1\u914D\u7F6E: ${xt.dim(u)}`),console.log(`${xt.dim(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u81EA\u5B9A\u4E49\u81EA\u9009\u80A1\u5217\u8868")}
623
- `)}let i=await Lt(),a=t&&t.length>0?t:i.config.stock?.symbols?.map(c=>c.code)??["sh000001","sz399006","sh601688"];await Fr(Rr(Pi,{codes:a,onExit:()=>process.exit(0)})).waitUntilExit}),_u(),e.command("game").description("\u542F\u52A8\u5185\u7F6E\u5C0F\u6E38\u620F").argument("[name]","\u6E38\u620F\u540D\u79F0\uFF0C\u4E0D\u6307\u5B9A\u5219\u663E\u793A\u4EA4\u4E92\u5F0F\u6E38\u620F\u5217\u8868").action(async function(t){if(t){let n=Eh(t);n||(console.error(`\u672A\u627E\u5230\u6E38\u620F "${t}"\u3002\u4F7F\u7528 dskcode game \u67E5\u770B\u53EF\u7528\u6E38\u620F\u5217\u8868\u3002`),process.exit(1)),console.log(`\u6B63\u5728\u542F\u52A8: ${n.name} \u2014 ${n.description}
624
- `),await n.play()}else{let n=Io();if(n.length===0){console.log("\u6682\u65E0\u53EF\u7528\u6E38\u620F\u3002");return}let r=await new Promise(o=>{let{unmount:s}=pg(Rr(vi,{games:n,onSelect:i=>{s(),o(i)},onExit:()=>{s(),o(null)}}),{exitOnCtrlC:!1})});r&&(console.log(`
626
+ compdef _dskcode_completion dskcode`)}),e.command("stock").description("\u67E5\u770B\u81EA\u9009\u80A1\u5B9E\u65F6\u884C\u60C5").argument("[codes...]","\u80A1\u7968\u4EE3\u7801\uFF08\u7A7A\u683C\u5206\u9694\uFF09\uFF0C\u5982 513090 600519").action(async function(t){let n=this.dskcodeCtx,r=process.env.HOME??process.env.USERPROFILE??"~",o=xg(r,".dskcode","settings.json"),s=!1;try{let c=await f_(o,"utf-8"),d=JSON.parse(c).stock;s=Array.isArray(d?.symbols)&&d.symbols.length>0}catch{}if(!s){let u=await Ta([{code:"sh000001"},{code:"sz399300"},{code:"sh601899"}]);console.log(`${xt.green("\u2714")} \u5DF2\u751F\u6210\u81EA\u9009\u80A1\u914D\u7F6E: ${xt.dim(u)}`),console.log(`${xt.dim(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u81EA\u5B9A\u4E49\u81EA\u9009\u80A1\u5217\u8868")}
627
+ `)}let i=await Lt(),a=t&&t.length>0?t:i.config.stock?.symbols?.map(c=>c.code)??["sh000001","sz399006","sh601688"];await Br(Cr(Di,{codes:a,onExit:()=>process.exit(0)})).waitUntilExit}),Iu(),e.command("game").description("\u542F\u52A8\u5185\u7F6E\u5C0F\u6E38\u620F").argument("[name]","\u6E38\u620F\u540D\u79F0\uFF0C\u4E0D\u6307\u5B9A\u5219\u663E\u793A\u4EA4\u4E92\u5F0F\u6E38\u620F\u5217\u8868").action(async function(t){if(t){let n=Nh(t);n||(console.error(`\u672A\u627E\u5230\u6E38\u620F "${t}"\u3002\u4F7F\u7528 dskcode game \u67E5\u770B\u53EF\u7528\u6E38\u620F\u5217\u8868\u3002`),process.exit(1)),console.log(`\u6B63\u5728\u542F\u52A8: ${n.name} \u2014 ${n.description}
628
+ `),await n.play()}else{let n=Lo();if(n.length===0){console.log("\u6682\u65E0\u53EF\u7528\u6E38\u620F\u3002");return}let r=await new Promise(o=>{let{unmount:s}=bg(Cr(Ii,{games:n,onSelect:i=>{s(),o(i)},onExit:()=>{s(),o(null)}}),{exitOnCtrlC:!1})});r&&(console.log(`
625
629
  \u542F\u52A8\u6E38\u620F: ${xt.green(r.name)}
626
- `),await r.play())}}),e.command("config-ui").description("\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF0C\u5141\u8BB8 Chrome \u6269\u5C55\u7F16\u8F91 settings.json (\u9ED8\u8BA4\u7AEF\u53E3 54006)").option("--host <host>","\u76D1\u542C host\uFF0C\u9ED8\u8BA4 127.0.0.1\uFF08\u5FC5\u987B\u4FDD\u7559 loopback\uFF09","127.0.0.1").option("--port <port>","\u76D1\u542C\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 54006 (\u4E0E Chrome \u6269\u5C55\u540C\u6B65)",t=>Number.parseInt(t,10),54006).action(async function(){let t=this.opts(),{startConfigUi:n}=await import("./config-ui-LWC4GWEV.js");await n({host:t.host??"127.0.0.1",port:t.port??54006})}),e}async function ug(e){let t="opts"in e?e.opts():{},n=t.dir??process.cwd();process.stdin.isTTY||(console.error("dskcode chat \u9700\u8981\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\u3002\u5982\u9700\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1\uFF0C\u8BF7\u4F7F\u7528 dskcode run\u3002"),process.exit(1));let r=e.dskcodeCtx;if(r&&!id(r.config.providers)){let u=await ad();u||process.exit(1);let d=await xa(u);console.log(` ${xt.green("\u2714")} API Key \u5DF2\u4FDD\u5B58\u5230 ${xt.dim(d)}
627
- `);let m=await Lt();r={...r,config:m.config}}await dd(process.cwd());let o=await wa();if(o){let u=await Lt();r={...r,config:u.config},console.log(" \u2714 \u5DF2\u751F\u6210\u6743\u9650\u914D\u7F6E: "+o),console.log(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u6DFB\u52A0 permissions \u89C4\u5219")}let s=cs(r?.config.voice);if(s.resolved)(s.source.appId==="env"||s.source.accessKey==="env")&&console.log(` ${xt.dim("\u2139 \u8BED\u97F3\u51ED\u636E\u4ECE\u73AF\u5883\u53D8\u91CF\u8BFB\u53D6\uFF08\u672A\u6301\u4E45\u5316\u5230 settings.json\uFF09")}`);else{let u=await ld();if(!u)console.log(" "+xt.yellow("\u26A0 \u672A\u914D\u7F6E\u8BED\u97F3\u8BC6\u522B\u51ED\u636E\uFF0C/voice \u547D\u4EE4\u4E0D\u53EF\u7528\uFF08\u5176\u4F59\u529F\u80FD\u6B63\u5E38\uFF09"));else{let d=process.env.HOME??process.env.USERPROFILE??"~",m=dg(d,".dskcode","settings.json");await _a(m,u.appId,u.accessKey),console.log(` ${xt.green("\u2714")} \u8BED\u97F3\u51ED\u636E\u5DF2\u4FDD\u5B58\u5230 ${xt.dim(m)}
628
- `);let h=await Lt();r=r?{...r,config:h.config}:{config:h.config,verbose:!1},s=cs(h.config.voice)}}let i=new Me({budgetLimit:r?.config.budgetLimit??0,tokenBudgetLimit:r?.config.tokenBudgetLimit??0}),l=process.env.DSKCODE_CONFIG_UI==="0"?!1:t.configUi??!0,c=null;if(l){let{startConfigServerBackground:u}=await import("./config-ui-LWC4GWEV.js");c=await u({})}Li(r,i,n,s,c)}async function Li(e,t,n=process.cwd(),r,o=null){let[s,i,a,l]=await Promise.all([ud(),Ea(process.cwd()),pd(process.cwd()),lg(n)]),c=s+i;function u(m){let[h,f]=cg(e),[g,b]=cg(0),w=o;XC(()=>w?w.onConfigChanged(q=>{Lt().then($=>{e&&(e.config=$.config,f({...e,config:$.config})),b(oe=>oe+1),console.error(xt.cyan(`
629
- \u27F3 dskcode \u8FD0\u884C\u65F6\u8BBE\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D (source: ${q.source})
630
- `))}).catch($=>{console.error(` \u26A0 \u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25: ${$.message}`)})}):void 0,[w]);let S=h??e,v=S?.config.providers.find(F=>F.name===(S?.config.defaultProvider??"deepseek")),_=v?.model??"deepseek-v4-flash",E=v?.apiKey,M=v?.baseUrl??"https://api.deepseek.com",U=S?.verbose??!1,T=S?.config.thinking?.enabled??!1,N=S?.config.thinking?.effort??"high";return Rr(mu,{...m,model:_,apiKey:E,baseUrl:M,verbose:U,thinkingEnabledFromConfig:T,thinkingEffortFromConfig:N,configReloadEpoch:g})}let d=Fr(Rr(u,{skillCount:c,skills:a,files:l,toolCount:e?.config.tools.length??0,costTracker:t,permissionsConfig:e?.config.permissions,voiceConfig:r,onLaunchGame:()=>{d.unmount(),setImmediate(()=>{_u();let m=Io(),{unmount:h}=pg(Rr(vi,{games:m,onSelect:async f=>{h(),await f.play(),Li(e,t,n,r,o)},onBackToChat:()=>{h(),setImmediate(()=>Li(e,t,n,r,o))}}),{exitOnCtrlC:!1})})},onLaunchStock:()=>{d.unmount(),setImmediate(()=>{let m=e?.config.stock?.symbols?.map(f=>f.code)??["sh000001","sz399006","sh601688"],h=Fr(Rr(Pi,{codes:m,onBackToChat:()=>{h.unmount(),setImmediate(()=>Li(e,t,n,r))},onExit:()=>process.exit(0)}))})}}))}p();var $o={SUCCESS:0,GENERAL_ERROR:1,CONFIG_ERROR:2,SIGINT:130};var Ru=0,Au=null;async function mg(e){try{await Promise.all([Me.flushAll(),en.endAllAndFlush()])}catch{}process.exit(e)}process.on("SIGINT",()=>{if(Ru++,Ru>=2){mg($o.SIGINT);return}process.stdout.write(`
630
+ `),await r.play())}}),e.command("config-ui").description("\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF0C\u5141\u8BB8 Chrome \u6269\u5C55\u7F16\u8F91 settings.json (\u9ED8\u8BA4\u7AEF\u53E3 54006)").option("--host <host>","\u76D1\u542C host\uFF0C\u9ED8\u8BA4 127.0.0.1\uFF08\u5FC5\u987B\u4FDD\u7559 loopback\uFF09","127.0.0.1").option("--port <port>","\u76D1\u542C\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 54006 (\u4E0E Chrome \u6269\u5C55\u540C\u6B65)",t=>Number.parseInt(t,10),54006).action(async function(){let t=this.opts(),{startConfigUi:n}=await import("./config-ui-ESM4R7PB.js");await n({host:t.host??"127.0.0.1",port:t.port??54006})}),e}async function yg(e){let t="opts"in e?e.opts():{},n=t.dir??process.cwd();process.stdin.isTTY||(console.error("dskcode chat \u9700\u8981\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\u3002\u5982\u9700\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1\uFF0C\u8BF7\u4F7F\u7528 dskcode run\u3002"),process.exit(1));let r=e.dskcodeCtx;if(r&&!dd(r.config.providers)){let u=await pd();u||process.exit(1);let d=await Sa(u);console.log(` ${xt.green("\u2714")} API Key \u5DF2\u4FDD\u5B58\u5230 ${xt.dim(d)}
631
+ `);let m=await Lt();r={...r,config:m.config}}await gd(process.cwd());let o=await Ca();if(o){let u=await Lt();r={...r,config:u.config},console.log(" \u2714 \u5DF2\u751F\u6210\u6743\u9650\u914D\u7F6E: "+o),console.log(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u6DFB\u52A0 permissions \u89C4\u5219")}let s=ps(r?.config.voice);if(s.resolved)(s.source.appId==="env"||s.source.accessKey==="env")&&console.log(` ${xt.dim("\u2139 \u8BED\u97F3\u51ED\u636E\u4ECE\u73AF\u5883\u53D8\u91CF\u8BFB\u53D6\uFF08\u672A\u6301\u4E45\u5316\u5230 settings.json\uFF09")}`);else{let u=await fd();if(!u)console.log(" "+xt.yellow("\u26A0 \u672A\u914D\u7F6E\u8BED\u97F3\u8BC6\u522B\u51ED\u636E\uFF0C/voice \u547D\u4EE4\u4E0D\u53EF\u7528\uFF08\u5176\u4F59\u529F\u80FD\u6B63\u5E38\uFF09"));else{let d=process.env.HOME??process.env.USERPROFILE??"~",m=xg(d,".dskcode","settings.json");await Ea(m,u.appId,u.accessKey),console.log(` ${xt.green("\u2714")} \u8BED\u97F3\u51ED\u636E\u5DF2\u4FDD\u5B58\u5230 ${xt.dim(m)}
632
+ `);let h=await Lt();r=r?{...r,config:h.config}:{config:h.config,verbose:!1},s=ps(h.config.voice)}}let i=new Me({budgetLimit:r?.config.budgetLimit??0,tokenBudgetLimit:r?.config.tokenBudgetLimit??0}),l=process.env.DSKCODE_CONFIG_UI==="0"?!1:t.configUi??!0,c=null;if(l){let{startConfigServerBackground:u}=await import("./config-ui-ESM4R7PB.js");c=await u({})}Ni(r,i,n,s,c)}async function Ni(e,t,n=process.cwd(),r,o=null){let[s,i,a,l]=await Promise.all([hd(),$a(process.cwd()),yd(process.cwd()),hg(n)]),c=s+i;function u(m){let[h,f]=gg(e),[g,k]=gg(0),b=o;p_(()=>b?b.onConfigChanged(M=>{Lt().then(U=>{e&&(e.config=U.config,f({...e,config:U.config})),k(N=>N+1),console.error(xt.cyan(`
633
+ \u27F3 dskcode \u8FD0\u884C\u65F6\u8BBE\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D (source: ${M.source})
634
+ `))}).catch(U=>{console.error(` \u26A0 \u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25: ${U.message}`)})}):void 0,[b]);let S=h??e,R=S?.config.providers.find(J=>J.name===(S?.config.defaultProvider??"deepseek")),v=R?.model??"deepseek-v4-flash",_=R?.apiKey,B=R?.baseUrl??"https://api.deepseek.com",j=S?.verbose??!1,D=S?.config.thinking?.enabled??!1,C=S?.config.thinking?.effort??"high";return Cr(bu,{...m,model:v,apiKey:_,baseUrl:B,verbose:j,thinkingEnabledFromConfig:D,thinkingEffortFromConfig:C,configReloadEpoch:g})}let d=Br(Cr(u,{skillCount:c,skills:a,files:l,toolCount:e?.config.tools.length??0,costTracker:t,permissionsConfig:e?.config.permissions,voiceConfig:r,permissionBroker:o?.permissionBroker,onLaunchGame:()=>{d.unmount(),setImmediate(()=>{Iu();let m=Lo(),{unmount:h}=bg(Cr(Ii,{games:m,onSelect:async f=>{h(),await f.play(),Ni(e,t,n,r,o)},onBackToChat:()=>{h(),setImmediate(()=>Ni(e,t,n,r,o))}}),{exitOnCtrlC:!1})})},onLaunchStock:()=>{d.unmount(),setImmediate(()=>{let m=e?.config.stock?.symbols?.map(f=>f.code)??["sh000001","sz399006","sh601688"],h=Br(Cr(Di,{codes:m,onBackToChat:()=>{h.unmount(),setImmediate(()=>Ni(e,t,n,r))},onExit:()=>process.exit(0)}))})}}))}p();var Do={SUCCESS:0,GENERAL_ERROR:1,CONFIG_ERROR:2,SIGINT:130};var Lu=0,$u=null;async function kg(e){try{await Promise.all([Me.flushAll(),en.endAllAndFlush()])}catch{}process.exit(e)}process.on("SIGINT",()=>{if(Lu++,Lu>=2){kg(Do.SIGINT);return}process.stdout.write(`
631
635
  \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode
632
- `),Au&&clearTimeout(Au),Au=setTimeout(()=>{Ru=0},1500)});process.on("SIGTERM",()=>{mg($o.SIGINT)});var YC=fg();try{await YC.parseAsync(process.argv),await Promise.all([Me.flushAll(),en.endAllAndFlush()])}catch(e){let t=e;(t.code==="commander.helpDisplayed"||t.code==="commander.version")&&(await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(t.exitCode??$o.SUCCESS)),typeof t.exitCode=="number"&&(await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(t.exitCode)),console.error(String(e)),await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit($o.GENERAL_ERROR)}
636
+ `),$u&&clearTimeout($u),$u=setTimeout(()=>{Lu=0},1500)});process.on("SIGTERM",()=>{kg(Do.SIGINT)});var h_=wg();try{await h_.parseAsync(process.argv),await Promise.all([Me.flushAll(),en.endAllAndFlush()])}catch(e){let t=e;(t.code==="commander.helpDisplayed"||t.code==="commander.version")&&(await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(t.exitCode??Do.SUCCESS)),typeof t.exitCode=="number"&&(await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(t.exitCode)),console.error(String(e)),await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(Do.GENERAL_ERROR)}
633
637
  //# sourceMappingURL=index.js.map