dimcode-web 0.1.0-alpha.16 → 0.1.0-alpha.18

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 (90) hide show
  1. package/NOTICE +24 -0
  2. package/package.json +3 -2
  3. package/release-manifest.json +80 -78
  4. package/web/THIRD-PARTY-NOTICES.txt +7054 -0
  5. package/web/assets/{AccountSettings-CuNxjb5M.js → AccountSettings-Zh9WjvzX.js} +1 -1
  6. package/web/assets/{AgentSettings-B1kyVC9H.js → AgentSettings-Bk5dgxFf.js} +1 -1
  7. package/web/assets/{AppearanceSettings-BImLkd19.js → AppearanceSettings-DBBurwcE.js} +1 -1
  8. package/web/assets/{ArchivedSettings-C6UPMqfk.js → ArchivedSettings-BzLm8EQ8.js} +1 -1
  9. package/web/assets/{CodeBlockNode-Cm4qQWYp.js → CodeBlockNode-C4re3gRU.js} +2 -2
  10. package/web/assets/DiagnosticsSettings-CNw8SqKc.js +1 -0
  11. package/web/assets/McpSettings-C75_nZVn.js +1 -0
  12. package/web/assets/McpSettings-qL33wCkW.css +1 -0
  13. package/web/assets/{ModalitySettings-BpFvRd--.js → ModalitySettings-DZDyeNKL.js} +1 -1
  14. package/web/assets/PermissionsSettings-C7-MdFoV.js +1 -0
  15. package/web/assets/{PluginSettings-BF6eSPEd.js → PluginSettings-sWWqlef6.js} +1 -1
  16. package/web/assets/{PreCodeBlock-DH2VwXzi.js → PreCodeBlock-T5SnpbhZ.js} +1 -1
  17. package/web/assets/{ProviderAuthFlow.vue_vue_type_script_setup_true_lang-opd2fMYR.js → ProviderAuthFlow.vue_vue_type_script_setup_true_lang-Dh0zqlBj.js} +1 -1
  18. package/web/assets/{ProviderSettings-A8WG9V7m.js → ProviderSettings-BUNoKu8n.js} +1 -1
  19. package/web/assets/{SettingsPage-DmhRtj9e.js → SettingsPage-DHL9c2Jr.js} +1 -1
  20. package/web/assets/{SkillSettings-CZ98gDWn.js → SkillSettings-DV-H22PD.js} +2 -2
  21. package/web/assets/{Tooltip--ZEIq327.js → Tooltip-CXXgLchR.js} +1 -1
  22. package/web/assets/{arc-BSskkHkz.js → arc-CsNe9vqq.js} +1 -1
  23. package/web/assets/{architectureDiagram-3BPJPVTR-B3e2_Mi5.js → architectureDiagram-3BPJPVTR-_CgItpOp.js} +1 -1
  24. package/web/assets/{arrow-left-mbUIwPsq.js → arrow-left-ME3pery9.js} +1 -1
  25. package/web/assets/{blockDiagram-GPEHLZMM-BSII-1bz.js → blockDiagram-GPEHLZMM-DggqvY56.js} +1 -1
  26. package/web/assets/{c4Diagram-AAUBKEIU-DA3DfWUR.js → c4Diagram-AAUBKEIU-CBEWjSQQ.js} +1 -1
  27. package/web/assets/channel-BfCdub6c.js +1 -0
  28. package/web/assets/{chunk-2J33WTMH-B112AqHa.js → chunk-2J33WTMH-BPslIGSV.js} +1 -1
  29. package/web/assets/{chunk-4BX2VUAB-DnNs4Y-E.js → chunk-4BX2VUAB-DRxxZx72.js} +1 -1
  30. package/web/assets/{chunk-55IACEB6-BEqL8hBV.js → chunk-55IACEB6-BFTmdNv6.js} +1 -1
  31. package/web/assets/{chunk-727SXJPM-DBBS3g7k.js → chunk-727SXJPM-B0H5cxJb.js} +1 -1
  32. package/web/assets/{chunk-AQP2D5EJ-B9jCastR.js → chunk-AQP2D5EJ-CAGZpQVz.js} +1 -1
  33. package/web/assets/{chunk-FMBD7UC4-DllPbdIS.js → chunk-FMBD7UC4-YZOsDkKK.js} +1 -1
  34. package/web/assets/{chunk-ND2GUHAM-D9KZG0cK.js → chunk-ND2GUHAM-Dv0BqvL4.js} +1 -1
  35. package/web/assets/{chunk-QZHKN3VN-BoD6R3M0.js → chunk-QZHKN3VN-kcqi3_AE.js} +1 -1
  36. package/web/assets/classDiagram-4FO5ZUOK-HMqvnuHk.js +1 -0
  37. package/web/assets/classDiagram-v2-Q7XG4LA2-HMqvnuHk.js +1 -0
  38. package/web/assets/{cose-bilkent-S5V4N54A-BXVnnRnw.js → cose-bilkent-S5V4N54A-BzR7T4Z0.js} +1 -1
  39. package/web/assets/{cynefin-OW5HDTMX-B-6oGbPp.js → cynefin-OW5HDTMX-BzoTogr4.js} +1 -1
  40. package/web/assets/{dagre-BM42HDAG-B22lGQ6O.js → dagre-BM42HDAG-CHHzC_h0.js} +1 -1
  41. package/web/assets/{diagram-2AECGRRQ-CJpCn-CU.js → diagram-2AECGRRQ-Dq2u3QFv.js} +1 -1
  42. package/web/assets/{diagram-5GNKFQAL-CXv-E4RN.js → diagram-5GNKFQAL-Dyiw22Ms.js} +1 -1
  43. package/web/assets/{diagram-KO2AKTUF-DE6YITcQ.js → diagram-KO2AKTUF-AJOZF7eS.js} +1 -1
  44. package/web/assets/{diagram-LMA3HP47-C6a1LN_b.js → diagram-LMA3HP47-BWjJzFe2.js} +1 -1
  45. package/web/assets/{diagram-OG6HWLK6-lzlMxndk.js → diagram-OG6HWLK6-BCPdwc8z.js} +1 -1
  46. package/web/assets/{erDiagram-TEJ5UH35-C33pLVdS.js → erDiagram-TEJ5UH35-BSGcQbVD.js} +1 -1
  47. package/web/assets/{flowDiagram-I6XJVG4X-CNEnFS_c.js → flowDiagram-I6XJVG4X-C_2SM7Fa.js} +1 -1
  48. package/web/assets/{ganttDiagram-6RSMTGT7-Dvt_IgnY.js → ganttDiagram-6RSMTGT7-CDqVoaY1.js} +1 -1
  49. package/web/assets/{gitGraphDiagram-PVQCEYII-DEM3UDeh.js → gitGraphDiagram-PVQCEYII-BVDOraAA.js} +1 -1
  50. package/web/assets/{index-BbPaKBmv.css → index-DCEhwLss.css} +1 -1
  51. package/web/assets/{index-AEXvUA5U.js → index-DKAjh3Jq.js} +1 -1
  52. package/web/assets/index-DVjYS93F.js +248 -0
  53. package/web/assets/{index-B4STIxMF.js → index-DwhvmzI8.js} +5 -5
  54. package/web/assets/{index10-BMLJ-2NW.js → index10-f2I9Ayxh.js} +1 -1
  55. package/web/assets/{index5-BvcjsDmt.js → index5-Blb0RoSP.js} +1 -1
  56. package/web/assets/{index6-CxMZBEKt.js → index6-CTZ8yAb4.js} +1 -1
  57. package/web/assets/{index8-bIdcFO9W.js → index8-DfdXis2a.js} +1 -1
  58. package/web/assets/{index9-DBx_o1y8.js → index9-Dw4KfUCH.js} +1 -1
  59. package/web/assets/{infoDiagram-5YYISTIA-BYT4MYJl.js → infoDiagram-5YYISTIA-DHvGqVaW.js} +1 -1
  60. package/web/assets/{ishikawaDiagram-YF4QCWOH-C9V1Zhoz.js → ishikawaDiagram-YF4QCWOH-CPlDNCmB.js} +1 -1
  61. package/web/assets/{journeyDiagram-JHISSGLW-Be6x6oc7.js → journeyDiagram-JHISSGLW-D4ApVy2o.js} +1 -1
  62. package/web/assets/{kanban-definition-UN3LZRKU-BctYKWYf.js → kanban-definition-UN3LZRKU-CdMvzpap.js} +1 -1
  63. package/web/assets/{linear-Dl_nEC-L.js → linear-DLDicOVi.js} +1 -1
  64. package/web/assets/{markstream-CvxnTmYJ.js → markstream-Cmk_Kis9.js} +2 -2
  65. package/web/assets/{mermaid.core-qKUR3_rw.js → mermaid.core-QMchuDAN.js} +4 -4
  66. package/web/assets/{mindmap-definition-RKZ34NQL-CeMPPNxO.js → mindmap-definition-RKZ34NQL-BfupSgJ_.js} +1 -1
  67. package/web/assets/{pieDiagram-4H26LBE5-DDfXBtNB.js → pieDiagram-4H26LBE5-xUNlFhrU.js} +1 -1
  68. package/web/assets/{quadrantDiagram-W4KKPZXB-DM7LwKAJ.js → quadrantDiagram-W4KKPZXB-B1Uc835t.js} +1 -1
  69. package/web/assets/{requirementDiagram-4Y6WPE33-CaWzWB7c.js → requirementDiagram-4Y6WPE33-CkSs-69D.js} +1 -1
  70. package/web/assets/{sankeyDiagram-5OEKKPKP-DC1oe_AT.js → sankeyDiagram-5OEKKPKP-CEwLIfRT.js} +1 -1
  71. package/web/assets/{sequenceDiagram-3UESZ5HK-BZM66sLw.js → sequenceDiagram-3UESZ5HK-M_9hs2P6.js} +1 -1
  72. package/web/assets/{stateDiagram-AJRCARHV-BAaUZKRp.js → stateDiagram-AJRCARHV-CUXGSTho.js} +1 -1
  73. package/web/assets/stateDiagram-v2-BHNVJYJU-BIgjzG10.js +1 -0
  74. package/web/assets/{timeline-definition-PNZ67QCA-Boz2EyqB.js → timeline-definition-PNZ67QCA-Diw4BdiV.js} +1 -1
  75. package/web/assets/{vennDiagram-CIIHVFJN-ByQmaid9.js → vennDiagram-CIIHVFJN-BA6gOXtk.js} +1 -1
  76. package/web/assets/{wardleyDiagram-YWT4CUSO-ByOBzspB.js → wardleyDiagram-YWT4CUSO-L3ox1HvQ.js} +1 -1
  77. package/web/assets/{xychartDiagram-2RQKCTM6-BNgy6nQp.js → xychartDiagram-2RQKCTM6-CZ9XDAvq.js} +1 -1
  78. package/web/assets/zh-CN-Bv-Uv5nk.js +1 -0
  79. package/web/dimcode-web.json +2 -2
  80. package/web/index.html +2 -2
  81. package/web/assets/DiagnosticsSettings-YSRtq2dI.js +0 -1
  82. package/web/assets/McpSettings-BhAZ-WL2.css +0 -1
  83. package/web/assets/McpSettings-y4Wzg8CT.js +0 -1
  84. package/web/assets/PermissionsSettings-DQV3cdej.js +0 -1
  85. package/web/assets/channel-DrR7UcgS.js +0 -1
  86. package/web/assets/classDiagram-4FO5ZUOK-DGOBz3OV.js +0 -1
  87. package/web/assets/classDiagram-v2-Q7XG4LA2-DGOBz3OV.js +0 -1
  88. package/web/assets/index-CenMTLFY.js +0 -247
  89. package/web/assets/stateDiagram-v2-BHNVJYJU-DTfJIIDB.js +0 -1
  90. package/web/assets/zh-CN-DtOnK_oD.js +0 -1
