@openchamber/web 1.18.3 → 1.18.4

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 (60) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DbUi6I9s.js → CodeMirrorCommentWidgets-4qZbrEXU.js} +1 -1
  2. package/dist/assets/{CommitSection-Jc2_hNPE.js → CommitSection-MJmntVPJ.js} +1 -1
  3. package/dist/assets/{DiagramEditor-PCrYHBko.js → DiagramEditor-jnG3Hbxg.js} +1 -1
  4. package/dist/assets/{DiagramView-CndEcZNu.js → DiagramView-CFXxgg_a.js} +1 -1
  5. package/dist/assets/{DiffView-DEGlNjMH.js → DiffView-DZIoOnV7.js} +1 -1
  6. package/dist/assets/{FilesView-CzUgIvUm.js → FilesView-BKL6YlKG.js} +1 -1
  7. package/dist/assets/{GitView-C-n17voy.js → GitView-DBFrDDBv.js} +1 -1
  8. package/dist/assets/{JsonTreeView-BYcgdTOQ.js → JsonTreeView-DLW2Wy1g.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +12 -0
  11. package/dist/assets/{OnboardingScreen-BmN0lhk4.js → OnboardingScreen-D2Y6djMw.js} +1 -1
  12. package/dist/assets/{PatchDiff-Bn7bfgUv.js → PatchDiff-BuLPx7AN.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-D1fWvrUn.js → PierreDiffViewer-BHm4Yr0X.js} +1 -1
  14. package/dist/assets/{PlanView-CWM0iyFk.js → PlanView-ZYEJn8A_.js} +1 -1
  15. package/dist/assets/{SessionSwitcherDropdown-Cez-9xRh.js → SessionSwitcherDropdown-rro-SsaO.js} +1 -1
  16. package/dist/assets/{SettingsView-Bl1drwPw.js → SettingsView-5RmswFZe.js} +1 -1
  17. package/dist/assets/{SettingsWindow-DL5axjDZ.js → SettingsWindow-BZhAYFdS.js} +1 -1
  18. package/dist/assets/{ToolOutputDialog-BtIJkFno.js → ToolOutputDialog-Za6V4VMJ.js} +1 -1
  19. package/dist/assets/{ToolPartDiffPreview-i3PQo6_0.js → ToolPartDiffPreview-BL-9ixyC.js} +1 -1
  20. package/dist/assets/{VirtualizedFileDiff-DkcusvMa.js → VirtualizedFileDiff-CwGocYQd.js} +1 -1
  21. package/dist/assets/{WalkthroughView-Cc5Hd6P5.js → WalkthroughView-5DyvN03T.js} +1 -1
  22. package/dist/assets/{computeVirtualFileMetrics-xPena3W2.js → computeVirtualFileMetrics-Da00Jg7M.js} +1 -1
  23. package/dist/assets/{contextPanelEmbeddedChat-tQekJUAF.js → contextPanelEmbeddedChat-B-bSg3P5.js} +1 -1
  24. package/dist/assets/index-BzIpNlNE.css +1 -0
  25. package/dist/assets/{index-Crz1YOFl.js → index-C0yNhuZw.js} +1 -1
  26. package/dist/assets/{index-iFY_N5aO.js → index-DRpChWux.js} +1 -1
  27. package/dist/assets/{isDiffPlainText-Dudf-dWx.js → isDiffPlainText-D9YpoLrV.js} +1 -1
  28. package/dist/assets/{isFilePlainText-DS4QV1dd.js → isFilePlainText-gTibdNIe.js} +1 -1
  29. package/dist/assets/{main-C0DyIwTb.js → main-D7UcL3VQ.js} +2 -2
  30. package/dist/assets/{main-CAxX6DAN.js → main-DPMd2iKS.js} +4 -4
  31. package/dist/assets/markdownCore-DDrHVneM.js +2 -0
  32. package/dist/assets/{miniChat-CGfrxKpJ.js → miniChat-O_GVoEbc.js} +2 -2
  33. package/dist/assets/{mobile-DEmhwNcV.js → mobile-Br4TtAqc.js} +2 -2
  34. package/dist/assets/{patchFileDiff-C5D1OPCa.js → patchFileDiff-KNkxM1C1.js} +1 -1
  35. package/dist/assets/{renderElectronMiniChatApp-Dpbswpom.js → renderElectronMiniChatApp-CJpdxTT1.js} +2 -2
  36. package/dist/assets/{renderMobileApp-B5HA4qbi.js → renderMobileApp-toj9cXoh.js} +4 -4
  37. package/dist/assets/{runtimeEndpointReset-cbahJ3hD.js → runtimeEndpointReset-BVmispdD.js} +2 -2
  38. package/dist/assets/{scheduledTasksApi-BxgGWTL8.js → scheduledTasksApi-ByKya3Un.js} +1 -1
  39. package/dist/assets/{shikiHighlight-CmanopUB.js → shikiHighlight-C7LTbwFx.js} +1 -1
  40. package/dist/assets/{useAppFontEffects-sHmU5b8u.js → useAppFontEffects-BikB6enL.js} +131 -131
  41. package/dist/assets/{useInlineCommentController-gt56WkxJ.js → useInlineCommentController-CYPvYJDt.js} +1 -1
  42. package/dist/assets/{vendor-codemirror-language-data-Dihw9MtL.js → vendor-codemirror-language-data-CLHw8NWn.js} +2 -2
  43. package/dist/assets/{web-components-BL-Ur2Tb.js → web-components-GMc3oR3i.js} +1 -1
  44. package/dist/index.html +4 -4
  45. package/dist/mini-chat.html +3 -3
  46. package/dist/mobile.html +3 -3
  47. package/package.json +1 -1
  48. package/server/lib/dev-tunnel/client.js +20 -1
  49. package/server/lib/dev-tunnel/tunnel.test.js +9 -0
  50. package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
  51. package/server/lib/markdown-image-grants/routes.js +340 -0
  52. package/server/lib/markdown-image-grants/routes.test.js +221 -0
  53. package/server/lib/opencode/feature-routes-runtime.js +11 -0
  54. package/server/lib/opencode/server-startup-runtime.js +22 -1
  55. package/server/lib/opencode/server-startup-runtime.test.js +44 -0
  56. package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +0 -1
  57. package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +0 -12
  58. package/dist/assets/index-CVNuER6G.css +0 -1
  59. package/dist/assets/markdownCore-DhfzuGXu.js +0 -2
  60. package/dist/assets/markdownImageAssets-BTNlRyjd.js +0 -1
@@ -1 +1 @@
1
- import{f as V,R as Ne,j as s,r as ze}from"./vendor-react-BUCujlKS.js";import{u as je,at as Le,au as De,av as Ie,L as ne}from"./index-iFY_N5aO.js";import{f as ye,h as R,aZ as Te,w as Me,x as Pe,I as A,M as Fe,aY as $e,aX as Ee,aR as Ue,aT as Oe,aU as We,z as Ae,y as Ce,A as Be,C as Re,E as Ge,r as He}from"./useAppFontEffects-sHmU5b8u.js";import{d as ke}from"./vendor-base-ui-D_V6hAcE.js";function bt(){const n=V.c(5),e=je(Ye);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Le(),n[0]=t):t=n[0];const c=t;let a;n[1]!==e?(a=De(e),n[1]=e,n[2]=a):a=n[2];const r=a;let i;return n[3]!==r?(i={usesFramelessChrome:c,side:r},n[3]=r,n[4]=i):i=n[4],i}function Ye(n){return n.desktopWindowControlsPosition}const jt=n=>{const e=V.c(129),{totalTokens:t,percentage:c,colorPercentage:a,contextLimit:r,outputLimit:i,size:d,isMobile:h,hideIcon:m,showPercentIcon:o,className:u,valueClassName:f,percentIconClassName:p,onClick:x,pressed:g}=n,y=d===void 0?"default":d,w=h===void 0?!1:h,v=m===void 0?!1:m,_=o===void 0?!1:o,k=g===void 0?!1:g,{t:l}=ye(),[S,P]=Ne.useState(!1),j=typeof a=="number"?a:c;let b,N,z,L,F,G,B,H;if(e[0]!==j||e[1]!==r||e[2]!==v||e[3]!==w||e[4]!==x||e[5]!==i||e[6]!==p||e[7]!==c||e[8]!==_||e[9]!==l||e[10]!==t||e[11]!==f){const T=Me(c)??0,D=Pe(j),I=D==="critical"?"var(--status-error)":D==="warn"?"var(--status-warning)":"var(--status-success)";b=Ke,N=Xe;const M=2*Math.PI*8.5,C=M*(1-T/100);L=typeof i=="number"?Math.max(i,0):0;let U;e[20]!==l||e[21]!==t?(U=l("contextUsage.tooltip.usedTokens",{tokens:b(t)}),e[20]=l,e[21]=t,e[22]=U):U=e[22];let O;e[23]!==r||e[24]!==l?(O=l("contextUsage.tooltip.contextLimit",{tokens:b(r)}),e[23]=r,e[24]=l,e[25]=O):O=e[25];let W;e[26]!==L||e[27]!==l?(W=l("contextUsage.tooltip.outputLimit",{tokens:b(L)}),e[26]=L,e[27]=l,e[28]=W):W=e[28];let J;e[29]!==O||e[30]!==W||e[31]!==U?(J=[U,O,W],e[29]=O,e[30]=W,e[31]=U,e[32]=J):J=e[32],H=J,z=!w&&typeof x=="function",e[33]!==v||e[34]!==w?(B=!w&&!v&&s.jsx(A,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=v,e[34]=w,e[35]=B):B=e[35],e[36]!==f?(F=R("font-medium inline-flex items-center gap-1.5",f),e[36]=f,e[37]=F):F=e[37],G=_?s.jsxs(s.Fragment,{children:[s.jsxs("svg",{viewBox:"0 0 20 20",className:R("h-3.5 w-3.5 -rotate-90",p),role:"progressbar","aria-valuenow":Math.round(T),"aria-valuemin":0,"aria-valuemax":100,children:[s.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),s.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:I,strokeWidth:3,strokeLinecap:"round",strokeDasharray:M,strokeDashoffset:C,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),s.jsxs("span",{className:"text-foreground",children:[Math.min(c,999).toFixed(1),"%"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:N(j),children:Math.min(c,999).toFixed(1)}),"%"]}),e[0]=j,e[1]=r,e[2]=v,e[3]=w,e[4]=x,e[5]=i,e[6]=p,e[7]=c,e[8]=_,e[9]=l,e[10]=t,e[11]=f,e[12]=b,e[13]=N,e[14]=z,e[15]=L,e[16]=F,e[17]=G,e[18]=B,e[19]=H}else b=e[12],N=e[13],z=e[14],L=e[15],F=e[16],G=e[17],B=e[18],H=e[19];let Y;e[38]!==F||e[39]!==G?(Y=s.jsx("span",{className:F,children:G}),e[38]=F,e[39]=G,e[40]=Y):Y=e[40];let ee;e[41]!==B||e[42]!==Y?(ee=s.jsxs(s.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=ee):ee=e[43];const K=ee,te=y==="compact"?"typography-micro":"typography-meta";let se;e[44]!==u||e[45]!==z||e[46]!==te?(se=R("app-region-no-drag flex items-center gap-1.5 select-none",te,z?R("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",u),e[44]=u,e[45]=z,e[46]=te,e[47]=se):se=e[47];const X=se;let Z;e[48]!==K||e[49]!==z||e[50]!==w||e[51]!==x||e[52]!==k||e[53]!==X||e[54]!==l?(Z=z?s.jsx("button",{type:"button",className:X,"aria-label":l("contextUsage.aria.label"),"aria-pressed":k,onClick:x,children:K}):s.jsx("div",{className:X,"aria-label":l("contextUsage.aria.label"),onClick:w?()=>P(!0):void 0,children:K}),e[48]=K,e[49]=z,e[50]=w,e[51]=x,e[52]=k,e[53]=X,e[54]=l,e[55]=Z):Z=e[55];const Q=Z;if(w){let T;e[56]===Symbol.for("react.memo_cache_sentinel")?(T=()=>P(!1),e[56]=T):T=e[56];let D;e[57]!==l?(D=l("contextUsage.mobile.title"),e[57]=l,e[58]=D):D=e[58];let I;e[59]!==l?(I=l("contextUsage.mobile.usedTokens"),e[59]=l,e[60]=I):I=e[60];let M;e[61]!==I?(M=s.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[61]=I,e[62]=M):M=e[62];let C;e[63]!==b||e[64]!==t?(C=b(t),e[63]=b,e[64]=t,e[65]=C):C=e[65];let U;e[66]!==C?(U=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:C}),e[66]=C,e[67]=U):U=e[67];let O;e[68]!==M||e[69]!==U?(O=s.jsxs("div",{className:"flex justify-between items-center",children:[M,U]}),e[68]=M,e[69]=U,e[70]=O):O=e[70];let W;e[71]!==l?(W=l("contextUsage.mobile.contextLimit"),e[71]=l,e[72]=W):W=e[72];let J;e[73]!==W?(J=s.jsx("span",{className:"typography-meta text-muted-foreground",children:W}),e[73]=W,e[74]=J):J=e[74];let ie;e[75]!==r||e[76]!==b?(ie=b(r),e[75]=r,e[76]=b,e[77]=ie):ie=e[77];let oe;e[78]!==ie?(oe=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:ie}),e[78]=ie,e[79]=oe):oe=e[79];let re;e[80]!==J||e[81]!==oe?(re=s.jsxs("div",{className:"flex justify-between items-center",children:[J,oe]}),e[80]=J,e[81]=oe,e[82]=re):re=e[82];let le;e[83]!==l?(le=l("contextUsage.mobile.outputLimit"),e[83]=l,e[84]=le):le=e[84];let ae;e[85]!==le?(ae=s.jsx("span",{className:"typography-meta text-muted-foreground",children:le}),e[85]=le,e[86]=ae):ae=e[86];let ce;e[87]!==b||e[88]!==L?(ce=b(L),e[87]=b,e[88]=L,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let me;e[92]!==ae||e[93]!==de?(me=s.jsxs("div",{className:"flex justify-between items-center",children:[ae,de]}),e[92]=ae,e[93]=de,e[94]=me):me=e[94];let ue;e[95]!==l?(ue=l("contextUsage.mobile.usage"),e[95]=l,e[96]=ue):ue=e[96];let fe;e[97]!==ue?(fe=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ue}),e[97]=ue,e[98]=fe):fe=e[98];let pe;e[99]!==j||e[100]!==N?(pe=R("typography-meta font-semibold",N(j)),e[99]=j,e[100]=N,e[101]=pe):pe=e[101];const _e=Math.min(c,999);let he;e[102]!==_e?(he=_e.toFixed(1),e[102]=_e,e[103]=he):he=e[103];let xe;e[104]!==pe||e[105]!==he?(xe=s.jsxs("span",{className:pe,children:[he,"%"]}),e[104]=pe,e[105]=he,e[106]=xe):xe=e[106];let ge;e[107]!==fe||e[108]!==xe?(ge=s.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,xe]}),e[107]=fe,e[108]=xe,e[109]=ge):ge=e[109];let we;e[110]!==O||e[111]!==re||e[112]!==me||e[113]!==ge?(we=s.jsx("div",{className:"flex flex-col gap-1.5",children:s.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,re,me,ge]})}),e[110]=O,e[111]=re,e[112]=me,e[113]=ge,e[114]=we):we=e[114];let be;e[115]!==S||e[116]!==D||e[117]!==we?(be=s.jsx(Fe,{open:S,onClose:T,title:D,children:we}),e[115]=S,e[116]=D,e[117]=we,e[118]=be):be=e[118];let ve;return e[119]!==Q||e[120]!==be?(ve=s.jsxs(s.Fragment,{children:[Q,be]}),e[119]=Q,e[120]=be,e[121]=ve):ve=e[121],ve}let $;e[122]!==Q?($=s.jsx($e,{asChild:!0,children:Q}),e[122]=Q,e[123]=$):$=e[123];let E;e[124]!==H?(E=s.jsx(Te,{children:s.jsx("div",{className:"space-y-0.5",children:H.map(Ze)})}),e[124]=H,e[125]=E):E=e[125];let q;return e[126]!==$||e[127]!==E?(q=s.jsxs(Ee,{children:[$,E]}),e[126]=$,e[127]=E,e[128]=q):q=e[128],q};function Ke(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n.toFixed(1).replace(/\.0$/,"")}function Xe(n){return n>=90?"text-status-error":n>=75?"text-status-warning":"text-status-success"}function Ze(n){return s.jsx("p",{className:"typography-micro leading-tight",children:n},n)}const qe={close:"#FF5F57",minimize:"#FEBC2E",maximize:"#28C940"},Je="rgba(0, 0, 0, 0.7)",Qe=n=>{const e=V.c(3),{action:t}=n;if(t==="close"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(A,{name:"close",className:"size-[10px]"}),e[0]=a):a=e[0],a}if(t==="minimize"){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(A,{name:"subtract",className:"size-[10px]"}),e[1]=a):a=e[1],a}let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(A,{name:"add",className:"size-[10px]"}),e[2]=c):c=e[2],c},Ve=n=>{const e=V.c(18),{action:t,isMaximized:c,onActivate:a}=n,{t:r}=ye(),i=qe[t];let d;e[0]!==t||e[1]!==c||e[2]!==r?(d=r(t==="close"?"header.windowControls.close":t==="minimize"?"header.windowControls.minimize":c?"header.windowControls.restore":"header.windowControls.maximize"),e[0]=t,e[1]=c,e[2]=r,e[3]=d):d=e[3];const h=d;let m;e[4]!==t||e[5]!==a?(m=()=>a(t),e[4]=t,e[5]=a,e[6]=m):m=e[6];let o;e[7]!==i?(o={backgroundColor:i,color:Je},e[7]=i,e[8]=o):o=e[8];let u;e[9]!==t?(u=s.jsx("span",{className:"flex items-center justify-center opacity-0 transition-opacity duration-75 group-hover/wctl:opacity-100",children:s.jsx(Qe,{action:t})}),e[9]=t,e[10]=u):u=e[10];let f;e[11]!==o||e[12]!==u?(f=s.jsx("span",{className:"flex size-3.5 items-center justify-center rounded-full shadow-[inset_0_0_0_0.5px_rgba(0,0,0,0.28)] transition-[filter] duration-75 active:brightness-90",style:o,children:u}),e[11]=o,e[12]=u,e[13]=f):f=e[13];let p;return e[14]!==h||e[15]!==m||e[16]!==f?(p=s.jsx("button",{type:"button",onClick:m,title:h,"aria-label":h,className:"app-region-no-drag flex h-8 w-[24px] items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:f}),e[14]=h,e[15]=m,e[16]=f,e[17]=p):p=e[17],p},yt=Ne.memo(function(e){const t=V.c(25),{visible:c,position:a}=e,r=a===void 0?"right":a,{t:i}=ye(),[d,h]=Ne.useState(!1),m=je(et);let o,u;if(t[0]!==c?(o=()=>{if(!c)return;let v=!1;ne("desktop_get_current_window_state").then(k=>{v||h(!!k?.maximized)}).catch(tt);const _=k=>{const l=k.detail;h(!!l?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",_),()=>{v=!0,window.removeEventListener("openchamber:window-maximized-changed",_)}},u=[c],t[0]=c,t[1]=o,t[2]=u):(o=t[1],u=t[2]),ze.useEffect(o,u),!c)return null;const f=r==="left";let p,x,g,y;if(t[3]!==m||t[4]!==f||t[5]!==d||t[6]!==r||t[7]!==i){y=Symbol.for("react.early_return_sentinel");e:{const v=Ie(r);let _;t[12]===Symbol.for("react.memo_cache_sentinel")?(_=j=>{if(j==="close"){ne("desktop_close_current_window");return}if(j==="minimize"){ne("desktop_minimize_current_window");return}ne("desktop_toggle_current_window_maximized").then(b=>h(!!b?.maximized)).catch(st)},t[12]=_):_=t[12];const k=_;if(m==="traffic-lights"){const j=f?"mr-1":"ml-1";let b;t[13]!==j?(b=R("app-region-no-drag group/wctl flex h-8 shrink-0 items-center",j),t[13]=j,t[14]=b):b=t[14];let N;t[15]!==i?(N=i("header.windowControls.groupAria"),t[15]=i,t[16]=N):N=t[16];let z;t[17]!==d?(z=L=>s.jsx(Ve,{action:L,isMaximized:d,onActivate:k},L),t[17]=d,t[18]=z):z=t[18],y=s.jsx("div",{className:b,"aria-label":N,children:v.map(z)});break e}const l=R("app-region-no-drag inline-flex items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",f?"h-8 w-8 rounded-md":"h-12 w-11"),S=f?"app-region-no-drag mr-1 flex h-8 shrink-0 items-center":"app-region-no-drag ml-1 flex h-12 shrink-0 items-center",P=j=>j==="minimize"?s.jsx("button",{type:"button",className:l,onClick:nt,title:i("header.windowControls.minimize"),"aria-label":i("header.windowControls.minimize"),children:s.jsx(A,{name:"subtract",className:"h-4 w-4"})},"minimize"):j==="maximize"?s.jsx("button",{type:"button",className:l,onClick:()=>{ne("desktop_toggle_current_window_maximized").then(b=>h(!!b?.maximized)).catch(it)},title:i(d?"header.windowControls.restore":"header.windowControls.maximize"),"aria-label":i(d?"header.windowControls.restore":"header.windowControls.maximize"),children:s.jsx(A,{name:d?"fullscreen-exit":"checkbox-blank",className:"h-3.5 w-3.5"})},"maximize"):s.jsx("button",{type:"button",className:R(l,"hover:bg-status-error hover:text-status-error-foreground"),onClick:ot,title:i("header.windowControls.close"),"aria-label":i("header.windowControls.close"),children:s.jsx(A,{name:"close",className:"h-4 w-4"})},"close");p=S,t[19]!==i?(x=i("header.windowControls.groupAria"),t[19]=i,t[20]=x):x=t[20],g=v.map(P)}t[3]=m,t[4]=f,t[5]=d,t[6]=r,t[7]=i,t[8]=p,t[9]=x,t[10]=g,t[11]=y}else p=t[8],x=t[9],g=t[10],y=t[11];if(y!==Symbol.for("react.early_return_sentinel"))return y;let w;return t[21]!==p||t[22]!==x||t[23]!==g?(w=s.jsx("div",{className:p,"aria-label":x,children:g}),t[21]=p,t[22]=x,t[23]=g,t[24]=w):w=t[24],w});function et(n){return n.desktopWindowControlsStyle}function tt(){}function st(){}function nt(){ne("desktop_minimize_current_window")}function it(){}function ot(){ne("desktop_close_current_window")}function vt(n){const e=V.c(18),{children:t,variant:c,scopeProjectId:a,align:r}=n,i=c===void 0?"default":c,d=a===void 0?null:a,h=r===void 0?"start":r,m=je(lt),o=je(rt);let u;e[0]!==t?(u=s.jsx(Ue,{asChild:!0,children:t}),e[0]=t,e[1]=u):u=e[1];const f=i==="compact"?"w-[280px]":"w-[360px]";let p;e[2]!==f?(p=R("overflow-hidden p-1 max-w-[calc(100vw-32px)]",f),e[2]=f,e[3]=p):p=e[3];let x;e[4]!==m||e[5]!==d||e[6]!==o||e[7]!==i?(x=m?s.jsx(at,{onSelect:()=>o(!1),variant:i,scopeProjectId:d}):null,e[4]=m,e[5]=d,e[6]=o,e[7]=i,e[8]=x):x=e[8];let g;e[9]!==h||e[10]!==p||e[11]!==x?(g=s.jsx(Oe,{align:h,sideOffset:6,className:p,children:x}),e[9]=h,e[10]=p,e[11]=x,e[12]=g):g=e[12];let y;return e[13]!==m||e[14]!==o||e[15]!==u||e[16]!==g?(y=s.jsxs(We,{open:m,onOpenChange:o,modal:!1,children:[u,g]}),e[13]=m,e[14]=o,e[15]=u,e[16]=g,e[17]=y):y=e[17],y}function rt(n){return n.setSessionDropdownOpen}function lt(n){return n.isSessionDropdownOpen}function at(n){const e=V.c(26),{onSelect:t,variant:c,scopeProjectId:a}=n;let r;e[0]!==a?(r={scopeProjectId:a},e[0]=a,e[1]=r):r=e[1];const i=Ae(!0,r),d=Ce(dt),h=je(ct),{t:m}=ye();let o;e[2]!==t||e[3]!==d||e[4]!==h?(o=()=>{h("chat"),t(),d()},e[2]=t,e[3]=d,e[4]=h,e[5]=o):o=e[5];const u=o;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,e[6]=f):f=e[6];const[p,x]=Ne.useState(f);let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=j=>{x(b=>{const N=new Set(b);return N.has(j)?N.delete(j):N.add(j),N})},e[7]=g):g=e[7];const y=g;let w,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=R("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),v=s.jsx(A,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=w,e[9]=v):(w=e[8],v=e[9]);let _;e[10]!==m?(_=m("sessions.sidebar.header.actions.newSession"),e[10]=m,e[11]=_):_=e[11];let k;e[12]!==_?(k=s.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:_}),e[12]=_,e[13]=k):k=e[13];let l;e[14]!==u||e[15]!==k?(l=s.jsxs(ke,{onClick:u,className:w,children:[v,k]}),e[14]=u,e[15]=k,e[16]=l):l=e[16];let S;e[17]!==p||e[18]!==i||e[19]!==t||e[20]!==m||e[21]!==c?(S=i.length===0?s.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:m("sessions.switcher.empty")}):i.map(j=>s.jsx(Se,{item:j,depth:0,variant:c,expandedParents:p,toggleParent:y,closeDropdown:t},j.node.session.id)),e[17]=p,e[18]=i,e[19]=t,e[20]=m,e[21]=c,e[22]=S):S=e[22];let P;return e[23]!==S||e[24]!==l?(P=s.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"space-y-0.5",children:[l,S]})}),e[23]=S,e[24]=l,e[25]=P):P=e[25],P}function ct(n){return n.setActiveMainTab}function dt(n){return n.openNewSessionDraft}function Se(n){const e=V.c(31),{item:t,depth:c,variant:a,expandedParents:r,toggleParent:i,closeDropdown:d}=n,{node:h,secondaryMeta:m}=t,o=h.session,u=h.children.length>0;let f;e[0]!==r||e[1]!==o.id?(f=r.has(o.id),e[0]=r,e[1]=o.id,e[2]=f):f=e[2];const p=f;let x;e[3]!==u||e[4]!==o.id||e[5]!==i?(x=u?()=>i(o.id):void 0,e[3]=u,e[4]=o.id,e[5]=i,e[6]=x):x=e[6];let g;e[7]!==d||e[8]!==c||e[9]!==u||e[10]!==p||e[11]!==m||e[12]!==o||e[13]!==x||e[14]!==a?(g=s.jsx(mt,{session:o,depth:c,variant:a,secondaryMeta:m,hasChildren:u,isExpanded:p,onToggleExpand:x,closeDropdown:d}),e[7]=d,e[8]=c,e[9]=u,e[10]=p,e[11]=m,e[12]=o,e[13]=x,e[14]=a,e[15]=g):g=e[15];let y;e[16]!==d||e[17]!==c||e[18]!==r||e[19]!==u||e[20]!==p||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==h.children||e[24]!==m||e[25]!==i||e[26]!==a?(y=u&&p?h.children.map(v=>s.jsx(Se,{item:{node:v,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:m},depth:c+1,variant:a,expandedParents:r,toggleParent:i,closeDropdown:d},v.session.id)):null,e[16]=d,e[17]=c,e[18]=r,e[19]=u,e[20]=p,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=h.children,e[24]=m,e[25]=i,e[26]=a,e[27]=y):y=e[27];let w;return e[28]!==g||e[29]!==y?(w=s.jsxs(s.Fragment,{children:[g,y]}),e[28]=g,e[29]=y,e[30]=w):w=e[30],w}function mt(n){const e=V.c(57),{session:t,depth:c,variant:a,secondaryMeta:r,hasChildren:i,isExpanded:d,onToggleExpand:h,closeDropdown:m}=n,{t:o}=ye(),u=Ce(pt),f=Ce(ft),p=je(ut),x=Be(t.id),g=Re(t.id),y=u===t.id;let w;e[0]!==t.title||e[1]!==o?(w=t.title?.trim()||o("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=o,e[2]=w):w=e[2];const v=w,_=!!t.parentID,k=g>0&&(!_||p),l=x?.type??"idle",S=l==="busy"||l==="retry",P=!S&&k&&!y;let j;e[3]!==t.time?.created||e[4]!==t.time?.updated?(j=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=j):j=e[5];const b=j;let N;e[6]!==b?(N=Ge(b),e[6]=b,e[7]=N):N=e[7];const z=N;let L;e[8]!==r?.projectLabel?(L=r?.projectLabel?.trim()||null,e[8]=r?.projectLabel,e[9]=L):L=e[9];const F=L;let G;e[10]!==r?.branchLabel?(G=r?.branchLabel?.trim()||null,e[10]=r?.branchLabel,e[11]=G):G=e[11];const B=G,H=B&&B!=="HEAD"?B:null;let Y;e[12]!==m||e[13]!==y||e[14]!==t||e[15]!==f?(Y=()=>{if(y){m();return}const C=He(t);f(t.id,C??null),m()},e[12]=m,e[13]=y,e[14]=t,e[15]=f,e[16]=Y):Y=e[16];const ee=Y;let K;e[17]!==ee?(K=C=>{if(C.target?.closest("[data-switcher-expand]")){C.preventDefault();return}ee()},e[17]=ee,e[18]=K):K=e[18];let te;e[19]===Symbol.for("react.memo_cache_sentinel")?(te=R("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=te):te=e[19];const se=8+c*12;let X;e[20]!==se?(X={paddingLeft:se},e[20]=se,e[21]=X):X=e[21];let Z;e[22]!==i||e[23]!==d||e[24]!==h||e[25]!==o||e[26]!==a?(Z=a==="compact"&&i?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:C=>{C.preventDefault(),C.stopPropagation(),h?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(d?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:d?s.jsx(A,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):s.jsx(A,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=i,e[23]=d,e[24]=h,e[25]=o,e[26]=a,e[27]=Z):Z=e[27];const Q=y?"text-primary":"text-foreground";let $;e[28]!==Q?($=R("truncate text-[14px] font-normal leading-tight",Q),e[28]=Q,e[29]=$):$=e[29];let E;e[30]!==v||e[31]!==$?(E=s.jsx("span",{className:$,children:v}),e[30]=v,e[31]=$,e[32]=E):E=e[32];let q;e[33]!==Z||e[34]!==E?(q=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[Z,E]}),e[33]=Z,e[34]=E,e[35]=q):q=e[35];let T;e[36]!==H||e[37]!==i||e[38]!==d||e[39]!==h||e[40]!==F||e[41]!==o||e[42]!==z||e[43]!==a?(T=a==="default"?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[i?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:C=>{C.preventDefault(),C.stopPropagation(),h?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(d?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:d?s.jsx(A,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(A,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:z}),F?s.jsx("span",{className:"truncate",children:F}):null,H?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(A,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:H})]}):null]}):null,e[36]=H,e[37]=i,e[38]=d,e[39]=h,e[40]=F,e[41]=o,e[42]=z,e[43]=a,e[44]=T):T=e[44];let D;e[45]!==q||e[46]!==T?(D=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[q,T]}),e[45]=q,e[46]=T,e[47]=D):D=e[47];let I;e[48]!==S||e[49]!==P||e[50]!==o?(I=S||P?s.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:S?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":o("sessions.sidebar.session.status.active"),title:o("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":o("sessions.sidebar.session.status.unread"),title:o("sessions.sidebar.session.status.unread")})}):null,e[48]=S,e[49]=P,e[50]=o,e[51]=I):I=e[51];let M;return e[52]!==X||e[53]!==D||e[54]!==I||e[55]!==K?(M=s.jsxs(ke,{onClick:K,"data-slot":"session-switcher-item",className:te,style:X,children:[D,I]}),e[52]=X,e[53]=D,e[54]=I,e[55]=K,e[56]=M):M=e[56],M}function ut(n){return n.notifyOnSubtasks}function ft(n){return n.setCurrentSession}function pt(n){return n.currentSessionId}export{jt as C,vt as S,yt as W,bt as u};
1
+ import{f as V,R as Ne,j as s,r as ze}from"./vendor-react-BUCujlKS.js";import{u as je,at as Le,au as De,av as Ie,L as ne}from"./index-DRpChWux.js";import{f as ye,h as R,aZ as Te,w as Me,x as Pe,I as A,M as Fe,aY as $e,aX as Ee,aR as Ue,aT as Oe,aU as We,z as Ae,y as Ce,A as Be,C as Re,E as Ge,r as He}from"./useAppFontEffects-BikB6enL.js";import{d as ke}from"./vendor-base-ui-D_V6hAcE.js";function bt(){const n=V.c(5),e=je(Ye);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Le(),n[0]=t):t=n[0];const c=t;let a;n[1]!==e?(a=De(e),n[1]=e,n[2]=a):a=n[2];const r=a;let i;return n[3]!==r?(i={usesFramelessChrome:c,side:r},n[3]=r,n[4]=i):i=n[4],i}function Ye(n){return n.desktopWindowControlsPosition}const jt=n=>{const e=V.c(129),{totalTokens:t,percentage:c,colorPercentage:a,contextLimit:r,outputLimit:i,size:d,isMobile:h,hideIcon:m,showPercentIcon:o,className:u,valueClassName:f,percentIconClassName:p,onClick:x,pressed:g}=n,y=d===void 0?"default":d,w=h===void 0?!1:h,v=m===void 0?!1:m,_=o===void 0?!1:o,k=g===void 0?!1:g,{t:l}=ye(),[S,P]=Ne.useState(!1),j=typeof a=="number"?a:c;let b,N,z,L,F,G,B,H;if(e[0]!==j||e[1]!==r||e[2]!==v||e[3]!==w||e[4]!==x||e[5]!==i||e[6]!==p||e[7]!==c||e[8]!==_||e[9]!==l||e[10]!==t||e[11]!==f){const T=Me(c)??0,D=Pe(j),I=D==="critical"?"var(--status-error)":D==="warn"?"var(--status-warning)":"var(--status-success)";b=Ke,N=Xe;const M=2*Math.PI*8.5,C=M*(1-T/100);L=typeof i=="number"?Math.max(i,0):0;let U;e[20]!==l||e[21]!==t?(U=l("contextUsage.tooltip.usedTokens",{tokens:b(t)}),e[20]=l,e[21]=t,e[22]=U):U=e[22];let O;e[23]!==r||e[24]!==l?(O=l("contextUsage.tooltip.contextLimit",{tokens:b(r)}),e[23]=r,e[24]=l,e[25]=O):O=e[25];let W;e[26]!==L||e[27]!==l?(W=l("contextUsage.tooltip.outputLimit",{tokens:b(L)}),e[26]=L,e[27]=l,e[28]=W):W=e[28];let J;e[29]!==O||e[30]!==W||e[31]!==U?(J=[U,O,W],e[29]=O,e[30]=W,e[31]=U,e[32]=J):J=e[32],H=J,z=!w&&typeof x=="function",e[33]!==v||e[34]!==w?(B=!w&&!v&&s.jsx(A,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=v,e[34]=w,e[35]=B):B=e[35],e[36]!==f?(F=R("font-medium inline-flex items-center gap-1.5",f),e[36]=f,e[37]=F):F=e[37],G=_?s.jsxs(s.Fragment,{children:[s.jsxs("svg",{viewBox:"0 0 20 20",className:R("h-3.5 w-3.5 -rotate-90",p),role:"progressbar","aria-valuenow":Math.round(T),"aria-valuemin":0,"aria-valuemax":100,children:[s.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),s.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:I,strokeWidth:3,strokeLinecap:"round",strokeDasharray:M,strokeDashoffset:C,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),s.jsxs("span",{className:"text-foreground",children:[Math.min(c,999).toFixed(1),"%"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:N(j),children:Math.min(c,999).toFixed(1)}),"%"]}),e[0]=j,e[1]=r,e[2]=v,e[3]=w,e[4]=x,e[5]=i,e[6]=p,e[7]=c,e[8]=_,e[9]=l,e[10]=t,e[11]=f,e[12]=b,e[13]=N,e[14]=z,e[15]=L,e[16]=F,e[17]=G,e[18]=B,e[19]=H}else b=e[12],N=e[13],z=e[14],L=e[15],F=e[16],G=e[17],B=e[18],H=e[19];let Y;e[38]!==F||e[39]!==G?(Y=s.jsx("span",{className:F,children:G}),e[38]=F,e[39]=G,e[40]=Y):Y=e[40];let ee;e[41]!==B||e[42]!==Y?(ee=s.jsxs(s.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=ee):ee=e[43];const K=ee,te=y==="compact"?"typography-micro":"typography-meta";let se;e[44]!==u||e[45]!==z||e[46]!==te?(se=R("app-region-no-drag flex items-center gap-1.5 select-none",te,z?R("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",u),e[44]=u,e[45]=z,e[46]=te,e[47]=se):se=e[47];const X=se;let Z;e[48]!==K||e[49]!==z||e[50]!==w||e[51]!==x||e[52]!==k||e[53]!==X||e[54]!==l?(Z=z?s.jsx("button",{type:"button",className:X,"aria-label":l("contextUsage.aria.label"),"aria-pressed":k,onClick:x,children:K}):s.jsx("div",{className:X,"aria-label":l("contextUsage.aria.label"),onClick:w?()=>P(!0):void 0,children:K}),e[48]=K,e[49]=z,e[50]=w,e[51]=x,e[52]=k,e[53]=X,e[54]=l,e[55]=Z):Z=e[55];const Q=Z;if(w){let T;e[56]===Symbol.for("react.memo_cache_sentinel")?(T=()=>P(!1),e[56]=T):T=e[56];let D;e[57]!==l?(D=l("contextUsage.mobile.title"),e[57]=l,e[58]=D):D=e[58];let I;e[59]!==l?(I=l("contextUsage.mobile.usedTokens"),e[59]=l,e[60]=I):I=e[60];let M;e[61]!==I?(M=s.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[61]=I,e[62]=M):M=e[62];let C;e[63]!==b||e[64]!==t?(C=b(t),e[63]=b,e[64]=t,e[65]=C):C=e[65];let U;e[66]!==C?(U=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:C}),e[66]=C,e[67]=U):U=e[67];let O;e[68]!==M||e[69]!==U?(O=s.jsxs("div",{className:"flex justify-between items-center",children:[M,U]}),e[68]=M,e[69]=U,e[70]=O):O=e[70];let W;e[71]!==l?(W=l("contextUsage.mobile.contextLimit"),e[71]=l,e[72]=W):W=e[72];let J;e[73]!==W?(J=s.jsx("span",{className:"typography-meta text-muted-foreground",children:W}),e[73]=W,e[74]=J):J=e[74];let ie;e[75]!==r||e[76]!==b?(ie=b(r),e[75]=r,e[76]=b,e[77]=ie):ie=e[77];let oe;e[78]!==ie?(oe=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:ie}),e[78]=ie,e[79]=oe):oe=e[79];let re;e[80]!==J||e[81]!==oe?(re=s.jsxs("div",{className:"flex justify-between items-center",children:[J,oe]}),e[80]=J,e[81]=oe,e[82]=re):re=e[82];let le;e[83]!==l?(le=l("contextUsage.mobile.outputLimit"),e[83]=l,e[84]=le):le=e[84];let ae;e[85]!==le?(ae=s.jsx("span",{className:"typography-meta text-muted-foreground",children:le}),e[85]=le,e[86]=ae):ae=e[86];let ce;e[87]!==b||e[88]!==L?(ce=b(L),e[87]=b,e[88]=L,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let me;e[92]!==ae||e[93]!==de?(me=s.jsxs("div",{className:"flex justify-between items-center",children:[ae,de]}),e[92]=ae,e[93]=de,e[94]=me):me=e[94];let ue;e[95]!==l?(ue=l("contextUsage.mobile.usage"),e[95]=l,e[96]=ue):ue=e[96];let fe;e[97]!==ue?(fe=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ue}),e[97]=ue,e[98]=fe):fe=e[98];let pe;e[99]!==j||e[100]!==N?(pe=R("typography-meta font-semibold",N(j)),e[99]=j,e[100]=N,e[101]=pe):pe=e[101];const _e=Math.min(c,999);let he;e[102]!==_e?(he=_e.toFixed(1),e[102]=_e,e[103]=he):he=e[103];let xe;e[104]!==pe||e[105]!==he?(xe=s.jsxs("span",{className:pe,children:[he,"%"]}),e[104]=pe,e[105]=he,e[106]=xe):xe=e[106];let ge;e[107]!==fe||e[108]!==xe?(ge=s.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,xe]}),e[107]=fe,e[108]=xe,e[109]=ge):ge=e[109];let we;e[110]!==O||e[111]!==re||e[112]!==me||e[113]!==ge?(we=s.jsx("div",{className:"flex flex-col gap-1.5",children:s.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,re,me,ge]})}),e[110]=O,e[111]=re,e[112]=me,e[113]=ge,e[114]=we):we=e[114];let be;e[115]!==S||e[116]!==D||e[117]!==we?(be=s.jsx(Fe,{open:S,onClose:T,title:D,children:we}),e[115]=S,e[116]=D,e[117]=we,e[118]=be):be=e[118];let ve;return e[119]!==Q||e[120]!==be?(ve=s.jsxs(s.Fragment,{children:[Q,be]}),e[119]=Q,e[120]=be,e[121]=ve):ve=e[121],ve}let $;e[122]!==Q?($=s.jsx($e,{asChild:!0,children:Q}),e[122]=Q,e[123]=$):$=e[123];let E;e[124]!==H?(E=s.jsx(Te,{children:s.jsx("div",{className:"space-y-0.5",children:H.map(Ze)})}),e[124]=H,e[125]=E):E=e[125];let q;return e[126]!==$||e[127]!==E?(q=s.jsxs(Ee,{children:[$,E]}),e[126]=$,e[127]=E,e[128]=q):q=e[128],q};function Ke(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n.toFixed(1).replace(/\.0$/,"")}function Xe(n){return n>=90?"text-status-error":n>=75?"text-status-warning":"text-status-success"}function Ze(n){return s.jsx("p",{className:"typography-micro leading-tight",children:n},n)}const qe={close:"#FF5F57",minimize:"#FEBC2E",maximize:"#28C940"},Je="rgba(0, 0, 0, 0.7)",Qe=n=>{const e=V.c(3),{action:t}=n;if(t==="close"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(A,{name:"close",className:"size-[10px]"}),e[0]=a):a=e[0],a}if(t==="minimize"){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(A,{name:"subtract",className:"size-[10px]"}),e[1]=a):a=e[1],a}let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(A,{name:"add",className:"size-[10px]"}),e[2]=c):c=e[2],c},Ve=n=>{const e=V.c(18),{action:t,isMaximized:c,onActivate:a}=n,{t:r}=ye(),i=qe[t];let d;e[0]!==t||e[1]!==c||e[2]!==r?(d=r(t==="close"?"header.windowControls.close":t==="minimize"?"header.windowControls.minimize":c?"header.windowControls.restore":"header.windowControls.maximize"),e[0]=t,e[1]=c,e[2]=r,e[3]=d):d=e[3];const h=d;let m;e[4]!==t||e[5]!==a?(m=()=>a(t),e[4]=t,e[5]=a,e[6]=m):m=e[6];let o;e[7]!==i?(o={backgroundColor:i,color:Je},e[7]=i,e[8]=o):o=e[8];let u;e[9]!==t?(u=s.jsx("span",{className:"flex items-center justify-center opacity-0 transition-opacity duration-75 group-hover/wctl:opacity-100",children:s.jsx(Qe,{action:t})}),e[9]=t,e[10]=u):u=e[10];let f;e[11]!==o||e[12]!==u?(f=s.jsx("span",{className:"flex size-3.5 items-center justify-center rounded-full shadow-[inset_0_0_0_0.5px_rgba(0,0,0,0.28)] transition-[filter] duration-75 active:brightness-90",style:o,children:u}),e[11]=o,e[12]=u,e[13]=f):f=e[13];let p;return e[14]!==h||e[15]!==m||e[16]!==f?(p=s.jsx("button",{type:"button",onClick:m,title:h,"aria-label":h,className:"app-region-no-drag flex h-8 w-[24px] items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:f}),e[14]=h,e[15]=m,e[16]=f,e[17]=p):p=e[17],p},yt=Ne.memo(function(e){const t=V.c(25),{visible:c,position:a}=e,r=a===void 0?"right":a,{t:i}=ye(),[d,h]=Ne.useState(!1),m=je(et);let o,u;if(t[0]!==c?(o=()=>{if(!c)return;let v=!1;ne("desktop_get_current_window_state").then(k=>{v||h(!!k?.maximized)}).catch(tt);const _=k=>{const l=k.detail;h(!!l?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",_),()=>{v=!0,window.removeEventListener("openchamber:window-maximized-changed",_)}},u=[c],t[0]=c,t[1]=o,t[2]=u):(o=t[1],u=t[2]),ze.useEffect(o,u),!c)return null;const f=r==="left";let p,x,g,y;if(t[3]!==m||t[4]!==f||t[5]!==d||t[6]!==r||t[7]!==i){y=Symbol.for("react.early_return_sentinel");e:{const v=Ie(r);let _;t[12]===Symbol.for("react.memo_cache_sentinel")?(_=j=>{if(j==="close"){ne("desktop_close_current_window");return}if(j==="minimize"){ne("desktop_minimize_current_window");return}ne("desktop_toggle_current_window_maximized").then(b=>h(!!b?.maximized)).catch(st)},t[12]=_):_=t[12];const k=_;if(m==="traffic-lights"){const j=f?"mr-1":"ml-1";let b;t[13]!==j?(b=R("app-region-no-drag group/wctl flex h-8 shrink-0 items-center",j),t[13]=j,t[14]=b):b=t[14];let N;t[15]!==i?(N=i("header.windowControls.groupAria"),t[15]=i,t[16]=N):N=t[16];let z;t[17]!==d?(z=L=>s.jsx(Ve,{action:L,isMaximized:d,onActivate:k},L),t[17]=d,t[18]=z):z=t[18],y=s.jsx("div",{className:b,"aria-label":N,children:v.map(z)});break e}const l=R("app-region-no-drag inline-flex items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",f?"h-8 w-8 rounded-md":"h-12 w-11"),S=f?"app-region-no-drag mr-1 flex h-8 shrink-0 items-center":"app-region-no-drag ml-1 flex h-12 shrink-0 items-center",P=j=>j==="minimize"?s.jsx("button",{type:"button",className:l,onClick:nt,title:i("header.windowControls.minimize"),"aria-label":i("header.windowControls.minimize"),children:s.jsx(A,{name:"subtract",className:"h-4 w-4"})},"minimize"):j==="maximize"?s.jsx("button",{type:"button",className:l,onClick:()=>{ne("desktop_toggle_current_window_maximized").then(b=>h(!!b?.maximized)).catch(it)},title:i(d?"header.windowControls.restore":"header.windowControls.maximize"),"aria-label":i(d?"header.windowControls.restore":"header.windowControls.maximize"),children:s.jsx(A,{name:d?"fullscreen-exit":"checkbox-blank",className:"h-3.5 w-3.5"})},"maximize"):s.jsx("button",{type:"button",className:R(l,"hover:bg-status-error hover:text-status-error-foreground"),onClick:ot,title:i("header.windowControls.close"),"aria-label":i("header.windowControls.close"),children:s.jsx(A,{name:"close",className:"h-4 w-4"})},"close");p=S,t[19]!==i?(x=i("header.windowControls.groupAria"),t[19]=i,t[20]=x):x=t[20],g=v.map(P)}t[3]=m,t[4]=f,t[5]=d,t[6]=r,t[7]=i,t[8]=p,t[9]=x,t[10]=g,t[11]=y}else p=t[8],x=t[9],g=t[10],y=t[11];if(y!==Symbol.for("react.early_return_sentinel"))return y;let w;return t[21]!==p||t[22]!==x||t[23]!==g?(w=s.jsx("div",{className:p,"aria-label":x,children:g}),t[21]=p,t[22]=x,t[23]=g,t[24]=w):w=t[24],w});function et(n){return n.desktopWindowControlsStyle}function tt(){}function st(){}function nt(){ne("desktop_minimize_current_window")}function it(){}function ot(){ne("desktop_close_current_window")}function vt(n){const e=V.c(18),{children:t,variant:c,scopeProjectId:a,align:r}=n,i=c===void 0?"default":c,d=a===void 0?null:a,h=r===void 0?"start":r,m=je(lt),o=je(rt);let u;e[0]!==t?(u=s.jsx(Ue,{asChild:!0,children:t}),e[0]=t,e[1]=u):u=e[1];const f=i==="compact"?"w-[280px]":"w-[360px]";let p;e[2]!==f?(p=R("overflow-hidden p-1 max-w-[calc(100vw-32px)]",f),e[2]=f,e[3]=p):p=e[3];let x;e[4]!==m||e[5]!==d||e[6]!==o||e[7]!==i?(x=m?s.jsx(at,{onSelect:()=>o(!1),variant:i,scopeProjectId:d}):null,e[4]=m,e[5]=d,e[6]=o,e[7]=i,e[8]=x):x=e[8];let g;e[9]!==h||e[10]!==p||e[11]!==x?(g=s.jsx(Oe,{align:h,sideOffset:6,className:p,children:x}),e[9]=h,e[10]=p,e[11]=x,e[12]=g):g=e[12];let y;return e[13]!==m||e[14]!==o||e[15]!==u||e[16]!==g?(y=s.jsxs(We,{open:m,onOpenChange:o,modal:!1,children:[u,g]}),e[13]=m,e[14]=o,e[15]=u,e[16]=g,e[17]=y):y=e[17],y}function rt(n){return n.setSessionDropdownOpen}function lt(n){return n.isSessionDropdownOpen}function at(n){const e=V.c(26),{onSelect:t,variant:c,scopeProjectId:a}=n;let r;e[0]!==a?(r={scopeProjectId:a},e[0]=a,e[1]=r):r=e[1];const i=Ae(!0,r),d=Ce(dt),h=je(ct),{t:m}=ye();let o;e[2]!==t||e[3]!==d||e[4]!==h?(o=()=>{h("chat"),t(),d()},e[2]=t,e[3]=d,e[4]=h,e[5]=o):o=e[5];const u=o;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,e[6]=f):f=e[6];const[p,x]=Ne.useState(f);let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=j=>{x(b=>{const N=new Set(b);return N.has(j)?N.delete(j):N.add(j),N})},e[7]=g):g=e[7];const y=g;let w,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=R("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),v=s.jsx(A,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=w,e[9]=v):(w=e[8],v=e[9]);let _;e[10]!==m?(_=m("sessions.sidebar.header.actions.newSession"),e[10]=m,e[11]=_):_=e[11];let k;e[12]!==_?(k=s.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:_}),e[12]=_,e[13]=k):k=e[13];let l;e[14]!==u||e[15]!==k?(l=s.jsxs(ke,{onClick:u,className:w,children:[v,k]}),e[14]=u,e[15]=k,e[16]=l):l=e[16];let S;e[17]!==p||e[18]!==i||e[19]!==t||e[20]!==m||e[21]!==c?(S=i.length===0?s.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:m("sessions.switcher.empty")}):i.map(j=>s.jsx(Se,{item:j,depth:0,variant:c,expandedParents:p,toggleParent:y,closeDropdown:t},j.node.session.id)),e[17]=p,e[18]=i,e[19]=t,e[20]=m,e[21]=c,e[22]=S):S=e[22];let P;return e[23]!==S||e[24]!==l?(P=s.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"space-y-0.5",children:[l,S]})}),e[23]=S,e[24]=l,e[25]=P):P=e[25],P}function ct(n){return n.setActiveMainTab}function dt(n){return n.openNewSessionDraft}function Se(n){const e=V.c(31),{item:t,depth:c,variant:a,expandedParents:r,toggleParent:i,closeDropdown:d}=n,{node:h,secondaryMeta:m}=t,o=h.session,u=h.children.length>0;let f;e[0]!==r||e[1]!==o.id?(f=r.has(o.id),e[0]=r,e[1]=o.id,e[2]=f):f=e[2];const p=f;let x;e[3]!==u||e[4]!==o.id||e[5]!==i?(x=u?()=>i(o.id):void 0,e[3]=u,e[4]=o.id,e[5]=i,e[6]=x):x=e[6];let g;e[7]!==d||e[8]!==c||e[9]!==u||e[10]!==p||e[11]!==m||e[12]!==o||e[13]!==x||e[14]!==a?(g=s.jsx(mt,{session:o,depth:c,variant:a,secondaryMeta:m,hasChildren:u,isExpanded:p,onToggleExpand:x,closeDropdown:d}),e[7]=d,e[8]=c,e[9]=u,e[10]=p,e[11]=m,e[12]=o,e[13]=x,e[14]=a,e[15]=g):g=e[15];let y;e[16]!==d||e[17]!==c||e[18]!==r||e[19]!==u||e[20]!==p||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==h.children||e[24]!==m||e[25]!==i||e[26]!==a?(y=u&&p?h.children.map(v=>s.jsx(Se,{item:{node:v,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:m},depth:c+1,variant:a,expandedParents:r,toggleParent:i,closeDropdown:d},v.session.id)):null,e[16]=d,e[17]=c,e[18]=r,e[19]=u,e[20]=p,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=h.children,e[24]=m,e[25]=i,e[26]=a,e[27]=y):y=e[27];let w;return e[28]!==g||e[29]!==y?(w=s.jsxs(s.Fragment,{children:[g,y]}),e[28]=g,e[29]=y,e[30]=w):w=e[30],w}function mt(n){const e=V.c(57),{session:t,depth:c,variant:a,secondaryMeta:r,hasChildren:i,isExpanded:d,onToggleExpand:h,closeDropdown:m}=n,{t:o}=ye(),u=Ce(pt),f=Ce(ft),p=je(ut),x=Be(t.id),g=Re(t.id),y=u===t.id;let w;e[0]!==t.title||e[1]!==o?(w=t.title?.trim()||o("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=o,e[2]=w):w=e[2];const v=w,_=!!t.parentID,k=g>0&&(!_||p),l=x?.type??"idle",S=l==="busy"||l==="retry",P=!S&&k&&!y;let j;e[3]!==t.time?.created||e[4]!==t.time?.updated?(j=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=j):j=e[5];const b=j;let N;e[6]!==b?(N=Ge(b),e[6]=b,e[7]=N):N=e[7];const z=N;let L;e[8]!==r?.projectLabel?(L=r?.projectLabel?.trim()||null,e[8]=r?.projectLabel,e[9]=L):L=e[9];const F=L;let G;e[10]!==r?.branchLabel?(G=r?.branchLabel?.trim()||null,e[10]=r?.branchLabel,e[11]=G):G=e[11];const B=G,H=B&&B!=="HEAD"?B:null;let Y;e[12]!==m||e[13]!==y||e[14]!==t||e[15]!==f?(Y=()=>{if(y){m();return}const C=He(t);f(t.id,C??null),m()},e[12]=m,e[13]=y,e[14]=t,e[15]=f,e[16]=Y):Y=e[16];const ee=Y;let K;e[17]!==ee?(K=C=>{if(C.target?.closest("[data-switcher-expand]")){C.preventDefault();return}ee()},e[17]=ee,e[18]=K):K=e[18];let te;e[19]===Symbol.for("react.memo_cache_sentinel")?(te=R("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=te):te=e[19];const se=8+c*12;let X;e[20]!==se?(X={paddingLeft:se},e[20]=se,e[21]=X):X=e[21];let Z;e[22]!==i||e[23]!==d||e[24]!==h||e[25]!==o||e[26]!==a?(Z=a==="compact"&&i?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:C=>{C.preventDefault(),C.stopPropagation(),h?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(d?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:d?s.jsx(A,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):s.jsx(A,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=i,e[23]=d,e[24]=h,e[25]=o,e[26]=a,e[27]=Z):Z=e[27];const Q=y?"text-primary":"text-foreground";let $;e[28]!==Q?($=R("truncate text-[14px] font-normal leading-tight",Q),e[28]=Q,e[29]=$):$=e[29];let E;e[30]!==v||e[31]!==$?(E=s.jsx("span",{className:$,children:v}),e[30]=v,e[31]=$,e[32]=E):E=e[32];let q;e[33]!==Z||e[34]!==E?(q=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[Z,E]}),e[33]=Z,e[34]=E,e[35]=q):q=e[35];let T;e[36]!==H||e[37]!==i||e[38]!==d||e[39]!==h||e[40]!==F||e[41]!==o||e[42]!==z||e[43]!==a?(T=a==="default"?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[i?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:C=>{C.preventDefault(),C.stopPropagation(),h?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(d?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:d?s.jsx(A,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(A,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:z}),F?s.jsx("span",{className:"truncate",children:F}):null,H?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(A,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:H})]}):null]}):null,e[36]=H,e[37]=i,e[38]=d,e[39]=h,e[40]=F,e[41]=o,e[42]=z,e[43]=a,e[44]=T):T=e[44];let D;e[45]!==q||e[46]!==T?(D=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[q,T]}),e[45]=q,e[46]=T,e[47]=D):D=e[47];let I;e[48]!==S||e[49]!==P||e[50]!==o?(I=S||P?s.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:S?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":o("sessions.sidebar.session.status.active"),title:o("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":o("sessions.sidebar.session.status.unread"),title:o("sessions.sidebar.session.status.unread")})}):null,e[48]=S,e[49]=P,e[50]=o,e[51]=I):I=e[51];let M;return e[52]!==X||e[53]!==D||e[54]!==I||e[55]!==K?(M=s.jsxs(ke,{onClick:K,"data-slot":"session-switcher-item",className:te,style:X,children:[D,I]}),e[52]=X,e[53]=D,e[54]=I,e[55]=K,e[56]=M):M=e[56],M}function ut(n){return n.notifyOnSubtasks}function ft(n){return n.setCurrentSession}function pt(n){return n.currentSessionId}export{jt as C,vt as S,yt as W,bt as u};
@@ -1,4 +1,4 @@
1
- import{R as o,j as s,f as ht,r as We}from"./vendor-react-BUCujlKS.js";import{f as ot,B as H,I as _,o as En,aV as Jn,t as R,O as Cl,f8 as Il,ee as Oe,f9 as Et,b as Fs,h as je,fa as Pl,aR as $s,aT as Bs,fb as Al,aU as Hs,e5 as ja,fc as Tl,fd as Bn,fe as qs,bU as Ds,bs as Ut,bt as Vt,bu as Ht,bv as Gt,bw as qt,bx as os,S as He,ff as xa,aQ as Gs,dV as Oi,fg as El,fh as ir,fi as In,eg as Yt,fj as Ls,l as nt,fk as $t,bK as Dt,bL as Mt,eq as Kt,bM as _t,bN as Rt,bO as dt,fl as Qt,bP as Ns,dj as ua,fm as bn,er as Gn,fn as vn,fo as gs,dp as ys,fp as Dl,fq as ut,fr as Ao,fs as Ml,ft as qn,fu as qa,fv as Rl,fw as Qa,fx as rn,fy as Hn,dk as To,fz as Tn,ag as Ya,af as Is,fA as rr,eH as Ol,dT as Eo,g as ga,fB as Ll,fC as Vs,dS as Fl,fD as Kl,fE as _l,fF as Wi,aX as Ji,aY as Qi,aZ as Do,fG as an,fH as sn,L as Yi,fI as or,aa as zl,bQ as Ul,cq as Vl,Q as $l,N as Bl,R as Hl,V as Mo,fJ as Gl,fK as ql,bH as Wl,bR as Li,eG as lr,P as Pn,fL as xn,ed as As,a$ as Ro,n as ss,bg as Wa,x as Jl,i as Ql,j as Yl,bA as Zl,p as Xl,fM as ec,bj as tc,bB as cr,bC as Oo,bi as sc,fN as gi,fO as dr,fP as nc,fQ as ac,fR as ic,fS as rc,dv as Za,fT as bs,fU as Os,fV as gn,fW as hn,aj as ea,fX as fn,fY as Wn,fZ as pr,f_ as ta,f$ as sa,g0 as oc,g1 as lc,g2 as cc,g3 as dc,g4 as hi,g5 as mr,g6 as pc,g7 as mc,g8 as uc,g9 as gc,ga as hc,gb as fi,gc as ur,gd as fc,cb as xc,br as gr,ge as nn,gf as xi,bq as hr,gg as Lo,gh as fr,gi as Fo,gj as bc,d_ as vc,gk as yc,ac as dn,ae as jc,gl as wc}from"./useAppFontEffects-sHmU5b8u.js";import{r as ct,C as ds,cr as Nc,cs as xr,t as on,al as bi,l as Ko,U as kc,K as yt,n as jn,u as de,x as is,I as br,bY as vr,b$ as yr,J as na,p as Sc,ct as Cc,j as Ic,bX as $n,cu as Pc,a4 as Ac,b_ as Tc,cv as Ec,cw as Dc,s as Mc,e as wa,bZ as Rc,y as Na,cx as _o,R as Oc,cy as Lc,Q as Fc,aB as jr,at as Kc,Y as yn,cz as _c,q as zo,cA as wr,cq as Nr,cB as kr,ar as Sr,cC as zc,cD as Uc,cE as Cr,b as Vc,ap as Uo,cF as Vo,cG as $c,cH as Bc,cI as Hc,cJ as Gc,cK as qc,cL as Wc,af as Jc,i as $o}from"./index-iFY_N5aO.js";import{u as Qc,U as Ir,w as Dn,y as Mn,z as Rn,A as On,b as Zi,q as ba,s as va,v as ya,J as An,F as Yc,h as ws,p as Zc,H as Xc,K as pa,Q as Bo,B as ed,E as td}from"./runtimeEndpointReset-cbahJ3hD.js";import{u as Ps,c as Ho,d as sd,p as nd}from"./vendor-zustand-BAGL70zf.js";import{s as ad,p as id}from"./vendor-yaml-3778uTud.js";import{c as Pr,s as rd,C as Ar,P as od}from"./shikiHighlight-CmanopUB.js";import{getResolvedShikiTheme as ld}from"./appThemeRegistry-BK0dHKa6.js";import{E as Tr}from"./vendor-codemirror-view-DSzLbZiS.js";import{Q as Go}from"./vendor-qrcode-DTJ12-WC.js";import{f as cd,s as dd}from"./contextPanelEmbeddedChat-tQekJUAF.js";const Er=()=>{const{t}=ot(),[e,a]=o.useState(null);o.useEffect(()=>{let i=!1;const r=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const x=await ct("/api/system/info",{signal:r?.signal,headers:{Accept:"application/json"}});if(!x.ok)return;const c=await x.json().catch(()=>null);if(!c||i)return;const y=typeof c.port=="number"&&Number.isFinite(c.port)&&c.port>0?c.port:null,m=typeof c.tunnelUrl=="string"&&c.tunnelUrl.trim().length>0?c.tunnelUrl.trim():null;a({port:y,tunnelUrl:m})}catch{}})(),()=>{i=!0,r?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(i=>s.jsxs(H,{type:"button",variant:"outline",size:"sm",title:i.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{En(i.url)},children:[s.jsx(_,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:i.url})]},i.key))})},Dr="https://github.com/openchamber/openchamber",pd="https://discord.gg/ZYRSdnwwKA",Mr="https://x.com/openchamber_dev",md=800,qo=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=ot(),[a,n]=o.useState(t),[i,r]=o.useState(!1),[l,x]=o.useState(null),[c,y]=o.useState(null),m=Qc(Ps(N=>({info:N.info,checking:N.checking,available:N.available,error:N.error,downloading:N.downloading,downloaded:N.downloaded,progress:N.progress,runtimeType:N.runtimeType,checkForUpdates:N.checkForUpdates,downloadUpdate:N.downloadUpdate,restartToUpdate:N.restartToUpdate}))),{isMobile:b}=Jn(),p=l||m.info?.currentVersion||"unknown";o.useEffect(()=>{let N=!1;return(async()=>{try{const C=await ct("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!C.ok)return;const u=await C.json().catch(()=>null),E=typeof u?.openchamberVersion=="string"&&u.openchamberVersion.trim().length>0?u.openchamberVersion.trim():null;N||x(E)}catch{N||x(null)}})(),()=>{N=!0}},[]),o.useEffect(()=>{let N=!1;return(async()=>{try{const C=await ct("/api/opencode/upgrade-status",{method:"GET",headers:{Accept:"application/json"}});if(!C.ok)return;const u=await C.json().catch(()=>null),E=typeof u?.currentVersion=="string"&&u.currentVersion.trim().length>0?u.currentVersion.trim():null;N||y(E)}catch{N||y(null)}})(),()=>{N=!0}},[]);const L=o.useRef(!1);o.useEffect(()=>{if(m.checking)r(!0),L.current=!0;else if(i){const N=setTimeout(()=>{r(!1),L.current&&!m.available&&!m.error&&(R.success(e("settings.openchamber.about.toast.latestVersion")),L.current=!1)},md);return()=>clearTimeout(N)}},[e,m.checking,i,m.available,m.error]);const k=m.checking||i;return b?s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(Cl,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${Il}`,children:"OpenChamber"}),s.jsxs("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:p})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:c||e("settings.openchamber.about.state.unknown")})})]}),s.jsx(Er,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!m.available&&!m.error&&s.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:()=>m.checkForUpdates(),disabled:k,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[k?s.jsx(_,{name:"loader",className:"size-4 animate-spin"}):s.jsx(_,{name:"refresh",className:"size-4"}),e(k?"settings.openchamber.about.state.checking":"settings.openchamber.about.actions.checkForUpdates")]}),!k&&m.available&&s.jsxs(H,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[s.jsx(_,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]})]}),m.error&&s.jsx("p",{className:"rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:m.error}),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:Dr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:pd,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Mr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(Ir,{open:a,onOpenChange:n,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]}):s.jsxs(Oe,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Et,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:p})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Et,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:c||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[m.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(_,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!m.checking&&m.available&&s.jsxs(H,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx(_,{name:"download",className:"h-4 w-4 mr-1"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]}),!m.checking&&!m.available&&!m.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(H,{size:"sm",variant:"outline",onClick:()=>m.checkForUpdates(),disabled:m.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),m.error&&s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:m.error})}),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Et,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(Er,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:Dr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(_,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Mr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(_,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(Ir,{open:a,onOpenChange:n,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]})},Wo=t=>t.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),ka=t=>{const e=ht.c(39),{className:a}=t,{t:n}=ot(),i=Fs(ud),r=Fs(gd),l=Fs(hd),x=ds();let c;e[0]!==i?(c=[...i].sort(fd),e[0]=i,e[1]=c):c=e[1];const y=c;let m;e:{if(y.length===0){m=null;break e}let $;e[2]!==r||e[3]!==y?($=y.find(w=>w.id===r)??y[0],e[2]=r,e[3]=y,e[4]=$):$=e[4],m=$}const b=m;if(x||y.length===0)return null;let p;e[5]!==b||e[6]!==n?(p=b?.label&&b.label.trim().length>0?b.label:b?.path.split("/").filter(Boolean).pop()||b?.path||n("settings.shared.projectSelector.fallbackProject"),e[5]=b,e[6]=n,e[7]=p):p=e[7];const L=p;let k;e[8]!==L?(k=Wo(L),e[8]=L,e[9]=k):k=e[9];const N=k;let h;e[10]!==a?(h=je(a),e[10]=a,e[11]=h):h=e[11];let C;e[12]!==n?(C=n("settings.shared.projectSelector.switchProjectAria"),e[12]=n,e[13]=C):C=e[13];let u;e[14]!==n?(u=n("settings.shared.projectSelector.switchProjectTitle"),e[14]=n,e[15]=u):u=e[15];let E,q;e[16]===Symbol.for("react.memo_cache_sentinel")?(E=je("text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none","hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70","flex items-center gap-1.5 text-left"),q=s.jsx(_,{name:"folder",className:"h-4 w-4 opacity-70"}),e[16]=E,e[17]=q):(E=e[16],q=e[17]);let M;e[18]!==N?(M=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:N}),e[18]=N,e[19]=M):M=e[19];let I;e[20]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(_,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[20]=I):I=e[20];let g;e[21]!==M||e[22]!==C||e[23]!==u?(g=s.jsx($s,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":C,title:u,className:E,children:[q,M,I]})}),e[21]=M,e[22]=C,e[23]=u,e[24]=g):g=e[24];const j=b?.id??"";let F;e[25]!==l?(F=$=>{$&&l($)},e[25]=l,e[26]=F):F=e[26];let S;e[27]!==y?(S=y.map(xd),e[27]=y,e[28]=S):S=e[28];let T;e[29]!==j||e[30]!==F||e[31]!==S?(T=s.jsx(Bs,{align:"start",className:"w-auto",children:s.jsx(Al,{value:j,onValueChange:F,children:S})}),e[29]=j,e[30]=F,e[31]=S,e[32]=T):T=e[32];let v;e[33]!==g||e[34]!==T?(v=s.jsxs(Hs,{children:[g,T]}),e[33]=g,e[34]=T,e[35]=v):v=e[35];let K;return e[36]!==v||e[37]!==h?(K=s.jsx("div",{className:h,children:v}),e[36]=v,e[37]=h,e[38]=K):K=e[38],K};function ud(t){return t.projects}function gd(t){return t.activeProjectId}function hd(t){return t.setActiveProject}function fd(t,e){return(t.label||t.path).localeCompare(e.label||e.path)}function xd(t){const e=t.label?.trim()?t.label.trim():t.path.split("/").filter(Boolean).pop()||t.path,a=Wo(e);return s.jsx(Pl,{value:t.id,children:s.jsx("span",{className:"min-w-0 truncate typography-ui",children:a})},t.id)}function bd(t,e){return`opencode:sidebar-group:${t}:${e}`}const Fi=t=>{const e=ht.c(33),{label:a,count:n,storageKey:i,defaultExpanded:r,children:l}=t,x=r===void 0?!0:r;let c;e[0]!==a||e[1]!==i?(c=bd(i,a),e[0]=a,e[1]=i,e[2]=c):c=e[2];const y=c,m=o.useId();let b;e[3]!==x||e[4]!==y?(b=()=>{try{const T=localStorage.getItem(y);if(T!==null)return T==="true"}catch{}return x},e[3]=x,e[4]=y,e[5]=b):b=e[5];const[p,L]=We.useState(b);let k,N;e[6]!==p||e[7]!==y?(k=()=>{try{localStorage.setItem(y,String(p))}catch{}},N=[y,p],e[6]=p,e[7]=y,e[8]=k,e[9]=N):(k=e[8],N=e[9]),We.useEffect(k,N);let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>L(vd),e[10]=h):h=e[10];let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=je("flex w-full items-center gap-1 rounded-md px-2 py-1 text-left","text-xs font-semibold uppercase tracking-wide text-muted-foreground","hover:bg-[var(--interactive-hover)] transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"),e[11]=C):C=e[11];const u=!p&&"-rotate-90";let E;e[12]!==u?(E=je("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",u),e[12]=u,e[13]=E):E=e[13];let q;e[14]!==E?(q=s.jsx(_,{name:"arrow-down-s",className:E}),e[14]=E,e[15]=q):q=e[15];let M;e[16]!==a?(M=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=M):M=e[17];let I;e[18]!==n?(I=s.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=I):I=e[19];let g;e[20]!==m||e[21]!==p||e[22]!==q||e[23]!==M||e[24]!==I?(g=s.jsxs("button",{type:"button",onClick:h,"aria-expanded":p,"aria-controls":m,className:C,children:[q,M,I]}),e[20]=m,e[21]=p,e[22]=q,e[23]=M,e[24]=I,e[25]=g):g=e[25];const j=!p;let F;e[26]!==l||e[27]!==m||e[28]!==j?(F=s.jsx("div",{id:m,hidden:j,className:"mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]",children:l}),e[26]=l,e[27]=m,e[28]=j,e[29]=F):F=e[29];let S;return e[30]!==g||e[31]!==F?(S=s.jsxs("div",{children:[g,F]}),e[30]=g,e[31]=F,e[32]=S):S=e[32],S};function vd(t){return!t}const yd=t=>{if(!Array.isArray(t))return[];const e=[];for(const a of t){if(!a||typeof a!="object")continue;const n=a;typeof n.permission!="string"||typeof n.pattern!="string"||typeof n.action!="string"||n.action!=="allow"&&n.action!=="ask"&&n.action!=="deny"||e.push({permission:n.permission,pattern:n.pattern,action:n.action})}return e},jd=t=>{const e=new Map;for(const a of t)!a.permission||a.permission==="invalid"||a.pattern&&e.set(`${a.permission}::${a.pattern}`,a);return Array.from(e.values())},Rr=t=>{const e=jd(yd(t));if(e.length===0)return;const a={};for(const i of e)i.permission&&((a[i.permission]||={})[i.pattern]=i.action);const n={};for(const[i,r]of Object.entries(a)){const l=Object.keys(r);if(l.length===1&&l[0]==="*"){n[i]=r["*"];continue}n[i]=r}return Object.keys(n).length>0?n:void 0},wd=({onItemSelect:t})=>{const{t:e}=ot(),[a,n]=o.useState(null),[i,r]=o.useState(""),[l,x]=o.useState(null),[c,y]=o.useState(null),[m,b]=o.useState(!1),[p,L]=o.useState(null),{selectedAgentName:k,agents:N,setSelectedAgent:h,setAgentDraft:C,createAgent:u,deleteAgent:E,loadAgents:q}=ja(Ps(P=>({selectedAgentName:P.selectedAgentName,agents:P.agents,setSelectedAgent:P.setSelectedAgent,setAgentDraft:P.setAgentDraft,createAgent:P.createAgent,deleteAgent:P.deleteAgent,loadAgents:P.loadAgents})));o.useEffect(()=>{q()},[q]);const M="bg-background",I=()=>{const P="new-agent";let ee=P,se=1;for(;N.some(D=>D.name===ee);)ee=`${P}-${se}`,se++;C({name:ee,scope:"user"}),h(ee),t?.()},g=async P=>{if(Bn(P)){R.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}x(P),y("delete")},j=async P=>{Bn(P)&&(x(P),y("reset"))},F=()=>{x(null),y(null)},S=async()=>{if(!(!l||!c)){b(!0);try{const P=await E(l.name,l.scope);P.ok?(P.requiresManualRestart?R.warning(e("settings.agents.page.toast.savedManualRestart")):P.restartDeferred?R.success(e("settings.view.pendingRestart.saved")):c==="delete"?R.success(e("settings.agents.sidebar.toast.agentDeleted",{name:l.name})):R.success(e("settings.agents.sidebar.toast.agentReset",{name:l.name})),F()):c==="delete"?R.error(e("settings.agents.sidebar.toast.deleteFailed")):R.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(P){const ee=P instanceof Error?P.message:"",se=/built-in|not deletable|not found/i.test(ee);c==="delete"?R.error(e(se?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):R.error(e("settings.agents.sidebar.toast.resetFailed"))}b(!1)}},T=P=>{const ee=P.name;let se=1,D=`${ee}-copy`;for(;N.some(V=>V.name===D);)se++,D=`${ee}-copy-${se}`;const O=P,U=P.model?.providerID&&P.model?.modelID?`${P.model.providerID}/${P.model.modelID}`:null,A=P;C({name:D,scope:O.scope||"user",description:P.description,model:U,variant:P.variant,temperature:P.temperature,top_p:P.topP,prompt:P.prompt,mode:P.mode,permission:Rr(P.permission),disable:A.disable}),h(D)},v=P=>{r(P.name),n(P)},K=async()=>{if(!a)return;const P=i.trim().replace(/\s+/g,"-");if(!P){R.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(P===a.name){n(null);return}if(N.some(O=>O.name===P)){R.error(e("settings.agents.sidebar.toast.agentExists"));return}const ee=a.model?.providerID&&a.model?.modelID?`${a.model.providerID}/${a.model.modelID}`:null,se=a,D=await u({name:P,description:a.description,model:ee,variant:a.variant,temperature:a.temperature,top_p:a.topP,prompt:a.prompt,mode:a.mode,permission:Rr(a.permission),disable:se.disable,scope:se.scope});if(D.ok){const O=await E(a.name,se.scope);O.ok?(D.requiresManualRestart||O.requiresManualRestart?R.warning(e("settings.agents.page.toast.savedManualRestart")):R.success(e("settings.agents.sidebar.toast.agentRenamed",{name:P})),h(P)):R.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed"))}else R.error(e("settings.agents.sidebar.toast.renameFailed"));n(null)},$=P=>{switch(P){case"primary":return s.jsx(_,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(_,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(_,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},w=N.filter(P=>!Tl(P)),G=w.filter(Bn),Q=w.filter(P=>!Bn(P)),{groupedCustomAgents:X,ungroupedCustomAgents:Z}=We.useMemo(()=>{const P={},ee=[];for(const D of Q){const O=D;O.group?(P[O.group]||(P[O.group]=[]),P[O.group].push(D)):ee.push(D)}return{groupedCustomAgents:Object.keys(P).sort((D,O)=>D.localeCompare(O)).map(D=>({name:D,agents:P[D]})),ungroupedCustomAgents:ee}},[Q]);return s.jsxs("div",{className:je("flex h-full flex-col",M),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${qs} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(ka,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:w.length})}),s.jsx(H,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:I,children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:w.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[G.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),G.map(P=>s.jsx(vi,{agent:P,isSelected:k===P.name,onSelect:()=>{h(P.name),t?.()},onReset:()=>j(P),onDuplicate:()=>T(P),getAgentModeIcon:$,isMenuOpen:p===P.name,onMenuOpenChange:ee=>L(ee?P.name:null)},P.name))]}),Q.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),X.map(({name:P,agents:ee})=>s.jsx(Fi,{label:P,count:ee.length,storageKey:"agents",children:ee.map(se=>s.jsx(vi,{agent:se,isSelected:k===se.name,onSelect:()=>{h(se.name),t?.()},onRename:()=>v(se),onDelete:()=>g(se),onDuplicate:()=>T(se),getAgentModeIcon:$,isMenuOpen:p===se.name,onMenuOpenChange:D=>L(D?se.name:null)},se.name))},P)),Z.map(P=>s.jsx(vi,{agent:P,isSelected:k===P.name,onSelect:()=>{h(P.name),t?.()},onRename:()=>v(P),onDelete:()=>g(P),onDuplicate:()=>T(P),getAgentModeIcon:$,isMenuOpen:p===P.name,onMenuOpenChange:ee=>L(ee?P.name:null)},P.name))]})]})}),s.jsx(Ut,{open:l!==null&&c!==null,onOpenChange:P=>{!P&&!m&&F()},children:s.jsxs(Vt,{className:"max-w-md",children:[s.jsxs(Ht,{children:[s.jsx(Gt,{children:e(c==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),s.jsx(qt,{children:c==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:l?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:l?.name??""})})]}),s.jsxs(os,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:F,disabled:m,children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:S,disabled:m,children:e(c==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),s.jsx(Ut,{open:a!==null,onOpenChange:P=>!P&&n(null),children:s.jsxs(Vt,{children:[s.jsxs(Ht,{children:[s.jsx(Gt,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(qt,{children:e("settings.agents.sidebar.renameDialog.description",{name:a?.name??""})})]}),s.jsx(He,{value:i,onChange:P=>r(P.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:P=>{P.key==="Enter"&&K()}}),s.jsxs(os,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>n(null),children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:K,children:e("settings.common.actions.rename")})]})]})})]})},vi=t=>{const e=ht.c(52),{agent:a,isSelected:n,onSelect:i,onDelete:r,onReset:l,onRename:x,onDuplicate:c,getAgentModeIcon:y,isMenuOpen:m,onMenuOpenChange:b}=t,{t:p}=ot(),L=a;let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=xa(),e[0]=k):k=e[0];const N=k,[h,C]=o.useState(!1);let u;e[1]!==r||e[2]!==c||e[3]!==x||e[4]!==l||e[5]!==p?(u=se=>s.jsxs(s.Fragment,{children:[x&&s.jsxs(se,{onClick:D=>{D.stopPropagation(),x()},children:[s.jsx(_,{name:"edit",className:"h-4 w-4 mr-px"}),p("settings.common.actions.rename")]}),s.jsxs(se,{onClick:D=>{D.stopPropagation(),c()},children:[s.jsx(_,{name:"file-copy",className:"h-4 w-4 mr-px"}),p("settings.common.actions.duplicate")]}),l&&s.jsxs(se,{onClick:D=>{D.stopPropagation(),l()},children:[s.jsx(_,{name:"restart",className:"h-4 w-4 mr-px"}),p("settings.common.actions.reset")]}),r&&s.jsxs(se,{onClick:D=>{D.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),p("settings.common.actions.delete")]})]}),e[1]=r,e[2]=c,e[3]=x,e[4]=l,e[5]=p,e[6]=u):u=e[6];const E=u,q=n?"bg-interactive-selection":"hover:bg-interactive-hover";let M;e[7]!==q?(M=je("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",q),e[7]=q,e[8]=M):M=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=N?void 0:se=>{se.preventDefault(),C(!0)},e[9]=I):I=e[9];let g;e[10]!==M?(g=s.jsx("div",{className:M,onContextMenu:I}),e[10]=M,e[11]=g):g=e[11];let j;e[12]!==a.name?(j=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=j):j=e[13];let F;e[14]!==a.mode||e[15]!==y?(F=y(a.mode),e[14]=a.mode,e[15]=y,e[16]=F):F=e[16];let S;e[17]!==a||e[18]!==L.scope||e[19]!==p?(S=(L.scope||Bn(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Bn(a)?p("settings.agents.sidebar.badge.system"):L.scope}),e[17]=a,e[18]=L.scope,e[19]=p,e[20]=S):S=e[20];let T;e[21]!==j||e[22]!==F||e[23]!==S?(T=s.jsxs("div",{className:"flex items-center gap-1.5",children:[j,F,S]}),e[21]=j,e[22]=F,e[23]=S,e[24]=T):T=e[24];let v;e[25]!==a.description?(v=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=v):v=e[26];let K;e[27]!==i||e[28]!==T||e[29]!==v?(K=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[T,v]}),e[27]=i,e[28]=T,e[29]=v,e[30]=K):K=e[30];let $;e[31]!==b?($=se=>{se&&C(!1),b(se)},e[31]=b,e[32]=$):$=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx($s,{asChild:!0,children:s.jsx(H,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=w):w=e[33];let G;e[34]!==E?(G=s.jsx(Bs,{align:"end",className:"w-fit min-w-20",children:E(Gs)}),e[34]=E,e[35]=G):G=e[35];let Q;e[36]!==m||e[37]!==$||e[38]!==G?(Q=s.jsxs(Hs,{open:m,onOpenChange:$,children:[w,G]}),e[36]=m,e[37]=$,e[38]=G,e[39]=Q):Q=e[39];let X;e[40]!==K||e[41]!==Q?(X=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[K,Q]}),e[40]=K,e[41]=Q,e[42]=X):X=e[42];let Z;e[43]!==X||e[44]!==g?(Z=s.jsx(Rn,{render:g,children:X}),e[43]=X,e[44]=g,e[45]=Z):Z=e[45];let P;e[46]!==E?(P=s.jsx(Dn,{className:"w-fit min-w-20",children:E(Mn)}),e[46]=E,e[47]=P):P=e[47];let ee;return e[48]!==h||e[49]!==Z||e[50]!==P?(ee=s.jsxs(On,{open:h,onOpenChange:C,children:[Z,P]}),e[48]=h,e[49]=Z,e[50]=P,e[51]=ee):ee=e[51],ee},rs=t=>{const e=ht.c(21),{children:a,className:n,outerClassName:i,title:r,titleLeading:l,titleAccessory:x,description:c,headerEnd:y,showSaveStatus:m}=t,b=m===void 0?!1:m,p=r!=null||c!=null||y!=null||b,L=typeof r=="string"||typeof r=="number",k=l!=null||x!=null;let N;e[0]!==i?(N=je("h-full",i),e[0]=i,e[1]=N):N=e[1];let h;e[2]!==n?(h=je("mx-auto max-w-[840px] space-y-0 px-6 py-6 @3xl:px-12 @3xl:py-8","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",n),e[2]=n,e[3]=h):h=e[3];let C;e[4]!==c||e[5]!==p||e[6]!==k||e[7]!==y||e[8]!==L||e[9]!==b||e[10]!==r||e[11]!==x||e[12]!==l?(C=p&&s.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[s.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[r!=null?L?k?s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l,s.jsx("h1",{className:je(Oi,"min-w-0 truncate"),children:r}),s.jsx("span",{className:"shrink-0",children:x})]}):s.jsx("h1",{className:Oi,children:r}):r:null,c!=null?typeof c=="string"||typeof c=="number"?s.jsx("p",{className:El,children:c}):c:null]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[y,b&&s.jsx(kd,{})]})]}),e[4]=c,e[5]=p,e[6]=k,e[7]=y,e[8]=L,e[9]=b,e[10]=r,e[11]=x,e[12]=l,e[13]=C):C=e[13];let u;e[14]!==a||e[15]!==h||e[16]!==C?(u=s.jsxs("div",{className:h,children:[C,a]}),e[14]=a,e[15]=h,e[16]=C,e[17]=u):u=e[17];let E;return e[18]!==N||e[19]!==u?(E=s.jsx(Ds,{outerClassName:N,className:"w-full @container",children:u}),e[18]=N,e[19]=u,e[20]=E):E=e[20],E},Nd=500,kd=()=>{const t=ht.c(13),{t:e}=ot(),a=o.useSyncExternalStore(Nc,xr,xr),[n,i]=o.useState(!1);let r,l;if(t[0]!==a?(r=()=>{if(a!=="saving"){i(!1);return}const m=setTimeout(()=>i(!0),Nd);return()=>clearTimeout(m)},l=[a],t[0]=a,t[1]=r,t[2]=l):(r=t[1],l=t[2]),o.useEffect(r,l),a==="error"){let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(_,{name:"error-warning",className:"size-3.5"}),t[3]=m):m=t[3];let b;t[4]!==e?(b=e("settings.common.status.saveFailed"),t[4]=e,t[5]=b):b=t[5];let p;return t[6]!==b?(p=s.jsxs("div",{"aria-live":"assertive",className:"flex shrink-0 items-center gap-1.5 typography-meta text-[var(--status-error)]",children:[m,s.jsx("span",{children:b})]}),t[6]=b,t[7]=p):p=t[7],p}if(a!=="saving"||!n)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}),t[8]=x):x=t[8];let c;t[9]!==e?(c=e("settings.common.actions.saving"),t[9]=e,t[10]=c):c=t[10];let y;return t[11]!==c?(y=s.jsxs("div",{"aria-live":"polite",className:"flex shrink-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[x,s.jsx("span",{children:c})]}),t[11]=c,t[12]=y):y=t[12],y},Sd=["allow","ask","deny"],ma=t=>t==="allow"||t==="ask"||t==="deny",Ki=()=>({global:null,keys:{}}),Cd=t=>{const e=Ki();if(t==null)return e;if(typeof t=="string")return ma(t)&&(e.global=t),e;if(typeof t!="object"||Array.isArray(t))return e;for(const[a,n]of Object.entries(t)){if(a==="*"){ma(n)&&(e.global=n);continue}const i={action:null,patterns:[]};if(ma(n))i.action=n;else if(n&&typeof n=="object"&&!Array.isArray(n))for(const[r,l]of Object.entries(n))ma(l)&&(r==="*"?i.action=l:i.patterns.push({pattern:r,action:l}));else continue;e.keys[a]=i}return e},_i=t=>{const e={};t.global!==null&&(e["*"]=t.global);for(const[a,n]of Object.entries(t.keys)){const i=n.patterns.filter(r=>r.pattern.trim().length>0);if(n.action!==null&&i.length===0)e[a]=n.action;else if(i.length>0){const r={};n.action!==null&&(r["*"]=n.action);for(const l of i)r[l.pattern]=l.action;e[a]=r}}return Object.keys(e).length>0?e:null},Id=(t,e)=>JSON.stringify(_i(t))===JSON.stringify(_i(e)),pn=t=>JSON.parse(JSON.stringify(t)),Pd=["edit","external_directory","doom_loop","plan_enter","plan_exit"],Ad=new Set(["read","edit","glob","grep","list","bash","task","external_directory","lsp","skill"]),Or=new Set(["write","patch","apply_patch","multiedit","invalid"]),Td=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),Ed=({agent:t})=>{const{t:e}=ot(),a=ja(O=>O.updateAgent),[n,i]=o.useState(Ki),[r,l]=o.useState(Ki),[x,c]=o.useState(!0),[y,m]=o.useState(!1),[b,p]=o.useState(!1),[L,k]=o.useState({}),[N,h]=o.useState([]),[C,u]=o.useState(""),[E,q]=o.useState(0),M=t.name;o.useEffect(()=>{let O=!1;return c(!0),m(!1),(async()=>{try{const U=ir(),A=U?`?directory=${encodeURIComponent(U)}`:"",V=await ct(`/api/config/agents/${encodeURIComponent(M)}/config${A}`,{headers:{"Cache-Control":"no-cache",...U?{"x-opencode-directory":U}:{}}});if(!V.ok)throw new Error(String(V.status));const W=await V.json().catch(()=>null);if(O)return;const te=Cd(W?.config?.permission);i(pn(te)),l(te)}catch{O||m(!0)}finally{O||c(!1)}})(),()=>{O=!0}},[M,E]),o.useEffect(()=>{let O=!1;return(async()=>{try{const U=await on.listToolIds({directory:ir()});!O&&Array.isArray(U)&&h(U.filter(A=>typeof A=="string"&&!Or.has(A)))}catch{}})(),()=>{O=!0}},[M]);const I=o.useMemo(()=>{const O=t.permission;if(!Array.isArray(O))return[];const U=[];for(const A of O){if(!A||typeof A!="object")continue;const{permission:V,pattern:W,action:te}=A;typeof V=="string"&&typeof W=="string"&&ma(te)&&U.push({permission:V,pattern:W,action:te})}return U},[t]),g=o.useCallback(O=>{const U=I.find(V=>V.permission===O&&V.pattern==="*");if(U)return U.action;const A=I.find(V=>V.permission==="*"&&V.pattern==="*");return A?A.action:null},[I]),j=o.useCallback(O=>{const U=r.keys[O]?.patterns??[],A=new Set(U.map(V=>V.pattern));return I.filter(V=>V.permission===O&&V.pattern!=="*"&&!A.has(V.pattern))},[I,r.keys]),F=o.useMemo(()=>{const O=new Set;for(const U of N)O.add(U);for(const U of Pd)O.add(U);for(const U of Object.keys(r.keys))O.add(U);for(const U of Or)O.delete(U);return Array.from(O).sort((U,A)=>U.localeCompare(A))},[N,r.keys]),S=o.useMemo(()=>!Id(r,n),[r,n]),T=O=>{l(U=>({...U,global:O}))},v=(O,U)=>{l(A=>{const V=pn(A),W=V.keys[O]??{action:null,patterns:[]};return W.action=U,W.action===null&&W.patterns.length===0?delete V.keys[O]:V.keys[O]=W,V})},K=(O,U,A,V)=>{l(W=>{const te=pn(W),ae=te.keys[O]??{action:null,patterns:[]};return ae.patterns[U]={pattern:A,action:V},te.keys[O]=ae,te})},$=O=>{l(U=>{const A=pn(U),V=A.keys[O]??{action:null,patterns:[]};return V.patterns.push({pattern:"",action:"allow"}),A.keys[O]=V,A}),k(U=>({...U,[O]:!0}))},w=(O,U)=>{l(A=>{const V=pn(A),W=V.keys[O];return W?(W.patterns.splice(U,1),W.action===null&&W.patterns.length===0&&delete V.keys[O],V):A})},G=()=>{const O=C.trim();!O||O==="*"||(l(U=>{if(U.keys[O])return U;const A=pn(U);return A.keys[O]={action:"ask",patterns:[]},A}),k(U=>({...U,[O]:!0})),u(""))},Q=async()=>{p(!0);try{const O=_i(r),U=await a(M,{permission:O});U.ok?(i(pn(r)),R.success(U.requiresManualRestart?e("settings.agents.page.permissionsEditor.toast.savedRestartRequired"):e("settings.agents.page.permissionsEditor.toast.saved"))):R.error(e("settings.agents.page.permissionsEditor.toast.saveFailed"))}finally{p(!1)}},X=()=>{l(pn(n))},Z=O=>e(O==="allow"?"settings.agents.page.permissionsEditor.action.allow":O==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),P=e("settings.agents.page.permissionsEditor.action.inherit"),ee=e("settings.agents.page.permissionsEditor.action.default"),se=O=>[...O?[{value:"inherit",label:O}]:[],...Sd.map(U=>({value:U,label:Z(U)}))],D=(O,U,A,V=P)=>s.jsx(Ls,{value:O??"inherit",options:se(V),onChange:W=>U(W==="inherit"?null:W),"aria-label":A});return x?s.jsx(Oe,{title:e("settings.agents.page.section.toolPermissions"),children:s.jsx("p",{className:In,children:e("common.loading")})}):y?s.jsx(Oe,{title:e("settings.agents.page.section.toolPermissions"),children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.agents.page.permissionsEditor.state.loadFailed")}),s.jsx(H,{variant:"outline",size:"xs",onClick:()=>q(O=>O+1),children:e("settings.agents.page.permissionsEditor.actions.retry")})]})}):s.jsxs(Oe,{title:e("settings.agents.page.section.toolPermissions"),settingsItem:"agents.permissions",info:e("settings.agents.page.permissionsEditor.sectionInfo"),headerAction:S?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:X,disabled:b,children:e("settings.agents.page.permissionsEditor.actions.discard")}),s.jsx(H,{size:"xs",className:"!font-normal",onClick:()=>{Q()},disabled:b,children:e(b?"settings.common.actions.saving":"settings.agents.page.permissionsEditor.actions.save")})]}):void 0,contentClassName:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Et,children:e("settings.agents.page.permissionsEditor.defaultLabel")}),s.jsx(Yt,{children:e("settings.agents.page.permissionsEditor.defaultInfo")}),r.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.agents.page.permissionsEditor.effectiveHint",{action:Z(g("*")??"allow")})})]}),D(r.global,T,e("settings.agents.page.permissionsEditor.defaultAria"),ee)]}),s.jsx("div",{children:F.map(O=>{const U=r.keys[O]??{action:null,patterns:[]},A=j(O),V=Ad.has(O)||U.patterns.length>0,W=V||A.length>0,te=L[O]===!0,ae=g(O);return s.jsxs("div",{className:"border-t border-border/40 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:W?()=>k(le=>({...le,[O]:!te})):void 0,className:je("flex min-w-0 items-center gap-1.5 text-left",!W&&"cursor-default"),"aria-expanded":W?te:void 0,children:[s.jsx(_,{name:te&&W?"arrow-down-s":"arrow-right-s",className:je("h-3.5 w-3.5 shrink-0 text-muted-foreground",!W&&"opacity-0")}),s.jsx("span",{className:Et,children:Td(O)}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:O}),U.action===null&&ae!==null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.agents.page.permissionsEditor.effectiveHint",{action:Z(ae)})}),U.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:e("settings.agents.page.permissionsEditor.ruleCount",{count:String(U.patterns.length)})})]}),D(U.action,le=>v(O,le),e("settings.agents.page.permissionsEditor.keyAria",{key:O}))]}),te&&W&&s.jsxs("div",{className:"mt-2 space-y-2 pl-5",children:[U.patterns.map((le,be)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(He,{value:le.pattern,onChange:ke=>K(O,be,ke.target.value,le.action),placeholder:e("settings.agents.page.permissionsEditor.patternPlaceholder"),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Ls,{value:le.action,options:se(),onChange:ke=>K(O,be,le.pattern,ke),"aria-label":e("settings.agents.page.permissionsEditor.patternActionAria",{key:O})}),s.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>w(O,be),"aria-label":e("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]},be)),V&&s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>$(O),children:[s.jsx(_,{name:"add",className:"mr-1 h-3.5 w-3.5"}),e("settings.agents.page.permissionsEditor.actions.addRule")]}),A.length>0&&s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"typography-micro font-medium text-muted-foreground",children:e("settings.agents.page.permissionsEditor.sessionRulesTitle")}),s.jsx(Yt,{children:e("settings.agents.page.permissionsEditor.sessionRulesInfo")})]}),A.map(le=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-micro min-w-0 flex-1 truncate font-mono text-muted-foreground/70",children:le.pattern}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:Z(le.action)})]},`${le.pattern}-${le.action}`))]})]})]},O)})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[s.jsx(He,{value:C,onChange:O=>u(O.target.value),onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),G())},placeholder:e("settings.agents.page.permissionsEditor.customKeyPlaceholder"),className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:G,disabled:!C.trim(),children:[s.jsx(_,{name:"add",className:"mr-1 h-3.5 w-3.5"}),e("settings.agents.page.permissionsEditor.actions.addKey")]})]})]})},Dd=(t,e)=>{const a=Gn(e);if(!a)return[];const i=t.find(r=>r.id===a.providerId)?.models?.find(r=>r.id===a.modelId);return i?.variants?Object.keys(i.variants):[]},Md=()=>{const{t}=ot(),e=nt(D=>D.providers),{selectedAgentName:a,getAgentByName:n,createAgent:i,updateAgent:r,agents:l,agentDraft:x,setAgentDraft:c}=ja(Ps(D=>({selectedAgentName:D.selectedAgentName,getAgentByName:D.getAgentByName,createAgent:D.createAgent,updateAgent:D.updateAgent,agents:D.agents,agentDraft:D.agentDraft,setAgentDraft:D.setAgentDraft}))),y=a?n(a):null,m=!!(x&&x.name===a&&!y),[b,p]=o.useState(""),[L,k]=o.useState("user"),[N,h]=o.useState(""),[C,u]=o.useState("subagent"),[E,q]=o.useState(""),[M,I]=o.useState(""),[g,j]=o.useState(void 0),[F,S]=o.useState(void 0),[T,v]=o.useState(""),[K,$]=o.useState(!1),w=o.useRef(null),G=o.useMemo(()=>Dd(e,E),[E,e]),Q=G.length>0,X=M||"__default",Z=Q,P=o.useMemo(()=>M&&!G.includes(M)?[M,...G]:G,[M,G]);o.useEffect(()=>{if(m&&x){const D=x.name||"",O=x.scope||"user",U=x.description||"",A=x.mode||"subagent",V=x.model||"",W=x.variant||"",te=x.temperature??void 0,ae=x.top_p??void 0,le=x.prompt||"";p(D),k(O),h(U),u(A),q(V),I(W),j(te),S(ae),v(le),w.current={draftName:D,draftScope:O,description:U,mode:A,model:V,variant:W,temperature:te,topP:ae,prompt:le};return}if(y&&a===y.name){const D=y.description||"",O=y.mode||"subagent",U=y.model?.providerID&&y.model?.modelID?`${y.model.providerID}/${y.model.modelID}`:"",A=y.variant||"",V=y.temperature??void 0,W=y.topP??void 0,te=y.prompt||"";h(D),u(O),q(U),I(A),j(V),S(W),v(te),w.current={draftName:"",draftScope:"user",description:D,mode:O,model:U,variant:A,temperature:V,topP:W,prompt:te}}},[x,m,y,a]);const ee=o.useMemo(()=>{const D=w.current;return D?!!(m&&(b!==D.draftName||L!==D.draftScope)||N!==D.description||C!==D.mode||E!==D.model||M!==D.variant||g!==D.temperature||F!==D.topP||T!==D.prompt):!1},[N,b,L,m,C,E,T,g,F,M]),se=async()=>{const D=m?b.trim().replace(/\s+/g,"-"):a?.trim();if(!D){R.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(m&&l.some(O=>O.name===D)){R.error(t("settings.agents.sidebar.toast.agentExists"));return}$(!0);try{const O=E.trim(),U=M.trim(),A=T.trim(),V={name:D,...N.trim()?{description:N.trim()}:{},mode:C,model:O===""?null:O,variant:U===""?null:U||void 0,temperature:g??null,top_p:F??null,prompt:A||(m?void 0:null),...m&&L?{scope:L}:{}};let W;m?(W=await i(V),W.ok&&c(null)):W=await r(D,V),W.ok?W.requiresManualRestart?R.warning(t("settings.agents.page.toast.savedManualRestart")):W.restartDeferred?R.success(t("settings.view.pendingRestart.saved")):R.success(t(m?"settings.agents.page.toast.created":"settings.agents.page.toast.updated")):R.error(t(m?"settings.agents.page.toast.createFailed":"settings.agents.page.toast.updateFailed"))}catch(O){console.error("Error saving agent:",O);const U=O instanceof Error&&O.message?O.message:t("settings.agents.page.toast.saveUnexpectedError");R.error(U)}finally{$(!1)}};return a?s.jsxs(rs,{title:m?t("settings.agents.page.title.new"):a,description:t(m?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),showSaveStatus:!1,children:[s.jsxs(Oe,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-0",children:[m&&s.jsxs($t,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"@"}),s.jsx(He,{value:b,onChange:D=>p(D.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Dt,{value:L,onValueChange:D=>k(D),children:[s.jsx(Mt,{size:Kt,className:"w-fit min-w-[100px]",children:s.jsx(_t,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Rt,{align:"end",children:[s.jsx(dt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(dt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Qt,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Ns,{value:N,onChange:D=>h(D.target.value),placeholder:t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Qt,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Ls,{"aria-label":t("settings.agents.page.field.mode"),value:C,onChange:u,options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})})]}),s.jsxs(Oe,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx($t,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ua,{providerId:Gn(E)?.providerId??"",modelId:Gn(E)?.modelId??"",onChange:(D,O)=>{q(D&&O?`${D}/${O}`:""),I("")},className:bn})}),s.jsx($t,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:Z?s.jsxs(Dt,{value:X,onValueChange:D=>I(D==="__default"?"":D),children:[s.jsx(Mt,{size:Kt,className:vn,children:s.jsx(_t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:D=>D==="__default"?t("chat.modelControls.default"):D})}),s.jsxs(Rt,{children:[s.jsx(dt,{value:"__default",children:t("chat.modelControls.default")}),P.map(D=>s.jsx(dt,{value:D,children:D},D))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(He,{value:M,onChange:D=>I(D.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!E&&!M,className:"h-8 w-40 rounded-md px-3"}),M&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>I(""),className:gs,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs($t,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(ys,{value:g,fallbackValue:.7,onValueChange:j,onClear:()=>j(void 0),min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),g!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>j(void 0),className:gs,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs($t,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(ys,{value:F,fallbackValue:.9,onValueChange:S,onClear:()=>S(void 0),min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),F!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>S(void 0),className:gs,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Oe,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Ns,{value:T,onChange:D=>v(D.target.value),placeholder:t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y"})}),!m&&y&&s.jsx(Ed,{agent:y}),s.jsx("div",{className:"pb-8",children:s.jsx(H,{onClick:se,disabled:K||!ee,size:"xs",className:"!font-normal",children:t(K?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})},Rd="~/.config/opencode/AGENTS.md",Jo=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},Od=t=>t.length>0&&!t.endsWith(`
1
+ import{R as o,j as s,f as ht,r as We}from"./vendor-react-BUCujlKS.js";import{f as ot,B as H,I as _,o as En,aV as Jn,t as R,O as Cl,f8 as Il,ee as Oe,f9 as Et,b as Fs,h as je,fa as Pl,aR as $s,aT as Bs,fb as Al,aU as Hs,e5 as ja,fc as Tl,fd as Bn,fe as qs,bU as Ds,bs as Ut,bt as Vt,bu as Ht,bv as Gt,bw as qt,bx as os,S as He,ff as xa,aQ as Gs,dV as Oi,fg as El,fh as ir,fi as In,eg as Yt,fj as Ls,l as nt,fk as $t,bK as Dt,bL as Mt,eq as Kt,bM as _t,bN as Rt,bO as dt,fl as Qt,bP as Ns,dj as ua,fm as bn,er as Gn,fn as vn,fo as gs,dp as ys,fp as Dl,fq as ut,fr as Ao,fs as Ml,ft as qn,fu as qa,fv as Rl,fw as Qa,fx as rn,fy as Hn,dk as To,fz as Tn,ag as Ya,af as Is,fA as rr,eH as Ol,dT as Eo,g as ga,fB as Ll,fC as Vs,dS as Fl,fD as Kl,fE as _l,fF as Wi,aX as Ji,aY as Qi,aZ as Do,fG as an,fH as sn,L as Yi,fI as or,aa as zl,bQ as Ul,cq as Vl,Q as $l,N as Bl,R as Hl,V as Mo,fJ as Gl,fK as ql,bH as Wl,bR as Li,eG as lr,P as Pn,fL as xn,ed as As,a$ as Ro,n as ss,bg as Wa,x as Jl,i as Ql,j as Yl,bA as Zl,p as Xl,fM as ec,bj as tc,bB as cr,bC as Oo,bi as sc,fN as gi,fO as dr,fP as nc,fQ as ac,fR as ic,fS as rc,dv as Za,fT as bs,fU as Os,fV as gn,fW as hn,aj as ea,fX as fn,fY as Wn,fZ as pr,f_ as ta,f$ as sa,g0 as oc,g1 as lc,g2 as cc,g3 as dc,g4 as hi,g5 as mr,g6 as pc,g7 as mc,g8 as uc,g9 as gc,ga as hc,gb as fi,gc as ur,gd as fc,cb as xc,br as gr,ge as nn,gf as xi,bq as hr,gg as Lo,gh as fr,gi as Fo,gj as bc,d_ as vc,gk as yc,ac as dn,ae as jc,gl as wc}from"./useAppFontEffects-BikB6enL.js";import{r as ct,C as ds,cr as Nc,cs as xr,t as on,al as bi,l as Ko,U as kc,K as yt,n as jn,u as de,x as is,I as br,bY as vr,b$ as yr,J as na,p as Sc,ct as Cc,j as Ic,bX as $n,cu as Pc,a4 as Ac,b_ as Tc,cv as Ec,cw as Dc,s as Mc,e as wa,bZ as Rc,y as Na,cx as _o,R as Oc,cy as Lc,Q as Fc,aB as jr,at as Kc,Y as yn,cz as _c,q as zo,cA as wr,cq as Nr,cB as kr,ar as Sr,cC as zc,cD as Uc,cE as Cr,b as Vc,ap as Uo,cF as Vo,cG as $c,cH as Bc,cI as Hc,cJ as Gc,cK as qc,cL as Wc,af as Jc,i as $o}from"./index-DRpChWux.js";import{u as Qc,U as Ir,w as Dn,y as Mn,z as Rn,A as On,b as Zi,q as ba,s as va,v as ya,J as An,F as Yc,h as ws,p as Zc,H as Xc,K as pa,Q as Bo,B as ed,E as td}from"./runtimeEndpointReset-BVmispdD.js";import{u as Ps,c as Ho,d as sd,p as nd}from"./vendor-zustand-BAGL70zf.js";import{s as ad,p as id}from"./vendor-yaml-3778uTud.js";import{c as Pr,s as rd,C as Ar,P as od}from"./shikiHighlight-C7LTbwFx.js";import{getResolvedShikiTheme as ld}from"./appThemeRegistry-BK0dHKa6.js";import{E as Tr}from"./vendor-codemirror-view-DSzLbZiS.js";import{Q as Go}from"./vendor-qrcode-DTJ12-WC.js";import{f as cd,s as dd}from"./contextPanelEmbeddedChat-B-bSg3P5.js";const Er=()=>{const{t}=ot(),[e,a]=o.useState(null);o.useEffect(()=>{let i=!1;const r=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const x=await ct("/api/system/info",{signal:r?.signal,headers:{Accept:"application/json"}});if(!x.ok)return;const c=await x.json().catch(()=>null);if(!c||i)return;const y=typeof c.port=="number"&&Number.isFinite(c.port)&&c.port>0?c.port:null,m=typeof c.tunnelUrl=="string"&&c.tunnelUrl.trim().length>0?c.tunnelUrl.trim():null;a({port:y,tunnelUrl:m})}catch{}})(),()=>{i=!0,r?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(i=>s.jsxs(H,{type:"button",variant:"outline",size:"sm",title:i.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{En(i.url)},children:[s.jsx(_,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:i.url})]},i.key))})},Dr="https://github.com/openchamber/openchamber",pd="https://discord.gg/ZYRSdnwwKA",Mr="https://x.com/openchamber_dev",md=800,qo=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=ot(),[a,n]=o.useState(t),[i,r]=o.useState(!1),[l,x]=o.useState(null),[c,y]=o.useState(null),m=Qc(Ps(N=>({info:N.info,checking:N.checking,available:N.available,error:N.error,downloading:N.downloading,downloaded:N.downloaded,progress:N.progress,runtimeType:N.runtimeType,checkForUpdates:N.checkForUpdates,downloadUpdate:N.downloadUpdate,restartToUpdate:N.restartToUpdate}))),{isMobile:b}=Jn(),p=l||m.info?.currentVersion||"unknown";o.useEffect(()=>{let N=!1;return(async()=>{try{const C=await ct("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!C.ok)return;const u=await C.json().catch(()=>null),E=typeof u?.openchamberVersion=="string"&&u.openchamberVersion.trim().length>0?u.openchamberVersion.trim():null;N||x(E)}catch{N||x(null)}})(),()=>{N=!0}},[]),o.useEffect(()=>{let N=!1;return(async()=>{try{const C=await ct("/api/opencode/upgrade-status",{method:"GET",headers:{Accept:"application/json"}});if(!C.ok)return;const u=await C.json().catch(()=>null),E=typeof u?.currentVersion=="string"&&u.currentVersion.trim().length>0?u.currentVersion.trim():null;N||y(E)}catch{N||y(null)}})(),()=>{N=!0}},[]);const L=o.useRef(!1);o.useEffect(()=>{if(m.checking)r(!0),L.current=!0;else if(i){const N=setTimeout(()=>{r(!1),L.current&&!m.available&&!m.error&&(R.success(e("settings.openchamber.about.toast.latestVersion")),L.current=!1)},md);return()=>clearTimeout(N)}},[e,m.checking,i,m.available,m.error]);const k=m.checking||i;return b?s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(Cl,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${Il}`,children:"OpenChamber"}),s.jsxs("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:p})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:c||e("settings.openchamber.about.state.unknown")})})]}),s.jsx(Er,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!m.available&&!m.error&&s.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:()=>m.checkForUpdates(),disabled:k,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[k?s.jsx(_,{name:"loader",className:"size-4 animate-spin"}):s.jsx(_,{name:"refresh",className:"size-4"}),e(k?"settings.openchamber.about.state.checking":"settings.openchamber.about.actions.checkForUpdates")]}),!k&&m.available&&s.jsxs(H,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[s.jsx(_,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]})]}),m.error&&s.jsx("p",{className:"rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:m.error}),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:Dr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:pd,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Mr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(Ir,{open:a,onOpenChange:n,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]}):s.jsxs(Oe,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Et,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:p})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Et,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:c||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[m.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(_,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!m.checking&&m.available&&s.jsxs(H,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx(_,{name:"download",className:"h-4 w-4 mr-1"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]}),!m.checking&&!m.available&&!m.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(H,{size:"sm",variant:"outline",onClick:()=>m.checkForUpdates(),disabled:m.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),m.error&&s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:m.error})}),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Et,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(Er,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:Dr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(_,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Mr,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(_,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(Ir,{open:a,onOpenChange:n,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]})},Wo=t=>t.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),ka=t=>{const e=ht.c(39),{className:a}=t,{t:n}=ot(),i=Fs(ud),r=Fs(gd),l=Fs(hd),x=ds();let c;e[0]!==i?(c=[...i].sort(fd),e[0]=i,e[1]=c):c=e[1];const y=c;let m;e:{if(y.length===0){m=null;break e}let $;e[2]!==r||e[3]!==y?($=y.find(w=>w.id===r)??y[0],e[2]=r,e[3]=y,e[4]=$):$=e[4],m=$}const b=m;if(x||y.length===0)return null;let p;e[5]!==b||e[6]!==n?(p=b?.label&&b.label.trim().length>0?b.label:b?.path.split("/").filter(Boolean).pop()||b?.path||n("settings.shared.projectSelector.fallbackProject"),e[5]=b,e[6]=n,e[7]=p):p=e[7];const L=p;let k;e[8]!==L?(k=Wo(L),e[8]=L,e[9]=k):k=e[9];const N=k;let h;e[10]!==a?(h=je(a),e[10]=a,e[11]=h):h=e[11];let C;e[12]!==n?(C=n("settings.shared.projectSelector.switchProjectAria"),e[12]=n,e[13]=C):C=e[13];let u;e[14]!==n?(u=n("settings.shared.projectSelector.switchProjectTitle"),e[14]=n,e[15]=u):u=e[15];let E,q;e[16]===Symbol.for("react.memo_cache_sentinel")?(E=je("text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none","hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70","flex items-center gap-1.5 text-left"),q=s.jsx(_,{name:"folder",className:"h-4 w-4 opacity-70"}),e[16]=E,e[17]=q):(E=e[16],q=e[17]);let M;e[18]!==N?(M=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:N}),e[18]=N,e[19]=M):M=e[19];let I;e[20]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(_,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[20]=I):I=e[20];let g;e[21]!==M||e[22]!==C||e[23]!==u?(g=s.jsx($s,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":C,title:u,className:E,children:[q,M,I]})}),e[21]=M,e[22]=C,e[23]=u,e[24]=g):g=e[24];const j=b?.id??"";let F;e[25]!==l?(F=$=>{$&&l($)},e[25]=l,e[26]=F):F=e[26];let S;e[27]!==y?(S=y.map(xd),e[27]=y,e[28]=S):S=e[28];let T;e[29]!==j||e[30]!==F||e[31]!==S?(T=s.jsx(Bs,{align:"start",className:"w-auto",children:s.jsx(Al,{value:j,onValueChange:F,children:S})}),e[29]=j,e[30]=F,e[31]=S,e[32]=T):T=e[32];let v;e[33]!==g||e[34]!==T?(v=s.jsxs(Hs,{children:[g,T]}),e[33]=g,e[34]=T,e[35]=v):v=e[35];let K;return e[36]!==v||e[37]!==h?(K=s.jsx("div",{className:h,children:v}),e[36]=v,e[37]=h,e[38]=K):K=e[38],K};function ud(t){return t.projects}function gd(t){return t.activeProjectId}function hd(t){return t.setActiveProject}function fd(t,e){return(t.label||t.path).localeCompare(e.label||e.path)}function xd(t){const e=t.label?.trim()?t.label.trim():t.path.split("/").filter(Boolean).pop()||t.path,a=Wo(e);return s.jsx(Pl,{value:t.id,children:s.jsx("span",{className:"min-w-0 truncate typography-ui",children:a})},t.id)}function bd(t,e){return`opencode:sidebar-group:${t}:${e}`}const Fi=t=>{const e=ht.c(33),{label:a,count:n,storageKey:i,defaultExpanded:r,children:l}=t,x=r===void 0?!0:r;let c;e[0]!==a||e[1]!==i?(c=bd(i,a),e[0]=a,e[1]=i,e[2]=c):c=e[2];const y=c,m=o.useId();let b;e[3]!==x||e[4]!==y?(b=()=>{try{const T=localStorage.getItem(y);if(T!==null)return T==="true"}catch{}return x},e[3]=x,e[4]=y,e[5]=b):b=e[5];const[p,L]=We.useState(b);let k,N;e[6]!==p||e[7]!==y?(k=()=>{try{localStorage.setItem(y,String(p))}catch{}},N=[y,p],e[6]=p,e[7]=y,e[8]=k,e[9]=N):(k=e[8],N=e[9]),We.useEffect(k,N);let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>L(vd),e[10]=h):h=e[10];let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=je("flex w-full items-center gap-1 rounded-md px-2 py-1 text-left","text-xs font-semibold uppercase tracking-wide text-muted-foreground","hover:bg-[var(--interactive-hover)] transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"),e[11]=C):C=e[11];const u=!p&&"-rotate-90";let E;e[12]!==u?(E=je("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",u),e[12]=u,e[13]=E):E=e[13];let q;e[14]!==E?(q=s.jsx(_,{name:"arrow-down-s",className:E}),e[14]=E,e[15]=q):q=e[15];let M;e[16]!==a?(M=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=M):M=e[17];let I;e[18]!==n?(I=s.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=I):I=e[19];let g;e[20]!==m||e[21]!==p||e[22]!==q||e[23]!==M||e[24]!==I?(g=s.jsxs("button",{type:"button",onClick:h,"aria-expanded":p,"aria-controls":m,className:C,children:[q,M,I]}),e[20]=m,e[21]=p,e[22]=q,e[23]=M,e[24]=I,e[25]=g):g=e[25];const j=!p;let F;e[26]!==l||e[27]!==m||e[28]!==j?(F=s.jsx("div",{id:m,hidden:j,className:"mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]",children:l}),e[26]=l,e[27]=m,e[28]=j,e[29]=F):F=e[29];let S;return e[30]!==g||e[31]!==F?(S=s.jsxs("div",{children:[g,F]}),e[30]=g,e[31]=F,e[32]=S):S=e[32],S};function vd(t){return!t}const yd=t=>{if(!Array.isArray(t))return[];const e=[];for(const a of t){if(!a||typeof a!="object")continue;const n=a;typeof n.permission!="string"||typeof n.pattern!="string"||typeof n.action!="string"||n.action!=="allow"&&n.action!=="ask"&&n.action!=="deny"||e.push({permission:n.permission,pattern:n.pattern,action:n.action})}return e},jd=t=>{const e=new Map;for(const a of t)!a.permission||a.permission==="invalid"||a.pattern&&e.set(`${a.permission}::${a.pattern}`,a);return Array.from(e.values())},Rr=t=>{const e=jd(yd(t));if(e.length===0)return;const a={};for(const i of e)i.permission&&((a[i.permission]||={})[i.pattern]=i.action);const n={};for(const[i,r]of Object.entries(a)){const l=Object.keys(r);if(l.length===1&&l[0]==="*"){n[i]=r["*"];continue}n[i]=r}return Object.keys(n).length>0?n:void 0},wd=({onItemSelect:t})=>{const{t:e}=ot(),[a,n]=o.useState(null),[i,r]=o.useState(""),[l,x]=o.useState(null),[c,y]=o.useState(null),[m,b]=o.useState(!1),[p,L]=o.useState(null),{selectedAgentName:k,agents:N,setSelectedAgent:h,setAgentDraft:C,createAgent:u,deleteAgent:E,loadAgents:q}=ja(Ps(P=>({selectedAgentName:P.selectedAgentName,agents:P.agents,setSelectedAgent:P.setSelectedAgent,setAgentDraft:P.setAgentDraft,createAgent:P.createAgent,deleteAgent:P.deleteAgent,loadAgents:P.loadAgents})));o.useEffect(()=>{q()},[q]);const M="bg-background",I=()=>{const P="new-agent";let ee=P,se=1;for(;N.some(D=>D.name===ee);)ee=`${P}-${se}`,se++;C({name:ee,scope:"user"}),h(ee),t?.()},g=async P=>{if(Bn(P)){R.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}x(P),y("delete")},j=async P=>{Bn(P)&&(x(P),y("reset"))},F=()=>{x(null),y(null)},S=async()=>{if(!(!l||!c)){b(!0);try{const P=await E(l.name,l.scope);P.ok?(P.requiresManualRestart?R.warning(e("settings.agents.page.toast.savedManualRestart")):P.restartDeferred?R.success(e("settings.view.pendingRestart.saved")):c==="delete"?R.success(e("settings.agents.sidebar.toast.agentDeleted",{name:l.name})):R.success(e("settings.agents.sidebar.toast.agentReset",{name:l.name})),F()):c==="delete"?R.error(e("settings.agents.sidebar.toast.deleteFailed")):R.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(P){const ee=P instanceof Error?P.message:"",se=/built-in|not deletable|not found/i.test(ee);c==="delete"?R.error(e(se?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):R.error(e("settings.agents.sidebar.toast.resetFailed"))}b(!1)}},T=P=>{const ee=P.name;let se=1,D=`${ee}-copy`;for(;N.some(V=>V.name===D);)se++,D=`${ee}-copy-${se}`;const O=P,U=P.model?.providerID&&P.model?.modelID?`${P.model.providerID}/${P.model.modelID}`:null,A=P;C({name:D,scope:O.scope||"user",description:P.description,model:U,variant:P.variant,temperature:P.temperature,top_p:P.topP,prompt:P.prompt,mode:P.mode,permission:Rr(P.permission),disable:A.disable}),h(D)},v=P=>{r(P.name),n(P)},K=async()=>{if(!a)return;const P=i.trim().replace(/\s+/g,"-");if(!P){R.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(P===a.name){n(null);return}if(N.some(O=>O.name===P)){R.error(e("settings.agents.sidebar.toast.agentExists"));return}const ee=a.model?.providerID&&a.model?.modelID?`${a.model.providerID}/${a.model.modelID}`:null,se=a,D=await u({name:P,description:a.description,model:ee,variant:a.variant,temperature:a.temperature,top_p:a.topP,prompt:a.prompt,mode:a.mode,permission:Rr(a.permission),disable:se.disable,scope:se.scope});if(D.ok){const O=await E(a.name,se.scope);O.ok?(D.requiresManualRestart||O.requiresManualRestart?R.warning(e("settings.agents.page.toast.savedManualRestart")):R.success(e("settings.agents.sidebar.toast.agentRenamed",{name:P})),h(P)):R.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed"))}else R.error(e("settings.agents.sidebar.toast.renameFailed"));n(null)},$=P=>{switch(P){case"primary":return s.jsx(_,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(_,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(_,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},w=N.filter(P=>!Tl(P)),G=w.filter(Bn),Q=w.filter(P=>!Bn(P)),{groupedCustomAgents:X,ungroupedCustomAgents:Z}=We.useMemo(()=>{const P={},ee=[];for(const D of Q){const O=D;O.group?(P[O.group]||(P[O.group]=[]),P[O.group].push(D)):ee.push(D)}return{groupedCustomAgents:Object.keys(P).sort((D,O)=>D.localeCompare(O)).map(D=>({name:D,agents:P[D]})),ungroupedCustomAgents:ee}},[Q]);return s.jsxs("div",{className:je("flex h-full flex-col",M),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${qs} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(ka,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:w.length})}),s.jsx(H,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:I,children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:w.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[G.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),G.map(P=>s.jsx(vi,{agent:P,isSelected:k===P.name,onSelect:()=>{h(P.name),t?.()},onReset:()=>j(P),onDuplicate:()=>T(P),getAgentModeIcon:$,isMenuOpen:p===P.name,onMenuOpenChange:ee=>L(ee?P.name:null)},P.name))]}),Q.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),X.map(({name:P,agents:ee})=>s.jsx(Fi,{label:P,count:ee.length,storageKey:"agents",children:ee.map(se=>s.jsx(vi,{agent:se,isSelected:k===se.name,onSelect:()=>{h(se.name),t?.()},onRename:()=>v(se),onDelete:()=>g(se),onDuplicate:()=>T(se),getAgentModeIcon:$,isMenuOpen:p===se.name,onMenuOpenChange:D=>L(D?se.name:null)},se.name))},P)),Z.map(P=>s.jsx(vi,{agent:P,isSelected:k===P.name,onSelect:()=>{h(P.name),t?.()},onRename:()=>v(P),onDelete:()=>g(P),onDuplicate:()=>T(P),getAgentModeIcon:$,isMenuOpen:p===P.name,onMenuOpenChange:ee=>L(ee?P.name:null)},P.name))]})]})}),s.jsx(Ut,{open:l!==null&&c!==null,onOpenChange:P=>{!P&&!m&&F()},children:s.jsxs(Vt,{className:"max-w-md",children:[s.jsxs(Ht,{children:[s.jsx(Gt,{children:e(c==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),s.jsx(qt,{children:c==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:l?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:l?.name??""})})]}),s.jsxs(os,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:F,disabled:m,children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:S,disabled:m,children:e(c==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),s.jsx(Ut,{open:a!==null,onOpenChange:P=>!P&&n(null),children:s.jsxs(Vt,{children:[s.jsxs(Ht,{children:[s.jsx(Gt,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(qt,{children:e("settings.agents.sidebar.renameDialog.description",{name:a?.name??""})})]}),s.jsx(He,{value:i,onChange:P=>r(P.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:P=>{P.key==="Enter"&&K()}}),s.jsxs(os,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>n(null),children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:K,children:e("settings.common.actions.rename")})]})]})})]})},vi=t=>{const e=ht.c(52),{agent:a,isSelected:n,onSelect:i,onDelete:r,onReset:l,onRename:x,onDuplicate:c,getAgentModeIcon:y,isMenuOpen:m,onMenuOpenChange:b}=t,{t:p}=ot(),L=a;let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=xa(),e[0]=k):k=e[0];const N=k,[h,C]=o.useState(!1);let u;e[1]!==r||e[2]!==c||e[3]!==x||e[4]!==l||e[5]!==p?(u=se=>s.jsxs(s.Fragment,{children:[x&&s.jsxs(se,{onClick:D=>{D.stopPropagation(),x()},children:[s.jsx(_,{name:"edit",className:"h-4 w-4 mr-px"}),p("settings.common.actions.rename")]}),s.jsxs(se,{onClick:D=>{D.stopPropagation(),c()},children:[s.jsx(_,{name:"file-copy",className:"h-4 w-4 mr-px"}),p("settings.common.actions.duplicate")]}),l&&s.jsxs(se,{onClick:D=>{D.stopPropagation(),l()},children:[s.jsx(_,{name:"restart",className:"h-4 w-4 mr-px"}),p("settings.common.actions.reset")]}),r&&s.jsxs(se,{onClick:D=>{D.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),p("settings.common.actions.delete")]})]}),e[1]=r,e[2]=c,e[3]=x,e[4]=l,e[5]=p,e[6]=u):u=e[6];const E=u,q=n?"bg-interactive-selection":"hover:bg-interactive-hover";let M;e[7]!==q?(M=je("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",q),e[7]=q,e[8]=M):M=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=N?void 0:se=>{se.preventDefault(),C(!0)},e[9]=I):I=e[9];let g;e[10]!==M?(g=s.jsx("div",{className:M,onContextMenu:I}),e[10]=M,e[11]=g):g=e[11];let j;e[12]!==a.name?(j=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=j):j=e[13];let F;e[14]!==a.mode||e[15]!==y?(F=y(a.mode),e[14]=a.mode,e[15]=y,e[16]=F):F=e[16];let S;e[17]!==a||e[18]!==L.scope||e[19]!==p?(S=(L.scope||Bn(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Bn(a)?p("settings.agents.sidebar.badge.system"):L.scope}),e[17]=a,e[18]=L.scope,e[19]=p,e[20]=S):S=e[20];let T;e[21]!==j||e[22]!==F||e[23]!==S?(T=s.jsxs("div",{className:"flex items-center gap-1.5",children:[j,F,S]}),e[21]=j,e[22]=F,e[23]=S,e[24]=T):T=e[24];let v;e[25]!==a.description?(v=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=v):v=e[26];let K;e[27]!==i||e[28]!==T||e[29]!==v?(K=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[T,v]}),e[27]=i,e[28]=T,e[29]=v,e[30]=K):K=e[30];let $;e[31]!==b?($=se=>{se&&C(!1),b(se)},e[31]=b,e[32]=$):$=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx($s,{asChild:!0,children:s.jsx(H,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=w):w=e[33];let G;e[34]!==E?(G=s.jsx(Bs,{align:"end",className:"w-fit min-w-20",children:E(Gs)}),e[34]=E,e[35]=G):G=e[35];let Q;e[36]!==m||e[37]!==$||e[38]!==G?(Q=s.jsxs(Hs,{open:m,onOpenChange:$,children:[w,G]}),e[36]=m,e[37]=$,e[38]=G,e[39]=Q):Q=e[39];let X;e[40]!==K||e[41]!==Q?(X=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[K,Q]}),e[40]=K,e[41]=Q,e[42]=X):X=e[42];let Z;e[43]!==X||e[44]!==g?(Z=s.jsx(Rn,{render:g,children:X}),e[43]=X,e[44]=g,e[45]=Z):Z=e[45];let P;e[46]!==E?(P=s.jsx(Dn,{className:"w-fit min-w-20",children:E(Mn)}),e[46]=E,e[47]=P):P=e[47];let ee;return e[48]!==h||e[49]!==Z||e[50]!==P?(ee=s.jsxs(On,{open:h,onOpenChange:C,children:[Z,P]}),e[48]=h,e[49]=Z,e[50]=P,e[51]=ee):ee=e[51],ee},rs=t=>{const e=ht.c(21),{children:a,className:n,outerClassName:i,title:r,titleLeading:l,titleAccessory:x,description:c,headerEnd:y,showSaveStatus:m}=t,b=m===void 0?!1:m,p=r!=null||c!=null||y!=null||b,L=typeof r=="string"||typeof r=="number",k=l!=null||x!=null;let N;e[0]!==i?(N=je("h-full",i),e[0]=i,e[1]=N):N=e[1];let h;e[2]!==n?(h=je("mx-auto max-w-[840px] space-y-0 px-6 py-6 @3xl:px-12 @3xl:py-8","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",n),e[2]=n,e[3]=h):h=e[3];let C;e[4]!==c||e[5]!==p||e[6]!==k||e[7]!==y||e[8]!==L||e[9]!==b||e[10]!==r||e[11]!==x||e[12]!==l?(C=p&&s.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[s.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[r!=null?L?k?s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l,s.jsx("h1",{className:je(Oi,"min-w-0 truncate"),children:r}),s.jsx("span",{className:"shrink-0",children:x})]}):s.jsx("h1",{className:Oi,children:r}):r:null,c!=null?typeof c=="string"||typeof c=="number"?s.jsx("p",{className:El,children:c}):c:null]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[y,b&&s.jsx(kd,{})]})]}),e[4]=c,e[5]=p,e[6]=k,e[7]=y,e[8]=L,e[9]=b,e[10]=r,e[11]=x,e[12]=l,e[13]=C):C=e[13];let u;e[14]!==a||e[15]!==h||e[16]!==C?(u=s.jsxs("div",{className:h,children:[C,a]}),e[14]=a,e[15]=h,e[16]=C,e[17]=u):u=e[17];let E;return e[18]!==N||e[19]!==u?(E=s.jsx(Ds,{outerClassName:N,className:"w-full @container",children:u}),e[18]=N,e[19]=u,e[20]=E):E=e[20],E},Nd=500,kd=()=>{const t=ht.c(13),{t:e}=ot(),a=o.useSyncExternalStore(Nc,xr,xr),[n,i]=o.useState(!1);let r,l;if(t[0]!==a?(r=()=>{if(a!=="saving"){i(!1);return}const m=setTimeout(()=>i(!0),Nd);return()=>clearTimeout(m)},l=[a],t[0]=a,t[1]=r,t[2]=l):(r=t[1],l=t[2]),o.useEffect(r,l),a==="error"){let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(_,{name:"error-warning",className:"size-3.5"}),t[3]=m):m=t[3];let b;t[4]!==e?(b=e("settings.common.status.saveFailed"),t[4]=e,t[5]=b):b=t[5];let p;return t[6]!==b?(p=s.jsxs("div",{"aria-live":"assertive",className:"flex shrink-0 items-center gap-1.5 typography-meta text-[var(--status-error)]",children:[m,s.jsx("span",{children:b})]}),t[6]=b,t[7]=p):p=t[7],p}if(a!=="saving"||!n)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}),t[8]=x):x=t[8];let c;t[9]!==e?(c=e("settings.common.actions.saving"),t[9]=e,t[10]=c):c=t[10];let y;return t[11]!==c?(y=s.jsxs("div",{"aria-live":"polite",className:"flex shrink-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[x,s.jsx("span",{children:c})]}),t[11]=c,t[12]=y):y=t[12],y},Sd=["allow","ask","deny"],ma=t=>t==="allow"||t==="ask"||t==="deny",Ki=()=>({global:null,keys:{}}),Cd=t=>{const e=Ki();if(t==null)return e;if(typeof t=="string")return ma(t)&&(e.global=t),e;if(typeof t!="object"||Array.isArray(t))return e;for(const[a,n]of Object.entries(t)){if(a==="*"){ma(n)&&(e.global=n);continue}const i={action:null,patterns:[]};if(ma(n))i.action=n;else if(n&&typeof n=="object"&&!Array.isArray(n))for(const[r,l]of Object.entries(n))ma(l)&&(r==="*"?i.action=l:i.patterns.push({pattern:r,action:l}));else continue;e.keys[a]=i}return e},_i=t=>{const e={};t.global!==null&&(e["*"]=t.global);for(const[a,n]of Object.entries(t.keys)){const i=n.patterns.filter(r=>r.pattern.trim().length>0);if(n.action!==null&&i.length===0)e[a]=n.action;else if(i.length>0){const r={};n.action!==null&&(r["*"]=n.action);for(const l of i)r[l.pattern]=l.action;e[a]=r}}return Object.keys(e).length>0?e:null},Id=(t,e)=>JSON.stringify(_i(t))===JSON.stringify(_i(e)),pn=t=>JSON.parse(JSON.stringify(t)),Pd=["edit","external_directory","doom_loop","plan_enter","plan_exit"],Ad=new Set(["read","edit","glob","grep","list","bash","task","external_directory","lsp","skill"]),Or=new Set(["write","patch","apply_patch","multiedit","invalid"]),Td=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),Ed=({agent:t})=>{const{t:e}=ot(),a=ja(O=>O.updateAgent),[n,i]=o.useState(Ki),[r,l]=o.useState(Ki),[x,c]=o.useState(!0),[y,m]=o.useState(!1),[b,p]=o.useState(!1),[L,k]=o.useState({}),[N,h]=o.useState([]),[C,u]=o.useState(""),[E,q]=o.useState(0),M=t.name;o.useEffect(()=>{let O=!1;return c(!0),m(!1),(async()=>{try{const U=ir(),A=U?`?directory=${encodeURIComponent(U)}`:"",V=await ct(`/api/config/agents/${encodeURIComponent(M)}/config${A}`,{headers:{"Cache-Control":"no-cache",...U?{"x-opencode-directory":U}:{}}});if(!V.ok)throw new Error(String(V.status));const W=await V.json().catch(()=>null);if(O)return;const te=Cd(W?.config?.permission);i(pn(te)),l(te)}catch{O||m(!0)}finally{O||c(!1)}})(),()=>{O=!0}},[M,E]),o.useEffect(()=>{let O=!1;return(async()=>{try{const U=await on.listToolIds({directory:ir()});!O&&Array.isArray(U)&&h(U.filter(A=>typeof A=="string"&&!Or.has(A)))}catch{}})(),()=>{O=!0}},[M]);const I=o.useMemo(()=>{const O=t.permission;if(!Array.isArray(O))return[];const U=[];for(const A of O){if(!A||typeof A!="object")continue;const{permission:V,pattern:W,action:te}=A;typeof V=="string"&&typeof W=="string"&&ma(te)&&U.push({permission:V,pattern:W,action:te})}return U},[t]),g=o.useCallback(O=>{const U=I.find(V=>V.permission===O&&V.pattern==="*");if(U)return U.action;const A=I.find(V=>V.permission==="*"&&V.pattern==="*");return A?A.action:null},[I]),j=o.useCallback(O=>{const U=r.keys[O]?.patterns??[],A=new Set(U.map(V=>V.pattern));return I.filter(V=>V.permission===O&&V.pattern!=="*"&&!A.has(V.pattern))},[I,r.keys]),F=o.useMemo(()=>{const O=new Set;for(const U of N)O.add(U);for(const U of Pd)O.add(U);for(const U of Object.keys(r.keys))O.add(U);for(const U of Or)O.delete(U);return Array.from(O).sort((U,A)=>U.localeCompare(A))},[N,r.keys]),S=o.useMemo(()=>!Id(r,n),[r,n]),T=O=>{l(U=>({...U,global:O}))},v=(O,U)=>{l(A=>{const V=pn(A),W=V.keys[O]??{action:null,patterns:[]};return W.action=U,W.action===null&&W.patterns.length===0?delete V.keys[O]:V.keys[O]=W,V})},K=(O,U,A,V)=>{l(W=>{const te=pn(W),ae=te.keys[O]??{action:null,patterns:[]};return ae.patterns[U]={pattern:A,action:V},te.keys[O]=ae,te})},$=O=>{l(U=>{const A=pn(U),V=A.keys[O]??{action:null,patterns:[]};return V.patterns.push({pattern:"",action:"allow"}),A.keys[O]=V,A}),k(U=>({...U,[O]:!0}))},w=(O,U)=>{l(A=>{const V=pn(A),W=V.keys[O];return W?(W.patterns.splice(U,1),W.action===null&&W.patterns.length===0&&delete V.keys[O],V):A})},G=()=>{const O=C.trim();!O||O==="*"||(l(U=>{if(U.keys[O])return U;const A=pn(U);return A.keys[O]={action:"ask",patterns:[]},A}),k(U=>({...U,[O]:!0})),u(""))},Q=async()=>{p(!0);try{const O=_i(r),U=await a(M,{permission:O});U.ok?(i(pn(r)),R.success(U.requiresManualRestart?e("settings.agents.page.permissionsEditor.toast.savedRestartRequired"):e("settings.agents.page.permissionsEditor.toast.saved"))):R.error(e("settings.agents.page.permissionsEditor.toast.saveFailed"))}finally{p(!1)}},X=()=>{l(pn(n))},Z=O=>e(O==="allow"?"settings.agents.page.permissionsEditor.action.allow":O==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),P=e("settings.agents.page.permissionsEditor.action.inherit"),ee=e("settings.agents.page.permissionsEditor.action.default"),se=O=>[...O?[{value:"inherit",label:O}]:[],...Sd.map(U=>({value:U,label:Z(U)}))],D=(O,U,A,V=P)=>s.jsx(Ls,{value:O??"inherit",options:se(V),onChange:W=>U(W==="inherit"?null:W),"aria-label":A});return x?s.jsx(Oe,{title:e("settings.agents.page.section.toolPermissions"),children:s.jsx("p",{className:In,children:e("common.loading")})}):y?s.jsx(Oe,{title:e("settings.agents.page.section.toolPermissions"),children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.agents.page.permissionsEditor.state.loadFailed")}),s.jsx(H,{variant:"outline",size:"xs",onClick:()=>q(O=>O+1),children:e("settings.agents.page.permissionsEditor.actions.retry")})]})}):s.jsxs(Oe,{title:e("settings.agents.page.section.toolPermissions"),settingsItem:"agents.permissions",info:e("settings.agents.page.permissionsEditor.sectionInfo"),headerAction:S?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:X,disabled:b,children:e("settings.agents.page.permissionsEditor.actions.discard")}),s.jsx(H,{size:"xs",className:"!font-normal",onClick:()=>{Q()},disabled:b,children:e(b?"settings.common.actions.saving":"settings.agents.page.permissionsEditor.actions.save")})]}):void 0,contentClassName:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Et,children:e("settings.agents.page.permissionsEditor.defaultLabel")}),s.jsx(Yt,{children:e("settings.agents.page.permissionsEditor.defaultInfo")}),r.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.agents.page.permissionsEditor.effectiveHint",{action:Z(g("*")??"allow")})})]}),D(r.global,T,e("settings.agents.page.permissionsEditor.defaultAria"),ee)]}),s.jsx("div",{children:F.map(O=>{const U=r.keys[O]??{action:null,patterns:[]},A=j(O),V=Ad.has(O)||U.patterns.length>0,W=V||A.length>0,te=L[O]===!0,ae=g(O);return s.jsxs("div",{className:"border-t border-border/40 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:W?()=>k(le=>({...le,[O]:!te})):void 0,className:je("flex min-w-0 items-center gap-1.5 text-left",!W&&"cursor-default"),"aria-expanded":W?te:void 0,children:[s.jsx(_,{name:te&&W?"arrow-down-s":"arrow-right-s",className:je("h-3.5 w-3.5 shrink-0 text-muted-foreground",!W&&"opacity-0")}),s.jsx("span",{className:Et,children:Td(O)}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:O}),U.action===null&&ae!==null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.agents.page.permissionsEditor.effectiveHint",{action:Z(ae)})}),U.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:e("settings.agents.page.permissionsEditor.ruleCount",{count:String(U.patterns.length)})})]}),D(U.action,le=>v(O,le),e("settings.agents.page.permissionsEditor.keyAria",{key:O}))]}),te&&W&&s.jsxs("div",{className:"mt-2 space-y-2 pl-5",children:[U.patterns.map((le,be)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(He,{value:le.pattern,onChange:ke=>K(O,be,ke.target.value,le.action),placeholder:e("settings.agents.page.permissionsEditor.patternPlaceholder"),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Ls,{value:le.action,options:se(),onChange:ke=>K(O,be,le.pattern,ke),"aria-label":e("settings.agents.page.permissionsEditor.patternActionAria",{key:O})}),s.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>w(O,be),"aria-label":e("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]},be)),V&&s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>$(O),children:[s.jsx(_,{name:"add",className:"mr-1 h-3.5 w-3.5"}),e("settings.agents.page.permissionsEditor.actions.addRule")]}),A.length>0&&s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"typography-micro font-medium text-muted-foreground",children:e("settings.agents.page.permissionsEditor.sessionRulesTitle")}),s.jsx(Yt,{children:e("settings.agents.page.permissionsEditor.sessionRulesInfo")})]}),A.map(le=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-micro min-w-0 flex-1 truncate font-mono text-muted-foreground/70",children:le.pattern}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:Z(le.action)})]},`${le.pattern}-${le.action}`))]})]})]},O)})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[s.jsx(He,{value:C,onChange:O=>u(O.target.value),onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),G())},placeholder:e("settings.agents.page.permissionsEditor.customKeyPlaceholder"),className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:G,disabled:!C.trim(),children:[s.jsx(_,{name:"add",className:"mr-1 h-3.5 w-3.5"}),e("settings.agents.page.permissionsEditor.actions.addKey")]})]})]})},Dd=(t,e)=>{const a=Gn(e);if(!a)return[];const i=t.find(r=>r.id===a.providerId)?.models?.find(r=>r.id===a.modelId);return i?.variants?Object.keys(i.variants):[]},Md=()=>{const{t}=ot(),e=nt(D=>D.providers),{selectedAgentName:a,getAgentByName:n,createAgent:i,updateAgent:r,agents:l,agentDraft:x,setAgentDraft:c}=ja(Ps(D=>({selectedAgentName:D.selectedAgentName,getAgentByName:D.getAgentByName,createAgent:D.createAgent,updateAgent:D.updateAgent,agents:D.agents,agentDraft:D.agentDraft,setAgentDraft:D.setAgentDraft}))),y=a?n(a):null,m=!!(x&&x.name===a&&!y),[b,p]=o.useState(""),[L,k]=o.useState("user"),[N,h]=o.useState(""),[C,u]=o.useState("subagent"),[E,q]=o.useState(""),[M,I]=o.useState(""),[g,j]=o.useState(void 0),[F,S]=o.useState(void 0),[T,v]=o.useState(""),[K,$]=o.useState(!1),w=o.useRef(null),G=o.useMemo(()=>Dd(e,E),[E,e]),Q=G.length>0,X=M||"__default",Z=Q,P=o.useMemo(()=>M&&!G.includes(M)?[M,...G]:G,[M,G]);o.useEffect(()=>{if(m&&x){const D=x.name||"",O=x.scope||"user",U=x.description||"",A=x.mode||"subagent",V=x.model||"",W=x.variant||"",te=x.temperature??void 0,ae=x.top_p??void 0,le=x.prompt||"";p(D),k(O),h(U),u(A),q(V),I(W),j(te),S(ae),v(le),w.current={draftName:D,draftScope:O,description:U,mode:A,model:V,variant:W,temperature:te,topP:ae,prompt:le};return}if(y&&a===y.name){const D=y.description||"",O=y.mode||"subagent",U=y.model?.providerID&&y.model?.modelID?`${y.model.providerID}/${y.model.modelID}`:"",A=y.variant||"",V=y.temperature??void 0,W=y.topP??void 0,te=y.prompt||"";h(D),u(O),q(U),I(A),j(V),S(W),v(te),w.current={draftName:"",draftScope:"user",description:D,mode:O,model:U,variant:A,temperature:V,topP:W,prompt:te}}},[x,m,y,a]);const ee=o.useMemo(()=>{const D=w.current;return D?!!(m&&(b!==D.draftName||L!==D.draftScope)||N!==D.description||C!==D.mode||E!==D.model||M!==D.variant||g!==D.temperature||F!==D.topP||T!==D.prompt):!1},[N,b,L,m,C,E,T,g,F,M]),se=async()=>{const D=m?b.trim().replace(/\s+/g,"-"):a?.trim();if(!D){R.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(m&&l.some(O=>O.name===D)){R.error(t("settings.agents.sidebar.toast.agentExists"));return}$(!0);try{const O=E.trim(),U=M.trim(),A=T.trim(),V={name:D,...N.trim()?{description:N.trim()}:{},mode:C,model:O===""?null:O,variant:U===""?null:U||void 0,temperature:g??null,top_p:F??null,prompt:A||(m?void 0:null),...m&&L?{scope:L}:{}};let W;m?(W=await i(V),W.ok&&c(null)):W=await r(D,V),W.ok?W.requiresManualRestart?R.warning(t("settings.agents.page.toast.savedManualRestart")):W.restartDeferred?R.success(t("settings.view.pendingRestart.saved")):R.success(t(m?"settings.agents.page.toast.created":"settings.agents.page.toast.updated")):R.error(t(m?"settings.agents.page.toast.createFailed":"settings.agents.page.toast.updateFailed"))}catch(O){console.error("Error saving agent:",O);const U=O instanceof Error&&O.message?O.message:t("settings.agents.page.toast.saveUnexpectedError");R.error(U)}finally{$(!1)}};return a?s.jsxs(rs,{title:m?t("settings.agents.page.title.new"):a,description:t(m?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),showSaveStatus:!1,children:[s.jsxs(Oe,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-0",children:[m&&s.jsxs($t,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"@"}),s.jsx(He,{value:b,onChange:D=>p(D.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Dt,{value:L,onValueChange:D=>k(D),children:[s.jsx(Mt,{size:Kt,className:"w-fit min-w-[100px]",children:s.jsx(_t,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Rt,{align:"end",children:[s.jsx(dt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(dt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Qt,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Ns,{value:N,onChange:D=>h(D.target.value),placeholder:t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Qt,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Ls,{"aria-label":t("settings.agents.page.field.mode"),value:C,onChange:u,options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})})]}),s.jsxs(Oe,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx($t,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ua,{providerId:Gn(E)?.providerId??"",modelId:Gn(E)?.modelId??"",onChange:(D,O)=>{q(D&&O?`${D}/${O}`:""),I("")},className:bn})}),s.jsx($t,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:Z?s.jsxs(Dt,{value:X,onValueChange:D=>I(D==="__default"?"":D),children:[s.jsx(Mt,{size:Kt,className:vn,children:s.jsx(_t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:D=>D==="__default"?t("chat.modelControls.default"):D})}),s.jsxs(Rt,{children:[s.jsx(dt,{value:"__default",children:t("chat.modelControls.default")}),P.map(D=>s.jsx(dt,{value:D,children:D},D))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(He,{value:M,onChange:D=>I(D.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!E&&!M,className:"h-8 w-40 rounded-md px-3"}),M&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>I(""),className:gs,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs($t,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(ys,{value:g,fallbackValue:.7,onValueChange:j,onClear:()=>j(void 0),min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),g!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>j(void 0),className:gs,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs($t,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(ys,{value:F,fallbackValue:.9,onValueChange:S,onClear:()=>S(void 0),min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),F!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>S(void 0),className:gs,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Oe,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Ns,{value:T,onChange:D=>v(D.target.value),placeholder:t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y"})}),!m&&y&&s.jsx(Ed,{agent:y}),s.jsx("div",{className:"pb-8",children:s.jsx(H,{onClick:se,disabled:K||!ee,size:"xs",className:"!font-normal",children:t(K?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})},Rd="~/.config/opencode/AGENTS.md",Jo=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},Od=t=>t.length>0&&!t.endsWith(`
2
2
  `)?`${t}
3
3
  `:t,Oa={prompt:"",optimizeSystemPrompt:!1,responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},Ld=(t,e)=>t==="custom"?e:Rl(t),Fd=t=>t==="custom"?"custom":Ao(t)?t:"concise",Lr={concise:"settings.behavior.page.responseStyle.option.concise",detailed:"settings.behavior.page.responseStyle.option.detailed",mentor:"settings.behavior.page.responseStyle.option.mentor",pushback:"settings.behavior.page.responseStyle.option.pushback",noFiller:"settings.behavior.page.responseStyle.option.noFiller",matchEnergy:"settings.behavior.page.responseStyle.option.matchEnergy",warmPeer:"settings.behavior.page.responseStyle.option.warmPeer"},yi=async(t,e)=>{bi("saving");try{const a=await ct("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(await Jo(a,e));bi("saved")}catch(a){throw bi("error"),a}},Kd=()=>{const{t}=ot(),e=Dl(),[a,n]=o.useState(""),[i,r]=o.useState(!1),[l,x]=o.useState(Oa.responseStyleEnabled),[c,y]=o.useState(Oa.responseStylePreset),[m,b]=o.useState(Oa.responseStyleCustomInstructions),[p,L]=o.useState(!0),[k,N]=o.useState(!1),[h,C]=o.useState(!1),[u,E]=o.useState(""),[q,M]=o.useState(!1),I=o.useRef(null);o.useEffect(()=>{const v=new AbortController;return(async()=>{try{const[$,w]=await Promise.all([ct("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},signal:v.signal}),ct("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:v.signal})]);let G=Oa;if($.ok){const Q=await $.json();G={...G,optimizeSystemPrompt:Q.optimizeSystemPrompt===!0,responseStyleEnabled:Q.responseStyleEnabled===!0,responseStylePreset:Fd(Q.responseStylePreset),responseStyleCustomInstructions:typeof Q.responseStyleCustomInstructions=="string"?Q.responseStyleCustomInstructions:""},typeof Q.globalBehaviorPrompt=="string"&&(G={...G,prompt:Q.globalBehaviorPrompt})}if(!G.prompt.trim()&&w.ok){const Q=await w.json();typeof Q.content=="string"&&(G={...G,prompt:Q.content})}n(G.prompt),r(G.optimizeSystemPrompt),M(G.optimizeSystemPrompt),x(G.responseStyleEnabled),y(G.responseStylePreset),b(G.responseStyleCustomInstructions),E(G.prompt),I.current={enabled:G.responseStyleEnabled,preset:G.responseStylePreset,custom:G.responseStyleCustomInstructions}}catch($){$.name!=="AbortError"&&console.warn("Failed to load behavior settings:",$)}finally{L(!1)}})(),()=>v.abort()},[]),o.useEffect(()=>{if(p)return;const v=I.current;if(v&&v.enabled===l&&v.preset===c&&v.custom===m)return;const K={enabled:l,preset:c,custom:m},$=setTimeout(async()=>{try{await yi({responseStyleEnabled:K.enabled,responseStylePreset:K.preset,responseStyleCustomInstructions:K.custom},t("settings.behavior.page.toast.saveFailed")),I.current=K}catch(w){const G=w instanceof Error?w.message:t("settings.behavior.page.toast.saveFailed");R.error(G)}},400);return()=>clearTimeout($)},[l,c,m,p,t]);const g=Ld(c,m),j=a!==u,F=i!==q,S=async()=>{N(!0);try{const v=Od(a),K=await ct("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:v})});if(!K.ok)throw new Error(await Jo(K,t("settings.behavior.page.toast.saveFailed")));const $=await K.json().catch(()=>null),w=qa($,"behavior",{id:"agents-md"});await yi({globalBehaviorPrompt:v},t("settings.behavior.page.toast.saveFailed")),n(v),E(v),R.success(t(w?"settings.view.pendingRestart.saved":"settings.behavior.page.toast.saved"))}catch(v){console.error("Failed to save behavior:",v);const K=v instanceof Error?v.message:t("settings.behavior.page.toast.saveFailed");R.error(K)}finally{N(!1)}},T=async()=>{C(!0);try{await yi({optimizeSystemPrompt:i},t("settings.behavior.page.toast.saveFailed")),M(i),qn("behavior",{id:"optimize-system-prompt"}),R.success(t("settings.view.pendingRestart.saved"))}catch(v){const K=v instanceof Error?v.message:t("settings.behavior.page.toast.saveFailed");R.error(K)}finally{C(!1)}};return s.jsxs(rs,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),showSaveStatus:!0,children:[!e&&s.jsxs(Oe,{title:t("settings.behavior.page.section.systemPromptOptimization"),divider:!1,settingsItem:"behavior.system-prompt-optimization",contentClassName:"space-y-3",children:[s.jsx(ut,{checked:i,onChange:r,disabled:p||h,label:t("settings.behavior.page.systemPromptOptimization.enable"),ariaLabel:t("settings.behavior.page.systemPromptOptimization.enableAria"),info:t("settings.behavior.page.systemPromptOptimization.info")}),s.jsx(H,{type:"button",size:"xs",onClick:()=>{T()},disabled:p||h||!F,className:"!font-normal",children:t(h?"settings.common.actions.saving":"settings.common.actions.saveChanges")})]}),s.jsxs(Oe,{title:t("settings.behavior.page.section.systemPrompt"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"font-medium text-foreground",children:t("settings.behavior.page.warning.title")}),s.jsx("p",{children:t("settings.behavior.page.warning.description",{path:Rd})})]}),settingsItem:"behavior.system-prompt",contentClassName:"space-y-3",children:[s.jsx(Ns,{value:a,onChange:v=>n(v.target.value),placeholder:t("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:p,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"}),s.jsx(H,{onClick:S,disabled:k||!j||p,size:"xs",className:"!font-normal",children:t(k?"settings.common.actions.saving":"settings.common.actions.saveChanges")})]}),s.jsxs(Oe,{title:t("settings.behavior.page.section.responseStyle"),info:t("settings.behavior.page.responseStyle.tooltip"),settingsItem:"behavior.response-style",contentClassName:"space-y-3",children:[s.jsx(ut,{checked:l,onChange:x,disabled:p,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx($t,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Dt,{value:c,onValueChange:v=>y(v),disabled:p||!l,children:[s.jsx(Mt,{size:Kt,className:vn,children:s.jsx(_t,{children:v=>v==="custom"?t("settings.behavior.page.responseStyle.option.custom"):Ao(v)?t(Lr[v]):null})}),s.jsxs(Rt,{children:[Ml.map(v=>s.jsx(dt,{value:v,children:t(Lr[v])},v)),s.jsx(dt,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(Ns,{value:g,onChange:v=>b(v.target.value),placeholder:t("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:p||!l||c!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})},_d=t=>{const e=ht.c(169),{onItemSelect:a}=t,{t:n}=ot(),[i,r]=o.useState(null),[l,x]=o.useState(""),[c,y]=o.useState(null),[m,b]=o.useState(null),[p,L]=o.useState(!1),[k,N]=o.useState(null),{selectedCommandName:h,commands:C,setSelectedCommand:u,setCommandDraft:E,createCommand:q,deleteCommand:M,loadCommands:I}=Qa(Ps(zd)),g=rn(Ud),j=rn(Vd);let F,S;e[0]!==I||e[1]!==j?(F=()=>{I(),j()},S=[I,j],e[0]=I,e[1]=j,e[2]=F,e[3]=S):(F=e[2],S=e[3]),o.useEffect(F,S);let T;e[4]!==g?(T=new Set(g.map($d)),e[4]=g,e[5]=T):T=e[5];const v=T;let K;if(e[6]!==C||e[7]!==v){let ie;e[9]!==v?(ie=Ae=>!v.has(Ae.name),e[9]=v,e[10]=ie):ie=e[10],K=C.filter(ie),e[6]=C,e[7]=v,e[8]=K}else K=e[8];const $=K;let w,G;e[11]!==h||e[12]!==u||e[13]!==v?(w=()=>{h&&v.has(h)&&u(null)},G=[h,u,v],e[11]=h,e[12]=u,e[13]=v,e[14]=w,e[15]=G):(w=e[14],G=e[15]),o.useEffect(w,G);let Q;e[16]!==C||e[17]!==a||e[18]!==E||e[19]!==u?(Q=()=>{let ie="new-command",Ae=1;for(;C.some(Be=>Be.name===ie);)ie=`new-command-${Ae}`,Ae++;E({name:ie,scope:"user"}),u(ie),a?.()},e[16]=C,e[17]=a,e[18]=E,e[19]=u,e[20]=Q):Q=e[20];const X=Q;let Z;e[21]!==n?(Z=async ie=>{if(Hn(ie)){R.error(n("settings.commands.sidebar.toast.builtInCannotDelete"));return}y(ie),b("delete")},e[21]=n,e[22]=Z):Z=e[22];const P=Z;let ee;e[23]===Symbol.for("react.memo_cache_sentinel")?(ee=async ie=>{Hn(ie)&&(y(ie),b("reset"))},e[23]=ee):ee=e[23];const se=ee;let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{y(null),b(null)},e[24]=D):D=e[24];const O=D;let U;e[25]!==c||e[26]!==m||e[27]!==M||e[28]!==n?(U=async()=>{if(!c||!m)return;L(!0),await M(c.name)?(m==="delete"?R.success(n("settings.commands.sidebar.toast.commandDeleted",{name:c.name})):R.success(n("settings.commands.sidebar.toast.commandReset",{name:c.name})),O()):m==="delete"?R.error(n("settings.commands.sidebar.toast.deleteFailed")):R.error(n("settings.commands.sidebar.toast.resetFailed")),L(!1)},e[25]=c,e[26]=m,e[27]=M,e[28]=n,e[29]=U):U=e[29];const A=U;let V;e[30]!==C||e[31]!==E||e[32]!==u?(V=ie=>{const Ae=ie.name;let Be=1,qe=`${Ae}-copy`;for(;C.some(Nt=>Nt.name===qe);)Be++,qe=`${Ae}-copy-${Be}`;E({name:qe,scope:ie.scope||"user",description:ie.description,template:ie.template,agent:ie.agent,model:ie.model}),u(qe)},e[30]=C,e[31]=E,e[32]=u,e[33]=V):V=e[33];const W=V;let te;e[34]===Symbol.for("react.memo_cache_sentinel")?(te=ie=>{x(ie.name),r(ie)},e[34]=te):te=e[34];const ae=te;let le;e[35]!==C||e[36]!==q||e[37]!==M||e[38]!==i||e[39]!==l||e[40]!==u||e[41]!==n?(le=async()=>{if(!i)return;const ie=l.trim().replace(/\s+/g,"-");if(!ie){R.error(n("settings.commands.sidebar.toast.commandNameRequired"));return}if(ie===i.name){r(null);return}if(C.some(Be=>Be.name===ie)){R.error(n("settings.commands.sidebar.toast.commandExists"));return}await q({name:ie,description:i.description,template:i.template,agent:i.agent,model:i.model})?await M(i.name)?(R.success(`Command renamed to "${ie}"`),u(ie)):R.error(n("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):R.error(n("settings.commands.sidebar.toast.renameFailed")),r(null)},e[35]=C,e[36]=q,e[37]=M,e[38]=i,e[39]=l,e[40]=u,e[41]=n,e[42]=le):le=e[42];const be=le;let ke,ce,ge,Ee,Se,Ne;if(e[43]!==$||e[44]!==X||e[45]!==P||e[46]!==W||e[47]!==a||e[48]!==k||e[49]!==h||e[50]!==u||e[51]!==n){const ie=$.filter(Hn),Ae=$.filter(Bd);e[58]===Symbol.for("react.memo_cache_sentinel")?(Se=je("flex h-full flex-col","bg-background"),e[58]=Se):Se=e[58];let Be;e[59]!==n?(Be=n("settings.commands.sidebar.title"),e[59]=n,e[60]=Be):Be=e[60];let qe;e[61]!==Be?(qe=s.jsx("h2",{className:`${qs} mb-3`,children:Be}),e[61]=Be,e[62]=qe):qe=e[62];let Nt;e[63]===Symbol.for("react.memo_cache_sentinel")?(Nt=s.jsx(ka,{className:"mb-3"}),e[63]=Nt):Nt=e[63];let xt;e[64]!==$.length||e[65]!==n?(xt=n("settings.commands.sidebar.total",{count:$.length}),e[64]=$.length,e[65]=n,e[66]=xt):xt=e[66];let zt;e[67]!==xt?(zt=s.jsx("span",{className:"typography-meta text-muted-foreground",children:xt}),e[67]=xt,e[68]=zt):zt=e[68];let J;e[69]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),e[69]=J):J=e[69];let xe;e[70]!==X?(xe=s.jsx(H,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:X,children:J}),e[70]=X,e[71]=xe):xe=e[71];let Re;e[72]!==zt||e[73]!==xe?(Re=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[zt,xe]}),e[72]=zt,e[73]=xe,e[74]=Re):Re=e[74],e[75]!==qe||e[76]!==Re?(Ne=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[qe,Nt,Re]}),e[75]=qe,e[76]=Re,e[77]=Ne):Ne=e[77],ke=Ds,ce="flex-1 min-h-0",ge="space-y-1 px-3 py-2",Ee=$.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.commands.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.commands.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[ie.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.builtIn")}),[...ie].sort(Hd).map(we=>s.jsx(Fr,{command:we,isSelected:h===we.name,onSelect:()=>{u(we.name),a?.()},onReset:()=>se(we),onDuplicate:()=>W(we),isMenuOpen:k===we.name,onMenuOpenChange:rt=>N(rt?we.name:null)},we.name))]}),Ae.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.custom")}),[...Ae].sort(Gd).map(we=>s.jsx(Fr,{command:we,isSelected:h===we.name,onSelect:()=>{u(we.name),a?.()},onRename:()=>ae(we),onDelete:()=>P(we),onDuplicate:()=>W(we),isMenuOpen:k===we.name,onMenuOpenChange:rt=>N(rt?we.name:null)},we.name))]})]}),e[43]=$,e[44]=X,e[45]=P,e[46]=W,e[47]=a,e[48]=k,e[49]=h,e[50]=u,e[51]=n,e[52]=ke,e[53]=ce,e[54]=ge,e[55]=Ee,e[56]=Se,e[57]=Ne}else ke=e[52],ce=e[53],ge=e[54],Ee=e[55],Se=e[56],Ne=e[57];let fe;e[78]!==ke||e[79]!==ce||e[80]!==ge||e[81]!==Ee?(fe=s.jsx(ke,{outerClassName:ce,className:ge,children:Ee}),e[78]=ke,e[79]=ce,e[80]=ge,e[81]=Ee,e[82]=fe):fe=e[82];const Ke=c!==null&&m!==null;let De;e[83]!==p?(De=ie=>{!ie&&!p&&O()},e[83]=p,e[84]=De):De=e[84];let he;e[85]!==m||e[86]!==n?(he=n(m==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[85]=m,e[86]=n,e[87]=he):he=e[87];let pe;e[88]!==he?(pe=s.jsx(Gt,{children:he}),e[88]=he,e[89]=pe):pe=e[89];let Ie;e[90]!==c?.name||e[91]!==m||e[92]!==n?(Ie=m==="delete"?n("settings.commands.sidebar.dialog.deleteDescription",{name:c?.name??""}):n("settings.commands.sidebar.dialog.resetDescription",{name:c?.name??""}),e[90]=c?.name,e[91]=m,e[92]=n,e[93]=Ie):Ie=e[93];let ze;e[94]!==Ie?(ze=s.jsx(qt,{children:Ie}),e[94]=Ie,e[95]=ze):ze=e[95];let Je;e[96]!==pe||e[97]!==ze?(Je=s.jsxs(Ht,{children:[pe,ze]}),e[96]=pe,e[97]=ze,e[98]=Je):Je=e[98];let _e;e[99]!==n?(_e=n("settings.common.actions.cancel"),e[99]=n,e[100]=_e):_e=e[100];let Le;e[101]!==p||e[102]!==_e?(Le=s.jsx(H,{size:"sm",variant:"ghost",onClick:O,disabled:p,children:_e}),e[101]=p,e[102]=_e,e[103]=Le):Le=e[103];let Pe;e[104]!==m||e[105]!==n?(Pe=n(m==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[104]=m,e[105]=n,e[106]=Pe):Pe=e[106];let Ye;e[107]!==A||e[108]!==p||e[109]!==Pe?(Ye=s.jsx(H,{size:"sm",onClick:A,disabled:p,children:Pe}),e[107]=A,e[108]=p,e[109]=Pe,e[110]=Ye):Ye=e[110];let Ge;e[111]!==Le||e[112]!==Ye?(Ge=s.jsxs(os,{children:[Le,Ye]}),e[111]=Le,e[112]=Ye,e[113]=Ge):Ge=e[113];let Me;e[114]!==Je||e[115]!==Ge?(Me=s.jsxs(Vt,{className:"max-w-md",children:[Je,Ge]}),e[114]=Je,e[115]=Ge,e[116]=Me):Me=e[116];let $e;e[117]!==Ke||e[118]!==De||e[119]!==Me?($e=s.jsx(Ut,{open:Ke,onOpenChange:De,children:Me}),e[117]=Ke,e[118]=De,e[119]=Me,e[120]=$e):$e=e[120];const Fe=i!==null;let ye;e[121]===Symbol.for("react.memo_cache_sentinel")?(ye=ie=>!ie&&r(null),e[121]=ye):ye=e[121];let z;e[122]!==n?(z=n("settings.commands.sidebar.renameDialog.title"),e[122]=n,e[123]=z):z=e[123];let oe;e[124]!==z?(oe=s.jsx(Gt,{children:z}),e[124]=z,e[125]=oe):oe=e[125];const me=i?.name??"";let ve;e[126]!==n||e[127]!==me?(ve=n("settings.commands.sidebar.renameDialog.description",{name:me}),e[126]=n,e[127]=me,e[128]=ve):ve=e[128];let re;e[129]!==ve?(re=s.jsx(qt,{children:ve}),e[129]=ve,e[130]=re):re=e[130];let Ve;e[131]!==oe||e[132]!==re?(Ve=s.jsxs(Ht,{children:[oe,re]}),e[131]=oe,e[132]=re,e[133]=Ve):Ve=e[133];let Ze;e[134]===Symbol.for("react.memo_cache_sentinel")?(Ze=ie=>x(ie.target.value),e[134]=Ze):Ze=e[134];let B;e[135]!==n?(B=n("settings.commands.sidebar.renameDialog.placeholder"),e[135]=n,e[136]=B):B=e[136];let Ue;e[137]!==be?(Ue=ie=>{ie.key==="Enter"&&be()},e[137]=be,e[138]=Ue):Ue=e[138];let Qe;e[139]!==l||e[140]!==B||e[141]!==Ue?(Qe=s.jsx(He,{value:l,onChange:Ze,placeholder:B,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:Ue}),e[139]=l,e[140]=B,e[141]=Ue,e[142]=Qe):Qe=e[142];let et;e[143]===Symbol.for("react.memo_cache_sentinel")?(et=()=>r(null),e[143]=et):et=e[143];let tt;e[144]!==n?(tt=n("settings.common.actions.cancel"),e[144]=n,e[145]=tt):tt=e[145];let wt;e[146]!==tt?(wt=s.jsx(H,{size:"sm",variant:"ghost",onClick:et,children:tt}),e[146]=tt,e[147]=wt):wt=e[147];let mt;e[148]!==n?(mt=n("settings.common.actions.rename"),e[148]=n,e[149]=mt):mt=e[149];let pt;e[150]!==be||e[151]!==mt?(pt=s.jsx(H,{size:"sm",onClick:be,children:mt}),e[150]=be,e[151]=mt,e[152]=pt):pt=e[152];let at;e[153]!==wt||e[154]!==pt?(at=s.jsxs(os,{children:[wt,pt]}),e[153]=wt,e[154]=pt,e[155]=at):at=e[155];let ft;e[156]!==Ve||e[157]!==Qe||e[158]!==at?(ft=s.jsxs(Vt,{children:[Ve,Qe,at]}),e[156]=Ve,e[157]=Qe,e[158]=at,e[159]=ft):ft=e[159];let gt;e[160]!==Fe||e[161]!==ft?(gt=s.jsx(Ut,{open:Fe,onOpenChange:ye,children:ft}),e[160]=Fe,e[161]=ft,e[162]=gt):gt=e[162];let Ct;return e[163]!==Se||e[164]!==Ne||e[165]!==fe||e[166]!==$e||e[167]!==gt?(Ct=s.jsxs("div",{className:Se,children:[Ne,fe,$e,gt]}),e[163]=Se,e[164]=Ne,e[165]=fe,e[166]=$e,e[167]=gt,e[168]=Ct):Ct=e[168],Ct},Fr=t=>{const e=ht.c(47),{command:a,isSelected:n,onSelect:i,onDelete:r,onReset:l,onRename:x,onDuplicate:c,isMenuOpen:y,onMenuOpenChange:m}=t,{t:b}=ot();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=xa(),e[0]=p):p=e[0];const L=p,[k,N]=o.useState(!1);let h;e[1]!==r||e[2]!==c||e[3]!==x||e[4]!==l||e[5]!==b?(h=Z=>s.jsxs(s.Fragment,{children:[x&&s.jsxs(Z,{onClick:P=>{P.stopPropagation(),x()},children:[s.jsx(_,{name:"edit",className:"h-4 w-4 mr-px"}),b("settings.common.actions.rename")]}),s.jsxs(Z,{onClick:P=>{P.stopPropagation(),c()},children:[s.jsx(_,{name:"file-copy",className:"h-4 w-4 mr-px"}),b("settings.common.actions.duplicate")]}),l&&s.jsxs(Z,{onClick:P=>{P.stopPropagation(),l()},children:[s.jsx(_,{name:"restart",className:"h-4 w-4 mr-px"}),b("settings.common.actions.reset")]}),r&&s.jsxs(Z,{onClick:P=>{P.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),b("settings.common.actions.delete")]})]}),e[1]=r,e[2]=c,e[3]=x,e[4]=l,e[5]=b,e[6]=h):h=e[6];const C=h,u=n?"bg-interactive-selection":"hover:bg-interactive-hover";let E;e[7]!==u?(E=je("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",u),e[7]=u,e[8]=E):E=e[8];let q;e[9]===Symbol.for("react.memo_cache_sentinel")?(q=L?void 0:Z=>{Z.preventDefault(),N(!0)},e[9]=q):q=e[9];let M;e[10]!==E?(M=s.jsx("div",{className:E,onContextMenu:q}),e[10]=E,e[11]=M):M=e[11];let I;e[12]!==a.name?(I=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",a.name]}),e[12]=a.name,e[13]=I):I=e[13];let g;e[14]!==a||e[15]!==b?(g=(a.scope||Hn(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Hn(a)?b("settings.agents.sidebar.badge.system"):a.scope}),e[14]=a,e[15]=b,e[16]=g):g=e[16];let j;e[17]!==I||e[18]!==g?(j=s.jsxs("div",{className:"flex items-center gap-2",children:[I,g]}),e[17]=I,e[18]=g,e[19]=j):j=e[19];let F;e[20]!==a.description?(F=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[20]=a.description,e[21]=F):F=e[21];let S;e[22]!==i||e[23]!==F||e[24]!==j?(S=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[j,F]}),e[22]=i,e[23]=F,e[24]=j,e[25]=S):S=e[25];let T;e[26]!==m?(T=Z=>{Z&&N(!1),m(Z)},e[26]=m,e[27]=T):T=e[27];let v;e[28]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx($s,{asChild:!0,children:s.jsx(H,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=v):v=e[28];let K;e[29]!==C?(K=s.jsx(Bs,{align:"end",className:"w-fit min-w-20",children:C(Gs)}),e[29]=C,e[30]=K):K=e[30];let $;e[31]!==y||e[32]!==T||e[33]!==K?($=s.jsxs(Hs,{open:y,onOpenChange:T,children:[v,K]}),e[31]=y,e[32]=T,e[33]=K,e[34]=$):$=e[34];let w;e[35]!==S||e[36]!==$?(w=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[S,$]}),e[35]=S,e[36]=$,e[37]=w):w=e[37];let G;e[38]!==w||e[39]!==M?(G=s.jsx(Rn,{render:M,children:w}),e[38]=w,e[39]=M,e[40]=G):G=e[40];let Q;e[41]!==C?(Q=s.jsx(Dn,{className:"w-fit min-w-20",children:C(Mn)}),e[41]=C,e[42]=Q):Q=e[42];let X;return e[43]!==k||e[44]!==G||e[45]!==Q?(X=s.jsxs(On,{open:k,onOpenChange:N,children:[G,Q]}),e[43]=k,e[44]=G,e[45]=Q,e[46]=X):X=e[46],X};function zd(t){return{selectedCommandName:t.selectedCommandName,commands:t.commands,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function Ud(t){return t.skills}function Vd(t){return t.loadSkills}function $d(t){return t.name}function Bd(t){return!Hn(t)}function Hd(t,e){return t.name.localeCompare(e.name)}function Gd(t,e){return t.name.localeCompare(e.name)}const qd=()=>{const{t}=ot(),{selectedCommandName:e,getCommandByName:a,createCommand:n,updateCommand:i,commands:r,commandDraft:l,setCommandDraft:x}=Qa(Ps(T=>({selectedCommandName:T.selectedCommandName,getCommandByName:T.getCommandByName,createCommand:T.createCommand,updateCommand:T.updateCommand,commands:T.commands,commandDraft:T.commandDraft,setCommandDraft:T.setCommandDraft}))),c=e?a(e):null,y=!!(l&&l.name===e&&!c),[m,b]=o.useState(""),[p,L]=o.useState("user"),[k,N]=o.useState(""),[h,C]=o.useState(""),[u,E]=o.useState(""),[q,M]=o.useState(""),[I,g]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{if(y&&l){const T=l.name||"",v=l.scope||"user",K=l.description||"",$=l.agent||"",w=l.model||"",G=l.template||"";b(T),L(v),N(K),C($),E(w),M(G),j.current={draftName:T,draftScope:v,description:K,agent:$,model:w,template:G}}else if(c){const T=c.description||"",v=c.agent||"",K=c.model||"",$=c.template||"";N(T),C(v),E(K),M($),j.current={draftName:"",draftScope:"user",description:T,agent:v,model:K,template:$}}},[c,y,e,r,l]);const F=o.useMemo(()=>{const T=j.current;return T?!!(y&&(m!==T.draftName||p!==T.draftScope)||k!==T.description||h!==T.agent||u!==T.model||q!==T.template):!1},[h,k,m,p,y,u,q]),S=async()=>{const T=y?m.trim().replace(/\s+/g,"-"):e?.trim();if(!T){R.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!q.trim()){R.error(t("settings.commands.page.toast.templateRequired"));return}if(y&&r.some(v=>v.name===T)){R.error(t("settings.commands.sidebar.toast.commandExists"));return}g(!0);try{const v=h.trim(),K=u.trim(),$=q.trim(),w={name:T,description:k.trim()||void 0,agent:v===""?null:v,model:K===""?null:K,template:$,scope:y?p:void 0};let G;if(y?(G=await n(w),G&&x(null)):G=await i(T,w),G){const Q=Tn.getState().changes.some(X=>X.scope==="commands"&&X.id.startsWith(`commands:${T}:`));R.success(t(Q?"settings.view.pendingRestart.saved":y?"settings.commands.page.toast.created":"settings.commands.page.toast.updated"))}else R.error(t(y?"settings.commands.page.toast.createFailed":"settings.commands.page.toast.updateFailed"))}catch(v){console.error("Error saving command:",v),R.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{g(!1)}};return e?s.jsxs(rs,{title:y?t("settings.commands.page.title.new"):`/${e}`,description:t(y?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),showSaveStatus:!1,children:[s.jsxs(Oe,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[y&&s.jsxs($t,{settingsItem:"commands.name",label:t("settings.commands.page.field.commandName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"/"}),s.jsx(He,{value:m,onChange:T=>b(T.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Dt,{value:p,onValueChange:T=>L(T),children:[s.jsx(Mt,{size:Kt,className:"w-fit min-w-[100px]",children:s.jsx(_t,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Rt,{align:"end",children:[s.jsx(dt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(dt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsxs("div",{className:"py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.common.field.description")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(Ns,{value:k,onChange:T=>N(T.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(Oe,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx($t,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(To,{agentName:h,onChange:T=>C(T),className:bn})}),s.jsx($t,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ua,{providerId:Gn(u)?.providerId??"",modelId:Gn(u)?.modelId??"",onChange:(T,v)=>{E(T&&v?`${T}/${v}`:"")},className:bn})})]}),s.jsxs(Oe,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(Ns,{value:q,onChange:T=>M(T.target.value),placeholder:t("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y"}),s.jsxs("p",{className:"mt-2 typography-meta text-muted-foreground",children:[s.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",t("settings.commands.page.templateHint.userInput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",t("settings.commands.page.templateHint.shellOutput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"@file"})," ",t("settings.commands.page.templateHint.fileContents")]}),s.jsx("div",{className:"pt-3",children:s.jsx(H,{onClick:S,disabled:I||!F,size:"xs",className:"!font-normal",children:t(I?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.commands.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.commands.page.empty.description")})]})})},Kr=t=>{switch(t){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"idle"}},_r=t=>{const e=ht.c(5),{tone:a,enabled:n}=t;if(!n){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0"}),e[0]=l):l=e[0],l}let i;e[1]!==a?(i=je("inline-block h-2 w-2 rounded-full flex-shrink-0",{success:"bg-[var(--status-success)]",error:"bg-[var(--status-error)]",warning:"bg-[var(--status-warning)]",idle:"bg-muted-foreground/40"}[a]),e[1]=a,e[2]=i):i=e[2];let r;return e[3]!==i?(r=s.jsx("span",{className:i}),e[3]=i,e[4]=r):r=e[4],r},Wd=t=>{const e=ht.c(120),{onItemSelect:a}=t,{t:n}=ot(),{mcpServers:i,selectedMcpName:r,setSelectedMcp:l,setMcpDraft:x,loadMcpConfigs:c,deleteMcp:y}=Ya(Ps(Jd)),m=Ko(Qd);let b;e[0]!==m?(b=re=>re.getStatusForDirectory(m??null),e[0]=m,e[1]=b):b=e[1];const p=Is(b),L=Is(Yd),k=Is(Zd),[N,h]=o.useState(null),[C,u]=o.useState(!1),[E,q]=o.useState(null),[M,I]=o.useState(null),[g,j]=o.useState(!1);let F;e[2]!==i?(F=i.filter(Xd),e[2]=i,e[3]=F):F=e[3];const S=F;let T;e[4]!==i?(T=i.filter(ep),e[4]=i,e[5]=T):T=e[5];const v=T;let K,$;e[6]!==c?(K=()=>{c()},$=[c],e[6]=c,e[7]=K,e[8]=$):(K=e[7],$=e[8]),o.useEffect(K,$);let w;e[9]!==m||e[10]!==k||e[11]!==g||e[12]!==L?(w=()=>{if(g)return;j(!0);const re=new Promise(tp);Promise.all([L({directory:m,silent:!0}),re]).then(()=>{const Ve=k(m);Ve&&R.error(Ve)}).finally(()=>{j(!1)})},e[9]=m,e[10]=k,e[11]=g,e[12]=L,e[13]=w):w=e[13];const G=w;let Q;e[14]!==i||e[15]!==a||e[16]!==x||e[17]!==l?(Q=()=>{let re="new-mcp-server",Ve=1;for(;i.some(B=>B.name===re);)re=`new-mcp-server-${Ve}`,Ve++;x({name:re,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),l(re),a?.()},e[14]=i,e[15]=a,e[16]=x,e[17]=l,e[18]=Q):Q=e[18];const X=Q;let Z;e[19]!==y||e[20]!==N||e[21]!==n?(Z=async()=>{if(!N)return;u(!0);const re=await y(N.name);re.ok?re.reloadFailed?R.warning(re.message||`MCP server "${N.name}" deleted, but OpenCode reload failed`,{description:re.warning||n("settings.mcp.sidebar.toast.refreshListIfStale")}):R.success(re.message||n("settings.mcp.sidebar.toast.serverDeleted",{name:N.name})):R.error(n("settings.mcp.sidebar.toast.deleteFailed")),h(null),u(!1)},e[19]=y,e[20]=N,e[21]=n,e[22]=Z):Z=e[22];const P=Z;let ee;e[23]!==n?(ee=(re,Ve)=>s.jsxs(Ve,{onClick:Ze=>{Ze.stopPropagation(),h(re)},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),n("settings.common.actions.delete")]}),e[23]=n,e[24]=ee):ee=e[24];const se=ee;let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=je("flex h-full flex-col","bg-background"),e[25]=D):D=e[25];let O;e[26]!==n?(O=n("settings.mcp.sidebar.title"),e[26]=n,e[27]=O):O=e[27];let U;e[28]!==O?(U=s.jsx("h2",{className:qs,children:O}),e[28]=O,e[29]=U):U=e[29];let A;e[30]!==n?(A=n("settings.mcp.sidebar.actions.refreshStatusAria"),e[30]=n,e[31]=A):A=e[31];let V;e[32]!==n?(V=n("settings.mcp.sidebar.actions.refreshStatusTitle"),e[32]=n,e[33]=V):V=e[33];const W=g&&"animate-spin";let te;e[34]!==W?(te=je("h-4 w-4",W),e[34]=W,e[35]=te):te=e[35];let ae;e[36]!==te?(ae=s.jsx(_,{name:"refresh",className:te}),e[36]=te,e[37]=ae):ae=e[37];let le;e[38]!==G||e[39]!==g||e[40]!==A||e[41]!==V||e[42]!==ae?(le=s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:g,onClick:G,"aria-label":A,title:V,children:ae}),e[38]=G,e[39]=g,e[40]=A,e[41]=V,e[42]=ae,e[43]=le):le=e[43];let be;e[44]!==U||e[45]!==le?(be=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[U,le]}),e[44]=U,e[45]=le,e[46]=be):be=e[46];let ke;e[47]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(ka,{className:"mb-3"}),e[47]=ke):ke=e[47];let ce;e[48]!==i.length||e[49]!==n?(ce=n("settings.mcp.sidebar.total",{count:i.length}),e[48]=i.length,e[49]=n,e[50]=ce):ce=e[50];let ge;e[51]!==ce?(ge=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ce}),e[51]=ce,e[52]=ge):ge=e[52];let Ee;e[53]!==n?(Ee=n("settings.mcp.sidebar.actions.addServerTitle"),e[53]=n,e[54]=Ee):Ee=e[54];let Se;e[55]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),e[55]=Se):Se=e[55];let Ne;e[56]!==X||e[57]!==Ee?(Ne=s.jsx(H,{size:"sm","data-settings-item":"mcp.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:X,title:Ee,children:Se}),e[56]=X,e[57]=Ee,e[58]=Ne):Ne=e[58];let fe;e[59]!==ge||e[60]!==Ne?(fe=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ge,Ne]}),e[59]=ge,e[60]=Ne,e[61]=fe):fe=e[61];let Ke;e[62]!==be||e[63]!==fe?(Ke=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[be,ke,fe]}),e[62]=be,e[63]=fe,e[64]=Ke):Ke=e[64];let De;e[65]!==i.length||e[66]!==p||e[67]!==a||e[68]!==E||e[69]!==S||e[70]!==se||e[71]!==M||e[72]!==r||e[73]!==x||e[74]!==l||e[75]!==n||e[76]!==v?(De=s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:i.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.mcp.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.mcp.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[S.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.mcp.sidebar.group.projectServers")}),S.map(re=>{const Ve=p[re.name],Ze=Kr(Ve?.status),B=r===re.name,Ue=xa();return s.jsxs(On,{open:M===re.name,onOpenChange:Qe=>I(Qe?re.name:null),children:[s.jsxs(Rn,{render:s.jsx("div",{className:je("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",B?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:Ue?void 0:Qe=>{Qe.preventDefault(),I(re.name)}}),children:[s.jsxs("button",{onClick:()=>{l(re.name),x(null),a?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_r,{tone:Ze,enabled:re.enabled}),s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:re.name}),s.jsx("span",{title:re.type==="local"?n("settings.mcp.sidebar.serverType.localTitle"):n("settings.mcp.sidebar.serverType.remoteTitle"),children:re.type==="local"?s.jsx(_,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):s.jsx(_,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:re.type==="local"?re.command?.join(" ")??"":re.url??""})]}),s.jsxs(Hs,{open:E===re.name,onOpenChange:Qe=>{Qe&&I(null),q(Qe?re.name:null)},children:[s.jsx($s,{asChild:!0,children:s.jsx(H,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Bs,{align:"end",className:"w-fit min-w-20",children:se(re,Gs)})]})]}),s.jsx(Dn,{className:"w-fit min-w-20",children:se(re,Mn)})]},re.name)})]}),v.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.mcp.sidebar.group.userServers")}),v.map(re=>{const Ve=p[re.name],Ze=Kr(Ve?.status),B=r===re.name,Ue=xa();return s.jsxs(On,{open:M===re.name,onOpenChange:Qe=>I(Qe?re.name:null),children:[s.jsxs(Rn,{render:s.jsx("div",{className:je("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",B?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:Ue?void 0:Qe=>{Qe.preventDefault(),I(re.name)}}),children:[s.jsxs("button",{onClick:()=>{l(re.name),x(null),a?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_r,{tone:Ze,enabled:re.enabled}),s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:re.name}),s.jsx("span",{title:re.type==="local"?n("settings.mcp.sidebar.serverType.localTitle"):n("settings.mcp.sidebar.serverType.remoteTitle"),children:re.type==="local"?s.jsx(_,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):s.jsx(_,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:re.type==="local"?re.command?.join(" ")??"":re.url??""})]}),s.jsxs(Hs,{open:E===re.name,onOpenChange:Qe=>{Qe&&I(null),q(Qe?re.name:null)},children:[s.jsx($s,{asChild:!0,children:s.jsx(H,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Bs,{align:"end",className:"w-fit min-w-20",children:se(re,Gs)})]})]}),s.jsx(Dn,{className:"w-fit min-w-20",children:se(re,Mn)})]},re.name)})]})]})}),e[65]=i.length,e[66]=p,e[67]=a,e[68]=E,e[69]=S,e[70]=se,e[71]=M,e[72]=r,e[73]=x,e[74]=l,e[75]=n,e[76]=v,e[77]=De):De=e[77];const he=N!==null;let pe;e[78]!==C?(pe=re=>{!re&&!C&&h(null)},e[78]=C,e[79]=pe):pe=e[79];let Ie;e[80]!==n?(Ie=n("settings.mcp.sidebar.deleteDialog.title"),e[80]=n,e[81]=Ie):Ie=e[81];let ze;e[82]!==Ie?(ze=s.jsx(Gt,{children:Ie}),e[82]=Ie,e[83]=ze):ze=e[83];const Je=N?.name||"";let _e;e[84]!==n||e[85]!==Je?(_e=n("settings.mcp.sidebar.deleteDialog.descriptionPrefix",{name:Je}),e[84]=n,e[85]=Je,e[86]=_e):_e=e[86];let Le;e[87]===Symbol.for("react.memo_cache_sentinel")?(Le=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),e[87]=Le):Le=e[87];let Pe;e[88]!==_e?(Pe=s.jsxs(qt,{children:[_e," ",Le,"."]}),e[88]=_e,e[89]=Pe):Pe=e[89];let Ye;e[90]!==ze||e[91]!==Pe?(Ye=s.jsxs(Ht,{children:[ze,Pe]}),e[90]=ze,e[91]=Pe,e[92]=Ye):Ye=e[92];let Ge;e[93]===Symbol.for("react.memo_cache_sentinel")?(Ge=()=>h(null),e[93]=Ge):Ge=e[93];let Me;e[94]!==n?(Me=n("settings.common.actions.cancel"),e[94]=n,e[95]=Me):Me=e[95];let $e;e[96]!==C||e[97]!==Me?($e=s.jsx(H,{size:"sm",variant:"ghost",onClick:Ge,disabled:C,children:Me}),e[96]=C,e[97]=Me,e[98]=$e):$e=e[98];let Fe;e[99]!==C||e[100]!==n?(Fe=n(C?"settings.mcp.sidebar.actions.deleting":"settings.common.actions.delete"),e[99]=C,e[100]=n,e[101]=Fe):Fe=e[101];let ye;e[102]!==P||e[103]!==C||e[104]!==Fe?(ye=s.jsx(H,{size:"sm",onClick:P,disabled:C,children:Fe}),e[102]=P,e[103]=C,e[104]=Fe,e[105]=ye):ye=e[105];let z;e[106]!==$e||e[107]!==ye?(z=s.jsxs(os,{children:[$e,ye]}),e[106]=$e,e[107]=ye,e[108]=z):z=e[108];let oe;e[109]!==Ye||e[110]!==z?(oe=s.jsxs(Vt,{className:"max-w-md",children:[Ye,z]}),e[109]=Ye,e[110]=z,e[111]=oe):oe=e[111];let me;e[112]!==he||e[113]!==pe||e[114]!==oe?(me=s.jsx(Ut,{open:he,onOpenChange:pe,children:oe}),e[112]=he,e[113]=pe,e[114]=oe,e[115]=me):me=e[115];let ve;return e[116]!==Ke||e[117]!==De||e[118]!==me?(ve=s.jsxs("div",{className:D,children:[Ke,De,me]}),e[116]=Ke,e[117]=De,e[118]=me,e[119]=ve):ve=e[119],ve};function Jd(t){return{mcpServers:t.mcpServers,selectedMcpName:t.selectedMcpName,setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function Qd(t){return t.currentDirectory}function Yd(t){return t.refresh}function Zd(t){return t.getErrorForDirectory}function Xd(t){return t.scope==="project"}function ep(t){return t.scope!=="project"}function tp(t){return setTimeout(t,500)}function Us(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function aa(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function zs(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function La(t,e,a){const n=sp(a),i=typeof a.url=="string"?a.url.trim():"",r=zr(a,"env","environment"),l=zr(a,"headers"),x=np(a),c=typeof a.oauth=="object"&&a.oauth!==null?String(a.oauth.clientId??"").trim():"",y=typeof a.oauth=="object"&&a.oauth!==null?String(a.oauth.clientSecret??"").trim():"",m=typeof a.oauth=="object"&&a.oauth!==null?String(a.oauth.scope??"").trim():"",b=typeof a.oauth=="object"&&a.oauth!==null?String(a.oauth.redirectUri??"").trim():"",p=ap(a),L=ip(a);return{ok:!0,name:t,type:e,command:n,url:i,environment:r,headers:l,oauthEnabled:x,oauthClientId:c,oauthClientSecret:y,oauthScope:m,oauthRedirectUri:b,timeout:p,enabled:L}}function sp(t){const e=t.command,a=t.args;if(aa(e)&&aa(a))return[...e,...a];if(aa(e))return e;if(typeof e=="string"&&e.trim()){const n=e.trim().split(/\s+/);return aa(a)?[...n,...a]:n}return aa(a)?a:[]}function zr(t,...e){for(const a of e){const n=t[a];if(!Us(n))continue;const i=Object.entries(n).filter(([r,l])=>r&&typeof l=="string");if(i.length>0)return i.map(([r,l])=>({key:r,value:String(l)}))}return[]}function np(t){if(t.oauth===!1||t.oauth===null||t.oauth===void 0||!Us(t.oauth))return!1;const e=t.oauth;return!!(typeof e.clientId=="string"&&e.clientId.trim()||typeof e.clientSecret=="string"&&e.clientSecret.trim()||typeof e.scope=="string"&&e.scope.trim()||typeof e.redirectUri=="string"&&e.redirectUri.trim())}function ap(t){const e=t.timeout;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return String(Math.floor(e));if(typeof e=="string"&&e.trim()){const a=Number(e);if(Number.isFinite(a)&&a>0)return String(Math.floor(a))}return""}function ip(t){return"disabled"in t&&t.disabled===!0?!1:"enabled"in t?!!t.enabled:!0}function rp(t){const e=t.mcpServers;if(Us(e)){const n=Object.keys(e);if(n.length===1){const i=n[0],r=e[i];if(Us(r))return{name:i,entry:r}}if(n.length>1)return null}const a=Object.keys(t).filter(n=>{const i=t[n];return n!=="mcpServers"&&Us(i)});if(a.length===1){const n=a[0],i=t[n];if(Qo(i))return{name:n,entry:i}}return null}function Qo(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function op(t,e){let a;try{const x=t.trim();if(!x)return zs("No JSON content provided");a=JSON.parse(x)}catch(x){return zs(x instanceof Error?`Invalid JSON: ${x.message}`:"Invalid JSON")}if(!Us(a))return zs("Expected a JSON object, not an array or primitive");const n=a,i=n.mcpServers;if(Us(i)){const x=Object.keys(i);if(x.length===0)return zs("mcpServers object is empty",a);if(x.length>1)return zs("Paste one server at a time. Found "+x.length+" servers in mcpServers",a);const c=x[0],y=i[c];return Us(y)?La(c,Fa(y),y):zs("Server entry is not a valid object",a)}const r=n.mcp;if(Us(r)){const x=Object.keys(r);if(x.length===0)return zs("mcp object is empty",a);if(x.length>1)return zs("Paste one server at a time. Found "+x.length+" servers in mcp",a);const c=x[0],y=r[c];return Us(y)?La(c,Fa(y),y):zs("Server entry in mcp is not a valid object",a)}const l=rp(n);if(l)return La(l.name,Fa(l.entry),l.entry);if(Qo(n)){const x=Fa(n),c=typeof n.name=="string"&&n.name.trim()?n.name.trim():e?.fallbackName;return La(c,x,n)}return zs("No recognizable MCP server configuration found in JSON",a)}function Fa(t){return t.type==="remote"?"remote":t.type==="local"?"local":typeof t.url=="string"&&t.url.trim()?"remote":(Array.isArray(t.command)||typeof t.command=="string"||Array.isArray(t.args),"local")}function lp(t,e,a){const n=a?.isNewServer??!1,i=t.name,r=n&&i?i:e.name??"";return{...e,name:r,type:t.type,command:t.type==="local"?t.command:[],url:t.type==="remote"?t.url:"",environment:t.environment,headers:t.type==="remote"?t.headers:[],oauthEnabled:t.type==="remote"?t.oauthEnabled:!1,oauthClientId:t.type==="remote"?t.oauthClientId:"",oauthClientSecret:t.type==="remote"?t.oauthClientSecret:"",oauthScope:t.type==="remote"?t.oauthScope:"",oauthRedirectUri:t.type==="remote"?t.oauthRedirectUri:"",timeout:t.type==="remote"?t.timeout:"",enabled:t.enabled}}function Yo(t){const e=[];let a="",n=!1,i=!1;for(let r=0;r<t.length;r++){const l=t[r];if(l==="'"&&!i){n=!n;continue}if(l==='"'&&!n){i=!i;continue}if((l===" "||l===" ")&&!n&&!i){a&&(e.push(a),a="");continue}a+=l}return a&&e.push(a),e}function cp(t){const e=t.trim();if(!e)return{code:null,context:null,stateKey:null};try{const a=new URL(e),n=a.searchParams.get("code");if(typeof n=="string"&&n.trim())return{code:n.trim(),context:Fl(a.searchParams),stateKey:Eo(a.searchParams)}}catch{}return{code:e,context:null,stateKey:null}}const dp=t=>{const e=ht.c(27),{value:a,onChange:n,preview:i,onDetectUrl:r}=t;let l;e[0]!==a?(l=()=>a.join(`
4
4
  `),e[0]=a,e[1]=l):l=e[1];const[x,c]=o.useState(l),y=o.useRef(a);let m,b;e[2]!==a?(m=()=>{JSON.stringify(y.current)!==JSON.stringify(a)&&(y.current=a,c(a.join(`
@@ -1 +1 @@
1
- import{f as y,R as b,j as o}from"./vendor-react-BUCujlKS.js";import{f as w,h as u}from"./useAppFontEffects-sHmU5b8u.js";import{S as j}from"./SettingsView-Bl1drwPw.js";import{q as k,o as v,p as D,m as S,D as R}from"./vendor-base-ui-D_V6hAcE.js";import"./vendor-scheduler-7OC5HNn7.js";import"./index-iFY_N5aO.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./contextPanelEmbeddedChat-tQekJUAF.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Dihw9MtL.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeEndpointReset-cbahJ3hD.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-CmanopUB.js";import"./vendor-codemirror-search-8kyQdB3f.js";import"./vendor-replit-codemirror-vim-B0Ecqnlh.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";const Ro=h=>{const t=y.c(19),{open:c,onOpenChange:i}=h,{t:f}=w(),r=b.useId(),x=_;let e;t[0]!==i?(e=g=>{!g&&x()||i(g)},t[0]=i,t[1]=e):e=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(k,{className:u("oc-glass-backdrop fixed inset-0 z-50 bg-black/25 dark:bg-black/40","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),t[2]=a):a=t[2];let l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=u("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]"),t[3]=l):l=t[3];let p;t[4]!==f?(p=f("settings.window.description"),t[4]=f,t[5]=p):p=t[5];let m;t[6]!==r||t[7]!==p?(m=o.jsx(v,{id:r,className:"sr-only",children:p}),t[6]=r,t[7]=p,t[8]=m):m=t[8];let n;t[9]!==i?(n=o.jsx(j,{onClose:()=>i(!1),isWindowed:!0}),t[9]=i,t[10]=n):n=t[10];let s;t[11]!==r||t[12]!==m||t[13]!==n?(s=o.jsxs(D,{children:[a,o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:o.jsxs(S,{"aria-describedby":r,className:l,children:[m,n]})})]}),t[11]=r,t[12]=m,t[13]=n,t[14]=s):s=t[14];let d;return t[15]!==c||t[16]!==e||t[17]!==s?(d=o.jsx(R,{open:c,onOpenChange:e,children:s}),t[15]=c,t[16]=e,t[17]=s,t[18]=d):d=t[18],d};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{Ro as SettingsWindow};
1
+ import{f as y,R as b,j as o}from"./vendor-react-BUCujlKS.js";import{f as w,h as u}from"./useAppFontEffects-BikB6enL.js";import{S as j}from"./SettingsView-5RmswFZe.js";import{q as k,o as v,p as D,m as S,D as R}from"./vendor-base-ui-D_V6hAcE.js";import"./vendor-scheduler-7OC5HNn7.js";import"./index-DRpChWux.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeEndpointReset-BVmispdD.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-C7LTbwFx.js";import"./vendor-codemirror-search-8kyQdB3f.js";import"./vendor-replit-codemirror-vim-B0Ecqnlh.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";const Ro=h=>{const t=y.c(19),{open:c,onOpenChange:i}=h,{t:f}=w(),r=b.useId(),x=_;let e;t[0]!==i?(e=g=>{!g&&x()||i(g)},t[0]=i,t[1]=e):e=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(k,{className:u("oc-glass-backdrop fixed inset-0 z-50 bg-black/25 dark:bg-black/40","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),t[2]=a):a=t[2];let l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=u("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]"),t[3]=l):l=t[3];let p;t[4]!==f?(p=f("settings.window.description"),t[4]=f,t[5]=p):p=t[5];let m;t[6]!==r||t[7]!==p?(m=o.jsx(v,{id:r,className:"sr-only",children:p}),t[6]=r,t[7]=p,t[8]=m):m=t[8];let n;t[9]!==i?(n=o.jsx(j,{onClose:()=>i(!1),isWindowed:!0}),t[9]=i,t[10]=n):n=t[10];let s;t[11]!==r||t[12]!==m||t[13]!==n?(s=o.jsxs(D,{children:[a,o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:o.jsxs(S,{"aria-describedby":r,className:l,children:[m,n]})})]}),t[11]=r,t[12]=m,t[13]=n,t[14]=s):s=t[14];let d;return t[15]!==c||t[16]!==e||t[17]!==s?(d=o.jsx(R,{open:c,onOpenChange:e,children:s}),t[15]=c,t[16]=e,t[17]=s,t[18]=d):d=t[18],d};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{Ro as SettingsWindow};