@bkm016/basalt 0.1.9 → 0.1.10

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.
Files changed (132) hide show
  1. package/{chunk-0xd9mnc2.js → chunk-0mjb3sm3.js} +2 -2
  2. package/{chunk-66h5qpc6.js → chunk-3mqf9ped.js} +89 -89
  3. package/compiled.js +1 -1
  4. package/package.json +1 -1
  5. package/ui-test-worker.js +1 -1
  6. package/web/chunk-045d3b5d.js +1 -0
  7. package/web/{chunk-ff1pmd3g.js → chunk-0770q5e1.js} +1 -1
  8. package/web/{chunk-2x4g9t37.js → chunk-18neka5g.js} +2 -2
  9. package/web/{chunk-w3w18stt.js → chunk-1ev0n3n4.js} +1 -1
  10. package/web/chunk-1ex3wgms.js +2 -0
  11. package/web/{chunk-7qkav30b.js → chunk-1qh7f5kr.js} +1 -1
  12. package/web/{chunk-rayf24gy.js → chunk-26ecc2xh.js} +8 -8
  13. package/web/{chunk-me7dza1c.js → chunk-2cz7tx8q.js} +1 -1
  14. package/web/{chunk-mdfksj61.js → chunk-32ty2xfn.js} +1 -1
  15. package/web/{chunk-ts6jsfdk.js → chunk-3eexx7y5.js} +1 -1
  16. package/web/{chunk-2dvbeqt0.js → chunk-46jnkghq.js} +1 -1
  17. package/web/chunk-4am8j3k3.js +1 -0
  18. package/web/{chunk-qz6r9v1z.js → chunk-5qvmefq2.js} +1 -1
  19. package/web/{chunk-9ctg0f30.js → chunk-5svqfj4g.js} +1 -1
  20. package/web/{chunk-qsqtwf34.js → chunk-5v5q13hz.js} +1 -1
  21. package/web/chunk-7np1jp3x.js +8 -0
  22. package/web/chunk-87e8d1hv.js +1 -0
  23. package/web/{chunk-kcjz03h5.js → chunk-88wd49xe.js} +2 -2
  24. package/web/{chunk-0pghpg4y.js → chunk-8h2x89tw.js} +1 -1
  25. package/web/chunk-8y2526ve.js +1 -0
  26. package/web/{chunk-8jcvdd5d.js → chunk-905vw286.js} +1 -1
  27. package/web/{chunk-2hrswh3d.js → chunk-918e5t4x.js} +1 -1
  28. package/web/chunk-96m2m3e8.js +1 -0
  29. package/web/{chunk-43g4wd7a.js → chunk-9f4zzqbx.js} +1 -1
  30. package/web/{chunk-dnv8dx72.js → chunk-a1n4468c.js} +1 -1
  31. package/web/{chunk-s37beysw.js → chunk-b46ws7rf.js} +1 -1
  32. package/web/{chunk-24jhbz82.js → chunk-bc3ajvfg.js} +1 -1
  33. package/web/{chunk-ket6g0yd.js → chunk-d5gshd1a.js} +1 -1
  34. package/web/{chunk-c6yacwbc.js → chunk-de40q05r.js} +1 -1
  35. package/web/chunk-dp0k5vhd.js +1 -0
  36. package/web/{chunk-5dr4tkem.js → chunk-dv1berk6.js} +3 -3
  37. package/web/{chunk-dwjmr0zj.js → chunk-eh7wp62z.js} +1 -1
  38. package/web/{chunk-ctzkqx2g.js → chunk-ehtmb6sn.js} +1 -1
  39. package/web/chunk-et1hytyv.js +1 -0
  40. package/web/chunk-f9m9seam.js +1 -0
  41. package/web/{chunk-3pd0qt83.js → chunk-fmmrthpa.js} +2 -2
  42. package/web/chunk-g2erm7k0.js +1 -0
  43. package/web/chunk-g3kbn0t2.js +1 -0
  44. package/web/{chunk-t893141g.js → chunk-g7dc4hrd.js} +1 -1
  45. package/web/{chunk-p9hfcamx.js → chunk-g7kz8f7q.js} +1 -1
  46. package/web/chunk-ght0t49g.js +1 -0
  47. package/web/{chunk-xa43ndfj.js → chunk-ghwm7bdj.js} +2 -2
  48. package/web/{chunk-8z0r0wtk.js → chunk-grm2208k.js} +1 -1
  49. package/web/{chunk-0zwc2rvh.js → chunk-gsw1tv96.js} +1 -1
  50. package/web/{chunk-tftc5v89.js → chunk-gw8x1g61.js} +1 -1
  51. package/web/chunk-gx340asc.js +1 -0
  52. package/web/{chunk-935mjq1c.js → chunk-h2txs73e.js} +1 -1
  53. package/web/chunk-h3tkacc7.js +1 -0
  54. package/web/{chunk-ewx42c11.js → chunk-h5ckjk48.js} +1 -1
  55. package/web/{chunk-nnyc889n.js → chunk-j37p0b13.js} +1 -1
  56. package/web/{chunk-fjb3ksfd.js → chunk-j89s11x8.js} +1 -1
  57. package/web/chunk-je78j3vr.js +1 -0
  58. package/web/{chunk-fpb2dd2d.js → chunk-jke2ev6m.js} +1 -1
  59. package/web/{chunk-98y92vmh.js → chunk-js6kb05s.js} +1 -1
  60. package/web/{chunk-30b33r2w.js → chunk-k0cg4n2k.js} +2 -2
  61. package/web/{chunk-b5h52neg.js → chunk-knm82fw9.js} +1 -1
  62. package/web/{chunk-vqmj6peg.js → chunk-kxdtg9dt.js} +1 -1
  63. package/web/{chunk-db3twjvk.js → chunk-m4fxd5d9.js} +5 -5
  64. package/web/chunk-m9xzt9p7.js +1 -0
  65. package/web/{chunk-xx11yv61.js → chunk-n4yzs2q0.js} +1 -1
  66. package/web/{chunk-zdyys4ar.js → chunk-nawxgz87.js} +2 -2
  67. package/web/chunk-ngt1j8py.js +1139 -0
  68. package/web/{chunk-3ak5dg10.js → chunk-p55vhns6.js} +1 -1
  69. package/web/{chunk-nvpp0ghj.js → chunk-pgwf37s2.js} +1 -1
  70. package/web/{chunk-af9evdza.js → chunk-q4bst4an.js} +1 -1
  71. package/web/{chunk-9fnr00kv.js → chunk-qdzy124b.js} +2 -2
  72. package/web/chunk-qe0bgeda.js +1 -0
  73. package/web/{chunk-60axh4sa.js → chunk-qy1zx2yw.js} +2 -2
  74. package/web/{chunk-sk1wkgjw.js → chunk-rag65pfs.js} +1 -1
  75. package/web/{chunk-5jdrev9p.js → chunk-rbqnre6q.js} +3 -3
  76. package/web/{chunk-ddyyc20r.js → chunk-rh3xb76f.js} +1 -1
  77. package/web/{chunk-wzd2a4k5.js → chunk-rwfmccmh.js} +1 -1
  78. package/web/{chunk-zb2bkr7f.js → chunk-rxvm70w5.js} +1 -1
  79. package/web/{chunk-z05x9cbm.js → chunk-sat7zyva.js} +1 -1
  80. package/web/{chunk-rrpn5r5w.js → chunk-sc63488q.js} +1 -1
  81. package/web/{chunk-v1exk5wd.js → chunk-sd3xat3r.js} +6 -6
  82. package/web/{chunk-4a6gdrbs.js → chunk-se4h6wx0.js} +1 -1
  83. package/web/{chunk-a0ryzdnp.js → chunk-sjkg40ay.js} +1 -1
  84. package/web/chunk-sk0hpa80.js +1 -0
  85. package/web/{chunk-spbs56wz.js → chunk-t5nvgz7z.js} +1 -1
  86. package/web/{chunk-veam6vk4.js → chunk-tfqarvdx.js} +30 -30
  87. package/web/{chunk-5a4mj3qz.js → chunk-tqze6d6b.js} +1 -1
  88. package/web/{chunk-8w7fyb3v.js → chunk-tt93zbn4.js} +7 -7
  89. package/web/chunk-tvcxrx6h.js +1 -0
  90. package/web/chunk-tzpnh70q.js +1 -0
  91. package/web/{chunk-79e08rk1.js → chunk-vasppf6b.js} +1 -1
  92. package/web/chunk-vb7g4xg6.js +1 -0
  93. package/web/{chunk-dz7g1gnv.js → chunk-w3zgfhjb.js} +1 -1
  94. package/web/{chunk-gn8kyz76.js → chunk-wrevb4ew.js} +1 -1
  95. package/web/{chunk-3ecrkvr3.js → chunk-wtvch4ad.js} +1 -1
  96. package/web/chunk-wzfe6jtq.js +1 -0
  97. package/web/{chunk-eadfxfkw.js → chunk-x5g1yy12.js} +1 -1
  98. package/web/{chunk-m9q5nr8f.js → chunk-x850q01z.js} +1 -1
  99. package/web/{chunk-a61zrp66.js → chunk-xk904wqv.js} +1 -1
  100. package/web/{chunk-3hr3ew9w.js → chunk-xtn305fd.js} +1 -1
  101. package/web/{chunk-3txxt0a7.js → chunk-yekaz74b.js} +1 -1
  102. package/web/{chunk-rasjtvsb.js → chunk-yppgejg7.js} +2 -2
  103. package/web/{chunk-66wb0p6e.js → chunk-z4bp6p32.js} +1 -1
  104. package/web/{chunk-5v2c0aqk.js → chunk-z5qn0xev.js} +1 -1
  105. package/web/{chunk-5baeh8q7.js → chunk-zms6mrqk.js} +4 -4
  106. package/web/{chunk-601k823s.js → chunk-zse05v6j.js} +2 -2
  107. package/web/{chunk-vsjpnwsr.js → chunk-zz1qkaar.js} +1 -1
  108. package/web/index.html +1 -1
  109. package/web/chunk-08sq3cwm.js +0 -1
  110. package/web/chunk-24fjnnee.js +0 -1
  111. package/web/chunk-2j2atyjw.js +0 -1
  112. package/web/chunk-3h3g3ca3.js +0 -1
  113. package/web/chunk-3pcrxg6m.js +0 -1
  114. package/web/chunk-814kkkmq.js +0 -8
  115. package/web/chunk-8w8atrdh.js +0 -1
  116. package/web/chunk-942g3eqn.js +0 -1
  117. package/web/chunk-avxk6jpc.js +0 -2
  118. package/web/chunk-fmthkpff.js +0 -1
  119. package/web/chunk-gv99c8zv.js +0 -1
  120. package/web/chunk-h0767tjv.js +0 -1
  121. package/web/chunk-hqynf99g.js +0 -1
  122. package/web/chunk-mbwwj216.js +0 -1
  123. package/web/chunk-n0wazxgz.js +0 -1
  124. package/web/chunk-nvt9tkt4.js +0 -1139
  125. package/web/chunk-ph1dgffm.js +0 -1
  126. package/web/chunk-rad2s9ha.js +0 -1
  127. package/web/chunk-s60s09mb.js +0 -1
  128. package/web/chunk-tfvcs2xx.js +0 -1
  129. package/web/chunk-wdq2tp9e.js +0 -1
  130. package/web/chunk-wkf5xfyr.js +0 -1
  131. package/web/chunk-y1qty77a.js +0 -1
  132. package/web/chunk-zgavhnt8.js +0 -1
@@ -0,0 +1 @@
1
+ import"./chunk-tfqarvdx.js";import"./chunk-88wd49xe.js";import"./chunk-rxvm70w5.js";import{oo}from"./chunk-qdzy124b.js";export{oo as render};
@@ -0,0 +1 @@
1
+ import{Ni}from"./chunk-qy1zx2yw.js";export{Ni as createArchitectureServices};
@@ -1,2 +1,2 @@
1
- import{t,Fn,p,Gn}from"./chunk-veam6vk4.js";import{Se}from"./chunk-nvt9tkt4.js";var o=Se(Gn(),1);var an=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),qr=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};an(s,r).lower()},"drawBackgroundRect"),lo=t((s,e)=>{let r=e.text.replace(Fn," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),Aa=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Ra=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),Je=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),La=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Ft=t(()=>{let s=p(".mermaidTooltip");if(s.empty())s=p("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
1
+ import{t,Fn,p,Gn}from"./chunk-tfqarvdx.js";import{Se}from"./chunk-ngt1j8py.js";var o=Se(Gn(),1);var an=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),qr=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};an(s,r).lower()},"drawBackgroundRect"),lo=t((s,e)=>{let r=e.text.replace(Fn," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),Aa=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Ra=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),Je=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),La=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Ft=t(()=>{let s=p(".mermaidTooltip");if(s.empty())s=p("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
2
2
  export{an,qr,lo,Aa,Ra,Je,La,Ft};
@@ -0,0 +1 @@
1
+ import{Ti}from"./chunk-qy1zx2yw.js";export{Ti as createWardleyServices};
@@ -1,2 +1,2 @@
1
- import{g,o,r,e,n,y,ne}from"./chunk-nvt9tkt4.js";import{na}from"./chunk-2hrswh3d.js";function Nn(t){let{Button:i,SettingActions:l,cn:d}=y();return n(l,{children:[t.notice&&n("span",{role:t.notice.type==="error"?"alert":"status",className:d("mr-auto flex min-w-0 items-center gap-1.5 text-xs",t.notice.type==="success"?"text-success":"text-danger"),children:[t.notice.type==="success"?e(na,{className:"size-3.5 shrink-0"}):e(ne,{className:"size-3.5 shrink-0"}),e("span",{className:"min-w-0 break-words",children:t.notice.text})]}),t.dirty&&e(i,{type:"button",variant:"ghost",size:"sm",disabled:t.busy,onClick:t.onReset,children:"撤销更改"}),e(i,{form:t.formID,type:"submit",variant:"primary",size:"sm",disabled:t.busy||!t.dirty,children:t.saving?"保存中…":"保存"})]})}function ta(t){let{connection:i,endpoint:l,loadError:d}=t,[m,b]=r(null),[c,f]=r(null),[N,P]=r({models:[]}),[p,T]=r(!0),[M,v]=r(!1),[h,x]=r(!1),[k,a]=r(null),S=g(async(u=!1)=>{if(u)v(!0);else T(!0);a(null);try{let[s,C]=await Promise.all([i.request(l),i.request("/api/models")]);b(s),f(s),P(C)}catch(s){a({type:"error",text:s instanceof Error?s.message:d})}finally{T(!1),v(!1)}},[i,l,d]);o(()=>{S()},[S]);let w=c&&m?t.differs(c,m):!1;return{settings:c,modelList:N,loading:p,refreshing:M,saving:h,notice:k,dirty:w,load:S,save:async(u)=>{if(u?.preventDefault(),!c||h||p)return;x(!0),a(null);try{let s=await i.request(l,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.toBody(c))});b(s),f(s),a({type:"success",text:"设置已保存"})}catch(s){a({type:"error",text:s instanceof Error?s.message:"保存设置失败"})}finally{x(!1)}},reset:()=>{f(m),a(null)},edit:(u)=>{f((s)=>s?u(s):null),a(null)}}}
1
+ import{g,o,r,e,n,y,ne}from"./chunk-ngt1j8py.js";import{na}from"./chunk-918e5t4x.js";function Nn(t){let{Button:i,SettingActions:l,cn:d}=y();return n(l,{children:[t.notice&&n("span",{role:t.notice.type==="error"?"alert":"status",className:d("mr-auto flex min-w-0 items-center gap-1.5 text-xs",t.notice.type==="success"?"text-success":"text-danger"),children:[t.notice.type==="success"?e(na,{className:"size-3.5 shrink-0"}):e(ne,{className:"size-3.5 shrink-0"}),e("span",{className:"min-w-0 break-words",children:t.notice.text})]}),t.dirty&&e(i,{type:"button",variant:"ghost",size:"sm",disabled:t.busy,onClick:t.onReset,children:"撤销更改"}),e(i,{form:t.formID,type:"submit",variant:"primary",size:"sm",disabled:t.busy||!t.dirty,children:t.saving?"保存中…":"保存"})]})}function ta(t){let{connection:i,endpoint:l,loadError:d}=t,[m,b]=r(null),[c,f]=r(null),[N,P]=r({models:[]}),[p,T]=r(!0),[M,v]=r(!1),[h,x]=r(!1),[k,a]=r(null),S=g(async(u=!1)=>{if(u)v(!0);else T(!0);a(null);try{let[s,C]=await Promise.all([i.request(l),i.request("/api/models")]);b(s),f(s),P(C)}catch(s){a({type:"error",text:s instanceof Error?s.message:d})}finally{T(!1),v(!1)}},[i,l,d]);o(()=>{S()},[S]);let w=c&&m?t.differs(c,m):!1;return{settings:c,modelList:N,loading:p,refreshing:M,saving:h,notice:k,dirty:w,load:S,save:async(u)=>{if(u?.preventDefault(),!c||h||p)return;x(!0),a(null);try{let s=await i.request(l,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.toBody(c))});b(s),f(s),a({type:"success",text:"设置已保存"})}catch(s){a({type:"error",text:s instanceof Error?s.message:"保存设置失败"})}finally{x(!1)}},reset:()=>{f(m),a(null)},edit:(u)=>{f((s)=>s?u(s):null),a(null)}}}
2
2
  export{Nn,ta};