@@ -1 +1 @@
1
- import{d as ne,f as le,w as J,x as ie,c as n,j as T,e as l,t as e,u as t,b as k,a as u,F as b,h as oe,m as re,E as M,r as g,z as $,o as s}from"./vendor-vue-CncuOShJ.js";import{u as ue,h as ce,B as de,i as O,a as Q,j as ve,s as pe,k as he}from"./index-CenMTLFY.js";import{u as _e}from"./settings-general-dc8P6dA0.js";import{_ as ge,R as ye,E as V,r as fe,a as me,b as be,c as we}from"./ProviderAuthFlow.vue_vue_type_script_setup_true_lang-opd2fMYR.js";import{m as A}from"./context-Grqd_9Lt.js";const ke={class:"settings-page"},xe={"data-route-heading":"",tabindex:"-1"},Ie={key:0,class:"ui-banner settings-banner","data-tone":"danger",role:"alert"},Ce=["disabled"],Ue=["disabled"],Se={key:2,class:"ui-banner settings-banner",role:"status"},Ae={key:3,class:"settings-card"},Ee={class:"settings-help"},Le={class:"settings-card"},Be={key:0,class:"settings-identity"},Te={class:"settings-avatar"},De={class:"settings-identity-text"},Fe={key:0},Re={key:1},Pe=["disabled"],Me={class:"account-login-heading"},$e={key:0,class:"settings-card settings-usage"},je={class:"settings-list-toolbar"},Ne=["aria-label","disabled"],Oe={key:0,class:"ui-banner","data-tone":"danger",role:"alert"},Ve={key:1,class:"settings-identity"},ze={class:"settings-identity-text"},He={key:0},We={key:0},Ye={key:1},Ge={key:2},Ke={class:"settings-meter-label"},qe={key:0},Je={key:1},Qe=["value","max","aria-label"],Xe={key:1,class:"settings-meta"},Ze={class:"settings-inline-actions"},et=["href"],tt=["href"],at={key:1,class:"settings-card settings-form"},st={key:0,class:"ui-banner","data-tone":"danger",role:"alert"},nt={class:"settings-row-main"},lt={key:0},it=["disabled","onClick"],ot={key:0,class:"settings-help"},rt={key:2,class:"settings-card settings-form"},ut={key:0,class:"ui-banner","data-tone":"danger",role:"alert"},ct={class:"settings-help"},dt=["value"],vt={class:"settings-inline-actions"},pt=["href"],ht={key:1,class:"settings-help"},_t=ne({__name:"AccountSettings",setup(gt){const{t:c,locale:X}=le({messages:pe}),v=_e(),p=ue(),h=g(),o=g(),_=g(),D=g(),L=g(""),B=g(""),w=g(),j=g(!1),z=g(!1),x=g(!0),y=g(!1),C=g(""),F=g(),P=g(""),N=g(),U=$(()=>{var a,r;return(r=(a=h.value)==null?void 0:a.account)==null?void 0:r.state.identity}),R=$(()=>{var a,r;return((r=(a=h.value)==null?void 0:a.account)==null?void 0:r.state.authenticated)===!0}),H=$(()=>{var a,r;return((a=U.value)==null?void 0:a.name)||((r=U.value)==null?void 0:r.email)||c("account")}),Z=$(()=>{const a=o.value;if(!a)return[];const r=[];a.credits&&r.push({id:"credits",label:c("credits"),used:a.credits.usedUnits,total:a.credits.totalUnits,remaining:a.credits.remainingUnits,unlimited:a.credits.unlimited,expires:a.credits.resetsAt});for(const d of a.windows)r.push({id:`window-${d.durationHours}`,label:`${d.durationHours} h`,used:d.tokenUsed,total:d.tokenCap,expires:d.expiresAt});for(const d of a.features)r.push({id:d.key,label:d.key,used:d.used,total:d.allowance,remaining:d.remaining,unlimited:d.unlimited,expires:d.periodEnd});return r});J([()=>{var a;return(a=h.value)==null?void 0:a.providerId},()=>{var a;return(a=U.value)==null?void 0:a.issuer},()=>{var a;return(a=U.value)==null?void 0:a.subject},R],()=>{w.value=void 0,o.value=void 0,_.value=void 0},{flush:"sync"});async function S(){var a,r;x.value=!0,C.value="",F.value=void 0,P.value="";try{const d=await p.client.call("provider.management",{},fe);if(h.value=d.providers.find(f=>f.credentialAuthority==="account"),D.value=void 0,L.value="",(r=(a=h.value)==null?void 0:a.account)!=null&&r.state.authenticated){const f={providerId:h.value.providerId};await Promise.all([p.client.call("account.usage",f,me).then(m=>{o.value=m},m=>{P.value=A(m)}),p.client.call("account.referral",f,be).then(m=>{_.value=m},m=>{L.value=A(m)})])}const I=d.errors.find(f=>f.providerId==="dimcode-api-oauth");I&&(C.value=I.message,F.value=I.providerId)}catch(d){C.value=A(d)}finally{x.value=!1}}async function ee(){if(!(!F.value||y.value)){y.value=!0;try{await p.client.call("account.recover",{providerId:F.value},O),await Promise.all([S(),Q().load()])}catch(a){C.value=A(a)}finally{y.value=!1}}}async function te(){var r;const a=h.value;if(!(!a||y.value||!await((r=N.value)==null?void 0:r.open(c("signOutConfirm"),{confirmLabel:c("signOut")})))){y.value=!0;try{await p.client.call("account.logout",{providerId:a.providerId},O),w.value=void 0,await Promise.all([S(),Q().load()])}catch(d){C.value=A(d)}finally{y.value=!1}}}async function ae(){var a;if((a=_.value)!=null&&a.inviteUrl)try{await ve(_.value.inviteUrl),z.value=!0}catch(r){L.value=A(r)}}async function W(){if(!(!h.value||p.phase!=="connected")){B.value="";try{D.value=await p.client.call("account.reset_batches",{providerId:h.value.providerId},we)}catch(a){B.value=A(a)}}}async function se(a){var I,f;const r=(I=o.value)==null?void 0:I.subscriptionId;if(y.value||!h.value||r===void 0||w.value&&w.value.resetType!==a)return;const d=a==="window"?v("Use one credit to reset the current usage window?","使用一次额度重置当前用量窗口?"):v("Use one credit to reset this month's full usage?","使用一次额度重置本月全部用量?");if(await((f=N.value)==null?void 0:f.open(d,{confirmLabel:c("reset")}))){y.value=!0,B.value="",w.value??(w.value={providerId:h.value.providerId,subscriptionId:r,resetType:a,idempotencyKey:crypto.randomUUID()});try{await p.client.call("account.apply_reset",w.value,O),w.value=void 0,await S(),j.value&&await W()}catch(m){B.value=`${A(m)} ${v("Retry the same reset to safely check its result; no second credit will be consumed.","请重试同一种重置以安全确认结果;不会重复消耗额度。")}`}finally{y.value=!1}}}return J(()=>p.phase,(a,r)=>{a==="connected"&&r!=="connected"&&S()}),ie(S),(a,r)=>{var d,I,f,m,Y,G,K,q;return s(),n("article",ke,[T(ce,{ref_key:"confirm",ref:N},null,512),l("header",null,[l("h2",xe,e(t(c)("account")),1),l("p",null,e(t(c)("accountDescription")),1)]),C.value?(s(),n("p",Ie,[k(e(C.value)+" ",1),l("button",{class:"ui-button","data-variant":"ghost",disabled:x.value||t(p).phase!=="connected",onClick:S},e(t(c)("retry")),9,Ce)])):u("",!0),F.value&&t(p).supports("account.recover")?(s(),n("button",{key:1,class:"ui-button","data-variant":"secondary",disabled:y.value||x.value||t(p).phase!=="connected",onClick:ee},e(t(v)("Recover stored sign-in","恢复已保存的登录")),9,Ue)):u("",!0),x.value?(s(),n("p",Se,e(t(c)("loading")),1)):!h.value&&!C.value?(s(),n("section",Ae,[l("p",Ee,e(t(c)("accountUnavailable")),1)])):u("",!0),h.value?(s(),n(b,{key:4},[l("section",Le,[R.value?(s(),n("div",Be,[l("span",Te,e(H.value.slice(0,2).toUpperCase()),1),l("div",De,[l("strong",null,e(H.value),1),(d=U.value)!=null&&d.email?(s(),n("p",Fe,e(U.value.email),1)):u("",!0),(I=U.value)!=null&&I.subject?(s(),n("p",Re,e(t(c)("uid"))+": "+e(U.value.subject),1)):u("",!0)]),l("button",{class:"ui-button","data-variant":"ghost",disabled:y.value||x.value||t(p).phase!=="connected",onClick:te},e(t(c)("signOut")),9,Pe)])):(s(),n(b,{key:1},[l("div",Me,[T(de,{"aria-hidden":"true"}),l("h3",null,e(t(c)("signIn")),1)]),(s(),oe(ge,{key:h.value.providerId,provider:h.value,onFinished:S},null,8,["provider"]))],64))]),R.value?(s(),n("section",$e,[l("div",je,[l("h3",null,e(t(c)("plan")),1),l("button",{class:"ui-icon-button","data-variant":"ghost","aria-label":t(c)("refresh"),disabled:x.value||t(p).phase!=="connected",onClick:S},[T(t(ye),{class:re({"account-refreshing":x.value}),"aria-hidden":"true"},null,8,["class"])],8,Ne)]),P.value?(s(),n("p",Oe,e(P.value),1)):u("",!0),(f=o.value)!=null&&f.plan?(s(),n("div",Ve,[l("div",ze,[l("strong",null,e(o.value.plan.name),1),l("p",null,[k(e(o.value.plan.status),1),o.value.plan.expiresAt?(s(),n("span",He," · "+e(new Date(o.value.plan.expiresAt).toLocaleDateString()),1)):u("",!0)]),o.value.plan.priceAmount!==void 0?(s(),n("p",We,[k(e((o.value.plan.priceAmount/100).toLocaleString(t(X),{minimumFractionDigits:2}))+" "+e(o.value.plan.priceCurrency),1),o.value.plan.priceInterval?(s(),n(b,{key:0},[k(" / "+e(o.value.plan.priceInterval),1)],64)):u("",!0)])):u("",!0),o.value.plan.cancelAtPeriodEnd?(s(),n("p",Ye,e(t(v)("Cancels at the end of this term","将在本期结束后取消")),1)):u("",!0),o.value.plan.lastTermStatus?(s(),n("p",Ge,e(t(v)("Previous term","上一周期"))+": "+e(o.value.plan.lastTermStatus)+" · "+e(o.value.plan.lastTermStart)+" — "+e(o.value.plan.lastTermEnd),1)):u("",!0)])])):u("",!0),(s(!0),n(b,null,M(Z.value,i=>(s(),n("div",{key:i.id,class:"settings-meter"},[l("div",Ke,[l("span",null,e(i.label),1),i.unlimited?(s(),n("span",qe,e(t(c)("unlimited")),1)):(s(),n("span",Je,[i.used!==void 0?(s(),n(b,{key:0},[k(e(i.used.toLocaleString()),1)],64)):u("",!0),i.total!==void 0?(s(),n(b,{key:1},[k(" / "+e(i.total.toLocaleString()),1)],64)):u("",!0),i.remaining!==void 0?(s(),n(b,{key:2},[k(" · "+e(t(c)("remaining"))+" "+e(i.remaining.toLocaleString()),1)],64)):u("",!0)]))]),!i.unlimited&&i.total!==void 0&&i.total>0&&i.used!==void 0?(s(),n("progress",{key:0,value:i.used,max:i.total,"aria-label":i.label},null,8,Qe)):u("",!0),i.expires?(s(),n("small",Xe,e(t(c)("expires"))+": "+e(new Date(i.expires).toLocaleString()),1)):u("",!0)]))),128)),l("div",Ze,[(m=o.value)!=null&&m.subscriptionUrl?(s(),n("a",{key:0,class:"ui-button","data-variant":"secondary",href:o.value.subscriptionUrl,target:"_blank",rel:"noopener noreferrer"},[k(e(t(c)("viewPlan")),1),T(t(V),{"aria-hidden":"true"})],8,et)):u("",!0),(Y=o.value)!=null&&Y.pricingUrl?(s(),n("a",{key:1,class:"ui-button","data-variant":"ghost",href:o.value.pricingUrl,target:"_blank",rel:"noopener noreferrer"},[k(e(t(c)("choosePlan")),1),T(t(V),{"aria-hidden":"true"})],8,tt)):u("",!0)])])):u("",!0),R.value&&((G=o.value)!=null&&G.resets)?(s(),n("section",at,[l("h3",null,e(t(c)("resetCredits")),1),B.value?(s(),n("p",st,e(B.value),1)):u("",!0),(s(),n(b,null,M(["window","monthlyFull"],i=>l("div",{key:i,class:"settings-row"},[l("div",nt,[l("strong",null,e(i==="window"?t(v)("Window reset","窗口重置"):t(v)("Monthly full reset","每月全量重置"))+" · "+e(o.value.resets[i].availableCount),1),o.value.resets[i].nearestExpiresAt?(s(),n("small",lt,e(t(c)("expires"))+": "+e(new Date(o.value.resets[i].nearestExpiresAt).toLocaleString()),1)):u("",!0)]),l("button",{class:"ui-button","data-variant":"secondary",disabled:y.value||x.value||t(p).phase!=="connected"||(w.value?w.value.resetType!==(i==="window"?"window":"monthly_full"):!o.value.resets[i].availableCount)||o.value.subscriptionId===void 0,onClick:E=>se(i==="window"?"window":"monthly_full")},e(t(c)("reset")),9,it)])),64)),l("details",{onToggle:r[0]||(r[0]=i=>{j.value=i.target.open,j.value&&W()})},[l("summary",null,e(t(v)("Credit batches and expiry","重置额度批次与有效期")),1),D.value?(s(),n(b,{key:0},M(["window","monthlyFull"],i=>l("div",{key:i},[l("h4",null,e(i==="window"?t(v)("Window","窗口"):t(v)("Monthly","每月")),1),(s(!0),n(b,null,M(D.value[i],E=>(s(),n("p",{key:E.grantId,class:"settings-help"},e(E.sourceType)+" · "+e(E.remaining)+" · "+e(E.scopeType)+" "+e(E.subscriptionId)+" · "+e(new Date(E.expiresAt).toLocaleString()),1))),128)),D.value[i].length?u("",!0):(s(),n("p",ot,e(t(v)("No credits","暂无额度")),1))])),64)):u("",!0)],32)])):u("",!0),R.value&&((K=_.value)!=null&&K.enabled||L.value)?(s(),n("section",rt,[l("h3",null,e(t(c)("referral")),1),L.value?(s(),n("p",ut,e(L.value),1)):u("",!0),(q=_.value)!=null&&q.enabled?(s(),n(b,{key:1},[l("p",null,e(t(v)("Invited","已邀请"))+" "+e(_.value.invitedCount)+" · "+e(t(v)("Subscribed","已付费"))+" "+e(_.value.paidCount)+" · "+e(t(v)("Rewards","奖励额度"))+" "+e(_.value.rewardGrantedUnits??"—"),1),l("p",ct,e(t(v)("Your rebate","邀请人返利"))+" "+e(_.value.inviterRebateBp/100)+"% · "+e(t(v)("Friend's discount","受邀人优惠"))+" "+e(_.value.inviteeRebateBp/100)+"%",1),_.value.eligible&&_.value.inviteUrl?(s(),n(b,{key:0},[l("label",null,[l("span",null,e(t(v)("Invitation link","邀请链接")),1),l("input",{class:"ui-field",value:_.value.inviteUrl,readonly:""},null,8,dt)]),l("div",vt,[l("button",{class:"ui-button","data-variant":"secondary",onClick:ae},e(t(c)(z.value?"copied":"copy")),1),l("a",{class:"ui-button","data-variant":"ghost",href:_.value.inviteUrl,target:"_blank",rel:"noopener noreferrer"},[k(e(t(v)("Open","打开")),1),T(t(V),{"aria-hidden":"true"})],8,pt)])],64)):(s(),n("p",ht,e(t(v)("Your account is not eligible for invitations yet.","当前账户暂未获得邀请资格。")),1))],64)):u("",!0)])):u("",!0)],64)):u("",!0)])}}}),kt=he(_t,[["__scopeId","data-v-90febd9c"]]);export{kt as default};
1
+ import{d as ne,f as le,w as J,x as ie,c as n,j as T,e as l,t as e,u as t,b as k,a as u,F as b,h as oe,m as re,E as M,r as g,z as $,o as s}from"./vendor-vue-CncuOShJ.js";import{u as ue,h as ce,B as de,i as O,a as Q,j as ve,s as pe,k as he}from"./index-DVjYS93F.js";import{u as _e}from"./settings-general-dc8P6dA0.js";import{_ as ge,R as ye,E as V,r as fe,a as me,b as be,c as we}from"./ProviderAuthFlow.vue_vue_type_script_setup_true_lang-Dh0zqlBj.js";import{m as A}from"./context-Grqd_9Lt.js";const ke={class:"settings-page"},xe={"data-route-heading":"",tabindex:"-1"},Ie={key:0,class:"ui-banner settings-banner","data-tone":"danger",role:"alert"},Ce=["disabled"],Ue=["disabled"],Se={key:2,class:"ui-banner settings-banner",role:"status"},Ae={key:3,class:"settings-card"},Ee={class:"settings-help"},Le={class:"settings-card"},Be={key:0,class:"settings-identity"},Te={class:"settings-avatar"},De={class:"settings-identity-text"},Fe={key:0},Re={key:1},Pe=["disabled"],Me={class:"account-login-heading"},$e={key:0,class:"settings-card settings-usage"},je={class:"settings-list-toolbar"},Ne=["aria-label","disabled"],Oe={key:0,class:"ui-banner","data-tone":"danger",role:"alert"},Ve={key:1,class:"settings-identity"},ze={class:"settings-identity-text"},He={key:0},We={key:0},Ye={key:1},Ge={key:2},Ke={class:"settings-meter-label"},qe={key:0},Je={key:1},Qe=["value","max","aria-label"],Xe={key:1,class:"settings-meta"},Ze={class:"settings-inline-actions"},et=["href"],tt=["href"],at={key:1,class:"settings-card settings-form"},st={key:0,class:"ui-banner","data-tone":"danger",role:"alert"},nt={class:"settings-row-main"},lt={key:0},it=["disabled","onClick"],ot={key:0,class:"settings-help"},rt={key:2,class:"settings-card settings-form"},ut={key:0,class:"ui-banner","data-tone":"danger",role:"alert"},ct={class:"settings-help"},dt=["value"],vt={class:"settings-inline-actions"},pt=["href"],ht={key:1,class:"settings-help"},_t=ne({__name:"AccountSettings",setup(gt){const{t:c,locale:X}=le({messages:pe}),v=_e(),p=ue(),h=g(),o=g(),_=g(),D=g(),L=g(""),B=g(""),w=g(),j=g(!1),z=g(!1),x=g(!0),y=g(!1),C=g(""),F=g(),P=g(""),N=g(),U=$(()=>{var a,r;return(r=(a=h.value)==null?void 0:a.account)==null?void 0:r.state.identity}),R=$(()=>{var a,r;return((r=(a=h.value)==null?void 0:a.account)==null?void 0:r.state.authenticated)===!0}),H=$(()=>{var a,r;return((a=U.value)==null?void 0:a.name)||((r=U.value)==null?void 0:r.email)||c("account")}),Z=$(()=>{const a=o.value;if(!a)return[];const r=[];a.credits&&r.push({id:"credits",label:c("credits"),used:a.credits.usedUnits,total:a.credits.totalUnits,remaining:a.credits.remainingUnits,unlimited:a.credits.unlimited,expires:a.credits.resetsAt});for(const d of a.windows)r.push({id:`window-${d.durationHours}`,label:`${d.durationHours} h`,used:d.tokenUsed,total:d.tokenCap,expires:d.expiresAt});for(const d of a.features)r.push({id:d.key,label:d.key,used:d.used,total:d.allowance,remaining:d.remaining,unlimited:d.unlimited,expires:d.periodEnd});return r});J([()=>{var a;return(a=h.value)==null?void 0:a.providerId},()=>{var a;return(a=U.value)==null?void 0:a.issuer},()=>{var a;return(a=U.value)==null?void 0:a.subject},R],()=>{w.value=void 0,o.value=void 0,_.value=void 0},{flush:"sync"});async function S(){var a,r;x.value=!0,C.value="",F.value=void 0,P.value="";try{const d=await p.client.call("provider.management",{},fe);if(h.value=d.providers.find(f=>f.credentialAuthority==="account"),D.value=void 0,L.value="",(r=(a=h.value)==null?void 0:a.account)!=null&&r.state.authenticated){const f={providerId:h.value.providerId};await Promise.all([p.client.call("account.usage",f,me).then(m=>{o.value=m},m=>{P.value=A(m)}),p.client.call("account.referral",f,be).then(m=>{_.value=m},m=>{L.value=A(m)})])}const I=d.errors.find(f=>f.providerId==="dimcode-api-oauth");I&&(C.value=I.message,F.value=I.providerId)}catch(d){C.value=A(d)}finally{x.value=!1}}async function ee(){if(!(!F.value||y.value)){y.value=!0;try{await p.client.call("account.recover",{providerId:F.value},O),await Promise.all([S(),Q().load()])}catch(a){C.value=A(a)}finally{y.value=!1}}}async function te(){var r;const a=h.value;if(!(!a||y.value||!await((r=N.value)==null?void 0:r.open(c("signOutConfirm"),{confirmLabel:c("signOut")})))){y.value=!0;try{await p.client.call("account.logout",{providerId:a.providerId},O),w.value=void 0,await Promise.all([S(),Q().load()])}catch(d){C.value=A(d)}finally{y.value=!1}}}async function ae(){var a;if((a=_.value)!=null&&a.inviteUrl)try{await ve(_.value.inviteUrl),z.value=!0}catch(r){L.value=A(r)}}async function W(){if(!(!h.value||p.phase!=="connected")){B.value="";try{D.value=await p.client.call("account.reset_batches",{providerId:h.value.providerId},we)}catch(a){B.value=A(a)}}}async function se(a){var I,f;const r=(I=o.value)==null?void 0:I.subscriptionId;if(y.value||!h.value||r===void 0||w.value&&w.value.resetType!==a)return;const d=a==="window"?v("Use one credit to reset the current usage window?","使用一次额度重置当前用量窗口?"):v("Use one credit to reset this month's full usage?","使用一次额度重置本月全部用量?");if(await((f=N.value)==null?void 0:f.open(d,{confirmLabel:c("reset")}))){y.value=!0,B.value="",w.value??(w.value={providerId:h.value.providerId,subscriptionId:r,resetType:a,idempotencyKey:crypto.randomUUID()});try{await p.client.call("account.apply_reset",w.value,O),w.value=void 0,await S(),j.value&&await W()}catch(m){B.value=`${A(m)} ${v("Retry the same reset to safely check its result; no second credit will be consumed.","请重试同一种重置以安全确认结果;不会重复消耗额度。")}`}finally{y.value=!1}}}return J(()=>p.phase,(a,r)=>{a==="connected"&&r!=="connected"&&S()}),ie(S),(a,r)=>{var d,I,f,m,Y,G,K,q;return s(),n("article",ke,[T(ce,{ref_key:"confirm",ref:N},null,512),l("header",null,[l("h2",xe,e(t(c)("account")),1),l("p",null,e(t(c)("accountDescription")),1)]),C.value?(s(),n("p",Ie,[k(e(C.value)+" ",1),l("button",{class:"ui-button","data-variant":"ghost",disabled:x.value||t(p).phase!=="connected",onClick:S},e(t(c)("retry")),9,Ce)])):u("",!0),F.value&&t(p).supports("account.recover")?(s(),n("button",{key:1,class:"ui-button","data-variant":"secondary",disabled:y.value||x.value||t(p).phase!=="connected",onClick:ee},e(t(v)("Recover stored sign-in","恢复已保存的登录")),9,Ue)):u("",!0),x.value?(s(),n("p",Se,e(t(c)("loading")),1)):!h.value&&!C.value?(s(),n("section",Ae,[l("p",Ee,e(t(c)("accountUnavailable")),1)])):u("",!0),h.value?(s(),n(b,{key:4},[l("section",Le,[R.value?(s(),n("div",Be,[l("span",Te,e(H.value.slice(0,2).toUpperCase()),1),l("div",De,[l("strong",null,e(H.value),1),(d=U.value)!=null&&d.email?(s(),n("p",Fe,e(U.value.email),1)):u("",!0),(I=U.value)!=null&&I.subject?(s(),n("p",Re,e(t(c)("uid"))+": "+e(U.value.subject),1)):u("",!0)]),l("button",{class:"ui-button","data-variant":"ghost",disabled:y.value||x.value||t(p).phase!=="connected",onClick:te},e(t(c)("signOut")),9,Pe)])):(s(),n(b,{key:1},[l("div",Me,[T(de,{"aria-hidden":"true"}),l("h3",null,e(t(c)("signIn")),1)]),(s(),oe(ge,{key:h.value.providerId,provider:h.value,onFinished:S},null,8,["provider"]))],64))]),R.value?(s(),n("section",$e,[l("div",je,[l("h3",null,e(t(c)("plan")),1),l("button",{class:"ui-icon-button","data-variant":"ghost","aria-label":t(c)("refresh"),disabled:x.value||t(p).phase!=="connected",onClick:S},[T(t(ye),{class:re({"account-refreshing":x.value}),"aria-hidden":"true"},null,8,["class"])],8,Ne)]),P.value?(s(),n("p",Oe,e(P.value),1)):u("",!0),(f=o.value)!=null&&f.plan?(s(),n("div",Ve,[l("div",ze,[l("strong",null,e(o.value.plan.name),1),l("p",null,[k(e(o.value.plan.status),1),o.value.plan.expiresAt?(s(),n("span",He," · "+e(new Date(o.value.plan.expiresAt).toLocaleDateString()),1)):u("",!0)]),o.value.plan.priceAmount!==void 0?(s(),n("p",We,[k(e((o.value.plan.priceAmount/100).toLocaleString(t(X),{minimumFractionDigits:2}))+" "+e(o.value.plan.priceCurrency),1),o.value.plan.priceInterval?(s(),n(b,{key:0},[k(" / "+e(o.value.plan.priceInterval),1)],64)):u("",!0)])):u("",!0),o.value.plan.cancelAtPeriodEnd?(s(),n("p",Ye,e(t(v)("Cancels at the end of this term","将在本期结束后取消")),1)):u("",!0),o.value.plan.lastTermStatus?(s(),n("p",Ge,e(t(v)("Previous term","上一周期"))+": "+e(o.value.plan.lastTermStatus)+" · "+e(o.value.plan.lastTermStart)+" — "+e(o.value.plan.lastTermEnd),1)):u("",!0)])])):u("",!0),(s(!0),n(b,null,M(Z.value,i=>(s(),n("div",{key:i.id,class:"settings-meter"},[l("div",Ke,[l("span",null,e(i.label),1),i.unlimited?(s(),n("span",qe,e(t(c)("unlimited")),1)):(s(),n("span",Je,[i.used!==void 0?(s(),n(b,{key:0},[k(e(i.used.toLocaleString()),1)],64)):u("",!0),i.total!==void 0?(s(),n(b,{key:1},[k(" / "+e(i.total.toLocaleString()),1)],64)):u("",!0),i.remaining!==void 0?(s(),n(b,{key:2},[k(" · "+e(t(c)("remaining"))+" "+e(i.remaining.toLocaleString()),1)],64)):u("",!0)]))]),!i.unlimited&&i.total!==void 0&&i.total>0&&i.used!==void 0?(s(),n("progress",{key:0,value:i.used,max:i.total,"aria-label":i.label},null,8,Qe)):u("",!0),i.expires?(s(),n("small",Xe,e(t(c)("expires"))+": "+e(new Date(i.expires).toLocaleString()),1)):u("",!0)]))),128)),l("div",Ze,[(m=o.value)!=null&&m.subscriptionUrl?(s(),n("a",{key:0,class:"ui-button","data-variant":"secondary",href:o.value.subscriptionUrl,target:"_blank",rel:"noopener noreferrer"},[k(e(t(c)("viewPlan")),1),T(t(V),{"aria-hidden":"true"})],8,et)):u("",!0),(Y=o.value)!=null&&Y.pricingUrl?(s(),n("a",{key:1,class:"ui-button","data-variant":"ghost",href:o.value.pricingUrl,target:"_blank",rel:"noopener noreferrer"},[k(e(t(c)("choosePlan")),1),T(t(V),{"aria-hidden":"true"})],8,tt)):u("",!0)])])):u("",!0),R.value&&((G=o.value)!=null&&G.resets)?(s(),n("section",at,[l("h3",null,e(t(c)("resetCredits")),1),B.value?(s(),n("p",st,e(B.value),1)):u("",!0),(s(),n(b,null,M(["window","monthlyFull"],i=>l("div",{key:i,class:"settings-row"},[l("div",nt,[l("strong",null,e(i==="window"?t(v)("Window reset","窗口重置"):t(v)("Monthly full reset","每月全量重置"))+" · "+e(o.value.resets[i].availableCount),1),o.value.resets[i].nearestExpiresAt?(s(),n("small",lt,e(t(c)("expires"))+": "+e(new Date(o.value.resets[i].nearestExpiresAt).toLocaleString()),1)):u("",!0)]),l("button",{class:"ui-button","data-variant":"secondary",disabled:y.value||x.value||t(p).phase!=="connected"||(w.value?w.value.resetType!==(i==="window"?"window":"monthly_full"):!o.value.resets[i].availableCount)||o.value.subscriptionId===void 0,onClick:E=>se(i==="window"?"window":"monthly_full")},e(t(c)("reset")),9,it)])),64)),l("details",{onToggle:r[0]||(r[0]=i=>{j.value=i.target.open,j.value&&W()})},[l("summary",null,e(t(v)("Credit batches and expiry","重置额度批次与有效期")),1),D.value?(s(),n(b,{key:0},M(["window","monthlyFull"],i=>l("div",{key:i},[l("h4",null,e(i==="window"?t(v)("Window","窗口"):t(v)("Monthly","每月")),1),(s(!0),n(b,null,M(D.value[i],E=>(s(),n("p",{key:E.grantId,class:"settings-help"},e(E.sourceType)+" · "+e(E.remaining)+" · "+e(E.scopeType)+" "+e(E.subscriptionId)+" · "+e(new Date(E.expiresAt).toLocaleString()),1))),128)),D.value[i].length?u("",!0):(s(),n("p",ot,e(t(v)("No credits","暂无额度")),1))])),64)):u("",!0)],32)])):u("",!0),R.value&&((K=_.value)!=null&&K.enabled||L.value)?(s(),n("section",rt,[l("h3",null,e(t(c)("referral")),1),L.value?(s(),n("p",ut,e(L.value),1)):u("",!0),(q=_.value)!=null&&q.enabled?(s(),n(b,{key:1},[l("p",null,e(t(v)("Invited","已邀请"))+" "+e(_.value.invitedCount)+" · "+e(t(v)("Subscribed","已付费"))+" "+e(_.value.paidCount)+" · "+e(t(v)("Rewards","奖励额度"))+" "+e(_.value.rewardGrantedUnits??"—"),1),l("p",ct,e(t(v)("Your rebate","邀请人返利"))+" "+e(_.value.inviterRebateBp/100)+"% · "+e(t(v)("Friend's discount","受邀人优惠"))+" "+e(_.value.inviteeRebateBp/100)+"%",1),_.value.eligible&&_.value.inviteUrl?(s(),n(b,{key:0},[l("label",null,[l("span",null,e(t(v)("Invitation link","邀请链接")),1),l("input",{class:"ui-field",value:_.value.inviteUrl,readonly:""},null,8,dt)]),l("div",vt,[l("button",{class:"ui-button","data-variant":"secondary",onClick:ae},e(t(c)(z.value?"copied":"copy")),1),l("a",{class:"ui-button","data-variant":"ghost",href:_.value.inviteUrl,target:"_blank",rel:"noopener noreferrer"},[k(e(t(v)("Open","打开")),1),T(t(V),{"aria-hidden":"true"})],8,pt)])],64)):(s(),n("p",ht,e(t(v)("Your account is not eligible for invitations yet.","当前账户暂未获得邀请资格。")),1))],64)):u("",!0)])):u("",!0)],64)):u("",!0)])}}}),kt=he(_t,[["__scopeId","data-v-90febd9c"]]);export{kt as default};
@@ -1 +1 @@
1
- import{d as J,x as $,c as n,e,t as l,u as s,l as D,C as L,B,j as T,D as N,a as y,F as R,E as U,r as m,z as V,o as i}from"./vendor-vue-CncuOShJ.js";import{u as q}from"./settings-general-dc8P6dA0.js";import{u as G,a as H,r as K,b as Q,d as O,e as W,f as X}from"./index-CenMTLFY.js";import{_ as Y}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as Z,r as ee,m as j}from"./context-Grqd_9Lt.js";const le={class:"settings-page"},ae={"data-route-heading":"",tabindex:"-1"},te=["disabled"],oe=["disabled"],se={class:"settings-card"},ue=["disabled"],ne={value:"",disabled:""},ie=["value"],de=["value"],re={key:0},ve={key:0,class:"settings-card"},ce=["disabled"],pe={value:"agent"},me={value:"inherit"},fe=["value"],he=["value"],be={key:1,class:"settings-card"},_e=["disabled"],ye={value:""},ge=["value"],xe=["value"],ke={key:0,class:"ui-banner","data-tone":"danger"},we={class:"settings-actions"},Ie=["disabled"],Ve=J({__name:"AgentSettings",setup(Se){const o=q(),d=G(),P=H(),f=m(),h=m(),b=m("agent"),r=m(),c=m(""),z=m(!1),A=m(""),C=m(""),g=m(""),v=m(!1),I=m(""),M=m(!1),x=V(()=>{var u;return((u=P.providers)==null?void 0:u.flatMap(t=>t.models.map(p=>({key:JSON.stringify([t.providerId,p.id]),providerId:t.providerId,modelId:p.id,label:`${t.name} / ${p.name}`}))))??[]}),k=V(()=>f.value?JSON.stringify([f.value.providerId,f.value.modelId]):""),w=V(()=>{var u,t;return((u=h.value)==null?void 0:u.policy.mode)==="fixed"?JSON.stringify([h.value.policy.model.providerId,h.value.policy.model.modelId]):((t=h.value)==null?void 0:t.policy.mode)??"agent"}),S=V(()=>z.value&&(g.value!==k.value||b.value!==w.value||r.value!==void 0&&c.value!==(r.value.executablePath??"")));Z(S);async function E(){if(!v.value&&!(S.value&&!window.confirm(o("Discard unsaved defaults?","放弃未保存的默认设置?")))){v.value=!0,I.value="",M.value=!1;try{if(!d.supports("provider.selection"))throw new Error(o("Default model selection is not available on this server.","此服务器不支持默认模型选择。"));const u=A.value.trim(),[t,p,_]=await Promise.all([d.client.call("provider.selection",u?{cwd:u}:{},K),d.supports("collaboration.model_policy")?d.client.call("collaboration.model_policy",{},Q):void 0,d.supports("host.exec_shell.get")?d.client.call("host.exec_shell.get",{},O):void 0,P.load()]);f.value=t,h.value=p,r.value=_,c.value=(_==null?void 0:_.executablePath)??"",b.value=w.value,C.value=u,g.value=k.value,z.value=!0,P.error&&(I.value=P.error)}catch(u){I.value=j(u)}finally{v.value=!1}}}async function F(){const u=x.value.find(t=>t.key===g.value);if(!(v.value||!S.value)){v.value=!0,I.value="",M.value=!1;try{if(g.value!==k.value&&u&&(f.value=await d.client.call("provider.select",{...C.value?{cwd:C.value}:{},providerId:u.providerId,modelId:u.modelId,...f.value?{expectedVersion:f.value.version}:{}},W),g.value=k.value),h.value&&b.value!==w.value){const t=x.value.find(a=>a.key===b.value),p=b.value==="agent"||b.value==="inherit"?{mode:b.value}:t?{mode:"fixed",model:{providerId:t.providerId,modelId:t.modelId}}:void 0;if(!p)throw new Error(o("Choose an available subagent model.","请选择可用的子代理模型。"));const _=await d.client.call("collaboration.set_model_policy",{expectedRevision:h.value.revision,policy:p},X);h.value={revision:_,policy:p}}r.value&&c.value!==(r.value.executablePath??"")&&(r.value=await d.client.call("host.exec_shell.update",{expectedRevision:r.value.revision,...c.value?{executablePath:c.value}:{}},O),c.value=r.value.executablePath??""),M.value=!0}catch(t){I.value=j(t)}finally{v.value=!1}}}return ee(d,E,S),$(E),(u,t)=>{var p,_;return i(),n("article",le,[e("header",null,[e("h2",ae,l(s(o)("Agent","代理")),1),e("p",null,l(s(o)("Choose the default model for new sessions. Existing sessions keep their selected model.","为新会话选择默认模型。现有会话保留其已选模型。")),1)]),e("form",{class:"settings-card settings-form",onSubmit:B(E,["prevent"])},[e("label",null,[e("span",null,l(s(o)("Project directory (blank for the global default)","项目目录(留空表示全局默认)")),1),D(e("input",{"onUpdate:modelValue":t[0]||(t[0]=a=>A.value=a),class:"ui-field","data-size":"md",disabled:v.value,placeholder:"/path/to/project"},null,8,te),[[L,A.value]])]),e("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:v.value},l(s(o)("Load defaults","加载默认设置")),9,oe)],32),T(Y,{busy:v.value,error:I.value,saved:M.value&&!S.value,onReload:E},null,8,["busy","error","saved"]),z.value?(i(),n("form",{key:0,class:"settings-form",onSubmit:B(F,["prevent"])},[e("section",se,[e("h3",null,l(s(o)("Default model","默认模型")),1),e("p",null,l(C.value||s(o)("Global default","全局默认")),1),e("label",null,[e("span",null,l(s(o)("Model","模型")),1),D(e("select",{"onUpdate:modelValue":t[1]||(t[1]=a=>g.value=a),class:"ui-field","data-size":"md",disabled:v.value||!s(d).supports("provider.select")},[e("option",ne,l(s(o)("Automatic fallback — choose a model to pin a default","自动回退 — 选择模型以固定默认值")),1),k.value&&!x.value.some(a=>a.key===k.value)?(i(),n("option",{key:0,value:k.value,disabled:""},l((p=f.value)==null?void 0:p.providerId)+" / "+l((_=f.value)==null?void 0:_.modelId)+" ("+l(s(o)("unavailable","不可用"))+")",9,ie)):y("",!0),(i(!0),n(R,null,U(x.value,a=>(i(),n("option",{key:a.key,value:a.key},l(a.label),9,de))),128))],8,ue),[[N,g.value]])]),x.value.length?y("",!0):(i(),n("p",re,l(s(o)("No selectable models. Configure a provider and its model limits first.","没有可选模型。请先配置提供商和模型限制。")),1))]),h.value?(i(),n("section",ve,[e("h3",null,l(s(o)("Subagent models","子代理模型")),1),e("p",null,l(s(o)("Applies to every newly created native Collaboration member, including named agents. Existing members and external agents are unchanged.","适用于每个新建的原生协作成员,包括命名代理。现有成员和外部代理不受影响。")),1),e("label",null,[e("span",null,l(s(o)("Model policy","模型策略")),1),D(e("select",{"onUpdate:modelValue":t[2]||(t[2]=a=>b.value=a),class:"ui-field","data-size":"md",disabled:v.value||!s(d).supports("collaboration.set_model_policy")},[e("option",pe,l(s(o)("Agent decides (profile / workspace defaults)","由代理决定(配置 / 工作区默认值)")),1),e("option",me,l(s(o)("Inherit requesting branch model","继承请求分支的模型")),1),w.value!=="agent"&&w.value!=="inherit"&&!x.value.some(a=>a.key===w.value)?(i(),n("option",{key:0,value:w.value,disabled:""},l(s(o)("Configured model unavailable","已配置模型不可用")),9,fe)):y("",!0),(i(!0),n(R,null,U(x.value,a=>(i(),n("option",{key:a.key,value:a.key},l(a.label),9,he))),128))],8,ce),[[N,b.value]])])])):y("",!0),r.value?(i(),n("section",be,[e("h3",null,l(s(o)("Command shell","命令 Shell")),1),e("p",null,l(s(o)("Used for new command invocations. Already running processes keep their shell.","用于新启动的命令。已运行的进程保留其原 Shell。")),1),e("label",null,[e("span",null,l(s(o)("Executable","可执行程序")),1),D(e("select",{"onUpdate:modelValue":t[3]||(t[3]=a=>c.value=a),class:"ui-field","data-size":"md",disabled:v.value||!s(d).supports("host.exec_shell.update")},[e("option",ye,l(s(o)("Automatic detection","自动检测")),1),c.value&&!r.value.shells.some(a=>a.executablePath===c.value)?(i(),n("option",{key:0,value:c.value,disabled:""},l(c.value)+" ("+l(s(o)("unavailable","不可用"))+")",9,ge)):y("",!0),(i(!0),n(R,null,U(r.value.shells,a=>(i(),n("option",{key:a.executablePath,value:a.executablePath},l(a.name)+" — "+l(a.executablePath),9,xe))),128))],8,_e),[[N,c.value]])]),r.value.configError?(i(),n("p",ke,l(r.value.configError),1)):y("",!0)])):y("",!0),e("footer",we,[e("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:v.value||!S.value},l(s(o)("Save defaults","保存默认设置")),9,Ie)])],32)):y("",!0)])}}});export{Ve as default};
1
+ import{d as J,x as $,c as n,e,t as l,u as s,l as D,C as L,B,j as T,D as N,a as y,F as R,E as U,r as m,z as V,o as i}from"./vendor-vue-CncuOShJ.js";import{u as q}from"./settings-general-dc8P6dA0.js";import{u as G,a as H,r as K,b as Q,d as O,e as W,f as X}from"./index-DVjYS93F.js";import{_ as Y}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as Z,r as ee,m as j}from"./context-Grqd_9Lt.js";const le={class:"settings-page"},ae={"data-route-heading":"",tabindex:"-1"},te=["disabled"],oe=["disabled"],se={class:"settings-card"},ue=["disabled"],ne={value:"",disabled:""},ie=["value"],de=["value"],re={key:0},ve={key:0,class:"settings-card"},ce=["disabled"],pe={value:"agent"},me={value:"inherit"},fe=["value"],he=["value"],be={key:1,class:"settings-card"},_e=["disabled"],ye={value:""},ge=["value"],xe=["value"],ke={key:0,class:"ui-banner","data-tone":"danger"},we={class:"settings-actions"},Ie=["disabled"],Ve=J({__name:"AgentSettings",setup(Se){const o=q(),d=G(),P=H(),f=m(),h=m(),b=m("agent"),r=m(),c=m(""),z=m(!1),A=m(""),C=m(""),g=m(""),v=m(!1),I=m(""),M=m(!1),x=V(()=>{var u;return((u=P.providers)==null?void 0:u.flatMap(t=>t.models.map(p=>({key:JSON.stringify([t.providerId,p.id]),providerId:t.providerId,modelId:p.id,label:`${t.name} / ${p.name}`}))))??[]}),k=V(()=>f.value?JSON.stringify([f.value.providerId,f.value.modelId]):""),w=V(()=>{var u,t;return((u=h.value)==null?void 0:u.policy.mode)==="fixed"?JSON.stringify([h.value.policy.model.providerId,h.value.policy.model.modelId]):((t=h.value)==null?void 0:t.policy.mode)??"agent"}),S=V(()=>z.value&&(g.value!==k.value||b.value!==w.value||r.value!==void 0&&c.value!==(r.value.executablePath??"")));Z(S);async function E(){if(!v.value&&!(S.value&&!window.confirm(o("Discard unsaved defaults?","放弃未保存的默认设置?")))){v.value=!0,I.value="",M.value=!1;try{if(!d.supports("provider.selection"))throw new Error(o("Default model selection is not available on this server.","此服务器不支持默认模型选择。"));const u=A.value.trim(),[t,p,_]=await Promise.all([d.client.call("provider.selection",u?{cwd:u}:{},K),d.supports("collaboration.model_policy")?d.client.call("collaboration.model_policy",{},Q):void 0,d.supports("host.exec_shell.get")?d.client.call("host.exec_shell.get",{},O):void 0,P.load()]);f.value=t,h.value=p,r.value=_,c.value=(_==null?void 0:_.executablePath)??"",b.value=w.value,C.value=u,g.value=k.value,z.value=!0,P.error&&(I.value=P.error)}catch(u){I.value=j(u)}finally{v.value=!1}}}async function F(){const u=x.value.find(t=>t.key===g.value);if(!(v.value||!S.value)){v.value=!0,I.value="",M.value=!1;try{if(g.value!==k.value&&u&&(f.value=await d.client.call("provider.select",{...C.value?{cwd:C.value}:{},providerId:u.providerId,modelId:u.modelId,...f.value?{expectedVersion:f.value.version}:{}},W),g.value=k.value),h.value&&b.value!==w.value){const t=x.value.find(a=>a.key===b.value),p=b.value==="agent"||b.value==="inherit"?{mode:b.value}:t?{mode:"fixed",model:{providerId:t.providerId,modelId:t.modelId}}:void 0;if(!p)throw new Error(o("Choose an available subagent model.","请选择可用的子代理模型。"));const _=await d.client.call("collaboration.set_model_policy",{expectedRevision:h.value.revision,policy:p},X);h.value={revision:_,policy:p}}r.value&&c.value!==(r.value.executablePath??"")&&(r.value=await d.client.call("host.exec_shell.update",{expectedRevision:r.value.revision,...c.value?{executablePath:c.value}:{}},O),c.value=r.value.executablePath??""),M.value=!0}catch(t){I.value=j(t)}finally{v.value=!1}}}return ee(d,E,S),$(E),(u,t)=>{var p,_;return i(),n("article",le,[e("header",null,[e("h2",ae,l(s(o)("Agent","代理")),1),e("p",null,l(s(o)("Choose the default model for new sessions. Existing sessions keep their selected model.","为新会话选择默认模型。现有会话保留其已选模型。")),1)]),e("form",{class:"settings-card settings-form",onSubmit:B(E,["prevent"])},[e("label",null,[e("span",null,l(s(o)("Project directory (blank for the global default)","项目目录(留空表示全局默认)")),1),D(e("input",{"onUpdate:modelValue":t[0]||(t[0]=a=>A.value=a),class:"ui-field","data-size":"md",disabled:v.value,placeholder:"/path/to/project"},null,8,te),[[L,A.value]])]),e("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:v.value},l(s(o)("Load defaults","加载默认设置")),9,oe)],32),T(Y,{busy:v.value,error:I.value,saved:M.value&&!S.value,onReload:E},null,8,["busy","error","saved"]),z.value?(i(),n("form",{key:0,class:"settings-form",onSubmit:B(F,["prevent"])},[e("section",se,[e("h3",null,l(s(o)("Default model","默认模型")),1),e("p",null,l(C.value||s(o)("Global default","全局默认")),1),e("label",null,[e("span",null,l(s(o)("Model","模型")),1),D(e("select",{"onUpdate:modelValue":t[1]||(t[1]=a=>g.value=a),class:"ui-field","data-size":"md",disabled:v.value||!s(d).supports("provider.select")},[e("option",ne,l(s(o)("Automatic fallback — choose a model to pin a default","自动回退 — 选择模型以固定默认值")),1),k.value&&!x.value.some(a=>a.key===k.value)?(i(),n("option",{key:0,value:k.value,disabled:""},l((p=f.value)==null?void 0:p.providerId)+" / "+l((_=f.value)==null?void 0:_.modelId)+" ("+l(s(o)("unavailable","不可用"))+")",9,ie)):y("",!0),(i(!0),n(R,null,U(x.value,a=>(i(),n("option",{key:a.key,value:a.key},l(a.label),9,de))),128))],8,ue),[[N,g.value]])]),x.value.length?y("",!0):(i(),n("p",re,l(s(o)("No selectable models. Configure a provider and its model limits first.","没有可选模型。请先配置提供商和模型限制。")),1))]),h.value?(i(),n("section",ve,[e("h3",null,l(s(o)("Subagent models","子代理模型")),1),e("p",null,l(s(o)("Applies to every newly created native Collaboration member, including named agents. Existing members and external agents are unchanged.","适用于每个新建的原生协作成员,包括命名代理。现有成员和外部代理不受影响。")),1),e("label",null,[e("span",null,l(s(o)("Model policy","模型策略")),1),D(e("select",{"onUpdate:modelValue":t[2]||(t[2]=a=>b.value=a),class:"ui-field","data-size":"md",disabled:v.value||!s(d).supports("collaboration.set_model_policy")},[e("option",pe,l(s(o)("Agent decides (profile / workspace defaults)","由代理决定(配置 / 工作区默认值)")),1),e("option",me,l(s(o)("Inherit requesting branch model","继承请求分支的模型")),1),w.value!=="agent"&&w.value!=="inherit"&&!x.value.some(a=>a.key===w.value)?(i(),n("option",{key:0,value:w.value,disabled:""},l(s(o)("Configured model unavailable","已配置模型不可用")),9,fe)):y("",!0),(i(!0),n(R,null,U(x.value,a=>(i(),n("option",{key:a.key,value:a.key},l(a.label),9,he))),128))],8,ce),[[N,b.value]])])])):y("",!0),r.value?(i(),n("section",be,[e("h3",null,l(s(o)("Command shell","命令 Shell")),1),e("p",null,l(s(o)("Used for new command invocations. Already running processes keep their shell.","用于新启动的命令。已运行的进程保留其原 Shell。")),1),e("label",null,[e("span",null,l(s(o)("Executable","可执行程序")),1),D(e("select",{"onUpdate:modelValue":t[3]||(t[3]=a=>c.value=a),class:"ui-field","data-size":"md",disabled:v.value||!s(d).supports("host.exec_shell.update")},[e("option",ye,l(s(o)("Automatic detection","自动检测")),1),c.value&&!r.value.shells.some(a=>a.executablePath===c.value)?(i(),n("option",{key:0,value:c.value,disabled:""},l(c.value)+" ("+l(s(o)("unavailable","不可用"))+")",9,ge)):y("",!0),(i(!0),n(R,null,U(r.value.shells,a=>(i(),n("option",{key:a.executablePath,value:a.executablePath},l(a.name)+" — "+l(a.executablePath),9,xe))),128))],8,_e),[[N,c.value]])]),r.value.configError?(i(),n("p",ke,l(r.value.configError),1)):y("",!0)])):y("",!0),e("footer",we,[e("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:v.value||!S.value},l(s(o)("Save defaults","保存默认设置")),9,Ie)])],32)):y("",!0)])}}});export{Ve as default};
@@ -1,4 +1,4 @@
1
- import{u as y}from"./settings-general-dc8P6dA0.js";import{c,K as _,k as v}from"./index-CenMTLFY.js";import{d as k,c as r,e as t,t as s,u as e,a as f,F as u,E as p,m as b,h as x,Q as C,o as l}from"./vendor-vue-CncuOShJ.js";/**
1
+ import{u as y}from"./settings-general-dc8P6dA0.js";import{c,K as _,k as v}from"./index-DVjYS93F.js";import{d as k,c as r,e as t,t as s,u as e,a as f,F as u,E as p,m as b,h as x,Q as C,o as l}from"./vendor-vue-CncuOShJ.js";/**
2
2
  * @license lucide-vue-next v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{d as A,x as B,c,e as s,t as a,u as n,l as x,C,B as N,j as I,F as z,E as T,a as _,r as d,b as w,k as $,R as L,o as v}from"./vendor-vue-CncuOShJ.js";import{u as j}from"./settings-general-dc8P6dA0.js";import{u as E,D as F,E as M,i as P,k as q}from"./index-CenMTLFY.js";import{_ as O}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{r as U,m as D}from"./context-Grqd_9Lt.js";const Q={class:"settings-page"},G={"data-route-heading":"",tabindex:"-1"},H=["disabled"],J=["datetime"],K={class:"settings-actions"},W=["disabled","onClick"],X={key:0,role:"status"},Y=["disabled"],Z=A({__name:"ArchivedSettings",setup(ee){const o=j(),h=E(),R=F(),l=d(),g=d(""),b=d(""),S=d(""),k=d(""),i=d(!1),m=d("");async function p(r=!1){var t,f;if(!i.value){i.value=!0,m.value="";try{const u=r?S.value:g.value.trim(),e=r?k.value:b.value.trim(),y=await h.client.call("session.catalog",{limit:50,withPreview:!0,...u?{query:u}:{},...e?{cwd:e}:{},...r&&((t=l.value)!=null&&t.nextCursor)?{cursor:l.value.nextCursor}:{}},M);l.value={sessions:r?[...((f=l.value)==null?void 0:f.sessions)??[],...y.sessions]:y.sessions,nextCursor:y.nextCursor},S.value=u,k.value=e}catch(u){m.value=D(u)}finally{i.value=!1}}}async function V(r){if(!(i.value||!window.confirm(o("Permanently delete this session and all its history? This cannot be undone.","永久删除此会话及其全部历史?此操作不可撤销。")))){i.value=!0,m.value="";try{await h.client.call("session.delete",{sessionId:r.sessionId},P),l.value&&(l.value.sessions=l.value.sessions.filter(t=>t.sessionId!==r.sessionId)),R.forget(r.sessionId)}catch(t){m.value=D(t)}finally{i.value=!1}}}return U(h,()=>p()),B(()=>p()),(r,t)=>{var f,u;return v(),c("article",Q,[s("header",null,[s("h2",G,a(n(o)("Saved sessions","已保存的会话")),1),s("p",null,a(n(o)("Browse persisted history, reopen sessions or permanently delete them. This runtime does not have a separate archived flag; closing a session keeps its saved history.","浏览持久化历史、重新打开会话或永久删除会话。当前运行时没有单独的归档标记;关闭会话会保留其已保存历史。")),1)]),s("form",{class:"settings-card settings-form",role:"search",onSubmit:t[2]||(t[2]=N(e=>p(),["prevent"]))},[s("label",null,[s("span",null,a(n(o)("Search history","搜索历史")),1),x(s("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>g.value=e),class:"ui-field","data-size":"md",type:"search"},null,512),[[C,g.value]])]),s("label",null,[s("span",null,a(n(o)("Project directory (optional)","项目目录(可选)")),1),x(s("input",{"onUpdate:modelValue":t[1]||(t[1]=e=>b.value=e),class:"ui-field","data-size":"md",placeholder:"/path/to/project"},null,512),[[C,b.value]])]),s("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:i.value},a(n(o)("Search","搜索")),9,H)],32),I(O,{busy:i.value,error:m.value,onReload:t[3]||(t[3]=e=>p())},null,8,["busy","error"]),(v(!0),c(z,null,T((f=l.value)==null?void 0:f.sessions,e=>(v(),c("section",{key:e.sessionId,class:"settings-card"},[s("h3",null,a(e.preview||e.sessionId),1),s("p",null,[s("code",null,a(e.cwd),1)]),s("p",null,[s("time",{datetime:new Date(e.updatedAt).toISOString()},a(new Date(e.updatedAt).toLocaleString()),9,J),w(" · "+a(e.model.modelId),1),e.running?(v(),c(z,{key:0},[w(" · "+a(n(o)("Running","正在运行")),1)],64)):_("",!0)]),s("div",K,[I(n(L),{class:"ui-button","data-size":"md","data-variant":"secondary",to:{name:"chat-session",params:{sessionId:e.sessionId}}},{default:$(()=>[w(a(n(o)("Reopen","重新打开")),1)]),_:1},8,["to"]),s("button",{class:"ui-button","data-size":"md","data-variant":"danger-ghost",disabled:i.value||e.running||!n(h).supports("session.delete"),onClick:y=>V(e)},a(n(o)("Delete permanently","永久删除")),9,W)])]))),128)),l.value&&!l.value.sessions.length?(v(),c("p",X,a(n(o)("No matching saved sessions.","没有匹配的已保存会话。")),1)):_("",!0),(u=l.value)!=null&&u.nextCursor?(v(),c("button",{key:1,class:"ui-button","data-size":"md","data-variant":"secondary",disabled:i.value,onClick:t[4]||(t[4]=e=>p(!0))},a(n(o)("Load more","加载更多")),9,Y)):_("",!0)])}}}),le=q(Z,[["__scopeId","data-v-0c99200f"]]);export{le as default};
1
+ import{d as B,x as D,c,e as s,t as a,u as n,l as k,C,B as N,j as I,F as z,E as T,a as _,r as d,b as w,k as $,R as L,o as v}from"./vendor-vue-CncuOShJ.js";import{u as j}from"./settings-general-dc8P6dA0.js";import{u as F,x as M,y as P,i as q,k as E}from"./index-DVjYS93F.js";import{_ as O}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{r as U,m as R}from"./context-Grqd_9Lt.js";const Q={class:"settings-page"},G={"data-route-heading":"",tabindex:"-1"},H=["disabled"],J=["datetime"],K={class:"settings-actions"},W=["disabled","onClick"],X={key:0,role:"status"},Y=["disabled"],Z=B({__name:"ArchivedSettings",setup(ee){const o=j(),h=F(),V=M(),l=d(),g=d(""),b=d(""),S=d(""),x=d(""),i=d(!1),m=d("");async function p(r=!1){var t,f;if(!i.value){i.value=!0,m.value="";try{const u=r?S.value:g.value.trim(),e=r?x.value:b.value.trim(),y=await h.client.call("session.catalog",{limit:50,withPreview:!0,...u?{query:u}:{},...e?{cwd:e}:{},...r&&((t=l.value)!=null&&t.nextCursor)?{cursor:l.value.nextCursor}:{}},P);l.value={sessions:r?[...((f=l.value)==null?void 0:f.sessions)??[],...y.sessions]:y.sessions,nextCursor:y.nextCursor},S.value=u,x.value=e}catch(u){m.value=R(u)}finally{i.value=!1}}}async function A(r){if(!(i.value||!window.confirm(o("Permanently delete this session and all its history? This cannot be undone.","永久删除此会话及其全部历史?此操作不可撤销。")))){i.value=!0,m.value="";try{await h.client.call("session.delete",{sessionId:r.sessionId},q),l.value&&(l.value.sessions=l.value.sessions.filter(t=>t.sessionId!==r.sessionId)),V.forget(r.sessionId)}catch(t){m.value=R(t)}finally{i.value=!1}}}return U(h,()=>p()),D(()=>p()),(r,t)=>{var f,u;return v(),c("article",Q,[s("header",null,[s("h2",G,a(n(o)("Saved sessions","已保存的会话")),1),s("p",null,a(n(o)("Browse persisted history, reopen sessions or permanently delete them. This runtime does not have a separate archived flag; closing a session keeps its saved history.","浏览持久化历史、重新打开会话或永久删除会话。当前运行时没有单独的归档标记;关闭会话会保留其已保存历史。")),1)]),s("form",{class:"settings-card settings-form",role:"search",onSubmit:t[2]||(t[2]=N(e=>p(),["prevent"]))},[s("label",null,[s("span",null,a(n(o)("Search history","搜索历史")),1),k(s("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>g.value=e),class:"ui-field","data-size":"md",type:"search"},null,512),[[C,g.value]])]),s("label",null,[s("span",null,a(n(o)("Project directory (optional)","项目目录(可选)")),1),k(s("input",{"onUpdate:modelValue":t[1]||(t[1]=e=>b.value=e),class:"ui-field","data-size":"md",placeholder:"/path/to/project"},null,512),[[C,b.value]])]),s("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:i.value},a(n(o)("Search","搜索")),9,H)],32),I(O,{busy:i.value,error:m.value,onReload:t[3]||(t[3]=e=>p())},null,8,["busy","error"]),(v(!0),c(z,null,T((f=l.value)==null?void 0:f.sessions,e=>(v(),c("section",{key:e.sessionId,class:"settings-card"},[s("h3",null,a(e.preview||e.sessionId),1),s("p",null,[s("code",null,a(e.cwd),1)]),s("p",null,[s("time",{datetime:new Date(e.updatedAt).toISOString()},a(new Date(e.updatedAt).toLocaleString()),9,J),w(" · "+a(e.model.modelId),1),e.running?(v(),c(z,{key:0},[w(" · "+a(n(o)("Running","正在运行")),1)],64)):_("",!0)]),s("div",K,[I(n(L),{class:"ui-button","data-size":"md","data-variant":"secondary",to:{name:"chat-session",params:{sessionId:e.sessionId}}},{default:$(()=>[w(a(n(o)("Reopen","重新打开")),1)]),_:1},8,["to"]),s("button",{class:"ui-button","data-size":"md","data-variant":"danger-ghost",disabled:i.value||e.running||!n(h).supports("session.delete"),onClick:y=>A(e)},a(n(o)("Delete permanently","永久删除")),9,W)])]))),128)),l.value&&!l.value.sessions.length?(v(),c("p",X,a(n(o)("No matching saved sessions.","没有匹配的已保存会话。")),1)):_("",!0),(u=l.value)!=null&&u.nextCursor?(v(),c("button",{key:1,class:"ui-button","data-size":"md","data-variant":"secondary",disabled:i.value,onClick:t[4]||(t[4]=e=>p(!0))},a(n(o)("Load more","加载更多")),9,Y)):_("",!0)])}}}),le=E(Z,[["__scopeId","data-v-0c99200f"]]);export{le as default};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markstream-CvxnTmYJ.js","assets/index-CenMTLFY.js","assets/vendor-vue-CncuOShJ.js","assets/index-BbPaKBmv.css"])))=>i.map(i=>d[i]);
2
- import{d as aa,A as Ua,i as Wt,r as S,s as Qn,x as oa,w as A,g as Ja,G as ra,o as ul,h as rt,H as Xn,k as il,y as $l,n as nt,c as Yn,j as Qa,l as Xa,e as G,m as it,a as At,v as Ya,t as Ut,u as ia,z as m,I as Za,q as O,B as Ka,p as eo}from"./vendor-vue-CncuOShJ.js";import{C as lo,a as ua,l as to,h as no,o as sa,f as ao,s as oo,d as ro,A as Zn,i as se,Z as io,J as uo,j as so,K as fo,k as vo,M as co,q as mo,y as ho,t as po,G as go,w as yo,x as bo,Q as wo,H as Kn,I as ea,L as at,X as ko,m as xo}from"./index-B4STIxMF.js";import{B as la,g as So,Q as Co}from"./PreCodeBlock-DH2VwXzi.js";import{_ as Mo}from"./index-CenMTLFY.js";var ot=(C,b,M)=>new Promise((ce,ee)=>{var R=k=>{try{n(M.next(k))}catch(H){ee(H)}},he=k=>{try{n(M.throw(k))}catch(H){ee(H)}},n=k=>k.done?ce(k.value):Promise.resolve(k.value).then(R,he);n((M=M.apply(C,b)).next())});let Gt=!1,Hl=null,Ol=null,Dl=null;function Bo(){return ot(this,null,function*(){if(Dl)return Dl;Dl=ot(null,null,function*(){if(!Ol)try{if(Ol=(function(C){var b,M,ce;const ee=C,R=typeof(ee==null?void 0:ee.createCodeBlockRuntime)=="function"||typeof(ee==null?void 0:ee.useMonaco)=="function"?ee:C==null?void 0:C.default,he=(b=R==null?void 0:R.createCodeBlockRuntime)!=null?b:R==null?void 0:R.useMonaco;return typeof he!="function"?null:{createCodeBlockRuntime:n=>he.call(R,n),detectLanguage:(M=R==null?void 0:R.detectLanguage)==null?void 0:M.bind(R),preloadStreamDiffs:(ce=R==null?void 0:R.preloadStreamDiffs)==null?void 0:ce.bind(R)}})(yield Mo(()=>import("./markstream-CvxnTmYJ.js"),__vite__mapDeps([0,1,2,3]))),!Ol)return null}catch{return null}try{return yield(function(C){return ot(this,null,function*(){return Gt?void 0:Hl||(Hl=ot(null,null,function*(){const M=C==null?void 0:C.preloadStreamDiffs;typeof M=="function"&&(yield M()),Gt=!0}).finally(()=>{Hl=null}),Hl)})})(Ol),lo(),Ol}catch{return null}});try{return yield Dl}finally{Dl=null}})}var Po=Object.defineProperty,$o=Object.defineProperties,Ho=Object.getOwnPropertyDescriptors,ta=Object.getOwnPropertySymbols,Oo=Object.prototype.hasOwnProperty,Do=Object.prototype.propertyIsEnumerable,na=(C,b,M)=>b in C?Po(C,b,{enumerable:!0,configurable:!0,writable:!0,value:M}):C[b]=M,Ce=(C,b)=>{for(var M in b||(b={}))Oo.call(b,M)&&na(C,M,b[M]);if(ta)for(var M of ta(b))Do.call(b,M)&&na(C,M,b[M]);return C},Nl=(C,b)=>$o(C,Ho(b)),D=(C,b,M)=>new Promise((ce,ee)=>{var R=k=>{try{n(M.next(k))}catch(H){ee(H)}},he=k=>{try{n(M.throw(k))}catch(H){ee(H)}},n=k=>k.done?ce(k.value):Promise.resolve(k.value).then(R,he);n((M=M.apply(C,b)).next())});const No={class:"html-preview-frame__header"},Eo={class:"html-preview-frame__title"},Fo={class:"html-preview-frame__label"},To=["sandbox","srcdoc"],zo=ua(aa({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(C){const b=C,M=import.meta!==void 0&&!1;let ce=null;const{t:ee}=sa(),R=m(()=>{const k=b.code||"",H=k.trim().toLowerCase();return H.startsWith("<!doctype")||H.startsWith("<html")||H.startsWith("<body")?k:`<!doctype html>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markstream-Cmk_Kis9.js","assets/index-DVjYS93F.js","assets/vendor-vue-CncuOShJ.js","assets/index-DCEhwLss.css"])))=>i.map(i=>d[i]);
2
+ import{d as aa,A as Ua,i as Wt,r as S,s as Qn,x as oa,w as A,g as Ja,G as ra,o as ul,h as rt,H as Xn,k as il,y as $l,n as nt,c as Yn,j as Qa,l as Xa,e as G,m as it,a as At,v as Ya,t as Ut,u as ia,z as m,I as Za,q as O,B as Ka,p as eo}from"./vendor-vue-CncuOShJ.js";import{C as lo,a as ua,l as to,h as no,o as sa,f as ao,s as oo,d as ro,A as Zn,i as se,Z as io,J as uo,j as so,K as fo,k as vo,M as co,q as mo,y as ho,t as po,G as go,w as yo,x as bo,Q as wo,H as Kn,I as ea,L as at,X as ko,m as xo}from"./index-DwhvmzI8.js";import{B as la,g as So,Q as Co}from"./PreCodeBlock-T5SnpbhZ.js";import{_ as Mo}from"./index-DVjYS93F.js";var ot=(C,b,M)=>new Promise((ce,ee)=>{var R=k=>{try{n(M.next(k))}catch(H){ee(H)}},he=k=>{try{n(M.throw(k))}catch(H){ee(H)}},n=k=>k.done?ce(k.value):Promise.resolve(k.value).then(R,he);n((M=M.apply(C,b)).next())});let Gt=!1,Hl=null,Ol=null,Dl=null;function Bo(){return ot(this,null,function*(){if(Dl)return Dl;Dl=ot(null,null,function*(){if(!Ol)try{if(Ol=(function(C){var b,M,ce;const ee=C,R=typeof(ee==null?void 0:ee.createCodeBlockRuntime)=="function"||typeof(ee==null?void 0:ee.useMonaco)=="function"?ee:C==null?void 0:C.default,he=(b=R==null?void 0:R.createCodeBlockRuntime)!=null?b:R==null?void 0:R.useMonaco;return typeof he!="function"?null:{createCodeBlockRuntime:n=>he.call(R,n),detectLanguage:(M=R==null?void 0:R.detectLanguage)==null?void 0:M.bind(R),preloadStreamDiffs:(ce=R==null?void 0:R.preloadStreamDiffs)==null?void 0:ce.bind(R)}})(yield Mo(()=>import("./markstream-Cmk_Kis9.js"),__vite__mapDeps([0,1,2,3]))),!Ol)return null}catch{return null}try{return yield(function(C){return ot(this,null,function*(){return Gt?void 0:Hl||(Hl=ot(null,null,function*(){const M=C==null?void 0:C.preloadStreamDiffs;typeof M=="function"&&(yield M()),Gt=!0}).finally(()=>{Hl=null}),Hl)})})(Ol),lo(),Ol}catch{return null}});try{return yield Dl}finally{Dl=null}})}var Po=Object.defineProperty,$o=Object.defineProperties,Ho=Object.getOwnPropertyDescriptors,ta=Object.getOwnPropertySymbols,Oo=Object.prototype.hasOwnProperty,Do=Object.prototype.propertyIsEnumerable,na=(C,b,M)=>b in C?Po(C,b,{enumerable:!0,configurable:!0,writable:!0,value:M}):C[b]=M,Ce=(C,b)=>{for(var M in b||(b={}))Oo.call(b,M)&&na(C,M,b[M]);if(ta)for(var M of ta(b))Do.call(b,M)&&na(C,M,b[M]);return C},Nl=(C,b)=>$o(C,Ho(b)),D=(C,b,M)=>new Promise((ce,ee)=>{var R=k=>{try{n(M.next(k))}catch(H){ee(H)}},he=k=>{try{n(M.throw(k))}catch(H){ee(H)}},n=k=>k.done?ce(k.value):Promise.resolve(k.value).then(R,he);n((M=M.apply(C,b)).next())});const No={class:"html-preview-frame__header"},Eo={class:"html-preview-frame__title"},Fo={class:"html-preview-frame__label"},To=["sandbox","srcdoc"],zo=ua(aa({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(C){const b=C,M=import.meta!==void 0&&!1;let ce=null;const{t:ee}=sa(),R=m(()=>{const k=b.code||"",H=k.trim().toLowerCase();return H.startsWith("<!doctype")||H.startsWith("<html")||H.startsWith("<body")?k:`<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="utf-8" />
@@ -0,0 +1 @@
1
+ import{d as N,x as O,c as v,e,t,u as s,j as q,F as T,a as w,B as z,l as k,L as U,b as F,C as B,E,r as i,z as I,o as p}from"./vendor-vue-CncuOShJ.js";import{u as G}from"./settings-general-dc8P6dA0.js";import{u as j,z as P,A as D,k as A}from"./index-DVjYS93F.js";import{_ as $}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as H,r as J,m as M}from"./context-Grqd_9Lt.js";const K={class:"settings-page"},Q={"data-route-heading":"",tabindex:"-1"},W={class:"settings-card"},X=["disabled"],Y={class:"recording-toggle"},Z=["disabled"],ee={class:"ui-banner settings-banner","data-tone":"warning"},te={class:"settings-actions"},se=["disabled"],oe={class:"settings-card"},ae={class:"settings-card"},ne={class:"feature-list"},le={key:0},re=N({__name:"DiagnosticsSettings",setup(ie){const o=G(),a=j(),g=i(),y=i(),n=i(!1),h=i(""),b=i(""),l=i(),d=i(!1),f=i(!1),u=I(()=>l.value!==void 0&&d.value!==l.value.enabled);H(u);const S=I(()=>{var r;return((r=a.hello)==null?void 0:r.features.filter(c=>c.toLocaleLowerCase().includes(b.value.toLocaleLowerCase())).sort())??[]});async function _(){if(!n.value&&!(u.value&&!window.confirm(o("Discard unsaved recording settings?","放弃未保存的录制设置?")))){n.value=!0,h.value="",f.value=!1;try{const r=performance.now();g.value=await a.client.call("daemon.ping",{},P),y.value=Math.round(performance.now()-r),a.supports("settings.read")&&(l.value=await a.client.call("settings.read",{source:"model-log",scope:"user"},D),d.value=l.value.enabled)}catch(r){h.value=M(r)}finally{n.value=!1}}}async function V(){if(!(!l.value||!u.value||n.value)&&!(d.value&&!window.confirm(o("Record model requests and responses? Recordings include prompts, source code and tool output. Custom headers may contain secrets. The file has no automatic rotation.","录制模型请求和响应?录制包含提示词、源代码和工具输出。自定义请求头可能包含机密。文件不会自动轮换。")))){n.value=!0,h.value="",f.value=!1;try{l.value=await a.client.call("settings.update",{source:"model-log",scope:"user",expectedRevision:l.value.revision,document:{enabled:d.value}},D),d.value=l.value.enabled,f.value=!0}catch(r){h.value=M(r)}finally{n.value=!1}}}return J(a,_,u),O(_),(r,c)=>{var x,R,C,L;return p(),v("article",K,[e("header",null,[e("h2",Q,t(s(o)("Diagnostics","诊断")),1),e("p",null,t(s(o)("Live connection and server information. This page never displays credentials or bootstrap tokens.","实时连接和服务器信息。此页面不会显示凭据或引导令牌。")),1)]),q($,{busy:n.value,error:h.value,saved:f.value&&!u.value,onReload:_},null,8,["busy","error","saved"]),e("dl",W,[e("div",null,[e("dt",null,t(s(o)("Server version","服务器版本")),1),e("dd",null,t(((x=s(a).hello)==null?void 0:x.serverVersion)??"—"),1)]),e("div",null,[e("dt",null,t(s(o)("Protocol","协议")),1),e("dd",null,t(((R=s(a).hello)==null?void 0:R.protocolVersion)??"—"),1)]),e("div",null,[e("dt",null,t(s(o)("Instance","实例")),1),e("dd",null,[e("code",null,t(((C=s(a).hello)==null?void 0:C.instanceId)??"—"),1)])]),e("div",null,[e("dt",null,t(s(o)("Connection","连接")),1),e("dd",null,t(s(a).phase),1)]),g.value?(p(),v(T,{key:0},[e("div",null,[e("dt",null,t(s(o)("Sessions","会话")),1),e("dd",null,t(g.value.sessions),1)]),e("div",null,[e("dt",null,t(s(o)("Connections","连接数")),1),e("dd",null,t(g.value.connections),1)]),e("div",null,[e("dt",null,t(s(o)("Round trip","往返延迟")),1),e("dd",null,t(y.value)+" ms",1)])],64)):w("",!0)]),e("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:n.value,onClick:_},t(s(o)("Refresh diagnostics","刷新诊断")),9,X),l.value?(p(),v("form",{key:0,class:"settings-card settings-form",onSubmit:z(V,["prevent"])},[e("h3",null,t(s(o)("Model request recording","模型请求录制")),1),e("p",null,t(s(o)("Changes apply to new model requests without restarting. In-flight requests finish with their existing recorder. Records are written to model-log/recordings.jsonl in the daemon execution home.","更改适用于新模型请求,无需重启。正在进行的请求继续使用原录制器。记录写入守护进程执行目录中的 model-log/recordings.jsonl。")),1),e("label",Y,[k(e("input",{"onUpdate:modelValue":c[0]||(c[0]=m=>d.value=m),type:"checkbox",disabled:n.value||!s(a).supports("settings.update")},null,8,Z),[[U,d.value]]),F(t(s(o)("Record model requests and responses","录制模型请求和响应")),1)]),e("p",ee,t(s(o)("Recordings contain prompts, code and tool output. Custom headers may contain secrets. Files are private but have no automatic size limit or rotation.","录制包含提示词、代码和工具输出。自定义请求头可能包含机密。文件为私有文件,但没有自动大小限制或轮换。")),1),e("div",te,[e("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:n.value||!u.value||!s(a).supports("settings.update")},t(s(o)("Save recording settings","保存录制设置")),9,se)])],32)):w("",!0),e("section",oe,[e("h3",null,t(s(o)("Process logs","进程日志")),1),e("p",null,t(s(o)("The daemon writes runtime output to the private daemon.log in its native home when the CLI starts it, and to stderr when it is started directly; the file appends across starts. RUST_LOG sets the filter and is read when the daemon starts, and with it unset the daemon keeps errors only.","CLI 启动守护进程时,运行时输出写入其本机目录中的私有 daemon.log;直接启动时写入 stderr,该文件跨多次启动追加。RUST_LOG 设置过滤条件,在守护进程启动时读取;未设置时只保留错误。")),1),e("p",null,t(s(o)("This page has no log-mode control. To raise logging, run dimcode daemon stop, then start the daemon from a terminal with the filter set, for example RUST_LOG=debug dimcode.","本页没有日志模式开关。要提高日志级别,先运行 dimcode daemon stop,再从终端带过滤条件启动守护进程,例如 RUST_LOG=debug dimcode。")),1),e("p",null,t(s(o)("The complete record of what a run committed is dimcode export SESSION_ID; read it with daemon.log. Model request recording above is a separate opt-in record of model wire exchanges, not a process-log switch.","一次运行提交内容的完整记录是 dimcode export SESSION_ID,与 daemon.log 一起阅读。上方的模型请求录制是独立的、需主动启用的模型请求线路记录,不是进程日志开关。")),1)]),e("section",ae,[e("h3",null,t(s(o)("Advertised methods","已声明的方法"))+" ("+t(((L=s(a).hello)==null?void 0:L.features.length)??0)+")",1),e("label",null,[e("span",null,t(s(o)("Filter methods","筛选方法")),1),k(e("input",{"onUpdate:modelValue":c[1]||(c[1]=m=>b.value=m),class:"ui-field","data-size":"md",type:"search"},null,512),[[B,b.value]])]),e("ul",ne,[(p(!0),v(T,null,E(S.value,m=>(p(),v("li",{key:m},[e("code",null,t(m),1)]))),128))]),S.value.length?w("",!0):(p(),v("p",le,t(s(o)("No matching methods.","没有匹配的方法。")),1))])])}}}),pe=A(re,[["__scopeId","data-v-c78a2caa"]]);export{pe as default};
@@ -0,0 +1 @@
1
+ import{d as Ae,w as Se,x as ze,g as Ve,c as u,e as n,t,u as a,l as g,C as A,B as ee,j as Ie,F as U,E,a as v,b as R,D as N,L as de,r as z,z as q,o as r}from"./vendor-vue-CncuOShJ.js";import{u as Me}from"./settings-general-dc8P6dA0.js";import{u as Pe,D as ce,E as Re,F as Te,i as O,G as ve,H as xe,k as je}from"./index-DVjYS93F.js";import{_ as Le}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as De,r as Ee,m as j}from"./context-Grqd_9Lt.js";function be(d){const e=String(d??"").trim();return e?Number(e):null}function pe(d){const e=Object.fromEntries(d.secrets.filter(T=>T.action==="set").map(T=>[T.name.trim(),T.value])),p=d.source==="user"&&d.enabled,_=be(d.timeout);if(d.type==="stdio")return{type:"stdio",command:d.command,args:d.args,...d.cwd?{cwd:d.cwd}:{},env:e,enabled:p,..._===null?{}:{timeout:_}};const V={...d.clientId.trim()?{clientId:d.clientId.trim()}:{},...d.callbackPort?{callbackPort:Number(d.callbackPort)}:{},...d.scopes.trim()?{scopes:d.scopes.trim()}:{},...d.metadataUrl.trim()?{authServerMetadataUrl:d.metadataUrl.trim()}:{}};return{type:d.type,url:d.url.trim(),headers:e,enabled:p,...d.token?{auth:{type:"bearer",token:d.token}}:{},...d.oauth?{oauth:V}:{},..._===null?{}:{timeout:_}}}function me(d){const e={timeout:be(d.timeout)};if(d.secretsInUserScope){if(d.type==="stdio")return{command:d.command,cwd:d.cwd,...e};const V={...e};return d.oauthAction==="remove"&&(V.oauth={action:"remove"}),d.oauthAction==="set"&&(V.oauth={action:"set",clientId:d.clientId.trim()||null,callbackPort:d.callbackPort?Number(d.callbackPort):null,scopes:d.scopes.trim()||null}),V}const p=Object.fromEntries(d.secrets.filter(V=>V.action!=="keep").map(V=>[V.name.trim(),V.action==="remove"?null:V.value]));if(d.type==="stdio")return{command:d.command,...d.argsAction==="replace"?{args:d.args}:{},cwd:d.cwd,env:p,...e};const _={...d.url.trim()?{url:d.url.trim()}:{},headers:p,...e};return d.bearerAction!=="keep"&&(_.bearer=d.bearerAction==="remove"?{action:"remove"}:{action:"set",token:d.token}),d.oauthAction==="remove"&&(_.oauth={action:"remove"}),d.oauthAction==="set"&&(_.oauth={action:"set",clientId:d.clientId.trim()||null,callbackPort:d.callbackPort?Number(d.callbackPort):null,scopes:d.scopes.trim()||null,...d.metadataAction==="remove"?{authServerMetadataUrl:null}:d.metadataAction==="set"?{authServerMetadataUrl:d.metadataUrl.trim()}:{}}),_}const Oe={class:"settings-page"},$e=["disabled"],Ne={class:"settings-actions"},qe=["disabled"],Be=["disabled"],Fe={key:0,class:"settings-card"},He={class:"settings-actions"},Ke=["disabled","onClick"],We={key:1,class:"settings-card settings-form","aria-live":"polite"},Je={key:0},Ge={key:2},Qe={key:3,role:"status"},Xe={key:0},Ye={key:0},Ze={key:1},et={key:2},tt={key:4},at=["disabled"],nt={class:"settings-actions"},ot=["disabled"],st=["disabled"],lt=["disabled"],it={key:0,class:"ui-banner settings-banner","data-tone":"warning"},ut=["disabled"],rt=["disabled"],dt=["disabled"],ct=["disabled"],vt={value:"user"},pt={key:0,value:"project"},mt={key:0},bt=["disabled"],ht={key:0},ft={value:"keep"},yt={value:"replace"},gt={key:1},kt=["onUpdate:modelValue","aria-label"],_t=["onClick"],wt={key:0},Ct={key:1},Ut=["required"],At={class:"checkbox-label"},St=["disabled"],zt={key:0},Vt={key:3},It={value:"keep"},Mt={value:"set"},Pt={value:"remove"},Rt={key:4,class:"settings-form"},Tt={key:0},xt={value:"keep"},jt={value:"set"},Lt={value:"remove"},Dt={key:1},Et=["required"],Ot={key:3},$t={value:"keep"},Nt=["disabled"],qt={value:"remove"},Bt={key:0},Ft={key:4},Ht=["onUpdate:modelValue","aria-label","readonly"],Kt=["onUpdate:modelValue","aria-label"],Wt={key:0,value:"keep"},Jt={value:"set"},Gt={key:1,value:"remove"},Qt=["onUpdate:modelValue","aria-label"],Xt=["onClick"],Yt={key:5,class:"checkbox-label"},Zt={key:6},ea={key:7},ta={class:"settings-actions"},aa=["disabled"],na=["disabled"],oa={key:3,class:"settings-card",role:"status"},sa={key:0},la={key:1},ia={key:2},ua={key:3},ra={key:0},da={key:5},ca={key:6},va={key:0},pa={key:7},ma={key:4,class:"settings-card"},ba=["href"],ha=["disabled"],fa={class:"settings-actions"},ya=["disabled"],ga=["disabled"],ka={class:"search-label"},_a={class:"settings-actions"},wa=["disabled","onClick"],Ca=["disabled","onClick"],Ua=["disabled","onClick"],Aa=["disabled","onClick"],Sa=["disabled","onClick"],za=["disabled","onClick"],Va=["disabled","onClick"],Ia=["disabled","onClick"],Ma=["disabled","onClick"],Pa={key:0},Ra={key:5,role:"status"},Ta=Ae({__name:"McpSettings",setup(d){const e=Me(),p=Pe(),_=z(),V=z(""),T=z(""),c=z(!1),w=z(""),l=z(),Q=z(""),y=z(!1),X=z(""),M=z(),te=z(""),L=z(""),x=z(""),m=z(),k=z(),ae=z(),W=z("");let ne=!0;const D=q(()=>l.value!==void 0&&JSON.stringify(l.value)!==Q.value),he=q(()=>l.value!==void 0&&(y.value?l.value.oauthAction==="set"||l.value.oauthAction==="keep"&&l.value.oauth:l.value.oauth)),oe=q(()=>l.value!==void 0&&l.value.secretsInUserScope&&l.value.authConfigured),se=q(()=>{var i;return((i=_.value)==null?void 0:i.servers.filter(s=>s.id.toLocaleLowerCase().includes(W.value.toLocaleLowerCase())))??[]}),Y=q(()=>{var i;return((i=_.value)==null?void 0:i.invalid.filter(s=>s.id.toLocaleLowerCase().includes(W.value.toLocaleLowerCase())))??[]});De(q(()=>D.value||!!x.value||!!L.value)),Se(l,()=>{k.value=void 0},{deep:!0});function fe(i){switch(i){case"timeout":return e("The server did not answer before the deadline.","服务器在时限内未响应。");case"response":return e("The server answered something Dim cannot use.","服务器的返回无法被 Dim 使用。");case"cleanup":return e("The temporary connection did not close cleanly.","临时连接未能正常关闭。");default:return e("The connection or a request failed.","连接或请求失败。")}}function $(){return T.value?{cwd:T.value}:{}}function H(i){return{...$(),id:i.id,source:i.source}}function J(i){var h,b;const s=i==="user"?(h=_.value)==null?void 0:h.userRevision:(b=_.value)==null?void 0:b.projectRevision;if(s===void 0)throw new Error(e("Load the project catalog before editing it.","编辑项目前请先加载项目目录。"));return s}async function B(){_.value=await p.client.call("mcp.catalog",$(),ve)}async function K(){var s;if(!m.value)return;const i=(s=_.value)==null?void 0:s.servers.find(h=>{var b;return h.id===((b=m.value)==null?void 0:b.server.id)&&h.source===m.value.server.source});if(!i){m.value=void 0;return}m.value={server:i,inspection:await p.client.call("mcp.inspect",H(i),ce)}}async function le(i){if(!c.value&&!(x.value&&!window.confirm(e("Discard the entered OAuth client secret?","放弃已输入的 OAuth 客户端密钥?")))){c.value=!0,w.value="";try{m.value={server:i,inspection:await p.client.call("mcp.inspect",H(i),ce)},x.value=""}catch(s){w.value=j(s)}finally{c.value=!1}}}async function G(){if(!c.value&&!(D.value&&!window.confirm(e("Discard unsaved MCP configuration?","放弃未保存的 MCP 配置?")))){c.value=!0,w.value="";try{if(!p.supports("mcp.catalog"))throw new Error(e("MCP management is not available on this server.","此服务器不支持 MCP 管理。"));const i=V.value.trim(),s=await p.client.call("mcp.catalog",i?{cwd:i}:{},ve);T.value=i,_.value=s,l.value=void 0,m.value=void 0,x.value="",k.value=void 0}catch(i){w.value=j(i)}finally{c.value=!1}}}function ye(){D.value&&!window.confirm(e("Discard unsaved MCP configuration?","放弃未保存的 MCP 配置?"))||(l.value={id:"",source:"user",type:"stdio",command:"",args:[],argsAction:"replace",storedArgsCount:0,cwd:"",url:"",secrets:[],enabled:!1,oauth:!1,clientId:"",token:"",bearerAction:"keep",authConfigured:!1,oauthAction:"keep",callbackPort:"",scopes:"",metadataUrl:"",metadataConfigured:!1,metadataAction:"keep",secretsInUserScope:!1,timeout:""},Q.value=JSON.stringify(l.value),y.value=!1,X.value=J("user"))}async function ge(i){var s,h,b,I;if(!(i.source==="plugin"||c.value)&&!(D.value&&!window.confirm(e("Discard unsaved MCP configuration?","放弃未保存的 MCP 配置?")))){c.value=!0,w.value="";try{const P=await p.client.call("mcp.configuration",H(i),xe);if(P.revision===void 0)throw new Error(e("This entry has no source revision and cannot be edited.","此条目没有源修订号,无法编辑。"));const f=P.configuration;l.value={id:i.id,source:i.source,type:f.type,command:f.type==="stdio"?f.command:"",args:[],argsAction:"keep",storedArgsCount:f.type==="stdio"?f.argsCount:0,cwd:f.type==="stdio"?f.cwd??"":"",url:"",...f.type!=="stdio"?{endpoint:f.endpoint}:{},secrets:(f.type==="stdio"?f.envNames:f.headerNames).map(o=>({name:o,action:"keep",value:"",stored:!0})),enabled:P.enabled,oauth:f.type!=="stdio"&&f.oauthConfigured,authConfigured:f.type!=="stdio"&&f.authConfigured,clientId:f.type!=="stdio"?((s=f.oauth)==null?void 0:s.clientId)??"":"",callbackPort:f.type!=="stdio"?String(((h=f.oauth)==null?void 0:h.callbackPort)??""):"",scopes:f.type!=="stdio"?((b=f.oauth)==null?void 0:b.scopes)??"":"",metadataConfigured:f.type!=="stdio"&&(((I=f.oauth)==null?void 0:I.metadataConfigured)??!1),metadataUrl:"",metadataAction:"keep",token:"",bearerAction:"keep",oauthAction:"keep",timeout:f.timeout===void 0?"":String(f.timeout),secretsInUserScope:P.secretsInUserScope},y.value=!0,X.value=P.revision,Q.value=JSON.stringify(l.value)}catch(P){w.value=j(P)}finally{c.value=!1}}}function ke(){D.value&&!window.confirm(e("Discard unsaved MCP configuration?","放弃未保存的 MCP 配置?"))||(l.value=void 0)}function ie(i){var b;const s=i.secrets.map(I=>I.name.trim());if(s.some(I=>!I)||new Set(s).size!==s.length)return w.value=e("Secret field names must be nonempty and unique.","机密字段名称不能为空且必须唯一。"),!1;const h=i.url.trim();if(i.type!=="stdio"&&!i.secretsInUserScope&&h&&!h.includes("${"))try{new URL(h)}catch{return w.value=e("The endpoint must be an absolute URL, or contain a variable reference the daemon expands.","端点必须是绝对 URL,或包含由守护进程展开的变量引用。"),!1}return((b=ae.value)==null?void 0:b.reportValidity())??!1}async function _e(){var s;const i=l.value;if(!(!i||c.value||!D.value)&&(w.value="",!!ie(i))){if(!y.value&&((s=_.value)!=null&&s.servers.some(h=>h.id===i.id.trim()))){w.value=e("This ID already exists in the effective catalog. Edit the existing entry instead.","此 ID 已存在于有效目录中。请编辑现有条目。");return}if(!(!y.value&&i.source==="user"&&i.enabled&&!window.confirm(e("Enabling this server permits its configured command or network connection to run. Continue?","启用此服务器将允许运行其配置命令或网络连接。是否继续?")))){c.value=!0;try{y.value?await p.client.call("mcp.update",{...$(),id:i.id,source:i.source,expectedVersion:X.value,patch:me(i)},O):await p.client.call("mcp.save",{...$(),id:i.id.trim(),source:i.source,expectedVersion:J(i.source),configuration:pe(i)},O),l.value=void 0,await B(),await K()}catch(h){w.value=j(h)}finally{c.value=!1}}}}async function Z(i){if(c.value)return;w.value="";let s,h;if(i)s=H(i),h=i.id;else{const b=l.value;if(!b||!ie(b))return;s={...$(),id:b.id.trim(),source:b.source,...y.value?{patch:me(b)}:{configuration:pe(b)}},h=b.id}if(window.confirm(e("Open a temporary connection and list tools? This executes the configured command or contacts its endpoint. No configuration is saved and the connection is closed after the test.","打开临时连接并列出工具?这会执行配置的命令或连接端点。测试不会保存设置,且会在结束后关闭连接。"))){c.value=!0,k.value=void 0;try{const b=await p.client.call("mcp.test",s,Re);k.value={id:h,probe:b},await B(),await K()}catch(b){w.value=j(b)}finally{c.value=!1}}}async function F(i,s){var h;if(!c.value&&!(i==="mcp.remove"&&!window.confirm(e("Remove this server configuration?","移除此服务器配置?")))&&!(i==="mcp.set_enabled"&&!s.enabled&&!window.confirm(e("Enabling this server permits its configured command or network connection to run. Continue?","启用此服务器将允许运行其配置命令或网络连接。是否继续?")))){c.value=!0,w.value="";try{const b=H(s);if(i==="mcp.set_enabled"||i==="mcp.remove"){if(s.source==="plugin")return;b.expectedVersion=J(s.source),i==="mcp.set_enabled"&&(b.enabled=!s.enabled)}if(i==="mcp.auth.start"){((h=m.value)==null?void 0:h.server.id)===s.id&&m.value.server.source===s.source&&x.value&&(b.clientSecret=x.value);const I=await p.client.call(i,b,Te);if(!ne){await p.client.call("mcp.auth.cancel",{attemptId:I.attemptId},O);return}M.value=I,te.value=s.id}else await p.client.call(i,b,O);await B(),await K()}catch(b){w.value=j(b)}finally{i==="mcp.auth.start"&&(x.value=""),c.value=!1}}}async function we(i){if(!(c.value||l.value||i.source==="plugin")&&window.confirm(e("Remove this server configuration?","移除此服务器配置?"))){c.value=!0,w.value="";try{await p.client.call("mcp.remove",{...$(),id:i.id,source:i.source,expectedVersion:J(i.source)},O),await B()}catch(s){w.value=j(s)}finally{c.value=!1}}}async function ue(i){var C,S;if(c.value||i.source==="plugin"||!p.supports("mcp.move"))return;const s=i.source==="user"?"user":"project",h=s==="user"?"project":"user";if(h==="project"&&!T.value){w.value=e("Load a project directory before moving a server into it.","移入项目前请先加载项目目录。");return}if(D.value&&!window.confirm(e("Discard unsaved MCP configuration?","放弃未保存的 MCP 配置?")))return;const b=h==="project"?e("Move this server to the project? Withheld values stay in your local Dim configuration, the workspace file gets only the public configuration, and the entry starts disabled.","将此服务器移入项目?隐藏值保留在本地 Dim 配置中,工作区文件只包含公开配置,且条目默认禁用。"):e("Move this server to user scope? It keeps its current enabled state and its withheld values move to your local configuration.","将此服务器移入用户范围?它会保留当前启用状态,隐藏值会移至本地配置。");if(!window.confirm(b))return;const I=(C=_.value)==null?void 0:C.userRevision,P=(S=_.value)==null?void 0:S.projectRevision,f=s==="user"?I:P,o=h==="user"?I:P;if(f===void 0||o===void 0){w.value=e("Load the catalog before moving this server.","移动此服务器前请先加载目录。");return}c.value=!0,w.value="";try{await p.client.call("mcp.move",{...$(),id:i.id,from:s,to:h,expectedFromVersion:f,expectedToVersion:o},O),l.value=void 0,m.value=void 0,await B(),await K()}catch(Ue){w.value=j(Ue)}finally{c.value=!1}}function Ce(i){var h;const s=(h=_.value)==null?void 0:h.servers.find(b=>b.id===i&&b.source==="project");s&&ue(s)}async function re(i=!1){if(!(!M.value||!i&&!L.value||c.value)){c.value=!0,w.value="";try{await p.client.call(i?"mcp.auth.cancel":"mcp.auth.complete",{attemptId:M.value.attemptId,...i?{}:{callbackUrl:L.value}},O),L.value="",M.value=void 0,await B(),await K()}catch(s){w.value=j(s)}finally{c.value=!1}}}return Ee(p,G,q(()=>l.value!==void 0||!!x.value||!!L.value||!!M.value)),ze(G),Ve(()=>{ne=!1,L.value="",x.value="",M.value&&p.client.call("mcp.auth.cancel",{attemptId:M.value.attemptId},O).catch(()=>{})}),(i,s)=>{var h,b,I,P,f;return r(),u("article",Oe,[n("header",null,[s[32]||(s[32]=n("h2",{"data-route-heading":"",tabindex:"-1"},"MCP",-1)),n("p",null,t(a(e)("Manage command and remote MCP servers. Project servers stay disabled until you explicitly enable them locally.","管理命令和远程 MCP 服务器。项目服务器默认禁用,只有您在本地明确启用后才会运行。")),1)]),n("form",{class:"settings-card settings-form",onSubmit:ee(G,["prevent"])},[n("label",null,[n("span",null,t(a(e)("Project directory (optional, absolute path)","项目目录(可选,绝对路径)")),1),g(n("input",{"onUpdate:modelValue":s[0]||(s[0]=o=>V.value=o),class:"ui-field","data-size":"md",disabled:c.value},null,8,$e),[[A,V.value]])]),n("div",Ne,[n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value},t(a(e)("Load / refresh","加载 / 刷新")),9,qe),n("button",{class:"ui-button","data-size":"md","data-variant":"primary",type:"button",disabled:c.value||!_.value||!a(p).supports("mcp.save"),onClick:ye},t(a(e)("Add server","添加服务器")),9,Be)])],32),Ie(Le,{busy:c.value,error:w.value,onReload:G},null,8,["busy","error"]),(r(!0),u(U,null,E((h=_.value)==null?void 0:h.errors,o=>(r(),u("p",{key:o,class:"ui-banner settings-banner","data-tone":"warning"},t(o),1))),128)),Y.value.length?(r(),u("section",Fe,[n("h3",null,t(a(e)("Entries that did not decode","无法解码的条目")),1),n("p",null,t(a(e)("These entries stay in their file as written. They cannot run, and they can only be removed or replaced.","这些条目按原样保留在文件中。它们无法运行,只能被移除或替换。")),1),(r(!0),u(U,null,E(Y.value,o=>(r(),u("div",{key:`${o.source}:${o.id}`,class:"runtime-detail"},[n("h4",null,t(o.id)+" · "+t(o.source),1),n("p",null,t(o.error),1),n("div",He,[n("button",{class:"ui-button","data-size":"md","data-variant":"danger-ghost",disabled:c.value||!!l.value||o.source==="plugin"||!a(p).supports("mcp.remove"),onClick:C=>we(o)},t(a(e)("Remove","移除")),9,Ke)])]))),128))])):v("",!0),m.value?(r(),u("section",We,[n("h3",null,t(a(e)("Server details","服务器详情"))+": "+t(m.value.server.id),1),n("p",null,t(m.value.server.source)+" · "+t(m.value.server.transport)+" · "+t(m.value.inspection.enabled?a(e)("Enabled","已启用"):a(e)("Disabled","已禁用")),1),m.value.inspection.configuration.type==="stdio"?(r(),u(U,{key:0},[n("p",null,[R(t(a(e)("Executable","可执行程序"))+": ",1),n("code",null,t(m.value.inspection.configuration.command),1)]),n("p",null,t(a(e)("Stored arguments (hidden)","已存参数(隐藏)"))+": "+t(m.value.inspection.configuration.argsCount),1),n("p",null,t(a(e)("Working directory","工作目录"))+": "+t(m.value.inspection.configuration.cwd||a(e)("Daemon directory","守护进程目录")),1),n("p",null,t(a(e)("Environment names","环境变量名"))+": "+t(m.value.inspection.configuration.envNames.join(", ")||"—"),1),n("p",null,t(a(e)("Variables","变量"))+": "+t(m.value.inspection.configuration.referencedVariables.join(", ")||"—"),1),n("p",null,t(a(e)("Unset variables","未设置变量"))+": "+t(m.value.inspection.configuration.unsetVariables.join(", ")||"—"),1)],64)):(r(),u(U,{key:1},[n("p",null,[R(t(a(e)("Endpoint (origin only)","端点(仅来源)"))+": ",1),n("code",null,t(m.value.inspection.configuration.endpoint),1)]),n("p",null,t(a(e)("Header names","请求头名称"))+": "+t(m.value.inspection.configuration.headerNames.join(", ")||"—"),1),n("p",null,t(a(e)("Stored bearer token","已存储的 Bearer 令牌"))+": "+t(m.value.inspection.configuration.authConfigured?a(e)("Configured","已配置"):a(e)("None","无")),1),(b=m.value.inspection.configuration.oauth)!=null&&b.clientId?(r(),u("p",Je,"OAuth client ID: "+t(m.value.inspection.configuration.oauth.clientId),1)):v("",!0),n("p",null,t(a(e)("Variables","变量"))+": "+t(m.value.inspection.configuration.referencedVariables.join(", ")||"—"),1),n("p",null,t(a(e)("Unset variables","未设置变量"))+": "+t(m.value.inspection.configuration.unsetVariables.join(", ")||"—"),1)],64)),m.value.inspection.configuration.timeout!==void 0?(r(),u("p",Ge,t(a(e)("Tool call timeout","工具调用超时"))+": "+t(m.value.inspection.configuration.timeout)+" ms",1)):v("",!0),n("p",null,t(a(e)("Connection snapshots do not open a connection. Tool lists are the last successful discovery for each live connection generation.","查看快照不会打开连接。工具列表来自每个活动连接代次最近一次成功的发现。")),1),m.value.inspection.connections.length?v("",!0):(r(),u("p",Qe,t(a(e)("No live session connections. Use Test connection to discover tools without creating a session.","没有活动会话连接。可通过“测试连接”发现工具,无需创建会话。")),1)),(r(!0),u(U,null,E(m.value.inspection.connections,(o,C)=>(r(),u("section",{key:C,class:"runtime-detail"},[n("h4",null,[R(t(a(e)("Connection","连接"))+" "+t(C+1)+" · "+t(o.state),1),o.expired?(r(),u(U,{key:0},[R(" · "+t(a(e)("Credential expired","凭据已过期")),1)],64)):v("",!0)]),o.tools?(r(),u("ul",Xe,[(r(!0),u(U,null,E(o.tools,S=>(r(),u("li",{key:S.name},[n("strong",null,t(S.name),1),S.description?(r(),u("p",Ye,t(S.description),1)):v("",!0)]))),128))])):v("",!0),o.tools===void 0?(r(),u("p",Ze,t(a(e)("Tools have not been discovered.","尚未发现工具。")),1)):o.tools.length?v("",!0):(r(),u("p",et,t(a(e)("The server exposes no tools.","服务器没有提供工具。")),1))]))),128)),m.value.inspection.configuration.type!=="stdio"&&((I=m.value.inspection.configuration.oauth)!=null&&I.clientId)?(r(),u("label",tt,[n("span",null,t(a(e)("OAuth client secret (optional, sent once on Sign in)","OAuth 客户端密钥(可选,仅在登录时发送一次)")),1),g(n("input",{"onUpdate:modelValue":s[1]||(s[1]=o=>x.value=o),class:"ui-field","data-size":"md",type:"password",autocomplete:"new-password",disabled:c.value},null,8,at),[[A,x.value]])])):v("",!0),n("div",nt,[n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value,onClick:s[2]||(s[2]=o=>le(m.value.server))},t(a(e)("Refresh details","刷新详情")),9,ot),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!a(p).supports("mcp.test")||m.value.server.source!=="user"&&!m.value.server.enabled,onClick:s[3]||(s[3]=o=>Z(m.value.server))},t(a(e)("Test connection","测试连接")),9,st),m.value.server.transport!=="stdio"?(r(),u("button",{key:0,class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!!M.value||!m.value.server.enabled||!a(p).supports("mcp.auth.start"),onClick:s[4]||(s[4]=o=>F("mcp.auth.start",m.value.server))},t(a(e)("Sign in","登录")),9,lt)):v("",!0)])])):v("",!0),l.value?(r(),u("form",{key:2,ref_key:"editorForm",ref:ae,class:"settings-card settings-form",autocomplete:"off",onSubmit:ee(_e,["prevent"])},[n("h3",null,t(y.value?a(e)("Edit server","编辑服务器"):a(e)("New server","新服务器")),1),y.value&&l.value.secretsInUserScope?(r(),u("p",it,[R(t(a(e)("Withheld arguments, environment, headers, URL parts and OAuth metadata are stored in your user-scope configuration. They cannot be edited here; non-secret fields still save through the owner.","隐藏的参数、环境变量、请求头、URL 部分和 OAuth 元数据存储在用户范围配置中。此处无法编辑;非机密字段仍可通过所有者保存。"))+" ",1),n("button",{class:"ui-button","data-size":"sm","data-variant":"secondary",type:"button",disabled:c.value||!a(p).supports("mcp.move"),onClick:s[5]||(s[5]=o=>Ce(l.value.id))},t(a(e)("Move to user to edit","移到用户范围编辑")),9,ut)])):v("",!0),n("fieldset",{disabled:c.value},[n("label",null,[n("span",null,t(a(e)("Server ID","服务器 ID")),1),g(n("input",{"onUpdate:modelValue":s[6]||(s[6]=o=>l.value.id=o),class:"ui-field","data-size":"md",disabled:y.value,required:""},null,8,dt),[[A,l.value.id]])]),n("label",null,[n("span",null,t(a(e)("Source","来源")),1),g(n("select",{"onUpdate:modelValue":s[7]||(s[7]=o=>l.value.source=o),class:"ui-field","data-size":"md",disabled:y.value},[n("option",vt,t(a(e)("User","用户")),1),T.value?(r(),u("option",pt,t(a(e)("Project","项目")),1)):v("",!0)],8,ct),[[N,l.value.source]])]),y.value?(r(),u("p",mt,t(a(e)("The source and transport are fixed. Changes write only this source. Use Move to change the source; a move into a project keeps withheld values in your user-scope configuration.","来源和传输方式固定。更改只写入此来源。使用“移动”更改来源;移入项目时隐藏值保留在用户范围配置中。")),1)):v("",!0),n("label",null,[n("span",null,t(a(e)("Transport","传输方式")),1),g(n("select",{"onUpdate:modelValue":s[8]||(s[8]=o=>l.value.type=o),class:"ui-field","data-size":"md",disabled:y.value},[...s[33]||(s[33]=[n("option",{value:"stdio"},"stdio",-1),n("option",{value:"http"},"HTTP",-1),n("option",{value:"sse"},"SSE",-1)])],8,bt),[[N,l.value.type]])]),n("label",null,[n("span",null,t(a(e)("Tool call timeout (optional, milliseconds)","工具调用超时(可选,毫秒)")),1),g(n("input",{"onUpdate:modelValue":s[9]||(s[9]=o=>l.value.timeout=o),class:"ui-field","data-size":"md",type:"number",min:"1000",max:"86400000",step:"1",placeholder:"600000"},null,512),[[A,l.value.timeout]])]),l.value.type==="stdio"?(r(),u(U,{key:1},[n("label",null,[n("span",null,t(a(e)("Executable","可执行程序")),1),g(n("input",{"onUpdate:modelValue":s[10]||(s[10]=o=>l.value.command=o),class:"ui-field","data-size":"md",required:""},null,512),[[A,l.value.command]])]),n("label",null,[n("span",null,t(a(e)("Working directory (optional)","工作目录(可选)")),1),g(n("input",{"onUpdate:modelValue":s[11]||(s[11]=o=>l.value.cwd=o),class:"ui-field","data-size":"md"},null,512),[[A,l.value.cwd]])]),y.value&&!l.value.secretsInUserScope?(r(),u("label",ht,[n("span",null,t(a(e)("Stored arguments (hidden)","已存参数(隐藏)"))+": "+t(l.value.storedArgsCount),1),g(n("select",{"onUpdate:modelValue":s[12]||(s[12]=o=>l.value.argsAction=o),class:"ui-field"},[n("option",ft,t(a(e)("Keep stored arguments","保留已存参数")),1),n("option",yt,t(a(e)("Replace all arguments","替换全部参数")),1)],512),[[N,l.value.argsAction]])])):v("",!0),!l.value.secretsInUserScope&&(!y.value||l.value.argsAction==="replace")?(r(),u("div",gt,[n("strong",null,t(a(e)("Arguments (one per field)","参数(每个字段一个)")),1),(r(!0),u(U,null,E(l.value.args,(o,C)=>(r(),u("div",{key:C,class:"argument-row"},[g(n("input",{"onUpdate:modelValue":S=>l.value.args[C]=S,class:"ui-field","data-size":"md",type:"password",autocomplete:"new-password","aria-label":a(e)("Argument","参数")},null,8,kt),[[A,l.value.args[C]]]),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",type:"button",onClick:S=>l.value.args.splice(C,1)},t(a(e)("Remove","移除")),9,_t)]))),128)),n("button",{class:"ui-button","data-size":"sm","data-variant":"secondary",type:"button",onClick:s[13]||(s[13]=o=>l.value.args.push(""))},t(a(e)("Add argument","添加参数")),1)])):v("",!0)],64)):(r(),u(U,{key:2},[y.value?(r(),u("p",wt,t(a(e)("Current endpoint","当前端点"))+": "+t(l.value.endpoint)+" — "+t(a(e)("Path and credentials are hidden.","路径和凭据已隐藏。")),1)):v("",!0),l.value.secretsInUserScope?v("",!0):(r(),u("label",Ct,[n("span",null,t(y.value?a(e)("Replace URL (blank preserves the stored URL)","替换 URL(留空保留已存储的 URL)"):"URL"),1),g(n("input",{"onUpdate:modelValue":s[14]||(s[14]=o=>l.value.url=o),class:"ui-field","data-size":"md",type:"text",inputmode:"url",required:!y.value,autocomplete:"off"},null,8,Ut),[[A,l.value.url]])])),y.value?v("",!0):(r(),u(U,{key:2},[n("label",At,[g(n("input",{"onUpdate:modelValue":s[15]||(s[15]=o=>l.value.oauth=o),type:"checkbox",disabled:!!l.value.token},null,8,St),[[de,l.value.oauth]]),R(t(a(e)("Configure OAuth","配置 OAuth")),1)]),l.value.oauth?v("",!0):(r(),u("label",zt,[n("span",null,t(a(e)("Bearer token (optional, write-only)","Bearer 令牌(可选,只写)")),1),g(n("input",{"onUpdate:modelValue":s[16]||(s[16]=o=>l.value.token=o),class:"ui-field","data-size":"md",type:"password",autocomplete:"new-password"},null,512),[[A,l.value.token]])]))],64)),y.value&&!oe.value?(r(),u("label",Vt,[n("span",null,t(a(e)("OAuth configuration","OAuth 配置")),1),g(n("select",{"onUpdate:modelValue":s[17]||(s[17]=o=>l.value.oauthAction=o),class:"ui-field","data-size":"md"},[n("option",It,t(a(e)("Preserve existing configuration","保留现有配置")),1),n("option",Mt,t(a(e)("Configure / edit OAuth","配置 / 编辑 OAuth")),1),n("option",Pt,t(a(e)("Remove explicit configuration (automatic discovery remains)","移除显式配置(仍可自动发现)")),1)],512),[[N,l.value.oauthAction]])])):v("",!0),!y.value&&l.value.oauth||y.value&&l.value.oauthAction==="set"&&!oe.value?(r(),u("section",Rt,[n("p",null,t(a(e)("OAuth cannot be combined with a bearer token or Authorization header. Remove those explicitly when enabling OAuth. Leave optional fields blank to use defaults.","OAuth 不能与 Bearer 令牌或 Authorization 请求头一起使用。启用 OAuth 时请明确移除这些字段。可选字段留空使用默认值。")),1),n("label",null,[n("span",null,t(a(e)("OAuth client ID (optional)","OAuth 客户端 ID(可选)")),1),g(n("input",{"onUpdate:modelValue":s[18]||(s[18]=o=>l.value.clientId=o),class:"ui-field","data-size":"md"},null,512),[[A,l.value.clientId]])]),n("label",null,[n("span",null,t(a(e)("Callback port (default 1456)","回调端口(默认 1456)")),1),g(n("input",{"onUpdate:modelValue":s[19]||(s[19]=o=>l.value.callbackPort=o),class:"ui-field","data-size":"md",type:"number",min:"1",max:"65535",step:"1",placeholder:"1456"},null,512),[[A,l.value.callbackPort]])]),n("label",null,[n("span",null,t(a(e)("Scopes (space separated, optional)","权限范围(空格分隔,可选)")),1),g(n("input",{"onUpdate:modelValue":s[20]||(s[20]=o=>l.value.scopes=o),class:"ui-field","data-size":"md"},null,512),[[A,l.value.scopes]])]),y.value&&!l.value.secretsInUserScope?(r(),u("label",Tt,[n("span",null,t(a(e)("Authorization metadata URL","授权元数据 URL"))+" · "+t(l.value.metadataConfigured?a(e)("Configured (hidden)","已配置(隐藏)"):a(e)("None","无")),1),g(n("select",{"onUpdate:modelValue":s[21]||(s[21]=o=>l.value.metadataAction=o),class:"ui-field","data-size":"md"},[n("option",xt,t(a(e)("Keep","保留")),1),n("option",jt,t(a(e)("Replace","替换")),1),n("option",Lt,t(a(e)("Remove","移除")),1)],512),[[N,l.value.metadataAction]])])):v("",!0),!l.value.secretsInUserScope&&(!y.value||l.value.metadataAction==="set")?(r(),u("label",Dt,[n("span",null,t(a(e)("Authorization metadata URL (optional fallback)","授权元数据 URL(可选回退)")),1),g(n("input",{"onUpdate:modelValue":s[22]||(s[22]=o=>l.value.metadataUrl=o),class:"ui-field","data-size":"md",type:"url",required:y.value&&l.value.metadataAction==="set",autocomplete:"off"},null,8,Et),[[A,l.value.metadataUrl]])])):v("",!0),n("p",null,t(a(e)("Client secrets are entered under server details when signing in, never in saved configuration.","客户端密钥在服务器详情中登录时输入,绝不写入配置。")),1)])):v("",!0)],64)),y.value&&!l.value.secretsInUserScope&&l.value.type!=="stdio"?(r(),u("section",Ot,[n("h4",null,t(a(e)("Bearer token (write-only)","Bearer 令牌(只写)")),1),n("p",null,t(l.value.authConfigured?a(e)("A token is configured.","已配置令牌。"):a(e)("No token is configured.","未配置令牌。")),1),n("label",null,[n("span",null,t(a(e)("Token action","令牌操作")),1),g(n("select",{"onUpdate:modelValue":s[23]||(s[23]=o=>l.value.bearerAction=o),class:"ui-field","data-size":"md"},[n("option",$t,t(a(e)("Keep stored token","保留已存储的令牌")),1),n("option",{value:"set",disabled:he.value},t(a(e)("Replace token","替换令牌")),9,Nt),n("option",qt,t(a(e)("Remove token","移除令牌")),1)],512),[[N,l.value.bearerAction]])]),l.value.bearerAction==="set"?(r(),u("label",Bt,[n("span",null,t(a(e)("New bearer token","新 Bearer 令牌")),1),g(n("input",{"onUpdate:modelValue":s[24]||(s[24]=o=>l.value.token=o),class:"ui-field","data-size":"md",type:"password",autocomplete:"new-password",required:""},null,512),[[A,l.value.token]])])):v("",!0)])):v("",!0),l.value.secretsInUserScope?v("",!0):(r(),u("section",Ft,[n("h4",null,t(l.value.type==="stdio"?a(e)("Environment variables","环境变量"):a(e)("HTTP headers","HTTP 请求头")),1),n("p",null,t(a(e)("Stored values are never returned. Keep preserves a value; Set replaces it; Remove deletes it. Values are not stored in this browser.","已存储的值不会返回。“保留”维持原值,“设置”替换原值,“删除”移除字段。值不会保存在此浏览器中。")),1),(r(!0),u(U,null,E(l.value.secrets,(o,C)=>(r(),u("div",{key:C,class:"secret-row"},[g(n("input",{"onUpdate:modelValue":S=>o.name=S,class:"ui-field","data-size":"md","aria-label":a(e)("Field name","字段名称"),readonly:o.stored,required:""},null,8,Ht),[[A,o.name]]),g(n("select",{"onUpdate:modelValue":S=>o.action=S,class:"ui-field","data-size":"md","aria-label":a(e)("Secret action","机密操作")},[o.stored?(r(),u("option",Wt,t(a(e)("Keep","保留")),1)):v("",!0),n("option",Jt,t(a(e)("Set","设置")),1),o.stored?(r(),u("option",Gt,t(a(e)("Remove","删除")),1)):v("",!0)],8,Kt),[[N,o.action]]),o.action==="set"?g((r(),u("input",{key:0,"onUpdate:modelValue":S=>o.value=S,class:"ui-field","data-size":"md",type:"password",autocomplete:"new-password","aria-label":a(e)("New value","新值")},null,8,Qt)),[[A,o.value]]):v("",!0),n("button",{class:"ui-button","data-size":"sm","data-variant":"secondary",type:"button",onClick:S=>l.value.secrets.splice(C,1)},t(a(e)("Cancel field change","取消字段更改")),9,Xt)]))),128)),n("button",{class:"ui-button","data-size":"sm","data-variant":"secondary",type:"button",onClick:s[25]||(s[25]=o=>l.value.secrets.push({name:"",action:"set",value:""}))},t(a(e)("Add field","添加字段")),1)])),!y.value&&l.value.source==="user"?(r(),u("label",Yt,[g(n("input",{"onUpdate:modelValue":s[26]||(s[26]=o=>l.value.enabled=o),type:"checkbox"},null,512),[[de,l.value.enabled]]),R(t(a(e)("Enable after saving","保存后启用")),1)])):v("",!0),l.value.source==="project"?(r(),u("p",Zt,t(a(e)("Project tests require a saved entry that you explicitly enabled locally. Unsaved project definitions cannot execute.","项目测试要求条目已保存且由您在本地明确启用。未保存的项目定义不能执行。")),1)):v("",!0),y.value?(r(),u("p",ea,t(a(e)("Enablement and unedited fields are preserved. Use the server actions to enable, disable or sign in.","启用状态及未编辑字段会被保留。请通过服务器操作启用、禁用或登录。")),1)):v("",!0),n("div",ta,[n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",type:"button",disabled:!a(p).supports("mcp.test")||l.value.source==="project"&&(!y.value||!l.value.enabled),onClick:s[27]||(s[27]=o=>Z())},t(a(e)("Test draft connection","测试草稿连接")),9,aa),n("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:!D.value||y.value&&!a(p).supports("mcp.update")},t(a(e)("Save server","保存服务器")),9,na),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",type:"button",onClick:ke},t(a(e)("Cancel","取消")),1)])],8,rt)],544)):v("",!0),k.value?(r(),u("section",oa,[k.value.probe.status==="connected"?(r(),u("h3",sa,t(a(e)("Connection test passed","连接测试通过"))+": "+t(k.value.id)+" · "+t(k.value.probe.latencyMs)+" ms",1)):k.value.probe.status==="authRequired"?(r(),u("h3",la,t(a(e)("Sign-in required","需要登录"))+": "+t(k.value.id)+" · "+t(k.value.probe.latencyMs)+" ms",1)):(r(),u("h3",ia,t(a(e)("Connection test failed","连接测试失败"))+": "+t(k.value.id)+" · "+t(k.value.probe.latencyMs)+" ms",1)),k.value.probe.status==="connected"?(r(),u("p",ua,t(a(e)("The temporary connection has been closed. Configuration and session connections were not changed.","临时连接已关闭。配置及会话连接未被更改。")),1)):k.value.probe.status==="authRequired"?(r(),u(U,{key:4},[n("p",null,t(k.value.probe.expired?a(e)("The stored credential was rejected. Sign in again.","已存储的凭据被拒绝,请重新登录。"):a(e)("This server requires sign-in.","此服务器需要登录。")),1),(P=k.value.probe.missingScopes)!=null&&P.length?(r(),u("p",ra,t(a(e)("Additional scopes","额外权限范围"))+": "+t(k.value.probe.missingScopes.join(", ")),1)):v("",!0)],64)):(r(),u("p",da,[R(t(fe(k.value.probe.reason)),1),k.value.probe.message?(r(),u(U,{key:0},[R(" · "+t(k.value.probe.message),1)],64)):v("",!0)])),k.value.probe.tools?(r(),u("ul",ca,[(r(!0),u(U,null,E(k.value.probe.tools,o=>(r(),u("li",{key:o.name},[n("strong",null,t(o.name),1),o.description?(r(),u("p",va,t(o.description),1)):v("",!0)]))),128))])):v("",!0),k.value.probe.status==="connected"&&!((f=k.value.probe.tools)!=null&&f.length)?(r(),u("p",pa,t(a(e)("The server exposes no tools.","服务器没有提供工具。")),1)):v("",!0)])):v("",!0),M.value?(r(),u("section",ma,[n("h3",null,t(a(e)("Authorize MCP","授权 MCP"))+": "+t(te.value),1),n("p",null,[R(t(a(e)("Callback","回调"))+": ",1),n("code",null,t(M.value.redirectUri),1),R(" · "+t(a(e)("Expires","过期时间"))+": "+t(new Date(M.value.expiresAt).toLocaleString()),1)]),n("a",{class:"ui-button","data-size":"md","data-variant":"primary",href:M.value.authorizationUrl,target:"_blank",rel:"noopener noreferrer"},t(a(e)("Open authorization page","打开授权页面")),9,ba),n("form",{class:"settings-form",autocomplete:"off",onSubmit:s[30]||(s[30]=ee(o=>re(),["prevent"]))},[n("label",null,[n("span",null,t(a(e)("Paste the full callback URL after authorization","授权后粘贴完整回调 URL")),1),g(n("input",{"onUpdate:modelValue":s[28]||(s[28]=o=>L.value=o),class:"ui-field","data-size":"md",type:"password",autocomplete:"new-password",disabled:c.value,required:""},null,8,ha),[[A,L.value]])]),n("div",fa,[n("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:c.value||!a(p).supports("mcp.auth.complete")},t(a(e)("Complete sign-in","完成登录")),9,ya),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",type:"button",disabled:c.value||!a(p).supports("mcp.auth.cancel"),onClick:s[29]||(s[29]=o=>re(!0))},t(a(e)("Cancel sign-in","取消登录")),9,ga)])],32)])):v("",!0),n("label",ka,[n("span",null,t(a(e)("Search servers","搜索服务器")),1),g(n("input",{"onUpdate:modelValue":s[31]||(s[31]=o=>W.value=o),class:"ui-field","data-size":"md",type:"search"},null,512),[[A,W.value]])]),(r(!0),u(U,null,E(se.value,o=>(r(),u("section",{key:`${o.source}:${o.id}`,class:"settings-card"},[n("h3",null,t(o.id),1),n("p",null,[R(t(o.source)+" · "+t(o.transport)+" · "+t(o.enabled?a(e)("Enabled","已启用"):a(e)("Disabled","已禁用")),1),o.auth?(r(),u(U,{key:0},[R(" · OAuth: "+t(o.auth),1)],64)):v("",!0)]),n("div",_a,[n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!a(p).supports("mcp.inspect"),onClick:C=>le(o)},t(a(e)("Details / tools","详情 / 工具")),9,wa),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!!l.value||!a(p).supports("mcp.test")||o.source!=="user"&&!o.enabled,onClick:C=>Z(o)},t(a(e)("Test connection","测试连接")),9,Ca),o.source!=="plugin"?(r(),u(U,{key:0},[n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!!l.value||!a(p).supports("mcp.configuration")||!a(p).supports("mcp.update"),onClick:C=>ge(o)},t(a(e)("Edit","编辑")),9,Ua),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!!l.value||!a(p).supports("mcp.move")||o.source==="user"&&!T.value,onClick:C=>ue(o)},t(o.source==="user"?a(e)("Move to project…","移入项目…"):a(e)("Move to user…","移到用户…")),9,Aa),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!!l.value||!a(p).supports("mcp.set_enabled"),onClick:C=>F("mcp.set_enabled",o)},t(o.enabled?a(e)("Disable","禁用"):a(e)("Enable","启用")),9,Sa),n("button",{class:"ui-button","data-size":"md","data-variant":"danger-ghost",disabled:c.value||!!l.value||!a(p).supports("mcp.remove"),onClick:C=>F("mcp.remove",o)},t(a(e)("Remove","移除")),9,za)],64)):v("",!0),n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!o.enabled||!a(p).supports("mcp.disconnect"),onClick:C=>F("mcp.disconnect",o)},t(a(e)("Disconnect","断开连接")),9,Va),o.transport!=="stdio"?(r(),u(U,{key:1},[n("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!!M.value||!o.enabled||!a(p).supports("mcp.auth.start"),onClick:C=>F("mcp.auth.start",o)},t(a(e)("Sign in","登录")),9,Ia),o.auth?(r(),u("button",{key:0,class:"ui-button","data-size":"md","data-variant":"secondary",disabled:c.value||!a(p).supports("mcp.auth.logout"),onClick:C=>F("mcp.auth.logout",o)},t(a(e)("Sign out","退出登录")),9,Ma)):v("",!0)],64)):v("",!0)]),o.source==="plugin"?(r(),u("p",Pa,t(a(e)("This entry is owned by its plugin. Change it through Plugins.","此条目归其插件所有。请通过插件页面更改。")),1)):v("",!0)]))),128)),_.value&&!se.value.length&&!Y.value.length?(r(),u("p",Ra,t(a(e)("No matching MCP servers. Add a server to get started.","没有匹配的 MCP 服务器。请添加服务器以开始使用。")),1)):v("",!0)])}}}),Oa=je(Ta,[["__scopeId","data-v-e93ea48f"]]);export{Oa as default};
@@ -0,0 +1 @@
1
+ fieldset[data-v-e93ea48f]{display:grid;gap:var(--space-4);min-width:0;padding:0;border:0}label[data-v-e93ea48f]{display:grid;gap:var(--space-2)}.checkbox-label[data-v-e93ea48f],.argument-row[data-v-e93ea48f]{display:flex;align-items:center;gap:var(--space-2)}.argument-row[data-v-e93ea48f]{margin-block:var(--space-2)}.argument-row input[data-v-e93ea48f]{flex:1;min-width:0}.secret-row[data-v-e93ea48f]{display:grid;grid-template-columns:1fr auto 1fr auto;gap:var(--space-2);margin-block:var(--space-3)}.search-label[data-v-e93ea48f]{margin-block:var(--space-4)}.runtime-detail[data-v-e93ea48f]{border-top:1px solid var(--border);padding-top:var(--space-3)}code[data-v-e93ea48f],li p[data-v-e93ea48f]{overflow-wrap:anywhere}@media(max-width:700px){.secret-row[data-v-e93ea48f]{grid-template-columns:1fr 1fr}}
@@ -1 +1 @@
1
- import{d as w,x as J,c as d,e as i,t as o,u as l,j as A,B as L,F as N,E as x,a as I,r as h,z as E,o as c}from"./vendor-vue-CncuOShJ.js";import{u as P}from"./settings-general-dc8P6dA0.js";import{u as q,a as G,g as R,R as H}from"./index-CenMTLFY.js";import{_ as K}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as Q,r as U,m as O}from"./context-Grqd_9Lt.js";const W={class:"settings-page"},X={"data-route-heading":"",tabindex:"-1"},Y={key:0,class:"ui-banner settings-banner","data-tone":"warning"},Z=["value","disabled","onChange"],ee={value:""},ae=["value","disabled"],te={key:1,class:"ui-field-hint","data-tone":"danger"},ne={key:2},se={class:"settings-actions"},oe=["disabled"],fe=w({__name:"ModalitySettings",setup(re){const n=P(),f=q(),b=G(),v=h(),m=h({}),u=h(!1),g=h(""),y=h(!1),_=h(!1),k=E(()=>{var e,a;return((a=(e=v.value)==null?void 0:e.categories.find(t=>t.category==="image"))==null?void 0:a.operations)??[]}),p=E(()=>k.value.some(e=>e.key!==void 0&&(m.value[e.key]??"")!==M(e)));Q(p);function S(e){return JSON.stringify([e.providerId,e.modelId])}function M(e){const a=k.value.find(t=>t.key===e.key);return a!=null&&a.default?S(a.default):""}function C(e){var t,s;const a=(t=b.providers)==null?void 0:t.find(r=>r.providerId===e.providerId);return a?`${a.name} / ${((s=a.models.find(r=>r.id===e.modelId))==null?void 0:s.name)??e.modelId}`:`${e.providerId} / ${e.modelId}`}function B(e){switch(e){case"generate":return n("Image generation","图像生成");case"edit":return n("Image editing","图像编辑");case"enhance":return n("Image enhancement","图像增强");case"understand":return n("Image understanding","图像理解");default:return e}}function D(e){return e.reasons.map(a=>a.detail).join("; ")}function F(e){if(!e.effective)return e.default?n("None. The configured default is unavailable and is never replaced by another model.","无。已配置的默认值不可用,且不会被其他模型替代。"):n("None. No model serves this operation now.","无。当前没有模型服务此操作。");const a=C(e.effective);return e.effective.source==="automatic"?`${a} (${n("automatic","自动")})`:`${a} (${n("configured","已配置")})`}function j(e){if(e==="")return null;const[a,t]=JSON.parse(e);return{providerId:a,modelId:t}}function z(e,a){m.value[e]=a.target.value}function T(e){var t;const a=((t=e.categories.find(s=>s.category==="image"))==null?void 0:t.operations)??[];m.value=Object.fromEntries(a.filter(s=>s.key!==void 0).map(s=>[s.key,s.default?S(s.default):""]))}async function $(){if(!u.value&&!(p.value&&!window.confirm(n("Discard unsaved defaults?","放弃未保存的默认设置?")))){u.value=!0,g.value="",y.value=!1,_.value=!1;try{if(!f.supports("modality.capabilities"))throw new Error(n("Modality settings are not available on this server.","此服务器不支持多模态设置。"));const[e]=await Promise.all([f.client.call("modality.capabilities",{},R),b.load()]);if(!e.categories.some(a=>a.category==="image"))throw new Error(n("The server reports no image category for Modality.","服务器未返回多模态的图像类别。"));v.value=e,T(e),b.error&&(g.value=b.error)}catch(e){g.value=O(e)}finally{u.value=!1}}}async function V(){if(!(!v.value||u.value||!p.value||y.value)){u.value=!0,g.value="",_.value=!1;try{for(const e of k.value)e.key===void 0||(m.value[e.key]??"")===M(e)||(v.value=await f.client.call("modality.configure",{expectedRevision:v.value.revision,category:"image",operation:e.operation,model:j(m.value[e.key]??"")},R));_.value=!0}catch(e){y.value=e instanceof H&&e.appError==="modality_conflict",g.value=y.value?n("Modality defaults changed. Reload before saving again; your draft has been preserved.","多模态默认设置已变更。请重新加载后再保存,当前草稿已保留。"):O(e)}finally{u.value=!1}}}return U(f,$,p),J($),(e,a)=>(c(),d("article",W,[i("header",null,[i("h2",X,o(l(n)("Modality","多模态")),1),i("p",null,o(l(n)("Choose the default model for each image operation. Clearing a default restores automatic resolution; an unavailable default is never replaced by another model.","为每个图像操作选择默认模型。清除默认值即恢复自动解析;不可用的默认值不会被其他模型替代。")),1)]),A(K,{busy:u.value,error:g.value,saved:_.value&&!p.value,onReload:$},null,8,["busy","error","saved"]),v.value?(c(),d("form",{key:0,class:"settings-form",onSubmit:L(V,["prevent"])},[(c(!0),d(N,null,x(k.value,t=>{var s;return c(),d("section",{key:t.operation,class:"settings-card"},[i("h3",null,o(B(t.operation)),1),t.reasons.length?(c(),d("p",Y,o(D(t)),1)):I("",!0),i("label",null,[i("span",null,o(l(n)("Default model","默认模型")),1),i("select",{value:m.value[t.key]??"",class:"ui-field","data-size":"md",disabled:u.value||y.value||!l(f).supports("modality.configure"),onChange:r=>z(t.key,r)},[i("option",ee,o(l(n)("Automatic","自动")),1),(c(!0),d(N,null,x(t.options,r=>(c(),d("option",{key:S(r),value:S(r),disabled:!r.available},o(C(r))+o(r.available?"":` (${l(n)("unavailable","不可用")})`),9,ae))),128))],40,Z)]),i("p",null,o(l(n)("Currently effective","当前生效"))+": "+o(F(t)),1),t.default&&!t.default.available?(c(),d("p",te,o((s=t.default.reason)==null?void 0:s.detail),1)):I("",!0),t.operation==="understand"?(c(),d("p",ne,o(l(n)("Selection only for now: the Session image-understanding path does not read this default yet, so it does not change the model a Session uses.","目前仅用于选择:会话的图像理解路径尚未读取此默认值,因此不会改变会话使用的模型。")),1)):I("",!0)])}),128)),i("footer",se,[i("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:u.value||!p.value||y.value||!l(f).supports("modality.configure")},o(l(n)("Save defaults","保存默认设置")),9,oe)])],32)):I("",!0)]))}});export{fe as default};
1
+ import{d as w,x as J,c as d,e as i,t as o,u as l,j as A,B as L,F as N,E as x,a as I,r as h,z as E,o as c}from"./vendor-vue-CncuOShJ.js";import{u as P}from"./settings-general-dc8P6dA0.js";import{u as q,a as G,g as R,R as H}from"./index-DVjYS93F.js";import{_ as K}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as Q,r as U,m as O}from"./context-Grqd_9Lt.js";const W={class:"settings-page"},X={"data-route-heading":"",tabindex:"-1"},Y={key:0,class:"ui-banner settings-banner","data-tone":"warning"},Z=["value","disabled","onChange"],ee={value:""},ae=["value","disabled"],te={key:1,class:"ui-field-hint","data-tone":"danger"},ne={key:2},se={class:"settings-actions"},oe=["disabled"],fe=w({__name:"ModalitySettings",setup(re){const n=P(),f=q(),b=G(),v=h(),m=h({}),u=h(!1),g=h(""),y=h(!1),_=h(!1),k=E(()=>{var e,a;return((a=(e=v.value)==null?void 0:e.categories.find(t=>t.category==="image"))==null?void 0:a.operations)??[]}),p=E(()=>k.value.some(e=>e.key!==void 0&&(m.value[e.key]??"")!==M(e)));Q(p);function S(e){return JSON.stringify([e.providerId,e.modelId])}function M(e){const a=k.value.find(t=>t.key===e.key);return a!=null&&a.default?S(a.default):""}function C(e){var t,s;const a=(t=b.providers)==null?void 0:t.find(r=>r.providerId===e.providerId);return a?`${a.name} / ${((s=a.models.find(r=>r.id===e.modelId))==null?void 0:s.name)??e.modelId}`:`${e.providerId} / ${e.modelId}`}function B(e){switch(e){case"generate":return n("Image generation","图像生成");case"edit":return n("Image editing","图像编辑");case"enhance":return n("Image enhancement","图像增强");case"understand":return n("Image understanding","图像理解");default:return e}}function D(e){return e.reasons.map(a=>a.detail).join("; ")}function F(e){if(!e.effective)return e.default?n("None. The configured default is unavailable and is never replaced by another model.","无。已配置的默认值不可用,且不会被其他模型替代。"):n("None. No model serves this operation now.","无。当前没有模型服务此操作。");const a=C(e.effective);return e.effective.source==="automatic"?`${a} (${n("automatic","自动")})`:`${a} (${n("configured","已配置")})`}function j(e){if(e==="")return null;const[a,t]=JSON.parse(e);return{providerId:a,modelId:t}}function z(e,a){m.value[e]=a.target.value}function T(e){var t;const a=((t=e.categories.find(s=>s.category==="image"))==null?void 0:t.operations)??[];m.value=Object.fromEntries(a.filter(s=>s.key!==void 0).map(s=>[s.key,s.default?S(s.default):""]))}async function $(){if(!u.value&&!(p.value&&!window.confirm(n("Discard unsaved defaults?","放弃未保存的默认设置?")))){u.value=!0,g.value="",y.value=!1,_.value=!1;try{if(!f.supports("modality.capabilities"))throw new Error(n("Modality settings are not available on this server.","此服务器不支持多模态设置。"));const[e]=await Promise.all([f.client.call("modality.capabilities",{},R),b.load()]);if(!e.categories.some(a=>a.category==="image"))throw new Error(n("The server reports no image category for Modality.","服务器未返回多模态的图像类别。"));v.value=e,T(e),b.error&&(g.value=b.error)}catch(e){g.value=O(e)}finally{u.value=!1}}}async function V(){if(!(!v.value||u.value||!p.value||y.value)){u.value=!0,g.value="",_.value=!1;try{for(const e of k.value)e.key===void 0||(m.value[e.key]??"")===M(e)||(v.value=await f.client.call("modality.configure",{expectedRevision:v.value.revision,category:"image",operation:e.operation,model:j(m.value[e.key]??"")},R));_.value=!0}catch(e){y.value=e instanceof H&&e.appError==="modality_conflict",g.value=y.value?n("Modality defaults changed. Reload before saving again; your draft has been preserved.","多模态默认设置已变更。请重新加载后再保存,当前草稿已保留。"):O(e)}finally{u.value=!1}}}return U(f,$,p),J($),(e,a)=>(c(),d("article",W,[i("header",null,[i("h2",X,o(l(n)("Modality","多模态")),1),i("p",null,o(l(n)("Choose the default model for each image operation. Clearing a default restores automatic resolution; an unavailable default is never replaced by another model.","为每个图像操作选择默认模型。清除默认值即恢复自动解析;不可用的默认值不会被其他模型替代。")),1)]),A(K,{busy:u.value,error:g.value,saved:_.value&&!p.value,onReload:$},null,8,["busy","error","saved"]),v.value?(c(),d("form",{key:0,class:"settings-form",onSubmit:L(V,["prevent"])},[(c(!0),d(N,null,x(k.value,t=>{var s;return c(),d("section",{key:t.operation,class:"settings-card"},[i("h3",null,o(B(t.operation)),1),t.reasons.length?(c(),d("p",Y,o(D(t)),1)):I("",!0),i("label",null,[i("span",null,o(l(n)("Default model","默认模型")),1),i("select",{value:m.value[t.key]??"",class:"ui-field","data-size":"md",disabled:u.value||y.value||!l(f).supports("modality.configure"),onChange:r=>z(t.key,r)},[i("option",ee,o(l(n)("Automatic","自动")),1),(c(!0),d(N,null,x(t.options,r=>(c(),d("option",{key:S(r),value:S(r),disabled:!r.available},o(C(r))+o(r.available?"":` (${l(n)("unavailable","不可用")})`),9,ae))),128))],40,Z)]),i("p",null,o(l(n)("Currently effective","当前生效"))+": "+o(F(t)),1),t.default&&!t.default.available?(c(),d("p",te,o((s=t.default.reason)==null?void 0:s.detail),1)):I("",!0),t.operation==="understand"?(c(),d("p",ne,o(l(n)("Selection only for now: the Session image-understanding path does not read this default yet, so it does not change the model a Session uses.","目前仅用于选择:会话的图像理解路径尚未读取此默认值,因此不会改变会话使用的模型。")),1)):I("",!0)])}),128)),i("footer",se,[i("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:u.value||!p.value||y.value||!l(f).supports("modality.configure")},o(l(n)("Save defaults","保存默认设置")),9,oe)])],32)):I("",!0)]))}});export{fe as default};
@@ -0,0 +1 @@
1
+ import{d as T,x as F,c as m,e,t,u as s,j as O,b as N,a as x,B as z,l as y,L as M,F as J,E as L,r as c,z as E,C as j,D as B,o as p}from"./vendor-vue-CncuOShJ.js";import{u as q}from"./settings-general-dc8P6dA0.js";import{u as I,t as W,v as A,w as G,f as H,k as K}from"./index-DVjYS93F.js";import{_ as Q}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as X,r as Y,m as C}from"./context-Grqd_9Lt.js";const Z={class:"settings-page"},ee={"data-route-heading":"",tabindex:"-1"},ae={key:0,class:"ui-banner settings-banner","data-tone":"danger",role:"alert"},se=["disabled"],te={key:0,class:"ui-banner settings-banner","data-tone":"warning"},ne=["disabled"],oe={class:"ui-banner settings-banner","data-tone":"warning"},le={class:"settings-actions"},ie=["disabled"],ue={class:"settings-card"},re=["disabled"],de=["onUpdate:modelValue","aria-label"],ce=["onUpdate:modelValue","aria-label"],ve={value:"exact"},me={value:"prefix"},pe=["onUpdate:modelValue","aria-label"],be={value:"allow"},he={value:"deny"},fe=["onClick"],_e={key:0},we={class:"settings-actions"},ge=["disabled"],xe=["disabled"],ye=T({__name:"PermissionsSettings",setup(ke){const a=q(),i=I(),v=c(),d=c([]),n=c(!1),f=c(""),k=c(!1),l=c(),b=c(!1),h=c(!1),S=c(),_=c(""),V=E(()=>l.value!==void 0&&(b.value!==l.value.sandbox||h.value!==l.value.network)),D=E(()=>v.value!==void 0&&JSON.stringify(d.value)!==JSON.stringify(v.value.commandRules)),R=E(()=>D.value||V.value);X(R);async function g(){if(!n.value&&!(R.value&&!window.confirm(a("Discard unsaved command rules?","放弃未保存的命令规则?")))){n.value=!0,f.value="",k.value=!1;try{if(!i.supports("permission.rules"))throw new Error(a("Command rules are not available on this server.","此服务器不支持命令规则。"));v.value=await i.client.call("permission.rules",{},W),d.value=v.value.commandRules.map(o=>({...o}))}catch(o){f.value=C(o)}try{_.value="",i.supports("settings.read")&&(l.value=await i.client.call("settings.read",{source:"execution",scope:"user"},A),b.value=l.value.sandbox,h.value=l.value.network),i.supports("host.execution.backend")&&(S.value=await i.client.call("host.execution.backend",{},G))}catch(o){_.value=C(o)}n.value=!1}}async function $(){if(!(!v.value||!D.value||n.value)){if(d.value.some(o=>!o.command.trim()||/[;&|`()<>$\n\r]/.test(o.command))){f.value=a("Enter a simple command without shell separators, substitutions or redirection.","请输入不含 Shell 分隔符、替换或重定向的简单命令。");return}if(!(d.value.some(o=>o.decision==="allow")&&!window.confirm(a("Save command rules that allow execution without asking? Deny presets still take precedence.","保存允许免询问执行的命令规则?拒绝预设仍然优先。")))){n.value=!0,f.value="",k.value=!1;try{const o=await i.client.call("permission.set_rules",{expectedRevision:v.value.revision,commandRules:d.value},H);v.value={revision:o,commandRules:d.value.map(u=>({...u}))},k.value=!0}catch(o){f.value=C(o)}finally{n.value=!1}}}}async function P(){if(!(!l.value||n.value||!V.value||(l.value.sandbox&&!b.value||!l.value.network&&h.value)&&!window.confirm(a("New commands will run with less isolation than now. Running processes keep their boundary.","新命令将以比现在更少的隔离运行。已运行的进程保留原边界。")))){n.value=!0,_.value="";try{l.value=await i.client.call("settings.update",{source:"execution",scope:"user",expectedRevision:l.value.revision,document:{sandbox:b.value,network:h.value}},A),b.value=l.value.sandbox,h.value=l.value.network}catch(u){_.value=C(u)}finally{n.value=!1}}}return Y(i,g,R),F(g),(o,u)=>(p(),m("article",Z,[e("header",null,[e("h2",ee,t(s(a)("Permissions","权限")),1),e("p",null,t(s(a)("User-level command rules apply to process-starting agent tools in every session. Deny wins; Allow never overrides a denied permission preset.","用户命令规则适用于所有会话中启动进程的代理工具。拒绝优先;允许规则不会越过权限预设的拒绝。")),1)]),O(Q,{busy:n.value,error:f.value,saved:k.value&&!R.value,onReload:g},null,8,["busy","error","saved"]),_.value?(p(),m("p",ae,[N(t(_.value)+" ",1),e("button",{class:"ui-button","data-variant":"ghost",disabled:n.value,onClick:g},t(s(a)("Reload","重新加载")),9,se)])):x("",!0),l.value?(p(),m("form",{key:1,class:"settings-card settings-form",onSubmit:u[2]||(u[2]=z(r=>P(),["prevent"]))},[e("h3",null,t(s(a)("Execution","执行")),1),e("p",null,t(s(a)("Applies to new commands on this execution host. Running processes keep their boundary. A platform without a sandbox backend fails the command instead of running it unsandboxed.","适用于此执行主机上的新命令。已运行的进程保留原边界。没有沙盒后端的平台会让命令失败,而不是不加隔离地运行。")),1),S.value&&S.value.available===!1?(p(),m("p",te,t(s(a)("Sandbox is unavailable on this host: ","此主机上沙盒不可用:"))+t(S.value.reason),1)):x("",!0),e("fieldset",{class:"settings-form",disabled:n.value||!s(i).supports("settings.update")},[e("label",null,[y(e("input",{"onUpdate:modelValue":u[0]||(u[0]=r=>b.value=r),type:"checkbox"},null,512),[[M,b.value]]),N(t(s(a)("Sandbox — run commands isolated from the host","沙盒 — 在隔离环境中运行命令")),1)]),e("label",null,[y(e("input",{"onUpdate:modelValue":u[1]||(u[1]=r=>h.value=r),type:"checkbox"},null,512),[[M,h.value]]),N(t(s(a)("Network — allow outbound connections while sandboxed","网络 — 沙盒内允许出站连接")),1)])],8,ne),e("p",oe,t(s(a)("Network applies only while the sandbox is on. With the sandbox off, commands run as the daemon user with this host's files and network.","网络仅在沙盒开启时生效。沙盒关闭时,命令以守护进程用户的身份、使用此主机的文件和网络运行。")),1),e("div",le,[e("button",{class:"ui-button","data-variant":"primary",disabled:n.value||!V.value||!s(i).supports("settings.update")},t(s(a)("Save execution settings","保存执行设置")),9,ie)])],32)):x("",!0),v.value?(p(),m("form",{key:2,class:"settings-form",onSubmit:z($,["prevent"])},[e("section",ue,[e("h3",null,t(s(a)("Command rules","命令规则")),1),e("fieldset",{disabled:n.value||!s(i).supports("permission.set_rules")},[e("legend",null,t(s(a)("Match commands by words, not wildcards or regular expressions.","按单词匹配命令,不支持通配符或正则表达式。")),1),(p(!0),m(J,null,L(d.value,(r,U)=>(p(),m("div",{key:U,class:"rule-row"},[y(e("input",{"onUpdate:modelValue":w=>r.command=w,class:"ui-field","data-size":"md","aria-label":s(a)("Command","命令"),placeholder:"git status",required:""},null,8,de),[[j,r.command]]),y(e("select",{"onUpdate:modelValue":w=>r.match=w,class:"ui-field","data-size":"md","aria-label":s(a)("Match","匹配方式")},[e("option",ve,t(s(a)("Exact","精确")),1),e("option",me,t(s(a)("Prefix","前缀")),1)],8,ce),[[B,r.match]]),y(e("select",{"onUpdate:modelValue":w=>r.decision=w,class:"ui-field","data-size":"md","aria-label":s(a)("Decision","决策")},[e("option",be,t(s(a)("Allow","允许")),1),e("option",he,t(s(a)("Deny","拒绝")),1)],8,pe),[[B,r.decision]]),e("button",{class:"ui-button","data-size":"md","data-variant":"danger-ghost",type:"button",onClick:w=>d.value.splice(U,1)},t(s(a)("Remove","移除")),9,fe)]))),128)),d.value.length?x("",!0):(p(),m("p",_e,t(s(a)("No command rules. The session permission preset and approval flow decide each call.","尚无命令规则。每次调用由会话权限预设和审批流程决定。")),1)),e("button",{class:"ui-button","data-size":"md","data-variant":"secondary",type:"button",onClick:u[3]||(u[3]=r=>d.value.push({command:"",match:"prefix",decision:"deny"}))},t(s(a)("Add rule","添加规则")),1)],8,re)]),e("footer",we,[e("button",{class:"ui-button","data-size":"md","data-variant":"secondary",type:"button",disabled:n.value,onClick:g},t(s(a)("Reload","重新加载")),9,ge),e("button",{class:"ui-button","data-size":"md","data-variant":"primary",disabled:n.value||!D.value||!s(i).supports("permission.set_rules")},t(s(a)("Save rules","保存规则")),9,xe)])],32)):x("",!0)]))}}),Ne=K(ye,[["__scopeId","data-v-8d0f4351"]]);export{Ne as default};
@@ -1 +1 @@
1
- import{d as N,x as B,c as u,e as a,t,u as l,j as T,l as p,D as E,C as x,a as _,L as j,b as S,B as F,F as w,E as V,r as v,z as P,o as d}from"./vendor-vue-CncuOShJ.js";import{u as q}from"./settings-general-dc8P6dA0.js";import{u as O,q as A,i as H,k as J}from"./index-CenMTLFY.js";import{_ as K}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as Q,r as W,m as $}from"./context-Grqd_9Lt.js";const X={class:"settings-page"},Y={"data-route-heading":"",tabindex:"-1"},Z=["disabled"],ee={value:"path"},ae=["placeholder"],te={key:0},le={class:"checkbox-label"},se={class:"ui-button","data-size":"md","data-variant":"primary"},ne={class:"search-label"},oe={key:0},ie={key:0,class:"ui-banner","data-tone":"danger"},ue={class:"settings-actions"},de=["onUpdate:modelValue","aria-label","disabled"],re=["value"],ce=["disabled","onClick"],ve=["disabled","onClick"],pe=["disabled","onClick"],me=["disabled","onClick"],be=["disabled","onClick"],fe={key:0,role:"status"},_e=["disabled"],ge=N({__name:"PluginSettings",setup(he){const s=q(),c=O(),C=v(),g=v({}),h=v("path"),k=v(""),m=v(""),b=v(""),I=v(!1),L=v(""),r=v(!1),y=v(""),U=P(()=>!!k.value||!!m.value||!!b.value);Q(U);const D=P(()=>{var i;return((i=C.value)==null?void 0:i.filter(o=>o.name.toLocaleLowerCase().includes(L.value.toLocaleLowerCase())))??[]});async function R(){C.value=await c.client.call("plugin.list",{},A),g.value=Object.fromEntries(C.value.map(i=>{var o;return[i.name,i.use??((o=i.candidates[0])==null?void 0:o.id)??""]}))}async function z(){r.value=!0,y.value="";try{if(!c.supports("plugin.list"))throw new Error(s("Plugin management is not available on this server.","此服务器不支持插件管理。"));await R()}catch(i){y.value=$(i)}finally{r.value=!1}}async function f(i,o){if(!r.value&&!(["plugin.install","plugin.enable","plugin.update","plugin.reload"].includes(i)&&!window.confirm(s("Plugins execute trusted code and configured commands with your user privileges. Continue?","插件会以您的用户权限执行受信任代码和配置命令。是否继续?")))&&!(i==="plugin.remove"&&!window.confirm(s("Remove this installed plugin? Its content will be withdrawn.","移除此已安装插件?其提供的内容也将撤回。")))){r.value=!0,y.value="";try{await c.client.call(i,o,H,18e4),i==="plugin.install"&&(k.value="",m.value="",b.value=""),await R()}catch(e){y.value=$(e)}finally{r.value=!1}}}function G(){const i=k.value.trim();i&&f("plugin.install",{source:h.value==="path"?{path:i}:{git:i,...m.value.trim()?{ref:m.value.trim()}:{}},...b.value.trim()?{id:b.value.trim()}:{},enable:I.value})}return W(c,z,U),B(z),(i,o)=>(d(),u("article",X,[a("header",null,[a("h2",Y,t(l(s)("Plugins","插件")),1),a("p",null,t(l(s)("Install local or Git packages, select implementations and manage their lifecycle. Locked system plugins cannot be disabled or replaced.","安装本地或 Git 包、选择实现并管理生命周期。锁定的系统插件不可禁用或替换。")),1)]),T(K,{busy:r.value,error:y.value,onReload:z},null,8,["busy","error"]),a("form",{class:"settings-card settings-form",onSubmit:F(G,["prevent"])},[a("h3",null,t(l(s)("Install plugin","安装插件")),1),a("fieldset",{disabled:r.value||!l(c).supports("plugin.install")},[a("label",null,[a("span",null,t(l(s)("Source type","来源类型")),1),p(a("select",{"onUpdate:modelValue":o[0]||(o[0]=e=>h.value=e),class:"ui-field","data-size":"md"},[a("option",ee,t(l(s)("Local directory","本地目录")),1),o[6]||(o[6]=a("option",{value:"git"},"Git",-1))],512),[[E,h.value]])]),a("label",null,[a("span",null,t(l(s)("Source","来源")),1),p(a("input",{"onUpdate:modelValue":o[1]||(o[1]=e=>k.value=e),class:"ui-field","data-size":"md",placeholder:h.value==="path"?"/path/to/plugin":"https://github.com/owner/plugin.git",required:""},null,8,ae),[[x,k.value]])]),h.value==="git"?(d(),u("label",te,[a("span",null,t(l(s)("Git ref (optional)","Git 引用(可选)")),1),p(a("input",{"onUpdate:modelValue":o[2]||(o[2]=e=>m.value=e),class:"ui-field","data-size":"md"},null,512),[[x,m.value]])])):_("",!0),a("label",null,[a("span",null,t(l(s)("Installation ID (optional)","安装 ID(可选)")),1),p(a("input",{"onUpdate:modelValue":o[3]||(o[3]=e=>b.value=e),class:"ui-field","data-size":"md"},null,512),[[x,b.value]])]),a("label",le,[p(a("input",{"onUpdate:modelValue":o[4]||(o[4]=e=>I.value=e),type:"checkbox"},null,512),[[j,I.value]]),S(t(l(s)("Enable after installation (executes plugin code)","安装后启用(执行插件代码)")),1)]),a("button",se,t(l(s)("Install","安装")),1)],8,Z)],32),a("label",ne,[a("span",null,t(l(s)("Search plugins","搜索插件")),1),p(a("input",{"onUpdate:modelValue":o[5]||(o[5]=e=>L.value=e),class:"ui-field","data-size":"md",type:"search"},null,512),[[x,L.value]])]),(d(!0),u(w,null,V(D.value,e=>(d(),u("section",{key:e.name,class:"settings-card"},[a("h3",null,[S(t(e.name)+" ",1),e.locked?(d(),u("small",oe,t(l(s)("Locked","已锁定")),1)):_("",!0)]),a("p",null,[S(t(e.status??(e.off?"off":"content")),1),e.use?(d(),u(w,{key:0},[S(" · "+t(e.use),1)],64)):_("",!0)]),e.error?(d(),u("p",ie,t(e.error),1)):_("",!0),(d(!0),u(w,null,V(e.refused,n=>(d(),u("p",{key:n.kind,class:"ui-banner","data-tone":"danger"},t(n.kind)+": "+t(n.error),1))),128)),a("div",ue,[p(a("select",{"onUpdate:modelValue":n=>g.value[e.name]=n,class:"ui-field","data-size":"md","aria-label":l(s)("Implementation","实现"),disabled:r.value||e.locked},[(d(!0),u(w,null,V(e.candidates,n=>(d(),u("option",{key:n.id,value:n.id},t(n.id)+" ("+t(n.kinds.join(", "))+")",9,re))),128))],8,de),[[E,g.value[e.name]]]),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value||e.locked||!g.value[e.name]||!l(c).supports("plugin.enable"),onClick:n=>f("plugin.enable",{name:e.name,use:g.value[e.name]})},t(l(s)("Enable / use","启用 / 使用")),9,ce),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value||e.locked||e.off||!l(c).supports("plugin.disable"),onClick:n=>f("plugin.disable",{name:e.name})},t(l(s)("Disable","禁用")),9,ve),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value||e.off||!l(c).supports("plugin.reload"),onClick:n=>f("plugin.reload",{name:e.name})},t(l(s)("Reload","重新加载")),9,pe)]),(d(!0),u(w,null,V(e.candidates.filter(n=>n.id!=="builtin"&&n.id!=="default"),n=>(d(),u("div",{key:n.id,class:"candidate-row"},[a("code",null,t(n.id),1),n.git?(d(),u("button",{key:0,class:"ui-button","data-size":"sm","data-variant":"secondary",disabled:r.value||!l(c).supports("plugin.update"),onClick:M=>f("plugin.update",{id:n.id})},t(l(s)("Update","更新")),9,me)):_("",!0),a("button",{class:"ui-button","data-size":"sm","data-variant":"danger-ghost",disabled:r.value||e.locked||!l(c).supports("plugin.remove"),onClick:M=>f("plugin.remove",{id:n.id})},t(l(s)("Remove","移除")),9,be)]))),128))]))),128)),C.value&&!D.value.length?(d(),u("p",fe,t(l(s)("No matching plugins.","没有匹配的插件。")),1)):_("",!0),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value,onClick:z},t(l(s)("Refresh","刷新")),9,_e)]))}}),xe=J(ge,[["__scopeId","data-v-488afb95"]]);export{xe as default};
1
+ import{d as N,x as B,c as u,e as a,t,u as l,j as T,l as p,D as E,C as x,a as _,L as j,b as S,B as F,F as w,E as V,r as v,z as P,o as d}from"./vendor-vue-CncuOShJ.js";import{u as O}from"./settings-general-dc8P6dA0.js";import{u as q,l as A,i as H,k as J}from"./index-DVjYS93F.js";import{_ as K}from"./GeneralSettingsStatus.vue_vue_type_script_setup_true_lang-CWInOGTv.js";import{b as Q,r as W,m as $}from"./context-Grqd_9Lt.js";const X={class:"settings-page"},Y={"data-route-heading":"",tabindex:"-1"},Z=["disabled"],ee={value:"path"},ae=["placeholder"],te={key:0},le={class:"checkbox-label"},se={class:"ui-button","data-size":"md","data-variant":"primary"},ne={class:"search-label"},oe={key:0},ie={key:0,class:"ui-banner","data-tone":"danger"},ue={class:"settings-actions"},de=["onUpdate:modelValue","aria-label","disabled"],re=["value"],ce=["disabled","onClick"],ve=["disabled","onClick"],pe=["disabled","onClick"],me=["disabled","onClick"],be=["disabled","onClick"],fe={key:0,role:"status"},_e=["disabled"],ge=N({__name:"PluginSettings",setup(he){const s=O(),c=q(),C=v(),g=v({}),h=v("path"),k=v(""),m=v(""),b=v(""),I=v(!1),L=v(""),r=v(!1),y=v(""),U=P(()=>!!k.value||!!m.value||!!b.value);Q(U);const D=P(()=>{var i;return((i=C.value)==null?void 0:i.filter(o=>o.name.toLocaleLowerCase().includes(L.value.toLocaleLowerCase())))??[]});async function R(){C.value=await c.client.call("plugin.list",{},A),g.value=Object.fromEntries(C.value.map(i=>{var o;return[i.name,i.use??((o=i.candidates[0])==null?void 0:o.id)??""]}))}async function z(){r.value=!0,y.value="";try{if(!c.supports("plugin.list"))throw new Error(s("Plugin management is not available on this server.","此服务器不支持插件管理。"));await R()}catch(i){y.value=$(i)}finally{r.value=!1}}async function f(i,o){if(!r.value&&!(["plugin.install","plugin.enable","plugin.update","plugin.reload"].includes(i)&&!window.confirm(s("Plugins execute trusted code and configured commands with your user privileges. Continue?","插件会以您的用户权限执行受信任代码和配置命令。是否继续?")))&&!(i==="plugin.remove"&&!window.confirm(s("Remove this installed plugin? Its content will be withdrawn.","移除此已安装插件?其提供的内容也将撤回。")))){r.value=!0,y.value="";try{await c.client.call(i,o,H,18e4),i==="plugin.install"&&(k.value="",m.value="",b.value=""),await R()}catch(e){y.value=$(e)}finally{r.value=!1}}}function G(){const i=k.value.trim();i&&f("plugin.install",{source:h.value==="path"?{path:i}:{git:i,...m.value.trim()?{ref:m.value.trim()}:{}},...b.value.trim()?{id:b.value.trim()}:{},enable:I.value})}return W(c,z,U),B(z),(i,o)=>(d(),u("article",X,[a("header",null,[a("h2",Y,t(l(s)("Plugins","插件")),1),a("p",null,t(l(s)("Install local or Git packages, select implementations and manage their lifecycle. Locked system plugins cannot be disabled or replaced.","安装本地或 Git 包、选择实现并管理生命周期。锁定的系统插件不可禁用或替换。")),1)]),T(K,{busy:r.value,error:y.value,onReload:z},null,8,["busy","error"]),a("form",{class:"settings-card settings-form",onSubmit:F(G,["prevent"])},[a("h3",null,t(l(s)("Install plugin","安装插件")),1),a("fieldset",{disabled:r.value||!l(c).supports("plugin.install")},[a("label",null,[a("span",null,t(l(s)("Source type","来源类型")),1),p(a("select",{"onUpdate:modelValue":o[0]||(o[0]=e=>h.value=e),class:"ui-field","data-size":"md"},[a("option",ee,t(l(s)("Local directory","本地目录")),1),o[6]||(o[6]=a("option",{value:"git"},"Git",-1))],512),[[E,h.value]])]),a("label",null,[a("span",null,t(l(s)("Source","来源")),1),p(a("input",{"onUpdate:modelValue":o[1]||(o[1]=e=>k.value=e),class:"ui-field","data-size":"md",placeholder:h.value==="path"?"/path/to/plugin":"https://github.com/owner/plugin.git",required:""},null,8,ae),[[x,k.value]])]),h.value==="git"?(d(),u("label",te,[a("span",null,t(l(s)("Git ref (optional)","Git 引用(可选)")),1),p(a("input",{"onUpdate:modelValue":o[2]||(o[2]=e=>m.value=e),class:"ui-field","data-size":"md"},null,512),[[x,m.value]])])):_("",!0),a("label",null,[a("span",null,t(l(s)("Installation ID (optional)","安装 ID(可选)")),1),p(a("input",{"onUpdate:modelValue":o[3]||(o[3]=e=>b.value=e),class:"ui-field","data-size":"md"},null,512),[[x,b.value]])]),a("label",le,[p(a("input",{"onUpdate:modelValue":o[4]||(o[4]=e=>I.value=e),type:"checkbox"},null,512),[[j,I.value]]),S(t(l(s)("Enable after installation (executes plugin code)","安装后启用(执行插件代码)")),1)]),a("button",se,t(l(s)("Install","安装")),1)],8,Z)],32),a("label",ne,[a("span",null,t(l(s)("Search plugins","搜索插件")),1),p(a("input",{"onUpdate:modelValue":o[5]||(o[5]=e=>L.value=e),class:"ui-field","data-size":"md",type:"search"},null,512),[[x,L.value]])]),(d(!0),u(w,null,V(D.value,e=>(d(),u("section",{key:e.name,class:"settings-card"},[a("h3",null,[S(t(e.name)+" ",1),e.locked?(d(),u("small",oe,t(l(s)("Locked","已锁定")),1)):_("",!0)]),a("p",null,[S(t(e.status??(e.off?"off":"content")),1),e.use?(d(),u(w,{key:0},[S(" · "+t(e.use),1)],64)):_("",!0)]),e.error?(d(),u("p",ie,t(e.error),1)):_("",!0),(d(!0),u(w,null,V(e.refused,n=>(d(),u("p",{key:n.kind,class:"ui-banner","data-tone":"danger"},t(n.kind)+": "+t(n.error),1))),128)),a("div",ue,[p(a("select",{"onUpdate:modelValue":n=>g.value[e.name]=n,class:"ui-field","data-size":"md","aria-label":l(s)("Implementation","实现"),disabled:r.value||e.locked},[(d(!0),u(w,null,V(e.candidates,n=>(d(),u("option",{key:n.id,value:n.id},t(n.id)+" ("+t(n.kinds.join(", "))+")",9,re))),128))],8,de),[[E,g.value[e.name]]]),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value||e.locked||!g.value[e.name]||!l(c).supports("plugin.enable"),onClick:n=>f("plugin.enable",{name:e.name,use:g.value[e.name]})},t(l(s)("Enable / use","启用 / 使用")),9,ce),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value||e.locked||e.off||!l(c).supports("plugin.disable"),onClick:n=>f("plugin.disable",{name:e.name})},t(l(s)("Disable","禁用")),9,ve),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value||e.off||!l(c).supports("plugin.reload"),onClick:n=>f("plugin.reload",{name:e.name})},t(l(s)("Reload","重新加载")),9,pe)]),(d(!0),u(w,null,V(e.candidates.filter(n=>n.id!=="builtin"&&n.id!=="default"),n=>(d(),u("div",{key:n.id,class:"candidate-row"},[a("code",null,t(n.id),1),n.git?(d(),u("button",{key:0,class:"ui-button","data-size":"sm","data-variant":"secondary",disabled:r.value||!l(c).supports("plugin.update"),onClick:M=>f("plugin.update",{id:n.id})},t(l(s)("Update","更新")),9,me)):_("",!0),a("button",{class:"ui-button","data-size":"sm","data-variant":"danger-ghost",disabled:r.value||e.locked||!l(c).supports("plugin.remove"),onClick:M=>f("plugin.remove",{id:n.id})},t(l(s)("Remove","移除")),9,be)]))),128))]))),128)),C.value&&!D.value.length?(d(),u("p",fe,t(l(s)("No matching plugins.","没有匹配的插件。")),1)):_("",!0),a("button",{class:"ui-button","data-size":"md","data-variant":"secondary",disabled:r.value,onClick:z},t(l(s)("Refresh","刷新")),9,_e)]))}}),xe=J(ge,[["__scopeId","data-v-488afb95"]]);export{xe as default};
@@ -1 +1 @@
1
- import{d as ee,A as ne,i as le,g as ie,o as v,c as h,j as U,H as de,k as A,y as H,J as I,u,e as t,t as x,a as y,n as oe,h as se,z as f,r as E,B as ce,ah as ue,F as W,T as me,l as Y,v as Z,m as pe}from"./vendor-vue-CncuOShJ.js";import{h as ve,$ as X,a0 as fe,w as he,j as J,M as ge,G as be,A as te,H as Q,k as we,o as ke,Z as P,Y as ye,a1 as xe,a2 as Be,a3 as Ce}from"./index-B4STIxMF.js";var Se=Object.defineProperty,Fe=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,q=(a,d,e)=>d in a?Se(a,d,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[d]=e,O=(a,d)=>{for(var e in d||(d={}))ae.call(d,e)&&q(a,e,d[e]);if(D)for(var e of D(d))re.call(d,e)&&q(a,e,d[e]);return a},_=(a,d)=>Fe(a,ze(d)),K=(a,d,e)=>new Promise((g,b)=>{var M=m=>{try{w(e.next(m))}catch(C){b(C)}},T=m=>{try{w(e.throw(m))}catch(C){b(C)}},w=m=>m.done?g(m.value):Promise.resolve(m.value).then(M,T);w((e=e.apply(a,d)).next())});function Me(a,d){if(d===void 0)return xe(a);if(d){const g=d(a);if(g!=null&&g!=="")return g}const e=te(a);return Be(e)||Ce()}const Te={key:0,class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},je={class:"flex items-center gap-0.5"},Pe=["aria-label"],He={class:"code-diff-stat removed"},$e={class:"code-diff-stat added"},Ne=["aria-label"],Oe={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Ee={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Le=["aria-pressed"],Re={key:3,class:"relative"},_e=["aria-expanded"],Ae=["disabled"],De=["disabled"],Ve=["disabled"],Ge={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Ue={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Ie={class:"code-loading-placeholder"},We={class:"sr-only","aria-live":"polite",role:"status"},Ye=ee({__name:"CodeBlockShell",props:{showHeader:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},stream:{type:Boolean,default:!1},isCollapsed:{type:Boolean,default:!1},isExpanded:{type:Boolean,default:!1},copyText:{type:Boolean,default:!1},isPreviewable:{type:Boolean,default:!1},codeFontSize:{},codeFontMin:{},codeFontMax:{},defaultCodeFontSize:{},fontBaselineReady:{type:Boolean,default:!1},diffStats:{},diffStatsAriaLabel:{}},emits:["toggleCollapse","decreaseFont","resetFont","increaseFont","copy","toggleExpand","preview"],setup(a,{emit:d}){const e=a,g=d,b=E(!1),M=E(null),T=E(null);function w(){P(!0),b.value=!b.value,b.value&&document.addEventListener("click",C,{once:!0,capture:!0})}function m(){P(!0),b.value=!1}function C(p){var o,i;const R=p.target;(o=M.value)!=null&&o.contains(R)||(i=T.value)!=null&&i.contains(R)?document.addEventListener("click",C,{once:!0,capture:!0}):m()}const $=f(()=>e.showFontSizeButtons&&e.enableFontSizeControl||e.showExpandButton||e.isPreviewable&&e.showPreviewButton),{t:s}=ke(),N=f(()=>e.showTooltips!==!1);function S(p,o){N.value&&ye(p.currentTarget,o,"top",!1,void 0,e.isDark)}function F(){N.value&&P()}function j(p){S(p,e.copyText?s("common.copied")||"Copied":s("common.copy")||"Copy")}const V=f(()=>{var p,o;return!!Number.isFinite(e.codeFontSize)&&((p=e.codeFontSize)!=null?p:0)<=((o=e.codeFontMin)!=null?o:0)}),L=f(()=>!e.fontBaselineReady||e.codeFontSize===e.defaultCodeFontSize),r=f(()=>{var p,o;return!!Number.isFinite(e.codeFontSize)&&((p=e.codeFontSize)!=null?p:0)>=((o=e.codeFontMax)!=null?o:100)});return(p,o)=>(v(),h(W,null,[e.showHeader?(v(),h("div",Te,[H(p.$slots,"header-left"),H(p.$slots,"header-right",{},()=>[t("div",je,[a.diffStats?(v(),h("div",{key:0,class:"code-diff-stats","aria-label":a.diffStatsAriaLabel},[t("span",He,"-"+x(a.diffStats.removed),1),t("span",$e,"+"+x(a.diffStats.added),1)],8,Pe)):y("",!0),e.showCopyButton?(v(),h("button",{key:1,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-label":a.copyText?u(s)("common.copied")||"Copied":u(s)("common.copy")||"Copy",onClick:o[0]||(o[0]=i=>g("copy")),onMouseenter:o[1]||(o[1]=i=>j(i)),onFocus:o[2]||(o[2]=i=>j(i)),onMouseleave:F,onBlur:F},[a.copyText?(v(),h("svg",Ee,[...o[14]||(o[14]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(v(),h("svg",Oe,[...o[13]||(o[13]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,Ne)):y("",!0),e.showCollapseButton?(v(),h("button",{key:2,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-pressed":a.isCollapsed,onClick:o[3]||(o[3]=i=>g("toggleCollapse")),onMouseenter:o[4]||(o[4]=i=>S(i,a.isCollapsed?u(s)("common.expand")||"Expand":u(s)("common.collapse")||"Collapse")),onFocus:o[5]||(o[5]=i=>S(i,a.isCollapsed?u(s)("common.expand")||"Expand":u(s)("common.collapse")||"Collapse")),onMouseleave:F,onBlur:F},[(v(),h("svg",{style:oe({rotate:a.isCollapsed?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...o[15]||(o[15]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,Le)):y("",!0),$.value?(v(),h("div",Re,[t("button",{ref_key:"moreBtnRef",ref:T,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] transition-colors","aria-expanded":b.value,"aria-haspopup":"true",onClick:ce(w,["stop"]),onMouseenter:o[6]||(o[6]=i=>S(i,u(s)("common.more")||"More")),onFocus:o[7]||(o[7]=i=>S(i,u(s)("common.more")||"More")),onMouseleave:F,onBlur:F},[...o[16]||(o[16]=[ue('<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="1em" height="1em" viewBox="0 0 24 24" class="action-icon"><g fill="currentColor"><circle cx="12" cy="5" r="1.5"></circle><circle cx="12" cy="12" r="1.5"></circle><circle cx="12" cy="19" r="1.5"></circle></g></svg>',1)])],40,_e),U(me,{name:"code-menu"},{default:A(()=>[b.value?(v(),h("div",{key:0,ref_key:"moreMenuRef",ref:M,class:"code-more-menu min-w-[10rem] p-1 bg-[hsl(var(--ms-popover))] text-[hsl(var(--ms-popover-foreground))] border border-[var(--code-border)] shadow-[var(--ms-shadow-popover)]",role:"menu"},[e.showFontSizeButtons&&e.enableFontSizeControl?(v(),h(W,{key:0},[t("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:V.value,onClick:o[8]||(o[8]=i=>{u(P)(!0),g("decreaseFont")})},[o[17]||(o[17]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)),t("span",null,x(u(s)("common.fontSmaller")||"Font size −"),1)],8,Ae),t("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:L.value,onClick:o[9]||(o[9]=i=>{u(P)(!0),g("resetFont")})},[o[18]||(o[18]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),t("path",{d:"M3 3v5h5"})])],-1)),t("span",null,x(u(s)("common.fontReset")||"Font size reset"),1)],8,De),t("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:r.value,onClick:o[10]||(o[10]=i=>{u(P)(!0),g("increaseFont")})},[o[19]||(o[19]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)),t("span",null,x(u(s)("common.fontLarger")||"Font size +"),1)],8,Ve)],64)):y("",!0),e.showExpandButton?(v(),h("button",{key:1,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:o[11]||(o[11]=i=>{m(),g("toggleExpand")})},[a.isExpanded?(v(),h("svg",Ge,[...o[20]||(o[20]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(v(),h("svg",Ue,[...o[21]||(o[21]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])])),t("span",null,x(a.isExpanded?u(s)("common.collapse")||"Collapse":u(s)("common.expand")||"Expand"),1)])):y("",!0),a.isPreviewable&&e.showPreviewButton?(v(),h("button",{key:2,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:o[12]||(o[12]=i=>{m(),g("preview")})},[o[22]||(o[22]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),t("circle",{cx:"12",cy:"12",r:"3"})])],-1)),t("span",null,x(u(s)("common.preview")||"Preview"),1)])):y("",!0)],512)):y("",!0)]),_:1})])):y("",!0)])])])):y("",!0),Y(t("div",{class:pe(["code-block-shell-content",{"code-block-shell-content--collapsed":a.isCollapsed}])},[H(p.$slots,"default")],2),[[Z,!!a.stream||!a.loading]]),Y(t("div",Ie,[H(p.$slots,"loading",{},()=>[o[23]||(o[23]=t("div",{class:"loading-skeleton"},[t("div",{class:"skeleton-line"}),t("div",{class:"skeleton-line"}),t("div",{class:"skeleton-line short"})],-1))])],512),[[Z,!a.stream&&a.loading]]),t("span",We,x(a.copyText?u(s)("common.copied")||"Copied":""),1)],64))}}),Ze={class:"code-header-main"},Xe=["innerHTML"],Je={class:"code-header-copy"},Qe={class:"code-header-title"},qe={key:0,class:"code-header-caption"},Ke=ee(_(O({},{inheritAttrs:!1}),{__name:"PreCodeBlock",props:{codeBlockOptions:{},clipboardWriter:{},darkTheme:{},isDark:{type:Boolean,default:!1},lightTheme:{},resolvedVisualOptions:{},showCopyButton:{type:Boolean,default:!0},showHeader:{type:Boolean,default:!0},showToolbar:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},theme:{},themes:{},node:{},loading:{type:Boolean},showLineNumbers:{type:Boolean,default:!0},diffInline:{type:Boolean},diffHideUnchangedRegions:{type:[Boolean,Object]},reservedHeightPx:{}},emits:["copy"],setup(a,{emit:d}){const e=a,g=d,b=ne(),M=f(()=>{const n=b,{class:l,style:z}=n;return((c,k)=>{var G={};for(var B in c)ae.call(c,B)&&k.indexOf(B)<0&&(G[B]=c[B]);if(c!=null&&D)for(var B of D(c))k.indexOf(B)<0&&re.call(c,B)&&(G[B]=c[B]);return G})(n,["class","style"])}),T=E(null),w=E(!1);let m;const C=le(ve,void 0),$=f(()=>{var n,l;return(l=e.showLineNumbers)!=null?l:((n=e.codeBlockOptions)==null?void 0:n.disableLineNumbers)!==!0}),s=f(()=>J(e.node)),N=f(()=>{var n;return e.diffInline===!0||s.value&&fe((n=e.codeBlockOptions)!=null?n:{})}),S=f(()=>{var n,l;return te(String((l=(n=e.node)==null?void 0:n.language)!=null?l:""))}),F=f(()=>{const n=S.value;return n?Q[n]||n.charAt(0).toUpperCase()+n.slice(1):Q[""]}),j=f(()=>{var n,l;return he(String((l=(n=e.node)==null?void 0:n.raw)!=null?l:""),F.value,J(e.node))}),V=f(()=>(ge.value,Me(S.value,C))),L=f(()=>{var n;return(n=e.resolvedVisualOptions)!=null?n:we(e.codeBlockOptions)}),r=f(()=>be({darkTheme:e.darkTheme,isDark:e.isDark,lightTheme:e.lightTheme,theme:e.theme,themes:e.themes})),p=f(()=>_(O({"--markstream-code-fallback-bg":r.value.background,"--markstream-code-fallback-fg":r.value.foreground},r.value.builtin?{"--markstream-code-theme-bg":r.value.background,"--markstream-code-theme-fg":r.value.foreground,"--markstream-code-theme-line-number":r.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":r.value.diffAddedLine,"--markstream-diff-added-number-fill":r.value.diffAddedNumber,"--markstream-diff-editor-bg":r.value.background,"--markstream-diff-removed-line-fill":r.value.diffRemovedLine,"--markstream-diff-removed-number-fill":r.value.diffRemovedNumber,"--markstream-diff-shell-bg":r.value.background,"--markstream-pre-resolved-theme-bg":r.value.background,"--markstream-pre-resolved-theme-fg":r.value.foreground,"--markstream-pre-resolved-theme-line-number":r.value.lineNumber,backgroundColor:r.value.background,color:r.value.foreground})),o=f(()=>["code-pre-fallback",b.class,{"is-wrap":L.value.overflow==="wrap"}]),i=f(()=>{var n;const l=L.value,z=((n=e.codeBlockOptions)==null?void 0:n.padding)==null?"1ch":`${l.padding}px`,c=s.value&&typeof e.reservedHeightPx=="number"&&Number.isFinite(e.reservedHeightPx)&&e.reservedHeightPx>0?`${Math.ceil(e.reservedHeightPx)}px`:void 0;return O(_(O(_(O({"--markstream-code-font-family":l.fontFamily,"--markstream-code-padding-x":z,"--markstream-code-padding-y":`${l.padding}px`,"--markstream-code-padding-bottom":`${l.paddingBottom}px`,"--markstream-code-scrollbar-gutter":`${l.scrollbarGutter}px`,"--markstream-code-tab-size":String(l.tabSize)},s.value?{"--markstream-pre-diff-line-height":`${l.lineHeight}px`}:{}),{"--markstream-pre-line-number-top":`${l.padding}px`,"--markstream-pre-line-number-left":"0px","--markstream-pre-line-number-padding-left":"2ch","--markstream-pre-line-number-padding-right":"1ch","--markstream-pre-line-number-separator-width":"2px"}),r.value.builtin?{"--markstream-code-theme-bg":r.value.background,"--markstream-code-theme-fg":r.value.foreground,"--markstream-code-theme-line-number":r.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":r.value.diffAddedLine,"--markstream-diff-added-number-fill":r.value.diffAddedNumber,"--markstream-diff-metadata-bg":r.value.background,"--markstream-diff-metadata-fg":r.value.lineNumber,"--markstream-diff-removed-line-fill":r.value.diffRemovedLine,"--markstream-diff-removed-number-fill":r.value.diffRemovedNumber,"--markstream-pre-resolved-theme-bg":r.value.background,"--markstream-pre-resolved-theme-fg":r.value.foreground,"--markstream-pre-resolved-theme-line-number":r.value.lineNumber,"--markstream-pre-line-number-gap-to-code":z,"--markstream-diff-fallback-handoff-height":c??"auto",backgroundColor:"var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",boxSizing:"border-box",color:"var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",fontFamily:l.fontFamily,fontSize:`${l.fontSize}px`,lineHeight:`${l.lineHeight}px`,margin:"0",maxHeight:`${l.maxHeight}px`,overflow:"auto",overflowX:l.overflow==="wrap"?"hidden":"auto",overflowY:"auto",paddingBottom:`${l.paddingBottom}px`,paddingLeft:$.value?"var(--markstream-code-padding-left)":z,paddingRight:z,paddingTop:`${l.padding}px`,scrollbarGutter:s.value?"auto":"stable",tabSize:l.tabSize,whiteSpace:l.overflow==="scroll"?"pre":"pre-wrap",overflowWrap:l.overflow==="wrap"?"anywhere":"normal",wordBreak:"normal",width:"100%"}),c?{height:c,minHeight:c,maxHeight:c}:{})});function R(){return K(this,null,function*(){const n=String((z=(l=e.node)==null?void 0:l.code)!=null?z:"");var l,z;try{yield(function(c){return K(this,null,function*(){if(e.clipboardWriter)return void(yield e.clipboardWriter(c));if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return void(yield navigator.clipboard.writeText(c));if(typeof document>"u"||!document.body)throw new Error("Clipboard API is unavailable");const k=document.createElement("textarea");k.value=c,k.setAttribute("readonly",""),k.style.position="fixed",k.style.opacity="0",document.body.appendChild(k),k.select();try{if(!document.execCommand("copy"))throw new Error("Clipboard copy command failed")}finally{k.remove()}})})(n),w.value=!0,g("copy",n),m&&clearTimeout(m),m=setTimeout(()=>{w.value=!1,m=void 0},1e3)}catch(c){w.value=!1,console.error("[markstream-vue] Failed to copy preformatted code.",c)}})}return ie(()=>{m&&clearTimeout(m)}),(n,l)=>e.showToolbar?(v(),h("div",{key:0,style:oe(p.value),class:"code-block-container rounded-lg border"},[U(Ye,{"show-header":e.showHeader,"show-copy-button":e.showCopyButton,"show-collapse-button":!1,"show-font-size-buttons":!1,"show-expand-button":!1,"show-preview-button":!1,"show-tooltips":e.showTooltips,"copy-text":w.value,stream:"",onCopy:R},de({"header-left":A(()=>[H(n.$slots,"header-left",{},()=>[t("div",Ze,[t("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:V.value},null,8,Xe),t("div",Je,[t("div",Qe,x(j.value.title),1),j.value.caption?(v(),h("div",qe,x(j.value.caption),1)):y("",!0)])])])]),default:A(()=>[U(X,I({ref_key:"preNodeRef",ref:T},M.value,{class:o.value,style:[u(b).style,i.value],node:e.node,loading:e.loading,"show-line-numbers":$.value,"diff-inline":N.value,"diff-hide-unchanged-regions":e.diffHideUnchangedRegions,"reserved-height-px":e.reservedHeightPx,"data-markstream-code-theme":r.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"])]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:A(()=>[H(n.$slots,"header-right")]),key:"0"}:void 0]),1032,["show-header","show-copy-button","show-tooltips","copy-text"])],4)):(v(),se(X,I({key:1,ref_key:"preNodeRef",ref:T},M.value,{class:o.value,style:[u(b).style,i.value],node:e.node,loading:e.loading,"show-line-numbers":$.value,"diff-inline":N.value,"diff-hide-unchanged-regions":e.diffHideUnchangedRegions,"reserved-height-px":e.reservedHeightPx,"data-markstream-code-theme":r.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"]))}})),to=Object.freeze(Object.defineProperty({__proto__:null,default:Ke},Symbol.toStringTag,{value:"Module"}));export{Ke as B,to as P,Me as Q,Ye as g};
1
+ import{d as ee,A as ne,i as le,g as ie,o as v,c as h,j as U,H as de,k as A,y as H,J as I,u,e as t,t as x,a as y,n as oe,h as se,z as f,r as E,B as ce,ah as ue,F as W,T as me,l as Y,v as Z,m as pe}from"./vendor-vue-CncuOShJ.js";import{h as ve,$ as X,a0 as fe,w as he,j as J,M as ge,G as be,A as te,H as Q,k as we,o as ke,Z as P,Y as ye,a1 as xe,a2 as Be,a3 as Ce}from"./index-DwhvmzI8.js";var Se=Object.defineProperty,Fe=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,q=(a,d,e)=>d in a?Se(a,d,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[d]=e,O=(a,d)=>{for(var e in d||(d={}))ae.call(d,e)&&q(a,e,d[e]);if(D)for(var e of D(d))re.call(d,e)&&q(a,e,d[e]);return a},_=(a,d)=>Fe(a,ze(d)),K=(a,d,e)=>new Promise((g,b)=>{var M=m=>{try{w(e.next(m))}catch(C){b(C)}},T=m=>{try{w(e.throw(m))}catch(C){b(C)}},w=m=>m.done?g(m.value):Promise.resolve(m.value).then(M,T);w((e=e.apply(a,d)).next())});function Me(a,d){if(d===void 0)return xe(a);if(d){const g=d(a);if(g!=null&&g!=="")return g}const e=te(a);return Be(e)||Ce()}const Te={key:0,class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},je={class:"flex items-center gap-0.5"},Pe=["aria-label"],He={class:"code-diff-stat removed"},$e={class:"code-diff-stat added"},Ne=["aria-label"],Oe={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Ee={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Le=["aria-pressed"],Re={key:3,class:"relative"},_e=["aria-expanded"],Ae=["disabled"],De=["disabled"],Ve=["disabled"],Ge={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Ue={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},Ie={class:"code-loading-placeholder"},We={class:"sr-only","aria-live":"polite",role:"status"},Ye=ee({__name:"CodeBlockShell",props:{showHeader:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},stream:{type:Boolean,default:!1},isCollapsed:{type:Boolean,default:!1},isExpanded:{type:Boolean,default:!1},copyText:{type:Boolean,default:!1},isPreviewable:{type:Boolean,default:!1},codeFontSize:{},codeFontMin:{},codeFontMax:{},defaultCodeFontSize:{},fontBaselineReady:{type:Boolean,default:!1},diffStats:{},diffStatsAriaLabel:{}},emits:["toggleCollapse","decreaseFont","resetFont","increaseFont","copy","toggleExpand","preview"],setup(a,{emit:d}){const e=a,g=d,b=E(!1),M=E(null),T=E(null);function w(){P(!0),b.value=!b.value,b.value&&document.addEventListener("click",C,{once:!0,capture:!0})}function m(){P(!0),b.value=!1}function C(p){var o,i;const R=p.target;(o=M.value)!=null&&o.contains(R)||(i=T.value)!=null&&i.contains(R)?document.addEventListener("click",C,{once:!0,capture:!0}):m()}const $=f(()=>e.showFontSizeButtons&&e.enableFontSizeControl||e.showExpandButton||e.isPreviewable&&e.showPreviewButton),{t:s}=ke(),N=f(()=>e.showTooltips!==!1);function S(p,o){N.value&&ye(p.currentTarget,o,"top",!1,void 0,e.isDark)}function F(){N.value&&P()}function j(p){S(p,e.copyText?s("common.copied")||"Copied":s("common.copy")||"Copy")}const V=f(()=>{var p,o;return!!Number.isFinite(e.codeFontSize)&&((p=e.codeFontSize)!=null?p:0)<=((o=e.codeFontMin)!=null?o:0)}),L=f(()=>!e.fontBaselineReady||e.codeFontSize===e.defaultCodeFontSize),r=f(()=>{var p,o;return!!Number.isFinite(e.codeFontSize)&&((p=e.codeFontSize)!=null?p:0)>=((o=e.codeFontMax)!=null?o:100)});return(p,o)=>(v(),h(W,null,[e.showHeader?(v(),h("div",Te,[H(p.$slots,"header-left"),H(p.$slots,"header-right",{},()=>[t("div",je,[a.diffStats?(v(),h("div",{key:0,class:"code-diff-stats","aria-label":a.diffStatsAriaLabel},[t("span",He,"-"+x(a.diffStats.removed),1),t("span",$e,"+"+x(a.diffStats.added),1)],8,Pe)):y("",!0),e.showCopyButton?(v(),h("button",{key:1,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-label":a.copyText?u(s)("common.copied")||"Copied":u(s)("common.copy")||"Copy",onClick:o[0]||(o[0]=i=>g("copy")),onMouseenter:o[1]||(o[1]=i=>j(i)),onFocus:o[2]||(o[2]=i=>j(i)),onMouseleave:F,onBlur:F},[a.copyText?(v(),h("svg",Ee,[...o[14]||(o[14]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(v(),h("svg",Oe,[...o[13]||(o[13]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,Ne)):y("",!0),e.showCollapseButton?(v(),h("button",{key:2,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-pressed":a.isCollapsed,onClick:o[3]||(o[3]=i=>g("toggleCollapse")),onMouseenter:o[4]||(o[4]=i=>S(i,a.isCollapsed?u(s)("common.expand")||"Expand":u(s)("common.collapse")||"Collapse")),onFocus:o[5]||(o[5]=i=>S(i,a.isCollapsed?u(s)("common.expand")||"Expand":u(s)("common.collapse")||"Collapse")),onMouseleave:F,onBlur:F},[(v(),h("svg",{style:oe({rotate:a.isCollapsed?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...o[15]||(o[15]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,Le)):y("",!0),$.value?(v(),h("div",Re,[t("button",{ref_key:"moreBtnRef",ref:T,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] transition-colors","aria-expanded":b.value,"aria-haspopup":"true",onClick:ce(w,["stop"]),onMouseenter:o[6]||(o[6]=i=>S(i,u(s)("common.more")||"More")),onFocus:o[7]||(o[7]=i=>S(i,u(s)("common.more")||"More")),onMouseleave:F,onBlur:F},[...o[16]||(o[16]=[ue('<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="1em" height="1em" viewBox="0 0 24 24" class="action-icon"><g fill="currentColor"><circle cx="12" cy="5" r="1.5"></circle><circle cx="12" cy="12" r="1.5"></circle><circle cx="12" cy="19" r="1.5"></circle></g></svg>',1)])],40,_e),U(me,{name:"code-menu"},{default:A(()=>[b.value?(v(),h("div",{key:0,ref_key:"moreMenuRef",ref:M,class:"code-more-menu min-w-[10rem] p-1 bg-[hsl(var(--ms-popover))] text-[hsl(var(--ms-popover-foreground))] border border-[var(--code-border)] shadow-[var(--ms-shadow-popover)]",role:"menu"},[e.showFontSizeButtons&&e.enableFontSizeControl?(v(),h(W,{key:0},[t("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:V.value,onClick:o[8]||(o[8]=i=>{u(P)(!0),g("decreaseFont")})},[o[17]||(o[17]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)),t("span",null,x(u(s)("common.fontSmaller")||"Font size −"),1)],8,Ae),t("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:L.value,onClick:o[9]||(o[9]=i=>{u(P)(!0),g("resetFont")})},[o[18]||(o[18]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),t("path",{d:"M3 3v5h5"})])],-1)),t("span",null,x(u(s)("common.fontReset")||"Font size reset"),1)],8,De),t("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:r.value,onClick:o[10]||(o[10]=i=>{u(P)(!0),g("increaseFont")})},[o[19]||(o[19]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)),t("span",null,x(u(s)("common.fontLarger")||"Font size +"),1)],8,Ve)],64)):y("",!0),e.showExpandButton?(v(),h("button",{key:1,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:o[11]||(o[11]=i=>{m(),g("toggleExpand")})},[a.isExpanded?(v(),h("svg",Ge,[...o[20]||(o[20]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(v(),h("svg",Ue,[...o[21]||(o[21]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])])),t("span",null,x(a.isExpanded?u(s)("common.collapse")||"Collapse":u(s)("common.expand")||"Expand"),1)])):y("",!0),a.isPreviewable&&e.showPreviewButton?(v(),h("button",{key:2,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:o[12]||(o[12]=i=>{m(),g("preview")})},[o[22]||(o[22]=t("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),t("circle",{cx:"12",cy:"12",r:"3"})])],-1)),t("span",null,x(u(s)("common.preview")||"Preview"),1)])):y("",!0)],512)):y("",!0)]),_:1})])):y("",!0)])])])):y("",!0),Y(t("div",{class:pe(["code-block-shell-content",{"code-block-shell-content--collapsed":a.isCollapsed}])},[H(p.$slots,"default")],2),[[Z,!!a.stream||!a.loading]]),Y(t("div",Ie,[H(p.$slots,"loading",{},()=>[o[23]||(o[23]=t("div",{class:"loading-skeleton"},[t("div",{class:"skeleton-line"}),t("div",{class:"skeleton-line"}),t("div",{class:"skeleton-line short"})],-1))])],512),[[Z,!a.stream&&a.loading]]),t("span",We,x(a.copyText?u(s)("common.copied")||"Copied":""),1)],64))}}),Ze={class:"code-header-main"},Xe=["innerHTML"],Je={class:"code-header-copy"},Qe={class:"code-header-title"},qe={key:0,class:"code-header-caption"},Ke=ee(_(O({},{inheritAttrs:!1}),{__name:"PreCodeBlock",props:{codeBlockOptions:{},clipboardWriter:{},darkTheme:{},isDark:{type:Boolean,default:!1},lightTheme:{},resolvedVisualOptions:{},showCopyButton:{type:Boolean,default:!0},showHeader:{type:Boolean,default:!0},showToolbar:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},theme:{},themes:{},node:{},loading:{type:Boolean},showLineNumbers:{type:Boolean,default:!0},diffInline:{type:Boolean},diffHideUnchangedRegions:{type:[Boolean,Object]},reservedHeightPx:{}},emits:["copy"],setup(a,{emit:d}){const e=a,g=d,b=ne(),M=f(()=>{const n=b,{class:l,style:z}=n;return((c,k)=>{var G={};for(var B in c)ae.call(c,B)&&k.indexOf(B)<0&&(G[B]=c[B]);if(c!=null&&D)for(var B of D(c))k.indexOf(B)<0&&re.call(c,B)&&(G[B]=c[B]);return G})(n,["class","style"])}),T=E(null),w=E(!1);let m;const C=le(ve,void 0),$=f(()=>{var n,l;return(l=e.showLineNumbers)!=null?l:((n=e.codeBlockOptions)==null?void 0:n.disableLineNumbers)!==!0}),s=f(()=>J(e.node)),N=f(()=>{var n;return e.diffInline===!0||s.value&&fe((n=e.codeBlockOptions)!=null?n:{})}),S=f(()=>{var n,l;return te(String((l=(n=e.node)==null?void 0:n.language)!=null?l:""))}),F=f(()=>{const n=S.value;return n?Q[n]||n.charAt(0).toUpperCase()+n.slice(1):Q[""]}),j=f(()=>{var n,l;return he(String((l=(n=e.node)==null?void 0:n.raw)!=null?l:""),F.value,J(e.node))}),V=f(()=>(ge.value,Me(S.value,C))),L=f(()=>{var n;return(n=e.resolvedVisualOptions)!=null?n:we(e.codeBlockOptions)}),r=f(()=>be({darkTheme:e.darkTheme,isDark:e.isDark,lightTheme:e.lightTheme,theme:e.theme,themes:e.themes})),p=f(()=>_(O({"--markstream-code-fallback-bg":r.value.background,"--markstream-code-fallback-fg":r.value.foreground},r.value.builtin?{"--markstream-code-theme-bg":r.value.background,"--markstream-code-theme-fg":r.value.foreground,"--markstream-code-theme-line-number":r.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":r.value.diffAddedLine,"--markstream-diff-added-number-fill":r.value.diffAddedNumber,"--markstream-diff-editor-bg":r.value.background,"--markstream-diff-removed-line-fill":r.value.diffRemovedLine,"--markstream-diff-removed-number-fill":r.value.diffRemovedNumber,"--markstream-diff-shell-bg":r.value.background,"--markstream-pre-resolved-theme-bg":r.value.background,"--markstream-pre-resolved-theme-fg":r.value.foreground,"--markstream-pre-resolved-theme-line-number":r.value.lineNumber,backgroundColor:r.value.background,color:r.value.foreground})),o=f(()=>["code-pre-fallback",b.class,{"is-wrap":L.value.overflow==="wrap"}]),i=f(()=>{var n;const l=L.value,z=((n=e.codeBlockOptions)==null?void 0:n.padding)==null?"1ch":`${l.padding}px`,c=s.value&&typeof e.reservedHeightPx=="number"&&Number.isFinite(e.reservedHeightPx)&&e.reservedHeightPx>0?`${Math.ceil(e.reservedHeightPx)}px`:void 0;return O(_(O(_(O({"--markstream-code-font-family":l.fontFamily,"--markstream-code-padding-x":z,"--markstream-code-padding-y":`${l.padding}px`,"--markstream-code-padding-bottom":`${l.paddingBottom}px`,"--markstream-code-scrollbar-gutter":`${l.scrollbarGutter}px`,"--markstream-code-tab-size":String(l.tabSize)},s.value?{"--markstream-pre-diff-line-height":`${l.lineHeight}px`}:{}),{"--markstream-pre-line-number-top":`${l.padding}px`,"--markstream-pre-line-number-left":"0px","--markstream-pre-line-number-padding-left":"2ch","--markstream-pre-line-number-padding-right":"1ch","--markstream-pre-line-number-separator-width":"2px"}),r.value.builtin?{"--markstream-code-theme-bg":r.value.background,"--markstream-code-theme-fg":r.value.foreground,"--markstream-code-theme-line-number":r.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":r.value.diffAddedLine,"--markstream-diff-added-number-fill":r.value.diffAddedNumber,"--markstream-diff-metadata-bg":r.value.background,"--markstream-diff-metadata-fg":r.value.lineNumber,"--markstream-diff-removed-line-fill":r.value.diffRemovedLine,"--markstream-diff-removed-number-fill":r.value.diffRemovedNumber,"--markstream-pre-resolved-theme-bg":r.value.background,"--markstream-pre-resolved-theme-fg":r.value.foreground,"--markstream-pre-resolved-theme-line-number":r.value.lineNumber,"--markstream-pre-line-number-gap-to-code":z,"--markstream-diff-fallback-handoff-height":c??"auto",backgroundColor:"var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",boxSizing:"border-box",color:"var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",fontFamily:l.fontFamily,fontSize:`${l.fontSize}px`,lineHeight:`${l.lineHeight}px`,margin:"0",maxHeight:`${l.maxHeight}px`,overflow:"auto",overflowX:l.overflow==="wrap"?"hidden":"auto",overflowY:"auto",paddingBottom:`${l.paddingBottom}px`,paddingLeft:$.value?"var(--markstream-code-padding-left)":z,paddingRight:z,paddingTop:`${l.padding}px`,scrollbarGutter:s.value?"auto":"stable",tabSize:l.tabSize,whiteSpace:l.overflow==="scroll"?"pre":"pre-wrap",overflowWrap:l.overflow==="wrap"?"anywhere":"normal",wordBreak:"normal",width:"100%"}),c?{height:c,minHeight:c,maxHeight:c}:{})});function R(){return K(this,null,function*(){const n=String((z=(l=e.node)==null?void 0:l.code)!=null?z:"");var l,z;try{yield(function(c){return K(this,null,function*(){if(e.clipboardWriter)return void(yield e.clipboardWriter(c));if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return void(yield navigator.clipboard.writeText(c));if(typeof document>"u"||!document.body)throw new Error("Clipboard API is unavailable");const k=document.createElement("textarea");k.value=c,k.setAttribute("readonly",""),k.style.position="fixed",k.style.opacity="0",document.body.appendChild(k),k.select();try{if(!document.execCommand("copy"))throw new Error("Clipboard copy command failed")}finally{k.remove()}})})(n),w.value=!0,g("copy",n),m&&clearTimeout(m),m=setTimeout(()=>{w.value=!1,m=void 0},1e3)}catch(c){w.value=!1,console.error("[markstream-vue] Failed to copy preformatted code.",c)}})}return ie(()=>{m&&clearTimeout(m)}),(n,l)=>e.showToolbar?(v(),h("div",{key:0,style:oe(p.value),class:"code-block-container rounded-lg border"},[U(Ye,{"show-header":e.showHeader,"show-copy-button":e.showCopyButton,"show-collapse-button":!1,"show-font-size-buttons":!1,"show-expand-button":!1,"show-preview-button":!1,"show-tooltips":e.showTooltips,"copy-text":w.value,stream:"",onCopy:R},de({"header-left":A(()=>[H(n.$slots,"header-left",{},()=>[t("div",Ze,[t("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:V.value},null,8,Xe),t("div",Je,[t("div",Qe,x(j.value.title),1),j.value.caption?(v(),h("div",qe,x(j.value.caption),1)):y("",!0)])])])]),default:A(()=>[U(X,I({ref_key:"preNodeRef",ref:T},M.value,{class:o.value,style:[u(b).style,i.value],node:e.node,loading:e.loading,"show-line-numbers":$.value,"diff-inline":N.value,"diff-hide-unchanged-regions":e.diffHideUnchangedRegions,"reserved-height-px":e.reservedHeightPx,"data-markstream-code-theme":r.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"])]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:A(()=>[H(n.$slots,"header-right")]),key:"0"}:void 0]),1032,["show-header","show-copy-button","show-tooltips","copy-text"])],4)):(v(),se(X,I({key:1,ref_key:"preNodeRef",ref:T},M.value,{class:o.value,style:[u(b).style,i.value],node:e.node,loading:e.loading,"show-line-numbers":$.value,"diff-inline":N.value,"diff-hide-unchanged-regions":e.diffHideUnchangedRegions,"reserved-height-px":e.reservedHeightPx,"data-markstream-code-theme":r.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"]))}})),to=Object.freeze(Object.defineProperty({__proto__:null,default:Ke},Symbol.toStringTag,{value:"Module"}));export{Ke as B,to as P,Me as Q,Ye as g};