tarsk 0.5.35 → 0.5.36

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 (76) hide show
  1. package/dist/index.js +1 -2
  2. package/dist/public/assets/{account-view-k5jIArY-.js → account-view-BB-ze5ek.js} +1 -1
  3. package/dist/public/assets/api-DzFQRz0u.js +1 -0
  4. package/dist/public/assets/{browser-tab-C9kJT-C5.js → browser-tab-B3bYbBws.js} +1 -1
  5. package/dist/public/assets/commit-dialog-CJRMd4oA.js +1 -0
  6. package/dist/public/assets/context-menu-86TNA1D0.js +1 -0
  7. package/dist/public/assets/create-repo-dialog-nLnVNRqq.js +1 -0
  8. package/dist/public/assets/{dialogs-config-B4TDFSrS.js → dialogs-config-I0_cSU2z.js} +14 -14
  9. package/dist/public/assets/diff-view-B8vWYa_2.js +3 -0
  10. package/dist/public/assets/explorer-tab-view-BGWQPnkw.js +2 -0
  11. package/dist/public/assets/{explorer-tree-uXbr6cCI.js → explorer-tree-DrLoiF9t.js} +1 -1
  12. package/dist/public/assets/{explorer-view-CupxzDId.js → explorer-view-Clm-RCAB.js} +1 -1
  13. package/dist/public/assets/git-history-dialog-CcdMtW0o.js +1 -0
  14. package/dist/public/assets/git-ops-button-D9m2nmhO.js +2 -0
  15. package/dist/public/assets/history-view-Be-1C1tJ.js +7 -0
  16. package/dist/public/assets/index-DVXbmgHY.js +65 -0
  17. package/dist/public/assets/index-jIBJk8xl.css +1 -0
  18. package/dist/public/assets/{mcp-server-card-DrUUKNXv.js → mcp-server-card-bNNoXKsW.js} +1 -1
  19. package/dist/public/assets/merged-pr-dialog-Fj8II9Bt.js +1 -0
  20. package/dist/public/assets/onboarding-CgP4bJ5F.js +1 -0
  21. package/dist/public/assets/project-settings-view-DixzP7KH.js +1 -0
  22. package/dist/public/assets/providers-list-view-BzSUZZyq.js +1 -0
  23. package/dist/public/assets/pull-request-dialog-ChuHHY3J.js +1 -0
  24. package/dist/public/assets/pull-with-changes-dialog-Ck6aK6Q7.js +1 -0
  25. package/dist/public/assets/push-before-pr-dialog-CbtHXjDH.js +1 -0
  26. package/dist/public/assets/radio-group-ZjNXbvW6.js +1 -0
  27. package/dist/public/assets/react-vendor-Do-APsQ6.js +16 -0
  28. package/dist/public/assets/settings-general-view-FwrdJbys.js +1 -0
  29. package/dist/public/assets/settings-instructions-view-BHzMtSvN.js +1 -0
  30. package/dist/public/assets/settings-list-BCoqXa_X.js +1 -0
  31. package/dist/public/assets/settings-mcp-servers-view-DBD-NhPx.js +5 -0
  32. package/dist/public/assets/{settings-models-skeleton-B_56ozbA.js → settings-models-skeleton-DsWpzWOw.js} +1 -1
  33. package/dist/public/assets/settings-models-view-vgV5YHRx.js +1 -0
  34. package/dist/public/assets/settings-rules-view-DcSXrmaq.js +8 -0
  35. package/dist/public/assets/settings-skills-view-DVGGs16n.js +2 -0
  36. package/dist/public/assets/settings-slash-commands-view-BsJw1F4p.js +1 -0
  37. package/dist/public/assets/settings-subagents-view-BgWhQ9bf.js +2 -0
  38. package/dist/public/assets/{settings-system-prompt-view-66zf0gRc.js → settings-system-prompt-view-DAAbMucD.js} +1 -1
  39. package/dist/public/assets/settings-view-DLzrbu69.js +2 -0
  40. package/dist/public/assets/{skeleton-BvSNJL9q.js → skeleton-iEZ-dj1s.js} +1 -1
  41. package/dist/public/assets/{terminal-panel-Bm5ECpK_.js → terminal-panel-C5qj1ctH.js} +2 -2
  42. package/dist/public/assets/{ui-components-BZYnvMGc.js → ui-components-BN8dp4Bi.js} +1 -1
  43. package/dist/public/assets/{utils-umVhs9to.js → utils-CU0c_yCM.js} +1 -1
  44. package/dist/public/assets/{whisper-wasm-Cq5Ofwpd.js → whisper-wasm-EGutPGND.js} +2 -2
  45. package/dist/public/index.html +12 -9
  46. package/package.json +1 -1
  47. package/dist/public/assets/api-OCjPhv01.js +0 -1
  48. package/dist/public/assets/commit-dialog-8Ce6d3H8.js +0 -1
  49. package/dist/public/assets/context-menu-CMsWrzLD.js +0 -1
  50. package/dist/public/assets/create-repo-dialog-CVUtteNS.js +0 -1
  51. package/dist/public/assets/diff-view-DGfmGlB_.js +0 -3
  52. package/dist/public/assets/explorer-tab-view-CCXVTkVu.js +0 -2
  53. package/dist/public/assets/git-history-dialog-BCGOZ6ua.js +0 -1
  54. package/dist/public/assets/git-ops-button-BV9X3fo-.js +0 -2
  55. package/dist/public/assets/history-view-Ds_0e_bx.js +0 -7
  56. package/dist/public/assets/index-C0lTt0ZK.css +0 -1
  57. package/dist/public/assets/index-DOsSr4dl.js +0 -65
  58. package/dist/public/assets/merged-pr-dialog-DqWSFdCH.js +0 -1
  59. package/dist/public/assets/onboarding-DfL8a0LZ.js +0 -1
  60. package/dist/public/assets/project-settings-view-Cd_l3Lfy.js +0 -1
  61. package/dist/public/assets/providers-list-view-VXhgM3vp.js +0 -1
  62. package/dist/public/assets/pull-request-dialog-DZXTHHuh.js +0 -1
  63. package/dist/public/assets/pull-with-changes-dialog-CYQrwzcw.js +0 -1
  64. package/dist/public/assets/push-before-pr-dialog-D-ZnRpJi.js +0 -1
  65. package/dist/public/assets/radio-group-c0sU992r.js +0 -1
  66. package/dist/public/assets/react-vendor-unlDVFpU.js +0 -16
  67. package/dist/public/assets/settings-general-view-DI-lvP0L.js +0 -1
  68. package/dist/public/assets/settings-instructions-view-kUG32_dT.js +0 -1
  69. package/dist/public/assets/settings-list-CUbZrggr.js +0 -1
  70. package/dist/public/assets/settings-mcp-servers-view-DmxUO42I.js +0 -5
  71. package/dist/public/assets/settings-models-view-ms828HDa.js +0 -1
  72. package/dist/public/assets/settings-rules-view-Xx0ymfnQ.js +0 -8
  73. package/dist/public/assets/settings-skills-view-DvPPdsi_.js +0 -2
  74. package/dist/public/assets/settings-slash-commands-view-BULIAW2o.js +0 -1
  75. package/dist/public/assets/settings-subagents-view-B7FcLaZT.js +0 -2
  76. package/dist/public/assets/settings-view-B4CMq7it.js +0 -2
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Sn as r,Tr as i,X as a,_o as o,li as s,n as c,nr as l,oa as ee,r as u,si as te,ur as ne,yo as d}from"./dialogs-config-I0_cSU2z.js";import{a as f,i as p,o as m,r as h}from"./react-vendor-Do-APsQ6.js";import{D as re,E as ie,S as ae,b as oe}from"./history-view-Be-1C1tJ.js";import{t as se}from"./index-DVXbmgHY.js";var ce=o(),g=e(d(),1),_=t(),le=g.forwardRef((e,t)=>{let n=(0,ce.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=s(`relative flex w-full touch-none select-none items-center`,r),n[3]=r,n[4]=a);let o,c;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,_.jsx)(m,{className:`relative h-2 w-full grow overflow-hidden rounded-full bg-secondary`,children:(0,_.jsx)(h,{className:`absolute h-full bg-primary`})}),c=(0,_.jsx)(f,{className:`block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`}),n[5]=o,n[6]=c):(o=n[5],c=n[6]);let l;return n[7]!==i||n[8]!==t||n[9]!==a?(l=(0,_.jsxs)(p,{ref:t,className:a,...i,children:[o,c]}),n[7]=i,n[8]=t,n[9]=a,n[10]=l):l=n[10],l});le.displayName=p.displayName;var v=50;function ue(){let[e,t]=(0,g.useState)(v),[n,i]=(0,g.useState)(v.toString()),[o,s]=(0,g.useState)(!0),[c,l]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=!1;async function n(){try{let n=await a();e||(t(n.maximumTurnCount),i(n.maximumTurnCount.toString()))}catch(e){console.error(`Failed to load maximum turn count:`,e)}finally{e||s(!1)}}return n(),()=>{e=!0}},[]);function ee(e){i(e)}async function u(e){l(!0);try{let n=await r({maximumTurnCount:e});t(n.maximumTurnCount),i(n.maximumTurnCount.toString())}catch(e){throw console.error(`Failed to update maximum turn count:`,e),e}finally{l(!1)}}function te(){i(e.toString())}return{defaultMaximumTurnCount:v,draftMaximumTurnCount:n,isLoading:o,isSaving:c,maximumTurnCount:e,resetDraftMaximumTurnCount:te,setDraftMaximumTurnCount:ee,updateMaximumTurnCount:u}}var de=`local`;function fe(){let[e,t]=(0,g.useState)(de),[n,i]=(0,g.useState)(null),[o,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(!0),[ee,u]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=!1;async function n(){try{let n=await a();e||(t(n.serverBindMode),i(n.serverBindMode),s(n.networkAddresses))}catch(e){console.error(`Failed to load server bind mode:`,e)}finally{e||l(!1)}}return n(),()=>{e=!0}},[]);async function te(e){u(!0);try{let n=await r({serverBindMode:e});t(n.serverBindMode),s(n.networkAddresses)}catch(e){throw console.error(`Failed to update server bind mode:`,e),e}finally{u(!1)}}return{defaultServerBindMode:de,hasServerBindModeChanged:n!==null&&e!==n,isLoading:c,isSaving:ee,networkAddresses:o,serverBindMode:e,updateServerBindMode:te}}var pe=`default`;function me(){let e=(0,ce.c)(3),[t,n]=(0,g.useState)(he),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=e=>{n(e),ne(e)},e[0]=r):r=e[0];let i=r,a;return e[1]===t?a=e[2]:(a={voiceModel:t,updateVoiceModel:i,defaultVoiceModel:pe},e[1]=t,e[2]=a),a}function he(){return l(pe)}var ge=[{value:`default`,label:`Standard`},{value:`tiny`,label:`Tiny`}],_e=[{value:`local`,label:`Local`},{value:`network`,label:`Network`}],ve=[`462`,`8100`].includes(typeof document<`u`?document.location.port:``)?`462`:`641`,ye=600;function be(e){let t=(0,ce.c)(94),{onboardingResetSignal:r}=e,a=r===void 0?0:r,[o,l]=(0,g.useState)(!1),{scale:u,updateScale:ne,resetScale:d,min:f,max:p,default:m}=se(),{defaultMaximumTurnCount:h,draftMaximumTurnCount:v,isLoading:de,isSaving:pe,resetDraftMaximumTurnCount:he,setDraftMaximumTurnCount:be,updateMaximumTurnCount:we}=ue(),{voiceModel:Te,updateVoiceModel:Ee}=me(),{hasServerBindModeChanged:De,isLoading:Oe,isSaving:ke,networkAddresses:y,serverBindMode:b,updateServerBindMode:Ae}=fe(),x,S;t[0]===a?(x=t[1],S=t[2]):(x=()=>{if(a===0)return;l(!0);let e=setTimeout(()=>{l(!1)},ye);return()=>{clearTimeout(e)}},S=[a],t[0]=a,t[1]=x,t[2]=S),(0,g.useEffect)(x,S);let C;t[3]===be?C=t[4]:(C=function(e){be(e.target.value)},t[3]=be,t[4]=C);let je=C,w;t[5]!==h||t[6]!==v||t[7]!==he||t[8]!==we?(w=async function(){let e=Number.parseInt(v,10),t=Number.isFinite(e)&&e>0?e:h;try{await we(t)}catch{he()}},t[5]=h,t[6]=v,t[7]=he,t[8]=we,t[9]=w):w=t[9];let Me=w,T;t[10]===ne?T=t[11]:(T=function(e){e.length>0&&ne(e[0])},t[10]=ne,t[11]=T);let Ne=T,Pe=o&&`animate-headline-reset`,E;t[12]===Pe?E=t[13]:(E=s(Pe),t[12]=Pe,t[13]=E);let D;t[14]===E?D=t[15]:(D=(0,_.jsx)(ae,{title:`General`,description:`Customize the appearance and behavior of Tarsk.`,titleClassName:E}),t[14]=E,t[15]=D);let O,Fe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,_.jsx)(ee,{className:`h-3.5 w-3.5`}),Fe=(0,_.jsx)(`span`,{className:`sr-only`,children:`Reset font size to default`}),t[16]=O,t[17]=Fe):(O=t[16],Fe=t[17]);let k;t[18]===d?k=t[19]:(k=(0,_.jsxs)(te,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:d,children:[O,Fe]}),t[18]=d,t[19]=k);let A;t[20]===u?A=t[21]:(A=(0,_.jsxs)(`span`,{className:`${n.mono} tabular-nums w-12 text-right`,children:[u,`%`]}),t[20]=u,t[21]=A);let j;t[22]!==k||t[23]!==A?(j=(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24];let M;t[25]===f?M=t[26]:(M=(0,_.jsxs)(`span`,{className:`${n.bodyMuted} w-8 text-right`,children:[f,`%`]}),t[25]=f,t[26]=M);let N;t[27]===u?N=t[28]:(N=[u],t[27]=u,t[28]=N);let P;t[29]!==Ne||t[30]!==p||t[31]!==f||t[32]!==N?(P=(0,_.jsx)(le,{value:N,min:f,max:p,step:5,onValueChange:Ne,"aria-label":`Font size`}),t[29]=Ne,t[30]=p,t[31]=f,t[32]=N,t[33]=P):P=t[33];let F;t[34]===p?F=t[35]:(F=(0,_.jsxs)(`span`,{className:`${n.bodyMuted} w-9`,children:[p,`%`]}),t[34]=p,t[35]=F);let I;t[36]!==M||t[37]!==P||t[38]!==F?(I=(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[M,P,F]}),t[36]=M,t[37]=P,t[38]=F,t[39]=I):I=t[39];let L;t[40]!==m||t[41]!==u?(L=u!==m&&(0,_.jsxs)(`p`,{className:`${n.bodyMuted} mt-2`,children:[`Font size has been changed from the default (`,m,`%).`]}),t[40]=m,t[41]=u,t[42]=L):L=t[42];let R;t[43]!==j||t[44]!==I||t[45]!==L?(R=(0,_.jsxs)(oe,{title:`Font Size`,description:`Adjust the text size across the entire application.`,action:j,children:[I,L]}),t[43]=j,t[44]=I,t[45]=L,t[46]=R):R=t[46];let z;t[47]===Me?z=t[48]:(z=()=>{Me()},t[47]=Me,t[48]=z);let Ie=de||pe,B;t[49]!==v||t[50]!==je||t[51]!==z||t[52]!==Ie?(B=(0,_.jsx)(i,{type:`number`,min:1,step:1,value:v,onChange:je,onBlur:z,disabled:Ie,"aria-label":`Maximum turn count`,className:`w-28 text-right font-mono tabular-nums flex-shrink-0`}),t[49]=v,t[50]=je,t[51]=z,t[52]=Ie,t[53]=B):B=t[53];let V;t[54]===h?V=t[55]:(V=(0,_.jsxs)(`p`,{className:n.bodyMuted,children:[`Default: `,h,` turns.`]}),t[54]=h,t[55]=V);let H;t[56]!==B||t[57]!==V?(H=(0,_.jsx)(oe,{title:`Maximum Turn Count`,description:`Set how many turns a long-running agent chat can take before Tarsk asks whether to continue.`,action:B,children:V}),t[56]=B,t[57]=V,t[58]=H):H=t[58];let U;t[59]===Ee?U=t[60]:(U=e=>{(e==="default"||e===`tiny`)&&Ee(e)},t[59]=Ee,t[60]=U);let W;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(W=ge.map(Ce),t[61]=W):W=t[61];let G;t[62]!==U||t[63]!==Te?(G=(0,_.jsx)(oe,{title:`Voice Model`,description:`Choose which voice-to-text model Tarsk downloads and caches for speech input.`,children:(0,_.jsx)(c,{type:`single`,value:Te,onValueChange:U,"aria-label":`Voice model`,variant:`outline`,className:`inline-flex rounded-full border bg-muted/40 p-1`,children:W})}),t[62]=U,t[63]=Te,t[64]=G):G=t[64];let Le=b===`network`?`Tarsk accepts connections from other devices on your network such as the Tarsk mobile app.`:`Tarsk only accepts connections from this computer at http://localhost:${ve}.`,Re=Oe||ke,K;t[65]===Ae?K=t[66]:(K=e=>{(e===`local`||e===`network`)&&Ae(e)},t[65]=Ae,t[66]=K);let ze;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ze=_e.map(Se),t[67]=ze):ze=t[67];let q;t[68]!==b||t[69]!==Re||t[70]!==K?(q=(0,_.jsx)(c,{type:`single`,value:b,disabled:Re,onValueChange:K,"aria-label":`Server bind mode`,variant:`outline`,className:`inline-flex rounded-full border bg-muted/40 p-1`,children:ze}),t[68]=b,t[69]=Re,t[70]=K,t[71]=q):q=t[71];let J;t[72]!==y||t[73]!==b?(J=b===`network`&&y.length>0&&(0,_.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,_.jsx)(`p`,{className:n.bodyMuted,children:`Available on your network:`}),(0,_.jsx)(`ul`,{className:`${n.mono} space-y-1`,children:y.map(xe)})]}),t[72]=y,t[73]=b,t[74]=J):J=t[74];let Y;t[75]!==y||t[76]!==b?(Y=b===`network`&&y.length===0&&(0,_.jsx)(`p`,{className:`${n.bodyMuted} mt-3`,children:`No network IP addresses were detected on this computer.`}),t[75]=y,t[76]=b,t[77]=Y):Y=t[77];let X;t[78]===De?X=t[79]:(X=De&&(0,_.jsx)(`p`,{className:`${n.bodyMuted} mt-3`,children:`Restart Tarsk for this change to take effect.`}),t[78]=De,t[79]=X);let Z;t[80]!==Le||t[81]!==q||t[82]!==J||t[83]!==Y||t[84]!==X?(Z=(0,_.jsxs)(oe,{title:`Local`,description:Le,children:[q,J,Y,X]}),t[80]=Le,t[81]=q,t[82]=J,t[83]=Y,t[84]=X,t[85]=Z):Z=t[85];let Q;t[86]!==R||t[87]!==H||t[88]!==G||t[89]!==Z?(Q=(0,_.jsxs)(`div`,{className:`space-y-8`,children:[R,H,G,Z]}),t[86]=R,t[87]=H,t[88]=G,t[89]=Z,t[90]=Q):Q=t[90];let $;return t[91]!==Q||t[92]!==D?($=(0,_.jsx)(re,{children:(0,_.jsxs)(ie,{children:[D,Q]})}),t[91]=Q,t[92]=D,t[93]=$):$=t[93],$}function xe(e){return(0,_.jsxs)(`li`,{children:[`http://`,e,`:`,ve]},e)}function Se(e){return(0,_.jsx)(u,{value:e.value,"aria-label":e.label,className:`rounded-full border-0 px-4 data-[state=on]:bg-foreground data-[state=on]:text-background data-[state=on]:shadow-sm dark:data-[state=on]:bg-background dark:data-[state=on]:text-foreground`,children:e.label},e.value)}function Ce(e){return(0,_.jsx)(u,{value:e.value,"aria-label":e.label,className:`rounded-full border-0 px-4 data-[state=on]:bg-foreground data-[state=on]:text-background data-[state=on]:shadow-sm dark:data-[state=on]:bg-background dark:data-[state=on]:text-foreground`,children:e.label},e.value)}export{be as default};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,At as n,Ci as r,cn as i,li as a,si as o,wa as s,yo as c}from"./dialogs-config-I0_cSU2z.js";import{E as l,S as u,T as d,w as f}from"./history-view-Be-1C1tJ.js";import{E as p,O as m,j as h}from"./index-DVXbmgHY.js";var g=e(c(),1),_=t();function v(){let e=h(e=>e.selectedThreadId),[t,c]=(0,g.useState)(``),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{e&&(y(!0),n(e,`AGENTS.md`).then(e=>c(e.content)).catch(()=>c(``)).finally(()=>y(!1)))},[e]);async function S(){if(e){x(!0);try{await i(e,`AGENTS.md`,t),p({title:`Instructions saved`})}catch(e){p({title:`Error`,description:e instanceof Error?e.message:`Failed to save instructions`,variant:`destructive`})}finally{x(!1)}}}return e?(0,_.jsx)(f,{children:(0,_.jsxs)(l,{className:`w-full flex-1 flex flex-col min-h-0`,children:[(0,_.jsx)(u,{title:`Instructions`,description:`Add context like coding guidelines and expectations. Stored in AGENTS.md file.`,action:(0,_.jsx)(o,{onClick:S,disabled:v||b,children:b?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})}),v?(0,_.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,_.jsx)(s,{className:`h-8 w-8 animate-spin text-muted-foreground`})}):(0,_.jsx)(m,{value:t,onChange:e=>c(e.target.value),className:a(r.mono,`flex-1 min-h-0 resize-none`),placeholder:`Add instructions for your agent in AGENTS.md...`,disabled:b})]})}):(0,_.jsx)(d,{children:`Select a thread to edit instructions.`})}export{v as SettingsInstructionsView,v as default};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{Ai as e,Ci as t,Tr as n,_o as r,dr as i,fr as a,li as o,mr as s,na as c,pr as l,si as u,yo as d}from"./dialogs-config-I0_cSU2z.js";import{i as f,r as p}from"./history-view-Be-1C1tJ.js";var m=r();d();var h=e();function g(e){let n=(0,m.c)(16),{title:r,subtitle:i,subtitleMono:a,badge:s,actions:c}=e,l=a===void 0?!1:a,u;n[0]===r?u=n[1]:(u=typeof r==`string`?(0,h.jsx)(`h3`,{className:o(t.label,`truncate`),children:r}):r,n[0]=r,n[1]=u);let d;n[2]!==s||n[3]!==u?(d=(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u,s]}),n[2]=s,n[3]=u,n[4]=d):d=n[4];let g;n[5]!==i||n[6]!==l?(g=i?(0,h.jsx)(`p`,{className:o(t.bodyMuted,`mt-1 truncate`,l&&t.mono),children:i}):null,n[5]=i,n[6]=l,n[7]=g):g=n[7];let v;n[8]!==d||n[9]!==g?(v=(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,g]}),n[8]=d,n[9]=g,n[10]=v):v=n[10];let y;n[11]===c?y=n[12]:(y=(0,h.jsx)(_,{actions:c}),n[11]=c,n[12]=y);let b;return n[13]!==v||n[14]!==y?(b=(0,h.jsx)(p,{children:(0,h.jsxs)(f,{className:`flex items-center justify-between p-4`,children:[v,y]})}),n[13]=v,n[14]=y,n[15]=b):b=n[15],b}function _(e){let t=(0,m.c)(4),{actions:n}=e,r;t[0]===n?r=t[1]:(r=n.map(v),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,h.jsx)(l,{delayDuration:300,children:(0,h.jsx)(`div`,{className:`flex items-center gap-1 ml-4 flex-shrink-0`,children:r})}),t[2]=r,t[3]=i),i}function v(e){return(0,h.jsxs)(i,{children:[(0,h.jsx)(s,{asChild:!0,children:(0,h.jsx)(u,{variant:`ghost`,size:`icon-sm`,onClick:e.onClick,children:(0,h.jsx)(`span`,{className:e.destructive?`text-destructive`:void 0,children:e.icon})})}),(0,h.jsx)(a,{children:e.label})]},e.label)}function y(e){let n=(0,m.c)(12),{icon:r,title:i,description:a}=e,s;n[0]===r?s=n[1]:(s=(0,h.jsx)(r,{className:`mx-auto h-10 w-10 text-muted-foreground/50 mb-3`}),n[0]=r,n[1]=s);let c;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=o(t.emptyStateTitle,`mb-1`),n[2]=c):c=n[2];let l;n[3]===i?l=n[4]:(l=(0,h.jsx)(`h3`,{className:c,children:i}),n[3]=i,n[4]=l);let u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(t.bodyMuted,`mb-3`),n[5]=u):u=n[5];let d;n[6]===a?d=n[7]:(d=(0,h.jsx)(`p`,{className:u,children:a}),n[6]=a,n[7]=d);let f;return n[8]!==s||n[9]!==l||n[10]!==d?(f=(0,h.jsxs)(`div`,{className:`text-center py-12 border border-dashed rounded-lg mb-8`,children:[s,l,d]}),n[8]=s,n[9]=l,n[10]=d,n[11]=f):f=n[11],f}function b(e){let t=(0,m.c)(7),{placeholder:r,value:i,onChange:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,h.jsx)(c,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),t[0]=o):o=t[0];let s;t[1]===a?s=t[2]:(s=e=>a(e.target.value),t[1]=a,t[2]=s);let l;return t[3]!==r||t[4]!==s||t[5]!==i?(l=(0,h.jsxs)(`div`,{className:`relative mb-4`,children:[o,(0,h.jsx)(n,{placeholder:r,value:i,onChange:s,className:`pl-8`})]}),t[3]=r,t[4]=s,t[5]=i,t[6]=l):l=t[6],l}function x(e){let t=(0,m.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,h.jsx)(`div`,{className:`grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(220px,100%),1fr))]`,children:n}),t[0]=n,t[1]=r),r}function S(e){let n=(0,m.c)(3),{searchQuery:r,emptyLabel:i}=e,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=o(t.bodyMuted,`text-center py-8`),n[0]=a):a=n[0];let s=r.trim()?`No results for "${r}"`:i,c;return n[1]===s?c=n[2]:(c=(0,h.jsx)(`p`,{className:a,children:s}),n[1]=s,n[2]=c),c}function C(e){let n=(0,m.c)(3),{message:r}=e,i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=o(t.bodyMuted,`text-center py-8`),n[0]=i):i=n[0];let a;return n[1]===r?a=n[2]:(a=(0,h.jsx)(`p`,{className:i,children:r}),n[1]=r,n[2]=a),a}export{b as a,S as i,g as n,C as o,x as r,y as t};
@@ -0,0 +1,5 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Dr as r,Er as i,Fi as a,Ha as o,Hi as s,M as c,Tr as l,_o as u,an as d,ca as f,ct as p,ea as m,ft as h,si as g,ua as _,yo as v}from"./dialogs-config-I0_cSU2z.js";import{A as y,C as b,D as ee,E as x,F as S,M as C,N as w,O as T,P as E,S as te,T as D,b as O,d as k,f as A,g as j,h as M,j as N,k as P,p as F,y as I}from"./history-view-Be-1C1tJ.js";import{C as L,E as R,O as z,c as ne,j as B,l as V,o as re,s as H}from"./index-DVXbmgHY.js";import{t as U}from"./skeleton-iEZ-dj1s.js";import{a as W,i as ie,n as G,r as K,t as ae}from"./settings-list-BCoqXa_X.js";import{t as oe}from"./mcp-server-card-bNNoXKsW.js";var q=u(),J=e(v(),1);function se(e){let[t,n]=(0,J.useState)([]),[r,i]=(0,J.useState)(!1),a=(0,J.useCallback)(async()=>{if(e){i(!0);try{let t=await p(e);n(Object.entries(t.servers??{}).map(([e,t])=>({name:e,config:t})))}catch{n([])}finally{i(!1)}}},[e]);return(0,J.useEffect)(()=>{a()},[a]),{installedServers:t,loadingConfig:r,loadInstalledServers:a}}function Y(){let e=(0,q.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,J.useState)(t),i,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{h().then(r).catch(()=>r([]))},a=[],e[1]=i,e[2]=a):(i=e[1],a=e[2]),(0,J.useEffect)(i,a);let o;return e[3]===n?o=e[4]:(o={popularServers:n},e[3]=n,e[4]=o),o}async function X(e,t,n){await d(e,t,n)}async function ce(e,t){await c(e,t)}var Z=t();function le(e){return e?.url?`remote`:`local`}function ue(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:t}))}function Q({projectPath:e,serverName:t,initialName:r,initialConfig:i,onBack:o}){let{installedServers:s}=se(e),c=!!t,[u,d]=(0,J.useState)(`local`),[p,m]=(0,J.useState)(``),[h,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(`sse`),[w,T]=(0,J.useState)([]),[E,D]=(0,J.useState)([]),[N,P]=(0,J.useState)(!1),[L,B]=(0,J.useState)(!1),[U,W]=(0,J.useState)(null),[ie,G]=(0,J.useState)(c),[K,ae]=(0,J.useState)(``),[oe,q]=(0,J.useState)(``);function Y(e,t){let n=le(t);d(n),m(e),_(t.command??``),y((t.args??[]).join(`
2
+ `)),x(t.url??``),C(t.transport??`sse`),T(ue(t.env)),D(ue(t.headers)),ae(e),q(JSON.stringify({name:e,type:n,config:t}))}(0,J.useEffect)(()=>{if(c&&t){let e=s.find(e=>e.name===t);e&&(Y(e.name,e.config),G(!1))}else i&&Y(r??``,i),G(!1)},[s,t,c,i,r]);let Q=(0,J.useCallback)(()=>{T(e=>[...e,{key:``,value:``}])},[]),$=(0,J.useCallback)(e=>{T(t=>t.filter((t,n)=>n!==e))},[]),de=(0,J.useCallback)((e,t)=>{T(n=>n.map((n,r)=>r===e?{...n,key:t}:n))},[]),fe=(0,J.useCallback)((e,t)=>{T(n=>n.map((n,r)=>r===e?{...n,value:t}:n))},[]),pe=(0,J.useCallback)(()=>{D(e=>[...e,{key:``,value:``}])},[]),me=(0,J.useCallback)(e=>{D(t=>t.filter((t,n)=>n!==e))},[]),he=(0,J.useCallback)((e,t)=>{D(n=>n.map((n,r)=>r===e?{...n,key:t}:n))},[]),ge=(0,J.useCallback)((e,t)=>{D(n=>n.map((n,r)=>r===e?{...n,value:t}:n))},[]);function _e(e){let t={};for(let{key:n,value:r}of e)n.trim()&&(t[n.trim()]=r);return Object.keys(t).length>0?t:void 0}function ve(){let e=_e(w);if(u===`remote`){let t=_e(E);return{url:b.trim(),transport:S,...t?{headers:t}:{},...e?{env:e}:{}}}let t=v.split(`
3
+ `).map(e=>e.trim()).filter(Boolean);return{command:h.trim(),args:t,...e?{env:e}:{}}}let ye=JSON.stringify({name:p.trim(),type:u,config:ve()}),be=async()=>{W(null);let t=p.trim();if(!t){W(`Server name is required`);return}if(u===`remote`){if(!b.trim()){W(`Server URL is required`);return}try{new URL(b.trim())}catch{W(`Server URL must be a valid URL`);return}}else if(!h.trim()){W(`Command is required`);return}P(!0);try{if(!e)throw Error(`No project path`);await X(e,K||t,ve()),R({title:`Success`,description:c?`MCP server configuration saved`:`MCP server added`}),o()}catch(e){W(e instanceof Error?e.message:`Failed to save server`)}finally{P(!1)}},xe=async()=>{if(e){B(!0);try{await ce(e,K),R({title:`Success`,description:`MCP server removed`}),o()}catch(e){W(e instanceof Error?e.message:`Failed to delete server`)}finally{B(!1)}}},Se=c?ye!==oe:p.trim()!==``||h.trim()!==``||v.trim()!==``||b.trim()!==``||w.length>0||E.length>0;return ie?(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:n.bodyMuted,children:`Loading server configuration...`})}):(0,Z.jsx)(ee,{children:(0,Z.jsxs)(I,{children:[(0,Z.jsx)(te,{title:c?p:`Add MCP Server`,description:c?`Edit MCP Server configuration.`:`Configure a new MCP Server.`}),(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(O,{title:`Server name`,description:c?`Server name cannot be changed`:void 0,children:(0,Z.jsx)(l,{id:`server-name`,placeholder:`e.g. filesystem`,value:p,onChange:e=>m(e.target.value),disabled:c})}),(0,Z.jsxs)(re,{value:u,onValueChange:e=>d(e),className:`w-full`,children:[(0,Z.jsxs)(ne,{className:`grid w-full grid-cols-2`,children:[(0,Z.jsx)(V,{value:`local`,children:`Local (stdio)`}),(0,Z.jsx)(V,{value:`remote`,children:`Remote (HTTP/SSE)`})]}),(0,Z.jsxs)(H,{value:`local`,className:`space-y-6 mt-6`,children:[(0,Z.jsx)(O,{title:`Command`,children:(0,Z.jsx)(l,{id:`server-command`,placeholder:`e.g. npx`,value:h,onChange:e=>_(e.target.value)})}),(0,Z.jsx)(O,{title:`Arguments`,description:`One argument per line`,children:(0,Z.jsx)(z,{id:`server-args`,placeholder:`-y
4
+ @modelcontextprotocol/server-filesystem
5
+ /path/to/dir`,value:v,onChange:e=>y(e.target.value),className:`font-mono min-h-[80px] resize-none`})})]}),(0,Z.jsxs)(H,{value:`remote`,className:`space-y-6 mt-6`,children:[(0,Z.jsx)(O,{title:`Server URL`,description:`Paste the MCP endpoint URL from your provider.`,children:(0,Z.jsx)(l,{id:`server-url`,placeholder:`https://example.com/mcp`,value:b,onChange:e=>x(e.target.value),className:`font-mono`})}),(0,Z.jsx)(O,{title:`Transport`,children:(0,Z.jsxs)(k,{value:S,onValueChange:e=>C(e),children:[(0,Z.jsx)(M,{children:(0,Z.jsx)(j,{})}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(F,{value:`sse`,children:`SSE (Server-Sent Events)`}),(0,Z.jsx)(F,{value:`streamableHttp`,children:`Streamable HTTP`})]})]})}),(0,Z.jsx)(O,{title:`HTTP headers`,description:`Optional headers for authentication.`,action:(0,Z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,Z.jsx)(f,{className:`h-3 w-3 mr-1`}),`Add header`]}),children:E.length===0?(0,Z.jsx)(`p`,{className:n.caption,children:`No headers configured`}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:E.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(l,{placeholder:`Authorization`,value:e.key,onChange:e=>he(t,e.target.value),className:`font-mono w-[35%]`}),(0,Z.jsx)(l,{placeholder:`Bearer ...`,value:e.value,onChange:e=>ge(t,e.target.value),className:`font-mono flex-1`}),(0,Z.jsx)(g,{variant:`ghost`,size:`icon`,onClick:()=>me(t),className:`h-9 w-9 flex-shrink-0`,children:(0,Z.jsx)(a,{className:`h-3.5 w-3.5`})})]},t))})})]})]}),(0,Z.jsx)(O,{title:`Environment variables`,description:u===`remote`?`Optional metadata for local tooling.`:void 0,action:(0,Z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:Q,children:[(0,Z.jsx)(f,{className:`h-3 w-3 mr-1`}),`Add variable`]}),children:w.length===0?(0,Z.jsx)(`p`,{className:n.caption,children:`No environment variables configured`}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:w.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(l,{placeholder:`KEY`,value:e.key,onChange:e=>de(t,e.target.value),className:`font-mono w-[35%]`}),(0,Z.jsx)(l,{placeholder:`value`,value:e.value,onChange:e=>fe(t,e.target.value),className:`font-mono flex-1`}),(0,Z.jsx)(g,{variant:`ghost`,size:`icon`,onClick:()=>$(t),className:`h-9 w-9 flex-shrink-0`,children:(0,Z.jsx)(a,{className:`h-3.5 w-3.5`})})]},t))})}),U&&(0,Z.jsx)(`p`,{className:n.error,children:U}),(0,Z.jsxs)(`div`,{className:`border-t pt-4 flex items-center justify-between`,children:[c&&(0,Z.jsx)(g,{variant:`destructive`,onClick:xe,disabled:L||N,children:L?`Removing...`:`Remove`}),!c&&(0,Z.jsx)(`div`,{}),(0,Z.jsx)(g,{onClick:be,disabled:N||L||!Se,children:N?c?`Saving...`:`Adding...`:c?`Save`:`Add`})]})]})]})})}function $(e){return e.name.toLowerCase().replace(/\s+/g,`-`)}function de(e){return e.url?e.url:`${e.command??``} ${e.args?.join(` `)??``}`.trim()}function fe(){let e=B(e=>e.selectedProjectId),t=B(e=>e.projects).find(t=>t.projectId===e)?.projectPath,{installedServers:n,loadingConfig:a,loadInstalledServers:c}=se(t),{popularServers:l}=Y(),{setActiveMainTab:u,setPendingExplorerPath:d,triggerExplorerRefresh:f}=L(),[p,h]=(0,J.useState)(!1),[v,O]=(0,J.useState)(null),[k,A]=(0,J.useState)(null),[j,M]=(0,J.useState)(null),[F,I]=(0,J.useState)(!1),[z,ne]=(0,J.useState)(``),V=(0,J.useCallback)(async e=>{if(t){I(!0);try{await ce(t,e),await c(),f(),R({title:`MCP server removed`,description:e}),M(null)}catch(e){R({title:`Error`,description:e instanceof Error?e.message:`Failed to remove server`,variant:`destructive`})}finally{I(!1)}}},[t,c,f]),re=(0,J.useCallback)(()=>{d(`.agents/mcp.json`),u(`explorer`)},[d,u]),H=(0,J.useCallback)(async e=>{if(!t)return;let r=$(e);if(!n.some(t=>t.name===r||t.name===e.id)){if(e.url!==void 0){if(!e.url.trim()){O({name:r,config:{url:``,transport:e.transport??`sse`,...Object.keys(e.env??{}).length>0?{env:e.env}:{}}}),h(!0);return}try{await X(t,r,{url:e.url,transport:e.transport??`sse`,...Object.keys(e.env??{}).length>0?{env:e.env}:{}}),await c(),f(),R({title:`MCP server installed`,description:e.name})}catch(e){R({title:`Error`,description:e instanceof Error?e.message:`Failed to install server`,variant:`destructive`})}return}if(!e.command){R({title:`Error`,description:`This server is missing install configuration.`,variant:`destructive`});return}try{await X(t,r,{command:e.command,args:e.args??[],...Object.keys(e.env??{}).length>0?{env:e.env}:{}}),await c(),f(),R({title:`MCP server installed`,description:e.name})}catch(e){R({title:`Error`,description:e instanceof Error?e.message:`Failed to install server`,variant:`destructive`})}}},[t,n,c,f]),q=z.trim()?l.filter(e=>e.name.toLowerCase().includes(z.toLowerCase())||e.description.toLowerCase().includes(z.toLowerCase())):l;return e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ee,{children:(0,Z.jsxs)(x,{children:[(0,Z.jsx)(te,{title:`MCP Servers`,description:`Manage Model Context Protocol servers for your project.`,action:(0,Z.jsx)(g,{onClick:()=>h(!0),children:`Add Server`})}),(0,Z.jsx)(b,{title:`Installed`}),a?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(U,{className:`h-20 w-full`}),(0,Z.jsx)(U,{className:`h-20 w-full`})]}):n.length===0?(0,Z.jsx)(ae,{icon:m,title:`No MCP servers installed`,description:`Add an MCP server to extend agent capabilities.`}):(0,Z.jsx)(`div`,{className:`space-y-3 mb-8`,children:n.map(e=>(0,Z.jsx)(G,{title:e.name,subtitle:de(e.config),subtitleMono:!0,actions:[{label:`View config file`,icon:(0,Z.jsx)(o,{className:`h-4 w-4`}),onClick:re},{label:`Edit server`,icon:(0,Z.jsx)(_,{className:`h-4 w-4`}),onClick:()=>A(e.name)},{label:`Delete server`,icon:(0,Z.jsx)(s,{className:`h-4 w-4`}),onClick:()=>M(e.name),destructive:!0}]},e.name))}),(0,Z.jsx)(b,{title:`Available`,className:`mb-0`}),(0,Z.jsx)(W,{placeholder:`Search available servers...`,value:z,onChange:ne}),l.length===0?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(U,{className:`h-20 w-full`}),(0,Z.jsx)(U,{className:`h-20 w-full`})]}):q.length===0?(0,Z.jsx)(ie,{searchQuery:z,emptyLabel:`No available servers found.`}):(0,Z.jsx)(K,{children:q.map(e=>{let t=$(e),r=n.some(n=>n.name===t||n.name===e.id);return(0,Z.jsx)(oe,{name:e.name,description:e.description,installed:r,onClick:()=>{r||H(e)},showInstalledControls:!1},e.id)})})]})}),(0,Z.jsx)(i,{open:p,onOpenChange:e=>{h(e),e||O(null)},children:(0,Z.jsx)(r,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,Z.jsx)(Q,{projectPath:t,initialName:v?.name,initialConfig:v?.config,onBack:()=>{h(!1),O(null),c(),f()}})})}),(0,Z.jsx)(i,{open:k!==null,onOpenChange:e=>{e||A(null)},children:(0,Z.jsx)(r,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,Z.jsx)(Q,{projectPath:t,serverName:k??void 0,onBack:()=>{A(null),c(),f()}})})}),(0,Z.jsx)(T,{open:j!==null,onOpenChange:e=>!e&&M(null),children:(0,Z.jsxs)(N,{children:[(0,Z.jsxs)(E,{children:[(0,Z.jsx)(S,{children:`Delete MCP Server`}),(0,Z.jsxs)(C,{children:[`Are you sure you want to delete the server "`,j,`"? This action cannot be undone.`]})]}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(y,{children:`Cancel`}),(0,Z.jsx)(P,{onClick:()=>j&&void V(j),disabled:F,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:F?`Deleting...`:`Delete`})]})]})})]}):(0,Z.jsx)(D,{children:`Select a project to manage MCP servers.`})}export{fe as SettingsMCPServersView,fe as default};
@@ -1 +1 @@
1
- import{Ti as e,fo as t}from"./dialogs-config-B4TDFSrS.js";import{D as n,E as r,S as i}from"./history-view-Ds_0e_bx.js";import{t as a}from"./skeleton-BvSNJL9q.js";var o=t(),s=e();function c(){let e=(0,o.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,s.jsx)(i,{title:`Models`,description:`View and manage available models from your configured providers.`}),e[0]=t):t=e[0];let c,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,s.jsx)(a,{className:`h-10 w-full`}),u=(0,s.jsx)(a,{className:`h-9 w-48`}),e[1]=c,e[2]=u):(c=e[1],u=e[2]);let d;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,s.jsx)(n,{children:(0,s.jsxs)(r,{children:[t,(0,s.jsxs)(`div`,{className:`space-y-6`,children:[c,u,(0,s.jsx)(`div`,{className:`space-y-6`,children:[1,2].map(l)})]})]})}),e[3]=d):d=e[3],d}function l(e){return(0,s.jsxs)(`div`,{className:`space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,s.jsx)(a,{className:`h-8 w-8 rounded-full`}),(0,s.jsx)(a,{className:`h-6 w-36`})]}),(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,s.jsx)(a,{className:`h-5 w-32`}),(0,s.jsx)(a,{className:`h-8 w-28`})]}),(0,s.jsx)(`div`,{className:`border border-border rounded-md overflow-hidden`,children:[1,2,3,4,5].map(u)})]},e)}function u(e){return(0,s.jsxs)(`div`,{className:`flex items-center gap-3 p-3 border-b border-border last:border-b-0`,children:[(0,s.jsx)(a,{className:`h-4 w-4 rounded-sm`}),(0,s.jsx)(a,{className:`h-4 flex-1 max-w-xs`}),(0,s.jsx)(a,{className:`h-3 w-24`})]},e)}export{c as t};
1
+ import{Ai as e,_o as t}from"./dialogs-config-I0_cSU2z.js";import{D as n,E as r,S as i}from"./history-view-Be-1C1tJ.js";import{t as a}from"./skeleton-iEZ-dj1s.js";var o=t(),s=e();function c(){let e=(0,o.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,s.jsx)(i,{title:`Models`,description:`View and manage available models from your configured providers.`}),e[0]=t):t=e[0];let c,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,s.jsx)(a,{className:`h-10 w-full`}),u=(0,s.jsx)(a,{className:`h-9 w-48`}),e[1]=c,e[2]=u):(c=e[1],u=e[2]);let d;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,s.jsx)(n,{children:(0,s.jsxs)(r,{children:[t,(0,s.jsxs)(`div`,{className:`space-y-6`,children:[c,u,(0,s.jsx)(`div`,{className:`space-y-6`,children:[1,2].map(l)})]})]})}),e[3]=d):d=e[3],d}function l(e){return(0,s.jsxs)(`div`,{className:`space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,s.jsx)(a,{className:`h-8 w-8 rounded-full`}),(0,s.jsx)(a,{className:`h-6 w-36`})]}),(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,s.jsx)(a,{className:`h-5 w-32`}),(0,s.jsx)(a,{className:`h-8 w-28`})]}),(0,s.jsx)(`div`,{className:`border border-border rounded-md overflow-hidden`,children:[1,2,3,4,5].map(u)})]},e)}function u(e){return(0,s.jsxs)(`div`,{className:`flex items-center gap-3 p-3 border-b border-border last:border-b-0`,children:[(0,s.jsx)(a,{className:`h-4 w-4 rounded-sm`}),(0,s.jsx)(a,{className:`h-4 flex-1 max-w-xs`}),(0,s.jsx)(a,{className:`h-3 w-24`})]},e)}export{c as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,B as n,Ci as r,H as i,Ja as a,Tt as o,U as s,V as c,W as l,_o as u,dr as d,fr as f,go as p,li as m,mr as h,pr as g,qi as _,si as v,ui as y,wt as b,yo as x,z as S}from"./dialogs-config-I0_cSU2z.js";import{l as C,n as w}from"./onboarding-CgP4bJ5F.js";import{C as T,D as E,E as D,S as O,T as k,a as A,l as j,n as M,o as N,x as ee}from"./history-view-Be-1C1tJ.js";import{c as P,l as F,o as I,s as L}from"./index-DVXbmgHY.js";import{a as R,o as z}from"./settings-list-BCoqXa_X.js";import{t as B}from"./settings-models-skeleton-DsWpzWOw.js";var V=e(x(),1),H=u();function U(e){return`settings-models:coding:${e}`}function W(e){return`settings-models:image:${e}`}async function G(){let e=(await o()).filter(e=>e.apiKey),t={};e.forEach(e=>{t[e.slug]=`alphabetical`});let n={},r={};return await Promise.all(e.map(async e=>{try{let t=await l(e.slug);n[e.slug]=t.models,r[e.slug]=new Set(t.enabledModelIds)}catch(t){console.error(`Failed to load models for ${e.slug}:`,t),n[e.slug]=[],r[e.slug]=new Set}})),{providers:e,allModels:n,enabledModelIds:r,providerSortOptions:t}}async function K(e){let t=e.filter(e=>e.name.toLowerCase()===`openrouter`),n={},r={};return await Promise.all(t.map(async e=>{try{let t=await s(e.slug);n[e.slug]=t.models,r[e.slug]=new Set(t.enabledModelIds)}catch(t){console.error(`Failed to load image models for ${e.slug}:`,t),n[e.slug]=[],r[e.slug]=new Set}})),{allImageModels:n,enabledImageModelIds:r}}var q=t();function J({providers:e,globalSearchQuery:t,providerSortOptions:n,setProviderSortOptions:i,filterAndSortModels:o,getModelDisplayName:s,onSaveStatus:l}){let u=A(W(0),()=>K(e)),[_]=(0,V.useState)(u.allImageModels),[x,C]=(0,V.useState)(u.enabledImageModelIds);async function E(e,t){try{x[e]?.has(t)?(await S(e,t),C(n=>{let r=new Set(n[e]??[]);return r.delete(t),{...n,[e]:r}})):(await c(e,t),C(n=>({...n,[e]:new Set([...n[e]||[],t])}))),l(`Model preferences saved successfully`)}catch(e){l(e instanceof Error?e.message:`Failed to save model changes`)}}async function D(e,t){let n=_[e],r=x[e];if(n)for(let i of n)r?.has(i.id)!==t&&await E(e,i.id)}return(0,q.jsx)(`div`,{className:`space-y-6`,children:e.filter(e=>e.name.toLowerCase()===`openrouter`).map(e=>{let c=_[e.slug]||[],l=x[e.slug]||new Set,u=n[e.slug]||`alphabetical`,S=o(c,l,u);return S.length===0&&t?null:(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden`,children:(0,q.jsx)(`img`,{src:b(e.slug),alt:`${e.name} logo`,className:`h-5 w-5 dark:invert`,onError:e=>{e.target.style.display=`none`;let t=e.target.parentElement;t&&(t.classList.remove(`overflow-hidden`),t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-muted-foreground"><path d="M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5"/><path d="M8.5 8.5a2.5 2.5 0 0 0 0 5"/><path d="M15.5 15.5a2.5 2.5 0 0 0 0-5"/></svg>`)}})}),(0,q.jsx)(T,{title:e.name,className:`mb-0`})]}),S.length>0&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(w,{id:`select-all-image-${e.slug}`,checked:S.every(e=>l.has(e.id)),onCheckedChange:t=>void D(e.slug,t===!0)}),(0,q.jsx)(`label`,{htmlFor:`select-all-image-${e.slug}`,className:m(r.body,`cursor-pointer whitespace-nowrap`),children:`Select all models`})]}),(0,q.jsx)(g,{children:(0,q.jsxs)(`div`,{className:`flex items-center rounded-md border border-border p-0.5`,children:[(0,q.jsxs)(d,{children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(v,{type:`button`,variant:u===`alphabetical`?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>i(t=>({...t,[e.slug]:`alphabetical`})),children:(0,q.jsx)(p,{className:`h-4 w-4`})})}),(0,q.jsx)(f,{children:`Sort A–Z`})]}),(0,q.jsxs)(d,{children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(v,{type:`button`,variant:u===`price-low`||u===`price-high`?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>i(t=>({...t,[e.slug]:`price-low`})),children:(0,q.jsx)(a,{className:`h-4 w-4`})})}),(0,q.jsx)(f,{children:`Sort by price`})]})]})})]}),S.length===0?(0,q.jsx)(z,{message:t?`No models matching your search.`:`No image models available for this provider.`}):(0,q.jsx)(g,{children:(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-0 border border-border rounded-md overflow-hidden`,children:S.map(t=>{let n=l.has(t.id),i=t.pricing;return(0,q.jsxs)(`div`,{className:`flex items-center space-x-3 p-3 hover:bg-muted/30 transition-colors cursor-default border-b border-border last:border-b-0`,children:[(0,q.jsx)(w,{id:`image-${t.id}`,checked:n,onCheckedChange:()=>void E(e.slug,t.id),className:`mt-0`}),(0,q.jsxs)(`div`,{className:`flex-1 flex items-center justify-between gap-3 leading-none`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:(0,q.jsx)(`label`,{htmlFor:`image-${t.id}`,className:m(r.label,`peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer truncate`),children:s(t)})}),i&&(0,q.jsx)(`span`,{className:m(r.compact,`text-muted-foreground whitespace-nowrap flex-shrink-0`),children:(i.prompt??0)===0&&(i.completion??0)===0?``:`$${y(i.prompt??0)} in | $${y(i.completion??0)} out`})]})]},t.id)})})})]},e.slug)})})}function Y({loadVersion:e}){let t=A(U(e),()=>G()),o=t.providers,[s]=(0,V.useState)(t.allModels),[c,l]=(0,V.useState)(t.enabledModelIds),[u,x]=(0,V.useState)(`coding`),[S,M]=(0,V.useState)(``),[N,B]=(0,V.useState)(t.providerSortOptions),[H,W]=(0,V.useState)(``),K=e=>C(e.id),Y=async(e,t)=>{try{c[e]?.has(t)?(await n(e,t),l(n=>{let r=new Set(n[e]??[]);return r.delete(t),{...n,[e]:r}})):(await i(e,t),l(n=>({...n,[e]:new Set([...n[e]||[],t])}))),W(`Model preferences saved successfully`),setTimeout(()=>W(``),3e3)}catch(e){W(e instanceof Error?e.message:`Failed to save model changes`)}},X=async(e,t)=>{let n=s[e],r=c[e];if(n)for(let i of n)r?.has(i.id)!==t&&await Y(e,i.id)},Z=e=>e?e<20?1:e<30?2:e<40?3:e<50?4:5:0,Q=({codingIndex:e,modelName:t})=>{let n=Z(e);return n===0?null:(0,q.jsx)(g,{children:(0,q.jsxs)(d,{children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(`div`,{className:`flex items-center gap-0.5`,children:[1,2,3,4,5].map(e=>(0,q.jsx)(_,{className:`h-3 w-3 ${e<=n?`fill-yellow-400 text-yellow-400`:`text-gray-300`}`},e))})}),(0,q.jsx)(f,{children:(0,q.jsxs)(`p`,{className:r.body,children:[t,` was indexed `,e,` for coding intelligence`]})})]})})},$=(e,t,n)=>{let r=S.toLowerCase();return e.filter(e=>{let t=K(e);return e.name.toLowerCase().includes(r)||e.id.toLowerCase().includes(r)||t.toLowerCase().includes(r)}).sort((e,r)=>{let i=+!t.has(e.id),a=+!t.has(r.id);if(i!==a)return i-a;if(n===`price-low`){let t=!!e.pricing;return t===!!r.pricing?!e.pricing||!r.pricing?0:((e.pricing.prompt??0)+(e.pricing.completion??0))/2-((r.pricing.prompt??0)+(r.pricing.completion??0))/2:t?-1:1}if(n===`price-high`){let t=!!e.pricing;if(t!==!!r.pricing)return t?-1:1;if(!e.pricing||!r.pricing)return 0;let n=((e.pricing.prompt??0)+(e.pricing.completion??0))/2;return((r.pricing.prompt??0)+(r.pricing.completion??0))/2-n}if(n===`coding-index`){let t=e.coding_index!==void 0&&e.coding_index!==null;return t===(r.coding_index!==void 0&&r.coding_index!==null)?e.coding_index==null||r.coding_index==null?0:r.coding_index-e.coding_index:t?-1:1}return K(e).localeCompare(K(r))})};return o.length===0?(0,q.jsx)(k,{title:`No providers configured`,children:`Configure a provider with an API key to view available models.`}):(0,q.jsx)(E,{children:(0,q.jsxs)(D,{children:[(0,q.jsx)(O,{title:`Models`,description:`View and manage available models from your configured providers.`}),(0,q.jsxs)(`div`,{className:`space-y-6`,children:[(0,q.jsx)(R,{placeholder:`Search models across all providers...`,value:S,onChange:M}),(0,q.jsxs)(I,{value:u,onValueChange:e=>{x(e),M(``)},children:[(0,q.jsxs)(P,{className:`mb-4`,children:[(0,q.jsx)(F,{value:`coding`,children:`Coding`}),o.some(e=>e.name.toLowerCase()===`openrouter`)&&(0,q.jsx)(F,{value:`image`,children:`Image`})]}),(0,q.jsx)(L,{value:`coding`,children:(0,q.jsx)(`div`,{className:`space-y-6`,children:o.map(e=>{let t=s[e.slug]||[],n=c[e.slug]||new Set,i=N[e.slug]||`alphabetical`,o=$(t,n,i);return o.length===0&&S?null:(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden`,children:(0,q.jsx)(`img`,{src:b(e.slug),alt:`${e.name} logo`,className:`h-5 w-5 dark:invert`,onError:e=>{e.target.style.display=`none`;let t=e.target.parentElement;t&&(t.classList.remove(`overflow-hidden`),t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-muted-foreground"><path d="M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5"/><path d="M8.5 8.5a2.5 2.5 0 0 0 0 5"/><path d="M15.5 15.5a2.5 2.5 0 0 0 0-5"/></svg>`)}})}),(0,q.jsx)(T,{title:e.name,className:`mb-0`})]}),o.length>0&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(w,{id:`select-all-${e.slug}`,checked:o.every(e=>n.has(e.id)),onCheckedChange:t=>X(e.slug,t===!0)}),(0,q.jsx)(`label`,{htmlFor:`select-all-${e.slug}`,className:m(r.body,`cursor-pointer whitespace-nowrap`),children:`Select all models`})]}),(0,q.jsx)(g,{children:(0,q.jsxs)(`div`,{className:`flex items-center rounded-md border border-border p-0.5`,children:[(0,q.jsxs)(d,{children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(v,{type:`button`,variant:i===`alphabetical`?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>B(t=>({...t,[e.slug]:`alphabetical`})),children:(0,q.jsx)(p,{className:`h-4 w-4`})})}),(0,q.jsx)(f,{children:`Sort A–Z`})]}),(0,q.jsxs)(d,{children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(v,{type:`button`,variant:i===`price-low`||i===`price-high`?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>B(t=>({...t,[e.slug]:`price-low`})),children:(0,q.jsx)(a,{className:`h-4 w-4`})})}),(0,q.jsx)(f,{children:`Sort by price`})]}),(0,q.jsxs)(d,{children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(v,{type:`button`,variant:i===`coding-index`?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>B(t=>({...t,[e.slug]:`coding-index`})),children:(0,q.jsx)(_,{className:`h-4 w-4`})})}),(0,q.jsx)(f,{children:`Sort by coding intelligence`})]})]})})]}),o.length===0?(0,q.jsx)(z,{message:S?`No models matching your search.`:`No models available for this provider.`}):(0,q.jsx)(g,{children:(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-0 border border-border rounded-md overflow-hidden`,children:o.map(t=>{let a=n.has(t.id),o=t.pricing;return(0,q.jsxs)(`div`,{className:`flex items-center space-x-3 p-3 hover:bg-muted/30 transition-colors cursor-default border-b border-border last:border-b-0`,children:[(0,q.jsx)(w,{id:t.id,checked:a,onCheckedChange:()=>Y(e.slug,t.id),className:`mt-0`}),(0,q.jsxs)(`div`,{className:`flex-1 flex items-center justify-between gap-3 leading-none`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:(0,q.jsx)(`label`,{htmlFor:t.id,className:m(r.body,`peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer truncate`),children:K(t)})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[i===`coding-index`&&(0,q.jsx)(Q,{codingIndex:t.coding_index,modelName:K(t)}),o&&(0,q.jsx)(`span`,{className:m(r.compact,`text-muted-foreground whitespace-nowrap`),children:(o.prompt??0)===0&&(o.completion??0)===0?``:`$${y(o.prompt??0)} in | $${y(o.completion??0)} out`})]})]})]},t.id)})})})]},e.slug)})})}),(0,q.jsx)(L,{value:`image`,children:u===`image`?(0,q.jsx)(V.Suspense,{fallback:(0,q.jsx)(j,{className:`py-12`,size:`sm`}),children:(0,q.jsx)(J,{providers:o,globalSearchQuery:S,providerSortOptions:N,setProviderSortOptions:B,filterAndSortModels:$,getModelDisplayName:K,onSaveStatus:e=>{W(e),e.includes(`Failed`)||setTimeout(()=>W(``),3e3)}})}):null})]}),H&&(0,q.jsx)(ee,{variant:H.includes(`error`)||H.includes(`Failed`)?`error`:`success`,className:`mb-0`,children:H})]})]})})}function X(){let e=(0,H.c)(8),[t,n]=(0,V.useState)(0),r;e[0]===t?r=e[1]:(r=function(){N(U(t)),n(Q)},e[0]=t,e[1]=r);let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,q.jsx)(B,{}),e[2]=a):a=e[2];let o;e[3]===t?o=e[4]:(o=(0,q.jsx)(V.Suspense,{fallback:a,children:(0,q.jsx)(Y,{loadVersion:t},t)}),e[3]=t,e[4]=o);let s;return e[5]!==i||e[6]!==o?(s=(0,q.jsx)(M,{fallbackTitle:`Failed to load models`,onRetry:i,renderFallback:Z,children:o}),e[5]=i,e[6]=o,e[7]=s):s=e[7],s}function Z(e,t){return(0,q.jsx)(k,{title:`Failed to load models`,action:(0,q.jsx)(v,{variant:`outline`,onClick:t,children:`Retry`}),children:e.message})}function Q(e){return e+1}export{X as SettingsModelsView,X as default};
@@ -0,0 +1,8 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Dr as r,Er as i,Gt as a,Ha as o,Hi as s,L as c,P as l,Tr as u,_o as d,ao as f,cn as p,jt as m,li as h,pt as g,ra as ee,si as _,vt as te,wa as v,yo as y}from"./dialogs-config-I0_cSU2z.js";import{n as b,t as x}from"./react-vendor-Do-APsQ6.js";import{A as ne,C as S,D as C,E as w,F as re,M as T,N as E,O as D,P as ie,S as O,T as k,b as A,j,k as ae,x as oe,y as M}from"./history-view-Be-1C1tJ.js";import{C as se,E as N,O as P,j as F}from"./index-DVXbmgHY.js";import{t as I}from"./skeleton-iEZ-dj1s.js";import{a as ce,i as L,n as R,r as z,t as B}from"./settings-list-BCoqXa_X.js";import{t as V}from"./mcp-server-card-bNNoXKsW.js";var H=d(),U=e(y(),1),W=t(),G=U.forwardRef((e,t)=>{let n=(0,H.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=h(`peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,W.jsx)(b,{className:h(`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`)}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,W.jsx)(x,{className:a,...i,ref:t,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});G.displayName=x.displayName;function le({threadId:e,onRuleCreated:t}){let[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1),[l,d]=(0,U.useState)(!1),m=r.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),g=m.length>0&&m.length<=64;return e?(0,W.jsx)(C,{children:(0,W.jsxs)(M,{children:[(0,W.jsx)(O,{title:`Add Rule`,description:`Create a new agent rule. The rule will be saved as a .md file in the .agents/rules folder.`}),(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(A,{title:`Rule Name`,children:[(0,W.jsx)(u,{id:`ruleName`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. Code Style Guide`,disabled:l}),r?(0,W.jsxs)(`p`,{className:h(n.caption,`mt-2`),children:[`File name: `,(0,W.jsxs)(`span`,{className:`font-mono`,children:[m||`...`,`.md`]})]}):null]}),(0,W.jsx)(A,{title:`Description`,children:(0,W.jsx)(P,{id:`ruleDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Describe when Tarsk should apply this rule...`,className:`resize-none min-h-[120px]`,disabled:l})}),(0,W.jsx)(A,{title:`Always Apply`,description:s?`This rule will be automatically added to context for all conversations.`:`Only the rule description will be added to context, allowing the agent to read the rule file when needed.`,action:(0,W.jsx)(G,{id:`alwaysApply`,checked:s,onCheckedChange:c,disabled:l})}),(0,W.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,W.jsx)(_,{onClick:async()=>{if(!(!g||!e)){d(!0);try{let n=`---
2
+ description: ${a.trim()}
3
+ alwaysApply: ${s}
4
+ ---
5
+
6
+ Place your rule instructions here as markdown.
7
+ `;await p(e,`.agents/rules/${m}.md`,n),N({title:`Rule created`,description:`Rule '${m}' was created successfully.`}),i(``),o(``),c(!1),t?.(m)}catch(e){N({title:`Error`,description:e instanceof Error?e.message:`Failed to create rule`,variant:`destructive`})}finally{d(!1)}}},disabled:!g||!a.trim()||l,children:l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(v,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,W.jsxs)(W.Fragment,{children:[`Continue`,(0,W.jsx)(f,{className:`ml-2 h-4 w-4`})]})})})]})]})}):(0,W.jsx)(k,{title:`No thread selected`,children:`Please select a thread to add a rule.`})}function K(e){let t=[];for(let n of e)n.type===`file`&&n.path.startsWith(`.agents/rules/`)&&t.push(n),n.children&&n.children.length>0&&t.push(...K(n.children));return t}function q(){let e=F(e=>e.selectedProjectId),t=F(e=>e.selectedThreadId),{setActiveMainTab:n,setPendingExplorerPath:u,triggerExplorerRefresh:d,setExplorerClearPath:f}=se(),[h,v]=(0,U.useState)([]),[y,b]=(0,U.useState)(!1),[x,A]=(0,U.useState)(!1),[M,P]=(0,U.useState)(null),[H,G]=(0,U.useState)(!1),[q,J]=(0,U.useState)([]),[Y,X]=(0,U.useState)(new Set),[Z,ue]=(0,U.useState)(``),Q=(0,U.useCallback)(async()=>{if(e){b(!0);try{let n=K(await te(e));if(t)try{let e=K(await m(t)),r=new Set(n.map(e=>e.path));for(let t of e)r.has(t.path)||n.push(t)}catch{}v(n),X(new Set(n.map(e=>e.path)))}catch{v([]),X(new Set)}finally{b(!1)}}},[e,t]);(0,U.useEffect)(()=>{Q()},[Q]),(0,U.useEffect)(()=>{g().then(J).catch(()=>J([]))},[]);let de=(0,U.useCallback)(async n=>{if(!e)return;let r=n.name,i=n.path;G(!0);try{try{await l(e,i)}catch{if(t)await c(t,i);else throw Error(`No thread selected to delete from`)}f(i),d(),X(e=>{let t=new Set(e);return t.delete(i),t}),N({title:`Rule removed`,description:r}),P(null),await Q()}catch(e){N({title:`Error`,description:e instanceof Error?e.message:`Failed to remove rule`,variant:`destructive`})}finally{G(!1)}},[e,t,Q,d,f]),fe=(0,U.useCallback)(e=>{u(e),n(`explorer`)},[u,n]),pe=(0,U.useCallback)(async e=>{let n=`.agents/rules/${e.name}.md`;if(!(!t||Y.has(n)))try{e.gitHubRepo&&e.gitHubFolder?await a(t,e.gitHubRepo,e.gitHubFolder,`.agents/rules`):await p(t,n,[`---`,`description: ${e.description}`,`alwaysApply: ${e.alwaysApply??!1}`,`---`,``,e.content].join(`
8
+ `)),X(e=>new Set(e).add(n)),d(),Q(),N({title:`Rule installed`,description:e.name})}catch(e){N({title:`Error`,description:e instanceof Error?e.message:`Failed to install rule`,variant:`destructive`})}},[t,Y,d,Q]),$=Z.trim()?q.filter(e=>e.name.toLowerCase().includes(Z.toLowerCase())||e.description.toLowerCase().includes(Z.toLowerCase())):q;return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(C,{children:(0,W.jsxs)(w,{children:[(0,W.jsx)(O,{title:`Rules`,description:`Manage agent rules. Rules define coding standards and project-wide guidelines.`,action:(0,W.jsx)(_,{onClick:()=>A(!0),disabled:!t,children:`Add Rule`})}),!t&&(0,W.jsx)(oe,{children:`Select a thread to add or install rules.`}),(0,W.jsx)(S,{title:`Installed`}),y?(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(I,{className:`h-20 w-full`}),(0,W.jsx)(I,{className:`h-20 w-full`})]}):h.length===0?(0,W.jsx)(B,{icon:ee,title:`No rules installed`,description:`Add rules to enforce coding standards and project conventions.`}):(0,W.jsx)(`div`,{className:`space-y-3 mb-8`,children:h.map(e=>(0,W.jsx)(R,{title:e.name,subtitle:e.path,subtitleMono:!0,actions:[{label:`View in explorer`,icon:(0,W.jsx)(o,{className:`h-4 w-4`}),onClick:()=>fe(e.path)},{label:`Delete rule`,icon:(0,W.jsx)(s,{className:`h-4 w-4`}),onClick:()=>P(e),destructive:!0}]},e.id))}),(0,W.jsx)(S,{title:`Available`,className:`mb-0`}),(0,W.jsx)(ce,{placeholder:`Search available rules...`,value:Z,onChange:ue}),q.length===0?(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(I,{className:`h-20 w-full`}),(0,W.jsx)(I,{className:`h-20 w-full`})]}):$.length===0?(0,W.jsx)(L,{searchQuery:Z,emptyLabel:`No available rules found.`}):(0,W.jsx)(z,{children:$.map(e=>{let t=`.agents/rules/${e.name}.md`,n=Y.has(t);return(0,W.jsx)(V,{name:e.name,description:e.description,installed:n,onClick:()=>{n||pe(e)},showInstalledControls:!1},e.id)})})]})}),(0,W.jsx)(i,{open:x,onOpenChange:A,children:(0,W.jsx)(r,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,W.jsx)(le,{threadId:t,onRuleCreated:()=>{A(!1),Q(),d()}})})}),(0,W.jsx)(D,{open:M!==null,onOpenChange:e=>!e&&P(null),children:(0,W.jsxs)(j,{children:[(0,W.jsxs)(ie,{children:[(0,W.jsx)(re,{children:`Delete Rule`}),(0,W.jsxs)(T,{children:[`Are you sure you want to delete the rule "`,M?.name,`"? This action cannot be undone.`]})]}),(0,W.jsxs)(E,{children:[(0,W.jsx)(ne,{children:`Cancel`}),(0,W.jsx)(ae,{onClick:()=>M&&void de(M),disabled:H,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:H?`Deleting...`:`Delete`})]})]})})]}):(0,W.jsx)(k,{children:`Select a project to manage rules.`})}export{q as SettingsRulesView,q as default};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Dr as r,Er as i,Gt as a,Ha as o,Hi as s,Ii as c,L as l,P as u,Tr as d,ao as f,cn as ee,jt as te,k as p,li as m,mt as h,si as g,vt as ne,wa as _,yo as v}from"./dialogs-config-I0_cSU2z.js";import{A as y,C as b,D as x,E as S,F as C,M as re,N as ie,O as ae,P as oe,S as w,T,b as E,j as D,k as se,x as ce,y as O}from"./history-view-Be-1C1tJ.js";import{C as le,E as k,O as A,j}from"./index-DVXbmgHY.js";import{t as M}from"./skeleton-iEZ-dj1s.js";import{a as N,i as P,n as F,r as I,t as L}from"./settings-list-BCoqXa_X.js";import{t as R}from"./mcp-server-card-bNNoXKsW.js";var z=e(v(),1),B=t();function V({threadId:e,onSkillCreated:t}){let[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(!1),l=r.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),u=l.length>0&&l.length<=64;return e?(0,B.jsx)(x,{children:(0,B.jsxs)(O,{children:[(0,B.jsx)(w,{title:`Add Skill`,description:`Create a new agent skill. The skill will be saved as a SKILL.md file in the .agents/skills folder.`}),(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(E,{title:`Skill Name`,children:[(0,B.jsx)(d,{id:`skillName`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. Code Review`,disabled:s}),r?(0,B.jsxs)(`p`,{className:m(n.caption,`mt-2`),children:[`Folder name: `,(0,B.jsx)(`span`,{className:`font-mono`,children:l||`...`})]}):null]}),(0,B.jsx)(E,{title:`Description`,children:(0,B.jsx)(A,{id:`skillDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Describe when Tarsk should apply this skill`,className:`resize-none min-h-[120px]`,disabled:s})}),(0,B.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,B.jsx)(g,{onClick:async()=>{if(!(!u||!a.trim()||!e)){c(!0);try{let n=await p(e,l,a.trim());k({title:`Skill created`,description:`Skill '${l}' was created successfully.`}),i(``),o(``),t?.(n.path,`SKILL.md`)}catch(e){k({title:`Error`,description:e instanceof Error?e.message:`Failed to create skill`,variant:`destructive`})}finally{c(!1)}}},disabled:!u||!a.trim()||s,children:s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,B.jsxs)(B.Fragment,{children:[`Continue`,(0,B.jsx)(f,{className:`ml-2 h-4 w-4`})]})})})]})]})}):(0,B.jsx)(T,{title:`No thread selected`,children:`Please select a thread to add a skill.`})}function H(e){let t=[];for(let n of e){if(n.path===`.agents/skills`&&n.type===`folder`&&n.children)for(let e of n.children)e.type===`folder`&&t.push(e);n.children&&n.children.length>0&&t.push(...H(n.children))}return t}function U(){let e=j(e=>e.selectedProjectId),t=j(e=>e.selectedThreadId),{setActiveMainTab:n,setPendingExplorerPath:d,triggerExplorerRefresh:f,setExplorerClearPath:p}=le(),[m,_]=(0,z.useState)([]),[v,E]=(0,z.useState)(!1),[O,A]=(0,z.useState)(!1),[U,W]=(0,z.useState)(null),[G,K]=(0,z.useState)(!1),[q,J]=(0,z.useState)([]),[Y,X]=(0,z.useState)(new Set),[Z,ue]=(0,z.useState)(``),Q=(0,z.useCallback)(async()=>{if(e){E(!0);try{let n=H(await ne(e));if(t)try{let e=H(await te(t)),r=new Set(n.map(e=>e.path));for(let t of e)r.has(t.path)||n.push(t)}catch{}_(n),X(new Set(n.map(e=>`${e.path}/SKILL.md`)))}catch{_([]),X(new Set)}finally{E(!1)}}},[e,t]);(0,z.useEffect)(()=>{Q()},[Q]),(0,z.useEffect)(()=>{h().then(J).catch(()=>J([]))},[]);let de=(0,z.useCallback)(async n=>{if(!e)return;let r=n.name,i=n.path;K(!0);try{try{await u(e,i)}catch{if(t)await l(t,i);else throw Error(`No thread selected to delete from`)}p(i),f(),X(e=>{let t=new Set(e);return t.delete(`${i}/SKILL.md`),t}),k({title:`Skill removed`,description:r}),W(null),await Q()}catch(e){k({title:`Error`,description:e instanceof Error?e.message:`Failed to remove skill`,variant:`destructive`})}finally{K(!1)}},[e,t,Q,f,p]),fe=(0,z.useCallback)(e=>{d(`${e}/SKILL.md`),n(`explorer`)},[d,n]),pe=(0,z.useCallback)(async e=>{let n=`.agents/skills/${e.id}/SKILL.md`;if(!(!t||Y.has(n)))try{if(e.gitHubRepo&&e.gitHubFolder)await a(t,e.gitHubRepo,e.gitHubFolder,`.agents/skills/${e.id}`);else{let r=[`---`,`name: ${e.id}`,`description: ${e.description}`];e.allowedTools&&r.push(`allowed-tools: ${e.allowedTools}`),e.license&&r.push(`license: ${e.license}`),r.push(`---`,``,e.instructions),await ee(t,n,r.join(`
2
+ `))}X(e=>new Set(e).add(n)),f(),Q(),k({title:`Skill installed`,description:e.name})}catch(e){k({title:`Error`,description:e instanceof Error?e.message:`Failed to install skill`,variant:`destructive`})}},[t,Y,f,Q]),$=Z.trim()?q.filter(e=>e.name.toLowerCase().includes(Z.toLowerCase())||e.description.toLowerCase().includes(Z.toLowerCase())):q;return e?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(x,{children:(0,B.jsxs)(S,{children:[(0,B.jsx)(w,{title:`Skills`,description:`Manage agent skills. Skills are reusable instruction sets that guide agent behavior.`,action:(0,B.jsx)(g,{onClick:()=>A(!0),disabled:!t,children:`Add Skill`})}),!t&&(0,B.jsx)(ce,{children:`Select a thread to add or install skills.`}),(0,B.jsx)(b,{title:`Installed`}),v?(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(M,{className:`h-20 w-full`}),(0,B.jsx)(M,{className:`h-20 w-full`})]}):m.length===0?(0,B.jsx)(L,{icon:c,title:`No skills installed`,description:`Add skills to extend agent capabilities with reusable instructions.`}):(0,B.jsx)(`div`,{className:`space-y-3 mb-8`,children:m.map(e=>(0,B.jsx)(F,{title:e.name,subtitle:e.path,subtitleMono:!0,actions:[{label:`View in explorer`,icon:(0,B.jsx)(o,{className:`h-4 w-4`}),onClick:()=>fe(e.path)},{label:`Delete skill`,icon:(0,B.jsx)(s,{className:`h-4 w-4`}),onClick:()=>W(e),destructive:!0}]},e.id))}),(0,B.jsx)(b,{title:`Available`,className:`mb-0`}),(0,B.jsx)(N,{placeholder:`Search available skills...`,value:Z,onChange:ue}),q.length===0?(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(M,{className:`h-20 w-full`}),(0,B.jsx)(M,{className:`h-20 w-full`})]}):$.length===0?(0,B.jsx)(P,{searchQuery:Z,emptyLabel:`No available skills found.`}):(0,B.jsx)(I,{children:$.map(e=>{let t=`.agents/skills/${e.id}/SKILL.md`,n=Y.has(t);return(0,B.jsx)(R,{name:e.name,description:e.description,installed:n,onClick:()=>{n||pe(e)},showInstalledControls:!1},e.id)})})]})}),(0,B.jsx)(i,{open:O,onOpenChange:A,children:(0,B.jsx)(r,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,B.jsx)(V,{threadId:t,onSkillCreated:()=>{A(!1),Q(),f()}})})}),(0,B.jsx)(ae,{open:U!==null,onOpenChange:e=>!e&&W(null),children:(0,B.jsxs)(D,{children:[(0,B.jsxs)(oe,{children:[(0,B.jsx)(C,{children:`Delete Skill`}),(0,B.jsxs)(re,{children:[`Are you sure you want to delete the skill "`,U?.name,`"? This action cannot be undone.`]})]}),(0,B.jsxs)(ie,{children:[(0,B.jsx)(y,{children:`Cancel`}),(0,B.jsx)(se,{onClick:()=>U&&void de(U),disabled:G,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:G?`Deleting...`:`Delete`})]})]})})]}):(0,B.jsx)(T,{children:`Select a project to manage skills.`})}export{U as SettingsSkillsView,U as default};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Cr as r,Dr as i,Dt as a,E as o,Er as s,F as c,Gt as l,Ha as u,Hi as d,Tr as f,Wi as p,ao as m,ht as h,li as g,si as _,wa as v,yo as y}from"./dialogs-config-I0_cSU2z.js";import{A as b,C as x,D as S,E as C,F as w,M as T,N as E,O as D,P as O,S as k,T as A,b as j,j as ee,k as te,x as ne,y as M}from"./history-view-Be-1C1tJ.js";import{C as N,E as P,j as F}from"./index-DVXbmgHY.js";import{t as I}from"./skeleton-iEZ-dj1s.js";import{n as L,t as R}from"./radio-group-ZjNXbvW6.js";import{a as re,i as ie,n as ae,r as oe,t as se}from"./settings-list-BCoqXa_X.js";import{t as ce}from"./mcp-server-card-bNNoXKsW.js";var z=e(y(),1),B=t();function V({projectId:e,threadId:t,onCommandCreated:i}){let[a,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(``),[p,h]=(0,z.useState)(`default`),[y,b]=(0,z.useState)(!1),x=a.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),C=x.length>0&&x.length<=64;return e?(0,B.jsx)(S,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(k,{title:`Add Slash Command`,description:`Create a new slash command. The command will be saved as a .md file in the ~/.agents/commands folder.`}),(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(j,{title:`Command Name`,children:[(0,B.jsx)(f,{id:`commandName`,value:a,onChange:e=>s(e.target.value),placeholder:`e.g. review`,disabled:y}),a?(0,B.jsxs)(`p`,{className:g(n.caption,`mt-2`),children:[`Command: `,(0,B.jsxs)(`span`,{className:`font-mono`,children:[`/`,x||`...`]})]}):null]}),(0,B.jsx)(j,{title:`Description`,children:(0,B.jsx)(f,{id:`commandDescription`,value:c,onChange:e=>l(e.target.value),placeholder:`Brief description shown in autocomplete`,disabled:y})}),(0,B.jsx)(j,{title:`Argument Hint`,description:`Shows after the command name to guide users what to type`,children:(0,B.jsx)(f,{id:`argumentHint`,value:u,onChange:e=>d(e.target.value),placeholder:`e.g. <focus-area> or <branch-name>`,disabled:y})}),(0,B.jsx)(j,{title:`Mode`,description:p==="default"?`Standard chat mode`:`Activates plan mode when this command is used`,children:(0,B.jsxs)(R,{value:p,onValueChange:e=>h(e),className:`flex gap-4`,disabled:y,children:[(0,B.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,B.jsx)(L,{value:`default`,id:`mode-default`}),(0,B.jsx)(r,{htmlFor:`mode-default`,className:g(n.labelNormal,`cursor-pointer`),children:`Default`})]}),(0,B.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,B.jsx)(L,{value:`plan`,id:`mode-plan`}),(0,B.jsx)(r,{htmlFor:`mode-plan`,className:g(n.labelNormal,`cursor-pointer`),children:`Plan`})]})]})}),(0,B.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,B.jsx)(_,{onClick:async()=>{if(!(!C||!e)){b(!0);try{await o(x,``,{description:c.trim()||void 0,argumentHint:u.trim()||void 0,mode:p===`plan`?`plan`:void 0},`project`,t??void 0),P({title:`Command created`,description:`Command '/${x}' was created successfully.`}),s(``),l(``),d(``),h(`default`),i?.(x)}catch(e){P({title:`Error`,description:e instanceof Error?e.message:`Failed to create command`,variant:`destructive`})}finally{b(!1)}}},disabled:!C||y,children:y?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(v,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,B.jsxs)(B.Fragment,{children:[`Continue`,(0,B.jsx)(m,{className:`ml-2 h-4 w-4`})]})})})]})]})}):(0,B.jsx)(A,{title:`No project selected`,children:`Please select a project to add a slash command.`})}function H(){let e=F(e=>e.selectedProjectId),t=F(e=>e.selectedThreadId),{setActiveMainTab:r,setPendingExplorerPath:f,triggerExplorerRefresh:m,setExplorerClearPath:v}=N(),[y,j]=(0,z.useState)([]),[M,L]=(0,z.useState)(!1),[R,H]=(0,z.useState)(!1),[U,W]=(0,z.useState)(null),[G,K]=(0,z.useState)(!1),[q,J]=(0,z.useState)([]),[Y,X]=(0,z.useState)(new Map),[Z,le]=(0,z.useState)(``),Q=(0,z.useCallback)(async()=>{if(t){L(!0);try{let e=await a(t);j(e.filter(e=>!e.isBuiltIn)),X(new Map(e.map(e=>[e.name,e.filePath])))}catch{j([]),X(new Map)}finally{L(!1)}}},[t]);(0,z.useEffect)(()=>{Q()},[Q]),(0,z.useEffect)(()=>{h().then(J).catch(()=>J([]))},[]);let ue=(0,z.useCallback)(async e=>{K(!0);try{await c(e.filePath),v(e.filePath),m(),X(t=>{let n=new Map(t);return n.delete(e.name),n}),P({title:`Command removed`,description:`/${e.name}`}),W(null),await Q()}catch(e){P({title:`Error`,description:e instanceof Error?e.message:`Failed to remove command`,variant:`destructive`})}finally{K(!1)}},[Q,m,v]),de=(0,z.useCallback)(e=>{f(e),r(`explorer`)},[f,r]),fe=(0,z.useCallback)(async e=>{if(!(!t||Y.has(e.name)))try{if(e.gitHubRepo&&e.gitHubFolder){let n=`.agents/commands`;await l(t,e.gitHubRepo,e.gitHubFolder,n);let r=`${n}/${e.name}.md`;X(t=>new Map(t).set(e.name,r))}else{let n=await o(e.name,e.content,{description:e.description,argumentHint:e.argumentHint},`project`,t);X(t=>new Map(t).set(e.name,n.filePath))}m(),Q(),P({title:`Command installed`,description:`/${e.name}`})}catch(e){P({title:`Error`,description:e instanceof Error?e.message:`Failed to install command`,variant:`destructive`})}},[t,Y,m,Q]),$=Z.trim()?q.filter(e=>e.name.toLowerCase().includes(Z.toLowerCase())||e.description.toLowerCase().includes(Z.toLowerCase())):q;return e?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(S,{children:(0,B.jsxs)(C,{children:[(0,B.jsx)(k,{title:`Slash Commands`,description:`Manage slash commands. Commands are quick actions available via / in chat.`,action:(0,B.jsx)(_,{onClick:()=>H(!0),disabled:!t,children:`Add Command`})}),!t&&(0,B.jsx)(ne,{children:`Select a thread to add or install slash commands.`}),(0,B.jsx)(x,{title:`Installed`}),M?(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(I,{className:`h-20 w-full`}),(0,B.jsx)(I,{className:`h-20 w-full`})]}):y.length===0?(0,B.jsx)(se,{icon:p,title:`No slash commands installed`,description:`Add slash commands to create quick actions in chat.`}):(0,B.jsx)(`div`,{className:`space-y-3 mb-8`,children:y.map(e=>(0,B.jsx)(ae,{title:`/${e.name}`,subtitle:e.metadata?.description||`No description`,badge:e.metadata?.mode?(0,B.jsx)(`span`,{className:g(n.compact,`bg-muted px-1.5 py-0.5 rounded flex-shrink-0`),children:e.metadata.mode}):void 0,actions:[{label:`View in explorer`,icon:(0,B.jsx)(u,{className:`h-4 w-4`}),onClick:()=>de(e.filePath)},{label:`Delete command`,icon:(0,B.jsx)(d,{className:`h-4 w-4`}),onClick:()=>W(e),destructive:!0}]},e.filePath))}),(0,B.jsx)(x,{title:`Available`,className:`mb-0`}),(0,B.jsx)(re,{placeholder:`Search available commands...`,value:Z,onChange:le}),q.length===0?(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(I,{className:`h-20 w-full`}),(0,B.jsx)(I,{className:`h-20 w-full`})]}):$.length===0?(0,B.jsx)(ie,{searchQuery:Z,emptyLabel:`No available commands found.`}):(0,B.jsx)(oe,{children:$.map(e=>{let t=Y.has(e.name);return(0,B.jsx)(ce,{name:`/${e.name}`,description:e.description,installed:t,onClick:()=>{t||fe(e)},showInstalledControls:!1},e.id)})})]})}),(0,B.jsx)(s,{open:R,onOpenChange:H,children:(0,B.jsx)(i,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,B.jsx)(V,{projectId:e,threadId:t,onCommandCreated:()=>{H(!1),Q(),m()}})})}),(0,B.jsx)(D,{open:U!==null,onOpenChange:e=>!e&&W(null),children:(0,B.jsxs)(ee,{children:[(0,B.jsxs)(O,{children:[(0,B.jsx)(w,{children:`Delete Slash Command`}),(0,B.jsxs)(T,{children:[`Are you sure you want to delete "/`,U?.name,`"? This action cannot be undone.`]})]}),(0,B.jsxs)(E,{children:[(0,B.jsx)(b,{children:`Cancel`}),(0,B.jsx)(te,{onClick:()=>U&&void ue(U),disabled:G,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:G?`Deleting...`:`Delete`})]})]})})]}):(0,B.jsx)(A,{children:`Select a project to manage slash commands.`})}export{H as SettingsSlashCommandsView,H as default};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Dr as r,Er as i,Gt as a,Ha as o,Hi as s,L as c,Li as l,O as u,P as d,Tr as f,ao as p,cn as m,dt as h,jt as ee,li as g,si as _,vt as te,wa as v,yo as y}from"./dialogs-config-I0_cSU2z.js";import{A as b,C as x,D as S,E as C,F as w,M as ne,N as re,O as ie,P as ae,S as T,T as E,b as D,j as O,k as oe,x as se,y as k}from"./history-view-Be-1C1tJ.js";import{C as ce,E as A,O as j,j as M}from"./index-DVXbmgHY.js";import{t as N}from"./skeleton-iEZ-dj1s.js";import{a as le,i as ue,n as P,r as F,t as I}from"./settings-list-BCoqXa_X.js";import{t as L}from"./mcp-server-card-bNNoXKsW.js";var R=e(y(),1),z=t();function B({threadId:e,onAgentCreated:t}){let[r,i]=(0,R.useState)(``),[a,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(``),[l,d]=(0,R.useState)(!1),m=r.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),h=m.length>0&&m.length<=64;return e?(0,z.jsx)(S,{children:(0,z.jsxs)(k,{children:[(0,z.jsx)(T,{title:`Add Agent`,description:`Create a new subagent. The agent will be saved as an AGENT.md file in the .agents/agents folder.`}),(0,z.jsxs)(`div`,{className:`space-y-6`,children:[(0,z.jsxs)(D,{title:`Agent Name`,children:[(0,z.jsx)(f,{id:`agentName`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. Security Reviewer`,disabled:l}),r?(0,z.jsxs)(`p`,{className:g(n.caption,`mt-2`),children:[`Folder name: `,(0,z.jsx)(`span`,{className:`font-mono`,children:m||`...`})]}):null]}),(0,z.jsx)(D,{title:`Description`,children:(0,z.jsx)(j,{id:`agentDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Describe what this agent does and when it should be invoked`,className:`resize-none min-h-[120px]`,disabled:l})}),(0,z.jsx)(D,{title:`Allowed Tools`,description:`Space-separated list of tools this agent can use. Leave empty to allow all coding tools.`,children:(0,z.jsx)(f,{id:`agentTools`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. read grep glob`,disabled:l})}),(0,z.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,z.jsx)(_,{onClick:async()=>{if(!(!h||!a.trim()||!e)){d(!0);try{let n=await u(e,m,a.trim(),s.trim()||void 0);A({title:`Agent created`,description:`Agent '${m}' was created successfully.`}),i(``),o(``),c(``),t?.(n.path,`AGENT.md`)}catch(e){A({title:`Error`,description:e instanceof Error?e.message:`Failed to create agent`,variant:`destructive`})}finally{d(!1)}}},disabled:!h||!a.trim()||l,children:l?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,z.jsxs)(z.Fragment,{children:[`Continue`,(0,z.jsx)(p,{className:`ml-2 h-4 w-4`})]})})})]})]})}):(0,z.jsx)(E,{title:`No thread selected`,children:`Please select a thread to add an agent.`})}function V(e){let t=[];for(let n of e)n.path.startsWith(`.agents/agents/`)&&n.type===`folder`&&t.push(n),n.children&&n.children.length>0&&t.push(...V(n.children));return t}function H(){let e=M(e=>e.selectedProjectId),t=M(e=>e.selectedThreadId),{setActiveMainTab:n,setPendingExplorerPath:u,triggerExplorerRefresh:f,setExplorerClearPath:p}=ce(),[g,v]=(0,R.useState)([]),[y,D]=(0,R.useState)(!1),[k,j]=(0,R.useState)(!1),[H,U]=(0,R.useState)(null),[W,G]=(0,R.useState)(!1),[K,q]=(0,R.useState)([]),[J,Y]=(0,R.useState)(new Set),[X,Z]=(0,R.useState)(``),Q=(0,R.useCallback)(async()=>{if(e){D(!0);try{let n=V(await te(e));if(t)try{let e=V(await ee(t)),r=new Set(n.map(e=>e.path));for(let t of e)r.has(t.path)||n.push(t)}catch{}v(n),Y(new Set(n.map(e=>`${e.path}/AGENT.md`)))}catch{v([]),Y(new Set)}finally{D(!1)}}},[e,t]);(0,R.useEffect)(()=>{Q()},[Q]),(0,R.useEffect)(()=>{h().then(q).catch(()=>q([]))},[]);let de=(0,R.useCallback)(async n=>{if(!e)return;let r=n.name,i=n.path;G(!0);try{try{await d(e,i)}catch{if(t)await c(t,i);else throw Error(`No thread selected to delete from`)}p(i),f(),Y(e=>{let t=new Set(e);return t.delete(`${i}/AGENT.md`),t}),A({title:`Agent removed`,description:r}),U(null),await Q()}catch(e){A({title:`Error`,description:e instanceof Error?e.message:`Failed to remove agent`,variant:`destructive`})}finally{G(!1)}},[e,t,Q,f,p]),fe=(0,R.useCallback)(e=>{u(`${e}/AGENT.md`),n(`explorer`)},[u,n]),pe=(0,R.useCallback)(async e=>{let n=`.agents/agents/${e.id}/AGENT.md`;if(!(!t||J.has(n)))try{if(e.gitHubRepo&&e.gitHubFolder)await a(t,e.gitHubRepo,e.gitHubFolder,`.agents/agents/${e.id}`);else{let r=[`---`,`name: ${e.id}`,`description: ${e.description}`];e.tools&&r.push(`tools: ${e.tools}`),r.push(`---`,``,e.systemPrompt),await m(t,n,r.join(`
2
+ `))}Y(e=>new Set(e).add(n)),f(),Q(),A({title:`Agent installed`,description:e.name})}catch(e){A({title:`Error`,description:e instanceof Error?e.message:`Failed to install agent`,variant:`destructive`})}},[t,J,f,Q]),$=X.trim()?K.filter(e=>e.name.toLowerCase().includes(X.toLowerCase())||e.description.toLowerCase().includes(X.toLowerCase())):K;return e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(S,{children:(0,z.jsxs)(C,{children:[(0,z.jsx)(T,{title:`Subagents`,description:`Manage subagents. Subagents are specialized agents for focused tasks.`,action:(0,z.jsx)(_,{onClick:()=>j(!0),disabled:!t,children:`Add Subagent`})}),!t&&(0,z.jsx)(se,{children:`Select a thread to add or install subagents.`}),(0,z.jsx)(x,{title:`Installed`}),y?(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(N,{className:`h-20 w-full`}),(0,z.jsx)(N,{className:`h-20 w-full`})]}):g.length===0?(0,z.jsx)(I,{icon:l,title:`No subagents installed`,description:`Add subagents for specialized, focused tasks.`}):(0,z.jsx)(`div`,{className:`space-y-3 mb-8`,children:g.map(e=>(0,z.jsx)(P,{title:e.name,subtitle:e.path,subtitleMono:!0,actions:[{label:`View in explorer`,icon:(0,z.jsx)(o,{className:`h-4 w-4`}),onClick:()=>fe(e.path)},{label:`Delete agent`,icon:(0,z.jsx)(s,{className:`h-4 w-4`}),onClick:()=>U(e),destructive:!0}]},e.id))}),(0,z.jsx)(x,{title:`Available`,className:`mb-0`}),(0,z.jsx)(le,{placeholder:`Search available subagents...`,value:X,onChange:Z}),K.length===0?(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(N,{className:`h-20 w-full`}),(0,z.jsx)(N,{className:`h-20 w-full`})]}):$.length===0?(0,z.jsx)(ue,{searchQuery:X,emptyLabel:`No available subagents found.`}):(0,z.jsx)(F,{children:$.map(e=>{let t=`.agents/agents/${e.id}/AGENT.md`,n=J.has(t);return(0,z.jsx)(L,{name:e.name,description:e.description,installed:n,onClick:()=>{n||pe(e)},showInstalledControls:!1},e.id)})})]})}),(0,z.jsx)(i,{open:k,onOpenChange:j,children:(0,z.jsx)(r,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,z.jsx)(B,{threadId:t,onAgentCreated:()=>{j(!1),Q(),f()}})})}),(0,z.jsx)(ie,{open:H!==null,onOpenChange:e=>!e&&U(null),children:(0,z.jsxs)(O,{children:[(0,z.jsxs)(ae,{children:[(0,z.jsx)(w,{children:`Delete Subagent`}),(0,z.jsxs)(ne,{children:[`Are you sure you want to delete the subagent "`,H?.name,`"? This action cannot be undone.`]})]}),(0,z.jsxs)(re,{children:[(0,z.jsx)(b,{children:`Cancel`}),(0,z.jsx)(oe,{onClick:()=>H&&void de(H),disabled:W,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:W?`Deleting...`:`Delete`})]})]})})]}):(0,z.jsx)(E,{children:`Select a project to manage subagents.`})}export{H as SettingsSubagentsView,H as default};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ti as t,Ut as n,bn as r,ii as i,mo as a,ni as o,vi as s,vr as c,vt as l,ya as u}from"./dialogs-config-B4TDFSrS.js";import{n as d}from"./onboarding-DfL8a0LZ.js";import{A as f,E as p,F as m,M as h,N as g,O as _,P as v,S as y,T as b,j as x,k as S,w as C}from"./history-view-Ds_0e_bx.js";import{E as w,O as T,j as E}from"./index-DOsSr4dl.js";var D=e(a(),1),O=t();function k(){let e=E(e=>e.selectedProjectId),[t,a]=(0,D.useState)(``),[k,A]=(0,D.useState)(``),[j,M]=(0,D.useState)(!0),[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(``),[L,R]=(0,D.useState)(!1),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1);(0,D.useEffect)(()=>{e&&(R(!0),l(e).then(e=>{let t=e.useCustomSystemPrompt;a(e.generatedPrompt),P(t),I(e.customSystemPrompt),M(!t),A(t?e.customSystemPrompt:e.generatedPrompt)}).catch(()=>{a(``),A(``),M(!0),P(!1),I(``)}).finally(()=>R(!1)))},[e]);function U(){return j?N:k.trim()!==F.trim()}function W(e){A(e),j&&M(!1)}function G(){A(t),M(!0)}function K(e){if(!e){M(!1);return}if(k===t){G();return}H(!0)}function q(){G(),H(!1)}function J(){H(!1)}async function Y(){if(e){if(!j&&!k.trim()){w({title:`System prompt required`,description:`Enter a system prompt or enable Generated.`,variant:`destructive`});return}B(!0);try{await r(e,{customSystemPrompt:j?null:k.trim(),useCustomSystemPrompt:!j}),n(),P(!j),I(j?``:k.trim()),w({title:`System prompt settings saved`})}catch(e){w({title:`Error`,description:e instanceof Error?e.message:`Failed to save system prompt settings`,variant:`destructive`})}finally{B(!1)}}}return e?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(C,{children:(0,O.jsxs)(p,{className:`w-full flex-1 flex flex-col min-h-0`,children:[(0,O.jsx)(y,{title:`System Prompt`,description:`View the default system prompt or override it for this project. Instructions, rules, and other context are added separately at runtime.`,action:(0,O.jsx)(o,{onClick:Y,disabled:L||z||!U(),children:z?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(u,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,O.jsx)(d,{id:`use-generated-prompt`,checked:j,onCheckedChange:e=>K(e===!0),disabled:L||z}),(0,O.jsx)(c,{htmlFor:`use-generated-prompt`,className:i(s.labelNormal,`cursor-pointer`),children:`Generated`})]}),L?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,O.jsx)(u,{className:`h-8 w-8 animate-spin text-muted-foreground`})}):(0,O.jsx)(T,{value:k,onChange:e=>W(e.target.value),className:i(s.mono,`flex-1 min-h-0 resize-none`),placeholder:`System prompt will appear here...`,disabled:z})]})}),(0,O.jsx)(_,{open:V,onOpenChange:H,children:(0,O.jsxs)(x,{children:[(0,O.jsxs)(v,{children:[(0,O.jsx)(m,{children:`Overwrite custom system prompt?`}),(0,O.jsx)(h,{children:`This will replace your custom system prompt with the generated default. You can save the change after confirming.`})]}),(0,O.jsxs)(g,{children:[(0,O.jsx)(f,{onClick:J,children:`No`}),(0,O.jsx)(S,{onClick:q,children:`Yes`})]})]})})]}):(0,O.jsx)(b,{children:`Select a project to edit the system prompt.`})}export{k as SettingsSystemPromptView,k as default};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Ci as n,Cn as r,Cr as i,Kt as a,li as o,si as s,wa as c,xt as l,yo as u}from"./dialogs-config-I0_cSU2z.js";import{n as d}from"./onboarding-CgP4bJ5F.js";import{A as f,E as p,F as m,M as h,N as g,O as _,P as v,S as y,T as b,j as x,k as S,w as C}from"./history-view-Be-1C1tJ.js";import{E as w,O as T,j as E}from"./index-DVXbmgHY.js";var D=e(u(),1),O=t();function k(){let e=E(e=>e.selectedProjectId),[t,u]=(0,D.useState)(``),[k,A]=(0,D.useState)(``),[j,M]=(0,D.useState)(!0),[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(``),[L,R]=(0,D.useState)(!1),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1);(0,D.useEffect)(()=>{e&&(R(!0),l(e).then(e=>{let t=e.useCustomSystemPrompt;u(e.generatedPrompt),P(t),I(e.customSystemPrompt),M(!t),A(t?e.customSystemPrompt:e.generatedPrompt)}).catch(()=>{u(``),A(``),M(!0),P(!1),I(``)}).finally(()=>R(!1)))},[e]);function U(){return j?N:k.trim()!==F.trim()}function W(e){A(e),j&&M(!1)}function G(){A(t),M(!0)}function K(e){if(!e){M(!1);return}if(k===t){G();return}H(!0)}function q(){G(),H(!1)}function J(){H(!1)}async function Y(){if(e){if(!j&&!k.trim()){w({title:`System prompt required`,description:`Enter a system prompt or enable Generated.`,variant:`destructive`});return}B(!0);try{await r(e,{customSystemPrompt:j?null:k.trim(),useCustomSystemPrompt:!j}),a(),P(!j),I(j?``:k.trim()),w({title:`System prompt settings saved`})}catch(e){w({title:`Error`,description:e instanceof Error?e.message:`Failed to save system prompt settings`,variant:`destructive`})}finally{B(!1)}}}return e?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(C,{children:(0,O.jsxs)(p,{className:`w-full flex-1 flex flex-col min-h-0`,children:[(0,O.jsx)(y,{title:`System Prompt`,description:`View the default system prompt or override it for this project. Instructions, rules, and other context are added separately at runtime.`,action:(0,O.jsx)(s,{onClick:Y,disabled:L||z||!U(),children:z?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(c,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,O.jsx)(d,{id:`use-generated-prompt`,checked:j,onCheckedChange:e=>K(e===!0),disabled:L||z}),(0,O.jsx)(i,{htmlFor:`use-generated-prompt`,className:o(n.labelNormal,`cursor-pointer`),children:`Generated`})]}),L?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,O.jsx)(c,{className:`h-8 w-8 animate-spin text-muted-foreground`})}):(0,O.jsx)(T,{value:k,onChange:e=>W(e.target.value),className:o(n.mono,`flex-1 min-h-0 resize-none`),placeholder:`System prompt will appear here...`,disabled:z})]})}),(0,O.jsx)(_,{open:V,onOpenChange:H,children:(0,O.jsxs)(x,{children:[(0,O.jsxs)(v,{children:[(0,O.jsx)(m,{children:`Overwrite custom system prompt?`}),(0,O.jsx)(h,{children:`This will replace your custom system prompt with the generated default. You can save the change after confirming.`})]}),(0,O.jsxs)(g,{children:[(0,O.jsx)(f,{onClick:J,children:`No`}),(0,O.jsx)(S,{onClick:q,children:`Yes`})]})]})})]}):(0,O.jsx)(b,{children:`Select a project to edit the system prompt.`})}export{k as SettingsSystemPromptView,k as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-general-view-FwrdJbys.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-DVXbmgHY.js","assets/monaco-CZnIWXyV.js","assets/monaco-Br_kD0ds.css","assets/history-view-Be-1C1tJ.js","assets/dialogs-config-I0_cSU2z.js","assets/onboarding-CgP4bJ5F.js","assets/whisper-wasm-EGutPGND.js","assets/react-vendor-Do-APsQ6.js","assets/utils-CU0c_yCM.js","assets/index-jIBJk8xl.css","assets/project-settings-view-DixzP7KH.js","assets/radio-group-ZjNXbvW6.js","assets/providers-list-view-BzSUZZyq.js","assets/skeleton-iEZ-dj1s.js","assets/settings-models-view-vgV5YHRx.js","assets/settings-models-skeleton-DsWpzWOw.js","assets/settings-list-BCoqXa_X.js","assets/settings-mcp-servers-view-DBD-NhPx.js","assets/mcp-server-card-bNNoXKsW.js","assets/settings-skills-view-DVGGs16n.js","assets/settings-rules-view-DcSXrmaq.js","assets/settings-slash-commands-view-BsJw1F4p.js","assets/settings-subagents-view-BgWhQ9bf.js","assets/settings-instructions-view-BHzMtSvN.js","assets/settings-system-prompt-view-DAAbMucD.js","assets/account-view-BB-ze5ek.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{$t as t,Ai as n,Ci as r,Ii as i,Kt as a,Li as o,Qi as s,Ra as c,Ri as l,St as u,Wi as d,Xa as f,Yi as p,_o as m,do as h,ea as g,ka as _,li as ee,lo as v,oo as te,pa as ne,ra as y,si as re,yo as b}from"./dialogs-config-I0_cSU2z.js";import{ct as ie,lt as ae,st as oe}from"./react-vendor-Do-APsQ6.js";import{r as x}from"./monaco-CZnIWXyV.js";import{c as S,u as C}from"./onboarding-CgP4bJ5F.js";import{D as w,E as T,T as E}from"./history-view-Be-1C1tJ.js";import{A as D,T as O,a as se,i as k,j as A,k as j,n as M,p as N,r as P}from"./index-DVXbmgHY.js";import{t as F}from"./settings-models-skeleton-DsWpzWOw.js";var I=m(),L=e(b(),1),R=n(),ce=(0,L.forwardRef)(function(e,t){let n=(0,I.c)(28),{sidebar:r,children:i,defaultSidebarSize:a,minSidebarSize:o,maxSidebarSize:s,minContentSize:c,collapsible:l,collapsedSize:u,className:d,onCollapse:f,onExpand:p,isMobile:m,mobileShowSidebar:h}=e,g=a===void 0?25:a,_=o===void 0?20:o,v=s===void 0?30:s,te=c===void 0?40:c,ne=l===void 0?!1:l,y=u===void 0?0:u,re=d===void 0?``:d,b=m===void 0?!1:m,ie=h===void 0?!0:h,ae=b&&!ie,oe=b&&ie,x=`h-full ${re}`,S=b?100:g,C=b?50:_,w=b?100:v,T=ae&&`hidden`,E;n[0]===T?E=n[1]:(E=ee(`border-r border-transparent`,T),n[0]=T,n[1]=E);let D;n[2]!==y||n[3]!==ne||n[4]!==f||n[5]!==p||n[6]!==t||n[7]!==r||n[8]!==S||n[9]!==C||n[10]!==w||n[11]!==E?(D=(0,R.jsx)(P,{ref:t,defaultSize:S,minSize:C,maxSize:w,collapsible:ne,collapsedSize:y,onCollapse:f,onExpand:p,className:E,children:r}),n[2]=y,n[3]=ne,n[4]=f,n[5]=p,n[6]=t,n[7]=r,n[8]=S,n[9]=C,n[10]=w,n[11]=E,n[12]=D):D=n[12];let O;n[13]===b?O=n[14]:(O=!b&&(0,R.jsx)(M,{withHandle:!0,className:`ml-[-40px]`}),n[13]=b,n[14]=O);let se=oe&&`hidden`,A;n[15]===se?A=n[16]:(A=ee(`overflow-hidden`,se),n[15]=se,n[16]=A);let j;n[17]!==i||n[18]!==te||n[19]!==A?(j=(0,R.jsx)(P,{minSize:te,className:A,children:i}),n[17]=i,n[18]=te,n[19]=A,n[20]=j):j=n[20];let N;n[21]!==D||n[22]!==O||n[23]!==j?(N=(0,R.jsxs)(k,{direction:`horizontal`,className:`h-full`,children:[D,O,j]}),n[21]=D,n[22]=O,n[23]=j,n[24]=N):N=n[24];let F;return n[25]!==x||n[26]!==N?(F=(0,R.jsx)(`div`,{className:x,children:N}),n[25]=x,n[26]=N,n[27]=F):F=n[27],F}),le=[{id:`providers`,label:`Providers`,icon:(0,R.jsx)(f,{className:`h-4 w-4`}),route:`/settings/providers`},{id:`models`,label:`Models`,icon:(0,R.jsx)(v,{className:`h-4 w-4`}),route:`/settings/models`},{id:`skills`,label:`Skills`,icon:(0,R.jsx)(i,{className:`h-4 w-4`}),route:`/settings/skills`},{id:`rules`,label:`Rules`,icon:(0,R.jsx)(y,{className:`h-4 w-4`}),route:`/settings/rules`},{id:`slash-commands`,label:`Slash Commands`,icon:(0,R.jsx)(d,{className:`h-4 w-4`}),route:`/settings/slash-commands`},{id:`subagents`,label:`Subagents`,icon:(0,R.jsx)(o,{className:`h-4 w-4`}),route:`/settings/subagents`},{id:`instructions`,label:`Instructions`,icon:(0,R.jsx)(h,{className:`h-4 w-4`}),route:`/settings/instructions`},{id:`system-prompt`,label:`System Prompt`,icon:(0,R.jsx)(p,{className:`h-4 w-4`}),route:`/settings/system-prompt`},{id:`mcp-servers`,label:`MCP Servers`,icon:(0,R.jsx)(g,{className:`h-4 w-4`}),route:`/settings/mcp-servers`},{id:`general`,label:`General`,icon:(0,R.jsx)(s,{className:`h-4 w-4`}),route:`/settings/general`},{id:`history`,label:`History`,icon:(0,R.jsx)(_,{className:`h-4 w-4`}),route:`/settings/history`},{id:`account`,label:`Account`,icon:(0,R.jsx)(l,{className:`h-4 w-4`}),route:`/settings/account`}];function z(e){let t=[...le];if(!e)return t;let n=t.findIndex(e=>e.id===`skills`);return t.splice(n,0,{id:`project`,label:`Project`,icon:(0,R.jsx)(c,{className:`h-4 w-4`}),route:`/settings/project/${e}`}),t}function ue(e){let t=(0,I.c)(13),{className:n,selectedProjectId:r,onResetOnboarding:i,onNavItemSelect:a}=e,o=ie(),s=oe(),c=(0,L.useRef)(0),l=(0,L.useRef)(null),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>()=>{l.current&&clearTimeout(l.current)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),(0,L.useEffect)(u,d);let f,p;if(t[2]!==n||t[3]!==s.pathname||t[4]!==o||t[5]!==a||t[6]!==i||t[7]!==r){let e=z(r),u=function(){let t=s.pathname;if(t.startsWith(`/settings/project/`))return`project`;for(let n of e)if(t.startsWith(n.route))return n.id;return`general`}(),d=function(e){e.id===`general`&&i&&(l.current&&clearTimeout(l.current),c.current+=1,c.current>=3?(c.current=0,i()):l.current=setTimeout(()=>{c.current=0},1500)),a?.(),o(e.route)};f=`space-y-1${n?` ${n}`:``}`,p=e.map((t,n)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(C,{selected:u===t.id,asChild:!0,children:(0,R.jsx)(`button`,{className:`justify-start`,onClick:()=>d(t),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[t.icon,(0,R.jsx)(`span`,{children:t.label})]})})}),(t.id===`models`||t.id===`mcp-servers`||n===e.length-1)&&(0,R.jsx)(S,{className:`my-2 bg-sidebar-border`})]},t.id)),t[2]=n,t[3]=s.pathname,t[4]=o,t[5]=a,t[6]=i,t[7]=r,t[8]=f,t[9]=p}else f=t[8],p=t[9];let m;return t[10]!==f||t[11]!==p?(m=(0,R.jsx)(`div`,{className:f,children:p}),t[10]=f,t[11]=p,t[12]=m):m=t[12],m}var de=(0,L.lazy)(()=>x(()=>import(`./settings-general-view-FwrdJbys.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),fe=(0,L.lazy)(()=>x(()=>import(`./project-settings-view-DixzP7KH.js`),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9,10,11,13]))),pe=(0,L.lazy)(()=>x(()=>import(`./providers-list-view-BzSUZZyq.js`),__vite__mapDeps([14,1,2,3,4,5,6,7,8,9,10,11,15]))),me=(0,L.lazy)(()=>x(()=>import(`./settings-models-view-vgV5YHRx.js`),__vite__mapDeps([16,1,2,3,4,5,6,7,8,9,10,11,17,15,18]))),he=(0,L.lazy)(()=>x(()=>import(`./settings-mcp-servers-view-DBD-NhPx.js`),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,11,20,18,15]))),ge=(0,L.lazy)(()=>x(()=>import(`./settings-skills-view-DVGGs16n.js`),__vite__mapDeps([21,1,2,3,4,5,6,7,8,9,10,11,20,18,15]))),_e=(0,L.lazy)(()=>x(()=>import(`./settings-rules-view-DcSXrmaq.js`),__vite__mapDeps([22,1,2,3,4,5,6,7,8,9,10,11,20,18,15]))),ve=(0,L.lazy)(()=>x(()=>import(`./settings-slash-commands-view-BsJw1F4p.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,10,11,20,13,18,15]))),ye=(0,L.lazy)(()=>x(()=>import(`./settings-subagents-view-BgWhQ9bf.js`),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,11,20,18,15]))),be=(0,L.lazy)(()=>x(()=>import(`./settings-instructions-view-BHzMtSvN.js`),__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,10,11]))),xe=(0,L.lazy)(()=>x(()=>import(`./settings-system-prompt-view-DAAbMucD.js`),__vite__mapDeps([26,1,2,3,4,5,6,7,8,9,10,11]))),Se=(0,L.lazy)(()=>x(()=>import(`./account-view-BB-ze5ek.js`),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,10,11,15]))),Ce=(0,L.lazy)(()=>x(()=>import(`./history-view-Be-1C1tJ.js`).then(e=>e.t),__vite__mapDeps([5,1,6]))),we=[`general`,`providers`,`models`,`skills`,`rules`,`slash-commands`,`subagents`,`instructions`,`system-prompt`,`mcp-servers`,`history`,`account`];function B(e){let t=(0,I.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,R.jsx)(E,{title:n,children:`Content coming soon...`}),t[0]=n,t[1]=r),r}function Te(){let e=(0,I.c)(6),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`mb-6`,children:[(0,R.jsx)(`div`,{className:`h-8 w-32 bg-muted rounded animate-pulse mb-2`}),(0,R.jsx)(`div`,{className:`h-4 w-64 bg-muted rounded animate-pulse`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,R.jsx)(`div`,{className:`mb-6`,children:(0,R.jsx)(`div`,{className:`h-10 w-full bg-muted rounded animate-pulse`})}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,R.jsx)(`div`,{className:`h-4 w-36 bg-muted rounded animate-pulse mb-3`}),e[2]=r):r=e[2];let i,a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,R.jsxs)(`div`,{children:[r,(0,R.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,R.jsx)(`div`,{className:`h-24 bg-muted rounded-lg animate-pulse`}),(0,R.jsx)(`div`,{className:`h-24 bg-muted rounded-lg animate-pulse`})]})]}),a=(0,R.jsx)(`div`,{className:`h-4 w-40 bg-muted rounded animate-pulse mb-3`}),e[3]=i,e[4]=a):(i=e[3],a=e[4]);let o;return e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,R.jsx)(w,{children:(0,R.jsxs)(T,{children:[t,n,(0,R.jsxs)(`div`,{className:`space-y-8`,children:[i,(0,R.jsxs)(`div`,{children:[a,(0,R.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,R.jsx)(`div`,{className:`h-24 bg-muted rounded-lg animate-pulse`}),(0,R.jsx)(`div`,{className:`h-24 bg-muted rounded-lg animate-pulse`}),(0,R.jsx)(`div`,{className:`h-24 bg-muted rounded-lg animate-pulse`}),(0,R.jsx)(`div`,{className:`h-24 bg-muted rounded-lg animate-pulse`})]})]})]})]})}),e[5]=o):o=e[5],o}function Ee(e){return e.startsWith(`/settings/general`)?`general`:e.startsWith(`/settings/providers`)?`providers`:e.startsWith(`/settings/models`)?`models`:e.startsWith(`/settings/skills`)?`skills`:e.startsWith(`/settings/rules`)?`rules`:e.startsWith(`/settings/slash-commands`)?`slash-commands`:e.startsWith(`/settings/subagents`)?`subagents`:e.startsWith(`/settings/instructions`)?`instructions`:e.startsWith(`/settings/system-prompt`)?`system-prompt`:e.startsWith(`/settings/mcp-servers`)?`mcp-servers`:e.startsWith(`/settings/history`)?`history`:e.startsWith(`/settings/account`)?`account`:`general`}function De(e){let t=e.match(/^\/settings\/providers\/([^/]+)$/);return t?decodeURIComponent(t[1]):null}function Oe(){let e=(0,I.c)(68),{tab:n,projectId:i}=ae(),o=ie(),s=oe(),c=D(),l=A(je),d=A(Ae),f;e[0]!==s.pathname||e[1]!==i?(f=!!i&&s.pathname.startsWith(`/settings/project/`),e[0]=s.pathname,e[1]=i,e[2]=f):f=e[2];let p=f,m;e[3]===s.pathname?m=e[4]:(m=De(s.pathname),e[3]=s.pathname,e[4]=m);let h=m!==null,g;if(e[5]!==s.pathname||e[6]!==s.search||e[7]!==n){let t=new URLSearchParams(s.search).get(`tab`);g=t&&we.includes(t)?t:n&&we.includes(n)?n:Ee(s.pathname),e[5]=s.pathname,e[6]=s.search,e[7]=n,e[8]=g}else g=e[8];let _=g,v=N(),[y,b]=(0,L.useState)(!1),[x,S]=(0,L.useState)(!0),[C,w]=(0,L.useState)(0),T=(0,L.useRef)(null),E;bb0:{if(p){E=`Project`;break bb0}let t;e[9]===_?t=e[10]:(t=le.find(e=>e.id===_)?.label??`Settings`,e[9]=_,e[10]=t),E=t}let k=E,M;e[11]===o?M=e[12]:(M=()=>{o(`/settings/providers`)},e[11]=o,e[12]=M);let P=M,z;e[13]===v?z=e[14]:(z=()=>{v&&S(!1)},e[13]=v,e[14]=z);let Oe=z,V;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{S(!0)},e[15]=V):V=e[15];let Me=V,Ne;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=async()=>{try{await t(),w(ke)}catch(e){console.error(`Failed to reset onboarding:`,e)}},e[16]=Ne):Ne=e[16];let Pe=Ne,H;e[17]===o?H=e[18]:(H=()=>{o(`/`)},e[17]=o,e[18]=H);let Fe=H,U;e[19]===l?U=e[20]:(U=l?{type:`project`,id:l}:void 0,e[19]=l,e[20]=U);let Ie=U,W;e[21]===o?W=e[22]:(W=()=>{o(`/settings/general`)},e[21]=o,e[22]=W);let Le=W,G;e[23]!==c||e[24]!==i?(G=async()=>{a(i);try{let e=await u();c({type:j.SetProjects,projects:e.projects})}catch(e){let t=e;throw console.error(`Failed to refresh projects after settings update:`,t),t}},e[23]=c,e[24]=i,e[25]=G):G=e[25];let Re=G,K,q;e[26]!==s.pathname||e[27]!==o?(K=()=>{(s.pathname===`/settings`||s.pathname===`/settings/project`||[`/settings/mcp-server-edit`,`/settings/add-skill`,`/settings/add-command`,`/settings/add-rule`,`/settings/add-agent`].some(e=>s.pathname.startsWith(e)))&&o(`/settings/general`,{replace:!0})},q=[s.pathname,o],e[26]=s.pathname,e[27]=o,e[28]=K,e[29]=q):(K=e[28],q=e[29]),(0,L.useEffect)(K,q);let ze;e[30]!==Fe||e[31]!==Oe||e[32]!==l?(ze=()=>(0,R.jsx)(O,{onTitleClose:Fe,subtitle:`Settings`,children:(0,R.jsx)(`div`,{className:`px-2 py-2`,children:(0,R.jsx)(ue,{selectedProjectId:l,onResetOnboarding:Pe,onNavItemSelect:Oe})})}),e[30]=Fe,e[31]=Oe,e[32]=l,e[33]=ze):ze=e[33];let Be=ze,Ve;e[34]!==_||e[35]!==Le||e[36]!==Re||e[37]!==Ie||e[38]!==p||e[39]!==C||e[40]!==i||e[41]!==d?(Ve=()=>{if(p&&i)return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Project Settings`}),children:(0,R.jsx)(fe,{projectId:i,onProjectUpdated:Re})});switch(_){case`general`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`General`}),children:(0,R.jsx)(de,{onboardingResetSignal:C})});case`providers`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(Te,{}),children:(0,R.jsx)(pe,{})});case`models`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(F,{}),children:(0,R.jsx)(me,{})});case`skills`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Skills`}),children:(0,R.jsx)(ge,{})});case`rules`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Rules`}),children:(0,R.jsx)(_e,{})});case`slash-commands`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Slash Commands`}),children:(0,R.jsx)(ve,{})});case`subagents`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Subagents`}),children:(0,R.jsx)(ye,{})});case`instructions`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Instructions`}),children:(0,R.jsx)(be,{})});case`system-prompt`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`System Prompt`}),children:(0,R.jsx)(xe,{})});case`mcp-servers`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`MCP Servers`}),children:(0,R.jsx)(he,{})});case`history`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`History`}),children:(0,R.jsx)(Ce,{isOpen:!0,onClose:Le,initialFilter:Ie,projects:d,inline:!0})});case`account`:return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(B,{title:`Account`}),children:(0,R.jsx)(Se,{})});default:return(0,R.jsx)(B,{title:`Settings`})}},e[34]=_,e[35]=Le,e[36]=Re,e[37]=Ie,e[38]=p,e[39]=C,e[40]=i,e[41]=d,e[42]=Ve):Ve=e[42];let He=Ve,Ue,We;e[43]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=()=>b(!0),We=()=>b(!1),e[43]=Ue,e[44]=We):(Ue=e[43],We=e[44]);let J;e[45]===Be?J=e[46]:(J=Be(),e[45]=Be,e[46]=J);let Y;e[47]!==k||e[48]!==P||e[49]!==v||e[50]!==h||e[51]!==x?(Y=h?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,R.jsxs)(re,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0 text-muted-foreground electrobun-webkit-app-region-no-drag`,onClick:P,children:[(0,R.jsx)(te,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Back to providers`})]}),(0,R.jsx)(`button`,{type:`button`,className:ee(r.sectionTitle,`truncate text-foreground min-w-0 flex-1 text-left bg-transparent p-0 border-0 cursor-pointer electrobun-webkit-app-region-no-drag focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-sm`),onClick:P,children:k})]}):v&&!x&&(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,R.jsxs)(re,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0 text-muted-foreground electrobun-webkit-app-region-no-drag`,onClick:Me,children:[(0,R.jsx)(ne,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Show settings menu`})]}),(0,R.jsx)(`span`,{className:ee(r.sectionTitle,`truncate text-foreground`),children:k})]}),e[47]=k,e[48]=P,e[49]=v,e[50]=h,e[51]=x,e[52]=Y):Y=e[52];let X;e[53]===Y?X=e[54]:(X=(0,R.jsx)(se,{className:`pt-8 md:min-h-[103px]`,children:Y}),e[53]=Y,e[54]=X);let Ge=`flex-1 overflow-auto ${y&&!v?`ml-[40px]`:``}`,Z;e[55]===He?Z=e[56]:(Z=He(),e[55]=He,e[56]=Z);let Q;e[57]!==Ge||e[58]!==Z?(Q=(0,R.jsx)(`div`,{className:Ge,children:Z}),e[57]=Ge,e[58]=Z,e[59]=Q):Q=e[59];let $;e[60]!==X||e[61]!==Q?($=(0,R.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[X,Q]}),e[60]=X,e[61]=Q,e[62]=$):$=e[62];let Ke;return e[63]!==v||e[64]!==x||e[65]!==J||e[66]!==$?(Ke=(0,R.jsx)(ce,{ref:T,collapsible:!0,isMobile:v,mobileShowSidebar:x,onCollapse:Ue,onExpand:We,sidebar:J,children:$}),e[63]=v,e[64]=x,e[65]=J,e[66]=$,e[67]=Ke):Ke=e[67],Ke}function ke(e){return e+1}function Ae(e){return e.projects}function je(e){return e.selectedProjectId}export{Oe as default};
@@ -1 +1 @@
1
- import{Ti as e,fo as t,ii as n}from"./dialogs-config-B4TDFSrS.js";var r=t(),i=e();function a(e){let t=(0,r.c)(8),a,o;t[0]===e?(a=t[1],o=t[2]):({className:a,...o}=e,t[0]=e,t[1]=a,t[2]=o);let s;t[3]===a?s=t[4]:(s=n(`animate-pulse rounded-md bg-muted`,a),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,i.jsx)(`div`,{className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}export{a as t};
1
+ import{Ai as e,_o as t,li as n}from"./dialogs-config-I0_cSU2z.js";var r=t(),i=e();function a(e){let t=(0,r.c)(8),a,o;t[0]===e?(a=t[1],o=t[2]):({className:a,...o}=e,t[0]=e,t[1]=a,t[2]=o);let s;t[3]===a?s=t[4]:(s=n(`animate-pulse rounded-md bg-muted`,a),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,i.jsx)(`div`,{className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}export{a as t};
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ka as t,Qt as n,Ti as r,eo as i,mo as a}from"./dialogs-config-B4TDFSrS.js";import{C as o,M as s,S as c,j as l,k as u}from"./index-DOsSr4dl.js";var d=e(a(),1),f=r();function p(){let e=l(e=>e.selectedProjectId),r=l(e=>e.selectedThreadId),a=l(e=>e.projects),{terminalState:p,dispatch:m}=s(r),{queuedCommand:h,queuedRelativeFolder:g,outputLines:_,history:v,historyIndex:y,cwd:b,isRunning:x}=p,[S,C]=(0,d.useState)(``),[w,T]=(0,d.useState)([]),E=a.flatMap(e=>e.threads).find(e=>e.threadId===r)?.path??null,D=!b||b===`.`||b===`./`?E:b,O=!D||D===E,{activeMainTab:k}=o(),A=(0,d.useRef)(null),j=(0,d.useRef)(null),M=(0,d.useRef)(0);(0,d.useEffect)(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[w]),(0,d.useEffect)(()=>{T(_),M.current=_.length},[r,_]),(0,d.useEffect)(()=>{if(_.length===0)T([]),M.current=0;else if(_.length>M.current){let e=_.slice(M.current);T(t=>[...t,...e]),M.current=_.length}},[_]),(0,d.useEffect)(()=>{x||j.current?.focus()},[x]),(0,d.useEffect)(()=>{k===`terminal`&&j.current?.focus()},[k]);let N=(0,d.useCallback)(async(t,i)=>{if(!(!e||!r||!t.trim())){m({type:u.AppendTerminalLine,line:{type:`input`,content:t}}),m({type:u.SetTerminalHistory,history:[t,...v.filter(e=>e!==t)].slice(0,50)}),m({type:u.SetTerminalHistoryIndex,index:-1}),C(``),m({type:u.SetTerminalRunning,isRunning:!0});try{let a=await n(e,r,t,i??void 0);if(!a){m({type:u.AppendTerminalLine,line:{type:`system`,content:`Command started but no output stream received.`}}),m({type:u.SetTerminalRunning,isRunning:!1});return}let o=a.getReader(),s=new TextDecoder,l=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;l+=s.decode(t,{stream:!0});let n=l.split(`
2
- `);l=n.pop()??``;for(let e of n)if(e.trim())try{let t=JSON.parse(e);typeof t==`string`?m({type:u.AppendTerminalLine,line:{type:`output`,content:c(t)}}):t.type===`error`?m({type:u.AppendTerminalLine,line:{type:`error`,content:c(t.message)}}):t.type===`cwd`&&m({type:u.SetTerminalCwd,cwd:t.path})}catch{m({type:u.AppendTerminalLine,line:{type:`output`,content:c(e)}})}}if(l.trim())try{let e=JSON.parse(l);typeof e==`string`?m({type:u.AppendTerminalLine,line:{type:`output`,content:c(e)}}):e.type===`error`?m({type:u.AppendTerminalLine,line:{type:`error`,content:c(e.message)}}):e.type===`cwd`&&m({type:u.SetTerminalCwd,cwd:e.path})}catch{m({type:u.AppendTerminalLine,line:{type:`output`,content:c(l)}})}}catch(e){m({type:u.AppendTerminalLine,line:{type:`error`,content:e instanceof Error?e.message:`Failed to run command`}})}finally{m({type:u.SetTerminalRunning,isRunning:!1})}}},[e,r,m,v]);return(0,d.useEffect)(()=>{h&&!x&&(N(h,g??void 0),m({type:u.ClearQueuedTerminalCommand}))},[h,g,x,m,N]),(0,f.jsxs)(`div`,{className:`flex flex-col h-full bg-neutral-950 text-neutral-200 font-mono text-sm overflow-hidden`,children:[(0,f.jsxs)(`div`,{ref:A,className:`flex-1 overflow-y-auto p-4 space-y-0.5 terminal-scrollbar`,onClick:e=>{e.target===e.currentTarget&&j.current?.focus()},children:[w.length===0&&!x&&(0,f.jsx)(`div`,{className:`text-neutral-600 italic text-xs`,children:`Enter your commands below...`}),w.map((e,t)=>(0,f.jsxs)(`div`,{className:`whitespace-pre-wrap break-all leading-6 ${e.type===`input`?`flex items-start gap-2 text-neutral-200`:e.type===`error`?`text-red-400`:e.type===`system`?`text-blue-400`:``}`,children:[e.type===`input`&&(0,f.jsx)(i,{className:`h-4 w-4 mt-1 shrink-0 text-blue-400/70`}),(0,f.jsx)(`span`,{children:e.content})]},t))]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t border-white/5 bg-white/5`,children:[!O&&(0,f.jsx)(`span`,{className:`text-blue-400 text-xs font-bold whitespace-nowrap`,children:D.split(`/`).pop()}),(0,f.jsx)(i,{className:`h-4 w-4 text-blue-400 ${O?``:`-ml-1`}`}),(0,f.jsx)(`input`,{ref:j,type:`text`,className:`flex-1 bg-transparent border-none outline-none text-neutral-200 placeholder:text-neutral-700 h-6`,placeholder:x?`Running...`:`Type a command...`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{if(e.key===`Enter`)N(S);else if(e.key===`ArrowUp`){e.preventDefault();let t=y+1;t<v.length&&(m({type:u.SetTerminalHistoryIndex,index:t}),C(v[t]))}else if(e.key===`ArrowDown`){e.preventDefault();let t=y-1;t>=0?(m({type:u.SetTerminalHistoryIndex,index:t}),C(v[t])):(m({type:u.SetTerminalHistoryIndex,index:-1}),C(``))}},disabled:x}),(0,f.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded border border-white/10 bg-white/5`,children:[(0,f.jsx)(t,{className:`h-3 w-3 text-neutral-600`}),(0,f.jsx)(`span`,{className:`text-[10px] text-neutral-600 uppercase font-bold`,children:`Enter`})]})]})]})}export{p as TerminalPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ai as t,Za as n,ao as r,tn as i,yo as a}from"./dialogs-config-I0_cSU2z.js";import{C as o,M as s,S as c,j as l,k as u}from"./index-DVXbmgHY.js";var d=e(a(),1),f=t();function p(){let e=l(e=>e.selectedProjectId),t=l(e=>e.selectedThreadId),a=l(e=>e.projects),{terminalState:p,dispatch:m}=s(t),{queuedCommand:h,queuedRelativeFolder:g,outputLines:_,history:v,historyIndex:y,cwd:b,isRunning:x}=p,[S,C]=(0,d.useState)(``),[w,T]=(0,d.useState)([]),E=a.flatMap(e=>e.threads).find(e=>e.threadId===t)?.path??null,D=!b||b===`.`||b===`./`?E:b,O=!D||D===E,{activeMainTab:k}=o(),A=(0,d.useRef)(null),j=(0,d.useRef)(null),M=(0,d.useRef)(0);(0,d.useEffect)(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[w]),(0,d.useEffect)(()=>{T(_),M.current=_.length},[t,_]),(0,d.useEffect)(()=>{if(_.length===0)T([]),M.current=0;else if(_.length>M.current){let e=_.slice(M.current);T(t=>[...t,...e]),M.current=_.length}},[_]),(0,d.useEffect)(()=>{x||j.current?.focus()},[x]),(0,d.useEffect)(()=>{k===`terminal`&&j.current?.focus()},[k]);let N=(0,d.useCallback)(async(n,r)=>{if(!(!e||!t||!n.trim())){m({type:u.AppendTerminalLine,line:{type:`input`,content:n}}),m({type:u.SetTerminalHistory,history:[n,...v.filter(e=>e!==n)].slice(0,50)}),m({type:u.SetTerminalHistoryIndex,index:-1}),C(``),m({type:u.SetTerminalRunning,isRunning:!0});try{let a=await i(e,t,n,r??void 0);if(!a){m({type:u.AppendTerminalLine,line:{type:`system`,content:`Command started but no output stream received.`}}),m({type:u.SetTerminalRunning,isRunning:!1});return}let o=a.getReader(),s=new TextDecoder,l=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;l+=s.decode(t,{stream:!0});let n=l.split(`
2
+ `);l=n.pop()??``;for(let e of n)if(e.trim())try{let t=JSON.parse(e);typeof t==`string`?m({type:u.AppendTerminalLine,line:{type:`output`,content:c(t)}}):t.type===`error`?m({type:u.AppendTerminalLine,line:{type:`error`,content:c(t.message)}}):t.type===`cwd`&&m({type:u.SetTerminalCwd,cwd:t.path})}catch{m({type:u.AppendTerminalLine,line:{type:`output`,content:c(e)}})}}if(l.trim())try{let e=JSON.parse(l);typeof e==`string`?m({type:u.AppendTerminalLine,line:{type:`output`,content:c(e)}}):e.type===`error`?m({type:u.AppendTerminalLine,line:{type:`error`,content:c(e.message)}}):e.type===`cwd`&&m({type:u.SetTerminalCwd,cwd:e.path})}catch{m({type:u.AppendTerminalLine,line:{type:`output`,content:c(l)}})}}catch(e){m({type:u.AppendTerminalLine,line:{type:`error`,content:e instanceof Error?e.message:`Failed to run command`}})}finally{m({type:u.SetTerminalRunning,isRunning:!1})}}},[e,t,m,v]);return(0,d.useEffect)(()=>{h&&!x&&(N(h,g??void 0),m({type:u.ClearQueuedTerminalCommand}))},[h,g,x,m,N]),(0,f.jsxs)(`div`,{className:`flex flex-col h-full bg-neutral-950 text-neutral-200 font-mono text-sm overflow-hidden`,children:[(0,f.jsxs)(`div`,{ref:A,className:`flex-1 overflow-y-auto p-4 space-y-0.5 terminal-scrollbar`,onClick:e=>{e.target===e.currentTarget&&j.current?.focus()},children:[w.length===0&&!x&&(0,f.jsx)(`div`,{className:`text-neutral-600 italic text-xs`,children:`Enter your commands below...`}),w.map((e,t)=>(0,f.jsxs)(`div`,{className:`whitespace-pre-wrap break-all leading-6 ${e.type===`input`?`flex items-start gap-2 text-neutral-200`:e.type===`error`?`text-red-400`:e.type===`system`?`text-blue-400`:``}`,children:[e.type===`input`&&(0,f.jsx)(r,{className:`h-4 w-4 mt-1 shrink-0 text-blue-400/70`}),(0,f.jsx)(`span`,{children:e.content})]},t))]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t border-white/5 bg-white/5`,children:[!O&&(0,f.jsx)(`span`,{className:`text-blue-400 text-xs font-bold whitespace-nowrap`,children:D.split(`/`).pop()}),(0,f.jsx)(r,{className:`h-4 w-4 text-blue-400 ${O?``:`-ml-1`}`}),(0,f.jsx)(`input`,{ref:j,type:`text`,className:`flex-1 bg-transparent border-none outline-none text-neutral-200 placeholder:text-neutral-700 h-6`,placeholder:x?`Running...`:`Type a command...`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{if(e.key===`Enter`)N(S);else if(e.key===`ArrowUp`){e.preventDefault();let t=y+1;t<v.length&&(m({type:u.SetTerminalHistoryIndex,index:t}),C(v[t]))}else if(e.key===`ArrowDown`){e.preventDefault();let t=y-1;t>=0?(m({type:u.SetTerminalHistoryIndex,index:t}),C(v[t])):(m({type:u.SetTerminalHistoryIndex,index:-1}),C(``))}},disabled:x}),(0,f.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded border border-white/10 bg-white/5`,children:[(0,f.jsx)(n,{className:`h-3 w-3 text-neutral-600`}),(0,f.jsx)(`span`,{className:`text-[10px] text-neutral-600 uppercase font-bold`,children:`Enter`})]})]})]})}export{p as TerminalPanel};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ar as t,Ei as n,Mr as r,Or as i,Qr as a,jr as o,mo as s,yr as c}from"./dialogs-config-B4TDFSrS.js";var l=1,u=.9,d=.8,f=.17,p=.1,m=.999,h=.9999,g=.99,_=/[\\\/_+.#"@\[\(\{&]/,v=/[\\\/_+.#"@\[\(\{&]/g,y=/[\s-]/,b=/[\s-]/g;function x(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?l:g;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),S=n.indexOf(c,i),C=0,w,T,E,D;S>=0;)w=x(e,t,n,r,S+1,a+1,o),w>C&&(S===i?w*=l:_.test(e.charAt(S-1))?(w*=d,E=e.slice(i,S-1).match(v),E&&i>0&&(w*=m**+E.length)):y.test(e.charAt(S-1))?(w*=u,D=e.slice(i,S-1).match(b),D&&i>0&&(w*=m**+D.length)):(w*=f,i>0&&(w*=m**+(S-i))),e.charAt(S)!==t.charAt(a)&&(w*=h)),(w<p&&n.charAt(S-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(S-1)!==r.charAt(a))&&(T=x(e,t,n,r,S+1,a+2,o),T*p>w&&(w=T*p)),w>C&&(C=w),S=n.indexOf(c,S+1);return o[s]=C,C}function S(e){return e.toLowerCase().replace(b,` `)}function C(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,x(e,t,S(e),S(t),0,0,{})}var w=e(s(),1),T=`[cmdk-group=""]`,E=`[cmdk-group-items=""]`,D=`[cmdk-group-heading=""]`,O=`[cmdk-item=""]`,k=`${O}:not([aria-disabled="true"])`,A=`cmdk-item-select`,j=`data-value`,ee=(e,t,n)=>C(e,t,n),M=w.createContext(void 0),N=()=>w.useContext(M),P=w.createContext(void 0),F=()=>w.useContext(P),I=w.createContext(void 0),L=w.forwardRef((e,t)=>{let n=Y(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Y(()=>new Set),i=Y(()=>new Map),o=Y(()=>new Map),s=Y(()=>new Set),l=q(e),{label:u,children:d,value:f,onValueChange:p,filter:m,shouldFilter:h,loop:g,disablePointerSelection:_=!1,vimBindings:v=!0,...y}=e,b=a(),x=a(),S=a(),C=w.useRef(null),N=re();J(()=>{if(f!==void 0){let e=f.trim();n.current.value=e,F.emit()}},[f]),J(()=>{N(6,V)},[]);let F=w.useMemo(()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)B(),R(),N(1,z);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(S);e?e.focus():(i=document.getElementById(b))==null||i.focus()}if(N(7,()=>{n.current.selectedItemId=H()?.id,F.emit()}),r||N(5,V),l.current?.value!==void 0){let e=t??``;(o=(a=l.current).onValueChange)==null||o.call(a,e);return}}F.emit()}},emit:()=>{s.current.forEach(e=>e())}}),[]),I=w.useMemo(()=>({value:(e,t,r)=>{t!==o.current.get(e)?.value&&(o.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,L(t,r)),N(2,()=>{R(),F.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),N(3,()=>{B(),R(),n.current.value||z(),F.emit()}),()=>{o.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=H();N(4,()=>{B(),t?.getAttribute(`id`)===e&&z(),F.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{o.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e[`aria-label`],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:S,labelId:x,listInnerRef:C}),[]);function L(e,t){let r=l.current?.filter??ee;return e?r(e,n.current.search,t):0}function R(){if(!n.current.search||l.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=C.current;U().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(E);t?t.appendChild(e.parentElement===t?e:e.closest(`${E} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${E} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=C.current?.querySelector(`${T}[${j}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function z(){let e=U().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(j);F.setState(`value`,e||void 0)}function B(){if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=L(o.current.get(t)?.value??``,o.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function V(){var e;let t=H();t&&(t.parentElement?.firstChild===t&&((e=t.closest(T)?.querySelector(D))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function H(){return C.current?.querySelector(`${O}[aria-selected="true"]`)}function U(){return Array.from(C.current?.querySelectorAll(k)||[])}function W(e){let t=U()[e];t&&F.setState(`value`,t.getAttribute(j))}function G(e){var t;let n=H(),r=U(),i=r.findIndex(e=>e===n),a=r[i+e];(t=l.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&F.setState(`value`,a.getAttribute(j))}function K(e){let t=H()?.closest(T),n;for(;t&&!n;)t=e>0?te(t,T):ne(t,T),n=t?.querySelector(k);n?F.setState(`value`,n.getAttribute(j)):G(e)}let X=()=>W(U().length-1),Z=e=>{e.preventDefault(),e.metaKey?X():e.altKey?K(1):G(1)},Q=e=>{e.preventDefault(),e.metaKey?W(0):e.altKey?K(-1):G(-1)};return w.createElement(c.div,{ref:t,tabIndex:-1,...y,"cmdk-root":``,onKeyDown:e=>{var t;(t=y.onKeyDown)==null||t.call(y,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:v&&e.ctrlKey&&Z(e);break;case`ArrowDown`:Z(e);break;case`p`:case`k`:v&&e.ctrlKey&&Q(e);break;case`ArrowUp`:Q(e);break;case`Home`:e.preventDefault(),W(0);break;case`End`:e.preventDefault(),X();break;case`Enter`:{e.preventDefault();let t=H();if(t){let e=new Event(A);t.dispatchEvent(e)}}}}},w.createElement(`label`,{"cmdk-label":``,htmlFor:I.inputId,id:I.labelId,style:ie},u),$(e,e=>w.createElement(P.Provider,{value:F},w.createElement(M.Provider,{value:I},e))))}),R=w.forwardRef((e,t)=>{let r=a(),i=w.useRef(null),o=w.useContext(I),s=N(),l=q(e),u=l.current?.forceMount??o?.forceMount;J(()=>{if(!u)return s.item(r,o?.id)},[u]);let d=Z(r,i,[e.value,e.children,i],e.keywords),f=F(),p=X(e=>e.value&&e.value===d.current),m=X(e=>u||s.filter()===!1?!0:e.search?e.filtered.items.get(r)>0:!0);w.useEffect(()=>{let t=i.current;if(!(!t||e.disabled))return t.addEventListener(A,h),()=>t.removeEventListener(A,h)},[m,e.onSelect,e.disabled]);function h(){var e,t;g(),(t=(e=l.current).onSelect)==null||t.call(e,d.current)}function g(){f.setState(`value`,d.current,!0)}if(!m)return null;let{disabled:_,value:v,onSelect:y,forceMount:b,keywords:x,...S}=e;return w.createElement(c.div,{ref:n(i,t),...S,id:r,"cmdk-item":``,role:`option`,"aria-disabled":!!_,"aria-selected":!!p,"data-disabled":!!_,"data-selected":!!p,onPointerMove:_||s.getDisablePointerSelection()?void 0:g,onClick:_?void 0:h},e.children)}),z=w.forwardRef((e,t)=>{let{heading:r,children:i,forceMount:o,...s}=e,l=a(),u=w.useRef(null),d=w.useRef(null),f=a(),p=N(),m=X(e=>o||p.filter()===!1?!0:e.search?e.filtered.groups.has(l):!0);J(()=>p.group(l),[]),Z(l,u,[e.value,e.heading,d]);let h=w.useMemo(()=>({id:l,forceMount:o}),[o]);return w.createElement(c.div,{ref:n(u,t),...s,"cmdk-group":``,role:`presentation`,hidden:m?void 0:!0},r&&w.createElement(`div`,{ref:d,"cmdk-group-heading":``,"aria-hidden":!0,id:f},r),$(e,e=>w.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":r?f:void 0},w.createElement(I.Provider,{value:h},e))))}),B=w.forwardRef((e,t)=>{let{alwaysRender:r,...i}=e,a=w.useRef(null),o=X(e=>!e.search);return!r&&!o?null:w.createElement(c.div,{ref:n(a,t),...i,"cmdk-separator":``,role:`separator`})}),V=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=F(),o=X(e=>e.search),s=X(e=>e.selectedItemId),l=N();return w.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),w.createElement(c.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":s,id:l.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),H=w.forwardRef((e,t)=>{let{children:r,label:i=`Suggestions`,...a}=e,o=w.useRef(null),s=w.useRef(null),l=X(e=>e.selectedItemId),u=N();return w.useEffect(()=>{if(s.current&&o.current){let e=s.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),w.createElement(c.div,{ref:n(o,t),...a,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:u.listId},$(e,e=>w.createElement(`div`,{ref:n(s,u.listInnerRef),"cmdk-list-sizer":``},e)))}),U=w.forwardRef((e,n)=>{let{open:a,onOpenChange:s,overlayClassName:c,contentClassName:l,container:u,...d}=e;return w.createElement(r,{open:a,onOpenChange:s},w.createElement(o,{container:u},w.createElement(t,{"cmdk-overlay":``,className:c}),w.createElement(i,{"aria-label":e.label,"cmdk-dialog":``,className:l},w.createElement(L,{ref:n,...d}))))}),W=w.forwardRef((e,t)=>X(e=>e.filtered.count===0)?w.createElement(c.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),G=w.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return w.createElement(c.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},$(e,e=>w.createElement(`div`,{"aria-hidden":!0},e)))}),K=Object.assign(L,{List:H,Item:R,Input:V,Group:z,Separator:B,Dialog:U,Empty:W,Loading:G});function te(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ne(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function q(e){let t=w.useRef(e);return J(()=>{t.current=e}),t}var J=typeof window>`u`?w.useEffect:w.useLayoutEffect;function Y(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function X(e){let t=F(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function Z(e,t,n,r=[]){let i=w.useRef(),a=N();return J(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(j,s),i.current=s}),i}var re=()=>{let[e,t]=w.useState(),n=Y(()=>new Map);return J(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Q(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function $({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(Q(t),{ref:t.ref},n(t.props.children)):n(t)}var ie={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};export{K as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Fr as t,Ir as n,Lr as r,Nr as i,ji as a,ri as o,wr as s,yo as c}from"./dialogs-config-I0_cSU2z.js";var l=1,u=.9,d=.8,f=.17,p=.1,m=.999,h=.9999,g=.99,_=/[\\\/_+.#"@\[\(\{&]/,v=/[\\\/_+.#"@\[\(\{&]/g,y=/[\s-]/,b=/[\s-]/g;function x(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?l:g;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),S=n.indexOf(c,i),C=0,w,T,E,D;S>=0;)w=x(e,t,n,r,S+1,a+1,o),w>C&&(S===i?w*=l:_.test(e.charAt(S-1))?(w*=d,E=e.slice(i,S-1).match(v),E&&i>0&&(w*=m**+E.length)):y.test(e.charAt(S-1))?(w*=u,D=e.slice(i,S-1).match(b),D&&i>0&&(w*=m**+D.length)):(w*=f,i>0&&(w*=m**+(S-i))),e.charAt(S)!==t.charAt(a)&&(w*=h)),(w<p&&n.charAt(S-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(S-1)!==r.charAt(a))&&(T=x(e,t,n,r,S+1,a+2,o),T*p>w&&(w=T*p)),w>C&&(C=w),S=n.indexOf(c,S+1);return o[s]=C,C}function S(e){return e.toLowerCase().replace(b,` `)}function C(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,x(e,t,S(e),S(t),0,0,{})}var w=e(c(),1),T=`[cmdk-group=""]`,E=`[cmdk-group-items=""]`,D=`[cmdk-group-heading=""]`,O=`[cmdk-item=""]`,k=`${O}:not([aria-disabled="true"])`,A=`cmdk-item-select`,j=`data-value`,ee=(e,t,n)=>C(e,t,n),M=w.createContext(void 0),N=()=>w.useContext(M),P=w.createContext(void 0),F=()=>w.useContext(P),I=w.createContext(void 0),L=w.forwardRef((e,t)=>{let n=Y(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Y(()=>new Set),i=Y(()=>new Map),a=Y(()=>new Map),c=Y(()=>new Set),l=q(e),{label:u,children:d,value:f,onValueChange:p,filter:m,shouldFilter:h,loop:g,disablePointerSelection:_=!1,vimBindings:v=!0,...y}=e,b=o(),x=o(),S=o(),C=w.useRef(null),N=re();J(()=>{if(f!==void 0){let e=f.trim();n.current.value=e,F.emit()}},[f]),J(()=>{N(6,V)},[]);let F=w.useMemo(()=>({subscribe:e=>(c.current.add(e),()=>c.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)B(),R(),N(1,z);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(S);e?e.focus():(i=document.getElementById(b))==null||i.focus()}if(N(7,()=>{n.current.selectedItemId=H()?.id,F.emit()}),r||N(5,V),l.current?.value!==void 0){let e=t??``;(o=(a=l.current).onValueChange)==null||o.call(a,e);return}}F.emit()}},emit:()=>{c.current.forEach(e=>e())}}),[]),I=w.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,L(t,r)),N(2,()=>{R(),F.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),N(3,()=>{B(),R(),n.current.value||z(),F.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=H();N(4,()=>{B(),t?.getAttribute(`id`)===e&&z(),F.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e[`aria-label`],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:S,labelId:x,listInnerRef:C}),[]);function L(e,t){let r=l.current?.filter??ee;return e?r(e,n.current.search,t):0}function R(){if(!n.current.search||l.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=C.current;U().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(E);t?t.appendChild(e.parentElement===t?e:e.closest(`${E} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${E} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=C.current?.querySelector(`${T}[${j}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function z(){let e=U().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(j);F.setState(`value`,e||void 0)}function B(){if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=L(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function V(){var e;let t=H();t&&(t.parentElement?.firstChild===t&&((e=t.closest(T)?.querySelector(D))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function H(){return C.current?.querySelector(`${O}[aria-selected="true"]`)}function U(){return Array.from(C.current?.querySelectorAll(k)||[])}function W(e){let t=U()[e];t&&F.setState(`value`,t.getAttribute(j))}function G(e){var t;let n=H(),r=U(),i=r.findIndex(e=>e===n),a=r[i+e];(t=l.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&F.setState(`value`,a.getAttribute(j))}function K(e){let t=H()?.closest(T),n;for(;t&&!n;)t=e>0?te(t,T):ne(t,T),n=t?.querySelector(k);n?F.setState(`value`,n.getAttribute(j)):G(e)}let X=()=>W(U().length-1),Z=e=>{e.preventDefault(),e.metaKey?X():e.altKey?K(1):G(1)},Q=e=>{e.preventDefault(),e.metaKey?W(0):e.altKey?K(-1):G(-1)};return w.createElement(s.div,{ref:t,tabIndex:-1,...y,"cmdk-root":``,onKeyDown:e=>{var t;(t=y.onKeyDown)==null||t.call(y,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:v&&e.ctrlKey&&Z(e);break;case`ArrowDown`:Z(e);break;case`p`:case`k`:v&&e.ctrlKey&&Q(e);break;case`ArrowUp`:Q(e);break;case`Home`:e.preventDefault(),W(0);break;case`End`:e.preventDefault(),X();break;case`Enter`:{e.preventDefault();let t=H();if(t){let e=new Event(A);t.dispatchEvent(e)}}}}},w.createElement(`label`,{"cmdk-label":``,htmlFor:I.inputId,id:I.labelId,style:ie},u),$(e,e=>w.createElement(P.Provider,{value:F},w.createElement(M.Provider,{value:I},e))))}),R=w.forwardRef((e,t)=>{let n=o(),r=w.useRef(null),i=w.useContext(I),c=N(),l=q(e),u=l.current?.forceMount??i?.forceMount;J(()=>{if(!u)return c.item(n,i?.id)},[u]);let d=Z(n,r,[e.value,e.children,r],e.keywords),f=F(),p=X(e=>e.value&&e.value===d.current),m=X(e=>u||c.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);w.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(A,h),()=>t.removeEventListener(A,h)},[m,e.onSelect,e.disabled]);function h(){var e,t;g(),(t=(e=l.current).onSelect)==null||t.call(e,d.current)}function g(){f.setState(`value`,d.current,!0)}if(!m)return null;let{disabled:_,value:v,onSelect:y,forceMount:b,keywords:x,...S}=e;return w.createElement(s.div,{ref:a(r,t),...S,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!_,"aria-selected":!!p,"data-disabled":!!_,"data-selected":!!p,onPointerMove:_||c.getDisablePointerSelection()?void 0:g,onClick:_?void 0:h},e.children)}),z=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...c}=e,l=o(),u=w.useRef(null),d=w.useRef(null),f=o(),p=N(),m=X(e=>i||p.filter()===!1?!0:e.search?e.filtered.groups.has(l):!0);J(()=>p.group(l),[]),Z(l,u,[e.value,e.heading,d]);let h=w.useMemo(()=>({id:l,forceMount:i}),[i]);return w.createElement(s.div,{ref:a(u,t),...c,"cmdk-group":``,role:`presentation`,hidden:m?void 0:!0},n&&w.createElement(`div`,{ref:d,"cmdk-group-heading":``,"aria-hidden":!0,id:f},n),$(e,e=>w.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?f:void 0},w.createElement(I.Provider,{value:h},e))))}),B=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=w.useRef(null),o=X(e=>!e.search);return!n&&!o?null:w.createElement(s.div,{ref:a(i,t),...r,"cmdk-separator":``,role:`separator`})}),V=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=F(),o=X(e=>e.search),c=X(e=>e.selectedItemId),l=N();return w.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),w.createElement(s.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":c,id:l.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),H=w.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,o=w.useRef(null),c=w.useRef(null),l=X(e=>e.selectedItemId),u=N();return w.useEffect(()=>{if(c.current&&o.current){let e=c.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),w.createElement(s.div,{ref:a(o,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:u.listId},$(e,e=>w.createElement(`div`,{ref:a(c,u.listInnerRef),"cmdk-list-sizer":``},e)))}),U=w.forwardRef((e,a)=>{let{open:o,onOpenChange:s,overlayClassName:c,contentClassName:l,container:u,...d}=e;return w.createElement(r,{open:o,onOpenChange:s},w.createElement(n,{container:u},w.createElement(t,{"cmdk-overlay":``,className:c}),w.createElement(i,{"aria-label":e.label,"cmdk-dialog":``,className:l},w.createElement(L,{ref:a,...d}))))}),W=w.forwardRef((e,t)=>X(e=>e.filtered.count===0)?w.createElement(s.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),G=w.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return w.createElement(s.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},$(e,e=>w.createElement(`div`,{"aria-hidden":!0},e)))}),K=Object.assign(L,{List:H,Item:R,Input:V,Group:z,Separator:B,Dialog:U,Empty:W,Loading:G});function te(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ne(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function q(e){let t=w.useRef(e);return J(()=>{t.current=e}),t}var J=typeof window>`u`?w.useEffect:w.useLayoutEffect;function Y(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function X(e){let t=F(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function Z(e,t,n,r=[]){let i=w.useRef(),a=N();return J(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(j,s),i.current=s}),i}var re=()=>{let[e,t]=w.useState(),n=Y(()=>new Map);return J(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Q(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function $({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(Q(t),{ref:t.ref},n(t.props.children)):n(t)}var ie={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};export{K as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{mo as t}from"./dialogs-config-B4TDFSrS.js";var n=e(t(),1),r=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},i=[`light`,`dark`],a=`(prefers-color-scheme: dark)`,o=typeof window>`u`,s=n.createContext(void 0),c={setTheme:e=>{},themes:[]},l=()=>n.useContext(s)??c,u=e=>n.useContext(s)?n.createElement(n.Fragment,null,e.children):n.createElement(f,{...e}),d=[`light`,`dark`],f=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:r=!0,enableColorScheme:o=!0,storageKey:c=`theme`,themes:l=d,defaultTheme:u=r?`system`:`light`,attribute:f=`data-theme`,value:_,children:v,nonce:y,scriptProps:b})=>{let[x,S]=n.useState(()=>m(c,u)),[C,w]=n.useState(()=>x===`system`?g():x),T=_?Object.values(_):l,E=n.useCallback(e=>{let n=e;if(!n)return;e===`system`&&r&&(n=g());let a=_?_[n]:n,s=t?h(y):null,c=document.documentElement,l=e=>{e===`class`?(c.classList.remove(...T),a&&c.classList.add(a)):e.startsWith(`data-`)&&(a?c.setAttribute(e,a):c.removeAttribute(e))};if(Array.isArray(f)?f.forEach(l):l(f),o){let e=i.includes(u)?u:null,t=i.includes(n)?n:e;c.style.colorScheme=t}s?.()},[y]),D=n.useCallback(e=>{let t=typeof e==`function`?e(x):e;S(t);try{localStorage.setItem(c,t)}catch{}},[x]),O=n.useCallback(t=>{w(g(t)),x===`system`&&r&&!e&&E(`system`)},[x,e]);n.useEffect(()=>{let e=window.matchMedia(a);return e.addListener(O),O(e),()=>e.removeListener(O)},[O]),n.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?S(e.newValue):D(u))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[D]),n.useEffect(()=>{E(e??x)},[e,x]);let k=n.useMemo(()=>({theme:x,setTheme:D,forcedTheme:e,resolvedTheme:x===`system`?C:x,themes:r?[...l,`system`]:l,systemTheme:r?C:void 0}),[x,D,e,C,r,l]);return n.createElement(s.Provider,{value:k},n.createElement(p,{forcedTheme:e,storageKey:c,attribute:f,enableSystem:r,enableColorScheme:o,defaultTheme:u,value:_,themes:l,nonce:y,scriptProps:b}),v)},p=n.memo(({forcedTheme:e,storageKey:t,attribute:i,enableSystem:a,enableColorScheme:o,defaultTheme:s,value:c,themes:l,nonce:u,scriptProps:d})=>{let f=JSON.stringify([i,t,s,e,l,c,a,o]).slice(1,-1);return n.createElement(`script`,{...d,suppressHydrationWarning:!0,nonce:typeof window>`u`?u:``,dangerouslySetInnerHTML:{__html:`(${r.toString()})(${f})`}})}),m=(e,t)=>{if(o)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},h=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},g=e=>(e||=window.matchMedia(a),e.matches?`dark`:`light`);export{l as n,u as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{yo as t}from"./dialogs-config-I0_cSU2z.js";var n=e(t(),1),r=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},i=[`light`,`dark`],a=`(prefers-color-scheme: dark)`,o=typeof window>`u`,s=n.createContext(void 0),c={setTheme:e=>{},themes:[]},l=()=>n.useContext(s)??c,u=e=>n.useContext(s)?n.createElement(n.Fragment,null,e.children):n.createElement(f,{...e}),d=[`light`,`dark`],f=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:r=!0,enableColorScheme:o=!0,storageKey:c=`theme`,themes:l=d,defaultTheme:u=r?`system`:`light`,attribute:f=`data-theme`,value:_,children:v,nonce:y,scriptProps:b})=>{let[x,S]=n.useState(()=>m(c,u)),[C,w]=n.useState(()=>x===`system`?g():x),T=_?Object.values(_):l,E=n.useCallback(e=>{let n=e;if(!n)return;e===`system`&&r&&(n=g());let a=_?_[n]:n,s=t?h(y):null,c=document.documentElement,l=e=>{e===`class`?(c.classList.remove(...T),a&&c.classList.add(a)):e.startsWith(`data-`)&&(a?c.setAttribute(e,a):c.removeAttribute(e))};if(Array.isArray(f)?f.forEach(l):l(f),o){let e=i.includes(u)?u:null,t=i.includes(n)?n:e;c.style.colorScheme=t}s?.()},[y]),D=n.useCallback(e=>{let t=typeof e==`function`?e(x):e;S(t);try{localStorage.setItem(c,t)}catch{}},[x]),O=n.useCallback(t=>{w(g(t)),x===`system`&&r&&!e&&E(`system`)},[x,e]);n.useEffect(()=>{let e=window.matchMedia(a);return e.addListener(O),O(e),()=>e.removeListener(O)},[O]),n.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?S(e.newValue):D(u))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[D]),n.useEffect(()=>{E(e??x)},[e,x]);let k=n.useMemo(()=>({theme:x,setTheme:D,forcedTheme:e,resolvedTheme:x===`system`?C:x,themes:r?[...l,`system`]:l,systemTheme:r?C:void 0}),[x,D,e,C,r,l]);return n.createElement(s.Provider,{value:k},n.createElement(p,{forcedTheme:e,storageKey:c,attribute:f,enableSystem:r,enableColorScheme:o,defaultTheme:u,value:_,themes:l,nonce:y,scriptProps:b}),v)},p=n.memo(({forcedTheme:e,storageKey:t,attribute:i,enableSystem:a,enableColorScheme:o,defaultTheme:s,value:c,themes:l,nonce:u,scriptProps:d})=>{let f=JSON.stringify([i,t,s,e,l,c,a,o]).slice(1,-1);return n.createElement(`script`,{...d,suppressHydrationWarning:!0,nonce:typeof window>`u`?u:``,dangerouslySetInnerHTML:{__html:`(${r.toString()})(${f})`}})}),m=(e,t)=>{if(o)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},h=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},g=e=>(e||=window.matchMedia(a),e.matches?`dark`:`light`);export{l as n,u as t};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./monaco-CZnIWXyV.js";var t=class e{static levels={DEBUG:0,INFO:1,WARN:2,ERROR:3};level;prefix;constructor(t=e.levels.INFO,n=``){this.level=t,this.prefix=n}debug(...t){this.level<=e.levels.DEBUG&&console.debug(`[${this.prefix}] [DEBUG]`,...t)}info(...t){this.level<=e.levels.INFO&&console.info(`[${this.prefix}] [INFO]`,...t)}warn(...t){this.level<=e.levels.WARN&&console.warn(`[${this.prefix}] [WARN]`,...t)}error(...t){this.level<=e.levels.ERROR&&console.error(`[${this.prefix}] [ERROR]`,...t)}setLevel(e){this.level=e}getLevel(){return this.level}};function n(e){try{return JSON.stringify(e)}catch{return`"[non-serializable]"`}}function r(e){let t;try{t=n(e)}catch{console.error(`[voice-log] failed to serialize log payload`);return}fetch(`/api/logs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:t}).catch(e=>{console.error(`[voice-log] fetch to /api/logs failed:`,e)})}function i(e){function t(t,n,i){r({level:t,context:e,message:n,data:i});let a=`[${e}]`;t===`ERROR`?console.error(a,n,i??``):t===`WARN`?console.warn(a,n,i??``):t===`DEBUG`?console.debug(a,n,i??``):console.info(a,n,i??``)}return{debug:(e,n)=>t(`DEBUG`,e,n),info:(e,n)=>t(`INFO`,e,n),warn:(e,n)=>t(`WARN`,e,n),error:(e,n)=>t(`ERROR`,e,n),separator:e=>t(`INFO`,`${`─`.repeat(20)} ${e} ${`─`.repeat(20)}`)}}var a=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),o={language:`auto`,threads:4,translate:!1};function s(e){let t=String(e).trim().replace(`,`,`.`),n=t.split(`:`).map(Number);if(n.some(Number.isNaN))throw Error(`Bad time: "${e}"`);let r=0,i=0,a=0;if(n.length===3)[r,i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else if(n.length===2)[i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else throw Error(`Bad time format: "${e}"`);return Math.floor(((r*60+i)*60+a)*1e3)}function c(e){let t=/^\s*\[?\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*-->\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*\]?\s*(.*)\s*$/.exec(e);if(!t)throw Error(`Line does not match VTT-like pattern: `+e);let n=t[1],r=t[2],i=t[3]||``,a=s(n),o=s(r);if(o<a)throw Error(`End time is before start time`);return{startMs:a,endMs:o,start:n,end:r,text:i}}function l(e){return new Promise(t=>setTimeout(t,e))}function u(e,t){let n=null,r=!1,i=null,a=null;return{timeoutError:()=>new Promise((o,s)=>{a=o,i=s,n=setTimeout(()=>{!r&&i&&(r=!0,i(Error(t)))},e)}),clear:()=>{n&&=(clearTimeout(n),null),a&&=(a(),null),r=!0,i=null}}}var d=16e3*15;function f(e,t=d){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}var p=class{whisperService;logger;constructor(e,n){this.whisperService=e,this.logger=new t(n?.logLevel||t.levels.ERROR,`TranscriptionSession`)}async*streaming(e,t={}){let{timeoutMs:n=3e4}=t,r=f(e),i=0;for(let e of r){let r=[],a=null,o=!1,s,c=0,{timeoutError:d,clear:f}=u(n,`Transcribe timeout`),p=()=>this.whisperService.transcribe(e,e=>{c=e.timeEnd,e.timeStart+=i,e.timeEnd+=i,this.logger.debug(`Transcription segment in session:`,e),a?(a(e),a=null):r.push(e),f()},t).then(()=>{this.logger.debug(`Transcription done in session then`),o=!0,i+=c,f(),a?.(void 0)}).catch(e=>{this.logger.debug(`Transcription error in session catch:`,e),s=e,f(),a?.(void 0)});for(p();;){if(s){if(t.restartModelOnError){this.whisperService.restartModel(),p();continue}throw s}if(o)break;if(r.length)yield r.shift();else try{let e=await Promise.race([new Promise(e=>a=e),d()]);e&&(yield e)}catch(e){s=e}}t.sleepMsBetweenChunks&&await l(t.sleepMsBetweenChunks)}}async*streamimg(e,t={}){yield*this.streaming(e,t)}},m=i(`WhisperWasmService`),h=class extends EventTarget{on(e,t){return this.addEventListener(e,t),()=>this.removeEventListener(e,t)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}},g=class n{static wasmSupportPromise=null;wasmModule=null;instance=null;modelFileName=`whisper.bin`;isTranscribing=!1;bus=new h;logger;modelData=null;constructor(e){this.logger=new t(e?.logLevel??t.levels.ERROR,`WhisperWasmService`),e?.init&&this.loadWasmScript()}async checkWasmSupport(){return n.wasmSupportPromise??=a(),await n.wasmSupportPromise}async loadWasmScript(){let t=`${typeof window<`u`?window.location.origin:``}/wasm/libmain-D9-QM3iM.mjs`,n={print:(e,...t)=>{t.length>0&&this.logger.debug(t),e.startsWith(`[`)?(this.logger.info(e),this.bus.emit(`transcribe`,e)):(this.logger.debug(e),this.bus.emit(`system_info`,e))},printErr:(e,...t)=>{t.length>0&&this.logger.debug(t),this.logger.warn(e),m.warn(`WASM stderr output`,{message:e,extra:t.length?t:void 0}),this.bus.emit(`transcribeError`,e)}};m.info(`Loading WASM script`,{url:t}),globalThis.__mockWhisperWasmImport__?this.wasmModule=await globalThis.__mockWhisperWasmImport__(t,n):this.wasmModule=await(await e(async()=>{let{default:e}=await import(t);return{default:e}},[])).default(n),m.info(`WASM script loaded successfully`)}async initModel(e){if(!await this.checkWasmSupport())throw Error(`WASM is not supported`);return m.info(`Initializing WASM model`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),this.modelData=e,this.wasmModule&&(this.wasmModule.FS_unlink(this.modelFileName),this.wasmModule.free(),m.debug(`Previous WASM module freed`)),await this.loadWasmScript(),await l(100),m.info(`Storing model in WASM FS`,{fileName:this.modelFileName,sizeBytes:e.byteLength}),this.storeFS(this.modelFileName,e),m.info(`Creating WASM instance`),this.instance=this.wasmModule.init(this.modelFileName),m.info(`WASM instance created`,{instance:this.instance}),Promise.resolve()}restartModel(){if(!this.modelData)throw Error(`Model not loaded`);return this.initModel(this.modelData)}storeFS(e,t){if(!this.wasmModule)throw Error(`WASM module not loaded`);try{this.wasmModule.FS_unlink(e)}catch{}this.wasmModule.FS_createDataFile(`/`,e,t,!0,!0,!0)}async transcribe(e,t,n={}){if(this.isTranscribing)throw Error(`Already transcribing`);if(!this.wasmModule)throw Error(`WASM module not loaded`);if(!this.instance)throw Error(`WASM instance not loaded`);e.length>16e3*120&&this.logger.warn(`It's not recommended to transcribe audio data that is longer than 120 seconds`),this.isTranscribing=!0;let{language:r=`auto`,threads:i=4,translate:a=!1}={...o,...n},s=[],l=Date.now();m.info(`Calling WASM full_default`,{sampleCount:e.length,durationSec:(e.length/16e3).toFixed(2),language:r,threads:i,translate:a,instance:this.instance});try{this.wasmModule.full_default(this.instance,e,r,i,a),m.info(`WASM full_default returned without throwing`)}catch(e){let t=e instanceof Error?e.message:String(e);throw m.error(`WASM full_default threw an exception`,{error:t,type:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
2
- `).slice(0,5).join(` | `):void 0}),this.isTranscribing=!1,e}return await new Promise((e,n)=>{let r=this.bus.on(`transcribe`,e=>{let{startMs:n,endMs:r,text:i}=c(e.detail),a={timeStart:n,timeEnd:r,text:i,raw:e.detail};s.push(a),t?.(a)}),i=setTimeout(()=>{this.isTranscribing=!1,r(),a(),this.logger.error(`Transcribe timeout`),n(Error(`Transcribe timeout`)),this.bus.emit(`transcribeError`,`Transcribe timeout`)},240*1e3),a=this.bus.on(`transcribeError`,t=>{this.isTranscribing=!1,r(),a(),clearTimeout(i),this.logger.debug(`Transcribe error`,t.detail),e({segments:s,transcribeDurationMs:Date.now()-l})})})}createSession(){return new p(this,{logLevel:this.logger.getLevel()})}},_={"tiny.en":{id:`tiny.en`,name:`Tiny English`,size:75,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin`},tiny:{id:`tiny`,name:`Tiny Multilingual`,size:75,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin`},"base.en":{id:`base.en`,name:`Base English`,size:142,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin`},base:{id:`base`,name:`Base Multilingual`,size:142,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin`},"small.en":{id:`small.en`,name:`Small English`,size:466,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin`},small:{id:`small`,name:`Small Multilingual`,size:466,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin`},"tiny.en-q5_1":{id:`tiny.en-q5_1`,name:`Tiny English (Q5_1)`,size:31,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en-q5_1.bin`},"tiny-q5_1":{id:`tiny-q5_1`,name:`Tiny Multilingual (Q5_1)`,size:31,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny-q5_1.bin`},"base.en-q5_1":{id:`base.en-q5_1`,name:`Base English (Q5_1)`,size:57,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en-q5_1.bin`},"base-q5_1":{id:`base-q5_1`,name:`Base Multilingual (Q5_1)`,size:57,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base-q5_1.bin`},"small.en-q5_1":{id:`small.en-q5_1`,name:`Small English (Q5_1)`,size:182,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en-q5_1.bin`},"small-q5_1":{id:`small-q5_1`,name:`Small Multilingual (Q5_1)`,size:182,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small-q5_1.bin`},"medium.en-q5_0":{id:`medium.en-q5_0`,name:`Medium English (Q5_0)`,size:515,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.en-q5_0.bin`},"medium-q5_0":{id:`medium-q5_0`,name:`Medium Multilingual (Q5_0)`,size:515,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium-q5_0.bin`},"large-q5_0":{id:`large-q5_0`,name:`Large Multilingual (Q5_0)`,size:1030,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-q5_0.bin`}};function v(){return Object.values(_).map(({url:e,...t})=>t)}function y(e){return _[e]}var b=class{cacheEnabled=!0;models=v();logger;constructor(e={logLevel:t.levels.ERROR}){this.logger=new t(e.logLevel,`ModelManager`)}async loadModel(e,t=!0,n){let r=y(e);if(!r)throw Error(`Model ${e} not found in config`);if(this.cacheEnabled&&t){let t=await this.getCachedModel(e);if(t)return this.logger.info(`Model ${e} loaded from cache`),n&&n(100),t}this.logger.info(`Loading model ${e} from ${r.url}`);let i=await fetch(r.url);if(!i.ok)throw Error(`Failed to load model: ${i.statusText}`);let a=i.headers.get(`content-length`),o=a?parseInt(a,10):0,s=0,c=i.body?.getReader();if(!c)throw Error(`Response body is not readable`);let l=[];try{let e=!1;for(;!e;){let t=await c.read();e=t.done,!e&&t.value&&(l.push(t.value),s+=t.value.length,n&&o>0&&n(Math.round(s/o*100)))}}finally{c.releaseLock()}let u=l.reduce((e,t)=>e+t.length,0),d=new Uint8Array(u),f=0;for(let e of l)d.set(e,f),f+=e.length;return this.cacheEnabled&&t&&await this.saveModelToCache(e,d),n&&n(100),d}async loadModelByUrl(e,t){try{if(this.cacheEnabled){let n=await this.getCachedModelByUrl(e);if(n)return this.logger.info(`WASM module loaded from cache by URL: ${e}`),t&&t(100),n}this.logger.info(`Loading WASM module from URL: ${e}`);let n=await fetch(e);if(!n.ok)throw Error(`Failed to load WASM module: ${n.statusText}`);let r=n.headers.get(`content-length`),i=r?parseInt(r,10):0,a=0,o=n.body?.getReader();if(!o)throw Error(`Response body is not readable`);let s=[];try{let e=!1;for(;!e;){let n=await o.read();e=n.done,!e&&n.value&&(s.push(n.value),a+=n.value.length,t&&i>0&&t(Math.round(a/i*100)))}}finally{o.releaseLock()}let c=s.reduce((e,t)=>e+t.length,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;return this.cacheEnabled&&await this.saveModelToCacheByUrl(e,l),t&&t(100),l}catch(e){this.logger.error(e);let t=e instanceof Error?e.message:`Failed to load WASM module`;throw Error(t)}}async getCachedModelByUrl(e){try{let t=(await this.openIndexedDB()).transaction([`modelsByUrl`],`readonly`).objectStore(`modelsByUrl`);return new Promise((n,r)=>{let i=t.get(e);i.onsuccess=()=>{let e=i.result;e&&e.data?n(e.data):n(null)},i.onerror=()=>r(i.error)})}catch(e){return this.logger.error(`Error reading model from cache by URL:`,e),null}}async saveModelToCacheByUrl(e,t){try{let n=(await this.openIndexedDB()).transaction([`modelsByUrl`],`readwrite`).objectStore(`modelsByUrl`);await new Promise((r,i)=>{let a=n.put({url:e,data:t,timestamp:Date.now(),size:t.length});a.onsuccess=()=>r(),a.onerror=()=>i(a.error)}),this.logger.info(`Model saved to cache by URL: ${e}`)}catch(e){this.logger.error(`Error saving model to cache by URL:`,e)}}async getAvailableModels(){let e=[...this.models];if(!this.cacheEnabled)return e;try{let t=await this.getCachedModelNames();return e.map(e=>({...e,cached:t.includes(e.id)}))}catch(t){return this.logger.error(`Error checking cache status:`,t),e}}getAvailableModelsSync(){return[...this.models]}getModelConfig(e){return y(e)}async saveModelToCache(e,t){try{let n=(await this.openIndexedDB()).transaction([`models`],`readwrite`).objectStore(`models`);await new Promise((r,i)=>{let a=n.put({name:e,data:t,timestamp:Date.now(),size:t.length});a.onsuccess=()=>r(),a.onerror=()=>i(a.error)}),this.logger.info(`Model ${e} saved to cache`)}catch(e){this.logger.error(`Error saving model to cache:`,e)}}async getCachedModel(e){try{let t=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((n,r)=>{let i=t.get(e);i.onsuccess=()=>{let e=i.result;e&&e.data?n(e.data):n(null)},i.onerror=()=>r(i.error)})}catch(e){return this.logger.error(`Error getting cached model:`,e),null}}async getCachedModelNames(){try{let e=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((t,n)=>{let r=e.getAllKeys();r.onsuccess=()=>{let e=r.result;t(e)},r.onerror=()=>n(r.error)})}catch(e){return this.logger.error(`Error getting cached model names:`,e),[]}}async openIndexedDB(){return new Promise((e,t)=>{let n=indexedDB.open(`WhisperModels`,2);n.onerror=()=>t(n.error),n.onsuccess=()=>e(n.result),n.onupgradeneeded=e=>{let t=e.target.result;if(!t.objectStoreNames.contains(`models`)){let e=t.createObjectStore(`models`,{keyPath:`name`});e.createIndex(`timestamp`,`timestamp`,{unique:!1}),e.createIndex(`size`,`size`,{unique:!1})}if(!t.objectStoreNames.contains(`modelsByUrl`)){let e=t.createObjectStore(`modelsByUrl`,{keyPath:`url`});e.createIndex(`timestamp`,`timestamp`,{unique:!1}),e.createIndex(`size`,`size`,{unique:!1})}}})}async clearCache(){try{let e=(await this.openIndexedDB()).transaction([`models`,`modelsByUrl`],`readwrite`),t=e.objectStore(`models`);await new Promise((e,n)=>{let r=t.clear();r.onsuccess=()=>e(),r.onerror=()=>n(r.error)});let n=e.objectStore(`modelsByUrl`);await new Promise((e,t)=>{let r=n.clear();r.onsuccess=()=>e(),r.onerror=()=>t(r.error)}),this.logger.info(`Model cache cleared`)}catch(e){this.logger.error(`Error clearing cache:`,e)}}async getCacheInfo(){try{let e=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((t,n)=>{let r=e.getAll();r.onsuccess=()=>{let e=r.result,n=e.reduce((e,t)=>e+(t.size||0),0);t({count:e.length,totalSize:n})},r.onerror=()=>n(r.error)})}catch(e){return this.logger.error(`Error getting cache info:`,e),{count:0,totalSize:0}}}},x={targetSampleRate:16e3,targetChannels:1,inputSampleRate:16e3,normalize:!0,noiseReduction:!1,logLevel:t.levels.ERROR,signal:void 0,recordingDurationMs:1e4};function S(e){return typeof e==`number`?e:e?t.levels[e]:t.levels.ERROR}function C(e){return new t(S(e.logLevel),`AudioConverter`)}function w(e){if(e?.aborted)throw new DOMException(`Aborted`,`AbortError`)}function T(){return typeof window>`u`?!1:!!(window.AudioContext||window.webkitAudioContext||window.OfflineAudioContext||window.webkitOfflineAudioContext)}async function E(e,t={},n={}){if(!T())throw Error(`Web Audio API is not supported in this browser`);let r={...x,...t},i=C(r),a=[];try{w(r.signal),i.info(`Converting from MediaStream`),n.onProgress?.(0,`Starting recording...`);let t=await P(e,r,n,i);n.onProgress?.(50,`Recording completed, decoding...`);let o=await D(await t.arrayBuffer(),r,n,i);n.onProgress?.(70,`Audio decoded, processing...`);let s=await O(o,r,n,i,a);return n.onProgress?.(100,`Conversion completed`),s}catch(e){throw i.error(`MediaStream conversion failed:`,e),n.onError?.(e),e}}async function D(e,t,n,r){n.onProgress?.(15,`Decoding audio data`);let i=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t.targetSampleRate});try{return await i.decodeAudioData(e)}catch(e){throw r.error(`Audio decoding failed:`,e),Error(`Failed to decode audio: ${e.message}`)}finally{try{await i.close()}catch{}}}async function O(e,t,n,r,i){n.onProgress?.(50,`Converting audio format...`),N(e,t,i);let a=await k(e,t,n);n.onProgress?.(70,`Converting to Float32Array...`);let o=A(a);return n.onProgress?.(80,`Applying effects...`),t.normalize&&j(o),t.noiseReduction&&M(o),n.onProgress?.(90,`Finalizing...`),{audioData:o,audioInfo:{sampleRate:a.sampleRate,duration:a.duration,channels:a.numberOfChannels,bitDepth:32,format:`float32`},warnings:i.length>0?i:void 0}}async function k(e,t,n){n.onProgress?.(60,`Converting audio format...`);let r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(t.targetChannels,Math.floor(e.length*t.targetSampleRate/e.sampleRate),t.targetSampleRate),i=r.createBufferSource();return i.buffer=e,i.connect(r.destination),i.start(0),await r.startRendering()}function A(e){if(e.numberOfChannels===1)return e.getChannelData(0);{let t=e.getChannelData(0),n=e.getChannelData(1),r=new Float32Array(t.length);for(let e=0;e<t.length;e++)r[e]=(t[e]+n[e])/2;return r}}function j(e){let t=0;for(let n=0;n<e.length;n++)t=Math.max(t,Math.abs(e[n]));if(t>0){let n=.95/t;for(let t=0;t<e.length;t++)e[t]*=n}}function M(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++){let r=0,i=0;for(let t=Math.max(0,n-3);t<=Math.min(e.length-1,n+3);t++)r+=e[t],i++;t[n]=r/i}e.set(t)}function N(e,t,n){e.numberOfChannels>2&&n.push(`Audio has ${e.numberOfChannels} channels, will be mixed to mono`),e.sampleRate!==t.targetSampleRate&&n.push(`Audio sample rate (${e.sampleRate}Hz) will be converted to ${t.targetSampleRate}Hz`)}async function P(e,t,n,r){if(typeof window>`u`)throw Error(`MediaStream recording is only supported in browser environments`);if(!window.MediaRecorder)throw Error(`MediaRecorder is not supported in this browser`);let i=window.MediaRecorder,a=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/ogg`].find(e=>i.isTypeSupported(e)),o=new i(e,a?{mimeType:a}:void 0),s=[],c=new Promise((e,t)=>{o.ondataavailable=e=>{e.data&&e.data.size>0&&s.push(e.data)},o.onerror=()=>t(Error(`MediaRecorder error`)),o.onstop=()=>{let t=a||o.mimeType||`application/octet-stream`;e(new Blob(s,{type:t}))}}),l=t.signal,u=()=>{try{o.state!==`inactive`&&o.stop()}catch{}};l?.addEventListener(`abort`,u,{once:!0});let d=t.recordingDurationMs??1e4,f=setTimeout(()=>{try{o.state!==`inactive`&&o.stop()}catch{}},d);n.onProgress?.(20,`Recording audio...`),r.debug(`Starting MediaRecorder`,{mimeType:a??o.mimeType,durationMs:d}),o.start(250);try{return await c}finally{clearTimeout(f),l?.removeEventListener(`abort`,u)}}export{i,b as n,g as r,E as t};
1
+ import{r as e}from"./monaco-CZnIWXyV.js";function t(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function n(){return t()!==null}function r(){let e=t();return e?new e:null}function i(e){try{return JSON.stringify(e)}catch{return`"[non-serializable]"`}}function a(e){let t;try{t=i(e)}catch{console.error(`[voice-log] failed to serialize log payload`);return}fetch(`/api/logs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:t}).catch(e=>{console.error(`[voice-log] fetch to /api/logs failed:`,e)})}function o(e){function t(t,n,r){a({level:t,context:e,message:n,data:r});let i=`[${e}]`;t===`ERROR`?console.error(i,n,r??``):t===`WARN`?console.warn(i,n,r??``):t===`DEBUG`?console.debug(i,n,r??``):console.info(i,n,r??``)}return{debug:(e,n)=>t(`DEBUG`,e,n),info:(e,n)=>t(`INFO`,e,n),warn:(e,n)=>t(`WARN`,e,n),error:(e,n)=>t(`ERROR`,e,n),separator:e=>t(`INFO`,`${`─`.repeat(20)} ${e} ${`─`.repeat(20)}`)}}var s=class e{static levels={DEBUG:0,INFO:1,WARN:2,ERROR:3};level;prefix;constructor(t=e.levels.INFO,n=``){this.level=t,this.prefix=n}debug(...t){this.level<=e.levels.DEBUG&&console.debug(`[${this.prefix}] [DEBUG]`,...t)}info(...t){this.level<=e.levels.INFO&&console.info(`[${this.prefix}] [INFO]`,...t)}warn(...t){this.level<=e.levels.WARN&&console.warn(`[${this.prefix}] [WARN]`,...t)}error(...t){this.level<=e.levels.ERROR&&console.error(`[${this.prefix}] [ERROR]`,...t)}setLevel(e){this.level=e}getLevel(){return this.level}},c=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),l={language:`auto`,threads:4,translate:!1};function u(e){let t=String(e).trim().replace(`,`,`.`),n=t.split(`:`).map(Number);if(n.some(Number.isNaN))throw Error(`Bad time: "${e}"`);let r=0,i=0,a=0;if(n.length===3)[r,i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else if(n.length===2)[i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else throw Error(`Bad time format: "${e}"`);return Math.floor(((r*60+i)*60+a)*1e3)}function d(e){let t=/^\s*\[?\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*-->\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*\]?\s*(.*)\s*$/.exec(e);if(!t)throw Error(`Line does not match VTT-like pattern: `+e);let n=t[1],r=t[2],i=t[3]||``,a=u(n),o=u(r);if(o<a)throw Error(`End time is before start time`);return{startMs:a,endMs:o,start:n,end:r,text:i}}function f(e){return new Promise(t=>setTimeout(t,e))}function p(e,t){let n=null,r=!1,i=null,a=null;return{timeoutError:()=>new Promise((o,s)=>{a=o,i=s,n=setTimeout(()=>{!r&&i&&(r=!0,i(Error(t)))},e)}),clear:()=>{n&&=(clearTimeout(n),null),a&&=(a(),null),r=!0,i=null}}}var m=16e3*15;function h(e,t=m){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}var g=class{whisperService;logger;constructor(e,t){this.whisperService=e,this.logger=new s(t?.logLevel||s.levels.ERROR,`TranscriptionSession`)}async*streaming(e,t={}){let{timeoutMs:n=3e4}=t,r=h(e),i=0;for(let e of r){let r=[],a=null,o=!1,s,c=0,{timeoutError:l,clear:u}=p(n,`Transcribe timeout`),d=()=>this.whisperService.transcribe(e,e=>{c=e.timeEnd,e.timeStart+=i,e.timeEnd+=i,this.logger.debug(`Transcription segment in session:`,e),a?(a(e),a=null):r.push(e),u()},t).then(()=>{this.logger.debug(`Transcription done in session then`),o=!0,i+=c,u(),a?.(void 0)}).catch(e=>{this.logger.debug(`Transcription error in session catch:`,e),s=e,u(),a?.(void 0)});for(d();;){if(s){if(t.restartModelOnError){this.whisperService.restartModel(),d();continue}throw s}if(o)break;if(r.length)yield r.shift();else try{let e=await Promise.race([new Promise(e=>a=e),l()]);e&&(yield e)}catch(e){s=e}}t.sleepMsBetweenChunks&&await f(t.sleepMsBetweenChunks)}}async*streamimg(e,t={}){yield*this.streaming(e,t)}},_=o(`WhisperWasmService`),v=class extends EventTarget{on(e,t){return this.addEventListener(e,t),()=>this.removeEventListener(e,t)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}},y=class t{static wasmSupportPromise=null;wasmModule=null;instance=null;modelFileName=`whisper.bin`;isTranscribing=!1;bus=new v;logger;modelData=null;constructor(e){this.logger=new s(e?.logLevel??s.levels.ERROR,`WhisperWasmService`),e?.init&&this.loadWasmScript()}async checkWasmSupport(){return t.wasmSupportPromise??=c(),await t.wasmSupportPromise}async loadWasmScript(){let t=`${typeof window<`u`?window.location.origin:``}/wasm/libmain-D9-QM3iM.mjs`,n={print:(e,...t)=>{t.length>0&&this.logger.debug(t),e.startsWith(`[`)?(this.logger.info(e),this.bus.emit(`transcribe`,e)):(this.logger.debug(e),this.bus.emit(`system_info`,e))},printErr:(e,...t)=>{t.length>0&&this.logger.debug(t),this.logger.warn(e),_.warn(`WASM stderr output`,{message:e,extra:t.length?t:void 0}),this.bus.emit(`transcribeError`,e)}};_.info(`Loading WASM script`,{url:t}),globalThis.__mockWhisperWasmImport__?this.wasmModule=await globalThis.__mockWhisperWasmImport__(t,n):this.wasmModule=await(await e(async()=>{let{default:e}=await import(t);return{default:e}},[])).default(n),_.info(`WASM script loaded successfully`)}async initModel(e){if(!await this.checkWasmSupport())throw Error(`WASM is not supported`);return _.info(`Initializing WASM model`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),this.modelData=e,this.wasmModule&&(this.wasmModule.FS_unlink(this.modelFileName),this.wasmModule.free(),_.debug(`Previous WASM module freed`)),await this.loadWasmScript(),await f(100),_.info(`Storing model in WASM FS`,{fileName:this.modelFileName,sizeBytes:e.byteLength}),this.storeFS(this.modelFileName,e),_.info(`Creating WASM instance`),this.instance=this.wasmModule.init(this.modelFileName),_.info(`WASM instance created`,{instance:this.instance}),Promise.resolve()}restartModel(){if(!this.modelData)throw Error(`Model not loaded`);return this.initModel(this.modelData)}storeFS(e,t){if(!this.wasmModule)throw Error(`WASM module not loaded`);try{this.wasmModule.FS_unlink(e)}catch{}this.wasmModule.FS_createDataFile(`/`,e,t,!0,!0,!0)}async transcribe(e,t,n={}){if(this.isTranscribing)throw Error(`Already transcribing`);if(!this.wasmModule)throw Error(`WASM module not loaded`);if(!this.instance)throw Error(`WASM instance not loaded`);e.length>16e3*120&&this.logger.warn(`It's not recommended to transcribe audio data that is longer than 120 seconds`),this.isTranscribing=!0;let{language:r=`auto`,threads:i=4,translate:a=!1}={...l,...n},o=[],s=Date.now();_.info(`Calling WASM full_default`,{sampleCount:e.length,durationSec:(e.length/16e3).toFixed(2),language:r,threads:i,translate:a,instance:this.instance});try{this.wasmModule.full_default(this.instance,e,r,i,a),_.info(`WASM full_default returned without throwing`)}catch(e){let t=e instanceof Error?e.message:String(e);throw _.error(`WASM full_default threw an exception`,{error:t,type:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
2
+ `).slice(0,5).join(` | `):void 0}),this.isTranscribing=!1,e}return await new Promise((e,n)=>{let r=this.bus.on(`transcribe`,e=>{let{startMs:n,endMs:r,text:i}=d(e.detail),a={timeStart:n,timeEnd:r,text:i,raw:e.detail};o.push(a),t?.(a)}),i=setTimeout(()=>{this.isTranscribing=!1,r(),a(),this.logger.error(`Transcribe timeout`),n(Error(`Transcribe timeout`)),this.bus.emit(`transcribeError`,`Transcribe timeout`)},240*1e3),a=this.bus.on(`transcribeError`,t=>{this.isTranscribing=!1,r(),a(),clearTimeout(i),this.logger.debug(`Transcribe error`,t.detail),e({segments:o,transcribeDurationMs:Date.now()-s})})})}createSession(){return new g(this,{logLevel:this.logger.getLevel()})}},b={"tiny.en":{id:`tiny.en`,name:`Tiny English`,size:75,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin`},tiny:{id:`tiny`,name:`Tiny Multilingual`,size:75,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin`},"base.en":{id:`base.en`,name:`Base English`,size:142,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin`},base:{id:`base`,name:`Base Multilingual`,size:142,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin`},"small.en":{id:`small.en`,name:`Small English`,size:466,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin`},small:{id:`small`,name:`Small Multilingual`,size:466,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin`},"tiny.en-q5_1":{id:`tiny.en-q5_1`,name:`Tiny English (Q5_1)`,size:31,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en-q5_1.bin`},"tiny-q5_1":{id:`tiny-q5_1`,name:`Tiny Multilingual (Q5_1)`,size:31,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny-q5_1.bin`},"base.en-q5_1":{id:`base.en-q5_1`,name:`Base English (Q5_1)`,size:57,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en-q5_1.bin`},"base-q5_1":{id:`base-q5_1`,name:`Base Multilingual (Q5_1)`,size:57,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base-q5_1.bin`},"small.en-q5_1":{id:`small.en-q5_1`,name:`Small English (Q5_1)`,size:182,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en-q5_1.bin`},"small-q5_1":{id:`small-q5_1`,name:`Small Multilingual (Q5_1)`,size:182,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small-q5_1.bin`},"medium.en-q5_0":{id:`medium.en-q5_0`,name:`Medium English (Q5_0)`,size:515,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.en-q5_0.bin`},"medium-q5_0":{id:`medium-q5_0`,name:`Medium Multilingual (Q5_0)`,size:515,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium-q5_0.bin`},"large-q5_0":{id:`large-q5_0`,name:`Large Multilingual (Q5_0)`,size:1030,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-q5_0.bin`}};function x(){return Object.values(b).map(({url:e,...t})=>t)}function S(e){return b[e]}var C=class{cacheEnabled=!0;models=x();logger;constructor(e={logLevel:s.levels.ERROR}){this.logger=new s(e.logLevel,`ModelManager`)}async loadModel(e,t=!0,n){let r=S(e);if(!r)throw Error(`Model ${e} not found in config`);if(this.cacheEnabled&&t){let t=await this.getCachedModel(e);if(t)return this.logger.info(`Model ${e} loaded from cache`),n&&n(100),t}this.logger.info(`Loading model ${e} from ${r.url}`);let i=await fetch(r.url);if(!i.ok)throw Error(`Failed to load model: ${i.statusText}`);let a=i.headers.get(`content-length`),o=a?parseInt(a,10):0,s=0,c=i.body?.getReader();if(!c)throw Error(`Response body is not readable`);let l=[];try{let e=!1;for(;!e;){let t=await c.read();e=t.done,!e&&t.value&&(l.push(t.value),s+=t.value.length,n&&o>0&&n(Math.round(s/o*100)))}}finally{c.releaseLock()}let u=l.reduce((e,t)=>e+t.length,0),d=new Uint8Array(u),f=0;for(let e of l)d.set(e,f),f+=e.length;return this.cacheEnabled&&t&&await this.saveModelToCache(e,d),n&&n(100),d}async loadModelByUrl(e,t){try{if(this.cacheEnabled){let n=await this.getCachedModelByUrl(e);if(n)return this.logger.info(`WASM module loaded from cache by URL: ${e}`),t&&t(100),n}this.logger.info(`Loading WASM module from URL: ${e}`);let n=await fetch(e);if(!n.ok)throw Error(`Failed to load WASM module: ${n.statusText}`);let r=n.headers.get(`content-length`),i=r?parseInt(r,10):0,a=0,o=n.body?.getReader();if(!o)throw Error(`Response body is not readable`);let s=[];try{let e=!1;for(;!e;){let n=await o.read();e=n.done,!e&&n.value&&(s.push(n.value),a+=n.value.length,t&&i>0&&t(Math.round(a/i*100)))}}finally{o.releaseLock()}let c=s.reduce((e,t)=>e+t.length,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;return this.cacheEnabled&&await this.saveModelToCacheByUrl(e,l),t&&t(100),l}catch(e){this.logger.error(e);let t=e instanceof Error?e.message:`Failed to load WASM module`;throw Error(t)}}async getCachedModelByUrl(e){try{let t=(await this.openIndexedDB()).transaction([`modelsByUrl`],`readonly`).objectStore(`modelsByUrl`);return new Promise((n,r)=>{let i=t.get(e);i.onsuccess=()=>{let e=i.result;e&&e.data?n(e.data):n(null)},i.onerror=()=>r(i.error)})}catch(e){return this.logger.error(`Error reading model from cache by URL:`,e),null}}async saveModelToCacheByUrl(e,t){try{let n=(await this.openIndexedDB()).transaction([`modelsByUrl`],`readwrite`).objectStore(`modelsByUrl`);await new Promise((r,i)=>{let a=n.put({url:e,data:t,timestamp:Date.now(),size:t.length});a.onsuccess=()=>r(),a.onerror=()=>i(a.error)}),this.logger.info(`Model saved to cache by URL: ${e}`)}catch(e){this.logger.error(`Error saving model to cache by URL:`,e)}}async getAvailableModels(){let e=[...this.models];if(!this.cacheEnabled)return e;try{let t=await this.getCachedModelNames();return e.map(e=>({...e,cached:t.includes(e.id)}))}catch(t){return this.logger.error(`Error checking cache status:`,t),e}}getAvailableModelsSync(){return[...this.models]}getModelConfig(e){return S(e)}async saveModelToCache(e,t){try{let n=(await this.openIndexedDB()).transaction([`models`],`readwrite`).objectStore(`models`);await new Promise((r,i)=>{let a=n.put({name:e,data:t,timestamp:Date.now(),size:t.length});a.onsuccess=()=>r(),a.onerror=()=>i(a.error)}),this.logger.info(`Model ${e} saved to cache`)}catch(e){this.logger.error(`Error saving model to cache:`,e)}}async getCachedModel(e){try{let t=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((n,r)=>{let i=t.get(e);i.onsuccess=()=>{let e=i.result;e&&e.data?n(e.data):n(null)},i.onerror=()=>r(i.error)})}catch(e){return this.logger.error(`Error getting cached model:`,e),null}}async getCachedModelNames(){try{let e=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((t,n)=>{let r=e.getAllKeys();r.onsuccess=()=>{let e=r.result;t(e)},r.onerror=()=>n(r.error)})}catch(e){return this.logger.error(`Error getting cached model names:`,e),[]}}async openIndexedDB(){return new Promise((e,t)=>{let n=indexedDB.open(`WhisperModels`,2);n.onerror=()=>t(n.error),n.onsuccess=()=>e(n.result),n.onupgradeneeded=e=>{let t=e.target.result;if(!t.objectStoreNames.contains(`models`)){let e=t.createObjectStore(`models`,{keyPath:`name`});e.createIndex(`timestamp`,`timestamp`,{unique:!1}),e.createIndex(`size`,`size`,{unique:!1})}if(!t.objectStoreNames.contains(`modelsByUrl`)){let e=t.createObjectStore(`modelsByUrl`,{keyPath:`url`});e.createIndex(`timestamp`,`timestamp`,{unique:!1}),e.createIndex(`size`,`size`,{unique:!1})}}})}async clearCache(){try{let e=(await this.openIndexedDB()).transaction([`models`,`modelsByUrl`],`readwrite`),t=e.objectStore(`models`);await new Promise((e,n)=>{let r=t.clear();r.onsuccess=()=>e(),r.onerror=()=>n(r.error)});let n=e.objectStore(`modelsByUrl`);await new Promise((e,t)=>{let r=n.clear();r.onsuccess=()=>e(),r.onerror=()=>t(r.error)}),this.logger.info(`Model cache cleared`)}catch(e){this.logger.error(`Error clearing cache:`,e)}}async getCacheInfo(){try{let e=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((t,n)=>{let r=e.getAll();r.onsuccess=()=>{let e=r.result,n=e.reduce((e,t)=>e+(t.size||0),0);t({count:e.length,totalSize:n})},r.onerror=()=>n(r.error)})}catch(e){return this.logger.error(`Error getting cache info:`,e),{count:0,totalSize:0}}}},w={targetSampleRate:16e3,targetChannels:1,inputSampleRate:16e3,normalize:!0,noiseReduction:!1,logLevel:s.levels.ERROR,signal:void 0,recordingDurationMs:1e4};function T(e){return typeof e==`number`?e:e?s.levels[e]:s.levels.ERROR}function E(e){return new s(T(e.logLevel),`AudioConverter`)}function D(e){if(e?.aborted)throw new DOMException(`Aborted`,`AbortError`)}function O(){return typeof window>`u`?!1:!!(window.AudioContext||window.webkitAudioContext||window.OfflineAudioContext||window.webkitOfflineAudioContext)}async function k(e,t={},n={}){if(!O())throw Error(`Web Audio API is not supported in this browser`);let r={...w,...t},i=E(r),a=[];try{D(r.signal),i.info(`Converting from MediaStream`),n.onProgress?.(0,`Starting recording...`);let t=await L(e,r,n,i);n.onProgress?.(50,`Recording completed, decoding...`);let o=await A(await t.arrayBuffer(),r,n,i);n.onProgress?.(70,`Audio decoded, processing...`);let s=await j(o,r,n,i,a);return n.onProgress?.(100,`Conversion completed`),s}catch(e){throw i.error(`MediaStream conversion failed:`,e),n.onError?.(e),e}}async function A(e,t,n,r){n.onProgress?.(15,`Decoding audio data`);let i=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t.targetSampleRate});try{return await i.decodeAudioData(e)}catch(e){throw r.error(`Audio decoding failed:`,e),Error(`Failed to decode audio: ${e.message}`)}finally{try{await i.close()}catch{}}}async function j(e,t,n,r,i){n.onProgress?.(50,`Converting audio format...`),I(e,t,i);let a=await M(e,t,n);n.onProgress?.(70,`Converting to Float32Array...`);let o=N(a);return n.onProgress?.(80,`Applying effects...`),t.normalize&&P(o),t.noiseReduction&&F(o),n.onProgress?.(90,`Finalizing...`),{audioData:o,audioInfo:{sampleRate:a.sampleRate,duration:a.duration,channels:a.numberOfChannels,bitDepth:32,format:`float32`},warnings:i.length>0?i:void 0}}async function M(e,t,n){n.onProgress?.(60,`Converting audio format...`);let r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(t.targetChannels,Math.floor(e.length*t.targetSampleRate/e.sampleRate),t.targetSampleRate),i=r.createBufferSource();return i.buffer=e,i.connect(r.destination),i.start(0),await r.startRendering()}function N(e){if(e.numberOfChannels===1)return e.getChannelData(0);{let t=e.getChannelData(0),n=e.getChannelData(1),r=new Float32Array(t.length);for(let e=0;e<t.length;e++)r[e]=(t[e]+n[e])/2;return r}}function P(e){let t=0;for(let n=0;n<e.length;n++)t=Math.max(t,Math.abs(e[n]));if(t>0){let n=.95/t;for(let t=0;t<e.length;t++)e[t]*=n}}function F(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++){let r=0,i=0;for(let t=Math.max(0,n-3);t<=Math.min(e.length-1,n+3);t++)r+=e[t],i++;t[n]=r/i}e.set(t)}function I(e,t,n){e.numberOfChannels>2&&n.push(`Audio has ${e.numberOfChannels} channels, will be mixed to mono`),e.sampleRate!==t.targetSampleRate&&n.push(`Audio sample rate (${e.sampleRate}Hz) will be converted to ${t.targetSampleRate}Hz`)}async function L(e,t,n,r){if(typeof window>`u`)throw Error(`MediaStream recording is only supported in browser environments`);if(!window.MediaRecorder)throw Error(`MediaRecorder is not supported in this browser`);let i=window.MediaRecorder,a=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/ogg`].find(e=>i.isTypeSupported(e)),o=new i(e,a?{mimeType:a}:void 0),s=[],c=new Promise((e,t)=>{o.ondataavailable=e=>{e.data&&e.data.size>0&&s.push(e.data)},o.onerror=()=>t(Error(`MediaRecorder error`)),o.onstop=()=>{let t=a||o.mimeType||`application/octet-stream`;e(new Blob(s,{type:t}))}}),l=t.signal,u=()=>{try{o.state!==`inactive`&&o.stop()}catch{}};l?.addEventListener(`abort`,u,{once:!0});let d=t.recordingDurationMs??1e4,f=setTimeout(()=>{try{o.state!==`inactive`&&o.stop()}catch{}},d);n.onProgress?.(20,`Recording audio...`),r.debug(`Starting MediaRecorder`,{mimeType:a??o.mimeType,durationMs:d}),o.start(250);try{return await c}finally{clearTimeout(f),l?.removeEventListener(`abort`,u)}}export{r as a,o as i,C as n,n as o,y as r,k as t};
@@ -10,7 +10,10 @@
10
10
  <link rel="manifest" href="/manifest.json" />
11
11
 
12
12
  <!-- Meta Tags -->
13
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13
+ <meta
14
+ name="viewport"
15
+ content="viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
16
+ />
14
17
  <meta name="theme-color" content="#000000" />
15
18
  <meta name="description" content="Manage projects and conversation threads with AI agents" />
16
19
  <meta name="mobile-web-app-capable" content="yes" />
@@ -19,17 +22,17 @@
19
22
  <meta name="apple-mobile-web-app-title" content="Tarsk" />
20
23
 
21
24
  <title>Tarsk</title>
22
- <script type="module" crossorigin src="/assets/index-DOsSr4dl.js"></script>
25
+ <script type="module" crossorigin src="/assets/index-DVXbmgHY.js"></script>
23
26
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
24
27
  <link rel="modulepreload" crossorigin href="/assets/monaco-CZnIWXyV.js">
25
- <link rel="modulepreload" crossorigin href="/assets/dialogs-config-B4TDFSrS.js">
26
- <link rel="modulepreload" crossorigin href="/assets/history-view-Ds_0e_bx.js">
27
- <link rel="modulepreload" crossorigin href="/assets/onboarding-DfL8a0LZ.js">
28
- <link rel="modulepreload" crossorigin href="/assets/whisper-wasm-Cq5Ofwpd.js">
29
- <link rel="modulepreload" crossorigin href="/assets/react-vendor-unlDVFpU.js">
30
- <link rel="modulepreload" crossorigin href="/assets/utils-umVhs9to.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/dialogs-config-I0_cSU2z.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/history-view-Be-1C1tJ.js">
30
+ <link rel="modulepreload" crossorigin href="/assets/onboarding-CgP4bJ5F.js">
31
+ <link rel="modulepreload" crossorigin href="/assets/whisper-wasm-EGutPGND.js">
32
+ <link rel="modulepreload" crossorigin href="/assets/react-vendor-Do-APsQ6.js">
33
+ <link rel="modulepreload" crossorigin href="/assets/utils-CU0c_yCM.js">
31
34
  <link rel="stylesheet" crossorigin href="/assets/monaco-Br_kD0ds.css">
32
- <link rel="stylesheet" crossorigin href="/assets/index-C0lTt0ZK.css">
35
+ <link rel="stylesheet" crossorigin href="/assets/index-jIBJk8xl.css">
33
36
  </head>
34
37
  <body class="font-sans antialiased">
35
38
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.5.35",
3
+ "version": "0.5.36",
4
4
  "description": "CLI for Tarsk - Project Threads Manager",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- import{An as e,Fn as t,Mn as n,Nn as r,On as i,Pn as a,kn as o}from"./dialogs-config-B4TDFSrS.js";async function s(t,n,r=!1){return e(`api/threads/${o(t)}/explorer?path=${encodeURIComponent(n)}&recursive=${r}`)}async function c(t,n){return e(`api/threads/${o(t)}/ai-file?path=${encodeURIComponent(n)}`)}async function l(e,n,r){return t(`api/threads/${o(e)}/ai-file`,{path:n,content:r})}async function u(e,t){return i(`api/threads/${o(e)}/explorer?path=${encodeURIComponent(t)}`)}async function d(e,t,n){return r(`api/threads/${o(e)}/explorer`,{path:t,newName:n})}async function f(e,t,n){return a(`api/threads/${o(e)}/explorer/file`,{dirPath:t,name:n})}async function p(e,t){return n(`api/threads/${o(e)}/explorer/media?path=${encodeURIComponent(t)}`)}async function m(e,t,n){return a(`api/threads/${o(e)}/explorer/folder`,{dirPath:t,name:n})}export{c as a,l as c,p as i,m as n,s as o,u as r,d as s,f as t};
@@ -1 +0,0 @@
1
- import{Cr as e,Er as ee,Sr as t,Ti as n,Tr as r,Wi as i,ar as a,fo as o,ir as s,ni as c,or as l,rr as u,vi as d,vr as f,wr as p,xr as m,ya as te}from"./dialogs-config-B4TDFSrS.js";import{n as ne}from"./onboarding-DfL8a0LZ.js";import{O as h}from"./index-DOsSr4dl.js";var g=o(),_=n();function v(n){let o=(0,g.c)(57),{open:v,onOpenChange:y,commitMessage:b,onCommitMessageChange:x,autoGenerateCommitMessage:S,onAutoGenerateChange:C,isGeneratingMessage:w,isLoading:T,onGenerateMessage:E,onCommit:D,currentBranch:O}=n,k;o[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,_.jsx)(ee,{children:`Commit Changes`}),o[0]=k):k=o[0];let A;o[1]===O?A=o[2]:(A=(0,_.jsxs)(r,{children:[k,(0,_.jsxs)(e,{children:[`Enter a commit message for your changes on branch `,O]})]}),o[1]=O,o[2]=A);let j;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,_.jsx)(f,{htmlFor:`commit-message`,children:`Commit Message`}),o[3]=j):j=o[3];let M;o[4]===x?M=o[5]:(M=e=>x(e.target.value),o[4]=x,o[5]=M);let N;o[6]!==b||o[7]!==M?(N=(0,_.jsx)(h,{id:`commit-message`,placeholder:`Enter commit message...`,value:b,onChange:M,rows:4,className:`pr-10`}),o[6]=b,o[7]=M,o[8]=N):N=o[8];let P=w||T,F;o[9]===w?F=o[10]:(F=w?(0,_.jsx)(te,{className:`h-3.5 w-3.5 animate-spin`}):(0,_.jsx)(i,{className:`h-3.5 w-3.5`}),o[9]=w,o[10]=F);let I;o[11]!==E||o[12]!==P||o[13]!==F?(I=(0,_.jsx)(l,{asChild:!0,children:(0,_.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:E,disabled:P,children:F})}),o[11]=E,o[12]=P,o[13]=F,o[14]=I):I=o[14];let L=w?`Generating commit message...`:`Generate commit message with AI`,R;o[15]===L?R=o[16]:(R=(0,_.jsx)(s,{children:L}),o[15]=L,o[16]=R);let z;o[17]!==R||o[18]!==I?(z=(0,_.jsx)(a,{children:(0,_.jsxs)(u,{children:[I,R]})}),o[17]=R,o[18]=I,o[19]=z):z=o[19];let B;o[20]!==z||o[21]!==N?(B=(0,_.jsxs)(`div`,{className:`grid gap-2`,children:[j,(0,_.jsxs)(`div`,{className:`relative`,children:[N,z]})]}),o[20]=z,o[21]=N,o[22]=B):B=o[22];let V;o[23]===C?V=o[24]:(V=e=>C(e===!0),o[23]=C,o[24]=V);let H;o[25]!==S||o[26]!==V?(H=(0,_.jsx)(ne,{id:`auto-generate`,checked:S,onCheckedChange:V}),o[25]=S,o[26]=V,o[27]=H):H=o[27];let U;o[28]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,_.jsx)(f,{htmlFor:`auto-generate`,className:d.labelNormal,children:`Auto generate commit messages`}),o[28]=U):U=o[28];let W;o[29]===H?W=o[30]:(W=(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H,U]}),o[29]=H,o[30]=W);let G;o[31]!==B||o[32]!==W?(G=(0,_.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[B,W]}),o[31]=B,o[32]=W,o[33]=G):G=o[33];let K;o[34]===y?K=o[35]:(K=()=>y(!1),o[34]=y,o[35]=K);let q;o[36]!==T||o[37]!==K?(q=(0,_.jsx)(c,{variant:`outline`,onClick:K,disabled:T,children:`Cancel`}),o[36]=T,o[37]=K,o[38]=q):q=o[38];let J;o[39]!==b||o[40]!==T?(J=T||!b.trim(),o[39]=b,o[40]=T,o[41]=J):J=o[41];let Y=T?`Committing...`:`Commit`,X;o[42]!==D||o[43]!==J||o[44]!==Y?(X=(0,_.jsx)(c,{onClick:D,disabled:J,children:Y}),o[42]=D,o[43]=J,o[44]=Y,o[45]=X):X=o[45];let Z;o[46]!==q||o[47]!==X?(Z=(0,_.jsxs)(p,{children:[q,X]}),o[46]=q,o[47]=X,o[48]=Z):Z=o[48];let Q;o[49]!==G||o[50]!==A||o[51]!==Z?(Q=(0,_.jsxs)(t,{children:[A,G,Z]}),o[49]=G,o[50]=A,o[51]=Z,o[52]=Q):Q=o[52];let $;return o[53]!==y||o[54]!==v||o[55]!==Q?($=(0,_.jsx)(m,{open:v,onOpenChange:y,children:Q}),o[53]=y,o[54]=v,o[55]=Q,o[56]=$):$=o[56],$}export{v as CommitDialog};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{Ti as t,Ya as n,eo as r,fo as i,ii as a,mo as o,ro as s,vi as c}from"./dialogs-config-B4TDFSrS.js";import{_ as l,b as u,d,f,g as p,h as m,m as h,p as g,u as _,v,x as y,y as b}from"./react-vendor-unlDVFpU.js";var x=i(),S=e(o(),1),C=t(),w=l,T=y,E=S.forwardRef((e,t)=>{let n=(0,x.c)(14),i,o,s,l;n[0]===e?(i=n[1],o=n[2],s=n[3],l=n[4]):({className:o,inset:s,children:i,...l}=e,n[0]=e,n[1]=i,n[2]=o,n[3]=s,n[4]=l);let d;n[5]!==o||n[6]!==s?(d=a(a(c.body,`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`),s&&`pl-8`,o),n[5]=o,n[6]=s,n[7]=d):d=n[7];let f;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,C.jsx)(r,{className:`ml-auto h-4 w-4`}),n[8]=f):f=n[8];let p;return n[9]!==i||n[10]!==l||n[11]!==t||n[12]!==d?(p=(0,C.jsxs)(u,{ref:t,className:d,...l,children:[i,f]}),n[9]=i,n[10]=l,n[11]=t,n[12]=d,n[13]=p):p=n[13],p});E.displayName=u.displayName;var D=S.forwardRef((e,t)=>{let n=(0,x.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=a(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,C.jsx)(b,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});D.displayName=b.displayName;var O=S.forwardRef((e,t)=>{let n=(0,x.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=a(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,C.jsx)(m,{children:(0,C.jsx)(d,{ref:t,className:o,...i})}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});O.displayName=d.displayName;var k=S.forwardRef((e,t)=>{let n=(0,x.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,inset:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s;n[4]!==r||n[5]!==i?(s=a(a(c.body,`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),i&&`pl-8`,r),n[4]=r,n[5]=i,n[6]=s):s=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==s?(l=(0,C.jsx)(f,{ref:t,className:s,...o}),n[7]=o,n[8]=t,n[9]=s,n[10]=l):l=n[10],l});k.displayName=f.displayName;var A=S.forwardRef((e,t)=>{let n=(0,x.c)(14),r,i,o,l;n[0]===e?(r=n[1],i=n[2],o=n[3],l=n[4]):({className:o,children:i,checked:r,...l}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=l);let u;n[5]===o?u=n[6]:(u=a(a(c.body,`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),o),n[5]=o,n[6]=u);let d;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,C.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,C.jsx)(g,{children:(0,C.jsx)(s,{className:`h-4 w-4`})})}),n[7]=d):d=n[7];let f;return n[8]!==r||n[9]!==i||n[10]!==l||n[11]!==t||n[12]!==u?(f=(0,C.jsxs)(_,{ref:t,className:u,checked:r,...l,children:[d,i]}),n[8]=r,n[9]=i,n[10]=l,n[11]=t,n[12]=u,n[13]=f):f=n[13],f});A.displayName=_.displayName;var j=S.forwardRef((e,t)=>{let r=(0,x.c)(12),i,o,s;r[0]===e?(i=r[1],o=r[2],s=r[3]):({className:o,children:i,...s}=e,r[0]=e,r[1]=i,r[2]=o,r[3]=s);let l;r[4]===o?l=r[5]:(l=a(a(c.body,`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),o),r[4]=o,r[5]=l);let u;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,C.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,C.jsx)(g,{children:(0,C.jsx)(n,{className:`h-2 w-2 fill-current`})})}),r[6]=u):u=r[6];let d;return r[7]!==i||r[8]!==s||r[9]!==t||r[10]!==l?(d=(0,C.jsxs)(p,{ref:t,className:l,...s,children:[u,i]}),r[7]=i,r[8]=s,r[9]=t,r[10]=l,r[11]=d):d=r[11],d});j.displayName=p.displayName;var M=S.forwardRef((e,t)=>{let n=(0,x.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,inset:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s;n[4]!==r||n[5]!==i?(s=a(a(c.body,`px-2 py-1.5 font-semibold text-foreground`),i&&`pl-8`,r),n[4]=r,n[5]=i,n[6]=s):s=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==s?(l=(0,C.jsx)(h,{ref:t,className:s,...o}),n[7]=o,n[8]=t,n[9]=s,n[10]=l):l=n[10],l});M.displayName=h.displayName;var N=S.forwardRef((e,t)=>{let n=(0,x.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=a(`-mx-1 my-1 h-px bg-border`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,C.jsx)(v,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});N.displayName=v.displayName;var P=e=>{let t=(0,x.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=a(c.compact,`ml-auto tracking-widest text-muted-foreground`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,C.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};P.displayName=`ContextMenuShortcut`;export{T as a,N as i,O as n,k as r,w as t};