@@ -1,4 +1,4 @@
1
- import{t,a,ke,N,x,O,F,C,S,E,T,A,L,R,Vn,V,U,Ki}from"./chunk-veam6vk4.js";import"./chunk-9yfftz38.js";import{Xe}from"./chunk-07agqp8h.js";import{kt}from"./chunk-vsjpnwsr.js";import{Ot}from"./chunk-h0c42zy3.js";function Pt(e,i,s){e=+e,i=+i,s=(o=arguments.length)<2?(i=e,e=0,1):o<3?1:+s;var n=-1,o=Math.max(0,Math.ceil((i-e)/s))|0,c=Array(o);while(++n<o)c[n]=e+n*s;return c}function xt(){var e=Xe().unknown(void 0),{domain:i,range:s}=e,n=0,o=1,c,l,p=!1,g=0,y=0,I=0.5;delete e.unknown;function P(){var k=i().length,G=o<n,X=G?o:n,Y=G?n:o;if(c=(Y-X)/Math.max(1,k-g+y*2),p)c=Math.floor(c);if(X+=(Y-X-c*(k-g))*I,l=c*(1-g),p)X=Math.round(X),l=Math.round(l);var j=Pt(k).map(function(it){return X+c*it});return s(G?j.reverse():j)}return e.domain=function(k){return arguments.length?(i(k),P()):i()},e.range=function(k){return arguments.length?([n,o]=k,n=+n,o=+o,P()):[n,o]},e.rangeRound=function(k){return[n,o]=k,n=+n,o=+o,p=!0,P()},e.bandwidth=function(){return l},e.step=function(){return c},e.round=function(k){return arguments.length?(p=!!k,P()):p},e.padding=function(k){return arguments.length?(g=Math.min(1,y=+k),P()):g},e.paddingInner=function(k){return arguments.length?(g=Math.min(1,k),P()):g},e.paddingOuter=function(k){return arguments.length?(y=+k,P()):y},e.align=function(k){return arguments.length?(I=Math.max(0,Math.min(1,k)),P()):I},e.copy=function(){return xt(i(),[n,o]).round(p).paddingInner(g).paddingOuter(y).align(I)},Ot.apply(P(),arguments)}var Lt=function(){var e=t(function(J,h,u,f){for(u=u||{},f=J.length;f--;u[J[f]]=h);return u},"o"),i=[1,10,12,14,16,18,19,21,23],s=[2,6],n=[1,3],o=[1,5],c=[1,6],l=[1,7],p=[1,5,10,12,14,16,18,19,21,23,36,37,38],g=[1,25],y=[1,26],I=[1,28],P=[1,29],k=[1,30],G=[1,31],X=[1,32],Y=[1,33],j=[1,34],it=[1,35],nt=[1,36],_=[1,37],K=[1,43],d=[1,42],Q=[1,47],Z=[1,50],v=[1,10,12,14,16,18,19,21,23,36,37,38],ot=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],gt=[1,65],z=[26,28],D={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:t(function(h,u,f,m,M,r,rt){var b=r.length-1;switch(M){case 5:m.setOrientation(r[b]);break;case 9:m.setDiagramTitle(r[b].text.trim());break;case 12:m.setLineData({text:"",type:"text"},r[b]);break;case 13:m.setLineData(r[b-1],r[b]);break;case 14:m.setBarData({text:"",type:"text"},r[b]);break;case 15:m.setBarData(r[b-1],r[b]);break;case 16:this.$=r[b].trim(),m.setAccTitle(this.$);break;case 17:case 18:this.$=r[b].trim(),m.setAccDescription(this.$);break;case 19:this.$=r[b-1];break;case 20:case 30:this.$=[r[b-2],...r[b]];break;case 21:case 31:this.$=[r[b]];break;case 22:this.$={value:Number(r[b-1]),label:r[b]};break;case 23:this.$={value:Number(r[b]),label:""};break;case 24:m.setXAxisTitle(r[b]);break;case 25:m.setXAxisTitle(r[b-1]);break;case 26:m.setXAxisTitle({type:"text",text:""});break;case 27:m.setXAxisBand(r[b]);break;case 28:m.setXAxisRangeData(Number(r[b-2]),Number(r[b]));break;case 29:this.$=r[b-1];break;case 32:m.setYAxisTitle(r[b]);break;case 33:m.setYAxisTitle(r[b-1]);break;case 34:m.setYAxisTitle({type:"text",text:""});break;case 35:m.setYAxisRangeData(Number(r[b-2]),Number(r[b]));break;case 39:this.$={text:r[b],type:"text"};break;case 40:this.$={text:r[b],type:"text"};break;case 41:this.$={text:r[b],type:"markdown"};break;case 42:this.$=r[b];break;case 43:this.$=r[b-1]+""+r[b];break}},"anonymous"),table:[e(i,s,{3:1,4:2,7:4,5:n,36:o,37:c,38:l}),{1:[3]},e(i,s,{4:2,7:4,3:8,5:n,36:o,37:c,38:l}),e(i,s,{4:2,7:4,6:9,3:10,5:n,8:[1,11],36:o,37:c,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,36]),e(p,[2,37]),e(p,[2,38]),{1:[2,1]},e(i,s,{4:2,7:4,3:21,5:n,36:o,37:c,38:l}),{1:[2,3]},e(p,[2,5]),e(i,[2,7],{4:22,36:o,37:c,38:l}),{11:23,30:g,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:39,13:38,24:K,29:d,30:g,31:40,32:41,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:45,15:44,29:Q,30:g,35:46,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:49,17:48,24:Z,30:g,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:52,17:51,24:Z,30:g,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{20:[1,53]},{22:[1,54]},e(v,[2,18]),{1:[2,2]},e(v,[2,8]),e(v,[2,9]),e(ot,[2,39],{41:55,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_}),e(ot,[2,40]),e(ot,[2,41]),e(H,[2,42]),e(H,[2,44]),e(H,[2,45]),e(H,[2,46]),e(H,[2,47]),e(H,[2,48]),e(H,[2,49]),e(H,[2,50]),e(H,[2,51]),e(H,[2,52]),e(H,[2,53]),e(v,[2,10]),e(v,[2,24],{32:41,31:56,24:K,29:d}),e(v,[2,26]),e(v,[2,27]),{33:[1,57]},{11:59,30:g,34:58,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},e(v,[2,11]),e(v,[2,32],{35:60,29:Q}),e(v,[2,34]),{33:[1,61]},e(v,[2,12]),{17:62,24:Z},{25:63,27:64,29:gt},e(v,[2,14]),{17:66,24:Z},e(v,[2,16]),e(v,[2,17]),e(H,[2,43]),e(v,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(v,[2,33]),{29:[1,70]},e(v,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(z,[2,23],{30:[1,73]}),e(v,[2,15]),e(v,[2,28]),e(v,[2,29]),{11:59,30:g,34:74,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},e(v,[2,35]),e(v,[2,19]),{25:75,27:64,29:gt},e(z,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:t(function(h,u){if(u.recoverable)this.trace(h);else{var f=Error(h);throw f.hash=u,f}},"parseError"),parse:t(function(h){var u=this,f=[0],m=[],M=[null],r=[],rt=this.table,b="",bt=0,Ht=0,$t=0,fe=2,Ut=1,pe=r.slice.call(arguments,1),W=Object.create(this.lexer),ht={yy:{}};for(var Rt in this.yy)if(Object.prototype.hasOwnProperty.call(this.yy,Rt))ht.yy[Rt]=this.yy[Rt];if(W.setInput(h,ht.yy),ht.yy.lexer=W,ht.yy.parser=this,typeof W.yylloc>"u")W.yylloc={};var _t=W.yylloc;r.push(_t);var me=W.options&&W.options.ranges;if(typeof ht.yy.parseError==="function")this.parseError=ht.yy.parseError;else this.parseError=Object.getPrototypeOf(this).parseError;function be(et){f.length=f.length-2*et,M.length=M.length-et,r.length=r.length-et}t(be,"popStack");function qt(){var et=m.pop()||W.lex()||Ut;if(typeof et!=="number"){if(et instanceof Array)m=et,et=m.pop();et=u.symbols_[et]||et}return et}t(qt,"lex");var q,Tt,lt,tt,Oe,Dt,ut={},yt,at,Gt,wt;while(!0){if(lt=f[f.length-1],this.defaultActions[lt])tt=this.defaultActions[lt];else{if(q===null||typeof q>"u")q=qt();tt=rt[lt]&&rt[lt][q]}if(typeof tt>"u"||!tt.length||!tt[0]){var vt="";wt=[];for(yt in rt[lt])if(this.terminals_[yt]&&yt>fe)wt.push("'"+this.terminals_[yt]+"'");if(W.showPosition)vt="Parse error on line "+(bt+1)+`:
1
+ import{t,a,ke,N,x,O,F,C,S,E,T,A,L,R,Vn,V,U,Ki}from"./chunk-tfqarvdx.js";import"./chunk-9yfftz38.js";import{Xe}from"./chunk-07agqp8h.js";import{kt}from"./chunk-zz1qkaar.js";import{Ot}from"./chunk-h0c42zy3.js";function Pt(e,i,s){e=+e,i=+i,s=(o=arguments.length)<2?(i=e,e=0,1):o<3?1:+s;var n=-1,o=Math.max(0,Math.ceil((i-e)/s))|0,c=Array(o);while(++n<o)c[n]=e+n*s;return c}function xt(){var e=Xe().unknown(void 0),{domain:i,range:s}=e,n=0,o=1,c,l,p=!1,g=0,y=0,I=0.5;delete e.unknown;function P(){var k=i().length,G=o<n,X=G?o:n,Y=G?n:o;if(c=(Y-X)/Math.max(1,k-g+y*2),p)c=Math.floor(c);if(X+=(Y-X-c*(k-g))*I,l=c*(1-g),p)X=Math.round(X),l=Math.round(l);var j=Pt(k).map(function(it){return X+c*it});return s(G?j.reverse():j)}return e.domain=function(k){return arguments.length?(i(k),P()):i()},e.range=function(k){return arguments.length?([n,o]=k,n=+n,o=+o,P()):[n,o]},e.rangeRound=function(k){return[n,o]=k,n=+n,o=+o,p=!0,P()},e.bandwidth=function(){return l},e.step=function(){return c},e.round=function(k){return arguments.length?(p=!!k,P()):p},e.padding=function(k){return arguments.length?(g=Math.min(1,y=+k),P()):g},e.paddingInner=function(k){return arguments.length?(g=Math.min(1,k),P()):g},e.paddingOuter=function(k){return arguments.length?(y=+k,P()):y},e.align=function(k){return arguments.length?(I=Math.max(0,Math.min(1,k)),P()):I},e.copy=function(){return xt(i(),[n,o]).round(p).paddingInner(g).paddingOuter(y).align(I)},Ot.apply(P(),arguments)}var Lt=function(){var e=t(function(J,h,u,f){for(u=u||{},f=J.length;f--;u[J[f]]=h);return u},"o"),i=[1,10,12,14,16,18,19,21,23],s=[2,6],n=[1,3],o=[1,5],c=[1,6],l=[1,7],p=[1,5,10,12,14,16,18,19,21,23,36,37,38],g=[1,25],y=[1,26],I=[1,28],P=[1,29],k=[1,30],G=[1,31],X=[1,32],Y=[1,33],j=[1,34],it=[1,35],nt=[1,36],_=[1,37],K=[1,43],d=[1,42],Q=[1,47],Z=[1,50],v=[1,10,12,14,16,18,19,21,23,36,37,38],ot=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],gt=[1,65],z=[26,28],D={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:t(function(h,u,f,m,M,r,rt){var b=r.length-1;switch(M){case 5:m.setOrientation(r[b]);break;case 9:m.setDiagramTitle(r[b].text.trim());break;case 12:m.setLineData({text:"",type:"text"},r[b]);break;case 13:m.setLineData(r[b-1],r[b]);break;case 14:m.setBarData({text:"",type:"text"},r[b]);break;case 15:m.setBarData(r[b-1],r[b]);break;case 16:this.$=r[b].trim(),m.setAccTitle(this.$);break;case 17:case 18:this.$=r[b].trim(),m.setAccDescription(this.$);break;case 19:this.$=r[b-1];break;case 20:case 30:this.$=[r[b-2],...r[b]];break;case 21:case 31:this.$=[r[b]];break;case 22:this.$={value:Number(r[b-1]),label:r[b]};break;case 23:this.$={value:Number(r[b]),label:""};break;case 24:m.setXAxisTitle(r[b]);break;case 25:m.setXAxisTitle(r[b-1]);break;case 26:m.setXAxisTitle({type:"text",text:""});break;case 27:m.setXAxisBand(r[b]);break;case 28:m.setXAxisRangeData(Number(r[b-2]),Number(r[b]));break;case 29:this.$=r[b-1];break;case 32:m.setYAxisTitle(r[b]);break;case 33:m.setYAxisTitle(r[b-1]);break;case 34:m.setYAxisTitle({type:"text",text:""});break;case 35:m.setYAxisRangeData(Number(r[b-2]),Number(r[b]));break;case 39:this.$={text:r[b],type:"text"};break;case 40:this.$={text:r[b],type:"text"};break;case 41:this.$={text:r[b],type:"markdown"};break;case 42:this.$=r[b];break;case 43:this.$=r[b-1]+""+r[b];break}},"anonymous"),table:[e(i,s,{3:1,4:2,7:4,5:n,36:o,37:c,38:l}),{1:[3]},e(i,s,{4:2,7:4,3:8,5:n,36:o,37:c,38:l}),e(i,s,{4:2,7:4,6:9,3:10,5:n,8:[1,11],36:o,37:c,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,36]),e(p,[2,37]),e(p,[2,38]),{1:[2,1]},e(i,s,{4:2,7:4,3:21,5:n,36:o,37:c,38:l}),{1:[2,3]},e(p,[2,5]),e(i,[2,7],{4:22,36:o,37:c,38:l}),{11:23,30:g,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:39,13:38,24:K,29:d,30:g,31:40,32:41,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:45,15:44,29:Q,30:g,35:46,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:49,17:48,24:Z,30:g,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{11:52,17:51,24:Z,30:g,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},{20:[1,53]},{22:[1,54]},e(v,[2,18]),{1:[2,2]},e(v,[2,8]),e(v,[2,9]),e(ot,[2,39],{41:55,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_}),e(ot,[2,40]),e(ot,[2,41]),e(H,[2,42]),e(H,[2,44]),e(H,[2,45]),e(H,[2,46]),e(H,[2,47]),e(H,[2,48]),e(H,[2,49]),e(H,[2,50]),e(H,[2,51]),e(H,[2,52]),e(H,[2,53]),e(v,[2,10]),e(v,[2,24],{32:41,31:56,24:K,29:d}),e(v,[2,26]),e(v,[2,27]),{33:[1,57]},{11:59,30:g,34:58,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},e(v,[2,11]),e(v,[2,32],{35:60,29:Q}),e(v,[2,34]),{33:[1,61]},e(v,[2,12]),{17:62,24:Z},{25:63,27:64,29:gt},e(v,[2,14]),{17:66,24:Z},e(v,[2,16]),e(v,[2,17]),e(H,[2,43]),e(v,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(v,[2,33]),{29:[1,70]},e(v,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(z,[2,23],{30:[1,73]}),e(v,[2,15]),e(v,[2,28]),e(v,[2,29]),{11:59,30:g,34:74,39:24,40:y,41:27,42:I,43:P,44:k,45:G,46:X,47:Y,48:j,49:it,50:nt,51:_},e(v,[2,35]),e(v,[2,19]),{25:75,27:64,29:gt},e(z,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:t(function(h,u){if(u.recoverable)this.trace(h);else{var f=Error(h);throw f.hash=u,f}},"parseError"),parse:t(function(h){var u=this,f=[0],m=[],M=[null],r=[],rt=this.table,b="",bt=0,Ht=0,$t=0,fe=2,Ut=1,pe=r.slice.call(arguments,1),W=Object.create(this.lexer),ht={yy:{}};for(var Rt in this.yy)if(Object.prototype.hasOwnProperty.call(this.yy,Rt))ht.yy[Rt]=this.yy[Rt];if(W.setInput(h,ht.yy),ht.yy.lexer=W,ht.yy.parser=this,typeof W.yylloc>"u")W.yylloc={};var _t=W.yylloc;r.push(_t);var me=W.options&&W.options.ranges;if(typeof ht.yy.parseError==="function")this.parseError=ht.yy.parseError;else this.parseError=Object.getPrototypeOf(this).parseError;function be(et){f.length=f.length-2*et,M.length=M.length-et,r.length=r.length-et}t(be,"popStack");function qt(){var et=m.pop()||W.lex()||Ut;if(typeof et!=="number"){if(et instanceof Array)m=et,et=m.pop();et=u.symbols_[et]||et}return et}t(qt,"lex");var q,Tt,lt,tt,Oe,Dt,ut={},yt,at,Gt,wt;while(!0){if(lt=f[f.length-1],this.defaultActions[lt])tt=this.defaultActions[lt];else{if(q===null||typeof q>"u")q=qt();tt=rt[lt]&&rt[lt][q]}if(typeof tt>"u"||!tt.length||!tt[0]){var vt="";wt=[];for(yt in rt[lt])if(this.terminals_[yt]&&yt>fe)wt.push("'"+this.terminals_[yt]+"'");if(W.showPosition)vt="Parse error on line "+(bt+1)+`:
2
2
  `+W.showPosition()+`
3
3
  Expecting `+wt.join(", ")+", got '"+(this.terminals_[q]||q)+"'";else vt="Parse error on line "+(bt+1)+": Unexpected "+(q==Ut?"end of input":"'"+(this.terminals_[q]||q)+"'");this.parseError(vt,{text:W.match,token:this.terminals_[q]||q,line:W.yylineno,loc:_t,expected:wt})}if(tt[0]instanceof Array&&tt.length>1)throw Error("Parse Error: multiple actions possible at state: "+lt+", token: "+q);switch(tt[0]){case 1:if(f.push(q),M.push(W.yytext),r.push(W.yylloc),f.push(tt[1]),q=null,!Tt){if(Ht=W.yyleng,b=W.yytext,bt=W.yylineno,_t=W.yylloc,$t>0)$t--}else q=Tt,Tt=null;break;case 2:if(at=this.productions_[tt[1]][1],ut.$=M[M.length-at],ut._$={first_line:r[r.length-(at||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(at||1)].first_column,last_column:r[r.length-1].last_column},me)ut._$.range=[r[r.length-(at||1)].range[0],r[r.length-1].range[1]];if(Dt=this.performAction.apply(ut,[b,Ht,bt,ht.yy,tt[1],M,r].concat(pe)),typeof Dt<"u")return Dt;if(at)f=f.slice(0,-1*at*2),M=M.slice(0,-1*at),r=r.slice(0,-1*at);f.push(this.productions_[tt[1]][0]),M.push(ut.$),r.push(ut._$),Gt=rt[f[f.length-2]][f[f.length-1]],f.push(Gt);break;case 3:return!0}}return!0},"parse")},st=function(){var J={EOF:1,parseError:t(function(u,f){if(this.yy.parser)this.yy.parser.parseError(u,f);else throw Error(u)},"parseError"),setInput:t(function(h,u){if(this.yy=u||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges)this.yylloc.range=[0,0];return this.offset=0,this},"setInput"),input:t(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var u=h.match(/(?:\r\n?|\n).*/g);if(u)this.yylineno++,this.yylloc.last_line++;else this.yylloc.last_column++;if(this.options.ranges)this.yylloc.range[1]++;return this._input=this._input.slice(1),h},"input"),unput:t(function(h){var u=h.length,f=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var m=this.match.split(/(?:\r\n?|\n)/g);if(this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),f.length-1)this.yylineno-=f.length-1;var M=this.yylloc.range;if(this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:f?(f.length===m.length?this.yylloc.first_column:0)+m[m.length-f.length].length-f[0].length:this.yylloc.first_column-u},this.options.ranges)this.yylloc.range=[M[0],M[0]+this.yyleng-u];return this.yyleng=this.yytext.length,this},"unput"),more:t(function(){return this._more=!0,this},"more"),reject:t(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:t(function(h){this.unput(this.match.slice(h))},"less"),pastInput:t(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:t(function(){var h=this.match;if(h.length<20)h+=this._input.substr(0,20-h.length);return(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:t(function(){var h=this.pastInput(),u=Array(h.length+1).join("-");return h+this.upcomingInput()+`
@@ -1,4 +1,4 @@
1
- import{fn}from"./chunk-t893141g.js";import{G}from"./chunk-dwjmr0zj.js";import{t,a,N,x,b,C,S,E,T,A,L,R,l,kr,p,Zi,U,M}from"./chunk-veam6vk4.js";import{J}from"./chunk-60axh4sa.js";var v={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},Ce=N.gitGraph,X=t(()=>U({...Ce,...x().gitGraph}),"getConfig"),m=new fn(()=>{let e=X(),{mainBranchName:r,mainBranchOrder:o}=e;return{mainBranchName:r,commits:new Map,head:null,branchConfig:new Map([[r,{name:r,order:o}]]),branches:new Map([[r,null]]),currBranch:r,direction:"LR",seq:0,options:{}}});function ne(){return Zi({length:7})}t(ne,"getID");function pe(e,r){let o=Object.create(null);return e.reduce((c,i)=>{let h=r(i);if(!o[h])o[h]=!0,c.push(i);return c},[])}t(pe,"uniqBy");var ve=t(function(e){m.records.direction=e},"setDirection"),Ee=t(function(e){a.debug("options str",e),e=e?.trim(),e=e||"{}";try{m.records.options=JSON.parse(e)}catch(r){a.error("error while parsing gitGraph options",r.message)}},"setOptions"),Te=t(function(){return m.records.options},"getOptions"),Le=t(function(e){let{msg:r,id:o,type:c,tags:i}=e;a.info("commit",r,o,c,i),a.debug("Entering commit:",r,o,c,i);let h=X();o=b.sanitizeText(o,h),r=b.sanitizeText(r,h),i=i?.map((s)=>b.sanitizeText(s,h));let n={id:o?o:m.records.seq+"-"+ne(),message:r,seq:m.records.seq++,type:c??v.NORMAL,tags:i??[],parents:m.records.head==null?[]:[m.records.head.id],branch:m.records.currBranch};if(m.records.head=n,a.info("main branch",h.mainBranchName),m.records.commits.has(n.id))a.warn(`Commit ID ${n.id} already exists`);m.records.commits.set(n.id,n),m.records.branches.set(m.records.currBranch,n.id),a.debug("in pushCommit "+n.id)},"commit"),Me=t(function(e){let{name:r,order:o}=e;if(r=b.sanitizeText(r,X()),m.records.branches.has(r))throw Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${r}")`);m.records.branches.set(r,m.records.head!=null?m.records.head.id:null),m.records.branchConfig.set(r,{name:r,order:o}),ye(r),a.debug("in createBranch")},"branch"),Pe=t((e)=>{let{branch:r,id:o,type:c,tags:i}=e,h=X();if(r=b.sanitizeText(r,h),o)o=b.sanitizeText(o,h);let n=m.records.branches.get(m.records.currBranch),s=m.records.branches.get(r),g=n?m.records.commits.get(n):void 0,y=s?m.records.commits.get(s):void 0;if(g&&y&&g.branch===r)throw Error(`Cannot merge branch '${r}' into itself.`);if(m.records.currBranch===r){let d=Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},d}if(g===void 0||!g){let d=Error(`Incorrect usage of "merge". Current branch (${m.records.currBranch})has no commits`);throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["commit"]},d}if(!m.records.branches.has(r)){let d=Error('Incorrect usage of "merge". Branch to be merged ('+r+") does not exist");throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:[`branch ${r}`]},d}if(y===void 0||!y){let d=Error('Incorrect usage of "merge". Branch to be merged ('+r+") has no commits");throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:['"commit"']},d}if(g===y){let d=Error('Incorrect usage of "merge". Both branches have same head');throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},d}if(o&&m.records.commits.has(o)){let d=Error('Incorrect usage of "merge". Commit with id:'+o+" already exists, use different custom id");throw d.hash={text:`merge ${r} ${o} ${c} ${i?.join(" ")}`,token:`merge ${r} ${o} ${c} ${i?.join(" ")}`,expected:[`merge ${r} ${o}_UNIQUE ${c} ${i?.join(" ")}`]},d}let u=s?s:"",f={id:o||`${m.records.seq}-${ne()}`,message:`merged branch ${r} into ${m.records.currBranch}`,seq:m.records.seq++,parents:m.records.head==null?[]:[m.records.head.id,u],branch:m.records.currBranch,type:v.MERGE,customType:c,customId:o?!0:!1,tags:i??[]};m.records.head=f,m.records.commits.set(f.id,f),m.records.branches.set(m.records.currBranch,f.id),a.debug(m.records.branches),a.debug("in mergeBranch")},"merge"),Re=t(function(e){let{id:r,targetId:o,tags:c,parent:i}=e;a.debug("Entering cherryPick:",r,o,c);let h=X();if(r=b.sanitizeText(r,h),o=b.sanitizeText(o,h),c=c?.map((g)=>b.sanitizeText(g,h)),i=b.sanitizeText(i,h),!r||!m.records.commits.has(r)){let g=Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw g.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},g}let n=m.records.commits.get(r);if(n===void 0||!n)throw Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(i&&!(Array.isArray(n.parents)&&n.parents.includes(i)))throw Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");let s=n.branch;if(n.type===v.MERGE&&!i)throw Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!o||!m.records.commits.has(o)){if(s===m.records.currBranch){let f=Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw f.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},f}let g=m.records.branches.get(m.records.currBranch);if(g===void 0||!g){let f=Error(`Incorrect usage of "cherry-pick". Current branch (${m.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},f}let y=m.records.commits.get(g);if(y===void 0||!y){let f=Error(`Incorrect usage of "cherry-pick". Current branch (${m.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},f}let u={id:m.records.seq+"-"+ne(),message:`cherry-picked ${n?.message} into ${m.records.currBranch}`,seq:m.records.seq++,parents:m.records.head==null?[]:[m.records.head.id,n.id],branch:m.records.currBranch,type:v.CHERRY_PICK,tags:c?c.filter(Boolean):[`cherry-pick:${n.id}${n.type===v.MERGE?`|parent:${i}`:""}`]};m.records.head=u,m.records.commits.set(u.id,u),m.records.branches.set(m.records.currBranch,u.id),a.debug(m.records.branches),a.debug("in cherryPick")}},"cherryPick"),ye=t(function(e){if(e=b.sanitizeText(e,X()),!m.records.branches.has(e)){let r=Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw r.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},r}else{m.records.currBranch=e;let r=m.records.branches.get(m.records.currBranch);if(r===void 0||!r)m.records.head=null;else m.records.head=m.records.commits.get(r)??null}},"checkout");function he(e,r,o){let c=e.indexOf(r);if(c===-1)e.push(o);else e.splice(c,1,o)}t(he,"upsert");function me(e){let r=e.reduce((i,h)=>{if(i.seq>h.seq)return i;return h},e[0]),o="";e.forEach(function(i){if(i===r)o+="\t*";else o+="\t|"});let c=[o,r.id,r.seq];for(let i in m.records.branches)if(m.records.branches.get(i)===r.id)c.push(i);if(a.debug(c.join(" ")),r.parents&&r.parents.length==2&&r.parents[0]&&r.parents[1]){let i=m.records.commits.get(r.parents[0]);if(he(e,r,i),r.parents[1])e.push(m.records.commits.get(r.parents[1]))}else if(r.parents.length==0)return;else if(r.parents[0]){let i=m.records.commits.get(r.parents[0]);he(e,r,i)}e=pe(e,(i)=>i.id),me(e)}t(me,"prettyPrintCommitHistory");var Oe=t(function(){a.debug(m.records.commits);let e=xe()[0];me([e])},"prettyPrint"),Ie=t(function(){m.reset(),C()},"clear"),_e=t(function(){return[...m.records.branchConfig.values()].map((r,o)=>{if(r.order!==null&&r.order!==void 0)return r;return{...r,order:parseFloat(`0.${o}`)}}).sort((r,o)=>(r.order??0)-(o.order??0)).map(({name:r})=>({name:r}))},"getBranchesAsObjArray"),Ge=t(function(){return m.records.branches},"getBranches"),De=t(function(){return m.records.commits},"getCommits"),xe=t(function(){let e=[...m.records.commits.values()];return e.forEach(function(r){a.debug(r.id)}),e.sort((r,o)=>r.seq-o.seq),e},"getCommitsArray"),We=t(function(){return m.records.currBranch},"getCurrentBranch"),qe=t(function(){return m.records.direction},"getDirection"),Ae=t(function(){return m.records.head},"getHead"),ue={commitType:v,getConfig:X,setDirection:ve,setOptions:Ee,getOptions:Te,commit:Le,branch:Me,merge:Pe,cherryPick:Re,checkout:ye,prettyPrint:Oe,clear:Ie,getBranchesAsObjArray:_e,getBranches:Ge,getCommits:De,getCommitsArray:xe,getCurrentBranch:We,getDirection:qe,getHead:Ae,setAccTitle:S,getAccTitle:E,getAccDescription:A,setAccDescription:T,setDiagramTitle:L,getDiagramTitle:R},He=t((e,r)=>{if(G(e,r),e.dir)r.setDirection(e.dir);for(let o of e.statements)Se(o,r)},"populate"),Se=t((e,r)=>{let c={Commit:t((i)=>r.commit(Ne(i)),"Commit"),Branch:t((i)=>r.branch(Fe(i)),"Branch"),Merge:t((i)=>r.merge(ze(i)),"Merge"),Checkout:t((i)=>r.checkout(Ye(i)),"Checkout"),CherryPicking:t((i)=>r.cherryPick(je(i)),"CherryPicking")}[e.$type];if(c)c(e);else a.error(`Unknown statement type: ${e.$type}`)},"parseStatement"),Ne=t((e)=>({id:e.id,msg:e.message??"",type:e.type!==void 0?v[e.type]:v.NORMAL,tags:e.tags??void 0}),"parseCommit"),Fe=t((e)=>({name:e.name,order:e.order??0}),"parseBranch"),ze=t((e)=>({branch:e.branch,id:e.id??"",type:e.type!==void 0?v[e.type]:void 0,tags:e.tags??void 0}),"parseMerge"),Ye=t((e)=>e.branch,"parseCheckout"),je=t((e)=>({id:e.id,targetId:"",tags:e.tags?.length===0?void 0:e.tags,parent:e.parent}),"parseCherryPicking"),Ke={parse:t(async(e)=>{let r=await J("gitGraph",e);a.debug(r),He(r,ue)},"parse")},j=10,K=40,H=4,z=2,V=8,ce=new Set(["redux","redux-dark","redux-color","redux-dark-color"]),le=12,ge=new Set(["redux-color","redux-dark-color"]),Ue=new Set(["dark","redux-dark","redux-dark-color","neo-dark"]),Z=t((e,r,o=!1)=>{if(o&&e>0)return(e-1)%(r-1)+1;return e%r},"calcColorIndex"),D=new Map,W=new Map,oe=30,te=new Map,se=[],Y=0,B="LR",Ve=t(()=>{D.clear(),W.clear(),te.clear(),Y=0,se=[],B="LR"},"clear"),be=t((e)=>{let r=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof e==="string"?e.split(/\\n|\n|<br\s*\/?>/gi):e).forEach((c)=>{let i=document.createElementNS("http://www.w3.org/2000/svg","tspan");i.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),i.setAttribute("dy","1em"),i.setAttribute("x","0"),i.setAttribute("class","row"),i.textContent=c.trim(),r.appendChild(i)}),r},"drawText"),we=t((e)=>{let r,o,c;if(B==="BT")o=t((i,h)=>i<=h,"comparisonFunc"),c=1/0;else o=t((i,h)=>i>=h,"comparisonFunc"),c=0;return e.forEach((i)=>{let h=B==="TB"||B=="BT"?W.get(i)?.y:W.get(i)?.x;if(h!==void 0&&o(h,c))r=i,c=h}),r},"findClosestParent"),Ze=t((e)=>{let r="",o=1/0;return e.forEach((c)=>{let i=W.get(c).y;if(i<=o)r=c,o=i}),r||void 0},"findClosestParentBT"),Xe=t((e,r,o)=>{let c=o,i=o,h=[];e.forEach((n)=>{let s=r.get(n);if(!s)throw Error(`Commit not found for key ${n}`);if(s.parents.length)c=Qe(s),i=Math.max(c,i);else h.push(s);et(s,c)}),c=i,h.forEach((n)=>{tt(n,c,o)}),e.forEach((n)=>{let s=r.get(n);if(s?.parents.length){let g=Ze(s.parents);if(c=W.get(g).y-K,c<=i)i=c;let y=D.get(s.branch).pos,u=c-j;W.set(s.id,{x:y,y:u})}})},"setParallelBTPos"),Je=t((e)=>{let r=we(e.parents.filter((c)=>c!==null));if(!r)throw Error(`Closest parent not found for commit ${e.id}`);let o=W.get(r)?.y;if(o===void 0)throw Error(`Closest parent position not found for commit ${e.id}`);return o},"findClosestParentPos"),Qe=t((e)=>Je(e)+K,"calculateCommitPosition"),et=t((e,r)=>{let o=D.get(e.branch);if(!o)throw Error(`Branch not found for commit ${e.id}`);let c=o.pos,i=r+j;return W.set(e.id,{x:c,y:i}),{x:c,y:i}},"setCommitPosition"),tt=t((e,r,o)=>{let c=D.get(e.branch);if(!c)throw Error(`Branch not found for commit ${e.id}`);let i=r+o,h=c.pos;W.set(e.id,{x:h,y:i})},"setRootPosition"),rt=t((e,r,o,c,i,h)=>{let{theme:n}=l(),s=ce.has(n??""),g=ge.has(n??""),y=Ue.has(n??"");if(h===v.HIGHLIGHT)e.append("rect").attr("x",o.x-10+(s?3:0)).attr("y",o.y-10+(s?3:0)).attr("width",s?14:20).attr("height",s?14:20).attr("class",`commit ${r.id} commit-highlight${Z(i,V,g)} ${c}-outer`),e.append("rect").attr("x",o.x-6+(s?2:0)).attr("y",o.y-6+(s?2:0)).attr("width",s?8:12).attr("height",s?8:12).attr("class",`commit ${r.id} commit${Z(i,V,g)} ${c}-inner`);else if(h===v.CHERRY_PICK)e.append("circle").attr("cx",o.x).attr("cy",o.y).attr("r",s?7:10).attr("class",`commit ${r.id} ${c}`),e.append("circle").attr("cx",o.x-3).attr("cy",o.y+2).attr("r",s?2.5:2.75).attr("fill",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`),e.append("circle").attr("cx",o.x+3).attr("cy",o.y+2).attr("r",s?2.5:2.75).attr("fill",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`),e.append("line").attr("x1",o.x+3).attr("y1",o.y+1).attr("x2",o.x).attr("y2",o.y-5).attr("stroke",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`),e.append("line").attr("x1",o.x-3).attr("y1",o.y+1).attr("x2",o.x).attr("y2",o.y-5).attr("stroke",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`);else{let u=e.append("circle");if(u.attr("cx",o.x),u.attr("cy",o.y),u.attr("r",s?7:10),u.attr("class",`commit ${r.id} commit${Z(i,V,g)}`),h===v.MERGE){let f=e.append("circle");f.attr("cx",o.x),f.attr("cy",o.y),f.attr("r",s?5:6),f.attr("class",`commit ${c} ${r.id} commit${Z(i,V,g)}`)}if(h===v.REVERSE){let f=e.append("path"),d=s?4:5;f.attr("d",`M ${o.x-d},${o.y-d}L${o.x+d},${o.y+d}M${o.x-d},${o.y+d}L${o.x+d},${o.y-d}`).attr("class",`commit ${c} ${r.id} commit${Z(i,V,g)}`)}}},"drawCommitBullet"),at=t((e,r,o,c,i)=>{if(r.type!==v.CHERRY_PICK&&(r.customId&&r.type===v.MERGE||r.type!==v.MERGE)&&i.showCommitLabel){let h=e.append("g"),n=h.insert("rect").attr("class","commit-label-bkg"),s=h.append("text").attr("x",c).attr("y",o.y+25).attr("class","commit-label").text(r.id),g=s.node()?.getBBox();if(g){if(n.attr("x",o.posWithOffset-g.width/2-z).attr("y",o.y+13.5).attr("width",g.width+2*z).attr("height",g.height+2*z),B==="TB"||B==="BT")n.attr("x",o.x-(g.width+4*H+5)).attr("y",o.y-12),s.attr("x",o.x-(g.width+4*H)).attr("y",o.y+g.height-12);else s.attr("x",o.posWithOffset-g.width/2);if(i.rotateCommitLabel)if(B==="TB"||B==="BT")s.attr("transform","rotate(-45, "+o.x+", "+o.y+")"),n.attr("transform","rotate(-45, "+o.x+", "+o.y+")");else{let y=-7.5-(g.width+10)/25*9.5,u=10+g.width/25*8.5;h.attr("transform","translate("+y+", "+u+") rotate(-45, "+c+", "+o.y+")")}}}},"drawCommitLabel"),ot=t((e,r,o,c)=>{if(r.tags.length>0){let i=0,h=0,n=0,s=[];for(let g of r.tags.reverse()){let y=e.insert("polygon"),u=e.append("circle"),f=e.append("text").attr("y",o.y-16-i).attr("class","tag-label").text(g),d=f.node()?.getBBox();if(!d)throw Error("Tag bbox not found");h=Math.max(h,d.width),n=Math.max(n,d.height),f.attr("x",o.posWithOffset-d.width/2),s.push({tag:f,hole:u,rect:y,yOffset:i}),i+=20}for(let{tag:g,hole:y,rect:u,yOffset:f}of s){let d=n/2,k=o.y-19.2-f;if(u.attr("class","tag-label-bkg").attr("points",`
1
+ import{fn}from"./chunk-g7dc4hrd.js";import{G}from"./chunk-eh7wp62z.js";import{t,a,N,x,b,C,S,E,T,A,L,R,l,kr,p,Zi,U,M}from"./chunk-tfqarvdx.js";import{J}from"./chunk-qy1zx2yw.js";var v={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},Ce=N.gitGraph,X=t(()=>U({...Ce,...x().gitGraph}),"getConfig"),m=new fn(()=>{let e=X(),{mainBranchName:r,mainBranchOrder:o}=e;return{mainBranchName:r,commits:new Map,head:null,branchConfig:new Map([[r,{name:r,order:o}]]),branches:new Map([[r,null]]),currBranch:r,direction:"LR",seq:0,options:{}}});function ne(){return Zi({length:7})}t(ne,"getID");function pe(e,r){let o=Object.create(null);return e.reduce((c,i)=>{let h=r(i);if(!o[h])o[h]=!0,c.push(i);return c},[])}t(pe,"uniqBy");var ve=t(function(e){m.records.direction=e},"setDirection"),Ee=t(function(e){a.debug("options str",e),e=e?.trim(),e=e||"{}";try{m.records.options=JSON.parse(e)}catch(r){a.error("error while parsing gitGraph options",r.message)}},"setOptions"),Te=t(function(){return m.records.options},"getOptions"),Le=t(function(e){let{msg:r,id:o,type:c,tags:i}=e;a.info("commit",r,o,c,i),a.debug("Entering commit:",r,o,c,i);let h=X();o=b.sanitizeText(o,h),r=b.sanitizeText(r,h),i=i?.map((s)=>b.sanitizeText(s,h));let n={id:o?o:m.records.seq+"-"+ne(),message:r,seq:m.records.seq++,type:c??v.NORMAL,tags:i??[],parents:m.records.head==null?[]:[m.records.head.id],branch:m.records.currBranch};if(m.records.head=n,a.info("main branch",h.mainBranchName),m.records.commits.has(n.id))a.warn(`Commit ID ${n.id} already exists`);m.records.commits.set(n.id,n),m.records.branches.set(m.records.currBranch,n.id),a.debug("in pushCommit "+n.id)},"commit"),Me=t(function(e){let{name:r,order:o}=e;if(r=b.sanitizeText(r,X()),m.records.branches.has(r))throw Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${r}")`);m.records.branches.set(r,m.records.head!=null?m.records.head.id:null),m.records.branchConfig.set(r,{name:r,order:o}),ye(r),a.debug("in createBranch")},"branch"),Pe=t((e)=>{let{branch:r,id:o,type:c,tags:i}=e,h=X();if(r=b.sanitizeText(r,h),o)o=b.sanitizeText(o,h);let n=m.records.branches.get(m.records.currBranch),s=m.records.branches.get(r),g=n?m.records.commits.get(n):void 0,y=s?m.records.commits.get(s):void 0;if(g&&y&&g.branch===r)throw Error(`Cannot merge branch '${r}' into itself.`);if(m.records.currBranch===r){let d=Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},d}if(g===void 0||!g){let d=Error(`Incorrect usage of "merge". Current branch (${m.records.currBranch})has no commits`);throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["commit"]},d}if(!m.records.branches.has(r)){let d=Error('Incorrect usage of "merge". Branch to be merged ('+r+") does not exist");throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:[`branch ${r}`]},d}if(y===void 0||!y){let d=Error('Incorrect usage of "merge". Branch to be merged ('+r+") has no commits");throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:['"commit"']},d}if(g===y){let d=Error('Incorrect usage of "merge". Both branches have same head');throw d.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},d}if(o&&m.records.commits.has(o)){let d=Error('Incorrect usage of "merge". Commit with id:'+o+" already exists, use different custom id");throw d.hash={text:`merge ${r} ${o} ${c} ${i?.join(" ")}`,token:`merge ${r} ${o} ${c} ${i?.join(" ")}`,expected:[`merge ${r} ${o}_UNIQUE ${c} ${i?.join(" ")}`]},d}let u=s?s:"",f={id:o||`${m.records.seq}-${ne()}`,message:`merged branch ${r} into ${m.records.currBranch}`,seq:m.records.seq++,parents:m.records.head==null?[]:[m.records.head.id,u],branch:m.records.currBranch,type:v.MERGE,customType:c,customId:o?!0:!1,tags:i??[]};m.records.head=f,m.records.commits.set(f.id,f),m.records.branches.set(m.records.currBranch,f.id),a.debug(m.records.branches),a.debug("in mergeBranch")},"merge"),Re=t(function(e){let{id:r,targetId:o,tags:c,parent:i}=e;a.debug("Entering cherryPick:",r,o,c);let h=X();if(r=b.sanitizeText(r,h),o=b.sanitizeText(o,h),c=c?.map((g)=>b.sanitizeText(g,h)),i=b.sanitizeText(i,h),!r||!m.records.commits.has(r)){let g=Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw g.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},g}let n=m.records.commits.get(r);if(n===void 0||!n)throw Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(i&&!(Array.isArray(n.parents)&&n.parents.includes(i)))throw Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");let s=n.branch;if(n.type===v.MERGE&&!i)throw Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!o||!m.records.commits.has(o)){if(s===m.records.currBranch){let f=Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw f.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},f}let g=m.records.branches.get(m.records.currBranch);if(g===void 0||!g){let f=Error(`Incorrect usage of "cherry-pick". Current branch (${m.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},f}let y=m.records.commits.get(g);if(y===void 0||!y){let f=Error(`Incorrect usage of "cherry-pick". Current branch (${m.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${o}`,token:`cherryPick ${r} ${o}`,expected:["cherry-pick abc"]},f}let u={id:m.records.seq+"-"+ne(),message:`cherry-picked ${n?.message} into ${m.records.currBranch}`,seq:m.records.seq++,parents:m.records.head==null?[]:[m.records.head.id,n.id],branch:m.records.currBranch,type:v.CHERRY_PICK,tags:c?c.filter(Boolean):[`cherry-pick:${n.id}${n.type===v.MERGE?`|parent:${i}`:""}`]};m.records.head=u,m.records.commits.set(u.id,u),m.records.branches.set(m.records.currBranch,u.id),a.debug(m.records.branches),a.debug("in cherryPick")}},"cherryPick"),ye=t(function(e){if(e=b.sanitizeText(e,X()),!m.records.branches.has(e)){let r=Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw r.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},r}else{m.records.currBranch=e;let r=m.records.branches.get(m.records.currBranch);if(r===void 0||!r)m.records.head=null;else m.records.head=m.records.commits.get(r)??null}},"checkout");function he(e,r,o){let c=e.indexOf(r);if(c===-1)e.push(o);else e.splice(c,1,o)}t(he,"upsert");function me(e){let r=e.reduce((i,h)=>{if(i.seq>h.seq)return i;return h},e[0]),o="";e.forEach(function(i){if(i===r)o+="\t*";else o+="\t|"});let c=[o,r.id,r.seq];for(let i in m.records.branches)if(m.records.branches.get(i)===r.id)c.push(i);if(a.debug(c.join(" ")),r.parents&&r.parents.length==2&&r.parents[0]&&r.parents[1]){let i=m.records.commits.get(r.parents[0]);if(he(e,r,i),r.parents[1])e.push(m.records.commits.get(r.parents[1]))}else if(r.parents.length==0)return;else if(r.parents[0]){let i=m.records.commits.get(r.parents[0]);he(e,r,i)}e=pe(e,(i)=>i.id),me(e)}t(me,"prettyPrintCommitHistory");var Oe=t(function(){a.debug(m.records.commits);let e=xe()[0];me([e])},"prettyPrint"),Ie=t(function(){m.reset(),C()},"clear"),_e=t(function(){return[...m.records.branchConfig.values()].map((r,o)=>{if(r.order!==null&&r.order!==void 0)return r;return{...r,order:parseFloat(`0.${o}`)}}).sort((r,o)=>(r.order??0)-(o.order??0)).map(({name:r})=>({name:r}))},"getBranchesAsObjArray"),Ge=t(function(){return m.records.branches},"getBranches"),De=t(function(){return m.records.commits},"getCommits"),xe=t(function(){let e=[...m.records.commits.values()];return e.forEach(function(r){a.debug(r.id)}),e.sort((r,o)=>r.seq-o.seq),e},"getCommitsArray"),We=t(function(){return m.records.currBranch},"getCurrentBranch"),qe=t(function(){return m.records.direction},"getDirection"),Ae=t(function(){return m.records.head},"getHead"),ue={commitType:v,getConfig:X,setDirection:ve,setOptions:Ee,getOptions:Te,commit:Le,branch:Me,merge:Pe,cherryPick:Re,checkout:ye,prettyPrint:Oe,clear:Ie,getBranchesAsObjArray:_e,getBranches:Ge,getCommits:De,getCommitsArray:xe,getCurrentBranch:We,getDirection:qe,getHead:Ae,setAccTitle:S,getAccTitle:E,getAccDescription:A,setAccDescription:T,setDiagramTitle:L,getDiagramTitle:R},He=t((e,r)=>{if(G(e,r),e.dir)r.setDirection(e.dir);for(let o of e.statements)Se(o,r)},"populate"),Se=t((e,r)=>{let c={Commit:t((i)=>r.commit(Ne(i)),"Commit"),Branch:t((i)=>r.branch(Fe(i)),"Branch"),Merge:t((i)=>r.merge(ze(i)),"Merge"),Checkout:t((i)=>r.checkout(Ye(i)),"Checkout"),CherryPicking:t((i)=>r.cherryPick(je(i)),"CherryPicking")}[e.$type];if(c)c(e);else a.error(`Unknown statement type: ${e.$type}`)},"parseStatement"),Ne=t((e)=>({id:e.id,msg:e.message??"",type:e.type!==void 0?v[e.type]:v.NORMAL,tags:e.tags??void 0}),"parseCommit"),Fe=t((e)=>({name:e.name,order:e.order??0}),"parseBranch"),ze=t((e)=>({branch:e.branch,id:e.id??"",type:e.type!==void 0?v[e.type]:void 0,tags:e.tags??void 0}),"parseMerge"),Ye=t((e)=>e.branch,"parseCheckout"),je=t((e)=>({id:e.id,targetId:"",tags:e.tags?.length===0?void 0:e.tags,parent:e.parent}),"parseCherryPicking"),Ke={parse:t(async(e)=>{let r=await J("gitGraph",e);a.debug(r),He(r,ue)},"parse")},j=10,K=40,H=4,z=2,V=8,ce=new Set(["redux","redux-dark","redux-color","redux-dark-color"]),le=12,ge=new Set(["redux-color","redux-dark-color"]),Ue=new Set(["dark","redux-dark","redux-dark-color","neo-dark"]),Z=t((e,r,o=!1)=>{if(o&&e>0)return(e-1)%(r-1)+1;return e%r},"calcColorIndex"),D=new Map,W=new Map,oe=30,te=new Map,se=[],Y=0,B="LR",Ve=t(()=>{D.clear(),W.clear(),te.clear(),Y=0,se=[],B="LR"},"clear"),be=t((e)=>{let r=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof e==="string"?e.split(/\\n|\n|<br\s*\/?>/gi):e).forEach((c)=>{let i=document.createElementNS("http://www.w3.org/2000/svg","tspan");i.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),i.setAttribute("dy","1em"),i.setAttribute("x","0"),i.setAttribute("class","row"),i.textContent=c.trim(),r.appendChild(i)}),r},"drawText"),we=t((e)=>{let r,o,c;if(B==="BT")o=t((i,h)=>i<=h,"comparisonFunc"),c=1/0;else o=t((i,h)=>i>=h,"comparisonFunc"),c=0;return e.forEach((i)=>{let h=B==="TB"||B=="BT"?W.get(i)?.y:W.get(i)?.x;if(h!==void 0&&o(h,c))r=i,c=h}),r},"findClosestParent"),Ze=t((e)=>{let r="",o=1/0;return e.forEach((c)=>{let i=W.get(c).y;if(i<=o)r=c,o=i}),r||void 0},"findClosestParentBT"),Xe=t((e,r,o)=>{let c=o,i=o,h=[];e.forEach((n)=>{let s=r.get(n);if(!s)throw Error(`Commit not found for key ${n}`);if(s.parents.length)c=Qe(s),i=Math.max(c,i);else h.push(s);et(s,c)}),c=i,h.forEach((n)=>{tt(n,c,o)}),e.forEach((n)=>{let s=r.get(n);if(s?.parents.length){let g=Ze(s.parents);if(c=W.get(g).y-K,c<=i)i=c;let y=D.get(s.branch).pos,u=c-j;W.set(s.id,{x:y,y:u})}})},"setParallelBTPos"),Je=t((e)=>{let r=we(e.parents.filter((c)=>c!==null));if(!r)throw Error(`Closest parent not found for commit ${e.id}`);let o=W.get(r)?.y;if(o===void 0)throw Error(`Closest parent position not found for commit ${e.id}`);return o},"findClosestParentPos"),Qe=t((e)=>Je(e)+K,"calculateCommitPosition"),et=t((e,r)=>{let o=D.get(e.branch);if(!o)throw Error(`Branch not found for commit ${e.id}`);let c=o.pos,i=r+j;return W.set(e.id,{x:c,y:i}),{x:c,y:i}},"setCommitPosition"),tt=t((e,r,o)=>{let c=D.get(e.branch);if(!c)throw Error(`Branch not found for commit ${e.id}`);let i=r+o,h=c.pos;W.set(e.id,{x:h,y:i})},"setRootPosition"),rt=t((e,r,o,c,i,h)=>{let{theme:n}=l(),s=ce.has(n??""),g=ge.has(n??""),y=Ue.has(n??"");if(h===v.HIGHLIGHT)e.append("rect").attr("x",o.x-10+(s?3:0)).attr("y",o.y-10+(s?3:0)).attr("width",s?14:20).attr("height",s?14:20).attr("class",`commit ${r.id} commit-highlight${Z(i,V,g)} ${c}-outer`),e.append("rect").attr("x",o.x-6+(s?2:0)).attr("y",o.y-6+(s?2:0)).attr("width",s?8:12).attr("height",s?8:12).attr("class",`commit ${r.id} commit${Z(i,V,g)} ${c}-inner`);else if(h===v.CHERRY_PICK)e.append("circle").attr("cx",o.x).attr("cy",o.y).attr("r",s?7:10).attr("class",`commit ${r.id} ${c}`),e.append("circle").attr("cx",o.x-3).attr("cy",o.y+2).attr("r",s?2.5:2.75).attr("fill",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`),e.append("circle").attr("cx",o.x+3).attr("cy",o.y+2).attr("r",s?2.5:2.75).attr("fill",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`),e.append("line").attr("x1",o.x+3).attr("y1",o.y+1).attr("x2",o.x).attr("y2",o.y-5).attr("stroke",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`),e.append("line").attr("x1",o.x-3).attr("y1",o.y+1).attr("x2",o.x).attr("y2",o.y-5).attr("stroke",y?"#000000":"#fff").attr("class",`commit ${r.id} ${c}`);else{let u=e.append("circle");if(u.attr("cx",o.x),u.attr("cy",o.y),u.attr("r",s?7:10),u.attr("class",`commit ${r.id} commit${Z(i,V,g)}`),h===v.MERGE){let f=e.append("circle");f.attr("cx",o.x),f.attr("cy",o.y),f.attr("r",s?5:6),f.attr("class",`commit ${c} ${r.id} commit${Z(i,V,g)}`)}if(h===v.REVERSE){let f=e.append("path"),d=s?4:5;f.attr("d",`M ${o.x-d},${o.y-d}L${o.x+d},${o.y+d}M${o.x-d},${o.y+d}L${o.x+d},${o.y-d}`).attr("class",`commit ${c} ${r.id} commit${Z(i,V,g)}`)}}},"drawCommitBullet"),at=t((e,r,o,c,i)=>{if(r.type!==v.CHERRY_PICK&&(r.customId&&r.type===v.MERGE||r.type!==v.MERGE)&&i.showCommitLabel){let h=e.append("g"),n=h.insert("rect").attr("class","commit-label-bkg"),s=h.append("text").attr("x",c).attr("y",o.y+25).attr("class","commit-label").text(r.id),g=s.node()?.getBBox();if(g){if(n.attr("x",o.posWithOffset-g.width/2-z).attr("y",o.y+13.5).attr("width",g.width+2*z).attr("height",g.height+2*z),B==="TB"||B==="BT")n.attr("x",o.x-(g.width+4*H+5)).attr("y",o.y-12),s.attr("x",o.x-(g.width+4*H)).attr("y",o.y+g.height-12);else s.attr("x",o.posWithOffset-g.width/2);if(i.rotateCommitLabel)if(B==="TB"||B==="BT")s.attr("transform","rotate(-45, "+o.x+", "+o.y+")"),n.attr("transform","rotate(-45, "+o.x+", "+o.y+")");else{let y=-7.5-(g.width+10)/25*9.5,u=10+g.width/25*8.5;h.attr("transform","translate("+y+", "+u+") rotate(-45, "+c+", "+o.y+")")}}}},"drawCommitLabel"),ot=t((e,r,o,c)=>{if(r.tags.length>0){let i=0,h=0,n=0,s=[];for(let g of r.tags.reverse()){let y=e.insert("polygon"),u=e.append("circle"),f=e.append("text").attr("y",o.y-16-i).attr("class","tag-label").text(g),d=f.node()?.getBBox();if(!d)throw Error("Tag bbox not found");h=Math.max(h,d.width),n=Math.max(n,d.height),f.attr("x",o.posWithOffset-d.width/2),s.push({tag:f,hole:u,rect:y,yOffset:i}),i+=20}for(let{tag:g,hole:y,rect:u,yOffset:f}of s){let d=n/2,k=o.y-19.2-f;if(u.attr("class","tag-label-bkg").attr("points",`
2
2
  ${c-h/2-H/2},${k+z}
3
3
  ${c-h/2-H/2},${k-z}
4
4
  ${o.posWithOffset-h/2-H},${k-d-z}
@@ -0,0 +1 @@
1
+ import{Ci}from"./chunk-qy1zx2yw.js";export{Ci as createRadarServices};
@@ -1 +1 @@
1
- import{D,r,e,n,Ae,It,q,ie,ro}from"./chunk-nvt9tkt4.js";function T(s){let a=D(Ae);a?.useTheme?.();let t=s.payload,[i,m]=r(!1);if(!t||t.state==="pending")return null;let h=t.questions.map((o)=>o.header).join(" · "),l=t.state==="answered",u=l?q:It,d=l?"text-success":"text-faint",f=l?"已回答":t.state==="dismissed"?"已忽略提问":"提问已取消",p=l?g(t):h;if(a){let{Collapsible:o,CollapsibleTrigger:y,CollapsibleContent:N,Chevron:v,cn:b}=a;return n(o,{open:i,onOpenChange:m,className:"w-full text-xs text-ink/90 animate-fade",children:[n(y,{className:a.style("chat.timelineRow","cursor-pointer select-none"),children:[e("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e(u,{className:b("size-3.5",d)})}),e("span",{className:"shrink-0",children:f}),e("span",{className:"min-w-0 flex-1 truncate opacity-80",title:p,children:p}),e(v,{className:"size-3.5 shrink-0 text-faint opacity-0 transition-opacity group-hover/collapsible:opacity-100 group-data-[state=open]/collapsible:opacity-100"})]}),e(N,{children:e("div",{className:"mt-0.5 mb-1.5 ml-2 border-l border-line py-1 pl-[15px]",children:e(x,{question:t})})})]})}return n("div",{role:"status",className:"w-full animate-fade",children:[n("button",{type:"button","aria-expanded":i,className:"group -mx-2 flex w-[calc(100%+1rem)] cursor-pointer items-center gap-2 rounded-lg px-2 py-1 text-left text-[12.5px] text-faint transition-colors select-none hover:bg-raised/60 hover:text-dim",onClick:()=>m((o)=>!o),children:[e("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e(u,{className:`size-3.5 shrink-0 ${d}`})}),e("span",{className:"shrink-0",children:f}),e("span",{className:"min-w-0 flex-1 truncate opacity-80",title:p,children:p}),e(ie,{className:`size-3.5 shrink-0 text-faint opacity-0 transition-[opacity,transform] group-hover:opacity-100 ${i?"rotate-180 opacity-100":""}`})]}),i&&e("div",{className:"mt-0.5 mb-1.5 ml-2 border-l border-line py-1 pl-[15px]",children:e(x,{question:t})})]})}function c(s){if(!s)return"未作答";let a=s.selected.map((t)=>ro(t).title);if(s.other)a.push(`其他:${s.other}`);return a.length?a.join("、"):"未作答"}function g(s){if(s.questions.length===1)return`${s.questions[0]?.header??""} · ${c(s.answers?.[0])}`;return s.questions.map((a,t)=>`${a.header} → ${c(s.answers?.[t])}`).join(";")}function x(s){let a=s.question;return e("div",{className:"space-y-2 text-xs",children:a.questions.map((t,i)=>n("div",{className:"space-y-0.5",children:[n("div",{className:"text-dim",children:[e("span",{className:"font-medium text-ink/90",children:t.header})," · ",t.question]}),e("div",{className:"text-ink",children:c(a.answers?.[i])})]},t.header))})}export{T as QuestionCard};
1
+ import{D,r,e,n,Ae,It,q,ie,ro}from"./chunk-ngt1j8py.js";function T(s){let a=D(Ae);a?.useTheme?.();let t=s.payload,[i,m]=r(!1);if(!t||t.state==="pending")return null;let h=t.questions.map((o)=>o.header).join(" · "),l=t.state==="answered",u=l?q:It,d=l?"text-success":"text-faint",f=l?"已回答":t.state==="dismissed"?"已忽略提问":"提问已取消",p=l?g(t):h;if(a){let{Collapsible:o,CollapsibleTrigger:y,CollapsibleContent:N,Chevron:v,cn:b}=a;return n(o,{open:i,onOpenChange:m,className:"w-full text-xs text-ink/90 animate-fade",children:[n(y,{className:a.style("chat.timelineRow","cursor-pointer select-none"),children:[e("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e(u,{className:b("size-3.5",d)})}),e("span",{className:"shrink-0",children:f}),e("span",{className:"min-w-0 flex-1 truncate opacity-80",title:p,children:p}),e(v,{className:"size-3.5 shrink-0 text-faint opacity-0 transition-opacity group-hover/collapsible:opacity-100 group-data-[state=open]/collapsible:opacity-100"})]}),e(N,{children:e("div",{className:"mt-0.5 mb-1.5 ml-2 border-l border-line py-1 pl-[15px]",children:e(x,{question:t})})})]})}return n("div",{role:"status",className:"w-full animate-fade",children:[n("button",{type:"button","aria-expanded":i,className:"group -mx-2 flex w-[calc(100%+1rem)] cursor-pointer items-center gap-2 rounded-lg px-2 py-1 text-left text-[12.5px] text-faint transition-colors select-none hover:bg-raised/60 hover:text-dim",onClick:()=>m((o)=>!o),children:[e("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e(u,{className:`size-3.5 shrink-0 ${d}`})}),e("span",{className:"shrink-0",children:f}),e("span",{className:"min-w-0 flex-1 truncate opacity-80",title:p,children:p}),e(ie,{className:`size-3.5 shrink-0 text-faint opacity-0 transition-[opacity,transform] group-hover:opacity-100 ${i?"rotate-180 opacity-100":""}`})]}),i&&e("div",{className:"mt-0.5 mb-1.5 ml-2 border-l border-line py-1 pl-[15px]",children:e(x,{question:t})})]})}function c(s){if(!s)return"未作答";let a=s.selected.map((t)=>ro(t).title);if(s.other)a.push(`其他:${s.other}`);return a.length?a.join("、"):"未作答"}function g(s){if(s.questions.length===1)return`${s.questions[0]?.header??""} · ${c(s.answers?.[0])}`;return s.questions.map((a,t)=>`${a.header} → ${c(s.answers?.[t])}`).join(";")}function x(s){let a=s.question;return e("div",{className:"space-y-2 text-xs",children:a.questions.map((t,i)=>n("div",{className:"space-y-0.5",children:[n("div",{className:"text-dim",children:[e("span",{className:"font-medium text-ink/90",children:t.header})," · ",t.question]}),e("div",{className:"text-ink",children:c(a.answers?.[i])})]},t.header))})}export{T as QuestionCard};
@@ -1 +1 @@
1
- import{g,o,Y,i,r,f,e,n,y,qt,er,Ue,Mn,Ie,pn,ce,te,ia,Eo,oa}from"./chunk-nvt9tkt4.js";function de(d){let{Button:b,confirm:L,PageLayout:x,Switch:_,cn:F,style:z}=y(),{connection:u,onOpen:O}=d,[D,p]=r([]),[w,H]=r([]),[q,J]=r([]),[I,T]=r(),[B,U]=r([]),[A,V]=r(!0),[k,N]=r(),[C,R]=r(),[W,P]=r(!1),[G,c]=r({}),s=i(0),E=g(async()=>{let t=++s.current;try{let[a,l,m,v]=await Promise.all([u.request("/api/automations"),u.request("/api/projects").catch(()=>[]),u.request("/api/info").catch(()=>{return}),u.request("/api/models").catch(()=>({models:[]}))]),ee=[...new Set(a.flatMap((h)=>h.lastSessionID?[h.lastSessionID]:[]))],ne=(await Promise.all(ee.map(async(h)=>u.request(`/api/sessions/${encodeURIComponent(h)}`).catch((j)=>{if(j instanceof Error&&"status"in j&&j.status===404)return;throw j})))).filter((h)=>h!==void 0);if(t!==s.current)return;if(p(a.sort((h,j)=>h.created-j.created)),H(l),J(ne),T(m),v?.models)U(v.models.map((h)=>h.id));N(void 0)}catch(a){if(t===s.current)N(a instanceof Error?a.message:"加载失败")}finally{if(t===s.current)V(!1)}},[u]);o(()=>(E(),()=>{s.current++}),[E]);let S=(t)=>{R(t),P(!0)},Q=async(t)=>{c((a)=>({...a,[t.id]:!0}));try{let a=await u.request(`/api/automations/${t.id}/run`,{method:"POST"});O(a.id)}catch(a){N(a instanceof Error?a.message:"运行失败")}finally{c((a)=>({...a,[t.id]:!1}))}},X=async(t)=>{if(!await L({title:`删除自动化「${t.name}」?`,description:"已经跑出来的会话会保留。",action:"删除",danger:!0}))return;try{await u.request(`/api/automations/${t.id}`,{method:"DELETE"}),p((l)=>l.filter((m)=>m.id!==t.id))}catch(l){N(l instanceof Error?l.message:"删除失败")}},Z=async(t,a)=>{try{let l=await u.request(`/api/automations/${t.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})});p((m)=>m.map((v)=>v.id===t.id?l:v))}catch(l){N(l instanceof Error?l.message:"状态切换失败")}};return n(x,{title:"自动化",description:n(f,{children:["到点自动开一个新会话执行提示词,跑完的结果在会话里查看。",I?.timezone&&n("span",{className:"text-faint",children:["按服务器时区 ",I.timezone,"。"]})]}),actions:n(b,{variant:"primary",onClick:()=>S(null),children:[e(ce,{className:"size-4"}),"新建"]}),children:[k&&e("div",{className:"mb-4 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:k}),A?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载自动化…"}):D.length===0?n("div",{className:z("surface.emptyDashed","animate-fade"),children:[e("div",{className:"grid size-11 place-items-center rounded-xl bg-raised text-dim",children:e(qt,{className:"size-5"})}),n("div",{children:[e("p",{className:"text-[15px] font-medium",children:"还没有自动化"}),e("p",{className:"mt-1 text-sm text-dim",children:"比如「每个工作日 9 点总结昨天的提交」。"})]}),n(b,{size:"sm",onClick:()=>S(null),className:"mt-1",children:[e(ce,{className:"size-3.5"}),"新建自动化"]})]}):e("ul",{className:"flex animate-fade flex-col gap-3",children:D.map((t)=>{let a=t.projectID?w.find((v)=>v.id===t.projectID):void 0,l=t.lastSessionID?q.find((v)=>v.id===t.lastSessionID):void 0,m=Boolean(G[t.id]);return e("li",{children:n("article",{className:z("surface.card","group p-4 transition-[border-color,box-shadow] duration-200 hover:border-line-strong hover:shadow-composer"),children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:F("min-w-0 flex-1 transition-opacity duration-200",!t.enabled&&"opacity-55"),children:[e("h2",{className:"truncate text-[15px] font-medium",children:t.name}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-[13px] text-dim",children:[n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(qt,{}),Eo(t.schedule)]}),n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[a?e(Ue,{}):e(Mn,{}),a?a.name:"聊天"]}),t.enabled&&t.nextRun!==null&&n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(er,{}),"下次 ",oa(t.nextRun)]})]})]}),e(_,{checked:t.enabled,label:t.enabled?"停用":"启用",onCheckedChange:(v)=>Z(t,v),className:"mt-0.5"})]}),e("p",{className:F("mt-3 line-clamp-2 text-sm leading-6 whitespace-pre-wrap text-faint transition-opacity duration-200",!t.enabled&&"opacity-55"),children:t.prompt}),n("div",{className:"mt-3 -mb-1 flex items-center gap-1",children:[n(b,{size:"sm",onClick:()=>Q(t),disabled:m,children:[e(pn,{className:"size-3.5"}),m?"正在启动…":"立即运行"]}),n(b,{size:"sm",variant:"ghost",onClick:()=>S(t),children:[e(Ie,{className:"size-3.5"}),"编辑"]}),n(b,{size:"sm",variant:"danger-ghost",onClick:()=>X(t),children:[e(te,{className:"size-3.5"}),"删除"]}),e("div",{className:"flex-1"}),t.lastRun!==null&&n("button",{type:"button",disabled:!l,onClick:()=>l&&O(l.id),className:"rounded-md px-1.5 py-1 text-[13px] text-faint transition-colors enabled:hover:bg-raised enabled:hover:text-ink",children:["上次运行 ",oa(t.lastRun),l?.archivedAt!=null?" · 已归档":"",!l?" · 会话已删除":""]})]})]})},t.id)})}),C!==void 0&&e(oe,{open:W,onOpenChange:P,automation:C??void 0,projects:w,models:B,timezone:I?.timezone,onSaved:(t)=>{p((a)=>{let l=a.findIndex((m)=>m.id===t.id);if(l>=0){let m=[...a];return m[l]=t,m}return[...a,t].sort((m,v)=>m.created-v.created)}),P(!1)},connection:u},C?.id??"new")]})}var M="custom",K="chat";function oe(d){let{Button:b,Dialog:L,Field:x,Form:_,FormError:F,Input:z,Select:u,Textarea:O}=y(),D=Y(),p=d.automation,[w,H]=r(p?.name??""),[q,J]=r(p?.prompt??""),[I,T]=r(p?.schedule??ia[0]?.cron??"0 9 * * *"),[B,U]=r(()=>!ia.some((c)=>c.cron===I)),[A,V]=r(p?.projectID??K),[k,N]=r(p?.model??""),[C,R]=r(!1),[W,P]=r();async function G(c){c.preventDefault(),R(!0),P(void 0);try{let s=A===K?void 0:A,E={name:w,prompt:q,schedule:I,model:k||void 0},S;if(p)S=await d.connection.request(`/api/automations/${p.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s??null})});else S=await d.connection.request("/api/automations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s})});d.onSaved(S)}catch(s){P(s instanceof Error?s.message:"保存失败")}finally{R(!1)}}return e(L,{open:d.open,onOpenChange:d.onOpenChange,title:d.automation?"编辑自动化":"新建自动化",size:"lg",footer:n(f,{children:[e("div",{className:"flex-1 max-sm:hidden"}),e(b,{onClick:()=>d.onOpenChange(!1),children:"取消"}),e(b,{type:"submit",form:D,variant:"primary",disabled:C,children:C?"正在保存…":d.automation?"保存":"创建"})]}),children:n(_,{id:D,onSubmit:G,children:[e(x,{label:"名称",children:(c)=>e(z,{id:c,autoFocus:!p,required:!0,value:w,onChange:(s)=>H(s.target.value),placeholder:"例如:每日提交总结"})}),e(x,{label:"提示词",hint:"没人盯着运行,写清楚要做什么、结果怎么汇报。",children:(c)=>e(O,{id:c,required:!0,value:q,onChange:(s)=>J(s.target.value),rows:5,placeholder:"总结昨天到现在的 git 提交,按模块分组,列出需要我关注的改动。"})}),n("div",{className:"grid gap-x-3 gap-y-4 sm:grid-cols-2",children:[e(x,{label:"时间",children:(c)=>e(u,{id:c,value:B?M:I,onValueChange:(s)=>{if(U(s===M),s!==M)T(s)},groups:[{options:ia.map((s)=>({value:s.cron,label:s.label}))},{options:[{value:M,label:"自定义(cron)"}]}]})}),e(x,{label:"在哪里运行",children:(c)=>e(u,{id:c,value:A,onValueChange:V,groups:[{options:[{value:K,label:"聊天",description:"不绑定目录",icon:e(Mn,{})}]},...d.projects.length?[{label:"项目",options:d.projects.map((s)=>({value:s.id,label:s.name,icon:e(Ue,{})}))}]:[]]})})]}),B&&e(x,{label:"cron 表达式",hint:`分 时 日 月 周,例如 30 8 * * 1-5 是工作日 8:30。${d.timezone?`按 ${d.timezone} 时间。`:""}`,children:(c)=>e(z,{id:c,required:!0,value:I,onChange:(s)=>T(s.target.value),spellCheck:!1,className:"font-mono"})}),d.models.length>0&&e(x,{label:"模型",children:(c)=>e(u,{id:c,value:k||"default",onValueChange:(s)=>N(s==="default"?"":s),groups:[{options:[{value:"default",label:"默认模型"},...d.models.map((s)=>({value:s,label:s}))]}]})}),e(F,{children:W})]})})}export{de as AutomationsPage};
1
+ import{g,o,Y,i,r,f,e,n,y,qt,er,Ue,Mn,Ie,pn,ce,te,ia,Eo,oa}from"./chunk-ngt1j8py.js";function de(d){let{Button:b,confirm:L,PageLayout:x,Switch:_,cn:F,style:z}=y(),{connection:u,onOpen:O}=d,[D,p]=r([]),[w,H]=r([]),[q,J]=r([]),[I,T]=r(),[B,U]=r([]),[A,V]=r(!0),[k,N]=r(),[C,R]=r(),[W,P]=r(!1),[G,c]=r({}),s=i(0),E=g(async()=>{let t=++s.current;try{let[a,l,m,v]=await Promise.all([u.request("/api/automations"),u.request("/api/projects").catch(()=>[]),u.request("/api/info").catch(()=>{return}),u.request("/api/models").catch(()=>({models:[]}))]),ee=[...new Set(a.flatMap((h)=>h.lastSessionID?[h.lastSessionID]:[]))],ne=(await Promise.all(ee.map(async(h)=>u.request(`/api/sessions/${encodeURIComponent(h)}`).catch((j)=>{if(j instanceof Error&&"status"in j&&j.status===404)return;throw j})))).filter((h)=>h!==void 0);if(t!==s.current)return;if(p(a.sort((h,j)=>h.created-j.created)),H(l),J(ne),T(m),v?.models)U(v.models.map((h)=>h.id));N(void 0)}catch(a){if(t===s.current)N(a instanceof Error?a.message:"加载失败")}finally{if(t===s.current)V(!1)}},[u]);o(()=>(E(),()=>{s.current++}),[E]);let S=(t)=>{R(t),P(!0)},Q=async(t)=>{c((a)=>({...a,[t.id]:!0}));try{let a=await u.request(`/api/automations/${t.id}/run`,{method:"POST"});O(a.id)}catch(a){N(a instanceof Error?a.message:"运行失败")}finally{c((a)=>({...a,[t.id]:!1}))}},X=async(t)=>{if(!await L({title:`删除自动化「${t.name}」?`,description:"已经跑出来的会话会保留。",action:"删除",danger:!0}))return;try{await u.request(`/api/automations/${t.id}`,{method:"DELETE"}),p((l)=>l.filter((m)=>m.id!==t.id))}catch(l){N(l instanceof Error?l.message:"删除失败")}},Z=async(t,a)=>{try{let l=await u.request(`/api/automations/${t.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})});p((m)=>m.map((v)=>v.id===t.id?l:v))}catch(l){N(l instanceof Error?l.message:"状态切换失败")}};return n(x,{title:"自动化",description:n(f,{children:["到点自动开一个新会话执行提示词,跑完的结果在会话里查看。",I?.timezone&&n("span",{className:"text-faint",children:["按服务器时区 ",I.timezone,"。"]})]}),actions:n(b,{variant:"primary",onClick:()=>S(null),children:[e(ce,{className:"size-4"}),"新建"]}),children:[k&&e("div",{className:"mb-4 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:k}),A?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载自动化…"}):D.length===0?n("div",{className:z("surface.emptyDashed","animate-fade"),children:[e("div",{className:"grid size-11 place-items-center rounded-xl bg-raised text-dim",children:e(qt,{className:"size-5"})}),n("div",{children:[e("p",{className:"text-[15px] font-medium",children:"还没有自动化"}),e("p",{className:"mt-1 text-sm text-dim",children:"比如「每个工作日 9 点总结昨天的提交」。"})]}),n(b,{size:"sm",onClick:()=>S(null),className:"mt-1",children:[e(ce,{className:"size-3.5"}),"新建自动化"]})]}):e("ul",{className:"flex animate-fade flex-col gap-3",children:D.map((t)=>{let a=t.projectID?w.find((v)=>v.id===t.projectID):void 0,l=t.lastSessionID?q.find((v)=>v.id===t.lastSessionID):void 0,m=Boolean(G[t.id]);return e("li",{children:n("article",{className:z("surface.card","group p-4 transition-[border-color,box-shadow] duration-200 hover:border-line-strong hover:shadow-composer"),children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:F("min-w-0 flex-1 transition-opacity duration-200",!t.enabled&&"opacity-55"),children:[e("h2",{className:"truncate text-[15px] font-medium",children:t.name}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-[13px] text-dim",children:[n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(qt,{}),Eo(t.schedule)]}),n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[a?e(Ue,{}):e(Mn,{}),a?a.name:"聊天"]}),t.enabled&&t.nextRun!==null&&n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(er,{}),"下次 ",oa(t.nextRun)]})]})]}),e(_,{checked:t.enabled,label:t.enabled?"停用":"启用",onCheckedChange:(v)=>Z(t,v),className:"mt-0.5"})]}),e("p",{className:F("mt-3 line-clamp-2 text-sm leading-6 whitespace-pre-wrap text-faint transition-opacity duration-200",!t.enabled&&"opacity-55"),children:t.prompt}),n("div",{className:"mt-3 -mb-1 flex items-center gap-1",children:[n(b,{size:"sm",onClick:()=>Q(t),disabled:m,children:[e(pn,{className:"size-3.5"}),m?"正在启动…":"立即运行"]}),n(b,{size:"sm",variant:"ghost",onClick:()=>S(t),children:[e(Ie,{className:"size-3.5"}),"编辑"]}),n(b,{size:"sm",variant:"danger-ghost",onClick:()=>X(t),children:[e(te,{className:"size-3.5"}),"删除"]}),e("div",{className:"flex-1"}),t.lastRun!==null&&n("button",{type:"button",disabled:!l,onClick:()=>l&&O(l.id),className:"rounded-md px-1.5 py-1 text-[13px] text-faint transition-colors enabled:hover:bg-raised enabled:hover:text-ink",children:["上次运行 ",oa(t.lastRun),l?.archivedAt!=null?" · 已归档":"",!l?" · 会话已删除":""]})]})]})},t.id)})}),C!==void 0&&e(oe,{open:W,onOpenChange:P,automation:C??void 0,projects:w,models:B,timezone:I?.timezone,onSaved:(t)=>{p((a)=>{let l=a.findIndex((m)=>m.id===t.id);if(l>=0){let m=[...a];return m[l]=t,m}return[...a,t].sort((m,v)=>m.created-v.created)}),P(!1)},connection:u},C?.id??"new")]})}var M="custom",K="chat";function oe(d){let{Button:b,Dialog:L,Field:x,Form:_,FormError:F,Input:z,Select:u,Textarea:O}=y(),D=Y(),p=d.automation,[w,H]=r(p?.name??""),[q,J]=r(p?.prompt??""),[I,T]=r(p?.schedule??ia[0]?.cron??"0 9 * * *"),[B,U]=r(()=>!ia.some((c)=>c.cron===I)),[A,V]=r(p?.projectID??K),[k,N]=r(p?.model??""),[C,R]=r(!1),[W,P]=r();async function G(c){c.preventDefault(),R(!0),P(void 0);try{let s=A===K?void 0:A,E={name:w,prompt:q,schedule:I,model:k||void 0},S;if(p)S=await d.connection.request(`/api/automations/${p.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s??null})});else S=await d.connection.request("/api/automations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s})});d.onSaved(S)}catch(s){P(s instanceof Error?s.message:"保存失败")}finally{R(!1)}}return e(L,{open:d.open,onOpenChange:d.onOpenChange,title:d.automation?"编辑自动化":"新建自动化",size:"lg",footer:n(f,{children:[e("div",{className:"flex-1 max-sm:hidden"}),e(b,{onClick:()=>d.onOpenChange(!1),children:"取消"}),e(b,{type:"submit",form:D,variant:"primary",disabled:C,children:C?"正在保存…":d.automation?"保存":"创建"})]}),children:n(_,{id:D,onSubmit:G,children:[e(x,{label:"名称",children:(c)=>e(z,{id:c,autoFocus:!p,required:!0,value:w,onChange:(s)=>H(s.target.value),placeholder:"例如:每日提交总结"})}),e(x,{label:"提示词",hint:"没人盯着运行,写清楚要做什么、结果怎么汇报。",children:(c)=>e(O,{id:c,required:!0,value:q,onChange:(s)=>J(s.target.value),rows:5,placeholder:"总结昨天到现在的 git 提交,按模块分组,列出需要我关注的改动。"})}),n("div",{className:"grid gap-x-3 gap-y-4 sm:grid-cols-2",children:[e(x,{label:"时间",children:(c)=>e(u,{id:c,value:B?M:I,onValueChange:(s)=>{if(U(s===M),s!==M)T(s)},groups:[{options:ia.map((s)=>({value:s.cron,label:s.label}))},{options:[{value:M,label:"自定义(cron)"}]}]})}),e(x,{label:"在哪里运行",children:(c)=>e(u,{id:c,value:A,onValueChange:V,groups:[{options:[{value:K,label:"聊天",description:"不绑定目录",icon:e(Mn,{})}]},...d.projects.length?[{label:"项目",options:d.projects.map((s)=>({value:s.id,label:s.name,icon:e(Ue,{})}))}]:[]]})})]}),B&&e(x,{label:"cron 表达式",hint:`分 时 日 月 周,例如 30 8 * * 1-5 是工作日 8:30。${d.timezone?`按 ${d.timezone} 时间。`:""}`,children:(c)=>e(z,{id:c,required:!0,value:I,onChange:(s)=>T(s.target.value),spellCheck:!1,className:"font-mono"})}),d.models.length>0&&e(x,{label:"模型",children:(c)=>e(u,{id:c,value:k||"default",onValueChange:(s)=>N(s==="default"?"":s),groups:[{options:[{value:"default",label:"默认模型"},...d.models.map((s)=>({value:s,label:s}))]}]})}),e(F,{children:W})]})})}export{de as AutomationsPage};
@@ -1 +1 @@
1
- import{g,o,i,r,f,e,n,y,bt,Q}from"./chunk-nvt9tkt4.js";import{Or,$r,Br}from"./chunk-fpb2dd2d.js";var ee={global:"全局",project:"项目",custom:"自定义",builtin:"内置"};function F({skill:s,issue:N,connection:S}){let{Button:E,CopyButton:d,style:v,useTheme:w}=y();w();let[p,L]=r(),[P,x]=r(),[D,z]=r(0);return o(()=>{let c=!0;x(void 0),L(void 0);let m=new URLSearchParams;if(s.projectID)m.set("projectID",s.projectID);if(s.location)m.set("location",s.location);let I=m.toString()?`?${m.toString()}`:"";return Promise.all([S.request(`/api/skills/${encodeURIComponent(s.name)}/content${I}`),S.request(`/api/skills/${encodeURIComponent(s.name)}/files${I}`)]).then(([b,O])=>{if(c)L({text:b.text,files:O.files})}).catch((b)=>{if(c)x(b instanceof Error?b.message:"读取失败")}),()=>{c=!1}},[S,s.name,s.projectID,s.location,D]),n("div",{className:"min-w-0 space-y-5 text-sm text-ink",children:[e("p",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] text-dim",children:s.description||"暂无描述"}),n("div",{children:[n("p",{className:"break-all text-xs text-dim",children:[ee[s.scope],s.projectName?` · ${s.projectName}`:""]}),n("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[e("code",{className:v("markdown.inlineCode","min-w-0 flex-1 break-all text-xs"),children:s.location}),e(d,{text:s.location,label:"复制完整路径",className:"size-10"})]})]}),n("ul",{className:"space-y-1 break-words text-xs text-dim",children:[e("li",{children:"启用状态按名称生效,影响所有同名技能的新会话可用性。"}),s.disableModelInvocation&&e("li",{children:"仅手动:可由用户调用,不向模型自动提供。"}),s.platforms&&n("li",{children:["平台限制:",s.platforms.join("、")]}),s.disabled&&e("li",{children:"已禁用:不会提供给新会话。"}),N?.overriddenBy&&n("li",{className:"break-all",children:["被覆盖:同名技能优先使用 ",N.overriddenBy]})]}),s.commands?.length?n("div",{children:[e("h3",{className:"font-medium",children:"bin 命令"}),e("p",{className:"mt-1 text-xs text-dim",children:"技能目录中的可执行命令。"}),e("ul",{className:"mt-2 space-y-1 font-mono text-xs",children:s.commands.map((c)=>e("li",{className:"break-all",children:c},c))})]}):null,P?n("div",{role:"alert",className:"space-y-2",children:[n("p",{className:"break-words text-danger",children:["读取失败:",P]}),e(E,{className:"h-10",onClick:()=>z(D+1),children:"重试"})]}):!p?e("p",{role:"status",className:"text-dim",children:"正在读取文件…"}):n(f,{children:[n("section",{children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e("h3",{className:"font-medium",children:"SKILL.md 原文"}),e(d,{text:p.text,label:"复制 SKILL.md 原文",className:"size-10"})]}),n("p",{className:"mb-2 text-xs text-faint",children:[p.text.length.toLocaleString()," 字符 · 约 ",Math.ceil(p.text.length/4).toLocaleString()," ","tokens(估算)"]}),e("pre",{className:v("surface.subtle",v("chat.toolOutput"),"rounded-lg bg-raised p-3 text-xs leading-5 break-all"),children:p.text})]}),n("section",{children:[n("h3",{className:"font-medium",children:["目录文件 · ",p.files.length,p.files.length===200?"(最多显示 200 个)":""]}),e("ul",{className:"mt-2 space-y-1 font-mono text-xs text-dim",children:p.files.map((c)=>e("li",{className:"break-all",children:c},c))})]})]})]})}var A="all",G="non-project",te="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent";function me({connection:s}){let{Button:N,Select:S,Dialog:E,style:d,useTheme:v}=y();v();let[w,p]=r([]),[L,P]=r([]),[x,D]=r(A),[z,c]=r([]),[m,I]=r(),[b,O]=r(""),[k,B]=r(),[h,T]=r(!0),[K,R]=r(),[W,H]=r(),u=i(0),j=i(!1),C=g(async(t=!1)=>{let l=++u.current;j.current=!0,T(!0);try{if(t)await s.request("/api/skills/rescan",{method:"POST"});let[a,U,q]=await Promise.all([s.request("/api/skills?all=true"),s.request("/api/skills/settings"),s.request("/api/projects")]);if(l!==u.current)return;p(a.skills),P(q),c(a.issues),I(U),H(new Date),R(void 0)}catch(a){if(l===u.current)R(a instanceof Error?a.message:"读取失败")}finally{if(l===u.current)j.current=!1,T(!1)}},[s]);o(()=>(C(),()=>{u.current++}),[C]);async function V(t){if(j.current)return;j.current=!0;let l=++u.current;T(!0);try{let a=await s.request("/api/skills/settings",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(l!==u.current)return;I(a),await C()}catch(a){if(l!==u.current)return;R(a instanceof Error?a.message:"保存设置失败"),j.current=!1,T(!1)}}let X=b.trim().toLocaleLowerCase(),J=x===A?w:w.filter((t)=>{if(t.scope!=="project")return!0;return x!==G&&t.projectID===x}),M=J.filter((t)=>`${t.name} ${t.description??""}`.toLocaleLowerCase().includes(X)),_=(t)=>z.find((l)=>l.kind==="overridden"&&(l.path==="<built-in>"?t.scope==="builtin":l.path.replace(/\\/g,"/")===`${t.location.replace(/\\/g,"/")}/SKILL.md`));return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[e("h2",{className:d("settings.groupTitle"),children:"技能"}),e("p",{"aria-live":"polite",className:d("settings.groupDesc"),children:W&&`找到 ${J.length} 个 · ${W.toLocaleTimeString("zh-CN",{hour12:!1})}`})]}),n("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e(S,{value:x,disabled:h,onValueChange:(t)=>{B(void 0),D(t)},groups:[{options:[{value:A,label:"全部来源"},{value:G,label:"非项目技能"}]},...Or(L)],className:"w-44"}),n(N,{variant:"ghost",disabled:h,onClick:()=>C(!0),className:"h-9 px-2.5 text-xs",children:[e(Q,{className:`size-3.5 ${h?"animate-spin":""}`}),e("span",{className:"ml-1",children:"重新扫描"})]})]})]}),K&&n("div",{role:"alert",className:"mb-3 flex flex-wrap items-center gap-2 rounded-xl border border-line p-3",children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法更新技能:",K]}),e(N,{disabled:h,onClick:()=>C(),children:"重试"})]}),e($r,{label:"搜索技能",placeholder:"搜索技能",value:b,onChange:O}),e("div",{className:d("settings.groupBox"),children:h&&!w.length?e(Br,{}):M.length===0?e("p",{className:"p-4 text-sm text-dim",children:"没有找到匹配的技能"}):e("ul",{className:"divide-y divide-line",children:M.map((t)=>{let l=_(t),a=t.disabled;return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${a?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看技能 ${t.name}`,onClick:()=>B(t),children:[n("span",{className:"min-w-0 flex-1",children:[n("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e("span",{className:"truncate text-sm font-medium text-ink",title:t.name,children:t.name}),l&&n("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",children:[e(bt,{className:"size-3.5"}),"被覆盖"]})]}),t.description&&e("span",{className:"mt-0.5 block truncate text-xs text-dim",title:t.description,children:t.description})]}),e("span",{className:d("control.badge","shrink-0 text-[11px] text-dim"),children:t.scope==="project"?"项目":t.scope==="builtin"?"built-in":"全局"})]}),e("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:e("input",{type:"checkbox","aria-label":`启用技能 ${t.name}`,className:te,disabled:h,checked:!a,onChange:(U)=>{if(!m)return;let q=m.disabled??[],Y=U.target.checked?q.filter((Z)=>Z!==t.name):[...q,t.name];V({...m,disabled:Y})}})})]},`${t.scope}:${t.projectID??""}:${t.name}`)})})})]}),e(E,{open:Boolean(k),onOpenChange:(t)=>{if(!t)B(void 0)},title:k?.name??"",size:"lg",footer:e("div",{className:"flex w-full justify-end",children:e(N,{variant:"primary",onClick:()=>B(void 0),children:"关闭"})}),children:k&&e(F,{skill:k,issue:_(k),connection:s})})]})}export{me as SkillsSection};
1
+ import{g,o,i,r,f,e,n,y,bt,Q}from"./chunk-ngt1j8py.js";import{Or,$r,Br}from"./chunk-jke2ev6m.js";var ee={global:"全局",project:"项目",custom:"自定义",builtin:"内置"};function F({skill:s,issue:N,connection:S}){let{Button:E,CopyButton:d,style:v,useTheme:w}=y();w();let[p,L]=r(),[P,x]=r(),[D,z]=r(0);return o(()=>{let c=!0;x(void 0),L(void 0);let m=new URLSearchParams;if(s.projectID)m.set("projectID",s.projectID);if(s.location)m.set("location",s.location);let I=m.toString()?`?${m.toString()}`:"";return Promise.all([S.request(`/api/skills/${encodeURIComponent(s.name)}/content${I}`),S.request(`/api/skills/${encodeURIComponent(s.name)}/files${I}`)]).then(([b,O])=>{if(c)L({text:b.text,files:O.files})}).catch((b)=>{if(c)x(b instanceof Error?b.message:"读取失败")}),()=>{c=!1}},[S,s.name,s.projectID,s.location,D]),n("div",{className:"min-w-0 space-y-5 text-sm text-ink",children:[e("p",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] text-dim",children:s.description||"暂无描述"}),n("div",{children:[n("p",{className:"break-all text-xs text-dim",children:[ee[s.scope],s.projectName?` · ${s.projectName}`:""]}),n("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[e("code",{className:v("markdown.inlineCode","min-w-0 flex-1 break-all text-xs"),children:s.location}),e(d,{text:s.location,label:"复制完整路径",className:"size-10"})]})]}),n("ul",{className:"space-y-1 break-words text-xs text-dim",children:[e("li",{children:"启用状态按名称生效,影响所有同名技能的新会话可用性。"}),s.disableModelInvocation&&e("li",{children:"仅手动:可由用户调用,不向模型自动提供。"}),s.platforms&&n("li",{children:["平台限制:",s.platforms.join("、")]}),s.disabled&&e("li",{children:"已禁用:不会提供给新会话。"}),N?.overriddenBy&&n("li",{className:"break-all",children:["被覆盖:同名技能优先使用 ",N.overriddenBy]})]}),s.commands?.length?n("div",{children:[e("h3",{className:"font-medium",children:"bin 命令"}),e("p",{className:"mt-1 text-xs text-dim",children:"技能目录中的可执行命令。"}),e("ul",{className:"mt-2 space-y-1 font-mono text-xs",children:s.commands.map((c)=>e("li",{className:"break-all",children:c},c))})]}):null,P?n("div",{role:"alert",className:"space-y-2",children:[n("p",{className:"break-words text-danger",children:["读取失败:",P]}),e(E,{className:"h-10",onClick:()=>z(D+1),children:"重试"})]}):!p?e("p",{role:"status",className:"text-dim",children:"正在读取文件…"}):n(f,{children:[n("section",{children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e("h3",{className:"font-medium",children:"SKILL.md 原文"}),e(d,{text:p.text,label:"复制 SKILL.md 原文",className:"size-10"})]}),n("p",{className:"mb-2 text-xs text-faint",children:[p.text.length.toLocaleString()," 字符 · 约 ",Math.ceil(p.text.length/4).toLocaleString()," ","tokens(估算)"]}),e("pre",{className:v("surface.subtle",v("chat.toolOutput"),"rounded-lg bg-raised p-3 text-xs leading-5 break-all"),children:p.text})]}),n("section",{children:[n("h3",{className:"font-medium",children:["目录文件 · ",p.files.length,p.files.length===200?"(最多显示 200 个)":""]}),e("ul",{className:"mt-2 space-y-1 font-mono text-xs text-dim",children:p.files.map((c)=>e("li",{className:"break-all",children:c},c))})]})]})]})}var A="all",G="non-project",te="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent";function me({connection:s}){let{Button:N,Select:S,Dialog:E,style:d,useTheme:v}=y();v();let[w,p]=r([]),[L,P]=r([]),[x,D]=r(A),[z,c]=r([]),[m,I]=r(),[b,O]=r(""),[k,B]=r(),[h,T]=r(!0),[K,R]=r(),[W,H]=r(),u=i(0),j=i(!1),C=g(async(t=!1)=>{let l=++u.current;j.current=!0,T(!0);try{if(t)await s.request("/api/skills/rescan",{method:"POST"});let[a,U,q]=await Promise.all([s.request("/api/skills?all=true"),s.request("/api/skills/settings"),s.request("/api/projects")]);if(l!==u.current)return;p(a.skills),P(q),c(a.issues),I(U),H(new Date),R(void 0)}catch(a){if(l===u.current)R(a instanceof Error?a.message:"读取失败")}finally{if(l===u.current)j.current=!1,T(!1)}},[s]);o(()=>(C(),()=>{u.current++}),[C]);async function V(t){if(j.current)return;j.current=!0;let l=++u.current;T(!0);try{let a=await s.request("/api/skills/settings",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(l!==u.current)return;I(a),await C()}catch(a){if(l!==u.current)return;R(a instanceof Error?a.message:"保存设置失败"),j.current=!1,T(!1)}}let X=b.trim().toLocaleLowerCase(),J=x===A?w:w.filter((t)=>{if(t.scope!=="project")return!0;return x!==G&&t.projectID===x}),M=J.filter((t)=>`${t.name} ${t.description??""}`.toLocaleLowerCase().includes(X)),_=(t)=>z.find((l)=>l.kind==="overridden"&&(l.path==="<built-in>"?t.scope==="builtin":l.path.replace(/\\/g,"/")===`${t.location.replace(/\\/g,"/")}/SKILL.md`));return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[e("h2",{className:d("settings.groupTitle"),children:"技能"}),e("p",{"aria-live":"polite",className:d("settings.groupDesc"),children:W&&`找到 ${J.length} 个 · ${W.toLocaleTimeString("zh-CN",{hour12:!1})}`})]}),n("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e(S,{value:x,disabled:h,onValueChange:(t)=>{B(void 0),D(t)},groups:[{options:[{value:A,label:"全部来源"},{value:G,label:"非项目技能"}]},...Or(L)],className:"w-44"}),n(N,{variant:"ghost",disabled:h,onClick:()=>C(!0),className:"h-9 px-2.5 text-xs",children:[e(Q,{className:`size-3.5 ${h?"animate-spin":""}`}),e("span",{className:"ml-1",children:"重新扫描"})]})]})]}),K&&n("div",{role:"alert",className:"mb-3 flex flex-wrap items-center gap-2 rounded-xl border border-line p-3",children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法更新技能:",K]}),e(N,{disabled:h,onClick:()=>C(),children:"重试"})]}),e($r,{label:"搜索技能",placeholder:"搜索技能",value:b,onChange:O}),e("div",{className:d("settings.groupBox"),children:h&&!w.length?e(Br,{}):M.length===0?e("p",{className:"p-4 text-sm text-dim",children:"没有找到匹配的技能"}):e("ul",{className:"divide-y divide-line",children:M.map((t)=>{let l=_(t),a=t.disabled;return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${a?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看技能 ${t.name}`,onClick:()=>B(t),children:[n("span",{className:"min-w-0 flex-1",children:[n("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e("span",{className:"truncate text-sm font-medium text-ink",title:t.name,children:t.name}),l&&n("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",children:[e(bt,{className:"size-3.5"}),"被覆盖"]})]}),t.description&&e("span",{className:"mt-0.5 block truncate text-xs text-dim",title:t.description,children:t.description})]}),e("span",{className:d("control.badge","shrink-0 text-[11px] text-dim"),children:t.scope==="project"?"项目":t.scope==="builtin"?"built-in":"全局"})]}),e("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:e("input",{type:"checkbox","aria-label":`启用技能 ${t.name}`,className:te,disabled:h,checked:!a,onChange:(U)=>{if(!m)return;let q=m.disabled??[],Y=U.target.checked?q.filter((Z)=>Z!==t.name):[...q,t.name];V({...m,disabled:Y})}})})]},`${t.scope}:${t.projectID??""}:${t.name}`)})})})]}),e(E,{open:Boolean(k),onOpenChange:(t)=>{if(!t)B(void 0)},title:k?.name??"",size:"lg",footer:e("div",{className:"flex w-full justify-end",children:e(N,{variant:"primary",onClick:()=>B(void 0),children:"关闭"})}),children:k&&e(F,{skill:k,issue:_(k),connection:s})})]})}export{me as SkillsSection};
@@ -1 +1 @@
1
- import{o,i,r,vt,f,e,n,y,s,Z,rt,ie,tr,X}from"./chunk-nvt9tkt4.js";var pe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],A=s("at-sign",pe);var ue=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],te=s("file-code-2",ue);var xe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ne=s("maximize-2",xe);var fe=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],J=s("notebook-pen",fe);var be=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],se=s("user",be);var C={approve:{label:"通过",text:"text-success",ring:"ring-success/80",soft:"bg-success/12 text-success"},reject:{label:"反对",text:"text-danger",ring:"ring-danger/80",soft:"bg-danger/12 text-danger"},abstain:{label:"弃权",text:"text-dim",ring:"ring-line-strong",soft:"bg-raised text-dim"},pending:{label:"未表态",text:"text-faint",ring:"ring-line",soft:"bg-raised text-faint"}},ge={thinking:"思考中",reading:"查阅中",speaking:"发言中",idle:"等待中",error:"出错",aborted:"已中止"},U={success:"text-success",warning:"text-warning",danger:"text-danger",neutral:"text-faint"},G={success:"bg-success",warning:"bg-warning",danger:"bg-danger",neutral:"bg-faint"};function q(t){return t==="thinking"||t==="reading"||t==="speaking"}function F(t){let d=q(t.status);return{busy:d,text:d&&t.activeTool?t.activeTool:ge[t.status]}}function Q(t){let d=t.members.filter((v)=>v.verdict==="approve").length,u=t.members.filter((v)=>v.verdict==="reject").length;if(t.state==="running"){if(t.phase==="research")return{tone:"warning",label:"调研中"};if(t.phase==="opening")return{tone:"warning",label:"开场表态"};return{tone:"warning",label:"群聊交流"}}if(t.state==="consensus"){if(d===t.members.length)return{tone:"success",label:"全票通过"};if(u===t.members.length)return{tone:"danger",label:"全票反对"};if(u>d)return{tone:"danger",label:"共识:反对"};return{tone:"success",label:"共识:通过"}}if(t.state==="diverged")return{tone:"warning",label:"存在分歧"};if(t.state==="error")return{tone:"danger",label:"失败"};return{tone:"neutral",label:"已中止"}}function V(t){let d=Math.max(1,Math.round(t/1000));if(d<60)return`${d}s`;return`${Math.floor(d/60)}m ${String(d%60).padStart(2,"0")}s`}var ve={research:"调研",opening:"开场表态",discussion:"群聊交流"};function K(t){let{cn:d}=y(),{room:u}=t,v=Q(u),x=u.state==="running",b=u.research?["research","opening","discussion"]:["opening","discussion"],a=x?b.indexOf(u.phase==="closed"?"discussion":u.phase??"discussion"):-1,c=[...b.map((p,m)=>({key:p,label:ve[p],done:!x||m<a,active:m===a})),{key:"closed",label:x?"结论":v.label,done:!x,active:!1}];return e("ol",{className:d("flex min-w-0 gap-1",t.className),children:c.map((p,m)=>{let N=m===c.length-1&&!x;return n("li",{className:"min-w-0 flex-1",children:[e("span",{className:d("block h-[3px] rounded-full transition-colors duration-300",N?G[v.tone]:p.active?"bg-accent animate-pulse":p.done?"bg-line-strong":"bg-line/60")}),e("span",{className:d("mt-1.5 block truncate text-[11px]",N?d("font-medium",U[v.tone]):p.active?"font-medium text-ink":p.done?"text-dim":"text-faint"),children:p.label})]},p.key)})})}function oe(t){let{Collapsible:d,CollapsibleContent:u,Composer:v,Markdown:x,cn:b,confirm:a}=y(),{room:c,onClose:p}=t,[m,N]=r(!1),[w,M]=r(""),[g,L]=r(!1),[I,O]=r(),[S,H]=r(!1),[E,D]=r(!0),[B,h]=r(),z=i(!1);z.current=B!==void 0;let R=i(null),T=i(null),P=c.state==="running",j=Q(c),re=new Map(c.members.map((l)=>[l.id,l]));o(()=>{let l=(ee)=>{if(ee.key==="Escape"&&!ee.defaultPrevented&&!z.current)N(!0)},k=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),document.body.style.overflow=k}},[]);let Y=c.messages.length;o(()=>{let l=T.current;if(!l||!E||Y===0)return;l.scrollTo({top:l.scrollHeight,behavior:"smooth"})},[Y,E]);let le=async(l)=>{await t.onPost(l),D(!0)},ce=async()=>{if(g)return;if(!await a({title:"中止理事会?",description:"所有成员会立即停止,已有发言保留。",action:"中止",danger:!0}))return;L(!0),O(void 0);try{await t.onAbort()}catch(k){O(k instanceof Error?k.message:"中止理事会失败")}finally{L(!1)}},W=(l)=>{M((k)=>k.includes(`@${l}`)?k:`${k?`${k.trimEnd()} `:""}@${l} `),R.current?.focus()},me=c.members.filter((l)=>l.verdict==="approve").length,de=c.members.filter((l)=>l.verdict==="reject").length,_=c.members.find((l)=>l.id===B);return vt(n("div",{role:"dialog","aria-modal":"true","aria-label":`理事会:${c.topic}`,onAnimationEnd:(l)=>{if(m&&l.target===l.currentTarget)p()},className:b("fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] text-ink",m?"pointer-events-none animate-dialog-out":"animate-dialog-in"),children:[n(d,{open:S,onOpenChange:H,className:"shrink-0 border-b border-line px-4 pt-3 pb-3 sm:px-6",children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-3 text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-[0.2em] text-dim",children:"COUNCIL"}),e("span",{className:"tabular-nums",children:V(t.elapsedMs)}),n("span",{className:"tabular-nums",children:[c.messages.length," 条发言"]})]}),n("button",{type:"button","aria-expanded":S,onClick:()=>H((l)=>!l),className:"mt-0.5 flex max-w-full cursor-pointer items-start gap-1.5 text-left md:items-center",children:[e("h2",{className:"line-clamp-2 text-[15px] leading-snug font-semibold md:truncate md:text-lg",children:c.topic}),e(ie,{className:b("mt-0.5 size-4 shrink-0 text-faint transition-transform duration-300 ease-out-quint md:mt-0",!S&&"-rotate-90")})]})]}),n("div",{className:"flex shrink-0 items-center gap-1",children:[n("span",{className:b("inline-flex items-center gap-1.5 rounded-full border border-line px-2.5 py-1 text-xs font-medium",U[j.tone]),children:[e("span",{className:b("size-1.5 rounded-full",G[j.tone],P&&"animate-pulse")}),j.label]}),e("button",{type:"button","aria-label":"关闭理事会页面",title:"关闭(Esc)",onClick:()=>N(!0),className:"ml-1 inline-flex size-10 -mr-2 cursor-pointer items-center justify-center rounded-full text-faint transition-colors hover:bg-raised hover:text-ink md:size-8 md:mr-0",children:e(X,{className:"size-4"})})]})]}),e(u,{children:e("div",{className:"mt-2 max-h-[40dvh] overflow-y-auto overscroll-contain rounded-xl bg-panel px-3.5 py-2.5 text-[13px] leading-relaxed text-dim md:max-h-48",children:e(x,{text:c.brief})})}),e(K,{room:c,className:"mt-3"})]}),n("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[e("div",{className:"flex shrink-0 gap-2 overflow-x-auto overscroll-x-contain border-b border-line px-4 py-2.5 [scrollbar-width:none] md:hidden",children:c.members.map((l)=>e(he,{member:l,onSelect:()=>h(l.id)},l.id))}),n("aside",{className:"hidden w-72 shrink-0 flex-col gap-2 overflow-y-auto border-r border-line p-4 md:flex",children:[n("div",{className:"flex items-center justify-between text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-wide",children:"席位"}),n("span",{className:"tabular-nums",children:[e("span",{className:"text-success",children:me})," / ",e("span",{className:"text-danger",children:de})," /"," ",c.members.length]})]}),c.members.map((l)=>e(ye,{member:l,onMention:()=>W(l.name),onOpen:()=>t.onOpenMember(l.childSessionID)},l.id))]}),n("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e("div",{ref:T,onScroll:(l)=>{let k=l.currentTarget;D(k.scrollHeight-k.scrollTop-k.clientHeight<80)},className:"min-h-0 flex-1 overflow-y-auto",children:n("div",{className:"mx-auto w-full max-w-3xl px-4 py-4 sm:px-6 md:py-5",children:[c.messages.length===0?n("div",{className:"flex flex-col items-center justify-center gap-3 py-24 text-center text-faint",children:[P?e(Z,{className:"size-5 animate-spin"}):null,e("p",{className:"text-sm",children:P?c.phase==="research"?"成员正在各自调研,笔记不会进入群聊":"成员正在独立准备开场观点,彼此不可见":"这场理事会没有产生发言"})]}):e("ol",{className:"space-y-5",children:c.messages.map((l)=>e(ke,{message:l,membersByID:re,onMention:()=>W(l.senderName)},l.floor))}),c.summary&&!P&&n("section",{className:"mt-8 rounded-2xl border border-line bg-panel px-4 py-3",children:[n("h3",{className:b("text-xs font-semibold",U[j.tone]),children:["结论:",j.label]}),e("div",{className:"mt-1.5 text-[13px] leading-relaxed text-dim",children:e(x,{text:c.summary})})]})]})}),e("div",{className:"shrink-0 px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6 md:pb-4",children:n("div",{className:"mx-auto w-full max-w-3xl",children:[I&&e("p",{role:"status",className:"px-1 pb-2 text-[13px] text-danger",children:I}),e(v,{draftKey:`council:${c.roomID}`,placeholder:P?"插话,@ 某位成员会点名要求其回应":"理事会已结束,插话会重新唤醒成员",busy:P,allowAttachments:!1,text:w,onTextChange:M,inputRef:R,onSend:le,onAbort:()=>void ce()})]})})]})]}),_&&e(Ne,{member:_,onClose:()=>h(void 0),onMention:()=>{h(void 0),W(_.name)},onOpen:()=>t.onOpenMember(_.childSessionID)})]}),document.body)}function he(t){let{ModelIcon:d,cn:u}=y(),{member:v}=t,x=C[v.verdict]??C.pending,{busy:b}=F(v);return n("button",{type:"button",onClick:t.onSelect,"aria-label":`${v.name},${x.label},查看详情`,className:"flex h-11 max-w-[11rem] shrink-0 cursor-pointer items-center gap-2 rounded-full border border-line bg-panel/60 pr-3.5 pl-1.5 active:bg-raised",children:[n("span",{className:u("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",x.ring),children:[e(d,{modelID:v.model,className:"size-4",size:16}),b&&e(Z,{className:"absolute -right-1 -bottom-1 size-3.5 animate-spin rounded-full bg-bg text-accent"})]}),n("span",{className:"min-w-0 text-left leading-tight",children:[e("span",{className:"block truncate text-[13px] font-medium",children:v.name}),e("span",{className:u("block text-[11px]",x.text),children:x.label})]})]})}function Ne(t){let{Button:d,Dialog:u,Markdown:v,ModelIcon:x,cn:b}=y(),{member:a}=t,c=C[a.verdict]??C.pending,p=F(a);return e(u,{open:!0,onOpenChange:(m)=>!m&&t.onClose(),title:n("span",{className:"flex min-w-0 items-center gap-2.5",children:[e("span",{className:b("flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",c.ring),children:e(x,{modelID:a.model,className:"size-4",size:16})}),e("span",{className:"min-w-0 truncate",children:a.name}),e("span",{className:b("shrink-0 rounded px-1.5 py-px text-[11px] font-medium",c.soft),children:c.label})]}),description:a.model,footer:n(f,{children:[n(d,{variant:"secondary",onClick:t.onMention,children:[e(A,{className:"size-4"}),"点名"]}),n(d,{variant:"secondary",onClick:t.onOpen,children:[e(rt,{className:"size-4"}),"查看推理"]})]}),children:n("div",{className:"space-y-3 pb-1",children:[n("div",{className:"flex items-center gap-3 text-[13px]",children:[n("span",{className:b("flex min-w-0 flex-1 items-center gap-1.5",p.busy?"text-accent":"text-dim"),children:[p.busy&&e(Z,{className:"size-3.5 shrink-0 animate-spin"}),e("span",{className:"truncate",children:p.text})]}),n("span",{className:"shrink-0 text-faint tabular-nums",children:["发言 ",a.turns??0," 次"]})]}),a.notes?n("section",{children:[n("h3",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-faint",children:[e(J,{className:"size-3.5"}),"调研笔记"]}),e("div",{className:"rounded-xl bg-bg/60 px-3.5 py-2.5 text-[13px] leading-relaxed text-dim",children:e(v,{text:a.notes})})]}):e("p",{className:"text-[13px] text-faint",children:"没有调研笔记"})]})})}function ye(t){let{Collapsible:d,CollapsibleContent:u,Markdown:v,ModelIcon:x,cn:b}=y(),{member:a}=t,[c,p]=r(!1),m=C[a.verdict]??C.pending,{busy:N,text:w}=F(a);return n(d,{open:c,onOpenChange:p,className:"shrink-0 rounded-xl border border-line bg-panel/60 p-2.5",children:[n("div",{className:"flex items-center gap-2.5",children:[e("span",{className:b("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",m.ring),children:e(x,{modelID:a.model,className:"size-4",size:16})}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"truncate text-[13px] font-medium",title:a.model,children:a.name}),e("span",{className:b("shrink-0 rounded px-1 text-[10.5px] font-medium",m.soft),children:m.label})]}),n("div",{className:b("flex min-w-0 items-center gap-1 text-[11px]",N?"text-accent":"text-faint"),children:[N&&e(Z,{className:"size-3 shrink-0 animate-spin"}),e("span",{className:"truncate",children:w})]})]})]}),n("div",{className:"mt-2 flex items-center gap-1 text-[11px] text-faint",children:[n("span",{className:"tabular-nums",children:["发言 ",a.turns??0," 次"]}),e("span",{className:"ml-auto"}),a.notes&&n("button",{type:"button","aria-expanded":c,onClick:()=>p((M)=>!M),className:b("inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 hover:bg-raised hover:text-ink",c&&"text-ink"),children:[e(J,{className:"size-3"}),"笔记"]}),e("button",{type:"button","aria-label":`@ ${a.name}`,title:`@ ${a.name}`,onClick:t.onMention,className:"inline-flex cursor-pointer items-center rounded p-1 hover:bg-raised hover:text-ink",children:e(A,{className:"size-3"})}),e("button",{type:"button","aria-label":`查看 ${a.name} 的推理过程`,title:"查看推理与工具调用",onClick:t.onOpen,className:"inline-flex cursor-pointer items-center rounded p-1 hover:bg-raised hover:text-ink",children:e(rt,{className:"size-3"})})]}),a.notes&&e(u,{children:e("div",{className:"mt-2 max-h-56 overflow-y-auto rounded-lg bg-bg/60 px-2.5 py-2 text-xs leading-relaxed text-dim",children:e(v,{text:a.notes})})})]})}function ke(t){let{Code:d,Collapsible:u,CollapsibleContent:v,Markdown:x,cn:b}=y(),{message:a}=t,[c,p]=r(!1),m=a.senderID==="user"||a.senderID==="host",N=a.verdict&&a.verdict!=="pending"?C[a.verdict]:void 0,w=a.evidences??[],M=(a.mentions??[]).map((g)=>t.membersByID.get(g)).filter((g)=>g!==void 0);return n("li",{id:`council-floor-${a.floor}`,className:"group flex gap-3 animate-fade",children:[e(ae,{message:a,isHuman:m,className:"mt-0.5 hidden size-8 md:flex"}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs",children:[e(ae,{message:a,isHuman:m,className:"flex size-6 md:hidden"}),e("span",{className:"font-semibold text-ink",title:a.senderModel,children:a.senderName}),n("a",{href:`#council-floor-${a.floor}`,className:"font-mono text-[11px] text-faint hover:text-dim",onClick:(g)=>g.preventDefault(),children:["#",a.floor]}),N&&e("span",{className:b("rounded px-1.5 py-px text-[10.5px] font-medium",N.soft),children:N.label}),!m&&n("button",{type:"button",onClick:t.onMention,className:"ml-auto inline-flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-[11px] text-faint transition-opacity hover:bg-raised hover:text-ink focus-visible:opacity-100 md:px-1.5 md:py-0.5 md:opacity-0 md:group-hover:opacity-100",children:[e(A,{className:"size-3"}),"回复"]})]}),(a.replyToFloor||M.length>0)&&n("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-faint",children:[a.replyToFloor&&n("button",{type:"button",onClick:()=>document.getElementById(`council-floor-${a.replyToFloor}`)?.scrollIntoView({block:"center",behavior:"smooth"}),className:"inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-md bg-raised/70 px-1.5 py-0.5 hover:text-ink",children:[e(tr,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0 text-dim",children:["#",a.replyToFloor," ",a.replyToName]}),a.replyToPreview&&e("span",{className:"truncate",children:a.replyToPreview})]}),M.map((g)=>n("span",{className:"inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-accent",children:[e(A,{className:"size-3"}),g.name]},g.id))]}),e("div",{className:"mt-1.5 break-words text-[14px] leading-relaxed text-ink/90 md:text-[13.5px] [&_p]:my-1.5 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:e(x,{text:a.text})}),w.length>0&&n(u,{open:c,onOpenChange:p,className:"mt-2",children:[n("button",{type:"button","aria-expanded":c,onClick:()=>p((g)=>!g),className:"inline-flex max-w-full cursor-pointer items-center gap-1 text-[11px] text-faint hover:text-ink",children:[e(te,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0",children:["查阅 ",w.length," 处"]}),!c&&e("span",{className:"truncate font-mono",children:w.map((g)=>g.label).join(",")}),e(ie,{className:b("size-3 shrink-0 transition-transform duration-300 ease-out-quint",!c&&"-rotate-90")})]}),e(v,{children:e("div",{className:"mt-1.5 space-y-1.5",children:w.map((g)=>n("div",{className:"overflow-hidden rounded-lg border border-line bg-panel text-xs",children:[e("div",{className:"truncate border-b border-line/70 px-2.5 py-1 font-mono text-[11px] text-dim",children:g.label}),g.snippet&&e(d,{code:g.snippet,lang:g.lang||"ts",className:"max-h-40 overflow-auto px-2.5 py-1.5 text-[11.5px]"})]},`${g.tool}:${g.label}:${g.snippet?.slice(0,32)??""}`))})})]})]})]})}function ae(t){let{ModelIcon:d,cn:u}=y();return e("span",{className:u("shrink-0 items-center justify-center rounded-full",t.isHuman?"bg-accent/12 text-accent":"bg-raised",t.className),children:t.message.senderModel?e(d,{modelID:t.message.senderModel,className:"size-4",size:16}):e(se,{className:"size-4"})})}function Je(t){let{ModelIcon:d,cn:u,useTheme:v}=y();v();let{connection:x,sessionID:b,payload:a,onOpen:c}=t,p=a,[m,N]=r(p),[w,M]=r(!1),[g,L]=r(Date.now);o(()=>{N(p)},[p]);let I=m.state==="running",O=`/api/sessions/${encodeURIComponent(b)}/council/${encodeURIComponent(m.roomID)}`;o(()=>{if(!I)return;let h=!1,R=setInterval(()=>{if(x.request(O).then((T)=>{if(!h&&T&&typeof T==="object"&&"roomID"in T)N(T)}).catch(()=>{}),!h)L(Date.now())},1200);return()=>{h=!0,clearInterval(R)}},[x,O,I]);let S=async(h)=>{let z=await x.request(`${O}/post`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:h})});N(z)},H=async()=>{let h=await x.request(`${O}/kill`,{method:"POST"});N(h)},E=(I?g:m.updatedAt)-m.createdAt,D=m.messages.at(-1),B=m.members.filter((h)=>q(h.status)).length;return n(f,{children:[n("button",{type:"button","aria-label":`进入理事会:${m.topic}`,onClick:()=>M(!0),className:"group relative my-2 block w-full cursor-pointer overflow-hidden rounded-2xl border border-line bg-panel text-left transition-colors hover:border-line-strong animate-fade",children:[n("div",{className:"px-4 pt-3.5",children:[n("div",{className:"flex items-center gap-1.5 text-[11px] text-faint",children:[e("span",{className:"font-medium text-dim",children:"理事会"}),e("span",{"aria-hidden":!0,children:"·"}),e("span",{className:"tabular-nums",children:V(E)}),n("span",{className:"ml-auto tabular-nums",children:[m.members.length," 位成员"]})]}),e("h4",{className:"mt-1 line-clamp-2 text-sm font-semibold text-ink md:truncate",title:m.topic,children:m.topic})]}),e(K,{room:m,className:"mt-3 px-4"}),e("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-4",children:m.members.map((h)=>{let z=C[h.verdict]??C.pending,R=q(h.status);return n("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",title:h.model,children:[n("span",{className:u("relative flex size-6 shrink-0 items-center justify-center rounded-full bg-raised ring-2",z.ring),children:[e(d,{modelID:h.model,className:"size-3.5",size:14}),R&&e(Z,{className:"absolute -right-1 -bottom-1 size-3 animate-spin rounded-full bg-panel text-accent"})]}),e("span",{className:"truncate text-dim",children:h.name}),e("span",{className:u("shrink-0 text-[11px]",z.text),children:z.label})]},h.id)})}),n("div",{className:"mt-3 flex items-center gap-2 border-t border-line/70 px-4 py-2.5 text-xs",children:[D?n(f,{children:[e("span",{className:"shrink-0 font-medium text-dim",children:D.senderName}),e("span",{className:"min-w-0 flex-1 truncate text-faint",children:D.text.replace(/\s+/g," ")})]}):e("span",{className:"min-w-0 flex-1 truncate text-faint",children:I?`${B} 位成员正在${m.phase==="research"?"调研":"思考"}…`:"没有发言"}),n("span",{className:"inline-flex shrink-0 items-center gap-1 text-faint transition-colors group-hover:text-ink",children:[m.messages.length>0&&n("span",{className:"tabular-nums",children:[m.messages.length," 条"]}),e(ne,{className:"size-3.5"})]})]})]}),w&&e(oe,{room:m,elapsedMs:E,onClose:()=>M(!1),onOpenMember:c,onPost:S,onAbort:H})]})}export{Je as CouncilCard};
1
+ import{o,i,r,rt,f,e,n,y,s,Z,at,ie,tr,X}from"./chunk-ngt1j8py.js";var pe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],A=s("at-sign",pe);var ue=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],te=s("file-code-2",ue);var xe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ne=s("maximize-2",xe);var fe=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],J=s("notebook-pen",fe);var be=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],se=s("user",be);var C={approve:{label:"通过",text:"text-success",ring:"ring-success/80",soft:"bg-success/12 text-success"},reject:{label:"反对",text:"text-danger",ring:"ring-danger/80",soft:"bg-danger/12 text-danger"},abstain:{label:"弃权",text:"text-dim",ring:"ring-line-strong",soft:"bg-raised text-dim"},pending:{label:"未表态",text:"text-faint",ring:"ring-line",soft:"bg-raised text-faint"}},ge={thinking:"思考中",reading:"查阅中",speaking:"发言中",idle:"等待中",error:"出错",aborted:"已中止"},U={success:"text-success",warning:"text-warning",danger:"text-danger",neutral:"text-faint"},G={success:"bg-success",warning:"bg-warning",danger:"bg-danger",neutral:"bg-faint"};function q(t){return t==="thinking"||t==="reading"||t==="speaking"}function F(t){let d=q(t.status);return{busy:d,text:d&&t.activeTool?t.activeTool:ge[t.status]}}function Q(t){let d=t.members.filter((v)=>v.verdict==="approve").length,u=t.members.filter((v)=>v.verdict==="reject").length;if(t.state==="running"){if(t.phase==="research")return{tone:"warning",label:"调研中"};if(t.phase==="opening")return{tone:"warning",label:"开场表态"};return{tone:"warning",label:"群聊交流"}}if(t.state==="consensus"){if(d===t.members.length)return{tone:"success",label:"全票通过"};if(u===t.members.length)return{tone:"danger",label:"全票反对"};if(u>d)return{tone:"danger",label:"共识:反对"};return{tone:"success",label:"共识:通过"}}if(t.state==="diverged")return{tone:"warning",label:"存在分歧"};if(t.state==="error")return{tone:"danger",label:"失败"};return{tone:"neutral",label:"已中止"}}function V(t){let d=Math.max(1,Math.round(t/1000));if(d<60)return`${d}s`;return`${Math.floor(d/60)}m ${String(d%60).padStart(2,"0")}s`}var ve={research:"调研",opening:"开场表态",discussion:"群聊交流"};function K(t){let{cn:d}=y(),{room:u}=t,v=Q(u),x=u.state==="running",b=u.research?["research","opening","discussion"]:["opening","discussion"],a=x?b.indexOf(u.phase==="closed"?"discussion":u.phase??"discussion"):-1,c=[...b.map((p,m)=>({key:p,label:ve[p],done:!x||m<a,active:m===a})),{key:"closed",label:x?"结论":v.label,done:!x,active:!1}];return e("ol",{className:d("flex min-w-0 gap-1",t.className),children:c.map((p,m)=>{let N=m===c.length-1&&!x;return n("li",{className:"min-w-0 flex-1",children:[e("span",{className:d("block h-[3px] rounded-full transition-colors duration-300",N?G[v.tone]:p.active?"bg-accent animate-pulse":p.done?"bg-line-strong":"bg-line/60")}),e("span",{className:d("mt-1.5 block truncate text-[11px]",N?d("font-medium",U[v.tone]):p.active?"font-medium text-ink":p.done?"text-dim":"text-faint"),children:p.label})]},p.key)})})}function oe(t){let{Collapsible:d,CollapsibleContent:u,Composer:v,Markdown:x,cn:b,confirm:a}=y(),{room:c,onClose:p}=t,[m,N]=r(!1),[w,M]=r(""),[g,L]=r(!1),[I,O]=r(),[S,H]=r(!1),[E,D]=r(!0),[B,h]=r(),z=i(!1);z.current=B!==void 0;let R=i(null),T=i(null),P=c.state==="running",j=Q(c),re=new Map(c.members.map((l)=>[l.id,l]));o(()=>{let l=(ee)=>{if(ee.key==="Escape"&&!ee.defaultPrevented&&!z.current)N(!0)},k=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),document.body.style.overflow=k}},[]);let Y=c.messages.length;o(()=>{let l=T.current;if(!l||!E||Y===0)return;l.scrollTo({top:l.scrollHeight,behavior:"smooth"})},[Y,E]);let le=async(l)=>{await t.onPost(l),D(!0)},ce=async()=>{if(g)return;if(!await a({title:"中止理事会?",description:"所有成员会立即停止,已有发言保留。",action:"中止",danger:!0}))return;L(!0),O(void 0);try{await t.onAbort()}catch(k){O(k instanceof Error?k.message:"中止理事会失败")}finally{L(!1)}},W=(l)=>{M((k)=>k.includes(`@${l}`)?k:`${k?`${k.trimEnd()} `:""}@${l} `),R.current?.focus()},me=c.members.filter((l)=>l.verdict==="approve").length,de=c.members.filter((l)=>l.verdict==="reject").length,_=c.members.find((l)=>l.id===B);return rt(n("div",{role:"dialog","aria-modal":"true","aria-label":`理事会:${c.topic}`,onAnimationEnd:(l)=>{if(m&&l.target===l.currentTarget)p()},className:b("fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] text-ink",m?"pointer-events-none animate-dialog-out":"animate-dialog-in"),children:[n(d,{open:S,onOpenChange:H,className:"shrink-0 border-b border-line px-4 pt-3 pb-3 sm:px-6",children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-3 text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-[0.2em] text-dim",children:"COUNCIL"}),e("span",{className:"tabular-nums",children:V(t.elapsedMs)}),n("span",{className:"tabular-nums",children:[c.messages.length," 条发言"]})]}),n("button",{type:"button","aria-expanded":S,onClick:()=>H((l)=>!l),className:"mt-0.5 flex max-w-full cursor-pointer items-start gap-1.5 text-left md:items-center",children:[e("h2",{className:"line-clamp-2 text-[15px] leading-snug font-semibold md:truncate md:text-lg",children:c.topic}),e(ie,{className:b("mt-0.5 size-4 shrink-0 text-faint transition-transform duration-300 ease-out-quint md:mt-0",!S&&"-rotate-90")})]})]}),n("div",{className:"flex shrink-0 items-center gap-1",children:[n("span",{className:b("inline-flex items-center gap-1.5 rounded-full border border-line px-2.5 py-1 text-xs font-medium",U[j.tone]),children:[e("span",{className:b("size-1.5 rounded-full",G[j.tone],P&&"animate-pulse")}),j.label]}),e("button",{type:"button","aria-label":"关闭理事会页面",title:"关闭(Esc)",onClick:()=>N(!0),className:"ml-1 inline-flex size-10 -mr-2 cursor-pointer items-center justify-center rounded-full text-faint transition-colors hover:bg-raised hover:text-ink md:size-8 md:mr-0",children:e(X,{className:"size-4"})})]})]}),e(u,{children:e("div",{className:"mt-2 max-h-[40dvh] overflow-y-auto overscroll-contain rounded-xl bg-panel px-3.5 py-2.5 text-[13px] leading-relaxed text-dim md:max-h-48",children:e(x,{text:c.brief})})}),e(K,{room:c,className:"mt-3"})]}),n("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[e("div",{className:"flex shrink-0 gap-2 overflow-x-auto overscroll-x-contain border-b border-line px-4 py-2.5 [scrollbar-width:none] md:hidden",children:c.members.map((l)=>e(he,{member:l,onSelect:()=>h(l.id)},l.id))}),n("aside",{className:"hidden w-72 shrink-0 flex-col gap-2 overflow-y-auto border-r border-line p-4 md:flex",children:[n("div",{className:"flex items-center justify-between text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-wide",children:"席位"}),n("span",{className:"tabular-nums",children:[e("span",{className:"text-success",children:me})," / ",e("span",{className:"text-danger",children:de})," /"," ",c.members.length]})]}),c.members.map((l)=>e(ye,{member:l,onMention:()=>W(l.name),onOpen:()=>t.onOpenMember(l.childSessionID)},l.id))]}),n("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e("div",{ref:T,onScroll:(l)=>{let k=l.currentTarget;D(k.scrollHeight-k.scrollTop-k.clientHeight<80)},className:"min-h-0 flex-1 overflow-y-auto",children:n("div",{className:"mx-auto w-full max-w-3xl px-4 py-4 sm:px-6 md:py-5",children:[c.messages.length===0?n("div",{className:"flex flex-col items-center justify-center gap-3 py-24 text-center text-faint",children:[P?e(Z,{className:"size-5 animate-spin"}):null,e("p",{className:"text-sm",children:P?c.phase==="research"?"成员正在各自调研,笔记不会进入群聊":"成员正在独立准备开场观点,彼此不可见":"这场理事会没有产生发言"})]}):e("ol",{className:"space-y-5",children:c.messages.map((l)=>e(ke,{message:l,membersByID:re,onMention:()=>W(l.senderName)},l.floor))}),c.summary&&!P&&n("section",{className:"mt-8 rounded-2xl border border-line bg-panel px-4 py-3",children:[n("h3",{className:b("text-xs font-semibold",U[j.tone]),children:["结论:",j.label]}),e("div",{className:"mt-1.5 text-[13px] leading-relaxed text-dim",children:e(x,{text:c.summary})})]})]})}),e("div",{className:"shrink-0 px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6 md:pb-4",children:n("div",{className:"mx-auto w-full max-w-3xl",children:[I&&e("p",{role:"status",className:"px-1 pb-2 text-[13px] text-danger",children:I}),e(v,{draftKey:`council:${c.roomID}`,placeholder:P?"插话,@ 某位成员会点名要求其回应":"理事会已结束,插话会重新唤醒成员",busy:P,allowAttachments:!1,text:w,onTextChange:M,inputRef:R,onSend:le,onAbort:()=>void ce()})]})})]})]}),_&&e(Ne,{member:_,onClose:()=>h(void 0),onMention:()=>{h(void 0),W(_.name)},onOpen:()=>t.onOpenMember(_.childSessionID)})]}),document.body)}function he(t){let{ModelIcon:d,cn:u}=y(),{member:v}=t,x=C[v.verdict]??C.pending,{busy:b}=F(v);return n("button",{type:"button",onClick:t.onSelect,"aria-label":`${v.name},${x.label},查看详情`,className:"flex h-11 max-w-[11rem] shrink-0 cursor-pointer items-center gap-2 rounded-full border border-line bg-panel/60 pr-3.5 pl-1.5 active:bg-raised",children:[n("span",{className:u("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",x.ring),children:[e(d,{modelID:v.model,className:"size-4",size:16}),b&&e(Z,{className:"absolute -right-1 -bottom-1 size-3.5 animate-spin rounded-full bg-bg text-accent"})]}),n("span",{className:"min-w-0 text-left leading-tight",children:[e("span",{className:"block truncate text-[13px] font-medium",children:v.name}),e("span",{className:u("block text-[11px]",x.text),children:x.label})]})]})}function Ne(t){let{Button:d,Dialog:u,Markdown:v,ModelIcon:x,cn:b}=y(),{member:a}=t,c=C[a.verdict]??C.pending,p=F(a);return e(u,{open:!0,onOpenChange:(m)=>!m&&t.onClose(),title:n("span",{className:"flex min-w-0 items-center gap-2.5",children:[e("span",{className:b("flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",c.ring),children:e(x,{modelID:a.model,className:"size-4",size:16})}),e("span",{className:"min-w-0 truncate",children:a.name}),e("span",{className:b("shrink-0 rounded px-1.5 py-px text-[11px] font-medium",c.soft),children:c.label})]}),description:a.model,footer:n(f,{children:[n(d,{variant:"secondary",onClick:t.onMention,children:[e(A,{className:"size-4"}),"点名"]}),n(d,{variant:"secondary",onClick:t.onOpen,children:[e(at,{className:"size-4"}),"查看推理"]})]}),children:n("div",{className:"space-y-3 pb-1",children:[n("div",{className:"flex items-center gap-3 text-[13px]",children:[n("span",{className:b("flex min-w-0 flex-1 items-center gap-1.5",p.busy?"text-accent":"text-dim"),children:[p.busy&&e(Z,{className:"size-3.5 shrink-0 animate-spin"}),e("span",{className:"truncate",children:p.text})]}),n("span",{className:"shrink-0 text-faint tabular-nums",children:["发言 ",a.turns??0," 次"]})]}),a.notes?n("section",{children:[n("h3",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-faint",children:[e(J,{className:"size-3.5"}),"调研笔记"]}),e("div",{className:"rounded-xl bg-bg/60 px-3.5 py-2.5 text-[13px] leading-relaxed text-dim",children:e(v,{text:a.notes})})]}):e("p",{className:"text-[13px] text-faint",children:"没有调研笔记"})]})})}function ye(t){let{Collapsible:d,CollapsibleContent:u,Markdown:v,ModelIcon:x,cn:b}=y(),{member:a}=t,[c,p]=r(!1),m=C[a.verdict]??C.pending,{busy:N,text:w}=F(a);return n(d,{open:c,onOpenChange:p,className:"shrink-0 rounded-xl border border-line bg-panel/60 p-2.5",children:[n("div",{className:"flex items-center gap-2.5",children:[e("span",{className:b("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",m.ring),children:e(x,{modelID:a.model,className:"size-4",size:16})}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"truncate text-[13px] font-medium",title:a.model,children:a.name}),e("span",{className:b("shrink-0 rounded px-1 text-[10.5px] font-medium",m.soft),children:m.label})]}),n("div",{className:b("flex min-w-0 items-center gap-1 text-[11px]",N?"text-accent":"text-faint"),children:[N&&e(Z,{className:"size-3 shrink-0 animate-spin"}),e("span",{className:"truncate",children:w})]})]})]}),n("div",{className:"mt-2 flex items-center gap-1 text-[11px] text-faint",children:[n("span",{className:"tabular-nums",children:["发言 ",a.turns??0," 次"]}),e("span",{className:"ml-auto"}),a.notes&&n("button",{type:"button","aria-expanded":c,onClick:()=>p((M)=>!M),className:b("inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 hover:bg-raised hover:text-ink",c&&"text-ink"),children:[e(J,{className:"size-3"}),"笔记"]}),e("button",{type:"button","aria-label":`@ ${a.name}`,title:`@ ${a.name}`,onClick:t.onMention,className:"inline-flex cursor-pointer items-center rounded p-1 hover:bg-raised hover:text-ink",children:e(A,{className:"size-3"})}),e("button",{type:"button","aria-label":`查看 ${a.name} 的推理过程`,title:"查看推理与工具调用",onClick:t.onOpen,className:"inline-flex cursor-pointer items-center rounded p-1 hover:bg-raised hover:text-ink",children:e(at,{className:"size-3"})})]}),a.notes&&e(u,{children:e("div",{className:"mt-2 max-h-56 overflow-y-auto rounded-lg bg-bg/60 px-2.5 py-2 text-xs leading-relaxed text-dim",children:e(v,{text:a.notes})})})]})}function ke(t){let{Code:d,Collapsible:u,CollapsibleContent:v,Markdown:x,cn:b}=y(),{message:a}=t,[c,p]=r(!1),m=a.senderID==="user"||a.senderID==="host",N=a.verdict&&a.verdict!=="pending"?C[a.verdict]:void 0,w=a.evidences??[],M=(a.mentions??[]).map((g)=>t.membersByID.get(g)).filter((g)=>g!==void 0);return n("li",{id:`council-floor-${a.floor}`,className:"group flex gap-3 animate-fade",children:[e(ae,{message:a,isHuman:m,className:"mt-0.5 hidden size-8 md:flex"}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs",children:[e(ae,{message:a,isHuman:m,className:"flex size-6 md:hidden"}),e("span",{className:"font-semibold text-ink",title:a.senderModel,children:a.senderName}),n("a",{href:`#council-floor-${a.floor}`,className:"font-mono text-[11px] text-faint hover:text-dim",onClick:(g)=>g.preventDefault(),children:["#",a.floor]}),N&&e("span",{className:b("rounded px-1.5 py-px text-[10.5px] font-medium",N.soft),children:N.label}),!m&&n("button",{type:"button",onClick:t.onMention,className:"ml-auto inline-flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-[11px] text-faint transition-opacity hover:bg-raised hover:text-ink focus-visible:opacity-100 md:px-1.5 md:py-0.5 md:opacity-0 md:group-hover:opacity-100",children:[e(A,{className:"size-3"}),"回复"]})]}),(a.replyToFloor||M.length>0)&&n("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-faint",children:[a.replyToFloor&&n("button",{type:"button",onClick:()=>document.getElementById(`council-floor-${a.replyToFloor}`)?.scrollIntoView({block:"center",behavior:"smooth"}),className:"inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-md bg-raised/70 px-1.5 py-0.5 hover:text-ink",children:[e(tr,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0 text-dim",children:["#",a.replyToFloor," ",a.replyToName]}),a.replyToPreview&&e("span",{className:"truncate",children:a.replyToPreview})]}),M.map((g)=>n("span",{className:"inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-accent",children:[e(A,{className:"size-3"}),g.name]},g.id))]}),e("div",{className:"mt-1.5 break-words text-[14px] leading-relaxed text-ink/90 md:text-[13.5px] [&_p]:my-1.5 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:e(x,{text:a.text})}),w.length>0&&n(u,{open:c,onOpenChange:p,className:"mt-2",children:[n("button",{type:"button","aria-expanded":c,onClick:()=>p((g)=>!g),className:"inline-flex max-w-full cursor-pointer items-center gap-1 text-[11px] text-faint hover:text-ink",children:[e(te,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0",children:["查阅 ",w.length," 处"]}),!c&&e("span",{className:"truncate font-mono",children:w.map((g)=>g.label).join(",")}),e(ie,{className:b("size-3 shrink-0 transition-transform duration-300 ease-out-quint",!c&&"-rotate-90")})]}),e(v,{children:e("div",{className:"mt-1.5 space-y-1.5",children:w.map((g)=>n("div",{className:"overflow-hidden rounded-lg border border-line bg-panel text-xs",children:[e("div",{className:"truncate border-b border-line/70 px-2.5 py-1 font-mono text-[11px] text-dim",children:g.label}),g.snippet&&e(d,{code:g.snippet,lang:g.lang||"ts",className:"max-h-40 overflow-auto px-2.5 py-1.5 text-[11.5px]"})]},`${g.tool}:${g.label}:${g.snippet?.slice(0,32)??""}`))})})]})]})]})}function ae(t){let{ModelIcon:d,cn:u}=y();return e("span",{className:u("shrink-0 items-center justify-center rounded-full",t.isHuman?"bg-accent/12 text-accent":"bg-raised",t.className),children:t.message.senderModel?e(d,{modelID:t.message.senderModel,className:"size-4",size:16}):e(se,{className:"size-4"})})}function Je(t){let{ModelIcon:d,cn:u,useTheme:v}=y();v();let{connection:x,sessionID:b,payload:a,onOpen:c}=t,p=a,[m,N]=r(p),[w,M]=r(!1),[g,L]=r(Date.now);o(()=>{N(p)},[p]);let I=m.state==="running",O=`/api/sessions/${encodeURIComponent(b)}/council/${encodeURIComponent(m.roomID)}`;o(()=>{if(!I)return;let h=!1,R=setInterval(()=>{if(x.request(O).then((T)=>{if(!h&&T&&typeof T==="object"&&"roomID"in T)N(T)}).catch(()=>{}),!h)L(Date.now())},1200);return()=>{h=!0,clearInterval(R)}},[x,O,I]);let S=async(h)=>{let z=await x.request(`${O}/post`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:h})});N(z)},H=async()=>{let h=await x.request(`${O}/kill`,{method:"POST"});N(h)},E=(I?g:m.updatedAt)-m.createdAt,D=m.messages.at(-1),B=m.members.filter((h)=>q(h.status)).length;return n(f,{children:[n("button",{type:"button","aria-label":`进入理事会:${m.topic}`,onClick:()=>M(!0),className:"group relative my-2 block w-full cursor-pointer overflow-hidden rounded-2xl border border-line bg-panel text-left transition-colors hover:border-line-strong animate-fade",children:[n("div",{className:"px-4 pt-3.5",children:[n("div",{className:"flex items-center gap-1.5 text-[11px] text-faint",children:[e("span",{className:"font-medium text-dim",children:"理事会"}),e("span",{"aria-hidden":!0,children:"·"}),e("span",{className:"tabular-nums",children:V(E)}),n("span",{className:"ml-auto tabular-nums",children:[m.members.length," 位成员"]})]}),e("h4",{className:"mt-1 line-clamp-2 text-sm font-semibold text-ink md:truncate",title:m.topic,children:m.topic})]}),e(K,{room:m,className:"mt-3 px-4"}),e("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-4",children:m.members.map((h)=>{let z=C[h.verdict]??C.pending,R=q(h.status);return n("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",title:h.model,children:[n("span",{className:u("relative flex size-6 shrink-0 items-center justify-center rounded-full bg-raised ring-2",z.ring),children:[e(d,{modelID:h.model,className:"size-3.5",size:14}),R&&e(Z,{className:"absolute -right-1 -bottom-1 size-3 animate-spin rounded-full bg-panel text-accent"})]}),e("span",{className:"truncate text-dim",children:h.name}),e("span",{className:u("shrink-0 text-[11px]",z.text),children:z.label})]},h.id)})}),n("div",{className:"mt-3 flex items-center gap-2 border-t border-line/70 px-4 py-2.5 text-xs",children:[D?n(f,{children:[e("span",{className:"shrink-0 font-medium text-dim",children:D.senderName}),e("span",{className:"min-w-0 flex-1 truncate text-faint",children:D.text.replace(/\s+/g," ")})]}):e("span",{className:"min-w-0 flex-1 truncate text-faint",children:I?`${B} 位成员正在${m.phase==="research"?"调研":"思考"}…`:"没有发言"}),n("span",{className:"inline-flex shrink-0 items-center gap-1 text-faint transition-colors group-hover:text-ink",children:[m.messages.length>0&&n("span",{className:"tabular-nums",children:[m.messages.length," 条"]}),e(ne,{className:"size-3.5"})]})]})]}),w&&e(oe,{room:m,elapsedMs:E,onClose:()=>M(!1),onOpenMember:c,onPost:S,onAbort:H})]})}export{Je as CouncilCard};
@@ -1 +1 @@
1
- import{g,o,i,r,f,e,n,y,s,ne,bt,at,Vt,ve,ce,Q,xt,lt,te,rn,X}from"./chunk-nvt9tkt4.js";import{Or,$r,Br}from"./chunk-fpb2dd2d.js";var je=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],xe=s("key-round",je);function he(a){let d=[],h="",N,C=!1;for(let u=0;u<a.length;u++){let c=a.charAt(u);if(N)if(c===N)N=void 0;else if(c==="\\"&&N==='"'&&u+1<a.length)h+=a[++u];else h+=c;else if(c==='"'||c==="'")N=c,C=!0;else if(c==="\\"&&u+1<a.length)h+=a[++u],C=!0;else if(/\s/.test(c)){if(C||h)d.push(h);h="",C=!1}else h+=c,C=!0}if(C||h)d.push(h);return d}function me(a){return a.map((d)=>d===""||/[\s"'\\]/.test(d)?`"${d.replace(/(["\\])/g,"\\$1")}"`:d).join(" ")}var be="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent",$e={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function ae(a){return a.type==="local"?me(a.command):a.url}function ye({info:a,tools:d=!1}){let h=$e[a.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[e("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${h.dot}`}),e("span",{className:d?void 0:"hidden @md/panel:inline",children:h.label}),d&&a.status.status==="connected"&&n("span",{className:"text-faint",children:["· ",a.toolCount," 个工具"]})]})}function Te(a){if(typeof a!=="object"||a===null||!("type"in a))return"any";let d=a.type;if(typeof d==="string")return d;if(Array.isArray(d))return d.filter((h)=>typeof h==="string").join(" | ")||"any";return"any"}function Ne(a){let{Button:d,CopyButton:h,Dialog:N,StatusChip:C,confirm:u,style:c,useTheme:S}=y();S();let{info:l,connection:E}=a,[m,P]=r(),[Z,A]=r(),[D,k]=r(!1),_=l.status.status==="connected",U=l.status.status==="needs_auth",W=l.status.status==="failed",V=l.config.type==="remote"&&Boolean(l.config.oauth);o(()=>{function p(x){if(x&&x!==l.name)return;let R=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"";E.request(`/api/mcp/${encodeURIComponent(l.name)}/connect${R}`,{method:"POST"}).then((K)=>a.onChanged(K)).catch(()=>{})}function t(x){if(x.data?.type==="mcp-oauth-success")p(x.data.name)}function b(x){if(x.key==="basalt-mcp-oauth-event"&&x.newValue)try{let R=JSON.parse(x.newValue);p(R.name)}catch(R){}}window.addEventListener("message",t),window.addEventListener("storage",b);let w;if("BroadcastChannel"in window)w=new BroadcastChannel("basalt-mcp-oauth"),w.onmessage=(x)=>{if(x.data?.type==="mcp-oauth-success")p(x.data.name)};return()=>{window.removeEventListener("message",t),window.removeEventListener("storage",b),w?.close()}},[E,l.name,l.projectID,a]),o(()=>{if(l.status.status!=="connected")return;let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"";E.request(`/api/mcp/${encodeURIComponent(l.name)}/tools${p}`).then((t)=>{if(Array.isArray(t))P(t),A(void 0)}).catch((t)=>{A(t instanceof Error?t.message:"获取工具失败")})},[E,l.name,l.projectID,l.status.status]);async function Y(p){k(!0);try{let t=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",b=await E.request(`/api/mcp/${encodeURIComponent(l.name)}/${p}${t}`,{method:"POST"});a.onChanged(b)}catch{}finally{k(!1)}}async function H(){k(!0);try{let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",t=l.status.status==="needs_auth"?l.status.authorizationUrl:void 0;if(!t)t=(await E.request(`/api/mcp/${encodeURIComponent(l.name)}/oauth/authorize${p}`,{method:"POST"})).authorizationUrl;if(t)window.open(t,"_blank","width=600,height=700")}catch(p){A(p instanceof Error?p.message:"获取授权链接失败")}finally{k(!1)}}async function G(){k(!0);try{let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",t=await E.request(`/api/mcp/${encodeURIComponent(l.name)}/oauth/clear${p}`,{method:"POST"});a.onChanged(t)}finally{k(!1)}}async function j(){if(!await u({title:`删除 ${l.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;k(!0);try{let t=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"";await E.request(`/api/mcp/${encodeURIComponent(l.name)}${t}`,{method:"DELETE"}),a.onChanged(),a.onClose()}finally{k(!1)}}let T=l.config,M=ae(T),L="error"in l.status?l.status.error:void 0,ee=m?.length??l.toolCount??0;return e(N,{open:!0,className:"bg-panel shadow-float",onOpenChange:(p)=>{if(!p&&!D)a.onClose()},title:n("div",{className:"flex flex-wrap items-center gap-3",children:[e("div",{className:"flex size-8 items-center justify-center rounded-[10px] border border-accent/20 bg-accent-soft text-accent",children:T.type==="local"?e(lt,{className:"size-4"}):e(ve,{className:"size-4"})}),e("span",{className:"font-serif text-lg font-semibold tracking-tight text-ink",children:l.name}),_?e(C,{tone:"success",pulse:!0,children:"已连接"}):U?e(C,{tone:"warning",pulse:!0,children:"需要授权"}):W?e(C,{tone:"danger",children:"连接失败"}):l.status.status==="disabled"?e(C,{tone:"neutral",children:"已停用"}):e(C,{tone:"neutral",children:"未连接"})]}),description:n("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"flex min-w-0 max-w-full items-center gap-1 rounded-lg border border-line bg-raised/60 py-0.5 pr-1 pl-2.5 font-mono text-[11.5px] text-ink",children:[e("span",{className:"min-w-0 truncate",title:M,children:M}),e(h,{text:M,label:"复制地址",size:"icon-xs",className:"shrink-0 text-dim hover:text-ink"})]}),e("span",{className:"rounded-lg border border-line px-2 py-1 text-[11px] leading-none text-dim",children:T.type==="local"?"本地命令":"远程 HTTP"}),V&&n("span",{className:c("control.badgeAccent","gap-1 rounded-lg border border-accent/25 px-2 py-1"),children:[e(xt,{className:"size-3"}),"OAuth 2.0"]})]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:flex-col",children:[n("div",{className:"flex items-center gap-1 max-sm:w-full",children:[V&&e(d,{type:"button",variant:"ghost",onClick:G,disabled:D,title:"清除已保存的 OAuth 凭据",children:"清除凭据"}),e(d,{type:"button",variant:"danger-ghost",size:"icon-sm","aria-label":"删除服务器",onClick:j,disabled:D,title:"删除服务器",children:e(te,{className:"size-4"})})]}),n("div",{className:"flex items-center gap-2 max-sm:w-full max-sm:justify-end",children:[e(d,{type:"button",variant:"ghost",onClick:a.onEdit,disabled:D,children:"编辑配置"}),!U&&e(d,{type:"button",variant:"secondary",onClick:()=>Y(_?"disconnect":"connect"),disabled:D,children:D?"处理中...":_?"断开连接":"立即连接"}),e(d,{type:"button",variant:"primary",onClick:a.onClose,children:"完成"})]})]}),children:n("div",{className:"space-y-6 pt-1",children:[U&&e("div",{className:"relative overflow-hidden rounded-2xl border border-warning/30 bg-[radial-gradient(120%_140%_at_0%_0%,color-mix(in_oklch,var(--color-warning)_16%,transparent),transparent_65%)] p-5",children:n("div",{className:"flex items-start gap-4 max-sm:flex-col",children:[e("div",{className:"relative flex size-11 shrink-0 items-center justify-center rounded-xl border border-warning/30 bg-panel text-warning shadow-[0_0_28px_-4px_color-mix(in_oklch,var(--color-warning)_55%,transparent)]",children:e(xe,{className:"size-5"})}),n("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e("h4",{className:"text-sm font-semibold text-ink",children:"授权后即可使用此服务器"}),e("p",{className:"text-[13px] leading-relaxed text-dim",children:"该端点要求 OAuth 2.0 身份许可。在浏览器中完成授权后,令牌会自动保存并载入全部工具。"}),L&&e("p",{className:"line-clamp-2 break-words font-mono text-[11.5px] text-faint",title:L,children:L})]}),n(d,{type:"button",variant:"primary",onClick:H,disabled:D,className:"shrink-0",children:[e(Vt,{className:"mr-1.5 size-3.5"}),D?"正在拉起授权...":"前往授权"]})]})}),W&&n("div",{className:c("callout.base",c("callout.danger"),"gap-3 rounded-2xl p-4"),children:[e(bt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n("div",{className:"min-w-0 space-y-1",children:[e("h4",{className:"text-sm font-medium text-ink",children:"连接失败"}),e("p",{className:"font-mono text-[11.5px] leading-relaxed break-words text-dim",children:L})]})]}),n("section",{className:"space-y-3",children:[n("div",{className:"flex items-baseline justify-between gap-3 px-0.5",children:[n("h4",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:["可用工具",e("span",{className:"rounded-full bg-raised px-1.5 py-0.5 font-mono text-[11px] leading-none text-dim",children:ee})]}),e("span",{className:"text-[11.5px] text-faint",children:"对所有会话可用"})]}),Z?e("div",{className:c("callout.base",c("callout.danger"),"text-xs leading-relaxed break-words"),children:Z}):!_?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[e("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:e(rn,{className:"size-4.5"})}),e("p",{className:"text-[13px] font-medium text-dim",children:U?"等待授权":"尚未连接"}),e("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:U?"授权完成后会自动连接并列出工具。":"连接服务器后,这里会列出它提供的全部工具。"})]}):!m?e("div",{role:"status","aria-label":"正在获取工具列表",className:"grid gap-2",children:[0,1,2].map((p)=>n("div",{className:"animate-pulse space-y-2.5 rounded-xl border border-line p-3.5",children:[e("div",{className:"h-3.5 w-32 rounded bg-raised"}),e("div",{className:"h-3 w-4/5 rounded bg-raised/70"})]},p))}):m.length===0?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[e("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:e(rn,{className:"size-4.5"})}),e("p",{className:"text-[13px] font-medium text-dim",children:"没有可用工具"}),e("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:"已连接成功,但该服务器没有声明任何工具。"})]}):e("ul",{className:"grid gap-2",children:m.map((p)=>{let t=p.inputSchema?.properties??{},b=p.inputSchema?.required??[],w=Object.entries(t);return n("li",{className:c("surface.subtle","border-line bg-raised/30 p-3.5 transition-colors hover:border-line-strong hover:bg-raised/60"),children:[e("span",{className:"font-mono text-[13px] font-medium break-all text-accent",children:p.name}),p.description&&e("p",{className:"mt-1.5 text-[13px] leading-relaxed break-words text-dim",children:p.description}),w.length>0&&e("div",{className:"mt-3 flex flex-wrap gap-1.5",children:w.map(([x,R])=>n("span",{title:b.includes(x)?"必填参数":"可选参数",className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel px-1.5 py-1 font-mono text-[11px] leading-none",children:[e("span",{className:"text-ink",children:x}),b.includes(x)&&e("span",{className:"text-warning",children:"*"}),e("span",{className:"text-faint",children:Te(R)})]},x))})]},p.name)})})]})]})})}var Pe=/^[A-Za-z0-9_-]{1,64}$/;function F(a){return e("span",{className:"truncate text-xs text-faint",children:a.children})}function Ce(a){let{pairs:d,onChange:h,InputComponent:N}=a,C=(u,c)=>h(d.map((S,l)=>l===u?{...S,...c}:S));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[e("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:a.label}),e(F,{children:a.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>h([...d,{key:"",value:"",saved:!1}]),children:[e(ce,{className:"size-3.5"}),"添加"]})]}),d.map((u,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(N,{"aria-label":`${a.keyLabel} ${c+1}`,placeholder:a.keyLabel,value:u.key,readOnly:u.saved,onChange:(S)=>C(c,{key:S.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),e(N,{"aria-label":`${a.keyLabel} ${u.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:u.saved?"已保存,留空保持不变":"值",value:u.value,onChange:(S)=>C(c,{value:S.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),e("button",{type:"button","aria-label":`删除 ${u.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>h(d.filter((S,l)=>l!==c)),children:e(X,{className:"size-4"})})]},c))]})}function we(a){return Object.keys(a??{}).map((d)=>({key:d,value:"",saved:!0}))}function ke(a){let{Button:d,Segmented:h,Dialog:N,Form:C,Field:u,Input:c,Switch:S,style:l,useTheme:E}=y();E();let{existing:m}=a,[P,Z]=r(m?.config.type??"local"),[A,D]=r(m?.name??""),[k,_]=r(m?.config.type==="local"?me(m.config.command):""),[U,W]=r(m?.config.type==="remote"?m.config.url:""),[V,Y]=r(we(m?.config.type==="local"?m.config.environment:void 0)),[H,G]=r(we(m?.config.type==="remote"?m.config.headers:void 0)),j=m?.config.type==="remote"?m.config.oauth:void 0,[T,M]=r(Boolean(j)),[L,ee]=r(typeof j==="object"&&j.clientId?j.clientId:""),[p,t]=r(""),[b,w]=r(typeof j==="object"&&j.scope?j.scope:""),[x,R]=r(m?.config.defer??"default"),[K,se]=r(m?.config.timeout!==void 0?String(m.config.timeout):""),[le,Ie]=r(m?.config.defer!==void 0||m?.config.timeout!==void 0),[ue,J]=r(),[de,fe]=r(!1);async function Se(v){v.preventDefault(),J(void 0);let I=A.trim();if(!m&&!Pe.test(I)){J("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!m&&a.taken.includes(I)){J("同名服务器已存在");return}let oe=K.trim()?Number.parseInt(K.trim(),10):void 0;if(oe!==void 0&&(!Number.isFinite(oe)||oe<=0)){J("超时时间须为大于 0 的毫秒数");return}let pe;if(P==="local"){let B=he(k.trim());if(!B.length){J("请输入启动命令");return}let q={};for(let O of V){let z=O.key.trim();if(!z)continue;if(!O.saved||O.value)q[z]=O.value}pe={type:"local",command:B,environment:Object.keys(q).length?q:void 0,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:oe}}else{let B=U.trim();try{let z=new URL(B);if(z.protocol!=="http:"&&z.protocol!=="https:")throw Error("bad protocol")}catch{J("请输入合法的 HTTP 或 HTTPS 地址");return}let q={};for(let z of H){let ie=z.key.trim();if(!ie)continue;if(!z.saved||z.value)q[ie]=z.value}let O;if(T){let z=L.trim(),ie=p.trim(),ge=b.trim();if(z||ie||ge)O={clientId:z||void 0,clientSecret:ie||void 0,scope:ge||void 0};else O=!0}else O=!1;pe={type:"remote",url:B,headers:Object.keys(q).length?q:void 0,oauth:O,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:oe}}fe(!0);try{let B=m?.name??I,q=m?m.projectID:a.projectID,O=q?`?projectID=${encodeURIComponent(q)}`:"";await a.connection.request(`/api/mcp/${encodeURIComponent(B)}${O}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(pe)}),a.onSaved()}catch(B){J(B instanceof Error?B.message:"保存失败")}finally{fe(!1)}}return e(N,{open:!0,onOpenChange:(v)=>{if(!v&&!de)a.onClose()},title:m?`编辑 ${m.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[e(d,{type:"button",variant:"ghost",onClick:a.onClose,disabled:de,className:"min-w-20",children:"取消"}),e(d,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:de,className:"min-w-24",children:de?"保存中...":"保存"})]}),children:n(C,{id:"mcp-server-form",onSubmit:Se,children:[e(h,{value:P,onChange:(v)=>Z(v),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!m&&e(u,{label:"名称",aside:e(F,{children:"唯一标识,如 postgres"}),children:(v)=>e(c,{id:v,value:A,onChange:(I)=>D(I.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),P==="local"?n(f,{children:[e(u,{label:"启动命令",aside:e(F,{children:"完整命令及参数"}),children:(v)=>e(c,{id:v,value:k,onChange:(I)=>_(I.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),e(Ce,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:V,onChange:Y,InputComponent:c})]}):n(f,{children:[e(u,{label:"服务地址",aside:e(F,{children:"HTTP / HTTPS 端点"}),children:(v)=>e(c,{id:v,value:U,onChange:(I)=>W(I.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),e(Ce,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:H,onChange:G,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[e("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),e("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),e(S,{checked:T,onCheckedChange:M,label:"启用 OAuth 2.0"})]}),T&&n(f,{children:[e(u,{label:"Client ID",aside:e(F,{children:"留空自动动态注册(DCR)"}),children:(v)=>e(c,{id:v,value:L,onChange:(I)=>ee(I.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),e(u,{label:"Client Secret",aside:e(F,{children:"留空保持不变"}),children:(v)=>e(c,{id:v,type:"password",autoComplete:"off",value:p,onChange:(I)=>t(I.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),e(u,{label:"Scope",aside:e(F,{children:"选填授权范围"}),children:(v)=>e(c,{id:v,value:b,onChange:(I)=>w(I.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":le,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>Ie(!le),children:[e(at,{className:`size-3.5 transition-transform ${le?"rotate-90":""}`}),"高级设置",e("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),le&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[e(u,{label:"加载时机",aside:e(F,{children:"延迟 = 按需加载"}),children:()=>e(h,{value:x,onChange:(v)=>R(v),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),e(u,{label:"超时(毫秒)",aside:e(F,{children:"留空用默认"}),children:(v)=>e(c,{id:v,value:K,onChange:(I)=>se(I.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),ue&&n("div",{role:"alert",className:l("callout.base",l("callout.danger"),"px-3 py-2.5 text-xs"),children:[e(ne,{className:"mt-0.5 size-3.5 shrink-0"}),e("span",{className:"min-w-0 break-words",children:ue})]})]})})}var re="global";function nt({connection:a}){let{Button:d,Select:h,style:N,useTheme:C}=y();C();let[u,c]=r(""),[S,l]=r(),[E,m]=r([]),[P,Z]=r(re),[A,D]=r(),[k,_]=r(!1),[U,W]=r(),[V,Y]=r(!1),H=i(!1),[G,j]=r(),T=i(0),M=g(async()=>{let t=++T.current;_(!0);try{let b=P===re?"":`?projectID=${encodeURIComponent(P)}`,[w,x]=await Promise.all([a.request(`/api/mcp${b}`),a.request("/api/projects")]);if(t!==T.current)return;l(w),m(x),D(void 0)}catch(b){if(t===T.current)D(b instanceof Error?b.message:"读取失败")}finally{if(t===T.current)_(!1)}},[a,P]);o(()=>(M(),()=>{T.current++}),[M]);async function L(t,b){if(H.current)return;H.current=!0,Y(!0);let w=T.current;try{let x=t.projectID?`?projectID=${encodeURIComponent(t.projectID)}`:"",R=await a.request(`/api/mcp/${encodeURIComponent(t.name)}${x}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...t.config,enabled:b})});if(w===T.current)l((K)=>K?.map((se)=>se.name===R.name&&se.projectID===R.projectID?R:se))}finally{H.current=!1,Y(!1)}}let ee=S?.filter((t)=>`${t.name} ${ae(t.config)}`.toLowerCase().includes(u.trim().toLowerCase())),p=S?.find((t)=>t.name===U);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[e("h2",{className:N("settings.groupTitle"),children:"MCP 服务器"}),e("p",{className:N("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e(h,{value:P,disabled:k,onValueChange:(t)=>{W(void 0),j(void 0),l(void 0),Z(t)},groups:[{options:[{value:re,label:"全局"}]},...Or(E)],className:"w-44"}),e(d,{variant:"ghost",disabled:k,onClick:M,className:"h-9 px-2.5 text-xs",children:e(Q,{className:`size-3.5 ${k?"animate-spin":""}`})}),n(d,{variant:"secondary",onClick:()=>j({}),className:"h-9 px-2.5 text-xs",children:[e(ce,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),A&&n("div",{role:"alert",className:N("callout.base",N("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",A]}),e(d,{disabled:k,onClick:M,children:"重试"})]}),e($r,{label:"搜索 MCP 服务器",placeholder:"搜索服务器",value:u,onChange:c}),e("div",{className:N("settings.groupBox"),children:!S?e(Br,{}):ee?.length===0?e("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):e("ul",{className:"divide-y divide-line",children:ee?.map((t)=>{let b=t.config.enabled===!1,w=t.scope==="file";return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${b?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看 ${t.name}`,disabled:w,title:w?"来自项目的 .mcp.json,只读":void 0,onClick:()=>W(t.name),children:[e("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-raised text-dim",children:t.config.type==="local"?e(lt,{className:"size-4"}):e(ve,{className:"size-4"})}),n("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block truncate text-sm font-medium text-ink",title:t.name,children:t.name}),e("span",{className:"mt-0.5 block truncate font-mono text-xs text-dim",title:ae(t.config),children:ae(t.config)})]}),e("span",{className:N("control.badge","shrink-0 text-[11px] text-dim"),children:t.scope==="project"?"项目":t.scope==="file"?".mcp.json":"全局"}),e(ye,{info:t})]}),e("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:!w&&e("input",{type:"checkbox","aria-label":`启用服务器 ${t.name}`,className:be,disabled:V||k,checked:!b,onChange:(x)=>L(t,x.target.checked)})})]},t.name)})})})]}),p&&!G&&e(Ne,{connection:a,info:p,onClose:()=>W(void 0),onEdit:()=>j({info:p}),onChanged:(t)=>t?l((b)=>b?.map((w)=>w.name===t.name?t:w)):M()},`${p.projectID}:${p.name}`),G&&e(ke,{connection:a,projectID:P===re?void 0:P,existing:G.info,taken:(S??[]).filter((t)=>t.scope===(P===re?"global":"project")).map((t)=>t.name),onClose:()=>j(void 0),onSaved:()=>{j(void 0),M()}})]})}export{nt as McpSection};
1
+ import{g,o,i,r,f,e,n,y,s,ne,bt,it,Vt,ve,ce,Q,xt,ct,te,rn,X}from"./chunk-ngt1j8py.js";import{Or,$r,Br}from"./chunk-jke2ev6m.js";var je=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],xe=s("key-round",je);function he(a){let d=[],h="",N,C=!1;for(let u=0;u<a.length;u++){let c=a.charAt(u);if(N)if(c===N)N=void 0;else if(c==="\\"&&N==='"'&&u+1<a.length)h+=a[++u];else h+=c;else if(c==='"'||c==="'")N=c,C=!0;else if(c==="\\"&&u+1<a.length)h+=a[++u],C=!0;else if(/\s/.test(c)){if(C||h)d.push(h);h="",C=!1}else h+=c,C=!0}if(C||h)d.push(h);return d}function me(a){return a.map((d)=>d===""||/[\s"'\\]/.test(d)?`"${d.replace(/(["\\])/g,"\\$1")}"`:d).join(" ")}var be="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent",$e={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function ae(a){return a.type==="local"?me(a.command):a.url}function ye({info:a,tools:d=!1}){let h=$e[a.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[e("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${h.dot}`}),e("span",{className:d?void 0:"hidden @md/panel:inline",children:h.label}),d&&a.status.status==="connected"&&n("span",{className:"text-faint",children:["· ",a.toolCount," 个工具"]})]})}function Te(a){if(typeof a!=="object"||a===null||!("type"in a))return"any";let d=a.type;if(typeof d==="string")return d;if(Array.isArray(d))return d.filter((h)=>typeof h==="string").join(" | ")||"any";return"any"}function Ne(a){let{Button:d,CopyButton:h,Dialog:N,StatusChip:C,confirm:u,style:c,useTheme:S}=y();S();let{info:l,connection:E}=a,[m,P]=r(),[Z,A]=r(),[D,k]=r(!1),_=l.status.status==="connected",U=l.status.status==="needs_auth",W=l.status.status==="failed",V=l.config.type==="remote"&&Boolean(l.config.oauth);o(()=>{function p(x){if(x&&x!==l.name)return;let R=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"";E.request(`/api/mcp/${encodeURIComponent(l.name)}/connect${R}`,{method:"POST"}).then((K)=>a.onChanged(K)).catch(()=>{})}function t(x){if(x.data?.type==="mcp-oauth-success")p(x.data.name)}function b(x){if(x.key==="basalt-mcp-oauth-event"&&x.newValue)try{let R=JSON.parse(x.newValue);p(R.name)}catch(R){}}window.addEventListener("message",t),window.addEventListener("storage",b);let w;if("BroadcastChannel"in window)w=new BroadcastChannel("basalt-mcp-oauth"),w.onmessage=(x)=>{if(x.data?.type==="mcp-oauth-success")p(x.data.name)};return()=>{window.removeEventListener("message",t),window.removeEventListener("storage",b),w?.close()}},[E,l.name,l.projectID,a]),o(()=>{if(l.status.status!=="connected")return;let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"";E.request(`/api/mcp/${encodeURIComponent(l.name)}/tools${p}`).then((t)=>{if(Array.isArray(t))P(t),A(void 0)}).catch((t)=>{A(t instanceof Error?t.message:"获取工具失败")})},[E,l.name,l.projectID,l.status.status]);async function Y(p){k(!0);try{let t=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",b=await E.request(`/api/mcp/${encodeURIComponent(l.name)}/${p}${t}`,{method:"POST"});a.onChanged(b)}catch{}finally{k(!1)}}async function H(){k(!0);try{let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",t=l.status.status==="needs_auth"?l.status.authorizationUrl:void 0;if(!t)t=(await E.request(`/api/mcp/${encodeURIComponent(l.name)}/oauth/authorize${p}`,{method:"POST"})).authorizationUrl;if(t)window.open(t,"_blank","width=600,height=700")}catch(p){A(p instanceof Error?p.message:"获取授权链接失败")}finally{k(!1)}}async function G(){k(!0);try{let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",t=await E.request(`/api/mcp/${encodeURIComponent(l.name)}/oauth/clear${p}`,{method:"POST"});a.onChanged(t)}finally{k(!1)}}async function j(){if(!await u({title:`删除 ${l.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;k(!0);try{let t=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"";await E.request(`/api/mcp/${encodeURIComponent(l.name)}${t}`,{method:"DELETE"}),a.onChanged(),a.onClose()}finally{k(!1)}}let T=l.config,M=ae(T),L="error"in l.status?l.status.error:void 0,ee=m?.length??l.toolCount??0;return e(N,{open:!0,className:"bg-panel shadow-float",onOpenChange:(p)=>{if(!p&&!D)a.onClose()},title:n("div",{className:"flex flex-wrap items-center gap-3",children:[e("div",{className:"flex size-8 items-center justify-center rounded-[10px] border border-accent/20 bg-accent-soft text-accent",children:T.type==="local"?e(ct,{className:"size-4"}):e(ve,{className:"size-4"})}),e("span",{className:"font-serif text-lg font-semibold tracking-tight text-ink",children:l.name}),_?e(C,{tone:"success",pulse:!0,children:"已连接"}):U?e(C,{tone:"warning",pulse:!0,children:"需要授权"}):W?e(C,{tone:"danger",children:"连接失败"}):l.status.status==="disabled"?e(C,{tone:"neutral",children:"已停用"}):e(C,{tone:"neutral",children:"未连接"})]}),description:n("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"flex min-w-0 max-w-full items-center gap-1 rounded-lg border border-line bg-raised/60 py-0.5 pr-1 pl-2.5 font-mono text-[11.5px] text-ink",children:[e("span",{className:"min-w-0 truncate",title:M,children:M}),e(h,{text:M,label:"复制地址",size:"icon-xs",className:"shrink-0 text-dim hover:text-ink"})]}),e("span",{className:"rounded-lg border border-line px-2 py-1 text-[11px] leading-none text-dim",children:T.type==="local"?"本地命令":"远程 HTTP"}),V&&n("span",{className:c("control.badgeAccent","gap-1 rounded-lg border border-accent/25 px-2 py-1"),children:[e(xt,{className:"size-3"}),"OAuth 2.0"]})]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:flex-col",children:[n("div",{className:"flex items-center gap-1 max-sm:w-full",children:[V&&e(d,{type:"button",variant:"ghost",onClick:G,disabled:D,title:"清除已保存的 OAuth 凭据",children:"清除凭据"}),e(d,{type:"button",variant:"danger-ghost",size:"icon-sm","aria-label":"删除服务器",onClick:j,disabled:D,title:"删除服务器",children:e(te,{className:"size-4"})})]}),n("div",{className:"flex items-center gap-2 max-sm:w-full max-sm:justify-end",children:[e(d,{type:"button",variant:"ghost",onClick:a.onEdit,disabled:D,children:"编辑配置"}),!U&&e(d,{type:"button",variant:"secondary",onClick:()=>Y(_?"disconnect":"connect"),disabled:D,children:D?"处理中...":_?"断开连接":"立即连接"}),e(d,{type:"button",variant:"primary",onClick:a.onClose,children:"完成"})]})]}),children:n("div",{className:"space-y-6 pt-1",children:[U&&e("div",{className:"relative overflow-hidden rounded-2xl border border-warning/30 bg-[radial-gradient(120%_140%_at_0%_0%,color-mix(in_oklch,var(--color-warning)_16%,transparent),transparent_65%)] p-5",children:n("div",{className:"flex items-start gap-4 max-sm:flex-col",children:[e("div",{className:"relative flex size-11 shrink-0 items-center justify-center rounded-xl border border-warning/30 bg-panel text-warning shadow-[0_0_28px_-4px_color-mix(in_oklch,var(--color-warning)_55%,transparent)]",children:e(xe,{className:"size-5"})}),n("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e("h4",{className:"text-sm font-semibold text-ink",children:"授权后即可使用此服务器"}),e("p",{className:"text-[13px] leading-relaxed text-dim",children:"该端点要求 OAuth 2.0 身份许可。在浏览器中完成授权后,令牌会自动保存并载入全部工具。"}),L&&e("p",{className:"line-clamp-2 break-words font-mono text-[11.5px] text-faint",title:L,children:L})]}),n(d,{type:"button",variant:"primary",onClick:H,disabled:D,className:"shrink-0",children:[e(Vt,{className:"mr-1.5 size-3.5"}),D?"正在拉起授权...":"前往授权"]})]})}),W&&n("div",{className:c("callout.base",c("callout.danger"),"gap-3 rounded-2xl p-4"),children:[e(bt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n("div",{className:"min-w-0 space-y-1",children:[e("h4",{className:"text-sm font-medium text-ink",children:"连接失败"}),e("p",{className:"font-mono text-[11.5px] leading-relaxed break-words text-dim",children:L})]})]}),n("section",{className:"space-y-3",children:[n("div",{className:"flex items-baseline justify-between gap-3 px-0.5",children:[n("h4",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:["可用工具",e("span",{className:"rounded-full bg-raised px-1.5 py-0.5 font-mono text-[11px] leading-none text-dim",children:ee})]}),e("span",{className:"text-[11.5px] text-faint",children:"对所有会话可用"})]}),Z?e("div",{className:c("callout.base",c("callout.danger"),"text-xs leading-relaxed break-words"),children:Z}):!_?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[e("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:e(rn,{className:"size-4.5"})}),e("p",{className:"text-[13px] font-medium text-dim",children:U?"等待授权":"尚未连接"}),e("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:U?"授权完成后会自动连接并列出工具。":"连接服务器后,这里会列出它提供的全部工具。"})]}):!m?e("div",{role:"status","aria-label":"正在获取工具列表",className:"grid gap-2",children:[0,1,2].map((p)=>n("div",{className:"animate-pulse space-y-2.5 rounded-xl border border-line p-3.5",children:[e("div",{className:"h-3.5 w-32 rounded bg-raised"}),e("div",{className:"h-3 w-4/5 rounded bg-raised/70"})]},p))}):m.length===0?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[e("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:e(rn,{className:"size-4.5"})}),e("p",{className:"text-[13px] font-medium text-dim",children:"没有可用工具"}),e("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:"已连接成功,但该服务器没有声明任何工具。"})]}):e("ul",{className:"grid gap-2",children:m.map((p)=>{let t=p.inputSchema?.properties??{},b=p.inputSchema?.required??[],w=Object.entries(t);return n("li",{className:c("surface.subtle","border-line bg-raised/30 p-3.5 transition-colors hover:border-line-strong hover:bg-raised/60"),children:[e("span",{className:"font-mono text-[13px] font-medium break-all text-accent",children:p.name}),p.description&&e("p",{className:"mt-1.5 text-[13px] leading-relaxed break-words text-dim",children:p.description}),w.length>0&&e("div",{className:"mt-3 flex flex-wrap gap-1.5",children:w.map(([x,R])=>n("span",{title:b.includes(x)?"必填参数":"可选参数",className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel px-1.5 py-1 font-mono text-[11px] leading-none",children:[e("span",{className:"text-ink",children:x}),b.includes(x)&&e("span",{className:"text-warning",children:"*"}),e("span",{className:"text-faint",children:Te(R)})]},x))})]},p.name)})})]})]})})}var Pe=/^[A-Za-z0-9_-]{1,64}$/;function F(a){return e("span",{className:"truncate text-xs text-faint",children:a.children})}function Ce(a){let{pairs:d,onChange:h,InputComponent:N}=a,C=(u,c)=>h(d.map((S,l)=>l===u?{...S,...c}:S));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[e("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:a.label}),e(F,{children:a.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>h([...d,{key:"",value:"",saved:!1}]),children:[e(ce,{className:"size-3.5"}),"添加"]})]}),d.map((u,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(N,{"aria-label":`${a.keyLabel} ${c+1}`,placeholder:a.keyLabel,value:u.key,readOnly:u.saved,onChange:(S)=>C(c,{key:S.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),e(N,{"aria-label":`${a.keyLabel} ${u.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:u.saved?"已保存,留空保持不变":"值",value:u.value,onChange:(S)=>C(c,{value:S.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),e("button",{type:"button","aria-label":`删除 ${u.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>h(d.filter((S,l)=>l!==c)),children:e(X,{className:"size-4"})})]},c))]})}function we(a){return Object.keys(a??{}).map((d)=>({key:d,value:"",saved:!0}))}function ke(a){let{Button:d,Segmented:h,Dialog:N,Form:C,Field:u,Input:c,Switch:S,style:l,useTheme:E}=y();E();let{existing:m}=a,[P,Z]=r(m?.config.type??"local"),[A,D]=r(m?.name??""),[k,_]=r(m?.config.type==="local"?me(m.config.command):""),[U,W]=r(m?.config.type==="remote"?m.config.url:""),[V,Y]=r(we(m?.config.type==="local"?m.config.environment:void 0)),[H,G]=r(we(m?.config.type==="remote"?m.config.headers:void 0)),j=m?.config.type==="remote"?m.config.oauth:void 0,[T,M]=r(Boolean(j)),[L,ee]=r(typeof j==="object"&&j.clientId?j.clientId:""),[p,t]=r(""),[b,w]=r(typeof j==="object"&&j.scope?j.scope:""),[x,R]=r(m?.config.defer??"default"),[K,se]=r(m?.config.timeout!==void 0?String(m.config.timeout):""),[le,Ie]=r(m?.config.defer!==void 0||m?.config.timeout!==void 0),[ue,J]=r(),[de,fe]=r(!1);async function Se(v){v.preventDefault(),J(void 0);let I=A.trim();if(!m&&!Pe.test(I)){J("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!m&&a.taken.includes(I)){J("同名服务器已存在");return}let oe=K.trim()?Number.parseInt(K.trim(),10):void 0;if(oe!==void 0&&(!Number.isFinite(oe)||oe<=0)){J("超时时间须为大于 0 的毫秒数");return}let pe;if(P==="local"){let B=he(k.trim());if(!B.length){J("请输入启动命令");return}let q={};for(let O of V){let z=O.key.trim();if(!z)continue;if(!O.saved||O.value)q[z]=O.value}pe={type:"local",command:B,environment:Object.keys(q).length?q:void 0,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:oe}}else{let B=U.trim();try{let z=new URL(B);if(z.protocol!=="http:"&&z.protocol!=="https:")throw Error("bad protocol")}catch{J("请输入合法的 HTTP 或 HTTPS 地址");return}let q={};for(let z of H){let ie=z.key.trim();if(!ie)continue;if(!z.saved||z.value)q[ie]=z.value}let O;if(T){let z=L.trim(),ie=p.trim(),ge=b.trim();if(z||ie||ge)O={clientId:z||void 0,clientSecret:ie||void 0,scope:ge||void 0};else O=!0}else O=!1;pe={type:"remote",url:B,headers:Object.keys(q).length?q:void 0,oauth:O,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:oe}}fe(!0);try{let B=m?.name??I,q=m?m.projectID:a.projectID,O=q?`?projectID=${encodeURIComponent(q)}`:"";await a.connection.request(`/api/mcp/${encodeURIComponent(B)}${O}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(pe)}),a.onSaved()}catch(B){J(B instanceof Error?B.message:"保存失败")}finally{fe(!1)}}return e(N,{open:!0,onOpenChange:(v)=>{if(!v&&!de)a.onClose()},title:m?`编辑 ${m.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[e(d,{type:"button",variant:"ghost",onClick:a.onClose,disabled:de,className:"min-w-20",children:"取消"}),e(d,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:de,className:"min-w-24",children:de?"保存中...":"保存"})]}),children:n(C,{id:"mcp-server-form",onSubmit:Se,children:[e(h,{value:P,onChange:(v)=>Z(v),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!m&&e(u,{label:"名称",aside:e(F,{children:"唯一标识,如 postgres"}),children:(v)=>e(c,{id:v,value:A,onChange:(I)=>D(I.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),P==="local"?n(f,{children:[e(u,{label:"启动命令",aside:e(F,{children:"完整命令及参数"}),children:(v)=>e(c,{id:v,value:k,onChange:(I)=>_(I.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),e(Ce,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:V,onChange:Y,InputComponent:c})]}):n(f,{children:[e(u,{label:"服务地址",aside:e(F,{children:"HTTP / HTTPS 端点"}),children:(v)=>e(c,{id:v,value:U,onChange:(I)=>W(I.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),e(Ce,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:H,onChange:G,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[e("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),e("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),e(S,{checked:T,onCheckedChange:M,label:"启用 OAuth 2.0"})]}),T&&n(f,{children:[e(u,{label:"Client ID",aside:e(F,{children:"留空自动动态注册(DCR)"}),children:(v)=>e(c,{id:v,value:L,onChange:(I)=>ee(I.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),e(u,{label:"Client Secret",aside:e(F,{children:"留空保持不变"}),children:(v)=>e(c,{id:v,type:"password",autoComplete:"off",value:p,onChange:(I)=>t(I.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),e(u,{label:"Scope",aside:e(F,{children:"选填授权范围"}),children:(v)=>e(c,{id:v,value:b,onChange:(I)=>w(I.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":le,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>Ie(!le),children:[e(it,{className:`size-3.5 transition-transform ${le?"rotate-90":""}`}),"高级设置",e("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),le&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[e(u,{label:"加载时机",aside:e(F,{children:"延迟 = 按需加载"}),children:()=>e(h,{value:x,onChange:(v)=>R(v),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),e(u,{label:"超时(毫秒)",aside:e(F,{children:"留空用默认"}),children:(v)=>e(c,{id:v,value:K,onChange:(I)=>se(I.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),ue&&n("div",{role:"alert",className:l("callout.base",l("callout.danger"),"px-3 py-2.5 text-xs"),children:[e(ne,{className:"mt-0.5 size-3.5 shrink-0"}),e("span",{className:"min-w-0 break-words",children:ue})]})]})})}var re="global";function nt({connection:a}){let{Button:d,Select:h,style:N,useTheme:C}=y();C();let[u,c]=r(""),[S,l]=r(),[E,m]=r([]),[P,Z]=r(re),[A,D]=r(),[k,_]=r(!1),[U,W]=r(),[V,Y]=r(!1),H=i(!1),[G,j]=r(),T=i(0),M=g(async()=>{let t=++T.current;_(!0);try{let b=P===re?"":`?projectID=${encodeURIComponent(P)}`,[w,x]=await Promise.all([a.request(`/api/mcp${b}`),a.request("/api/projects")]);if(t!==T.current)return;l(w),m(x),D(void 0)}catch(b){if(t===T.current)D(b instanceof Error?b.message:"读取失败")}finally{if(t===T.current)_(!1)}},[a,P]);o(()=>(M(),()=>{T.current++}),[M]);async function L(t,b){if(H.current)return;H.current=!0,Y(!0);let w=T.current;try{let x=t.projectID?`?projectID=${encodeURIComponent(t.projectID)}`:"",R=await a.request(`/api/mcp/${encodeURIComponent(t.name)}${x}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...t.config,enabled:b})});if(w===T.current)l((K)=>K?.map((se)=>se.name===R.name&&se.projectID===R.projectID?R:se))}finally{H.current=!1,Y(!1)}}let ee=S?.filter((t)=>`${t.name} ${ae(t.config)}`.toLowerCase().includes(u.trim().toLowerCase())),p=S?.find((t)=>t.name===U);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[e("h2",{className:N("settings.groupTitle"),children:"MCP 服务器"}),e("p",{className:N("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e(h,{value:P,disabled:k,onValueChange:(t)=>{W(void 0),j(void 0),l(void 0),Z(t)},groups:[{options:[{value:re,label:"全局"}]},...Or(E)],className:"w-44"}),e(d,{variant:"ghost",disabled:k,onClick:M,className:"h-9 px-2.5 text-xs",children:e(Q,{className:`size-3.5 ${k?"animate-spin":""}`})}),n(d,{variant:"secondary",onClick:()=>j({}),className:"h-9 px-2.5 text-xs",children:[e(ce,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),A&&n("div",{role:"alert",className:N("callout.base",N("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",A]}),e(d,{disabled:k,onClick:M,children:"重试"})]}),e($r,{label:"搜索 MCP 服务器",placeholder:"搜索服务器",value:u,onChange:c}),e("div",{className:N("settings.groupBox"),children:!S?e(Br,{}):ee?.length===0?e("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):e("ul",{className:"divide-y divide-line",children:ee?.map((t)=>{let b=t.config.enabled===!1,w=t.scope==="file";return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${b?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看 ${t.name}`,disabled:w,title:w?"来自项目的 .mcp.json,只读":void 0,onClick:()=>W(t.name),children:[e("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-raised text-dim",children:t.config.type==="local"?e(ct,{className:"size-4"}):e(ve,{className:"size-4"})}),n("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block truncate text-sm font-medium text-ink",title:t.name,children:t.name}),e("span",{className:"mt-0.5 block truncate font-mono text-xs text-dim",title:ae(t.config),children:ae(t.config)})]}),e("span",{className:N("control.badge","shrink-0 text-[11px] text-dim"),children:t.scope==="project"?"项目":t.scope==="file"?".mcp.json":"全局"}),e(ye,{info:t})]}),e("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:!w&&e("input",{type:"checkbox","aria-label":`启用服务器 ${t.name}`,className:be,disabled:V||k,checked:!b,onChange:(x)=>L(t,x.target.checked)})})]},t.name)})})})]}),p&&!G&&e(Ne,{connection:a,info:p,onClose:()=>W(void 0),onEdit:()=>j({info:p}),onChanged:(t)=>t?l((b)=>b?.map((w)=>w.name===t.name?t:w)):M()},`${p.projectID}:${p.name}`),G&&e(ke,{connection:a,projectID:P===re?void 0:P,existing:G.info,taken:(S??[]).filter((t)=>t.scope===(P===re?"global":"project")).map((t)=>t.name),onClose:()=>j(void 0),onSaved:()=>{j(void 0),M()}})]})}export{nt as McpSection};