@openchamber/web 1.13.5 → 1.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/commands-update.test.js +50 -0
- package/dist/assets/{DiagramView-Bbj-QI7h.js → DiagramView-BJkP8Fjp.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BNr_9Jsb.js → MarkdownRendererImpl-Nq7bOf31.js} +3 -3
- package/dist/assets/{MultiRunWindow-DMMu53kw.js → MultiRunWindow-CRKVePMG.js} +1 -1
- package/dist/assets/NewWorktreeDialog-Dj6KETex.js +167 -0
- package/dist/assets/{OnboardingScreen-BucKVBD7.js → OnboardingScreen-DRe8UNiS.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-B6kvduse.js → SessionSwitcherDropdown-Cn_yoQrm.js} +1 -1
- package/dist/assets/{SettingsWindow-BEfDro9b.js → SettingsWindow-BIKNrxSK.js} +1 -1
- package/dist/assets/{TerminalView-CMdqMpTy.js → TerminalView-BDjzrhGS.js} +1 -1
- package/dist/assets/{es-Bk-yR0w-.js → es-D0PPWgfL.js} +1 -1
- package/dist/assets/{fr-f1ibV7QU.js → fr-4AxG2GNC.js} +1 -1
- package/dist/assets/index-AsCHiJ5P.js +3 -0
- package/dist/assets/{index-B82A6jBD.css → index-Bv4711NQ.css} +1 -1
- package/dist/assets/{ja-D9mS3zWP.js → ja-BPVJtPU2.js} +1 -1
- package/dist/assets/{ko-Cpl1IA3D.js → ko-BJHERh2a.js} +1 -1
- package/dist/assets/main-BByFAmjA.js +214 -0
- package/dist/assets/{main-KEVf2Yak.js → main-BJDsJGkp.js} +2 -2
- package/dist/assets/miniChat-Ckr71tB9.js +2 -0
- package/dist/assets/mobile-DVDtnIcD.js +2 -0
- package/dist/assets/{pl-CYke_fxL.js → pl-CH00wT_K.js} +1 -1
- package/dist/assets/{pt-BR-Clb6Z8up.js → pt-BR-1tfKEfvN.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Cb1iUq8M.js → renderElectronMiniChatApp-CXvtB6Rd.js} +2 -2
- package/dist/assets/{renderMobileApp-7chEBHPK.js → renderMobileApp-BVAt5rTM.js} +3 -3
- package/dist/assets/{uk-CXn8cxXa.js → uk-BkeRI8D4.js} +1 -1
- package/dist/assets/{useAppFontEffects-Bd0ks39c.js → useAppFontEffects-B66TruVB.js} +114 -114
- package/dist/assets/{zh-CN-BRwwlEdG.js → zh-CN-DtROWolc.js} +1 -1
- package/dist/assets/{zh-TW-D5pg5Z8l.js → zh-TW-CDqNEP6z.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/package-manager.js +2 -2
- package/server/lib/package-manager.test.js +13 -1
- package/dist/assets/NewWorktreeDialog-5TYBoMMA.js +0 -167
- package/dist/assets/index-BsXkdBYx.js +0 -3
- package/dist/assets/main-DOdUrt3s.js +0 -214
- package/dist/assets/miniChat-Nlzqr3Df.js +0 -2
- package/dist/assets/mobile-BIhOFhia.js +0 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import{ak as gc,e as rt,al as hc,j as t,H as ve,am as fc,an as xc,a as rn,d as ta,p as Br,b as Ur,R as l,L as Ss,ab as bc,ac as yc,aa as vc,ad as jc,a8 as wc,a9 as Nc,ae as kc,ao as Sc,ap as Cc,aq as Pc,u as Ic,l as Dc,n as Ac,w as Ec,C as Mc,S as Rc,ar as Tc,a6 as Fc,D as Oc,q as Lc,as as zc,at as Kc,au as $c,av as Bc,aw as Uc,X as Os,ax as Vc,ay as xn,az as Zr,aA as _c,aB as Hc,aC as Wa,aD as Wc,aE as qc,aF as Gc,aG as ei,aH as Ra,aI as ti,k as Na,aJ as ml,aK as Vr,aL as za,aM as ul,aN as si,aO as Jc,aP as Qc,aQ as Yc,aR as Xc,aS as ni,aT as Oe,aU as aa,aV as Zc,aW as ed,aX as td,aY as sd,aZ as nd,a_ as pl,a7 as ad,a$ as ai,b0 as rd,b1 as id,b2 as od,b3 as ld}from"./vendor-.bun-By2L9XvG.js";import{dy as Ka,r as Ta,v as Fa,m as ce,dz as ka,dA as Sa,dB as Ca,D as is,u as dt,I as A,aw as Pt,ax as It,ay as Dt,dC as cd,au as Ws,a_ as $t,aZ as Bt,aY as Ut,bC as Gt,w as wr,bb as _r,p as mn,at as Cs,t as _,cn as gl,B as J,dD as Dn,dE as dd,dF as md,dj as ud,dG as pd,dH as gd,dI as hd,z as Is,dJ as fd,cR as xd,cS as bd,cT as yd,c2 as vd,ap as us,ar as ps,c3 as jd,as as gs,aS as $a,dK as wd,dL as Sn,aX as _t,bo as Wt,bK as Yt,n as ot,dM as Xn,ao as vs,Q as ut,dg as Nd,bD as Mt,bE as Rt,bF as Kt,bG as Tt,bH as gt,b9 as hs,aT as Hr,dN as un,ba as St,dO as hl,dP as kd,dQ as Sd,dR as Ba,dS as Hs,dT as An,aV as fl,dU as Cn,dV as Cd,dW as Pd,dX as Id,dY as Dd,dZ as Ad,d_ as Ed,d$ as Vs,e0 as Md,q as Ua,c8 as ri,k as Rd,ca as Nr,a3 as xl,E as Td,P as bl,G as yl,cc as Fd,O as ii,c_ as Od,de as vl,d3 as jl,d5 as Ld,e1 as zd,cA as Kd,e2 as oi,e3 as $d,e4 as Bd,e5 as li,e6 as Ud,e7 as Vd,e8 as _d,e9 as Hd,av as Wd,ea as qd,H as Gd,K as Jd,a as Wr,aG as ci,eb as di,ec as mi,aJ as $n,ed as qa,ee as Qd,ef as Yd,ac as En,ab as wl,aa as Xd,eg as Zd,eh as ui,ad as em,ae as tm,a5 as sm,aA as nm,aB as am,aC as Nl,ei as Ga,ej as pi,ek as rm,el as im,em as om,en as lm,d6 as Va,R as _s,eo as cm,cb as kl,ep as dm,eq as mm,er as um,es as pm,et as Ja,eu as gi,ev as gm,ew as hm,ex as fm,ey as xm,ez as bm,eA as Qa,eB as ym,eC as hi,eD as Gn,eE as vm,aP as fi,eF as Nn,aO as jm,eG as wm,eH as xi,eI as bi,X as Ys,F as Nm,S as km,eJ as Sm,cl as ra,bg as kr,bh as Sr,bi as Cr,bj as Pr,bk as Us,bl as Rs,bL as Pn,M as Qn,eK as yi,bX as Cm,eL as Sl,bN as Pm,da as Im,f as Dm,eM as Ya,a2 as Am,b3 as ia,bR as Em,eN as Mm,eO as Rm,d4 as Tm,eP as Fm,eQ as Om}from"./useAppFontEffects-B66TruVB.js";import{D as Zn,e as yt,o as ws,u as ys,a2 as Lm,a3 as vi,a4 as zm,a5 as Km,w as fs,K as dn,b as Ke,j as sa,f as Ct,a as ea,q as zs,h as ds,a6 as $m,F as Bm,a7 as Xa,E as Um,a8 as ji,a9 as Vm,x as _m,aa as wi,ab as Ni,ac as ki,ad as Si,ae as Za,af as Ci,C as Cl,ag as Hm,ah as Wm,ai as qm,a1 as Gm,L as Jm,aj as Qm,ak as Ym,al as Xm}from"./index-AsCHiJ5P.js";import{g as Zm,s as eu}from"./mobileLayoutPreference-Dio-WWkI.js";function tu(){return new Worker(gc,{type:"module"})}const su=["typescript","javascript","tsx","jsx","json","markdown"],Ir={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Pi,Ii;const Di=s=>{const e=Ir[s],n=new hc({workerFactory:tu,poolSize:e.poolSize,totalASTLRUCacheSize:e.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:su,lineDiffType:e.lineDiffType,preferredHighlighter:"shiki-wasm"});return n.initialize(),n},nu=s=>{if(!(typeof window>"u"))return s==="split"?(Ii??=Di("split"),Ii):(Pi??=Di("unified"),Pi)},au=s=>{const e=rt.c(7),{children:n,renderTheme:a}=s,r=Dr("unified"),i=Dr("split");let o,d;e[0]!==a||e[1]!==i||e[2]!==r?(o=()=>{r&&r.setRenderOptions({theme:a,lineDiffType:Ir.unified.lineDiffType}),i&&i.setRenderOptions({theme:a,lineDiffType:Ir.split.lineDiffType})},d=[a,i,r],e[0]=a,e[1]=i,e[2]=r,e[3]=o,e[4]=d):(o=e[3],d=e[4]),ve.useEffect(o,d);let c;return e[5]!==n?(c=t.jsx(t.Fragment,{children:n}),e[5]=n,e[6]=c):c=e[6],c},Av=s=>{const e=rt.c(11),{children:n}=s,a=Ka();let r,i;if(e[0]!==a?.availableThemes||e[1]!==a?.darkThemeId||e[2]!==a?.lightThemeId){const x=Ta(!1),m=Ta(!0),p=a?.lightThemeId??x.metadata.id,u=a?.darkThemeId??m.metadata.id;i=a?.availableThemes.find(C=>C.metadata.id===p)??x,r=a?.availableThemes.find(C=>C.metadata.id===u)??m,Fa(i),Fa(r),e[0]=a?.availableThemes,e[1]=a?.darkThemeId,e[2]=a?.lightThemeId,e[3]=r,e[4]=i}else r=e[3],i=e[4];let o;e[5]!==r.metadata.id||e[6]!==i.metadata.id?(o={light:i.metadata.id,dark:r.metadata.id},e[5]=r.metadata.id,e[6]=i.metadata.id,e[7]=o):o=e[7];const d=o;let c;return e[8]!==n||e[9]!==d?(c=t.jsx(au,{renderTheme:d,children:n}),e[8]=n,e[9]=d,e[10]=c):c=e[10],c},Dr=s=>{const e=rt.c(2),n=s===void 0?"unified":s;let a;return e[0]!==n?(a=nu(n),e[0]=n,e[1]=a):a=e[1],a};function ru(s){const e=rt.c(4);let n,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("path",{d:"M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z"}),a=t.jsx("path",{d:"M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z"}),e[0]=n,e[1]=a):(n=e[0],a=e[1]);let r;return e[2]!==s?(r=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",fillRule:"evenodd",viewBox:"-0.5 -0.5 25 25",...s,children:[n,a]}),e[2]=s,e[3]=r):r=e[3],r}const Oa=ve.forwardRef((s,e)=>{const n=rt.c(11);let a,r;n[0]!==s?({className:a,...r}=s,n[0]=s,n[1]=a,n[2]=r):(a=n[1],r=n[2]);let i;n[3]!==a?(i=ce("peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]",a),n[3]=a,n[4]=i):i=n[4];let o;n[5]===Symbol.for("react.memo_cache_sentinel")?(o={width:"36px",height:"20px",minWidth:"36px",minHeight:"20px"},n[5]=o):o=n[5];let d;n[6]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(fc,{className:ce("pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0"),style:{width:"16px",height:"16px",minWidth:"16px",minHeight:"16px"}}),n[6]=d):d=n[6];let c;return n[7]!==r||n[8]!==e||n[9]!==i?(c=t.jsx(xc,{className:i,style:o,...r,ref:e,children:d}),n[7]=r,n[8]=e,n[9]=i,n[10]=c):c=n[10],c});Oa.displayName="Switch";const oa=()=>{try{const e=is.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();const n=ws.getDirectory();if(n?.trim())return n.trim()}catch(s){console.warn("[McpConfigStore] Error resolving config directory:",s)}return null},Ai=s=>s?Object.entries(s).map(([e,n])=>({key:e,value:n})):[],Ei=s=>{const e=s.filter(n=>n.key.trim());if(e.length!==0)return Object.fromEntries(e.map(n=>[n.key.trim(),n.value]))},la=s=>typeof s!="string"?void 0:s.trim()||void 0,er=800,iu=5e3,ou="__default__",Ar=new Map,tr=new Map,Pl=s=>s?.trim()||ou,sr=s=>{Ar.delete(Pl(s))},Rn=rn()(ta(Br((s,e)=>({mcpServers:[],selectedMcpName:null,isLoading:!1,mcpDraft:null,setSelectedMcp:n=>s({selectedMcpName:n}),setMcpDraft:n=>s({mcpDraft:n}),loadMcpConfigs:async n=>{const a=oa(),r=Pl(a),i=Date.now(),o=Ar.get(r)??0,d=e().mcpServers.length>0;if(!n?.force&&d&&i-o<iu)return!0;const c=tr.get(r);if(!n?.force&&c)return c;const x=(async()=>{s({isLoading:!0});try{const m=a?`?directory=${encodeURIComponent(a)}`:"",p=await yt(`/api/config/mcp${m}`,{headers:a?{"x-opencode-directory":a}:void 0});if(!p.ok)throw new Error("Failed to load MCP configs");const u=await p.json();return s({mcpServers:u,isLoading:!1}),Ar.set(r,Date.now()),!0}catch(m){return console.error("[McpConfigStore] Failed to load MCP configs:",m),s({isLoading:!1}),!1}})();tr.set(r,x);try{return await x}finally{tr.delete(r)}},createMcp:async n=>{ka("Creating MCP server configuration…");let a=!1;try{const r=Mi(n),i=oa(),o=i?`?directory=${encodeURIComponent(i)}`:"",d=await yt(`/api/config/mcp/${encodeURIComponent(n.name)}${o}`,{method:"POST",headers:{"Content-Type":"application/json",...i?{"x-opencode-directory":i}:{}},body:JSON.stringify(r)}),c=await d.json().catch(()=>null);if(!d.ok)throw new Error(c?.error||"Failed to create MCP server");return sr(i),c?.requiresReload?(a=!0,await Sa({message:c.message,delayMs:c.reloadDelayMs??er,scopes:["all"]}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(r){return console.error("[McpConfigStore] Failed to create MCP:",r),{ok:!1}}finally{a||Ca()}},updateMcp:async(n,a)=>{ka("Updating MCP server configuration…");let r=!1;try{const i=Mi(a),o=oa(),d=o?`?directory=${encodeURIComponent(o)}`:"",c=await yt(`/api/config/mcp/${encodeURIComponent(n)}${d}`,{method:"PATCH",headers:{"Content-Type":"application/json",...o?{"x-opencode-directory":o}:{}},body:JSON.stringify(i)}),x=await c.json().catch(()=>null);if(!c.ok)throw new Error(x?.error||"Failed to update MCP server");return sr(o),x?.requiresReload?(r=!0,await Sa({message:x.message,delayMs:x.reloadDelayMs??er,scopes:["all"]}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:x?.reloadFailed===!0,message:x?.message,warning:x?.warning}):(await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:x?.reloadFailed===!0,message:x?.message,warning:x?.warning})}catch(i){throw console.error("[McpConfigStore] Failed to update MCP:",i),i}finally{r||Ca()}},deleteMcp:async n=>{ka("Deleting MCP server configuration…");let a=!1;try{const r=oa(),i=r?`?directory=${encodeURIComponent(r)}`:"",o=await yt(`/api/config/mcp/${encodeURIComponent(n)}${i}`,{method:"DELETE",headers:r?{"x-opencode-directory":r}:void 0}),d=await o.json().catch(()=>null);if(!o.ok)throw new Error(d?.error||"Failed to delete MCP server");return sr(r),d?.requiresReload&&(a=!0,await Sa({message:d.message,delayMs:d.reloadDelayMs??er,scopes:["all"]})),e().selectedMcpName===n&&s({selectedMcpName:null}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:d?.reloadFailed===!0,message:d?.message,warning:d?.warning}}catch(r){return console.error("[McpConfigStore] Failed to delete MCP:",r),{ok:!1}}finally{a||Ca()}},getMcpByName:n=>e().mcpServers.find(a=>a.name===n)}),{name:"mcp-config-store",storage:Ur(()=>Zn()),partialize:s=>({selectedMcpName:s.selectedMcpName})}),{name:"mcp-config-store"}));function Mi(s){const e={};if(s.scope!==void 0&&(e.scope=s.scope),s.type!==void 0&&(e.type=s.type),(s.type==="local"||s.command!==void 0)&&(e.command=(s.command??[]).filter(n=>n.trim())),(s.type==="remote"||s.url!==void 0)&&(e.url=s.url?.trim()??""),s.environment!==void 0&&(e.environment=Ei(s.environment)??{}),s.headers!==void 0&&(e.headers=Ei(s.headers)??{}),s.oauthEnabled!==void 0||s.oauthClientId!==void 0||s.oauthClientSecret!==void 0||s.oauthScope!==void 0||s.oauthRedirectUri!==void 0)if(s.oauthEnabled===!1)e.oauth=!1;else{const n={clientId:la(s.oauthClientId),clientSecret:la(s.oauthClientSecret),scope:la(s.oauthScope),redirectUri:la(s.oauthRedirectUri)};n.clientId||n.clientSecret||n.scope||n.redirectUri?e.oauth=n:s.oauthEnabled?e.oauth={}:e.oauth=!1}if(s.timeout!==void 0){const n=Number(s.timeout);Number.isFinite(n)&&n>0?e.timeout=n:e.timeout=null}return s.enabled!==void 0&&(e.enabled=s.enabled),e}const lu={},cu={},Bs=s=>{if(typeof s!="string")return null;const e=s.trim();if(!e)return null;const n=e.replace(/\\/g,"/");return n.length>1?n.replace(/\/+$/,""):n},jn=s=>Bs(s)??"__global__",on=s=>{const e=Bs(s);return e?ws.getScopedApiClient(e):ws.getApiClient()},ls=rn()(ta((s,e)=>({byDirectory:{},diagnosticsByDirectory:{},loadingKeys:{},lastErrorKeys:{},getStatusForDirectory:n=>{const a=jn(n??ys.getState().currentDirectory);return e().byDirectory[a]??lu},getDiagnosticForDirectory:n=>{const a=jn(n??ys.getState().currentDirectory);return e().diagnosticsByDirectory[a]??cu},getErrorForDirectory:n=>{const a=jn(n??ys.getState().currentDirectory);return e().lastErrorKeys[a]??null},refresh:async n=>{const a=Bs(n?.directory??ys.getState().currentDirectory),r=jn(a);n?.silent||s(i=>({loadingKeys:{...i.loadingKeys,[r]:!0},lastErrorKeys:{...i.lastErrorKeys,[r]:null}}));try{const d=(await on(a).mcp.status()).data??{};s(c=>({byDirectory:{...c.byDirectory,[r]:d},diagnosticsByDirectory:{...c.diagnosticsByDirectory,[r]:Object.fromEntries(Object.entries(c.diagnosticsByDirectory[r]??{}).filter(([x])=>!d[x]))},loadingKeys:{...c.loadingKeys,[r]:!1},lastErrorKeys:{...c.lastErrorKeys,[r]:null}}))}catch(i){const o=i instanceof Error?i.message:"Failed to load MCP status";s(d=>({loadingKeys:{...d.loadingKeys,[r]:!1},lastErrorKeys:{...d.lastErrorKeys,[r]:o}}))}},connect:async(n,a)=>{const r=Bs(a??ys.getState().currentDirectory),i=jn(r),o=on(r);try{await o.mcp.connect({name:n},{throwOnError:!0})}catch(d){const c=d instanceof Error?d.message:"Connection failed";throw s(x=>({diagnosticsByDirectory:{...x.diagnosticsByDirectory,[i]:{...x.diagnosticsByDirectory[i]??{},[n]:{status:"failed",error:c}}}})),d}await e().refresh({directory:r,silent:!0})},disconnect:async(n,a)=>{const r=Bs(a??ys.getState().currentDirectory);await on(r).mcp.disconnect({name:n},{throwOnError:!0}),await e().refresh({directory:r,silent:!0})},startAuth:async(n,a)=>{const r=Bs(a??ys.getState().currentDirectory),d=(await on(r).mcp.auth.start({name:n},{throwOnError:!0})).data?.authorizationUrl;if(!d)throw new Error("Authorization URL was not returned");return d},completeAuth:async(n,a,r)=>{const i=Bs(r??ys.getState().currentDirectory);await on(i).mcp.auth.callback({name:n,code:a},{throwOnError:!0}),await e().refresh({directory:i,silent:!0})},clearAuth:async(n,a)=>{const r=Bs(a??ys.getState().currentDirectory);await on(r).mcp.auth.remove({name:n},{throwOnError:!0}),await e().refresh({directory:r,silent:!0})},testConnection:async(n,a)=>{const r=Bs(a??ys.getState().currentDirectory),i=jn(r),o=on(r),c=e().getStatusForDirectory(r)[n]?.status==="connected";let x,m;try{await o.mcp.connect({name:n},{throwOnError:!0})}catch(C){x=C instanceof Error?C.message:"Connection failed",s(f=>({diagnosticsByDirectory:{...f.diagnosticsByDirectory,[i]:{...f.diagnosticsByDirectory[i]??{},[n]:{status:"failed",error:x??"Connection failed"}}}}))}await e().refresh({directory:r,silent:!0});const p=e().getStatusForDirectory(r)[n],u=p;if(!c&&p?.status==="connected"){try{await o.mcp.disconnect({name:n},{throwOnError:!0})}catch(C){m=`Connection test succeeded, but cleanup disconnect failed: ${C instanceof Error?C.message:"Disconnect failed"}`}await e().refresh({directory:r,silent:!0})}return{status:u??e().getStatusForDirectory(r)[n],error:x,warning:m}}}))),du=(s,e)=>{if(!s)return e("mcpDropdown.status.unknown");switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:s.error||""});default:return s.status}},mu=s=>{switch(s?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},Ev=({active:s,className:e,headerAction:n,listClassName:a,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:o}=dt(),c=ys(N=>N.currentDirectory)??null,x=ls(N=>N.getStatusForDirectory(c)),m=ls(N=>N.refresh),p=ls(N=>N.connect),u=ls(N=>N.disconnect),C=Rn(N=>N.mcpServers),f=Rn(N=>N.loadMcpConfigs),[g,h]=l.useState(!1),[D,k]=l.useState(null);l.useEffect(()=>{m({directory:c,silent:!0})},[m,c]),l.useEffect(()=>{f({force:!0})},[f]),l.useEffect(()=>{s&&Promise.all([m({directory:c,silent:!0}),f({force:!0})])},[s,m,c,f]);const w=l.useMemo(()=>{const N=new Set(Object.keys(x));for(const y of C)y?.name&&N.add(y.name);return Array.from(N).sort((y,b)=>y.localeCompare(b))},[C,x]),E=l.useCallback(N=>{if(N?.preventDefault(),g)return;h(!0);const y=new Promise(b=>setTimeout(b,500));Promise.all([m({directory:c}),y]).finally(()=>{h(!1)})},[g,m,c]);return t.jsxs("div",{className:ce("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:o("mcpDropdown.title")}),c&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:c.split("/").pop()||c})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n,t.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:E,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(A,{name:"refresh",className:ce("h-4 w-4",g&&"animate-spin")})})]})]})}),t.jsxs("div",{className:ce("max-h-64 overflow-y-auto py-2",i&&"space-y-1 py-3",a),children:[w.map(N=>{const y=x[N],b=mu(y),P=y?.status==="connected",z=D===N,M=du(y,o);return t.jsxs("div",{className:ce("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"gap-3 px-4 py-3":"gap-2 px-4 py-1.5"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx("span",{className:ce("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",b==="success"&&"bg-status-success",b==="error"&&"bg-status-error",b==="warning"&&"bg-status-warning",b==="default"&&"bg-muted-foreground/40"),"aria-label":M})}),t.jsx(Dt,{side:"left",children:t.jsx("p",{children:M})})]}),t.jsx("span",{className:ce("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:N})]})}),t.jsx(Oa,{checked:P,disabled:z,className:"data-[checked]:bg-status-info",onCheckedChange:async I=>{k(N);try{I?await p(N,c):await u(N,c)}finally{k(null)}}})]},N)}),w.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})]})};function uu(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=cd();return s}catch{return"unknown"}}function pu(){const s=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const n=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(n==="arm"||n==="arm64"||n==="aarch64")return"arm64";if(n==="x86"||n==="x64"||n==="amd64")return"x64";const a=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return a.includes("aarch64")||a.includes("arm64")||a.includes("armv")?"arm64":a.includes("x86_64")||a.includes("x64")||a.includes("amd64")||a.includes("win64")?"x64":"unknown"}function gu(){if(typeof navigator>"u")return"web";const s=(navigator.platform||"").toLowerCase();return s.includes("mac")?"macos":s.includes("win")?"windows":s.includes("linux")?"linux":"web"}function hu(s){const e=Ke.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});return n.set("deviceClass",uu()),n.set("arch",pu()),n.set("platform",gu()),s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",sa()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Ri(s,e){try{const n=hu(s),a=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e||s==="vscode"&&a&&n.set("currentVersion",a);const r=await yt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Server responded with ${r.status}`);const i=await r.json();return{available:i.available??!1,version:i.version,currentVersion:i.currentVersion??"unknown",body:i.body,nextSuggestedCheckInSec:typeof i.nextSuggestedCheckInSec=="number"&&Number.isFinite(i.nextSuggestedCheckInSec)?i.nextSuggestedCheckInSec:void 0,packageManager:i.packageManager,updateCommand:i.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function fu(){return Km()?"desktop":fs()?"vscode":dn()?"web":null}const Ti={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Il=rn()((s,e)=>({...Ti,checkForUpdates:async()=>{const n=fu();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let a=null,r=null;if(n==="desktop"){const i=await vi();return s({checking:!1,available:i?.available??!1,info:i,lastChecked:Date.now(),nextCheckInSec:null}),r}else n==="web"?(a=await Ri("web"),r=a?.nextSuggestedCheckInSec??null):n==="vscode"&&(r=(await Ri("vscode"))?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:a?.available??!1,info:n==="vscode"?null:a,lastChecked:Date.now(),nextCheckInSec:r}),r}catch(a){return s({checking:!1,error:a instanceof Error?a.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:a}=e();if(!(a!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const r=await vi();if(!r?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(o=>({info:o.info?{...o.info,...r,body:o.info.body||r.body,available:o.info.available}:r})),!await zm(o=>{s({progress:o})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(r){s({downloading:!1,error:r instanceof Error?r.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:a}=e();if(!(a!=="desktop"||!n))try{if(!await Lm())throw new Error("Desktop restart only works on Local instance")}catch(r){s({error:r instanceof Error?r.message:"Failed to restart"})}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(Ti)}})),Fi="https://github.com/btriapitsyn/openchamber/releases";function xu(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(_r(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function bu(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Oi(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function yu(s,e){const n=s.split(".").map(r=>Number.parseInt(r,10)),a=e.split(".").map(r=>Number.parseInt(r,10));for(let r=0;r<3;r+=1){const i=Number.isFinite(n[r])?n[r]:0,o=Number.isFinite(a[r])?a[r]:0;if(i!==o)return o-i}return 0}function vu(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let a;for(;(a=e.exec(s))!==null;)n.push({version:a[1]??"",date:a[2]??"",start:a.index});return n.length===0?[]:n.map((r,i)=>{const o=n[i+1]?.start??s.length,d=s.slice(r.start,o).trim();return{version:r.version,date:r.date,start:r.start,end:o,raw:d}})}const Li=2e3,ju=600*1e3;async function wu(){try{const s=await yt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function Nu(){try{return(await yt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function ku(s,e=Math.ceil(ju/Li),n=Li){for(let a=0;a<e;a++){try{const r=await yt("/api/openchamber/update-check",{method:"GET",headers:{Accept:"application/json"}});if(r.ok){const i=await r.json().catch(()=>null);if(i&&i.available===!1||i&&typeof i.currentVersion=="string"&&typeof s=="string"&&i.currentVersion!==s)return!0}else if((r.status===401||r.status===403)&&await Nu())return!0}catch{}await new Promise(r=>setTimeout(r,n))}return!1}const zi=({open:s,onOpenChange:e,info:n,downloading:a,downloaded:r,progress:i,error:o,onDownload:d,onRestart:c,runtimeType:x="desktop"})=>{const{t:m}=dt(),[p,u]=ve.useState(!1),[C,f]=ve.useState("idle"),[g,h]=ve.useState(null),D=n?.version?`${Fi}/tag/v${n.version}`:Fi,k=i?.total?Math.round(i.downloaded/i.total*100):0,w=x==="web",E=n?.updateCommand||"openchamber update";ve.useEffect(()=>{s||(f("idle"),h(null))},[s]);const N=async()=>{(await mn(E)).ok&&(u(!0),setTimeout(()=>u(!1),2e3))},y=ve.useCallback(async M=>{await Ws(M)},[]),b=ve.useCallback(async()=>{f("updating"),h(null);const M=await wu();if(!M.success){f("error"),h(M.error||m("updateDialog.error.updateFailed"));return}M.autoRestart&&(f("restarting"),await new Promise(v=>setTimeout(v,2e3))),f("reconnecting"),await ku(n?.currentVersion)?window.location.reload():(f("error"),h(m("updateDialog.error.takingLonger")))},[n?.currentVersion,m]),P=C!=="idle"&&C!=="error",z=ve.useMemo(()=>{if(!n?.body)return null;const M=n.body.trim();if(!M)return null;const I=vu(M);if(I.length===0)return{kind:"raw",title:m("updateDialog.changelog.title"),content:Oi(M)};const v=[...I].sort((j,O)=>yu(j.version,O.version));return{kind:"sections",title:m("updateDialog.changelog.title"),sections:v.map(j=>({version:j.version,dateLabel:xu(j.date),content:Oi(bu(j.raw)||M)}))}},[n?.body,m]);return t.jsx($t,{open:s,onOpenChange:P?void 0:e,children:t.jsxs(Bt,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Ut,{className:"flex items-center gap-2.5",children:[t.jsx(A,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:m(C==="restarting"||C==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[w&&P&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(A,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[C==="updating"&&m("updateDialog.status.installingUpdate"),C==="restarting"&&m("updateDialog.status.serverRestarting"),C==="reconnecting"&&m("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:m("updateDialog.status.autoReloadHint")})]}),z&&!P&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Gt,{className:"max-h-[400px] p-0",fillContainer:!1,children:z.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:M=>{const v=M.target.closest("a");v&&v.href&&(M.preventDefault(),M.stopPropagation(),y(v.href))},children:t.jsx(wr,{content:z.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:z.sections.map(M=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",M.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:M.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:I=>{const j=I.target.closest("a");j&&j.href&&(I.preventDefault(),I.stopPropagation(),y(j.href))},children:t.jsx(wr,{content:M.content,disableLinkSafety:!0,enableFileReferences:!1})})]},M.version))})})}),w&&C==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(A,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:m("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:E}),t.jsx("button",{onClick:N,className:ce("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",p&&"text-[var(--status-success)]"),title:m(p?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:p?t.jsx(A,{name:"check",className:"h-4 w-4"}):t.jsx(A,{name:"clipboard",className:"h-4 w-4"})})]})]}),!w&&a&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:m("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[k,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${k}%`}})})]}),(o||g)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:o||g})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(A,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!w&&!r&&!a&&t.jsxs("button",{onClick:d,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(A,{name:"download",className:"h-4 w-4"}),m("updateDialog.actions.downloadUpdate")]}),!w&&a&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(A,{name:"loader",className:"h-4 w-4 animate-spin"}),m("updateDialog.status.downloading")]}),!w&&r&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(A,{name:"restart",className:"h-4 w-4"}),m("updateDialog.actions.restartToUpdate")]}),w&&!P&&t.jsxs("button",{onClick:b,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(A,{name:"download",className:"h-4 w-4"}),m("updateDialog.actions.updateNow")]}),w&&P&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(A,{name:"loader",className:"h-4 w-4 animate-spin"}),m("updateDialog.status.updating")]})]})]})]})})},Ki="https://github.com/openchamber/openchamber",Su="https://discord.gg/ZYRSdnwwKA",$i="https://x.com/openchamber_dev",Cu=800,Dl=({initialUpdateDialogOpen:s=!1})=>{const{t:e}=dt(),[n,a]=l.useState(s),[r,i]=l.useState(!1),[o,d]=l.useState(null),[c,x]=l.useState(null),m=Il(Ss(g=>({info:g.info,checking:g.checking,available:g.available,error:g.error,downloading:g.downloading,downloaded:g.downloaded,progress:g.progress,runtimeType:g.runtimeType,checkForUpdates:g.checkForUpdates,downloadUpdate:g.downloadUpdate,restartToUpdate:g.restartToUpdate}))),{isMobile:p}=Cs(),u=o||m.info?.currentVersion||"unknown";l.useEffect(()=>{let g=!1;return(async()=>{try{const D=await yt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const k=await D.json().catch(()=>null),w=typeof k?.openchamberVersion=="string"&&k.openchamberVersion.trim().length>0?k.openchamberVersion.trim():null;g||d(w)}catch{g||d(null)}})(),()=>{g=!0}},[]),l.useEffect(()=>{let g=!1;return(async()=>{try{const D=await yt("/api/opencode/upgrade-status",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const k=await D.json().catch(()=>null),w=typeof k?.currentVersion=="string"&&k.currentVersion.trim().length>0?k.currentVersion.trim():null;g||x(w)}catch{g||x(null)}})(),()=>{g=!0}},[]);const C=l.useRef(!1);l.useEffect(()=>{if(m.checking)i(!0),C.current=!0;else if(r){const g=setTimeout(()=>{i(!1),C.current&&!m.available&&!m.error&&(_.success(e("settings.openchamber.about.toast.latestVersion")),C.current=!1)},Cu);return()=>clearTimeout(g)}},[e,m.checking,r,m.available,m.error]);const f=m.checking||r;return p?t.jsxs("div",{className:"w-full space-y-6 pb-2",children:[t.jsxs("div",{className:"flex flex-col items-center text-center",children:[t.jsx(gl,{width:72,height:72}),t.jsx("h2",{className:"mt-4 typography-ui-header font-semibold text-foreground",children:"OpenChamber"}),t.jsxs("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:[t.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:u})}),t.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:c||e("settings.openchamber.about.state.unknown")})})]})]}),t.jsxs("div",{className:"flex justify-center",children:[!m.available&&!m.error&&t.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>m.checkForUpdates(),disabled:f,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[f?t.jsx(A,{name:"loader",className:"size-4 animate-spin"}):t.jsx(A,{name:"refresh",className:"size-4"}),e(f?"settings.openchamber.about.state.checking":"settings.openchamber.about.actions.checkForUpdates")]}),!f&&m.available&&t.jsxs(J,{type:"button",variant:"default",size:"sm",onClick:()=>a(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[t.jsx(A,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]})]}),m.error&&t.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}),t.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[t.jsxs("div",{className:"flex items-center justify-center gap-5",children:[t.jsxs("a",{href:Ki,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[t.jsx(A,{name:"github-fill",className:"size-5"}),t.jsx("span",{children:"GitHub"})]}),t.jsxs("a",{href:Su,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[t.jsx(A,{name:"discord-fill",className:"size-5"}),t.jsx("span",{children:"Discord"})]})]}),t.jsxs("a",{href:$i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[t.jsx(A,{name:"twitter-xfill",className:"size-5"}),t.jsx("span",{children:"@openchamber_dev"})]})]}),t.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),t.jsx(zi,{open:n,onOpenChange:a,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]}):t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-3 px-1",children:t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:e("settings.openchamber.about.title")})}),t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 px-4 py-3 border-b border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.openchamber.about.field.version")}),t.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:u})]}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.openchamber.about.field.openCodeVersion")}),t.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:c||e("settings.openchamber.about.state.unknown")})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[m.checking&&t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(A,{name:"loader",className:"h-4 w-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!m.checking&&m.available&&t.jsxs(J,{size:"sm",variant:"default",onClick:()=>a(!0),children:[t.jsx(A,{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&&t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),t.jsx(J,{size:"sm",variant:"outline",onClick:()=>m.checkForUpdates(),disabled:m.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),m.error&&t.jsx("div",{className:"px-3 py-2 border-b border-[var(--surface-subtle)]",children:t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:m.error})}),t.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[t.jsxs("a",{href:Ki,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[t.jsx(A,{name:"github-fill",className:"h-4 w-4"}),t.jsx("span",{children:"GitHub"})]}),t.jsxs("a",{href:$i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[t.jsx(A,{name:"twitter-xfill",className:"h-4 w-4"}),t.jsx("span",{children:"@openchamber_dev"})]})]})]}),t.jsx(zi,{open:n,onOpenChange:a,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]})},Mv=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),Pu=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Iu=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Du=s=>!s||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),Bn="opencode-update-available",ca="opencode-upgrade-progress",Au=5e3,Eu=[1e4,6e4],Bi="opencode-update-toast-dismissed-version",Rv=()=>{const{t:s}=dt(),e=Ke(o=>o.showOpenCodeUpdateNotifications),n=ve.useRef(new Set),a=ve.useRef(!1);ve.useEffect(()=>{e||_.dismiss(Bn)},[e]);const r=ve.useCallback(()=>{_.dismiss(ca),Dn({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),i=ve.useCallback(async()=>{if(!a.current){a.current=!0,_.dismiss(Bn),_.message(s("opencodeUpdate.toast.upgrading.title"),{id:ca,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(A,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const o=await yt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),d=await o.json().catch(()=>null);if(!o.ok||d?.success===!1)throw new Error(d?.error||o.statusText||s("opencodeUpdate.toast.failed.description"));_.success(s("opencodeUpdate.toast.updated.title"),{id:ca,description:d?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:d.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(A,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:r}})}catch(o){_.error(s("opencodeUpdate.toast.failed.title"),{id:ca,description:o instanceof Error?o.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{a.current=!1}}},[r,s]);return ve.useEffect(()=>{const o=p=>{if(!Ke.getState().showOpenCodeUpdateNotifications){_.dismiss(Bn);return}Pu({version:p,dismissedVersion:Zn().getItem(Bi),seenVersions:n.current})&&(n.current.add(p),_.info(s("opencodeUpdate.toast.available.title"),{id:Bn,description:s("opencodeUpdate.toast.available.description",{version:p}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:i},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Zn().setItem(Bi,p),Ct({openCodeUpdateToastDismissedVersion:p}),_.dismiss(Bn)}}}))},d=p=>{const u=Iu(p.detail);o(u)};let c=!1;const x=[],m=async p=>{try{const u=await yt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!u.ok)throw new Error(u.statusText||"OpenCode upgrade status check failed");const C=await u.json().catch(()=>null),f=Du(C);!c&&f&&o(f)}catch{const u=Eu[p];!c&&u!==void 0&&x.push(setTimeout(()=>{m(p+1)},u))}};return e&&x.push(setTimeout(()=>{m(0)},Au)),window.addEventListener("openchamber:opencode-update-available",d),()=>{c=!0;for(const p of x)clearTimeout(p);window.removeEventListener("openchamber:opencode-update-available",d)}},[i,e,s]),null},Tv=()=>{const s=rt.c(3),[e,n]=l.useState(Mu),{isUpdating:a}=e;let r,i;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>md(n),i=[],s[0]=r,s[1]=i):(r=s[0],i=s[1]),l.useEffect(r,i),!a)return null;let o;return s[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(gl,{width:80,height:80,isAnimated:!0})}),s[2]=o):o=s[2],o};function Mu(){return dd()}class Ru extends l.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(ud,{className:"w-full max-w-md",children:[t.jsx(pd,{className:"text-center",children:t.jsxs(gd,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(A,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(hd,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(J,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(A,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function Tu(s){const e=rt.c(22),{t:n}=dt();let a;e[0]!==n?(a=n("chat.errorBoundary.title"),e[0]=n,e[1]=a):a=e[1];let r;e[2]!==n?(r=n("chat.errorBoundary.description"),e[2]=n,e[3]=r):r=e[3];let i;e[4]!==n?(i=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=i):i=e[5];let o;e[6]!==n?(o=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=o):o=e[7];let d;e[8]!==n?(d=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=d):d=e[9];let c;e[10]!==n?(c=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=c):c=e[11];let x;e[12]!==a||e[13]!==r||e[14]!==i||e[15]!==o||e[16]!==d||e[17]!==c?(x={title:a,description:r,sessionLabel:i,detailsSummary:o,resetAction:d,persistentHint:c},e[12]=a,e[13]=r,e[14]=i,e[15]=o,e[16]=d,e[17]=c,e[18]=x):x=e[18];let m;return e[19]!==s||e[20]!==x?(m=t.jsx(Ru,{...s,texts:x}),e[19]=s,e[20]=x,e[21]=m):m=e[21],m}const Fv=s=>{const e=rt.c(5),{readOnly:n}=s,a=n===void 0?!1:n,i=Is(Fu)||void 0;let o;e[0]!==a?(o=t.jsx(fd,{readOnly:a}),e[0]=a,e[1]=o):o=e[1];let d;return e[2]!==i||e[3]!==o?(d=t.jsx(Tu,{sessionId:i,children:o}),e[2]=i,e[3]=o,e[4]=d):d=e[4],d};function Fu(s){return s.currentSessionId}function en(s){const e=rt.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let a;return e[2]!==n?(a=t.jsx(bc,{...n}),e[2]=n,e[3]=a):a=e[3],a}function tn(s){const e=rt.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let a;return e[2]!==n?(a=t.jsx(yc,{...n}),e[2]=n,e[3]=a):a=e[3],a}function sn(s){const e=rt.c(20);let n,a,r,i,o;e[0]!==s?({className:a,positionerClassName:r,children:n,style:o,...i}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=r,e[4]=i,e[5]=o):(n=e[1],a=e[2],r=e[3],i=e[4],o=e[5]);let d;e[6]!==r?(d=ce("app-region-no-drag z-50",r),e[6]=r,e[7]=d):d=e[7];let c;e[8]!==o?(c={backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)",...o},e[8]=o,e[9]=c):c=e[9];let x;e[10]!==a?(x=ce(xd,a),e[10]=a,e[11]=x):x=e[11];let m;e[12]!==n||e[13]!==i||e[14]!==c||e[15]!==x?(m=t.jsx(vc,{"data-slot":"dropdown-menu-content",style:c,className:x,...i,children:n}),e[12]=n,e[13]=i,e[14]=c,e[15]=x,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=t.jsx(wc,{children:t.jsx(Nc,{className:d,children:m})}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}function qs(s){const e=rt.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=ce(bd,n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(jc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i}function Ov(s){const e=rt.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=ce(yd,n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(kc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i}const Al=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),na=s=>{const e=rt.c(39),{className:n}=s,{t:a}=dt(),r=is(Ou),i=is(Lu),o=is(zu),d=fs();let c;e[0]!==r?(c=[...r].sort(Ku),e[0]=r,e[1]=c):c=e[1];const x=c;let m;e:{if(x.length===0){m=null;break e}let O;e[2]!==i||e[3]!==x?(O=x.find(T=>T.id===i)??x[0],e[2]=i,e[3]=x,e[4]=O):O=e[4],m=O}const p=m;if(d||x.length===0)return null;let u;e[5]!==p||e[6]!==a?(u=p?.label&&p.label.trim().length>0?p.label:p?.path.split("/").filter(Boolean).pop()||p?.path||a("settings.shared.projectSelector.fallbackProject"),e[5]=p,e[6]=a,e[7]=u):u=e[7];const C=u;let f;e[8]!==C?(f=Al(C),e[8]=C,e[9]=f):f=e[9];const g=f;let h;e[10]!==n?(h=ce(n),e[10]=n,e[11]=h):h=e[11];let D;e[12]!==a?(D=a("settings.shared.projectSelector.switchProjectAria"),e[12]=a,e[13]=D):D=e[13];let k;e[14]!==a?(k=a("settings.shared.projectSelector.switchProjectTitle"),e[14]=a,e[15]=k):k=e[15];let w,E;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=ce("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"),E=t.jsx(A,{name:"folder",className:"h-4 w-4 opacity-70"}),e[16]=w,e[17]=E):(w=e[16],E=e[17]);let N;e[18]!==g?(N=t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:g}),e[18]=g,e[19]=N):N=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[20]=y):y=e[20];let b;e[21]!==N||e[22]!==D||e[23]!==k?(b=t.jsx(us,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":D,title:k,className:w,children:[E,N,y]})}),e[21]=N,e[22]=D,e[23]=k,e[24]=b):b=e[24];const P=p?.id??"";let z;e[25]!==o?(z=O=>{O&&o(O)},e[25]=o,e[26]=z):z=e[26];let M;e[27]!==x?(M=x.map($u),e[27]=x,e[28]=M):M=e[28];let I;e[29]!==P||e[30]!==z||e[31]!==M?(I=t.jsx(ps,{align:"start",className:"w-auto",children:t.jsx(jd,{value:P,onValueChange:z,children:M})}),e[29]=P,e[30]=z,e[31]=M,e[32]=I):I=e[32];let v;e[33]!==b||e[34]!==I?(v=t.jsxs(gs,{children:[b,I]}),e[33]=b,e[34]=I,e[35]=v):v=e[35];let j;return e[36]!==v||e[37]!==h?(j=t.jsx("div",{className:h,children:v}),e[36]=v,e[37]=h,e[38]=j):j=e[38],j};function Ou(s){return s.projects}function Lu(s){return s.activeProjectId}function zu(s){return s.setActiveProject}function Ku(s,e){return(s.label||s.path).localeCompare(e.label||e.path)}function $u(s){const e=s.label?.trim()?s.label.trim():s.path.split("/").filter(Boolean).pop()||s.path,n=Al(e);return t.jsx(vd,{value:s.id,children:t.jsx("span",{className:"min-w-0 truncate typography-ui",children:n})},s.id)}function Bu(s,e){return`opencode:sidebar-group:${s}:${e}`}const Er=s=>{const e=rt.c(33),{label:n,count:a,storageKey:r,defaultExpanded:i,children:o}=s,d=i===void 0?!0:i;let c;e[0]!==n||e[1]!==r?(c=Bu(r,n),e[0]=n,e[1]=r,e[2]=c):c=e[2];const x=c,m=l.useId();let p;e[3]!==d||e[4]!==x?(p=()=>{try{const I=localStorage.getItem(x);if(I!==null)return I==="true"}catch{}return d},e[3]=d,e[4]=x,e[5]=p):p=e[5];const[u,C]=ve.useState(p);let f,g;e[6]!==u||e[7]!==x?(f=()=>{try{localStorage.setItem(x,String(u))}catch{}},g=[x,u],e[6]=u,e[7]=x,e[8]=f,e[9]=g):(f=e[8],g=e[9]),ve.useEffect(f,g);let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>C(Uu),e[10]=h):h=e[10];let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=ce("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]=D):D=e[11];const k=!u&&"-rotate-90";let w;e[12]!==k?(w=ce("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",k),e[12]=k,e[13]=w):w=e[13];let E;e[14]!==w?(E=t.jsx(A,{name:"arrow-down-s",className:w}),e[14]=w,e[15]=E):E=e[15];let N;e[16]!==n?(N=t.jsx("span",{className:"flex-1 truncate",children:n}),e[16]=n,e[17]=N):N=e[17];let y;e[18]!==a?(y=t.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=y):y=e[19];let b;e[20]!==m||e[21]!==u||e[22]!==E||e[23]!==N||e[24]!==y?(b=t.jsxs("button",{type:"button",onClick:h,"aria-expanded":u,"aria-controls":m,className:D,children:[E,N,y]}),e[20]=m,e[21]=u,e[22]=E,e[23]=N,e[24]=y,e[25]=b):b=e[25];const P=!u;let z;e[26]!==o||e[27]!==m||e[28]!==P?(z=t.jsx("div",{id:m,hidden:P,className:"mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]",children:o}),e[26]=o,e[27]=m,e[28]=P,e[29]=z):z=e[29];let M;return e[30]!==b||e[31]!==z?(M=t.jsxs("div",{children:[b,z]}),e[30]=b,e[31]=z,e[32]=M):M=e[32],M};function Uu(s){return!s}const Vu=s=>{if(!Array.isArray(s))return[];const e=[];for(const n of s){if(!n||typeof n!="object")continue;const a=n;typeof a.permission!="string"||typeof a.pattern!="string"||typeof a.action!="string"||a.action!=="allow"&&a.action!=="ask"&&a.action!=="deny"||e.push({permission:a.permission,pattern:a.pattern,action:a.action})}return e},_u=s=>{const e=new Map;for(const n of s)!n.permission||n.permission==="invalid"||n.pattern&&e.set(`${n.permission}::${n.pattern}`,n);return Array.from(e.values())},Ui=s=>{const e=_u(Vu(s));if(e.length===0)return;const n={};for(const r of e)r.permission&&((n[r.permission]||={})[r.pattern]=r.action);const a={};for(const[r,i]of Object.entries(n)){const o=Object.keys(i);if(o.length===1&&o[0]==="*"){a[r]=i["*"];continue}a[r]=i}return Object.keys(a).length>0?a:void 0},Hu=({onItemSelect:s})=>{const{t:e}=dt(),[n,a]=l.useState(null),[r,i]=l.useState(""),[o,d]=l.useState(null),[c,x]=l.useState(null),[m,p]=l.useState(!1),[u,C]=l.useState(null),{selectedAgentName:f,agents:g,setSelectedAgent:h,setAgentDraft:D,createAgent:k,deleteAgent:w,loadAgents:E}=$a(Ss(R=>({selectedAgentName:R.selectedAgentName,agents:R.agents,setSelectedAgent:R.setSelectedAgent,setAgentDraft:R.setAgentDraft,createAgent:R.createAgent,deleteAgent:R.deleteAgent,loadAgents:R.loadAgents})));l.useEffect(()=>{E()},[E]);const N="bg-background",y=()=>{const R="new-agent";let Y=R,F=1;for(;g.some(W=>W.name===Y);)Y=`${R}-${F}`,F++;D({name:Y,scope:"user"}),h(Y),s?.()},b=async R=>{if(Sn(R)){_.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(R),x("delete")},P=async R=>{Sn(R)&&(d(R),x("reset"))},z=()=>{d(null),x(null)},M=async()=>{if(!(!o||!c)){p(!0);try{const R=await w(o.name,o.scope);R.ok?(R.requiresManualRestart?_.warning(e("settings.agents.page.toast.savedManualRestart")):c==="delete"?_.success(e("settings.agents.sidebar.toast.agentDeleted",{name:o.name})):_.success(e("settings.agents.sidebar.toast.agentReset",{name:o.name})),z()):c==="delete"?_.error(e("settings.agents.sidebar.toast.deleteFailed")):_.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(R){const Y=R instanceof Error?R.message:"",F=/built-in|not deletable|not found/i.test(Y);c==="delete"?_.error(e(F?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):_.error(e("settings.agents.sidebar.toast.resetFailed"))}p(!1)}},I=R=>{const Y=R.name;let F=1,W=`${Y}-copy`;for(;g.some(de=>de.name===W);)F++,W=`${Y}-copy-${F}`;const X=R,re=R.model?.providerID&&R.model?.modelID?`${R.model.providerID}/${R.model.modelID}`:null,Z=R;D({name:W,scope:X.scope||"user",description:R.description,model:re,variant:R.variant,temperature:R.temperature,top_p:R.topP,prompt:R.prompt,mode:R.mode,permission:Ui(R.permission),disable:Z.disable}),h(W)},v=R=>{i(R.name),a(R)},j=async()=>{if(!n)return;const R=r.trim().replace(/\s+/g,"-");if(!R){_.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(R===n.name){a(null);return}if(g.some(X=>X.name===R)){_.error(e("settings.agents.sidebar.toast.agentExists"));return}const Y=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,F=n,W=await k({name:R,description:n.description,model:Y,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:Ui(n.permission),disable:F.disable,scope:F.scope});if(W.ok){const X=await w(n.name,F.scope);X.ok?(W.requiresManualRestart||X.requiresManualRestart?_.warning(e("settings.agents.page.toast.savedManualRestart")):_.success(e("settings.agents.sidebar.toast.agentRenamed",{name:R})),h(R)):_.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed"))}else _.error(e("settings.agents.sidebar.toast.renameFailed"));a(null)},O=R=>{switch(R){case"primary":return t.jsx(A,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return t.jsx(A,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return t.jsx(A,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},T=g.filter(R=>!wd(R)),B=T.filter(Sn),U=T.filter(R=>!Sn(R)),{groupedCustomAgents:Q,ungroupedCustomAgents:q}=ve.useMemo(()=>{const R={},Y=[];for(const W of U){const X=W;X.group?(R[X.group]||(R[X.group]=[]),R[X.group].push(W)):Y.push(W)}return{groupedCustomAgents:Object.keys(R).sort((W,X)=>W.localeCompare(X)).map(W=>({name:W,agents:R[W]})),ungroupedCustomAgents:Y}},[U]);return t.jsxs("div",{className:ce("flex h-full flex-col",N),children:[t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:e("settings.agents.sidebar.title")}),t.jsx(na,{className:"mb-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:T.length})}),t.jsx(J,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:y,children:t.jsx(A,{name:"add",className:"h-3.5 w-3.5"})})]})]}),t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:T.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[B.length>0&&t.jsxs(t.Fragment,{children:[t.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")}),B.map(R=>t.jsx(nr,{agent:R,isSelected:f===R.name,onSelect:()=>{h(R.name),s?.()},onReset:()=>P(R),onDuplicate:()=>I(R),getAgentModeIcon:O,isMenuOpen:u===R.name,onMenuOpenChange:Y=>C(Y?R.name:null)},R.name))]}),U.length>0&&t.jsxs(t.Fragment,{children:[t.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")}),Q.map(({name:R,agents:Y})=>t.jsx(Er,{label:R,count:Y.length,storageKey:"agents",children:Y.map(F=>t.jsx(nr,{agent:F,isSelected:f===F.name,onSelect:()=>{h(F.name),s?.()},onRename:()=>v(F),onDelete:()=>b(F),onDuplicate:()=>I(F),getAgentModeIcon:O,isMenuOpen:u===F.name,onMenuOpenChange:W=>C(W?F.name:null)},F.name))},R)),q.map(R=>t.jsx(nr,{agent:R,isSelected:f===R.name,onSelect:()=>{h(R.name),s?.()},onRename:()=>v(R),onDelete:()=>b(R),onDuplicate:()=>I(R),getAgentModeIcon:O,isMenuOpen:u===R.name,onMenuOpenChange:Y=>C(Y?R.name:null)},R.name))]})]})}),t.jsx($t,{open:o!==null&&c!==null,onOpenChange:R=>{!R&&!m&&z()},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:e(c==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),t.jsx(Wt,{children:c==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:o?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:o?.name??""})})]}),t.jsxs(Yt,{children:[t.jsx(J,{size:"sm",variant:"ghost",onClick:z,disabled:m,children:e("settings.common.actions.cancel")}),t.jsx(J,{size:"sm",onClick:M,disabled:m,children:e(c==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),t.jsx($t,{open:n!==null,onOpenChange:R=>!R&&a(null),children:t.jsxs(Bt,{children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:e("settings.agents.sidebar.renameDialog.title")}),t.jsx(Wt,{children:e("settings.agents.sidebar.renameDialog.description",{name:n?.name??""})})]}),t.jsx(ot,{value:r,onChange:R=>i(R.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:R=>{R.key==="Enter"&&j()}}),t.jsxs(Yt,{children:[t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>a(null),children:e("settings.common.actions.cancel")}),t.jsx(J,{size:"sm",onClick:j,children:e("settings.common.actions.rename")})]})]})})]})},nr=s=>{const e=rt.c(52),{agent:n,isSelected:a,onSelect:r,onDelete:i,onReset:o,onRename:d,onDuplicate:c,getAgentModeIcon:x,isMenuOpen:m,onMenuOpenChange:p}=s,{t:u}=dt(),C=n;let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=Xn(),e[0]=f):f=e[0];const g=f,[h,D]=l.useState(!1);let k;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==o||e[5]!==u?(k=F=>t.jsxs(t.Fragment,{children:[d&&t.jsxs(F,{onClick:W=>{W.stopPropagation(),d()},children:[t.jsx(A,{name:"edit",className:"h-4 w-4 mr-px"}),u("settings.common.actions.rename")]}),t.jsxs(F,{onClick:W=>{W.stopPropagation(),c()},children:[t.jsx(A,{name:"file-copy",className:"h-4 w-4 mr-px"}),u("settings.common.actions.duplicate")]}),o&&t.jsxs(F,{onClick:W=>{W.stopPropagation(),o()},children:[t.jsx(A,{name:"restart",className:"h-4 w-4 mr-px"}),u("settings.common.actions.reset")]}),i&&t.jsxs(F,{onClick:W=>{W.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),u("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=o,e[5]=u,e[6]=k):k=e[6];const w=k,E=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==E?(N=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",E),e[7]=E,e[8]=N):N=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=g?void 0:F=>{F.preventDefault(),D(!0)},e[9]=y):y=e[9];let b;e[10]!==N?(b=t.jsx("div",{className:N,onContextMenu:y}),e[10]=N,e[11]=b):b=e[11];let P;e[12]!==n.name?(P=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=P):P=e[13];let z;e[14]!==n.mode||e[15]!==x?(z=x(n.mode),e[14]=n.mode,e[15]=x,e[16]=z):z=e[16];let M;e[17]!==n||e[18]!==C.scope||e[19]!==u?(M=(C.scope||Sn(n))&&t.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:Sn(n)?u("settings.agents.sidebar.badge.system"):C.scope}),e[17]=n,e[18]=C.scope,e[19]=u,e[20]=M):M=e[20];let I;e[21]!==P||e[22]!==z||e[23]!==M?(I=t.jsxs("div",{className:"flex items-center gap-1.5",children:[P,z,M]}),e[21]=P,e[22]=z,e[23]=M,e[24]=I):I=e[24];let v;e[25]!==n.description?(v=n.description&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n.description}),e[25]=n.description,e[26]=v):v=e[26];let j;e[27]!==r||e[28]!==I||e[29]!==v?(j=t.jsxs("button",{onClick:r,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:[I,v]}),e[27]=r,e[28]=I,e[29]=v,e[30]=j):j=e[30];let O;e[31]!==p?(O=F=>{F&&D(!1),p(F)},e[31]=p,e[32]=O):O=e[32];let T;e[33]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(us,{asChild:!0,children:t.jsx(J,{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:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=T):T=e[33];let B;e[34]!==w?(B=t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:w(vs)}),e[34]=w,e[35]=B):B=e[35];let U;e[36]!==m||e[37]!==O||e[38]!==B?(U=t.jsxs(gs,{open:m,onOpenChange:O,children:[T,B]}),e[36]=m,e[37]=O,e[38]=B,e[39]=U):U=e[39];let Q;e[40]!==j||e[41]!==U?(Q=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[j,U]}),e[40]=j,e[41]=U,e[42]=Q):Q=e[42];let q;e[43]!==Q||e[44]!==b?(q=t.jsx(tn,{render:b,children:Q}),e[43]=Q,e[44]=b,e[45]=q):q=e[45];let R;e[46]!==w?(R=t.jsx(sn,{className:"w-fit min-w-20",children:w(qs)}),e[46]=w,e[47]=R):R=e[47];let Y;return e[48]!==h||e[49]!==q||e[50]!==R?(Y=t.jsxs(en,{open:h,onOpenChange:D,children:[q,R]}),e[48]=h,e[49]=q,e[50]=R,e[51]=Y):Y=e[51],Y};function Vi(s,e,n){return Math.min(n,Math.max(e,s))}function Wu(s){if(!Number.isFinite(s))return 0;const e=String(s);if(e.includes("e-")){const[,a]=e.split("e-");return Number(a)||0}const n=e.split(".");return n.length===2?n[1].length:0}function _i(s,e){const n=Wu(e);return n<=0?s:Number(s.toFixed(n))}const bs=ve.forwardRef((s,e)=>{const n=rt.c(125);let a,r,i,o,d,c,x,m,p,u,C,f,g;n[0]!==s?({value:g,onValueChange:x,min:p,max:u,step:C,className:a,containerClassName:r,onBlur:d,disabled:i,fallbackValue:o,onClear:c,emptyLabel:f,...m}=s,n[0]=s,n[1]=a,n[2]=r,n[3]=i,n[4]=o,n[5]=d,n[6]=c,n[7]=x,n[8]=m,n[9]=p,n[10]=u,n[11]=C,n[12]=f,n[13]=g):(a=n[1],r=n[2],i=n[3],o=n[4],d=n[5],c=n[6],x=n[7],m=n[8],p=n[9],u=n[10],C=n[11],f=n[12],g=n[13]);const h=p===void 0?-1/0:p,D=u===void 0?1/0:u,k=C===void 0?1:C,w=f===void 0?"—":f,{t:E}=dt();let N;n[14]!==g?(N=()=>g===void 0?"":String(g),n[14]=g,n[15]=N):N=n[15];const[y,b]=ve.useState(N),{isMobile:P}=Cs(),z=ve.useRef(!1),M=ve.useRef(null);let I;n[16]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{if(typeof document>"u"||typeof window>"u")return;M.current?.();const Ae=Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Fe.stopImmediatePropagation?.(),M.current?.()},Pe=window.setTimeout(()=>{M.current?.()},700),Te=()=>{window.clearTimeout(Pe),document.removeEventListener("click",Ae,!0),M.current=null};M.current=Te,document.addEventListener("click",Ae,!0)},n[16]=I):I=n[16];const v=I;let j,O;n[17]===Symbol.for("react.memo_cache_sentinel")?(j=()=>()=>{M.current?.()},O=[],n[17]=j,n[18]=O):(j=n[17],O=n[18]),ve.useEffect(j,O);let T,B;n[19]!==g?(B=()=>{b(g===void 0?"":String(g))},T=[g],n[19]=g,n[20]=T,n[21]=B):(T=n[20],B=n[21]),ve.useEffect(B,T);let U;e:{if(g!==void 0){U=g;break e}if(o!==void 0){U=o;break e}if(Number.isFinite(h)){U=h;break e}U=0}const Q=U;let q;n[22]!==D||n[23]!==h||n[24]!==x||n[25]!==k?(q=Ae=>{const Pe=Vi(Ae,h,D);x(_i(Pe,k))},n[22]=D,n[23]=h,n[24]=x,n[25]=k,n[26]=q):q=n[26];const R=q;let Y;n[27]!==R||n[28]!==c?(Y=Ae=>{const Pe=Ae.target.value;if(b(Pe),Pe.trim()===""){c?.();return}const Te=Number(Pe);Number.isFinite(Te)&&R(Te)},n[27]=R,n[28]=c,n[29]=Y):Y=n[29];const F=Y;let W;n[30]!==y||n[31]!==D||n[32]!==h||n[33]!==d||n[34]!==c||n[35]!==x||n[36]!==k||n[37]!==g?(W=Ae=>{if(y.trim()===""){c||b(g===void 0?"":String(g)),d?.(Ae);return}const Pe=Number(y);if(!Number.isFinite(Pe))b(g===void 0?"":String(g));else{const Te=Vi(Pe,h,D),Fe=_i(Te,k);Fe!==g&&x(Fe),b(String(Fe))}d?.(Ae)},n[30]=y,n[31]=D,n[32]=h,n[33]=d,n[34]=c,n[35]=x,n[36]=k,n[37]=g,n[38]=W):W=n[38];const X=W,re=!!(i||Q>=D),Z=!!(i||Q<=h);let de;n[39]!==Q||n[40]!==R||n[41]!==Z||n[42]!==k?(de=()=>{Z||R(Q-k)},n[39]=Q,n[40]=R,n[41]=Z,n[42]=k,n[43]=de):de=n[43];const le=de;let ee;n[44]!==Q||n[45]!==R||n[46]!==re||n[47]!==k?(ee=()=>{re||R(Q+k)},n[44]=Q,n[45]=R,n[46]=re,n[47]=k,n[48]=ee):ee=n[48];const xe=ee;let we;if(n[49]!==a||n[50]!==r||n[51]!==Z||n[52]!==y||n[53]!==w||n[54]!==le||n[55]!==xe||n[56]!==re||n[57]!==P||n[58]!==E||n[59]!==g){we=Symbol.for("react.early_return_sentinel");e:{const Ae=Te=>Fe=>{Fe.preventDefault(),Fe.stopPropagation(),z.current=!0,v(),Te()},Pe=Te=>Fe=>{if(z.current){z.current=!1,Fe.preventDefault(),Fe.stopPropagation();return}Te()};if(P){let Te;n[61]!==r?(Te=ce("flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain","[-webkit-user-select:none] [-webkit-touch-callout:none]","disabled:pointer-events-none disabled:opacity-50",r),n[61]=r,n[62]=Te):Te=n[62];let Fe;n[63]!==E?(Fe=E("numberInput.actions.decreaseAria"),n[63]=E,n[64]=Fe):Fe=n[64];const Be=Ae(le),We=Pe(le),ze=!Z&&"active:bg-interactive-hover";let Qe;n[65]!==ze?(Qe=ce("grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none","text-muted-foreground","disabled:pointer-events-none disabled:opacity-50",ze),n[65]=ze,n[66]=Qe):Qe=n[66];let oe;n[67]===Symbol.for("react.memo_cache_sentinel")?(oe=t.jsx(A,{name:"subtract",className:"block h-4 w-4"}),n[67]=oe):oe=n[67];const H=t.jsx("button",{type:"button","aria-label":Fe,disabled:Z,onTouchStart:Be,onClick:We,className:Qe,children:oe});let me;n[68]!==a?(me=ce("flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5","text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]",a),n[68]=a,n[69]=me):me=n[69];const Ne=g===void 0?w:y;let Ee;n[70]!==me||n[71]!==Ne?(Ee=t.jsx("div",{className:me,"aria-live":"polite",children:Ne}),n[70]=me,n[71]=Ne,n[72]=Ee):Ee=n[72];let Ce;n[73]!==E?(Ce=E("numberInput.actions.increaseAria"),n[73]=E,n[74]=Ce):Ce=n[74];const _e=Ae(xe),G=Pe(xe),$=!re&&"active:bg-interactive-hover";let fe;n[75]!==$?(fe=ce("grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none","text-muted-foreground","disabled:pointer-events-none disabled:opacity-50",$),n[75]=$,n[76]=fe):fe=n[76];let L;n[77]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(A,{name:"add",className:"block h-4 w-4"}),n[77]=L):L=n[77];const Le=t.jsx("button",{type:"button","aria-label":Ce,disabled:re,onTouchStart:_e,onClick:G,className:fe,children:L});let Je;n[78]!==Te||n[79]!==H||n[80]!==Ee||n[81]!==Le?(Je=t.jsxs("div",{className:Te,children:[H,Ee,Le]}),n[78]=Te,n[79]=H,n[80]=Ee,n[81]=Le,n[82]=Je):Je=n[82],we=Je;break e}}n[49]=a,n[50]=r,n[51]=Z,n[52]=y,n[53]=w,n[54]=le,n[55]=xe,n[56]=re,n[57]=P,n[58]=E,n[59]=g,n[60]=we}else we=n[60];if(we!==Symbol.for("react.early_return_sentinel"))return we;let he;n[83]!==r?(he=ce("flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent","disabled:pointer-events-none disabled:opacity-50",r),n[83]=r,n[84]=he):he=n[84];let Ie;n[85]!==E?(Ie=E("numberInput.actions.decreaseAria"),n[85]=E,n[86]=Ie):Ie=n[86];let be;n[87]!==Q||n[88]!==R||n[89]!==k?(be=()=>R(Q-k),n[87]=Q,n[88]=R,n[89]=k,n[90]=be):be=n[90];let je,ye;n[91]===Symbol.for("react.memo_cache_sentinel")?(je=ce("flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation","text-muted-foreground hover:bg-interactive-hover hover:text-foreground","disabled:pointer-events-none disabled:opacity-50"),ye=t.jsx(A,{name:"subtract",className:"block h-3.5 w-3.5"}),n[91]=je,n[92]=ye):(je=n[91],ye=n[92]);let se;n[93]!==Z||n[94]!==Ie||n[95]!==be?(se=t.jsx("button",{type:"button","aria-label":Ie,disabled:Z,onClick:be,className:je,children:ye}),n[93]=Z,n[94]=Ie,n[95]=be,n[96]=se):se=n[96];const ie=m.inputMode??"numeric";let ge;n[97]!==a?(ge=ce("h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]","placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground","appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","disabled:pointer-events-none disabled:cursor-not-allowed",a),n[97]=a,n[98]=ge):ge=n[98];let V;n[99]!==i||n[100]!==y||n[101]!==X||n[102]!==F||n[103]!==m||n[104]!==e||n[105]!==ie||n[106]!==ge?(V=t.jsx("input",{...m,ref:e,type:"text",inputMode:ie,value:y,onChange:F,onBlur:X,disabled:i,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:ge}),n[99]=i,n[100]=y,n[101]=X,n[102]=F,n[103]=m,n[104]=e,n[105]=ie,n[106]=ge,n[107]=V):V=n[107];let te;n[108]!==E?(te=E("numberInput.actions.increaseAria"),n[108]=E,n[109]=te):te=n[109];let ne;n[110]!==Q||n[111]!==R||n[112]!==k?(ne=()=>R(Q+k),n[110]=Q,n[111]=R,n[112]=k,n[113]=ne):ne=n[113];let ue,Me;n[114]===Symbol.for("react.memo_cache_sentinel")?(ue=ce("flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation","text-muted-foreground hover:bg-interactive-hover hover:text-foreground","disabled:pointer-events-none disabled:opacity-50"),Me=t.jsx(A,{name:"add",className:"block h-3.5 w-3.5"}),n[114]=ue,n[115]=Me):(ue=n[114],Me=n[115]);let ke;n[116]!==re||n[117]!==te||n[118]!==ne?(ke=t.jsx("button",{type:"button","aria-label":te,disabled:re,onClick:ne,className:ue,children:Me}),n[116]=re,n[117]=te,n[118]=ne,n[119]=ke):ke=n[119];let Re;return n[120]!==he||n[121]!==se||n[122]!==V||n[123]!==ke?(Re=t.jsxs("div",{className:he,children:[se,V,ke]}),n[120]=he,n[121]=se,n[122]=V,n[123]=ke,n[124]=Re):Re=n[124],Re});bs.displayName="NumberInput";const Hi=["*","read","edit","glob","grep","list","bash","task","skill","lsp","todoread","todowrite","webfetch","websearch","codesearch","external_directory","doom_loop","question","plan_enter","plan_exit"],Pa=s=>s==="allow"||s==="ask"||s==="deny",cn=(s,e)=>`${s}::${e}`,nn=s=>{const e=new Map;for(const n of s)!n.permission||n.permission==="invalid"||n.pattern&&Pa(n.action)&&e.set(cn(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(e.values())},da=s=>{const e=new Map;for(const n of nn(s))e.set(cn(n.permission,n.pattern),n);return e},Wi=s=>[...s].sort((e,n)=>{const a=e.permission.localeCompare(n.permission);return a!==0?a:e.pattern.localeCompare(n.pattern)}),qu=(s,e)=>{const n=Wi(nn(s)),a=Wi(nn(e));return n.length!==a.length?!1:n.every((r,i)=>{const o=a[i];return r.permission===o.permission&&r.pattern===o.pattern&&r.action===o.action})},Gu=s=>s.find(n=>n.permission==="*"&&n.pattern==="*")?.action??"allow",Ju=(s,e)=>nn(s).filter(n=>!(n.permission==="*"&&n.pattern==="*")).filter(n=>n.pattern!=="*"||n.action!==e),ar=s=>{if(Array.isArray(s))return nn(s);if(Pa(s))return[{permission:"*",pattern:"*",action:s}];if(!s||typeof s!="object"||Array.isArray(s))return[];const e=[];for(const[n,a]of Object.entries(s))if(n!=="__originalKeys"){if(Pa(a)){e.push({permission:n,pattern:"*",action:a});continue}if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,i]of Object.entries(a))Pa(i)&&e.push({permission:n,pattern:r,action:i})}return e},Qu=(s,e)=>{const n=nn(e),a={};for(const i of n)(a[i.permission]||={})[i.pattern]=i.action;const r={};for(const[i,o]of Object.entries(a))if(i!=="*"){if(Object.keys(o).length===1&&o["*"]){r[i]=o["*"];continue}r[i]=o}return Object.keys(r).length===0?s:(s!=="allow"&&(r["*"]=s),r)},Yu=(s,e)=>{const n=un(e);if(!n)return[];const r=s.find(i=>i.id===n.providerId)?.models?.find(i=>i.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Xu=()=>{const{t:s}=dt(),{isMobile:e}=Cs(),n=ut(H=>H.providers),{selectedAgentName:a,getAgentByName:r,createAgent:i,updateAgent:o,agents:d,agentDraft:c,setAgentDraft:x}=$a(Ss(H=>({selectedAgentName:H.selectedAgentName,getAgentByName:H.getAgentByName,createAgent:H.createAgent,updateAgent:H.updateAgent,agents:H.agents,agentDraft:H.agentDraft,setAgentDraft:H.setAgentDraft}))),m=a?r(a):null,p=!!(c&&c.name===a&&!m),[u,C]=l.useState(""),[f,g]=l.useState("user"),[h,D]=l.useState(""),[k,w]=l.useState("subagent"),[E,N]=l.useState(""),[y,b]=l.useState(""),[P,z]=l.useState(void 0),[M,I]=l.useState(void 0),[v,j]=l.useState(""),[O,T]=l.useState("allow"),[B,U]=l.useState([]),[Q,q]=l.useState([]),[R,Y]=l.useState(""),[F,W]=l.useState("*"),[X,re]=l.useState(!1),[Z,de]=l.useState(!1),le=l.useRef(null),ee=ys(H=>H.currentDirectory??null),[xe,we]=l.useState([]),he=l.useMemo(()=>Yu(n,E),[E,n]),Ie=he.length>0,be=l.useMemo(()=>!y||!he.includes(y)?"__default":y,[y,he]),je=Ie&&(!y||he.includes(y)),ye=Nd(H=>H.permission);l.useEffect(()=>{let H=!1;return(async()=>{const Ne=await ws.listToolIds({directory:ee});if(H)return;const Ee=new Set(["write","patch","multiedit"]),Ce=Ne.map(_e=>typeof _e=="string"?_e.trim():"").filter(Boolean).filter(_e=>_e!=="*").filter(_e=>_e!=="invalid").filter(_e=>!Ee.has(_e));we(Array.from(new Set(Ce)).sort((_e,G)=>_e.localeCompare(G)))})(),()=>{H=!0}},[ee]);const se=l.useMemo(()=>{const H=new Set;for(const me of d){const Ne=nn(ar(me.permission));for(const Ee of Ne)Ee.permission&&Ee.permission!=="*"&&Ee.permission!=="invalid"&&H.add(Ee.permission)}for(const me of Object.values(ye))for(const Ne of me){const Ee=Ne.permission?.trim();Ee&&Ee!=="invalid"&&H.add(Ee)}for(const me of xe)H.add(me);return Array.from(H).sort((me,Ne)=>me.localeCompare(Ne))},[d,ye,xe]),ie=l.useMemo(()=>da(B),[B]),ge=l.useMemo(()=>da(Q),[Q]),V=l.useCallback(H=>ge.get(cn(H,"*"))?.action,[ge]),te=l.useCallback(H=>Q.filter(me=>me.permission===H&&me.pattern!=="*").sort((me,Ne)=>me.pattern.localeCompare(Ne.pattern)),[Q]),ne=l.useMemo(()=>{const H=new Set;for(const me of Hi)H.add(me);for(const me of se)H.add(me);return Array.from(H).sort((me,Ne)=>me.localeCompare(Ne))},[se]),ue=l.useCallback(H=>{const me=H==="*"?O:V(H)??O,Ne=te(H),Ee=!1,Ce=Ne.reduce((G,$)=>(G[$.action]=(G[$.action]??0)+1,G),{allow:0,ask:0,deny:0}),_e=["allow","ask","deny"].filter(G=>Ce[G]>0).map(G=>`${Ce[G]} ${G}`).join(", ");return{defaultAction:me,patternRulesCount:Ne.length,patternSummary:_e,hasDefaultHint:Ee}},[te,V,O]),Me=l.useCallback(H=>s(H==="allow"?"settings.common.permission.allow":H==="deny"?"settings.common.permission.deny":"settings.common.permission.ask"),[s]),ke=l.useCallback(H=>H==="global"?s("settings.common.scope.global"):Me(H),[Me,s]),Re=l.useMemo(()=>{const H=new Set;for(const me of Hi)H.add(me);for(const me of se)H.add(me);return Array.from(H).sort((me,Ne)=>me.localeCompare(Ne))},[se]),Ae=l.useCallback((H,me,Ne)=>{q(Ee=>{const Ce=da(Ee);return Ce.set(cn(H,me),{permission:H,pattern:me,action:Ne}),Array.from(Ce.values())})},[]),Pe=l.useCallback((H,me)=>{q(Ne=>{const Ee=da(Ne);return Ee.delete(cn(H,me)),Array.from(Ee.values())})},[]),Te=l.useCallback((H,me)=>{const Ne=ie.get(cn(H,me));if(Ne){Ae(H,me,Ne.action);return}Pe(H,me)},[ie,Pe,Ae]),Fe=l.useCallback((H,me,Ne)=>{Ae(H,me,Ne)},[Ae]),Be=l.useCallback(H=>{T(H),q(me=>me.filter(Ne=>!(Ne.pattern==="*"&&Ne.action===H)))},[]),We=l.useCallback(H=>{const me=R.trim();if(!me){_.error(s("settings.agents.page.toast.permissionNameRequired"));return}const Ne=F.trim()||"*";if(me==="*"&&Ne==="*"){Be(H),Y(""),W("*");return}Ne==="*"&&me!=="*"&&H===O?Pe(me,"*"):Ae(me,Ne,H),Y(""),W("*")},[O,R,F,Pe,Be,s,Ae]),ze=l.useCallback(H=>H==="*"?s("settings.agents.page.permissions.defaultLabel"):H==="webfetch"?"WebFetch":H==="websearch"?"WebSearch":H==="codesearch"?"CodeSearch":H==="doom_loop"?"Doom Loop":H==="external_directory"?"External Directory":H==="todowrite"?"TodoWrite":H==="todoread"?"TodoRead":H.split(/[_-]+/g).filter(Boolean).map(me=>me.charAt(0).toUpperCase()+me.slice(1)).join(" "),[s]);l.useEffect(()=>{Y(""),W("*");const H=me=>{const Ne=nn(me),Ee=Gu(Ne),Ce=Ju(Ne,Ee);return T(Ee),U(Ce),q(Ce),{global:Ee,rules:Ce}};if(p&&c){const me=c.name||"",Ne=c.scope||"user",Ee=c.description||"",Ce=c.mode||"subagent",_e=c.model||"",G=c.variant||"",$=c.temperature??void 0,fe=c.top_p??void 0,L=c.prompt||"";C(me),g(Ne),D(Ee),w(Ce),N(_e),b(G),z($),I(fe),j(L);const Le=ar(c.permission),Je=H(Le);le.current={draftName:me,draftScope:Ne,description:Ee,mode:Ce,model:_e,variant:G,temperature:$,topP:fe,prompt:L,globalPermission:Je.global,permissionRules:Je.rules};return}if(m&&a===m.name){const me=m.description||"",Ne=m.mode||"subagent",Ee=m.model?.providerID&&m.model?.modelID?`${m.model.providerID}/${m.model.modelID}`:"",Ce=m.variant||"",_e=m.temperature,G=m.topP,$=m.prompt||"";D(me),w(Ne),N(Ee),b(Ce),z(_e),I(G),j($);const fe=H(ar(m.permission));le.current={draftName:"",draftScope:"user",description:me,mode:Ne,model:Ee,variant:Ce,temperature:_e,topP:G,prompt:$,globalPermission:fe.global,permissionRules:fe.rules}}},[c,p,m,a]);const Qe=l.useMemo(()=>{const H=le.current;return H?!!(p&&(u!==H.draftName||f!==H.draftScope)||h!==H.description||k!==H.mode||E!==H.model||y!==H.variant||P!==H.temperature||M!==H.topP||v!==H.prompt||O!==H.globalPermission||!qu(Q,H.permissionRules)):!1},[h,u,f,O,p,k,E,Q,v,P,M,y]),oe=async()=>{const H=p?u.trim().replace(/\s+/g,"-"):a?.trim();if(!H){_.error(s("settings.agents.sidebar.toast.agentNameRequired"));return}if(p&&d.some(me=>me.name===H)){_.error(s("settings.agents.sidebar.toast.agentExists"));return}de(!0);try{const me=E.trim(),Ne=y.trim(),Ee=v.trim(),Ce=Qu(O,Q),_e={name:H,description:h.trim()||void 0,mode:k,model:me===""?null:me,variant:Ne===""?null:Ne||void 0,temperature:P??null,top_p:M??null,prompt:Ee||(p?void 0:null),permission:Ce,scope:p?f:void 0};let G;p?(G=await i(_e),G.ok&&x(null)):G=await o(H,_e),G.ok?G.requiresManualRestart?_.warning(s("settings.agents.page.toast.savedManualRestart")):_.success(s(p?"settings.agents.page.toast.created":"settings.agents.page.toast.updated")):_.error(s(p?"settings.agents.page.toast.createFailed":"settings.agents.page.toast.updateFailed"))}catch(me){console.error("Error saving agent:",me);const Ne=me instanceof Error&&me.message?me.message:s("settings.agents.page.toast.saveUnexpectedError");_.error(Ne)}finally{de(!1)}};return a?t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4 flex items-center justify-between gap-4",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:p?s("settings.agents.page.title.new"):a}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:s(p?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit")})]})}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.identityRole")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[p&&t.jsxs("div",{"data-settings-item":"agents.name",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.agentName")})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"@"}),t.jsx(ot,{value:u,onChange:H=>C(H.target.value),placeholder:s("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),t.jsxs(Mt,{value:f,onValueChange:H=>g(H),children:[t.jsx(Rt,{className:"w-fit min-w-[100px]",children:t.jsx(Kt,{placeholder:s("settings.agents.page.field.scopePlaceholder")})}),t.jsxs(Tt,{align:"end",children:[t.jsx(gt,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.global")})]})}),t.jsx(gt,{value:"project",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.project")})]})})]})]})]})]}),t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.common.field.description")}),t.jsx("div",{className:"mt-1.5",children:t.jsx(hs,{value:h,onChange:H=>D(H.target.value),placeholder:s("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]}),t.jsx("div",{"data-settings-item":"agents.mode",className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.mode")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.modeTooltip")})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(J,{variant:"chip",size:"xs","aria-pressed":k==="primary",onClick:()=>w("primary"),className:"!font-normal",children:s("settings.agents.page.mode.primary")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":k==="subagent",onClick:()=>w("subagent"),className:"!font-normal",children:s("settings.agents.page.mode.subagent")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":k==="all",onClick:()=>w("all"),className:"!font-normal",children:s("settings.agents.page.mode.all")})]})]})})]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.modelParameters")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{"data-settings-item":"agents.model",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.overrideModel")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(Hr,{providerId:un(E)?.providerId??"",modelId:un(E)?.modelId??"",onChange:(H,me)=>{N(H&&me?`${H}/${me}`:""),b("")}})})]}),t.jsxs("div",{"data-settings-item":"agents.variant",className:ce("py-1.5",e?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsxs("div",{className:ce("flex min-w-0 flex-col",e?"w-full":"sm:w-56 shrink-0"),children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.variant")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.variantTooltip")})]})]}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.agents.page.field.variantHint")})]}),t.jsx("div",{className:ce("flex items-center gap-2",e?"w-full":"w-fit"),children:je?t.jsxs(Mt,{value:be,onValueChange:H=>b(H==="__default"?"":H),children:[t.jsx(Rt,{className:ce("max-w-full",e?"w-full":"w-fit min-w-[10rem]"),children:t.jsx(Kt,{placeholder:s("settings.agents.page.field.variantPlaceholder"),children:H=>H==="__default"?s("chat.modelControls.default"):H})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"__default",children:s("chat.modelControls.default")}),he.map(H=>t.jsx(gt,{value:H,children:H},H))]})]}):t.jsxs(t.Fragment,{children:[t.jsx(ot,{value:y,onChange:H=>b(H.target.value),placeholder:s("settings.agents.page.field.variantPlaceholder"),disabled:!E&&!y,className:ce("h-7 w-40",e&&"w-full")}),y&&t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>b(""),className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":s("settings.common.actions.clear"),title:s("settings.common.actions.clear"),children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]})})]}),t.jsxs("div",{"data-settings-item":"agents.temperature",className:ce("py-1.5",e?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsxs("div",{className:ce("flex min-w-0 flex-col",e?"w-full":"sm:w-56 shrink-0"),children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.temperature")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.temperatureTooltip")})]})]}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.agents.page.field.temperatureRange")})]}),t.jsxs("div",{className:ce("flex items-center gap-2",e?"w-full":"w-fit"),children:[t.jsx(bs,{value:P,fallbackValue:.7,onValueChange:z,onClear:()=>z(void 0),min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),P!==void 0&&t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>z(void 0),className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":s("settings.agents.page.field.clearTemperatureAria"),title:s("settings.common.actions.clear"),children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]})]}),t.jsxs("div",{"data-settings-item":"agents.top-p",className:ce("py-1.5",e?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsxs("div",{className:ce("flex min-w-0 flex-col",e?"w-full":"sm:w-56 shrink-0"),children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.topP")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.topPTooltip")})]})]}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.agents.page.field.topPRange")})]}),t.jsxs("div",{className:ce("flex items-center gap-2",e?"w-full":"w-fit"),children:[t.jsx(bs,{value:M,fallbackValue:.9,onValueChange:I,onClear:()=>I(void 0),min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),M!==void 0&&t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>I(void 0),className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":s("settings.agents.page.field.clearTopPAria"),title:s("settings.common.actions.clear"),children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]})]})]})]}),t.jsxs("div",{"data-settings-item":"agents.system-prompt",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.systemPrompt")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx(hs,{value:v,onChange:H=>j(H.target.value),placeholder:s("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y"})})]}),t.jsxs("div",{"data-settings-item":"agents.permissions",className:"mb-2",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-4",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.toolPermissions")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>re(H=>!H),children:s(X?"settings.agents.page.permissions.hideEditor":"settings.agents.page.permissions.advancedEditor")})]}),X?t.jsxs("div",{className:"space-y-6 px-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.permissions.globalDefault")}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono",children:"*"})]}),t.jsxs(Mt,{value:O,onValueChange:H=>Be(H),children:[t.jsx(Rt,{className:"w-[100px]",children:t.jsx(Kt,{children:Me(O)})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"allow",children:s("settings.common.permission.allow")}),t.jsx(gt,{value:"ask",children:s("settings.common.permission.ask")}),t.jsx(gt,{value:"deny",children:s("settings.common.permission.deny")})]})]})]}),t.jsx("div",{className:"space-y-4",children:ne.filter(H=>H!=="*").map(H=>{const me=ze(H),{defaultAction:Ne,patternRulesCount:Ee}=ue(H),Ce=V(H),_e=Ce??"global",G=te(H),$=["allow","ask","deny"].filter(fe=>fe!==O);return t.jsxs("div",{className:"border-t border-[var(--surface-subtle)] pt-2",children:[t.jsxs("div",{className:"flex items-center justify-between py-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:me}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono",children:H})]}),t.jsx("div",{className:"typography-micro text-muted-foreground",children:Ee>0?s("settings.agents.page.permissions.globalSummary",{summary:Ne}):Ne})]}),t.jsxs("div",{className:"space-y-1 pl-2 mt-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground",children:s("settings.agents.page.permissions.pattern")}),t.jsx("span",{className:"typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded",children:"*"}),Ce&&t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>Te(H,"*"),className:"px-1.5 py-0 h-5",children:t.jsx(A,{name:"subtract",className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]}),t.jsxs(Mt,{value:_e,onValueChange:fe=>{if(fe==="global"){Pe(H,"*");return}Ae(H,"*",fe)},children:[t.jsx(Rt,{className:"w-[90px]",children:t.jsx(Kt,{children:ke(_e)})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"global",children:s("settings.common.scope.global")}),$.map(fe=>t.jsx(gt,{value:fe,className:"capitalize",children:Me(fe)},fe))]})]})]}),G.map(fe=>{const L=cn(fe.permission,fe.pattern),Le=ie.get(L),Je=!Le,Xe=!!(Le&&Le.action!==fe.action);return t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground",children:s("settings.agents.page.permissions.pattern")}),t.jsx("span",{className:"typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded",children:fe.pattern}),Je&&t.jsx("span",{className:"typography-micro text-[var(--status-success)]",children:s("settings.common.badge.new")}),Xe&&t.jsx("span",{className:"typography-micro text-[var(--status-warning)]",children:s("settings.common.badge.modified")}),(Je||Xe)&&t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>Je?Pe(fe.permission,fe.pattern):Te(fe.permission,fe.pattern),className:"px-1.5 py-0 h-5",children:t.jsx(A,{name:"subtract",className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]}),t.jsxs(Mt,{value:fe.action,onValueChange:et=>Fe(fe.permission,fe.pattern,et),children:[t.jsx(Rt,{className:"w-[90px]",children:t.jsx(Kt,{children:Me(fe.action)})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"allow",children:s("settings.common.permission.allow")}),t.jsx(gt,{value:"ask",children:s("settings.common.permission.ask")}),t.jsx(gt,{value:"deny",children:s("settings.common.permission.deny")})]})]})]},L)})]})]},H)})}),t.jsxs("div",{className:"border-t border-[var(--surface-subtle)] pt-3",children:[t.jsx("h4",{className:"typography-ui-label text-foreground mb-2",children:s("settings.agents.page.permissions.addCustomRule")}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-end sm:items-center gap-2",children:[t.jsxs(Mt,{value:R,onValueChange:Y,children:[t.jsx(Rt,{className:"w-full sm:w-[160px]",children:R?t.jsx("span",{className:"truncate",children:ze(R)}):t.jsx("span",{className:"text-muted-foreground",children:s("settings.agents.page.permissions.permissionPlaceholder")})}),t.jsx(Tt,{children:Re.map(H=>t.jsx(gt,{value:H,children:t.jsx("div",{className:"flex items-center justify-between gap-2 w-full",children:t.jsx("span",{children:ze(H)})})},H))})]}),t.jsx(ot,{value:F,onChange:H=>W(H.target.value),placeholder:s("settings.agents.page.permissions.patternPlaceholder"),className:"h-7 flex-1 font-mono text-xs"}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>We("allow"),children:s("settings.common.permission.allow")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>We("ask"),children:s("settings.common.permission.ask")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>We("deny"),children:s("settings.common.permission.deny")})]})]})]})]}):t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-0",children:ne.map((H,me)=>{const{defaultAction:Ne,patternRulesCount:Ee,patternSummary:Ce,hasDefaultHint:_e}=ue(H),G=ze(H),$=_e?`${Ne} (env blocked)`:Ne;return t.jsxs("div",{className:ce("flex flex-col gap-1 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8",me>0&&"border-t border-[var(--surface-subtle)]"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:G}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block",children:H})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[Ee>0?t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:s("settings.agents.page.permissions.globalSummary",{summary:$})}):t.jsx("span",{className:ce("typography-micro capitalize px-1.5 py-0.5 rounded",$==="allow"?"text-[var(--status-success)] bg-[var(--status-success)]/10":$==="deny"?"text-[var(--status-error)] bg-[var(--status-error)]/10":"text-[var(--status-warning)] bg-[var(--status-warning)]/10"),children:$}),Ee>0&&t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:s("settings.agents.page.permissions.rulesSummary",{summary:Ce})})]})]},H)})})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(J,{onClick:oe,disabled:Z||!Qe,size:"xs",className:"!font-normal",children:s(Z?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.agents.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.agents.page.empty.description")})]})})},Zu="~/.config/opencode/AGENTS.md",El=async(s,e)=>{const n=await s.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},ep=s=>s.length>0&&!s.endsWith(`
|
|
2
|
+
`)?`${s}
|
|
3
|
+
`:s,ma={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},tp=(s,e)=>s==="custom"?e:Sd(s),sp=s=>s==="custom"?"custom":hl(s)?s:"concise",qi={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"},Gi=async(s,e)=>{const n=await yt("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(await El(n,e))},np=()=>{const{t:s}=dt(),[e,n]=l.useState(""),[a,r]=l.useState(ma.responseStyleEnabled),[i,o]=l.useState(ma.responseStylePreset),[d,c]=l.useState(ma.responseStyleCustomInstructions),[x,m]=l.useState(!0),[p,u]=l.useState(!1),[C,f]=l.useState(""),g=l.useRef(null);l.useEffect(()=>{const w=new AbortController;return(async()=>{try{const[N,y]=await Promise.all([yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},signal:w.signal}),yt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:w.signal})]);let b=ma;if(N.ok){const P=await N.json();b={...b,responseStyleEnabled:P.responseStyleEnabled===!0,responseStylePreset:sp(P.responseStylePreset),responseStyleCustomInstructions:typeof P.responseStyleCustomInstructions=="string"?P.responseStyleCustomInstructions:""},typeof P.globalBehaviorPrompt=="string"&&(b={...b,prompt:P.globalBehaviorPrompt})}if(!b.prompt.trim()&&y.ok){const P=await y.json();typeof P.content=="string"&&(b={...b,prompt:P.content})}n(b.prompt),r(b.responseStyleEnabled),o(b.responseStylePreset),c(b.responseStyleCustomInstructions),f(b.prompt),g.current={enabled:b.responseStyleEnabled,preset:b.responseStylePreset,custom:b.responseStyleCustomInstructions}}catch(N){N.name!=="AbortError"&&console.warn("Failed to load behavior settings:",N)}finally{m(!1)}})(),()=>w.abort()},[]),l.useEffect(()=>{if(x)return;const w=g.current;if(w&&w.enabled===a&&w.preset===i&&w.custom===d)return;const E={enabled:a,preset:i,custom:d},N=setTimeout(async()=>{try{await Gi({responseStyleEnabled:E.enabled,responseStylePreset:E.preset,responseStyleCustomInstructions:E.custom},s("settings.behavior.page.toast.saveFailed")),g.current=E}catch(y){const b=y instanceof Error?y.message:s("settings.behavior.page.toast.saveFailed");_.error(b)}},400);return()=>clearTimeout(N)},[a,i,d,x,s]);const h=tp(i,d),D=e!==C,k=async()=>{u(!0);try{const w=ep(e),E=await yt("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:w})});if(!E.ok)throw new Error(await El(E,s("settings.behavior.page.toast.saveFailed")));await Gi({globalBehaviorPrompt:w},s("settings.behavior.page.toast.saveFailed")),n(w),f(w),_.success(s("settings.behavior.page.toast.saved"))}catch(w){console.error("Failed to save behavior:",w);const E=w instanceof Error?w.message:s("settings.behavior.page.toast.saveFailed");_.error(E)}finally{u(!1)}};return t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8 space-y-6",children:[t.jsx("div",{className:"space-y-1",children:t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.behavior.page.title")})}),t.jsxs("div",{"data-settings-item":"behavior.system-prompt",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.behavior.page.section.systemPrompt")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"font-medium text-foreground",children:s("settings.behavior.page.warning.title")}),t.jsx("p",{children:s("settings.behavior.page.warning.description",{path:Zu})})]})})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsx(hs,{value:e,onChange:w=>n(w.target.value),placeholder:s("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:x,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"}),t.jsx(J,{onClick:k,disabled:p||!D||x,size:"xs",className:"!font-normal",children:s(p?"settings.common.actions.saving":"settings.common.actions.saveChanges")})]})]}),t.jsxs("div",{"data-settings-item":"behavior.response-style",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.behavior.page.section.responseStyle")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.behavior.page.responseStyle.tooltip")})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("label",{className:"flex items-center gap-2 typography-ui-label text-foreground",children:[t.jsx(St,{checked:a,onChange:r,disabled:x,ariaLabel:s("settings.behavior.page.responseStyle.enableAria")}),s("settings.behavior.page.responseStyle.enable")]}),t.jsxs(Mt,{value:i,onValueChange:w=>o(w),disabled:x||!a,children:[t.jsx(Rt,{className:"w-full sm:w-56",size:"lg",children:t.jsx(Kt,{children:w=>w==="custom"?s("settings.behavior.page.responseStyle.option.custom"):hl(w)?s(qi[w]):null})}),t.jsxs(Tt,{children:[kd.map(w=>t.jsx(gt,{value:w,children:s(qi[w])},w)),t.jsx(gt,{value:"custom",children:s("settings.behavior.page.responseStyle.option.custom")})]})]}),t.jsx(hs,{value:h,onChange:w=>c(w.target.value),placeholder:s("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:x||!a||i!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})]})})},ap=s=>{const e=rt.c(169),{onItemSelect:n}=s,{t:a}=dt(),[r,i]=l.useState(null),[o,d]=l.useState(""),[c,x]=l.useState(null),[m,p]=l.useState(null),[u,C]=l.useState(!1),[f,g]=l.useState(null),{selectedCommandName:h,commands:D,setSelectedCommand:k,setCommandDraft:w,createCommand:E,deleteCommand:N,loadCommands:y}=Ba(Ss(rp)),b=Hs(ip),P=Hs(op);let z,M;e[0]!==y||e[1]!==P?(z=()=>{y(),P()},M=[y,P],e[0]=y,e[1]=P,e[2]=z,e[3]=M):(z=e[2],M=e[3]),l.useEffect(z,M);let I;e[4]!==b?(I=new Set(b.map(lp)),e[4]=b,e[5]=I):I=e[5];const v=I;let j;if(e[6]!==D||e[7]!==v){let pe;e[9]!==v?(pe=nt=>!v.has(nt.name),e[9]=v,e[10]=pe):pe=e[10],j=D.filter(pe),e[6]=D,e[7]=v,e[8]=j}else j=e[8];const O=j;let T,B;e[11]!==h||e[12]!==k||e[13]!==v?(T=()=>{h&&v.has(h)&&k(null)},B=[h,k,v],e[11]=h,e[12]=k,e[13]=v,e[14]=T,e[15]=B):(T=e[14],B=e[15]),l.useEffect(T,B);let U;e[16]!==D||e[17]!==n||e[18]!==w||e[19]!==k?(U=()=>{let pe="new-command",nt=1;for(;D.some(st=>st.name===pe);)pe=`new-command-${nt}`,nt++;w({name:pe,scope:"user"}),k(pe),n?.()},e[16]=D,e[17]=n,e[18]=w,e[19]=k,e[20]=U):U=e[20];const Q=U;let q;e[21]!==a?(q=async pe=>{if(An(pe)){_.error(a("settings.commands.sidebar.toast.builtInCannotDelete"));return}x(pe),p("delete")},e[21]=a,e[22]=q):q=e[22];const R=q;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=async pe=>{An(pe)&&(x(pe),p("reset"))},e[23]=Y):Y=e[23];const F=Y;let W;e[24]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{x(null),p(null)},e[24]=W):W=e[24];const X=W;let re;e[25]!==c||e[26]!==m||e[27]!==N||e[28]!==a?(re=async()=>{if(!c||!m)return;C(!0),await N(c.name)?(m==="delete"?_.success(a("settings.commands.sidebar.toast.commandDeleted",{name:c.name})):_.success(a("settings.commands.sidebar.toast.commandReset",{name:c.name})),X()):m==="delete"?_.error(a("settings.commands.sidebar.toast.deleteFailed")):_.error(a("settings.commands.sidebar.toast.resetFailed")),C(!1)},e[25]=c,e[26]=m,e[27]=N,e[28]=a,e[29]=re):re=e[29];const Z=re;let de;e[30]!==D||e[31]!==w||e[32]!==k?(de=pe=>{const nt=pe.name;let st=1,Ge=`${nt}-copy`;for(;D.some(ht=>ht.name===Ge);)st++,Ge=`${nt}-copy-${st}`;w({name:Ge,scope:pe.scope||"user",description:pe.description,template:pe.template,agent:pe.agent,model:pe.model}),k(Ge)},e[30]=D,e[31]=w,e[32]=k,e[33]=de):de=e[33];const le=de;let ee;e[34]===Symbol.for("react.memo_cache_sentinel")?(ee=pe=>{d(pe.name),i(pe)},e[34]=ee):ee=e[34];const xe=ee;let we;e[35]!==D||e[36]!==E||e[37]!==N||e[38]!==r||e[39]!==o||e[40]!==k||e[41]!==a?(we=async()=>{if(!r)return;const pe=o.trim().replace(/\s+/g,"-");if(!pe){_.error(a("settings.commands.sidebar.toast.commandNameRequired"));return}if(pe===r.name){i(null);return}if(D.some(st=>st.name===pe)){_.error(a("settings.commands.sidebar.toast.commandExists"));return}await E({name:pe,description:r.description,template:r.template,agent:r.agent,model:r.model})?await N(r.name)?(_.success(`Command renamed to "${pe}"`),k(pe)):_.error(a("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):_.error(a("settings.commands.sidebar.toast.renameFailed")),i(null)},e[35]=D,e[36]=E,e[37]=N,e[38]=r,e[39]=o,e[40]=k,e[41]=a,e[42]=we):we=e[42];const he=we;let Ie,be,je,ye,se,ie;if(e[43]!==O||e[44]!==Q||e[45]!==R||e[46]!==le||e[47]!==n||e[48]!==f||e[49]!==h||e[50]!==k||e[51]!==a){const pe=O.filter(An),nt=O.filter(cp);e[58]===Symbol.for("react.memo_cache_sentinel")?(se=ce("flex h-full flex-col","bg-background"),e[58]=se):se=e[58];let st;e[59]!==a?(st=a("settings.commands.sidebar.title"),e[59]=a,e[60]=st):st=e[60];let Ge;e[61]!==st?(Ge=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:st}),e[61]=st,e[62]=Ge):Ge=e[62];let ht;e[63]===Symbol.for("react.memo_cache_sentinel")?(ht=t.jsx(na,{className:"mb-3"}),e[63]=ht):ht=e[63];let wt;e[64]!==O.length||e[65]!==a?(wt=a("settings.commands.sidebar.total",{count:O.length}),e[64]=O.length,e[65]=a,e[66]=wt):wt=e[66];let Nt;e[67]!==wt?(Nt=t.jsx("span",{className:"typography-meta text-muted-foreground",children:wt}),e[67]=wt,e[68]=Nt):Nt=e[68];let ae;e[69]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),e[69]=ae):ae=e[69];let Ue;e[70]!==Q?(Ue=t.jsx(J,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:Q,children:ae}),e[70]=Q,e[71]=Ue):Ue=e[71];let tt;e[72]!==Nt||e[73]!==Ue?(tt=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Nt,Ue]}),e[72]=Nt,e[73]=Ue,e[74]=tt):tt=e[74],e[75]!==Ge||e[76]!==tt?(ie=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[Ge,ht,tt]}),e[75]=Ge,e[76]=tt,e[77]=ie):ie=e[77],Ie=Gt,be="flex-1 min-h-0",je="space-y-1 px-3 py-2",ye=O.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.commands.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.commands.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[pe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.commands.sidebar.section.builtIn")}),[...pe].sort(dp).map(Ye=>t.jsx(Ji,{command:Ye,isSelected:h===Ye.name,onSelect:()=>{k(Ye.name),n?.()},onReset:()=>F(Ye),onDuplicate:()=>le(Ye),isMenuOpen:f===Ye.name,onMenuOpenChange:ft=>g(ft?Ye.name:null)},Ye.name))]}),nt.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.commands.sidebar.section.custom")}),[...nt].sort(mp).map(Ye=>t.jsx(Ji,{command:Ye,isSelected:h===Ye.name,onSelect:()=>{k(Ye.name),n?.()},onRename:()=>xe(Ye),onDelete:()=>R(Ye),onDuplicate:()=>le(Ye),isMenuOpen:f===Ye.name,onMenuOpenChange:ft=>g(ft?Ye.name:null)},Ye.name))]})]}),e[43]=O,e[44]=Q,e[45]=R,e[46]=le,e[47]=n,e[48]=f,e[49]=h,e[50]=k,e[51]=a,e[52]=Ie,e[53]=be,e[54]=je,e[55]=ye,e[56]=se,e[57]=ie}else Ie=e[52],be=e[53],je=e[54],ye=e[55],se=e[56],ie=e[57];let ge;e[78]!==Ie||e[79]!==be||e[80]!==je||e[81]!==ye?(ge=t.jsx(Ie,{outerClassName:be,className:je,children:ye}),e[78]=Ie,e[79]=be,e[80]=je,e[81]=ye,e[82]=ge):ge=e[82];const V=c!==null&&m!==null;let te;e[83]!==u?(te=pe=>{!pe&&!u&&X()},e[83]=u,e[84]=te):te=e[84];let ne;e[85]!==m||e[86]!==a?(ne=a(m==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[85]=m,e[86]=a,e[87]=ne):ne=e[87];let ue;e[88]!==ne?(ue=t.jsx(Ut,{children:ne}),e[88]=ne,e[89]=ue):ue=e[89];let Me;e[90]!==c?.name||e[91]!==m||e[92]!==a?(Me=m==="delete"?a("settings.commands.sidebar.dialog.deleteDescription",{name:c?.name??""}):a("settings.commands.sidebar.dialog.resetDescription",{name:c?.name??""}),e[90]=c?.name,e[91]=m,e[92]=a,e[93]=Me):Me=e[93];let ke;e[94]!==Me?(ke=t.jsx(Wt,{children:Me}),e[94]=Me,e[95]=ke):ke=e[95];let Re;e[96]!==ue||e[97]!==ke?(Re=t.jsxs(_t,{children:[ue,ke]}),e[96]=ue,e[97]=ke,e[98]=Re):Re=e[98];let Ae;e[99]!==a?(Ae=a("settings.common.actions.cancel"),e[99]=a,e[100]=Ae):Ae=e[100];let Pe;e[101]!==u||e[102]!==Ae?(Pe=t.jsx(J,{size:"sm",variant:"ghost",onClick:X,disabled:u,children:Ae}),e[101]=u,e[102]=Ae,e[103]=Pe):Pe=e[103];let Te;e[104]!==m||e[105]!==a?(Te=a(m==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[104]=m,e[105]=a,e[106]=Te):Te=e[106];let Fe;e[107]!==Z||e[108]!==u||e[109]!==Te?(Fe=t.jsx(J,{size:"sm",onClick:Z,disabled:u,children:Te}),e[107]=Z,e[108]=u,e[109]=Te,e[110]=Fe):Fe=e[110];let Be;e[111]!==Pe||e[112]!==Fe?(Be=t.jsxs(Yt,{children:[Pe,Fe]}),e[111]=Pe,e[112]=Fe,e[113]=Be):Be=e[113];let We;e[114]!==Re||e[115]!==Be?(We=t.jsxs(Bt,{className:"max-w-md",children:[Re,Be]}),e[114]=Re,e[115]=Be,e[116]=We):We=e[116];let ze;e[117]!==V||e[118]!==te||e[119]!==We?(ze=t.jsx($t,{open:V,onOpenChange:te,children:We}),e[117]=V,e[118]=te,e[119]=We,e[120]=ze):ze=e[120];const Qe=r!==null;let oe;e[121]===Symbol.for("react.memo_cache_sentinel")?(oe=pe=>!pe&&i(null),e[121]=oe):oe=e[121];let H;e[122]!==a?(H=a("settings.commands.sidebar.renameDialog.title"),e[122]=a,e[123]=H):H=e[123];let me;e[124]!==H?(me=t.jsx(Ut,{children:H}),e[124]=H,e[125]=me):me=e[125];const Ne=r?.name??"";let Ee;e[126]!==a||e[127]!==Ne?(Ee=a("settings.commands.sidebar.renameDialog.description",{name:Ne}),e[126]=a,e[127]=Ne,e[128]=Ee):Ee=e[128];let Ce;e[129]!==Ee?(Ce=t.jsx(Wt,{children:Ee}),e[129]=Ee,e[130]=Ce):Ce=e[130];let _e;e[131]!==me||e[132]!==Ce?(_e=t.jsxs(_t,{children:[me,Ce]}),e[131]=me,e[132]=Ce,e[133]=_e):_e=e[133];let G;e[134]===Symbol.for("react.memo_cache_sentinel")?(G=pe=>d(pe.target.value),e[134]=G):G=e[134];let $;e[135]!==a?($=a("settings.commands.sidebar.renameDialog.placeholder"),e[135]=a,e[136]=$):$=e[136];let fe;e[137]!==he?(fe=pe=>{pe.key==="Enter"&&he()},e[137]=he,e[138]=fe):fe=e[138];let L;e[139]!==o||e[140]!==$||e[141]!==fe?(L=t.jsx(ot,{value:o,onChange:G,placeholder:$,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:fe}),e[139]=o,e[140]=$,e[141]=fe,e[142]=L):L=e[142];let Le;e[143]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>i(null),e[143]=Le):Le=e[143];let Je;e[144]!==a?(Je=a("settings.common.actions.cancel"),e[144]=a,e[145]=Je):Je=e[145];let Xe;e[146]!==Je?(Xe=t.jsx(J,{size:"sm",variant:"ghost",onClick:Le,children:Je}),e[146]=Je,e[147]=Xe):Xe=e[147];let et;e[148]!==a?(et=a("settings.common.actions.rename"),e[148]=a,e[149]=et):et=e[149];let at;e[150]!==he||e[151]!==et?(at=t.jsx(J,{size:"sm",onClick:he,children:et}),e[150]=he,e[151]=et,e[152]=at):at=e[152];let ct;e[153]!==Xe||e[154]!==at?(ct=t.jsxs(Yt,{children:[Xe,at]}),e[153]=Xe,e[154]=at,e[155]=ct):ct=e[155];let Ze;e[156]!==_e||e[157]!==L||e[158]!==ct?(Ze=t.jsxs(Bt,{children:[_e,L,ct]}),e[156]=_e,e[157]=L,e[158]=ct,e[159]=Ze):Ze=e[159];let He;e[160]!==Qe||e[161]!==Ze?(He=t.jsx($t,{open:Qe,onOpenChange:oe,children:Ze}),e[160]=Qe,e[161]=Ze,e[162]=He):He=e[162];let mt;return e[163]!==se||e[164]!==ie||e[165]!==ge||e[166]!==ze||e[167]!==He?(mt=t.jsxs("div",{className:se,children:[ie,ge,ze,He]}),e[163]=se,e[164]=ie,e[165]=ge,e[166]=ze,e[167]=He,e[168]=mt):mt=e[168],mt},Ji=s=>{const e=rt.c(47),{command:n,isSelected:a,onSelect:r,onDelete:i,onReset:o,onRename:d,onDuplicate:c,isMenuOpen:x,onMenuOpenChange:m}=s,{t:p}=dt();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Xn(),e[0]=u):u=e[0];const C=u,[f,g]=l.useState(!1);let h;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==o||e[5]!==p?(h=q=>t.jsxs(t.Fragment,{children:[d&&t.jsxs(q,{onClick:R=>{R.stopPropagation(),d()},children:[t.jsx(A,{name:"edit",className:"h-4 w-4 mr-px"}),p("settings.common.actions.rename")]}),t.jsxs(q,{onClick:R=>{R.stopPropagation(),c()},children:[t.jsx(A,{name:"file-copy",className:"h-4 w-4 mr-px"}),p("settings.common.actions.duplicate")]}),o&&t.jsxs(q,{onClick:R=>{R.stopPropagation(),o()},children:[t.jsx(A,{name:"restart",className:"h-4 w-4 mr-px"}),p("settings.common.actions.reset")]}),i&&t.jsxs(q,{onClick:R=>{R.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),p("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=o,e[5]=p,e[6]=h):h=e[6];const D=h,k=a?"bg-interactive-selection":"hover:bg-interactive-hover";let w;e[7]!==k?(w=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",k),e[7]=k,e[8]=w):w=e[8];let E;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=C?void 0:q=>{q.preventDefault(),g(!0)},e[9]=E):E=e[9];let N;e[10]!==w?(N=t.jsx("div",{className:w,onContextMenu:E}),e[10]=w,e[11]=N):N=e[11];let y;e[12]!==n.name?(y=t.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",n.name]}),e[12]=n.name,e[13]=y):y=e[13];let b;e[14]!==n||e[15]!==p?(b=(n.scope||An(n))&&t.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:An(n)?p("settings.agents.sidebar.badge.system"):n.scope}),e[14]=n,e[15]=p,e[16]=b):b=e[16];let P;e[17]!==y||e[18]!==b?(P=t.jsxs("div",{className:"flex items-center gap-2",children:[y,b]}),e[17]=y,e[18]=b,e[19]=P):P=e[19];let z;e[20]!==n.description?(z=n.description&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n.description}),e[20]=n.description,e[21]=z):z=e[21];let M;e[22]!==r||e[23]!==z||e[24]!==P?(M=t.jsxs("button",{onClick:r,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:[P,z]}),e[22]=r,e[23]=z,e[24]=P,e[25]=M):M=e[25];let I;e[26]!==m?(I=q=>{q&&g(!1),m(q)},e[26]=m,e[27]=I):I=e[27];let v;e[28]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(us,{asChild:!0,children:t.jsx(J,{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:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=v):v=e[28];let j;e[29]!==D?(j=t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:D(vs)}),e[29]=D,e[30]=j):j=e[30];let O;e[31]!==x||e[32]!==I||e[33]!==j?(O=t.jsxs(gs,{open:x,onOpenChange:I,children:[v,j]}),e[31]=x,e[32]=I,e[33]=j,e[34]=O):O=e[34];let T;e[35]!==M||e[36]!==O?(T=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[M,O]}),e[35]=M,e[36]=O,e[37]=T):T=e[37];let B;e[38]!==T||e[39]!==N?(B=t.jsx(tn,{render:N,children:T}),e[38]=T,e[39]=N,e[40]=B):B=e[40];let U;e[41]!==D?(U=t.jsx(sn,{className:"w-fit min-w-20",children:D(qs)}),e[41]=D,e[42]=U):U=e[42];let Q;return e[43]!==f||e[44]!==B||e[45]!==U?(Q=t.jsxs(en,{open:f,onOpenChange:g,children:[B,U]}),e[43]=f,e[44]=B,e[45]=U,e[46]=Q):Q=e[46],Q};function rp(s){return{selectedCommandName:s.selectedCommandName,commands:s.commands,setSelectedCommand:s.setSelectedCommand,setCommandDraft:s.setCommandDraft,createCommand:s.createCommand,deleteCommand:s.deleteCommand,loadCommands:s.loadCommands}}function ip(s){return s.skills}function op(s){return s.loadSkills}function lp(s){return s.name}function cp(s){return!An(s)}function dp(s,e){return s.name.localeCompare(e.name)}function mp(s,e){return s.name.localeCompare(e.name)}const up=()=>{const{t:s}=dt(),{selectedCommandName:e,getCommandByName:n,createCommand:a,updateCommand:r,commands:i,commandDraft:o,setCommandDraft:d}=Ba(Ss(I=>({selectedCommandName:I.selectedCommandName,getCommandByName:I.getCommandByName,createCommand:I.createCommand,updateCommand:I.updateCommand,commands:I.commands,commandDraft:I.commandDraft,setCommandDraft:I.setCommandDraft}))),c=e?n(e):null,x=!!(o&&o.name===e&&!c),[m,p]=l.useState(""),[u,C]=l.useState("user"),[f,g]=l.useState(""),[h,D]=l.useState(""),[k,w]=l.useState(""),[E,N]=l.useState(""),[y,b]=l.useState(!1),P=l.useRef(null);l.useEffect(()=>{if(x&&o){const I=o.name||"",v=o.scope||"user",j=o.description||"",O=o.agent||"",T=o.model||"",B=o.template||"";p(I),C(v),g(j),D(O),w(T),N(B),P.current={draftName:I,draftScope:v,description:j,agent:O,model:T,template:B}}else if(c){const I=c.description||"",v=c.agent||"",j=c.model||"",O=c.template||"";g(I),D(v),w(j),N(O),P.current={draftName:"",draftScope:"user",description:I,agent:v,model:j,template:O}}},[c,x,e,i,o]);const z=l.useMemo(()=>{const I=P.current;return I?!!(x&&(m!==I.draftName||u!==I.draftScope)||f!==I.description||h!==I.agent||k!==I.model||E!==I.template):!1},[h,f,m,u,x,k,E]),M=async()=>{const I=x?m.trim().replace(/\s+/g,"-"):e?.trim();if(!I){_.error(s("settings.commands.sidebar.toast.commandNameRequired"));return}if(!E.trim()){_.error(s("settings.commands.page.toast.templateRequired"));return}if(x&&i.some(v=>v.name===I)){_.error(s("settings.commands.sidebar.toast.commandExists"));return}b(!0);try{const v=h.trim(),j=k.trim(),O=E.trim(),T={name:I,description:f.trim()||void 0,agent:v===""?null:v,model:j===""?null:j,template:O,scope:x?u:void 0};let B;x?(B=await a(T),B&&d(null)):B=await r(I,T),B?_.success(s(x?"settings.commands.page.toast.created":"settings.commands.page.toast.updated")):_.error(s(x?"settings.commands.page.toast.createFailed":"settings.commands.page.toast.updateFailed"))}catch(v){console.error("Error saving command:",v),_.error(s("settings.commands.page.toast.saveUnexpectedError"))}finally{b(!1)}};return e?t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4 flex items-center justify-between gap-4",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:x?s("settings.commands.page.title.new"):`/${e}`}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:s(x?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit")})]})}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.commands.page.section.identity")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[x&&t.jsxs("div",{"data-settings-item":"commands.name",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.commands.page.field.commandName")})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"/"}),t.jsx(ot,{value:m,onChange:I=>p(I.target.value),placeholder:s("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),t.jsxs(Mt,{value:u,onValueChange:I=>C(I),children:[t.jsx(Rt,{className:"w-fit min-w-[100px]",children:t.jsx(Kt,{placeholder:s("settings.agents.page.field.scopePlaceholder")})}),t.jsxs(Tt,{align:"end",children:[t.jsx(gt,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.global")})]})}),t.jsx(gt,{value:"project",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.project")})]})})]})]})]})]}),t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.common.field.description")}),t.jsx("div",{className:"mt-1.5",children:t.jsx(hs,{value:f,onChange:I=>g(I.target.value),placeholder:s("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.commands.page.section.executionContext")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{"data-settings-item":"commands.agent",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.commands.page.field.overrideAgent")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(fl,{agentName:h,onChange:I=>D(I)})})]}),t.jsxs("div",{"data-settings-item":"commands.model",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.overrideModel")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(Hr,{providerId:un(k)?.providerId??"",modelId:un(k)?.modelId??"",onChange:(I,v)=>{w(I&&v?`${I}/${v}`:"")}})})]})]})]}),t.jsxs("div",{"data-settings-item":"commands.template",className:"mb-2",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.commands.page.section.template")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx(hs,{value:E,onChange:I=>N(I.target.value),placeholder:s("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y"})}),t.jsx("div",{className:"mt-2 px-2",children:t.jsxs("p",{className:"typography-meta text-muted-foreground",children:[t.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",s("settings.commands.page.templateHint.userInput")," ·"," ",t.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",s("settings.commands.page.templateHint.shellOutput")," ·"," ",t.jsx("code",{className:"text-foreground",children:"@file"})," ",s("settings.commands.page.templateHint.fileContents")]})})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(J,{onClick:M,disabled:y||!z,size:"xs",className:"!font-normal",children:s(y?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.commands.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.commands.page.empty.description")})]})})},Qi=s=>{switch(s){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"idle"}},Yi=s=>{const e=rt.c(5),{tone:n,enabled:a}=s;if(!a){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0"}),e[0]=o):o=e[0],o}let r;e[1]!==n?(r=ce("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"}[n]),e[1]=n,e[2]=r):r=e[2];let i;return e[3]!==r?(i=t.jsx("span",{className:r}),e[3]=r,e[4]=i):i=e[4],i},pp=s=>{const e=rt.c(120),{onItemSelect:n}=s,{t:a}=dt(),{mcpServers:r,selectedMcpName:i,setSelectedMcp:o,setMcpDraft:d,loadMcpConfigs:c,deleteMcp:x}=Rn(Ss(gp)),m=ys(hp);let p;e[0]!==m?(p=Ce=>Ce.getStatusForDirectory(m??null),e[0]=m,e[1]=p):p=e[1];const u=ls(p),C=ls(fp),f=ls(xp),[g,h]=l.useState(null),[D,k]=l.useState(!1),[w,E]=l.useState(null),[N,y]=l.useState(null),[b,P]=l.useState(!1);let z;e[2]!==r?(z=r.filter(bp),e[2]=r,e[3]=z):z=e[3];const M=z;let I;e[4]!==r?(I=r.filter(yp),e[4]=r,e[5]=I):I=e[5];const v=I;let j,O;e[6]!==c?(j=()=>{c()},O=[c],e[6]=c,e[7]=j,e[8]=O):(j=e[7],O=e[8]),l.useEffect(j,O);let T;e[9]!==m||e[10]!==f||e[11]!==b||e[12]!==C?(T=()=>{if(b)return;P(!0);const Ce=new Promise(vp);Promise.all([C({directory:m,silent:!0}),Ce]).then(()=>{const _e=f(m);_e&&_.error(_e)}).finally(()=>{P(!1)})},e[9]=m,e[10]=f,e[11]=b,e[12]=C,e[13]=T):T=e[13];const B=T;let U;e[14]!==r||e[15]!==n||e[16]!==d||e[17]!==o?(U=()=>{let Ce="new-mcp-server",_e=1;for(;r.some($=>$.name===Ce);)Ce=`new-mcp-server-${_e}`,_e++;d({name:Ce,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),o(Ce),n?.()},e[14]=r,e[15]=n,e[16]=d,e[17]=o,e[18]=U):U=e[18];const Q=U;let q;e[19]!==x||e[20]!==g||e[21]!==a?(q=async()=>{if(!g)return;k(!0);const Ce=await x(g.name);Ce.ok?Ce.reloadFailed?_.warning(Ce.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:Ce.warning||a("settings.mcp.sidebar.toast.refreshListIfStale")}):_.success(Ce.message||a("settings.mcp.sidebar.toast.serverDeleted",{name:g.name})):_.error(a("settings.mcp.sidebar.toast.deleteFailed")),h(null),k(!1)},e[19]=x,e[20]=g,e[21]=a,e[22]=q):q=e[22];const R=q;let Y;e[23]!==a?(Y=(Ce,_e)=>t.jsxs(_e,{onClick:G=>{G.stopPropagation(),h(Ce)},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]}),e[23]=a,e[24]=Y):Y=e[24];const F=Y;let W;e[25]===Symbol.for("react.memo_cache_sentinel")?(W=ce("flex h-full flex-col","bg-background"),e[25]=W):W=e[25];let X;e[26]!==a?(X=a("settings.mcp.sidebar.title"),e[26]=a,e[27]=X):X=e[27];let re;e[28]!==X?(re=t.jsx("h2",{className:"text-base font-semibold text-foreground",children:X}),e[28]=X,e[29]=re):re=e[29];let Z;e[30]!==a?(Z=a("settings.mcp.sidebar.actions.refreshStatusAria"),e[30]=a,e[31]=Z):Z=e[31];let de;e[32]!==a?(de=a("settings.mcp.sidebar.actions.refreshStatusTitle"),e[32]=a,e[33]=de):de=e[33];const le=b&&"animate-spin";let ee;e[34]!==le?(ee=ce("h-4 w-4",le),e[34]=le,e[35]=ee):ee=e[35];let xe;e[36]!==ee?(xe=t.jsx(A,{name:"refresh",className:ee}),e[36]=ee,e[37]=xe):xe=e[37];let we;e[38]!==B||e[39]!==b||e[40]!==Z||e[41]!==de||e[42]!==xe?(we=t.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:b,onClick:B,"aria-label":Z,title:de,children:xe}),e[38]=B,e[39]=b,e[40]=Z,e[41]=de,e[42]=xe,e[43]=we):we=e[43];let he;e[44]!==re||e[45]!==we?(he=t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[re,we]}),e[44]=re,e[45]=we,e[46]=he):he=e[46];let Ie;e[47]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx(na,{className:"mb-3"}),e[47]=Ie):Ie=e[47];let be;e[48]!==r.length||e[49]!==a?(be=a("settings.mcp.sidebar.total",{count:r.length}),e[48]=r.length,e[49]=a,e[50]=be):be=e[50];let je;e[51]!==be?(je=t.jsx("span",{className:"typography-meta text-muted-foreground",children:be}),e[51]=be,e[52]=je):je=e[52];let ye;e[53]!==a?(ye=a("settings.mcp.sidebar.actions.addServerTitle"),e[53]=a,e[54]=ye):ye=e[54];let se;e[55]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),e[55]=se):se=e[55];let ie;e[56]!==Q||e[57]!==ye?(ie=t.jsx(J,{size:"sm","data-settings-item":"mcp.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:Q,title:ye,children:se}),e[56]=Q,e[57]=ye,e[58]=ie):ie=e[58];let ge;e[59]!==je||e[60]!==ie?(ge=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[je,ie]}),e[59]=je,e[60]=ie,e[61]=ge):ge=e[61];let V;e[62]!==he||e[63]!==ge?(V=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[he,Ie,ge]}),e[62]=he,e[63]=ge,e[64]=V):V=e[64];let te;e[65]!==r.length||e[66]!==u||e[67]!==n||e[68]!==w||e[69]!==M||e[70]!==F||e[71]!==N||e[72]!==i||e[73]!==d||e[74]!==o||e[75]!==a||e[76]!==v?(te=t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:r.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.mcp.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.mcp.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[M.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.mcp.sidebar.group.projectServers")}),M.map(Ce=>{const _e=u[Ce.name],G=Qi(_e?.status),$=i===Ce.name,fe=Xn();return t.jsxs(en,{open:N===Ce.name,onOpenChange:L=>y(L?Ce.name:null),children:[t.jsxs(tn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",$?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:fe?void 0:L=>{L.preventDefault(),y(Ce.name)}}),children:[t.jsxs("button",{onClick:()=>{o(Ce.name),d(null),n?.()},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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{tone:G,enabled:Ce.enabled}),t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:Ce.name}),t.jsx("span",{title:Ce.type==="local"?a("settings.mcp.sidebar.serverType.localTitle"):a("settings.mcp.sidebar.serverType.remoteTitle"),children:Ce.type==="local"?t.jsx(A,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):t.jsx(A,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:Ce.type==="local"?Ce.command?.join(" ")??"":Ce.url??""})]}),t.jsxs(gs,{open:w===Ce.name,onOpenChange:L=>{L&&y(null),E(L?Ce.name:null)},children:[t.jsx(us,{asChild:!0,children:t.jsx(J,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:F(Ce,vs)})]})]}),t.jsx(sn,{className:"w-fit min-w-20",children:F(Ce,qs)})]},Ce.name)})]}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.mcp.sidebar.group.userServers")}),v.map(Ce=>{const _e=u[Ce.name],G=Qi(_e?.status),$=i===Ce.name,fe=Xn();return t.jsxs(en,{open:N===Ce.name,onOpenChange:L=>y(L?Ce.name:null),children:[t.jsxs(tn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",$?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:fe?void 0:L=>{L.preventDefault(),y(Ce.name)}}),children:[t.jsxs("button",{onClick:()=>{o(Ce.name),d(null),n?.()},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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{tone:G,enabled:Ce.enabled}),t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:Ce.name}),t.jsx("span",{title:Ce.type==="local"?a("settings.mcp.sidebar.serverType.localTitle"):a("settings.mcp.sidebar.serverType.remoteTitle"),children:Ce.type==="local"?t.jsx(A,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):t.jsx(A,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:Ce.type==="local"?Ce.command?.join(" ")??"":Ce.url??""})]}),t.jsxs(gs,{open:w===Ce.name,onOpenChange:L=>{L&&y(null),E(L?Ce.name:null)},children:[t.jsx(us,{asChild:!0,children:t.jsx(J,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:F(Ce,vs)})]})]}),t.jsx(sn,{className:"w-fit min-w-20",children:F(Ce,qs)})]},Ce.name)})]})]})}),e[65]=r.length,e[66]=u,e[67]=n,e[68]=w,e[69]=M,e[70]=F,e[71]=N,e[72]=i,e[73]=d,e[74]=o,e[75]=a,e[76]=v,e[77]=te):te=e[77];const ne=g!==null;let ue;e[78]!==D?(ue=Ce=>{!Ce&&!D&&h(null)},e[78]=D,e[79]=ue):ue=e[79];let Me;e[80]!==a?(Me=a("settings.mcp.sidebar.deleteDialog.title"),e[80]=a,e[81]=Me):Me=e[81];let ke;e[82]!==Me?(ke=t.jsx(Ut,{children:Me}),e[82]=Me,e[83]=ke):ke=e[83];const Re=g?.name||"";let Ae;e[84]!==a||e[85]!==Re?(Ae=a("settings.mcp.sidebar.deleteDialog.descriptionPrefix",{name:Re}),e[84]=a,e[85]=Re,e[86]=Ae):Ae=e[86];let Pe;e[87]===Symbol.for("react.memo_cache_sentinel")?(Pe=t.jsx("code",{className:"text-foreground",children:"opencode.json"}),e[87]=Pe):Pe=e[87];let Te;e[88]!==Ae?(Te=t.jsxs(Wt,{children:[Ae," ",Pe,"."]}),e[88]=Ae,e[89]=Te):Te=e[89];let Fe;e[90]!==ke||e[91]!==Te?(Fe=t.jsxs(_t,{children:[ke,Te]}),e[90]=ke,e[91]=Te,e[92]=Fe):Fe=e[92];let Be;e[93]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>h(null),e[93]=Be):Be=e[93];let We;e[94]!==a?(We=a("settings.common.actions.cancel"),e[94]=a,e[95]=We):We=e[95];let ze;e[96]!==D||e[97]!==We?(ze=t.jsx(J,{size:"sm",variant:"ghost",onClick:Be,disabled:D,children:We}),e[96]=D,e[97]=We,e[98]=ze):ze=e[98];let Qe;e[99]!==D||e[100]!==a?(Qe=a(D?"settings.mcp.sidebar.actions.deleting":"settings.common.actions.delete"),e[99]=D,e[100]=a,e[101]=Qe):Qe=e[101];let oe;e[102]!==R||e[103]!==D||e[104]!==Qe?(oe=t.jsx(J,{size:"sm",onClick:R,disabled:D,children:Qe}),e[102]=R,e[103]=D,e[104]=Qe,e[105]=oe):oe=e[105];let H;e[106]!==ze||e[107]!==oe?(H=t.jsxs(Yt,{children:[ze,oe]}),e[106]=ze,e[107]=oe,e[108]=H):H=e[108];let me;e[109]!==Fe||e[110]!==H?(me=t.jsxs(Bt,{className:"max-w-md",children:[Fe,H]}),e[109]=Fe,e[110]=H,e[111]=me):me=e[111];let Ne;e[112]!==ne||e[113]!==ue||e[114]!==me?(Ne=t.jsx($t,{open:ne,onOpenChange:ue,children:me}),e[112]=ne,e[113]=ue,e[114]=me,e[115]=Ne):Ne=e[115];let Ee;return e[116]!==V||e[117]!==te||e[118]!==Ne?(Ee=t.jsxs("div",{className:W,children:[V,te,Ne]}),e[116]=V,e[117]=te,e[118]=Ne,e[119]=Ee):Ee=e[119],Ee};function gp(s){return{mcpServers:s.mcpServers,selectedMcpName:s.selectedMcpName,setSelectedMcp:s.setSelectedMcp,setMcpDraft:s.setMcpDraft,loadMcpConfigs:s.loadMcpConfigs,deleteMcp:s.deleteMcp}}function hp(s){return s.currentDirectory}function fp(s){return s.refresh}function xp(s){return s.getErrorForDirectory}function bp(s){return s.scope==="project"}function yp(s){return s.scope!=="project"}function vp(s){return setTimeout(s,500)}function Ls(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function Un(s){return Array.isArray(s)&&s.every(e=>typeof e=="string")}function Fs(s,e){return e!==void 0?{ok:!1,error:s,parsed:e}:{ok:!1,error:s}}function ua(s,e,n){const a=jp(n),r=typeof n.url=="string"?n.url.trim():"",i=Xi(n,"env","environment"),o=Xi(n,"headers"),d=wp(n),c=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.clientId??"").trim():"",x=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.clientSecret??"").trim():"",m=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.scope??"").trim():"",p=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.redirectUri??"").trim():"",u=Np(n),C=kp(n);return{ok:!0,name:s,type:e,command:a,url:r,environment:i,headers:o,oauthEnabled:d,oauthClientId:c,oauthClientSecret:x,oauthScope:m,oauthRedirectUri:p,timeout:u,enabled:C}}function jp(s){const e=s.command,n=s.args;if(Un(e)&&Un(n))return[...e,...n];if(Un(e))return e;if(typeof e=="string"&&e.trim()){const a=e.trim().split(/\s+/);return Un(n)?[...a,...n]:a}return Un(n)?n:[]}function Xi(s,...e){for(const n of e){const a=s[n];if(!Ls(a))continue;const r=Object.entries(a).filter(([i,o])=>i&&typeof o=="string");if(r.length>0)return r.map(([i,o])=>({key:i,value:String(o)}))}return[]}function wp(s){if(s.oauth===!1||s.oauth===null||s.oauth===void 0||!Ls(s.oauth))return!1;const e=s.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 Np(s){const e=s.timeout;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return String(Math.floor(e));if(typeof e=="string"&&e.trim()){const n=Number(e);if(Number.isFinite(n)&&n>0)return String(Math.floor(n))}return""}function kp(s){return"disabled"in s&&s.disabled===!0?!1:"enabled"in s?!!s.enabled:!0}function Sp(s){const e=s.mcpServers;if(Ls(e)){const a=Object.keys(e);if(a.length===1){const r=a[0],i=e[r];if(Ls(i))return{name:r,entry:i}}if(a.length>1)return null}const n=Object.keys(s).filter(a=>{const r=s[a];return a!=="mcpServers"&&Ls(r)});if(n.length===1){const a=n[0],r=s[a];if(Ml(r))return{name:a,entry:r}}return null}function Ml(s){return s.type==="local"||s.type==="remote"||Array.isArray(s.command)||typeof s.url=="string"||Array.isArray(s.args)}function Cp(s,e){let n;try{const d=s.trim();if(!d)return Fs("No JSON content provided");n=JSON.parse(d)}catch(d){return Fs(d instanceof Error?`Invalid JSON: ${d.message}`:"Invalid JSON")}if(!Ls(n))return Fs("Expected a JSON object, not an array or primitive");const a=n,r=a.mcpServers;if(Ls(r)){const d=Object.keys(r);if(d.length===0)return Fs("mcpServers object is empty",n);if(d.length>1)return Fs("Paste one server at a time. Found "+d.length+" servers in mcpServers",n);const c=d[0],x=r[c];return Ls(x)?ua(c,pa(x),x):Fs("Server entry is not a valid object",n)}const i=a.mcp;if(Ls(i)){const d=Object.keys(i);if(d.length===0)return Fs("mcp object is empty",n);if(d.length>1)return Fs("Paste one server at a time. Found "+d.length+" servers in mcp",n);const c=d[0],x=i[c];return Ls(x)?ua(c,pa(x),x):Fs("Server entry in mcp is not a valid object",n)}const o=Sp(a);if(o)return ua(o.name,pa(o.entry),o.entry);if(Ml(a)){const d=pa(a),c=typeof a.name=="string"&&a.name.trim()?a.name.trim():e?.fallbackName;return ua(c,d,a)}return Fs("No recognizable MCP server configuration found in JSON",n)}function pa(s){return s.type==="remote"?"remote":s.type==="local"?"local":typeof s.url=="string"&&s.url.trim()?"remote":(Array.isArray(s.command)||typeof s.command=="string"||Array.isArray(s.args),"local")}function Pp(s,e,n){const a=n?.isNewServer??!1,r=s.name,i=a&&r?r:e.name??"";return{...e,name:i,type:s.type,command:s.type==="local"?s.command:[],url:s.type==="remote"?s.url:"",environment:s.environment,headers:s.type==="remote"?s.headers:[],oauthEnabled:s.type==="remote"?s.oauthEnabled:!1,oauthClientId:s.type==="remote"?s.oauthClientId:"",oauthClientSecret:s.type==="remote"?s.oauthClientSecret:"",oauthScope:s.type==="remote"?s.oauthScope:"",oauthRedirectUri:s.type==="remote"?s.oauthRedirectUri:"",timeout:s.type==="remote"?s.timeout:"",enabled:s.enabled}}const Ip="/mcp/oauth/callback",Dp=s=>{if(typeof window>"u")return null;try{const e=s.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),a=window.atob(e+n),r=Uint8Array.from(a,i=>i.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}},Ap=s=>{const e=Ep(s.get("state"));if(e)return e;const n=s.get("server");if(typeof n!="string"||!n.trim())return null;const a=s.get("directory");return{name:n.trim(),directory:typeof a=="string"&&a.trim()?a.trim():null}},Rl=s=>{const e=s.get("state");return typeof e!="string"?null:e.trim()||null},Ep=s=>{if(typeof s!="string"||!s.trim())return null;const e=Dp(s.trim());if(!e)return null;try{const n=JSON.parse(e);return n?.v!==1||typeof n.n!="string"||!n.n.trim()?null:{name:n.n.trim(),directory:typeof n.d=="string"&&n.d.trim()?n.d.trim():null}}catch{return null}},pn=Cc,gn=s=>{const e=rt.c(14);let n,a,r,i;e[0]!==s?({className:r,asChild:n,children:a,...i}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=r,e[4]=i):(n=e[1],a=e[2],r=e[3],i=e[4]);let o;e[5]!==n||e[6]!==a?(o=n&&ve.isValidElement(a)?{render:a}:{children:a},e[5]=n,e[6]=a,e[7]=o):o=e[7];const d=o;let c;e[8]!==r?(c=ce("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",r),e[8]=r,e[9]=c):c=e[9];let x;return e[10]!==i||e[11]!==d||e[12]!==c?(x=t.jsx(Sc,{className:c,...i,...d}),e[10]=i,e[11]=d,e[12]=c,e[13]=x):x=e[13],x},hn=s=>{const e=rt.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=ce("overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down",n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(Pc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i};function Mp(s){const e=[];let n="",a=!1,r=!1;for(let i=0;i<s.length;i++){const o=s[i];if(o==="'"&&!r){a=!a;continue}if(o==='"'&&!a){r=!r;continue}if((o===" "||o===" ")&&!a&&!r){n&&(e.push(n),n="");continue}n+=o}return n&&e.push(n),e}function Rp(s){const e=s.trim();if(!e)return{code:null,context:null,stateKey:null};try{const n=new URL(e),a=n.searchParams.get("code");if(typeof a=="string"&&a.trim())return{code:a.trim(),context:Ap(n.searchParams),stateKey:Rl(n.searchParams)}}catch{}return{code:e,context:null,stateKey:null}}const Tp=({value:s,onChange:e,pasteCommandTitle:n,pasteCommandLabel:a,pasteSuccess:r,clipboardReadFailed:i,preview:o})=>{const[d,c]=l.useState(()=>s.join(`
|
|
4
|
+
`)),x=l.useRef(s);l.useEffect(()=>{JSON.stringify(x.current)!==JSON.stringify(s)&&(x.current=s,c(s.join(`
|
|
5
|
+
`)))},[s]);const m=u=>{const C=u.split(`
|
|
6
|
+
`).filter(f=>f.trim().length>0);e(C)},p=async()=>{try{const C=(await navigator.clipboard.readText()).trim(),f=C.includes(`
|
|
7
|
+
`)?C.split(`
|
|
8
|
+
`).filter(g=>g.trim()):Mp(C);c(f.join(`
|
|
9
|
+
`)),e(f),_.success(r(f.length))}catch{_.error(i)}};return t.jsxs("div",{className:"space-y-2","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",children:[t.jsx("div",{className:"flex items-center justify-end gap-2",children:t.jsxs(J,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:p,type:"button",title:n,children:[t.jsx(A,{name:"clipboard",className:"h-3 w-3"}),a]})}),t.jsx(hs,{value:d,onChange:u=>{c(u.target.value),m(u.target.value)},onBlur:()=>{const u=d.split(`
|
|
10
|
+
`).map(C=>C.trimEnd()).join(`
|
|
11
|
+
`);c(u),m(u)},placeholder:`npx
|
|
12
|
+
-y
|
|
13
|
+
@modelcontextprotocol/server-postgres
|
|
14
|
+
postgresql://user:pass@host/db`,rows:Math.max(4,s.length+1),className:"font-mono typography-meta resize-y min-h-[80px]",spellCheck:!1}),s.length>0&&t.jsxs("details",{className:"group",children:[t.jsx("summary",{className:"typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground",children:o(s.length)}),t.jsx("div",{className:"mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto",children:t.jsx("code",{className:"typography-micro text-foreground/80 whitespace-pre",children:s.map((u,C)=>t.jsxs("span",{className:"block",children:[t.jsxs("span",{className:"text-muted-foreground select-none mr-2",children:["[",C,"]"]}),u]},C))})})]})]})},Fp=s=>s.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),Zi=({value:s,onChange:e,keyTransform:n=Fp,keyPlaceholder:a="API_KEY",keyInputClassName:r="w-36 shrink-0 font-mono typography-meta uppercase",pasteLabel:i="Paste .env",pasteTitle:o="Paste KEY=VALUE lines from clipboard",noPairsFoundError:d,importSuccess:c,clipboardReadFailed:x,keyLabel:m,valueLabel:p,valuePlaceholder:u,hideValueTitle:C,showValueTitle:f,addVariable:g,plainTextWarning:h,removeVariableAria:D})=>{const[k,w]=l.useState(new Set),E=()=>e([...s,{key:"",value:""}]),N=M=>{e(s.filter((I,v)=>v!==M)),w(I=>{const v=new Set(I);return v.delete(M),v})},y=(M,I,v)=>{const j=[...s];j[M]={...j[M],[I]:v},e(j)},b=M=>{w(I=>{const v=new Set(I);return v.has(M)?v.delete(M):v.add(M),v})},P=async()=>{try{const M=await navigator.clipboard.readText(),I=[];for(const j of M.split(`
|
|
15
|
+
`)){const O=j.trim();if(!O||O.startsWith("#"))continue;const T=O.indexOf("=");if(T===-1)continue;const B=O.slice(0,T).trim();let U=O.slice(T+1).trim();(U.startsWith('"')&&U.endsWith('"')||U.startsWith("'")&&U.endsWith("'"))&&(U=U.slice(1,-1)),B&&I.push({key:B,value:U})}if(I.length===0){_.error(d);return}const v=[...s];for(const j of I){const O=v.findIndex(T=>T.key===j.key);O!==-1?v[O]=j:v.push(j)}e(v),_.success(c(I.length))}catch{_.error(x)}},z=s.some(M=>M.value.length>0);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"typography-micro text-muted-foreground w-32 shrink-0",children:m}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:p})]}),t.jsxs(J,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:P,type:"button",title:o,children:[t.jsx(A,{name:"clipboard",className:"h-3 w-3"}),i]})]}),t.jsx("div",{className:"space-y-1.5",children:s.map((M,I)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ot,{value:M.key,onChange:v=>y(I,"key",n(v.target.value)),placeholder:a,className:r,"data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),t.jsxs("div",{className:"relative flex-1 flex items-center",children:[t.jsx(ot,{type:k.has(I)?"text":"password",value:M.value,onChange:v=>y(I,"value",v.target.value),placeholder:u,className:"font-mono typography-meta pr-8 w-full",autoComplete:"new-password","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),t.jsx("button",{type:"button",onClick:()=>b(I),className:"absolute right-2 text-muted-foreground/60 hover:text-muted-foreground",title:k.has(I)?C:f,children:k.has(I)?t.jsx(A,{name:"eye-off",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"eye",className:"h-3.5 w-3.5"})})]}),t.jsx(J,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>N(I),"aria-label":D,children:t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},I))}),t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:E,type:"button",children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),g]}),z&&t.jsx("p",{className:"typography-micro text-muted-foreground/60",children:h})]})},eo=s=>{const e=rt.c(14),{status:n,enabled:a,getStatusLabel:r,variant:i}=s,o=i===void 0?"compact":i;if(!a||!n)return null;let d,c;if(e[0]!==r||e[1]!==n||e[2]!==o){c=Symbol.for("react.early_return_sentinel");e:{const u={connected:{text:"text-[var(--status-success)]",bg:"bg-[var(--status-success)]/10"},failed:{text:"text-[var(--status-error)]",bg:"bg-[var(--status-error)]/10"},needs_auth:{text:"text-[var(--status-warning)]",bg:"bg-[var(--status-warning)]/10"},needs_client_registration:{text:"text-[var(--status-warning)]",bg:"bg-[var(--status-warning)]/10"}}[n]??{text:"text-muted-foreground",bg:""};if(o==="pill"){const C=ce("typography-micro font-medium rounded-full px-2 py-0.5",u.text,u.bg);let f;e[5]!==r||e[6]!==n?(f=r(n),e[5]=r,e[6]=n,e[7]=f):f=e[7],c=t.jsxs("span",{className:C,children:["● ",f]});break e}d=ce("typography-micro font-medium",u.text)}e[0]=r,e[1]=n,e[2]=o,e[3]=d,e[4]=c}else d=e[3],c=e[4];if(c!==Symbol.for("react.early_return_sentinel"))return c;let x;e[8]!==r||e[9]!==n?(x=r(n),e[8]=r,e[9]=n,e[10]=x):x=e[10];let m;return e[11]!==d||e[12]!==x?(m=t.jsxs("span",{className:d,children:["● ",x]}),e[11]=d,e[12]=x,e[13]=m):m=e[13],m},Op=(s,e,n)=>{switch(s){case"connected":return e("settings.mcp.page.status.description.connected");case"failed":return n?.trim()||e("settings.mcp.page.status.description.failedDefault");case"needs_auth":return e("settings.mcp.page.status.description.needsAuth");case"needs_client_registration":return n?.trim()||e("settings.mcp.page.status.description.needsClientRegistrationDefault");case"disabled":return e("settings.mcp.page.status.description.disabled");default:return e("settings.mcp.page.status.description.default")}},Lp=s=>{switch(s){case"failed":return"border-[var(--status-error-border)] bg-[var(--status-error-background)]";case"needs_auth":case"needs_client_registration":return"border-[var(--status-warning-border)] bg-[var(--status-warning-background)]";default:return"border-[var(--interactive-border)] bg-[var(--surface-elevated)]"}},zp=(s,e,n,a)=>!!(s==="failed"||s==="needs_auth"||s==="needs_client_registration"||e||n||a),to=(s,e)=>{if(typeof window>"u")return null;const n=new URL(Ip,ea()||window.location.origin);return typeof s=="string"&&s.trim()&&n.searchParams.set("server",s.trim()),typeof e=="string"&&e.trim()&&n.searchParams.set("directory",e.trim()),n.toString()},Kp=async s=>{const e=await yt("/api/mcp/auth/pending",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:s.state,name:s.name,directory:typeof s.directory=="string"&&s.directory.trim()?s.directory.trim():null})});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error(n?.error||"Failed to prepare MCP authorization callback")}},$p=async s=>{const e=await yt(`/api/mcp/auth/pending?state=${encodeURIComponent(s)}`);if(!e.ok)return null;const n=await e.json().catch(()=>null);return n?.name?.trim()?{name:n.name.trim(),directory:typeof n.directory=="string"&&n.directory.trim()?n.directory.trim():null}:null},Vn=async s=>{typeof s!="string"||!s.trim()||await yt(`/api/mcp/auth/pending?state=${encodeURIComponent(s.trim())}`,{method:"DELETE"}).catch(()=>{})},rr=(s,e,n)=>{const a=s instanceof Error?s.message:e;return/oauth state required/i.test(a)?n("settings.mcp.page.toast.authSessionExpired"):a},Bp=(s,e)=>{const n=typeof e=="string"&&e.trim()?e.trim():"__global__";return`${s??"__none__"}::${n}`},Up=()=>{const{t:s}=dt(),e=l.useCallback((Se,vt)=>s(Se,vt),[s]),{selectedMcpName:n,mcpServers:a,mcpDraft:r,setMcpDraft:i,setSelectedMcp:o,getMcpByName:d,createMcp:c,updateMcp:x,deleteMcp:m}=Rn(Ss(Se=>({selectedMcpName:Se.selectedMcpName,mcpServers:Se.mcpServers,mcpDraft:Se.mcpDraft,setMcpDraft:Se.setMcpDraft,setSelectedMcp:Se.setSelectedMcp,getMcpByName:Se.getMcpByName,createMcp:Se.createMcp,updateMcp:Se.updateMcp,deleteMcp:Se.deleteMcp}))),p=ys(Se=>Se.currentDirectory),u=l.useMemo(()=>fs(),[]),C=ls(Se=>Se.getStatusForDirectory(p??null)),f=ls(Se=>Se.getDiagnosticForDirectory(p??null)),g=ls(Se=>Se.refresh),h=ls(Se=>Se.connect),D=ls(Se=>Se.disconnect),k=ls(Se=>Se.startAuth),w=ls(Se=>Se.completeAuth),E=ls(Se=>Se.clearAuth),N=ls(Se=>Se.testConnection),y=n?d(n):null,b=!!(r&&r.name===n&&!y),[P,z]=l.useState(""),[M,I]=l.useState("user"),[v,j]=l.useState("local"),[O,T]=l.useState([]),[B,U]=l.useState(""),[Q,q]=l.useState([]),[R,Y]=l.useState([]),[F,W]=l.useState(!0),[X,re]=l.useState(""),[Z,de]=l.useState(""),[le,ee]=l.useState(""),[xe,we]=l.useState(""),[he,Ie]=l.useState(""),[be,je]=l.useState(!0),[ye,se]=l.useState(!1),[ie,ge]=l.useState(!1),[V,te]=l.useState(!1),[ne,ue]=l.useState(!1),[Me,ke]=l.useState(!1),[Re,Ae]=l.useState(!1),[Pe,Te]=l.useState(!1),[Fe,Be]=l.useState(!1),[We,ze]=l.useState(null),[Qe,oe]=l.useState(null),[H,me]=l.useState(""),[Ne,Ee]=l.useState(!1),Ce=l.useRef(0),_e=l.useRef(!1),[G,$]=l.useState(!1),[fe,L]=l.useState(!1),[Le,Je]=l.useState(""),[Xe,et]=l.useState(null),at=l.useMemo(()=>Bp(n,p),[p,n]),ct=l.useRef(at),Ze=l.useRef(null),He=l.useCallback(()=>{ze(null),oe(null),me(""),Ee(!1),Ce.current=0,Be(!1),ke(!1),Ae(!1),_e.current=!1},[]),mt=l.useCallback(()=>{Je(""),et(null),L(!0)},[]),pe=l.useCallback(async()=>{try{const Se=await navigator.clipboard.readText();Je(Se),et(null)}catch{_.error(s("settings.mcp.page.toast.clipboardReadFailed"))}},[s]),nt=l.useCallback(()=>{const Se=Cp(Le,{fallbackName:P});if(!Se.ok){et(Se.error);return}const jt=Pp(Se,{name:P,scope:M,type:v,command:O,url:B,environment:Q,headers:R,oauthEnabled:F,oauthClientId:X,oauthClientSecret:Z,oauthScope:le,oauthRedirectUri:xe,timeout:he,enabled:be},{isNewServer:b});z(jt.name),j(jt.type),T(jt.command??[]),U(jt.url??""),q(jt.environment??[]),Y(jt.headers??[]),W(jt.oauthEnabled??!1),re(jt.oauthClientId??""),de(jt.oauthClientSecret??""),ee(jt.oauthScope??""),we(jt.oauthRedirectUri??""),Ie(jt.timeout??""),je(jt.enabled??!0),L(!1),Je(""),et(null),_.success(s("settings.mcp.page.toast.configImported"))},[Le,P,M,v,O,B,Q,R,F,X,Z,le,xe,he,be,b,s]);l.useEffect(()=>{if(b&&r){z(r.name),I(r.scope||"user"),j(r.type),T(r.command),U(r.url),q(r.environment),Y(r.headers),W(r.oauthEnabled),re(r.oauthClientId),de(r.oauthClientSecret),ee(r.oauthScope),we(r.oauthRedirectUri),Ie(r.timeout),je(r.enabled),$(!1),Ze.current={mcpType:r.type,command:r.command,url:r.url,envEntries:r.environment,headerEntries:r.headers,oauthEnabled:r.oauthEnabled,oauthClientId:r.oauthClientId,oauthClientSecret:r.oauthClientSecret,oauthScope:r.oauthScope,oauthRedirectUri:r.oauthRedirectUri,timeout:r.timeout,enabled:r.enabled};return}if(y){I(y.scope==="project"?"project":"user");const Se=Ai(y.environment),vt=y.type==="remote"?y:null,jt=Ai(vt?.headers),lt=vt?.oauth,Et=lt&&typeof lt=="object"?lt:null,qt=lt!==!1,os=y.type,as=os==="local"?y.command??[]:[],Es=os==="remote"?y.url??"":"",Jt=typeof vt?.timeout=="number"&&Number.isFinite(vt.timeout)?String(vt.timeout):"";j(os),T(as),U(Es),q(Se),Y(jt),W(qt),re(qt?Et?.clientId??"":""),de(qt?Et?.clientSecret??"":""),ee(qt?Et?.scope??"":""),we(qt?Et?.redirectUri??"":""),Ie(Jt),je(y.enabled),$(!1),Ze.current={mcpType:os,command:as,url:Es,envEntries:Se,headerEntries:jt,oauthEnabled:qt,oauthClientId:qt?Et?.clientId??"":"",oauthClientSecret:qt?Et?.clientSecret??"":"",oauthScope:qt?Et?.scope??"":"",oauthRedirectUri:qt?Et?.redirectUri??"":"",timeout:Jt,enabled:y.enabled}}},[y,b,r]);const st=l.useMemo(()=>{const Se=Ze.current;return Se?v!==Se.mcpType||be!==Se.enabled||JSON.stringify(O)!==JSON.stringify(Se.command)||B!==Se.url||JSON.stringify(Q)!==JSON.stringify(Se.envEntries)||JSON.stringify(R)!==JSON.stringify(Se.headerEntries)||F!==Se.oauthEnabled||X!==Se.oauthClientId||Z!==Se.oauthClientSecret||le!==Se.oauthScope||xe!==Se.oauthRedirectUri||he!==Se.timeout:!1},[v,O,B,Q,R,F,X,Z,le,xe,he,be]),Ge=async()=>{const Se=b?P.trim():n??"";if(!Se){_.error(s("settings.mcp.page.toast.nameRequired"));return}if(b&&a.some(jt=>jt.name===Se)){_.error(s("settings.mcp.page.toast.serverNameExists"));return}if(v==="local"&&O.filter(Boolean).length===0){_.error(s("settings.mcp.page.toast.localCommandRequired"));return}if(v==="remote"&&!B.trim()){_.error(s("settings.mcp.page.toast.remoteUrlRequired"));return}const vt={name:Se,scope:M,type:v,command:O,url:B,environment:Q,headers:R,oauthEnabled:F,oauthClientId:X,oauthClientSecret:Z,oauthScope:le,oauthRedirectUri:xe,timeout:he,enabled:be};se(!0);try{const jt=b?await c(vt):await x(Se,vt);jt.ok?(await Vn(Qe),He(),b&&(i(null),o(Se)),await g({directory:p,silent:!0}),jt.reloadFailed?_.warning(jt.message||s(b?"settings.mcp.page.toast.serverCreatedReloadFailed":"settings.mcp.page.toast.savedReloadFailed"),{description:jt.warning||s("settings.mcp.page.toast.retryRefreshHint")}):_.success(jt.message||s(b?"settings.mcp.page.toast.serverCreatedReloading":"settings.mcp.page.toast.savedReloading"))):_.error(s("settings.mcp.page.toast.saveFailed"))}catch(jt){_.error(jt instanceof Error?jt.message:s("settings.mcp.page.toast.unexpectedError"))}finally{se(!1)}},ht=async()=>{if(!n)return;te(!0);const Se=await m(n);Se.ok?(await Vn(Qe),He(),Se.reloadFailed?_.warning(Se.message||s("settings.mcp.page.toast.serverDeletedReloadFailed",{name:n}),{description:Se.warning||s("settings.mcp.page.toast.refreshListIfStale")}):_.success(Se.message||s("settings.mcp.page.toast.serverDeleted",{name:n})),ge(!1)):_.error(s("settings.mcp.page.toast.deleteFailed")),te(!1)},wt=async()=>{if(n){ue(!0);try{if(C[n]?.status==="connected")await D(n,p),_.success(s("settings.mcp.page.toast.disconnected"));else{await h(n,p),await g({directory:p,silent:!0});const vt=ls.getState().getStatusForDirectory(p??null)[n];vt?.status==="connected"?_.success(s("settings.mcp.page.toast.connected")):vt?.status==="needs_auth"?_.message(s("settings.mcp.page.toast.connectionNeedsAuthorization")):vt?.status==="needs_client_registration"?_.message(s("settings.mcp.page.toast.connectionNeedsClientRegistration")):vt?.status==="failed"?_.error(vt.error||s("settings.mcp.page.toast.connectionFailed")):_.message(s("settings.mcp.page.toast.connectionAttemptFinished"));return}await g({directory:p,silent:!0})}catch(Se){_.error(Se instanceof Error?Se.message:s("settings.mcp.page.toast.connectionFailed"))}finally{ue(!1)}}},Nt=l.useCallback(()=>b?(_.error(s("settings.mcp.page.toast.createServerBeforeLiveActions")),!1):st?(_.error(s("settings.mcp.page.toast.saveBeforeLiveActions")),!1):!0,[st,b,s]),ae=l.useCallback(async(Se=!1)=>{try{await g({directory:p,silent:Se})}catch(vt){Se||_.error(vt instanceof Error?vt.message:s("settings.mcp.page.toast.refreshStatusFailed"))}},[p,g,s]);l.useEffect(()=>{ae(!0)},[ae]),l.useEffect(()=>{ct.current=at,ue(!1),Te(!1),He()},[He,at]);const Ue=l.useCallback(async()=>{if(!n||v!=="remote"||!Nt())return;ke(!0);const Se=at;let vt=null;try{const jt=ls.getState().getStatusForDirectory(p??null)[n]?.status;_e.current=jt==="needs_auth"||jt==="needs_client_registration";const lt=to(n,p);if(!lt)throw new Error(s("settings.mcp.page.toast.oauthRedirectUrlBuildFailed"));if(!xe.trim()&&!u){const as=await x(n,{oauthEnabled:F,oauthClientId:X,oauthClientSecret:Z,oauthScope:le,oauthRedirectUri:lt});if(!as.ok)throw new Error(s("settings.mcp.page.toast.oauthBrowserCallbackSaveFailed"));if(as.reloadFailed)throw new Error(as.warning||as.message||s("settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave"));if(ct.current!==Se)return;we(lt),Ze.current=Ze.current?{...Ze.current,oauthRedirectUri:lt}:Ze.current}const Et=await k(n,p),qt=Rl(new URL(Et).searchParams);if(qt&&(vt=qt,await Kp({state:qt,name:n,directory:p})),ct.current!==Se)return;ze(Et),oe(qt??null),Ee(!0),Ce.current=0;const os=await Ws(Et);if(ct.current!==Se)return;os?_.message(s(u?"settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste":"settings.mcp.page.toast.completeAuthorizationInBrowser")):_.error(s("settings.mcp.page.toast.openAuthorizationUrlFailed"))}catch(jt){await Vn(vt),ct.current===Se&&_.error(rr(jt,s("settings.mcp.page.toast.authorizationStartFailed"),e))}finally{ct.current===Se&&ke(!1)}},[p,u,v,X,Z,F,xe,le,Nt,at,n,k,s,e,x]),tt=l.useCallback(async()=>{if(!n||!Nt())return;Ae(!0);const Se=at;try{if(await E(n,p),ct.current!==Se)return;ze(null),oe(null),me(""),Ee(!1),Ce.current=0,await Vn(Qe),_.success(s("settings.mcp.page.toast.savedAuthorizationRemoved"))}catch(vt){ct.current===Se&&_.error(rr(vt,s("settings.mcp.page.toast.clearAuthorizationFailed"),e))}finally{ct.current===Se&&Ae(!1)}},[Qe,E,p,Nt,at,n,s,e]),Ye=l.useCallback(async()=>{if(!We)return;if((await mn(We)).ok){_.success(s("settings.mcp.page.toast.authorizationUrlCopied"));return}_.error(s("settings.mcp.page.toast.authorizationUrlCopyFailed"))},[We,s]),ft=l.useCallback(async()=>{const Se=Rp(H);if(!Se.code){_.error(s("settings.mcp.page.toast.pasteCallbackOrCodeFirst"));return}const vt=Se.stateKey?await $p(Se.stateKey):null,jt=Se.context??vt,lt=jt?.name??n,Et=jt?.directory??p;if(!lt){_.error(s("settings.mcp.page.toast.missingServerDetails"));return}if(!jt&&!Nt())return;Be(!0);const qt=at;try{if(await w(lt,Se.code,Et),await Vn(Se.stateKey??Qe),ct.current!==qt)return;me(""),ze(null),oe(null),Ee(!1),Ce.current=0,_.success(lt===n?s("settings.mcp.page.toast.authorizationCompleted"):s("settings.mcp.page.toast.authorizationCompletedFor",{name:lt}))}catch(os){ct.current===qt&&_.error(rr(os,s("settings.mcp.page.toast.authorizationCompleteFailed"),e))}finally{ct.current===qt&&Be(!1)}},[H,Qe,w,p,Nt,at,n,s,e]),$e=l.useCallback(async()=>{if(!(!n||!Nt())){if(!be){_.error(s("settings.mcp.page.toast.enableServerBeforeTest"));return}Te(!0);try{const Se=await N(n,p),vt=Se.status?.status;Se.warning?_.warning(Se.warning):vt==="connected"?_.success(s("settings.mcp.page.toast.connectionTestSucceeded")):vt==="needs_auth"?_.message(s("settings.mcp.page.toast.connectionNeedsAuthorization")):vt==="needs_client_registration"?_.message(s("settings.mcp.page.toast.connectionNeedsClientRegistration")):vt==="failed"?_.error(Se.status?.error||Se.error||s("settings.mcp.page.toast.connectionTestFailed")):Se.error?_.error(Se.error):_.message(s("settings.mcp.page.toast.connectionTestFinished"))}catch(Se){_.error(Se instanceof Error?Se.message:s("settings.mcp.page.toast.connectionTestFailed"))}finally{Te(!1)}}},[p,be,Nt,n,s,N]);if(l.useEffect(()=>{if(!Ne||!n)return;const Se=window.setInterval(()=>{(async()=>{Ce.current+=1,await g({directory:p,silent:!0});const vt=ls.getState().getStatusForDirectory(p??null)[n];if(vt){if(_e.current&&vt.status!=="needs_auth"&&vt.status!=="needs_client_registration"){Ee(!1),Ce.current=0,_e.current=!1,ze(null),me(""),vt.status==="connected"&&_.success(s("settings.mcp.page.toast.authorizationCompleted"));return}if(!_e.current&&vt.status==="failed"){Ee(!1),Ce.current=0,_e.current=!1,_.error(vt.error||s("settings.mcp.page.toast.authorizationFailed"));return}Ce.current>=30&&(Ee(!1),Ce.current=0,_e.current=!1,_.message(s("settings.mcp.page.toast.authorizationStillInProgress")))}})()},2e3);return()=>{window.clearInterval(Se)}},[p,Ne,g,n,s]),!n)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"plug",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.mcp.page.empty.selectServer")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.mcp.page.empty.addNewOne")})]})});const Ve=C[n],it=n?f[n]:void 0,xt=Ve??it,At=Ve?.status==="connected",Zt=Ve?.status==="needs_auth"||Ve?.status==="needs_client_registration",ts=u?null:to(n,p),ss=Op(xt?.status,e,xt&&"error"in xt?xt.error:void 0),Vt=Se=>{switch(Se){case"connected":return s("settings.mcp.page.status.label.connected");case"failed":return s("settings.mcp.page.status.label.failed");case"needs_auth":return s("settings.mcp.page.status.label.needsAuth");case"needs_client_registration":return s("settings.mcp.page.status.label.needsRegistration");default:return Se}};return t.jsxs(Gt,{outerClassName:"h-full",className:"w-full",children:[t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"min-w-0",children:[b?t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.mcp.page.header.newServer")}):t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:n}),t.jsx(eo,{status:xt?.status,enabled:be,getStatusLabel:Vt,variant:"pill"})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:b?s("settings.mcp.page.header.configureNewServer"):s("settings.mcp.page.header.transport",{type:s(v==="local"?"settings.mcp.page.transport.local":"settings.mcp.page.transport.remote")})}),!b&&t.jsxs(t.Fragment,{children:[t.jsx(J,{variant:At?"outline":"default",size:"xs",className:"!font-normal",onClick:wt,disabled:ne||!be,children:s(ne?"settings.mcp.page.actions.working":At?"settings.mcp.page.actions.disconnect":"settings.mcp.page.actions.connect")}),v==="remote"&&t.jsxs(t.Fragment,{children:[t.jsx(J,{variant:Zt?"default":"outline",size:"xs",className:"!font-normal",onClick:()=>{Ue()},disabled:Me||!be,children:s(Me?"settings.mcp.page.actions.starting":Zt?"settings.mcp.page.actions.authorize":"settings.mcp.page.actions.reauthorize")}),t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{tt()},disabled:Re||!be,children:s(Re?"settings.mcp.page.actions.clearing":"settings.mcp.page.actions.clearAuth")})]}),At&&t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{$e()},disabled:Pe||!be,children:s(Pe?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.test")})]})]})]})}),!b&&zp(xt?.status,We,Zt,Ne)&&t.jsx("div",{className:"mb-6 px-2",children:t.jsxs("div",{className:ce("rounded-lg border p-3",Lp(xt?.status)),children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.status.runtimeStatus")}),t.jsx(eo,{status:xt?.status,enabled:be,getStatusLabel:Vt})]}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:ss}),t.jsx("p",{className:"typography-micro text-muted-foreground/80",children:M==="project"?s("settings.mcp.page.status.projectScopedTo",{directory:p??s("settings.mcp.page.status.activeProject")}):s("settings.mcp.page.status.userScoped")})]}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:!At&&t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{$e()},disabled:Pe||!be,children:s(Pe?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.testConnection")})}),We&&t.jsx("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-micro text-muted-foreground",children:s("settings.mcp.page.auth.authorizationUrl")}),t.jsx("div",{className:"break-all typography-micro text-foreground font-mono",children:We}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ws(We)},children:[t.jsx(A,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.mcp.page.actions.openInBrowser")]}),t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ye()},children:[t.jsx(A,{name:"clipboard",className:"h-3.5 w-3.5"}),s("settings.mcp.page.actions.copyLink")]})]})]})}),v==="remote"&&(Zt||Ne||We)&&t.jsx("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.auth.manualFallbackTitle")}),t.jsx("p",{className:"mt-1 typography-micro text-muted-foreground",children:s("settings.mcp.page.auth.manualFallbackDescription")})]}),t.jsx(hs,{value:H,onChange:Se=>me(Se.target.value),placeholder:s("settings.mcp.page.auth.callbackInputPlaceholder"),rows:3,className:"font-mono typography-meta resize-y","data-bwignore":"true","data-1p-ignore":"true",spellCheck:!1}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{ft()},disabled:Fe,children:s(Fe?"settings.mcp.page.actions.completing":"settings.mcp.page.actions.completeAuthorization")})})]})})]}),Ne&&t.jsx("p",{className:"mt-4 typography-micro text-muted-foreground",children:s("settings.mcp.page.auth.waitingForOpenCode")})]})}),t.jsxs("div",{"data-settings-item":"mcp.server",className:"mb-6",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.mcp.page.server.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[b&&t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.server.name")})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsx(ot,{value:P,onChange:Se=>z(Se.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"-")),placeholder:s("settings.mcp.page.server.namePlaceholder"),className:"h-7 w-48 font-mono px-2",autoFocus:!0}),t.jsxs(Mt,{value:M,onValueChange:Se=>I(Se),children:[t.jsx(Rt,{className:"!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden",title:s(M==="user"?"settings.common.scope.global":"settings.common.scope.project"),children:M==="user"?t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"})}),t.jsxs(Tt,{align:"end",children:[t.jsx(gt,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.global")})]})}),t.jsx(gt,{value:"project",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.project")})]})})]})]})]})]}),b&&t.jsx("div",{className:"py-1.5",children:t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:mt,type:"button",title:s("settings.mcp.page.server.importJsonTitle"),children:[t.jsx(A,{name:"file-code",className:"h-3.5 w-3.5"}),s("settings.mcp.page.server.importJson")]})}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":be,onClick:()=>je(!be),onKeyDown:Se=>{(Se.key===" "||Se.key==="Enter")&&(Se.preventDefault(),je(!be))},children:[t.jsx(St,{checked:be,onChange:je,ariaLabel:s("settings.mcp.page.server.enableAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.server.enable")})]}),t.jsx("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:t.jsxs("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.server.transportMode")}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(J,{variant:"chip",size:"xs","aria-pressed":v==="local",onClick:()=>j("local"),className:"!font-normal",children:s("settings.mcp.page.transport.local")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":v==="remote",onClick:()=>j("remote"),className:"!font-normal",children:s("settings.mcp.page.transport.remote")})]})]})})]})]}),t.jsxs("div",{"data-settings-item":"mcp.command",className:"mb-6",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s(v==="local"?"settings.mcp.page.connection.command":"settings.mcp.page.connection.serverUrl")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:v==="local"?t.jsx(Tp,{value:O,onChange:T,pasteCommandTitle:s("settings.mcp.page.connection.pasteCommandTitle"),pasteCommandLabel:s("settings.mcp.page.connection.pasteCommand"),pasteSuccess:Se=>s("settings.mcp.page.toast.pastedArgumentsCount",{count:Se}),clipboardReadFailed:s("settings.mcp.page.toast.clipboardReadFailed"),preview:Se=>s("settings.mcp.page.connection.previewArgs",{count:Se})}):t.jsx(ot,{value:B,onChange:Se=>U(Se.target.value),placeholder:s("settings.mcp.page.connection.serverUrlPlaceholder"),className:"font-mono typography-meta"})})]}),v==="remote"&&t.jsxs("div",{"data-settings-item":"mcp.advanced",className:"mb-6",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.mcp.page.advanced.title")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs(pn,{open:G,onOpenChange:$,children:[t.jsxs(gn,{className:"flex w-full items-center justify-between py-0.5 group",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[t.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:s("settings.mcp.page.advanced.configure")}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",s(F?"settings.mcp.page.advanced.autoDetect":"settings.mcp.page.advanced.custom")," · ",R.length," ",s("settings.mcp.page.advanced.headers"),he?` · ${he}ms`:"",")"]})]}),G?t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(A,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(hn,{className:"pt-2",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.advanced.timeoutMs")})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(ot,{type:"number",min:"1",step:"1",value:he,onChange:Se=>Ie(Se.target.value),placeholder:"5000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})})]}),t.jsx("p",{className:"typography-micro text-muted-foreground sm:pl-64",children:s("settings.mcp.page.advanced.timeoutHint")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"mb-2 typography-ui-label text-foreground",children:[s("settings.mcp.page.advanced.requestHeaders"),R.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",R.length,")"]})]}),t.jsx(Zi,{value:R,onChange:Y,keyTransform:Se=>Se.trimStart(),keyPlaceholder:s("settings.mcp.page.advanced.headerNamePlaceholder"),keyInputClassName:"w-36 shrink-0 font-mono typography-meta",pasteLabel:s("settings.mcp.page.advanced.pasteHeaders"),pasteTitle:s("settings.mcp.page.advanced.pasteHeadersTitle"),noPairsFoundError:s("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:Se=>s("settings.mcp.page.toast.importedVariablesCount",{count:Se}),clipboardReadFailed:s("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:s("settings.mcp.page.env.key"),valueLabel:s("settings.mcp.page.env.value"),valuePlaceholder:s("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:s("settings.mcp.page.env.hide"),showValueTitle:s("settings.mcp.page.env.show"),addVariable:s("settings.mcp.page.env.addVariable"),plainTextWarning:s("settings.mcp.page.env.plainTextWarning"),removeVariableAria:s("settings.mcp.page.env.removeVariableAria")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":F,onClick:()=>W(!F),onKeyDown:Se=>{(Se.key===" "||Se.key==="Enter")&&(Se.preventDefault(),W(!F))},children:[t.jsx(St,{checked:F,onChange:W,ariaLabel:s("settings.mcp.page.advanced.oauthAutoDetectionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.advanced.oauthAutoDetection")})]}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsx(ot,{value:X,onChange:Se=>re(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthClientIdPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(ot,{value:Z,onChange:Se=>de(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthClientSecretPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(ot,{value:le,onChange:Se=>ee(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthScopesPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(ot,{value:xe,onChange:Se=>we(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthRedirectUriPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:s("settings.mcp.page.advanced.oauthHint")}),ts&&t.jsxs("p",{className:"typography-micro text-muted-foreground",children:[s("settings.mcp.page.advanced.oauthCallbackHint"),t.jsx("span",{className:"mt-1 block break-all font-mono text-foreground/80",children:ts})]})]})]})})]})})]}),t.jsxs("div",{"data-settings-item":"mcp.environment",className:"mb-2",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("h3",{className:"typography-ui-header font-medium text-foreground",children:[s("settings.mcp.page.env.title"),Q.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",Q.length,")"]})]})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:Q.length===0?t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:()=>q([{key:"",value:""}]),children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),s("settings.mcp.page.env.addEnvironmentVariable")]}):t.jsx(Zi,{value:Q,onChange:q,keyPlaceholder:s("settings.mcp.page.env.keyPlaceholder"),pasteLabel:s("settings.mcp.page.env.pasteEnv"),pasteTitle:s("settings.mcp.page.env.pasteEnvTitle"),noPairsFoundError:s("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:Se=>s("settings.mcp.page.toast.importedVariablesCount",{count:Se}),clipboardReadFailed:s("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:s("settings.mcp.page.env.key"),valueLabel:s("settings.mcp.page.env.value"),valuePlaceholder:s("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:s("settings.mcp.page.env.hide"),showValueTitle:s("settings.mcp.page.env.show"),addVariable:s("settings.mcp.page.env.addVariable"),plainTextWarning:s("settings.mcp.page.env.plainTextWarning"),removeVariableAria:s("settings.mcp.page.env.removeVariableAria")})})]}),t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[t.jsx(J,{onClick:Ge,disabled:ye||!st&&!b,size:"xs",className:"!font-normal",children:s(ye?"settings.common.actions.saving":b?"settings.common.actions.create":"settings.common.actions.saveChanges")}),!b&&t.jsx(J,{variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>ge(!0),children:s("settings.common.actions.delete")})]})]}),t.jsx($t,{open:fe,onOpenChange:Se=>{Se||(L(!1),Je(""),et(null))},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.mcp.page.importDialog.title")}),t.jsx(Wt,{children:s("settings.mcp.page.importDialog.description")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(hs,{value:Le,onChange:Se=>{Je(Se.target.value),et(null)},placeholder:`{
|
|
16
|
+
"mcpServers": {
|
|
17
|
+
"postgres": {
|
|
18
|
+
"command": "npx",
|
|
19
|
+
"args": ["-y", "@modelcontextprotocol/server-postgres"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}`,rows:8,className:"font-mono typography-meta resize-y",spellCheck:!1,"data-bwignore":"true","data-1p-ignore":"true"}),Xe&&t.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:Xe}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:pe,type:"button",children:[t.jsx(A,{name:"clipboard",className:"h-3.5 w-3.5"}),s("settings.mcp.page.importDialog.pasteFromClipboard")]})})]}),t.jsxs(Yt,{children:[t.jsx(J,{variant:"outline",onClick:()=>{L(!1),Je(""),et(null)},className:"text-foreground",children:s("settings.common.actions.cancel")}),t.jsx(J,{onClick:nt,disabled:!Le.trim(),size:"sm",children:s("settings.common.actions.import")})]})]})}),t.jsx($t,{open:ie,onOpenChange:Se=>{!Se&&!V&&ge(!1)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.mcp.page.deleteDialog.title",{name:n??""})}),t.jsxs(Wt,{children:[s("settings.mcp.page.deleteDialog.descriptionPrefix")," ",t.jsx("code",{className:"text-foreground",children:"opencode.json"}),"."," ",s("settings.mcp.page.deleteDialog.descriptionSuffix")]})]}),t.jsxs(Yt,{children:[t.jsx(J,{variant:"outline",onClick:()=>ge(!1),disabled:V,className:"text-foreground",children:s("settings.common.actions.cancel")}),t.jsx(J,{variant:"destructive",size:"sm",onClick:ht,disabled:V,children:s(V?"settings.mcp.page.actions.deleting":"settings.common.actions.delete")})]})]})})]})},Vp=({transform:s})=>({...s,y:0}),_p=s=>{const e=rt.c(18),{id:n,children:a,className:r}=s;let i;e[0]!==n?(i={id:n},e[0]=n,e[1]=i):i=e[1];const{attributes:o,listeners:d,setNodeRef:c,transform:x,transition:m,isDragging:p}=Ec(i);let u;e[2]!==x?(u=Mc.Transform.toString(x),e[2]=x,e[3]=u):u=e[3];let C;e[4]!==u||e[5]!==m?(C={transform:u,transition:m},e[4]=u,e[5]=m,e[6]=C):C=e[6];const f=p&&"opacity-50";let g;e[7]!==r||e[8]!==f?(g=ce("h-full rounded-md",r,f),e[7]=r,e[8]=f,e[9]=g):g=e[9];let h;return e[10]!==o||e[11]!==a||e[12]!==n||e[13]!==d||e[14]!==c||e[15]!==C||e[16]!==g?(h=t.jsx("div",{ref:c,"data-sortable-tab-id":n,style:C,className:g,...o,...d,children:a}),e[10]=o,e[11]=a,e[12]=n,e[13]=d,e[14]=c,e[15]=C,e[16]=g,e[17]=h):h=e[17],h},Hp=s=>{const e=rt.c(6),{id:n,children:a,className:r}=s;let i;e[0]!==r?(i=ce("h-full",r),e[0]=r,e[1]=i):i=e[1];let o;return e[2]!==a||e[3]!==n||e[4]!==i?(o=t.jsx("div",{className:i,"data-sortable-tab-id":n,children:a}),e[2]=a,e[3]=n,e[4]=i,e[5]=o):o=e[5],o},fn=s=>{const e=rt.c(121),{items:n,activeId:a,onSelect:r,onClose:i,onReorder:o,layoutMode:d,variant:c,activePillInsetClassName:x,activePillButtonClassName:m,inactiveTabsIconOnly:p,iconOnlyActiveTab:u,animateActivePill:C,activePillLowercase:f,className:g}=s,h=d===void 0?"scrollable":d,D=c===void 0?"default":c,k=p===void 0?!1:p,w=u===void 0?!1:u,E=f===void 0?!0:f,{t:N}=dt(),y=Ke(Wp),{isTablet:b}=Cs(),P=y||b,z=l.useRef(null);let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={left:!1,right:!1},e[0]=M):M=e[0];const[I,v]=l.useState(M);let j;e[1]!==n?(j=n.map(qp),e[1]=n,e[2]=j):j=e[2];const O=j,T=h==="scrollable",B=D==="default",U=D==="active-pill",Q=D==="animated",q=U||Q,R=B,Y=q||R,F=U&&T,W=q,X=C??Q,re=typeof o=="function",Z=re?_p:Hp;let de;e[3]===Symbol.for("react.memo_cache_sentinel")?(de=new Map,e[3]=de):de=e[3];const le=l.useRef(de),[ee,xe]=l.useState(null);let we;e[4]===Symbol.for("react.memo_cache_sentinel")?(we={activationConstraint:{distance:8}},e[4]=we):we=e[4];const he=Ic(Dc(Ac,we)),Ie=Gp;let be;e[5]===Symbol.for("react.memo_cache_sentinel")?(be=(Ze,He)=>{if(He){le.current.set(Ze,He);return}le.current.delete(Ze)},e[5]=be):be=e[5];const je=be;let ye;e[6]!==a||e[7]!==Y?(ye=()=>{if(!Y||!a){xe(Jp);return}const Ze=z.current,He=le.current.get(a);if(!Ze||!He){xe(Qp);return}let mt=0,pe=0,nt=He;for(;nt&&nt!==Ze;)mt=mt+nt.offsetLeft,pe=pe+nt.offsetTop,nt=nt.offsetParent;const st={left:mt,top:pe,width:He.offsetWidth,height:He.offsetHeight};xe(Ge=>Ie(Ge,st)?Ge:st)},e[6]=a,e[7]=Y,e[8]=ye):ye=e[8];const se=ye;let ie;e[9]!==T?(ie=()=>{if(!T){v({left:!1,right:!1});return}const Ze=z.current;if(!Ze){v({left:!1,right:!1});return}v({left:Ze.scrollLeft>2,right:Ze.scrollLeft+Ze.clientWidth<Ze.scrollWidth-2})},e[9]=T,e[10]=ie):ie=e[10];const ge=ie;let V;e[11]!==T||e[12]!==ge?(V=()=>{if(!T){v({left:!1,right:!1});return}const Ze=z.current;if(!Ze)return;ge(),Ze.addEventListener("scroll",ge,{passive:!0});const He=new ResizeObserver(ge);return He.observe(Ze),()=>{Ze.removeEventListener("scroll",ge),He.disconnect()}},e[11]=T,e[12]=ge,e[13]=V):V=e[13];let te;e[14]!==T||e[15]!==n.length||e[16]!==ge?(te=[T,n.length,ge],e[14]=T,e[15]=n.length,e[16]=ge,e[17]=te):te=e[17],l.useEffect(V,te);let ne;e[18]!==a||e[19]!==se||e[20]!==Y?(ne=()=>{if(!Y){xe(null);return}se();const Ze=z.current;if(!Ze)return;const He=new ResizeObserver(se);if(He.observe(Ze),a){const mt=le.current.get(a);mt&&He.observe(mt)}return()=>{He.disconnect()}},e[18]=a,e[19]=se,e[20]=Y,e[21]=ne):ne=e[21];let ue;e[22]!==a||e[23]!==n.length||e[24]!==se||e[25]!==Y?(ue=[a,n.length,se,Y],e[22]=a,e[23]=n.length,e[24]=se,e[25]=Y,e[26]=ue):ue=e[26],l.useEffect(ne,ue);let Me;e[27]!==se?(Me=()=>{se()},e[27]=se,e[28]=Me):Me=e[28],l.useLayoutEffect(Me);let ke;e[29]!==a||e[30]!==T||e[31]!==ge?(ke=()=>{if(!T||!a)return;const Ze=z.current;if(!Ze)return;const He=window.requestAnimationFrame(()=>{const mt=typeof window.CSS?.escape=="function"?window.CSS.escape(a):a.replace(/"/g,'\\"'),pe=Ze.querySelector(`[data-sortable-tab-id="${mt}"]`);pe&&(pe.scrollIntoView({block:"nearest",inline:"nearest"}),ge())});return()=>{window.cancelAnimationFrame(He)}},e[29]=a,e[30]=T,e[31]=ge,e[32]=ke):ke=e[32];let Re;e[33]!==a||e[34]!==T||e[35]!==n.length||e[36]!==ge?(Re=[a,T,n.length,ge],e[33]=a,e[34]=T,e[35]=n.length,e[36]=ge,e[37]=Re):Re=e[37],l.useEffect(ke,Re);let Ae;e[38]!==o?(Ae=Ze=>{if(!o)return;const{active:He,over:mt}=Ze;!mt||He.id===mt.id||o(String(He.id),String(mt.id))},e[38]=o,e[39]=Ae):Ae=e[39];const Pe=Ae;let Te;e[40]!==g?(Te=ce("relative flex h-full min-w-0 flex-1",g),e[40]=g,e[41]=Te):Te=e[41];let Fe;e[42]!==T||e[43]!==I||e[44]!==q?(Fe=T&&I.left?t.jsx("div",{className:ce("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",q?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[42]=T,e[43]=I,e[44]=q,e[45]=Fe):Fe=e[45];let Be;e[46]!==T||e[47]!==I||e[48]!==q?(Be=T&&I.right?t.jsx("div",{className:ce("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",q?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[46]=T,e[47]=I,e[48]=q,e[49]=Be):Be=e[49];const We=q?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",ze=q&&"@container/pill-tabs",Qe=q&&"pill-tabs__track",oe=q&&(x??"gap-0.5 py-0.5"),H=R&&"items-center overflow-y-hidden",me=W&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_2%,transparent)] p-0.5 gap-0.5",Ne=T?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Ee;e[50]!==We||e[51]!==ze||e[52]!==Qe||e[53]!==oe||e[54]!==H||e[55]!==me||e[56]!==Ne?(Ee=ce("relative flex h-full min-w-0 flex-1",We,ze,Qe,oe,H,me,Ne),e[50]=We,e[51]=ze,e[52]=Qe,e[53]=oe,e[54]=H,e[55]=me,e[56]=Ne,e[57]=Ee):Ee=e[57];let Ce;e[58]!==T?(Ce=T?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[58]=T,e[59]=Ce):Ce=e[59];let _e;e[60]!==N?(_e=N("sortableTabsStrip.aria.tabs"),e[60]=N,e[61]=_e):_e=e[61];let G;e[62]!==ee||e[63]!==X||e[64]!==q?(G=q&&ee?t.jsx("div",{className:ce("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-border/60"),style:{transform:`translate3d(${ee.left}px, ${ee.top}px, 0)`,width:`${ee.width}px`,height:`${ee.height}px`,transition:X?"transform 300ms cubic-bezier(0.65, 0, 0.35, 1), width 300ms cubic-bezier(0.65, 0, 0.35, 1), height 300ms cubic-bezier(0.65, 0, 0.35, 1)":void 0}}):null,e[62]=ee,e[63]=X,e[64]=q,e[65]=G):G=e[65];let $;e[66]!==ee||e[67]!==R?($=R&&ee?t.jsx("div",{className:"pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",style:{transform:`translate3d(${ee.left}px, 0, 0)`,width:`${ee.width}px`},"aria-hidden":!0}):null,e[66]=ee,e[67]=R,e[68]=$):$=e[68];let fe;if(e[69]!==Z||e[70]!==a||e[71]!==m||e[72]!==E||e[73]!==P||e[74]!==w||e[75]!==k||e[76]!==U||e[77]!==y||e[78]!==T||e[79]!==n||e[80]!==i||e[81]!==r||e[82]!==F||e[83]!==q){let Ze;e[85]!==Z||e[86]!==a||e[87]!==m||e[88]!==E||e[89]!==P||e[90]!==w||e[91]!==k||e[92]!==U||e[93]!==y||e[94]!==T||e[95]!==i||e[96]!==r||e[97]!==F||e[98]!==q?(Ze=He=>{const mt=He.id===a,pe=k&&q&&!mt&&!!He.icon,nt=!pe,st=!!He.icon&&(!w||mt),Ge=k&&q&&mt&&!T&&!F,ht=He.closable!==!1&&!!i,wt=ht&&!!He.icon,Nt=T||F?void 0:q?Ge?"flex-none basis-auto":y?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",ae=ht?tt=>{tt.button===1&&(tt.preventDefault(),tt.stopPropagation(),i?.(He.id))}:void 0,Ue=ht?Yp:void 0;return t.jsx(Z,{id:He.id,className:Nt,children:t.jsxs("div",{ref:tt=>je(He.id,tt),onAuxClick:ae,onMouseDown:Ue,className:ce("group flex h-full min-w-0 flex-nowrap items-center",T||F?"shrink-0":q?"w-full":"w-full min-w-0",q?"relative z-10 bg-transparent":mt?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":mt,"aria-label":pe?He.title??He.label:void 0,onClick:()=>r(He.id),className:ce(q?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",q&&E?"lowercase":null,q&&(pe?"gap-0":"gap-1.5"),q?F?"shrink-0 whitespace-nowrap px-3 text-center":T?"max-w-56 shrink-0 px-3 text-center":pe?"px-2 !min-w-0 text-center":Ge?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":T?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",q?m??(U?y?"h-[38px]":"h-[31px]":"h-7"):null,q?mt?"text-foreground":"text-muted-foreground hover:text-foreground":null,q?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:He.title??He.label,children:q?t.jsxs(t.Fragment,{children:[st?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:ce("flex items-center justify-center transition-opacity",wt&&(P?"opacity-0":"group-hover:opacity-0")),children:He.icon}),wt?t.jsx("span",{role:"button",tabIndex:-1,className:ce("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",P?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Xp,onClick:tt=>{tt.stopPropagation(),i?.(He.id)},"aria-label":He.closeLabel??`Close ${He.label} tab`,title:He.closeLabel??`Close ${He.label} tab`,children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,nt?t.jsx("span",{className:"animated-tabs__label truncate",children:He.label}):null]}):t.jsxs("span",{className:ce("flex min-w-0 flex-nowrap items-center gap-1.5",!T&&"justify-center"),children:[st?t.jsxs("span",{className:ce("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",mt?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:ce("flex items-center justify-center transition-opacity",wt&&(P?"opacity-0":"group-hover:opacity-0")),children:He.icon}),wt?t.jsx("span",{role:"button",tabIndex:-1,className:ce("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",P?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Zp,onClick:tt=>{tt.stopPropagation(),i?.(He.id)},"aria-label":He.closeLabel??`Close ${He.label} tab`,title:He.closeLabel??`Close ${He.label} tab`,children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:He.label})]})}),ht&&!wt?t.jsx("button",{type:"button",onPointerDown:eg,onClick:tt=>{tt.stopPropagation(),i?.(He.id)},className:ce("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",q?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",q?mt?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":mt?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":He.closeLabel??`Close ${He.label} tab`,title:He.closeLabel??`Close ${He.label} tab`,children:t.jsx(A,{name:"close",className:"h-3 w-3"})}):null]})},He.id)},e[85]=Z,e[86]=a,e[87]=m,e[88]=E,e[89]=P,e[90]=w,e[91]=k,e[92]=U,e[93]=y,e[94]=T,e[95]=i,e[96]=r,e[97]=F,e[98]=q,e[99]=Ze):Ze=e[99],fe=n.map(Ze),e[69]=Z,e[70]=a,e[71]=m,e[72]=E,e[73]=P,e[74]=w,e[75]=k,e[76]=U,e[77]=y,e[78]=T,e[79]=n,e[80]=i,e[81]=r,e[82]=F,e[83]=q,e[84]=fe}else fe=e[84];let L;e[100]!==Ee||e[101]!==Ce||e[102]!==_e||e[103]!==G||e[104]!==$||e[105]!==fe?(L=t.jsxs("div",{ref:z,className:Ee,style:Ce,role:"tablist","aria-label":_e,children:[G,$,fe]}),e[100]=Ee,e[101]=Ce,e[102]=_e,e[103]=G,e[104]=$,e[105]=fe,e[106]=L):L=e[106];let Le;e[107]!==Te||e[108]!==Fe||e[109]!==Be||e[110]!==L?(Le=t.jsxs("div",{className:Te,children:[Fe,Be,L]}),e[107]=Te,e[108]=Fe,e[109]=Be,e[110]=L,e[111]=Le):Le=e[111];const Je=Le;if(!re)return Je;let Xe;e[112]===Symbol.for("react.memo_cache_sentinel")?(Xe=[Vp],e[112]=Xe):Xe=e[112];let et;e[113]!==O||e[114]!==Je?(et=t.jsx(Rc,{items:O,strategy:Tc,children:Je}),e[113]=O,e[114]=Je,e[115]=et):et=e[115];let at;e[116]===Symbol.for("react.memo_cache_sentinel")?(at=t.jsx(Fc,{dropAnimation:null}),e[116]=at):at=e[116];let ct;return e[117]!==Pe||e[118]!==he||e[119]!==et?(ct=t.jsxs(Oc,{sensors:he,collisionDetection:Lc,onDragEnd:Pe,modifiers:Xe,children:[et,at]}),e[117]=Pe,e[118]=he,e[119]=et,e[120]=ct):ct=e[120],ct};function Wp(s){return s.isMobile}function qp(s){return s.id}function Gp(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function Jp(s){return s===null?s:null}function Qp(s){return s===null?s:null}function Yp(s){s.button===1&&s.preventDefault()}function Xp(s){s.stopPropagation()}function Zp(s){s.stopPropagation()}function eg(s){s.stopPropagation()}const Ia=()=>{try{const e=is.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();const n=ws.getDirectory();if(n?.trim())return n.trim()}catch(s){console.warn("[PluginsStore] Error resolving config directory:",s)}return null},tg=800,sg=5e3,ng="__default__",Mr=new Map,ir=new Map,ag=1500,Tl=s=>s?.trim()||ng,rg=s=>{Mr.delete(Tl(s))},cs=rn()(ta(Br((s,e)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:n=>s({selectedId:n}),setDraft:n=>s({draft:n}),loadPlugins:async n=>{const a=Ia(),r=Tl(a),i=Date.now(),o=Mr.get(r)??0,d=e().entries.length>0||e().files.length>0;if(!n?.force&&d&&i-o<sg)return!0;const c=ir.get(r);if(!n?.force&&c)return c;const x=(async()=>{s({isLoading:!0});try{const m=await yt(Xs("/api/config/plugins",a),{headers:_n(a)});if(!m.ok)throw new Error("Failed to load plugins");const p=await Da(m);return s({entries:p.entries??[],files:p.files??[],isLoading:!1}),Mr.set(r,Date.now()),n?.force||e().loadRegistryInfo(),!0}catch(m){return console.error("[PluginsStore] Failed to load plugins:",m),s({isLoading:!1}),!1}})();ir.set(r,x);try{return await x}finally{ir.delete(r)}},loadRegistryInfo:async n=>{const a=og(n?.specs??e().entries.map(r=>r.spec));if(a.length===0){s({isLoadingRegistry:!1});return}s({isLoadingRegistry:!0});try{const r=Ia(),i={...e().registryInfo};for(const o of lg(a)){const d=await yt(ig(o,n?.force===!0,r),{headers:_n(r)});if(!d.ok)throw new Error("Failed to load plugin registry info");const c=await Da(d);for(const x of c.results??[])i[x.spec]=x}s({registryInfo:i,isLoadingRegistry:!1})}catch(r){console.error("[PluginsStore] Failed to load plugin registry info:",r),s({isLoadingRegistry:!1})}},updateToLatest:async n=>{const a=e().entries.find(i=>i.id===n);if(!a)return{ok:!1};const r=e().registryInfo[a.spec];return!r||r.kind!=="npm-ok"||!r.hasUpdate||!r.latestVersion?{ok:!1}:await e().updateEntry(n,{spec:`${r.name}@${r.latestVersion}`})},createEntry:async n=>{const a=await wn("Creating plugin entry…",async r=>await yt(Xs("/api/config/plugins/entry",r),{method:"POST",headers:ga(r),body:JSON.stringify(so(n))}),e);return a.ok&&e().loadRegistryInfo({specs:[n.spec],force:!0}),a},updateEntry:async(n,a)=>{const r=e().entries.find(d=>d.id===n)?.spec,i=a.spec??r,o=await wn("Updating plugin entry…",async d=>await yt(Xs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,d),{method:"PATCH",headers:ga(d),body:JSON.stringify(so(a))}),e);return o.ok&&i&&e().loadRegistryInfo({specs:[i],force:!0}),o},deleteEntry:async n=>{const a=e().entries.find(i=>i.id===n),r=await wn("Deleting plugin entry…",async i=>await yt(Xs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,i),{method:"DELETE",headers:_n(i)}),e);if(r.ok&&e().selectedId===n&&s({selectedId:null}),r.ok&&a){const i={...e().registryInfo};delete i[a.spec],s({registryInfo:i})}return r},readFile:async n=>{try{const a=Ia(),r=await yt(Xs(`/api/config/plugins/file/${encodeURIComponent(n)}`,a),{headers:_n(a)});if(!r.ok)throw new Error("Failed to read plugin file");return await Da(r)}catch(a){return console.error("[PluginsStore] Failed to read plugin file:",a),null}},createFile:async n=>wn("Creating plugin file…",async a=>await yt(Xs("/api/config/plugins/file",a),{method:"POST",headers:ga(a),body:JSON.stringify(n)}),e),updateFile:async(n,a)=>wn("Updating plugin file…",async r=>await yt(Xs(`/api/config/plugins/file/${encodeURIComponent(n)}`,r),{method:"PUT",headers:ga(r),body:JSON.stringify(a)}),e),deleteFile:async n=>{const a=await wn("Deleting plugin file…",async r=>await yt(Xs(`/api/config/plugins/file/${encodeURIComponent(n)}`,r),{method:"DELETE",headers:_n(r)}),e);return a.ok&&e().selectedId===n&&s({selectedId:null}),a},getById:n=>e().entries.find(a=>a.id===n)??e().files.find(a=>a.id===n)}),{name:"plugins-store",storage:Ur(()=>Zn()),partialize:s=>({selectedId:s.selectedId})}),{name:"plugins-store"}));function Xs(s,e){const n=e?`?directory=${encodeURIComponent(e)}`:"";return`${s}${n}`}function ig(s,e,n){const a=new URLSearchParams;e&&a.set("refresh","true"),n&&a.set("directory",n);const r=a.toString();return`/api/config/plugins/registry?${`specs=${s.map(encodeURIComponent).join(",")}`}${r?`&${r}`:""}`}function og(s){return Array.from(new Set(s.map(e=>e.trim()).filter(Boolean)))}function lg(s){const e=[];let n=[],a=0;for(const r of s){const i=encodeURIComponent(r),o=n.length===0?i.length:a+1+i.length;n.length>0&&o>ag?(e.push(n),n=[r],a=i.length):(n.push(r),a=o)}return n.length>0&&e.push(n),e}function _n(s){return s?{"x-opencode-directory":s}:void 0}function ga(s){return{"Content-Type":"application/json",...s?{"x-opencode-directory":s}:{}}}function so(s){const e={};return s.spec!==void 0&&(e.spec=s.spec),s.options!==void 0&&(e.options=s.options),s.scope!==void 0&&(e.scope=s.scope),e}async function wn(s,e,n){ka(s);let a=!1;try{const r=Ia(),i=await e(r),o=await Da(i).catch(()=>null);if(!i.ok)throw new Error(o?.error||"Failed to update plugin configuration");return rg(r),o?.requiresReload&&(a=!0,await Sa({message:o.message,delayMs:o.reloadDelayMs??tg,scopes:["all"]})),await n().loadPlugins({force:!0}),{ok:!0,reloadFailed:o?.reloadFailed===!0,message:o?.message,warning:o?.warning}}catch(r){return console.error("[PluginsStore] Failed to update plugin configuration:",r),{ok:!1}}finally{a||Ca()}}async function Da(s){return await s.json()}const cg=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function dg(s){const e=s.trim();if(e==="")return{ok:!0,value:void 0};try{const n=JSON.parse(e);return n===null||typeof n!="object"||Array.isArray(n)?{ok:!1}:{ok:!0,value:n}}catch{return{ok:!1}}}const mg=({open:s,onOpenChange:e,defaultScope:n="user"})=>{const{t:a}=dt(),r=cs(T=>T.createEntry),i=cs(T=>T.createFile),[o,d]=l.useState("npm"),[c,x]=l.useState(""),[m,p]=l.useState(""),[u,C]=l.useState(""),[f,g]=l.useState(""),[h,D]=l.useState(n),[k,w]=l.useState(!1),E=l.useCallback(()=>{x(""),p(""),C(""),g(""),D(n)},[n]);l.useEffect(()=>{s&&(d("npm"),E())},[s,E]);const N=T=>{T!==o&&(d(T),E())},y=l.useMemo(()=>dg(m),[m]),b=!y.ok,P=o==="file"&&u.trim()!==""&&!cg.test(u.trim()),z=(o==="npm"||o==="path")&&c.trim()==="",M=o==="file"&&f.trim()==="",I=o==="file"&&u.trim()==="",v=k||b||o==="npm"&&z||o==="path"&&z||o==="file"&&(I||P||M),j=async()=>{if(!v){w(!0);try{let T;o==="file"?T=await i({fileName:u.trim(),content:f,scope:h}):T=await r({spec:c.trim(),options:y.ok?y.value:void 0,scope:h}),T.ok?(_.success(T.message||a("settings.plugins.toast.created")),T.reloadFailed&&_.warning(a("settings.plugins.toast.reloadFailed")),e(!1)):_.error(T.message||a("settings.plugins.sidebar.toast.deleteFailed"))}finally{w(!1)}}},O=l.useMemo(()=>[{id:"npm",label:a("settings.plugins.dialog.add.tab.npm")},{id:"path",label:a("settings.plugins.dialog.add.tab.path")},{id:"file",label:a("settings.plugins.dialog.add.tab.file")}],[a]);return t.jsx($t,{open:s,onOpenChange:T=>{!T&&k||e(T)},children:t.jsxs(Bt,{className:"max-w-xl",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:a("settings.plugins.dialog.add.title")}),t.jsx(Wt,{children:a("settings.plugins.sidebar.empty.description")})]}),t.jsx(fn,{items:O,activeId:o,onSelect:T=>N(T),layoutMode:"fit",variant:"active-pill",activePillLowercase:!1,className:"h-10"}),t.jsxs("div",{className:"flex flex-col gap-4",children:[(o==="npm"||o==="path")&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-settings-item":"plugins.spec",className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-spec",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.spec")}),t.jsx(ot,{id:"plugin-spec",value:c,onChange:T=>x(T.target.value),placeholder:a("settings.plugins.page.field.spec.placeholder"),"aria-invalid":z?!1:void 0,disabled:k}),z&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.plugins.validation.specRequired")})]}),t.jsxs("div",{"data-settings-item":"plugins.options",className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-options",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.options")}),t.jsx(hs,{id:"plugin-options",value:m,onChange:T=>p(T.target.value),rows:5,className:"font-mono",hasError:b,disabled:k}),b&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:a("settings.plugins.page.field.options.invalidJson")})]})]}),o==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-settings-item":"plugins.content",className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-filename",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.fileName")}),t.jsx(ot,{id:"plugin-filename",value:u,onChange:T=>C(T.target.value),placeholder:"my-plugin.ts","aria-invalid":P||void 0,disabled:k}),P&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:a("settings.plugins.validation.fileName")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-content",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.content")}),t.jsx(hs,{id:"plugin-content",value:f,onChange:T=>g(T.target.value),rows:16,className:"font-mono",disabled:k})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.scope")}),t.jsx("div",{className:"flex items-center gap-4",children:["user","project"].map(T=>{const B=h===T,U=a(T==="user"?"settings.plugins.scope.user":"settings.plugins.scope.project");return t.jsxs("button",{type:"button",onClick:()=>D(T),disabled:k,className:"flex items-center gap-2 py-1 text-left disabled:opacity-50",children:[t.jsx(Cn,{checked:B,onChange:()=>D(T),ariaLabel:U}),t.jsx("span",{className:ce("typography-ui-label font-normal",B?"text-foreground":"text-foreground/60"),children:U})]},T)})})]})]}),t.jsxs(Yt,{children:[t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>e(!1),disabled:k,children:a("settings.plugins.dialog.add.action.cancel")}),t.jsxs(J,{size:"sm",onClick:()=>{j()},disabled:v,children:[k?t.jsx(A,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):null,a("settings.plugins.dialog.add.action.submit")]})]})]})})},ug=s=>{const e=rt.c(33),{spec:n}=s;let a;e[0]!==n?(a=d=>d.registryInfo[n],e[0]=n,e[1]=a):a=e[1];const r=cs(a),{t:i}=dt();if(!r)return null;const o=pg;switch(r.kind){case"npm-ok":{if(!r.hasUpdate||!r.latestVersion)return null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"arrow-up-s",className:"h-3 w-3"}),e[2]=d):d=e[2];let c;e[3]!==r.latestVersion?(c=t.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[var(--status-success)]",children:[d,r.latestVersion]}),e[3]=r.latestVersion,e[4]=c):c=e[4];let x;return e[5]!==r.currentVersion||e[6]!==r.latestVersion||e[7]!==i||e[8]!==c?(x=o(c,i("settings.plugins.registry.badge.update.tooltip",{current:r.currentVersion??"",latest:r.latestVersion})),e[5]=r.currentVersion,e[6]=r.latestVersion,e[7]=i,e[8]=c,e[9]=x):x=e[9],x}case"npm-missing-version":{let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"error-warning",className:"h-3 w-3 text-[var(--status-warning)]"}),e[10]=d):d=e[10];let c;return e[11]!==r.currentVersion||e[12]!==r.name||e[13]!==i?(c=o(d,i("settings.plugins.registry.badge.missingVersion.tooltip",{version:r.currentVersion,name:r.name})),e[11]=r.currentVersion,e[12]=r.name,e[13]=i,e[14]=c):c=e[14],c}case"npm-missing-package":{let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[15]=d):d=e[15];let c;return e[16]!==r.name||e[17]!==i?(c=o(d,i("settings.plugins.registry.badge.missingPackage.tooltip",{name:r.name})),e[16]=r.name,e[17]=i,e[18]=c):c=e[18],c}case"npm-malformed":{let d;e[19]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[19]=d):d=e[19];let c;return e[20]!==i?(c=o(d,i("settings.plugins.registry.badge.malformed.tooltip")),e[20]=i,e[21]=c):c=e[21],c}case"npm-network":{let d;e[22]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"cloud-off",className:"h-3 w-3 text-muted-foreground"}),e[22]=d):d=e[22];let c;return e[23]!==i?(c=o(d,i("settings.plugins.registry.badge.network.tooltip")),e[23]=i,e[24]=c):c=e[24],c}case"path-missing":{let d;e[25]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[25]=d):d=e[25];let c;return e[26]!==r.absolutePath||e[27]!==i?(c=o(d,i("settings.plugins.registry.badge.pathMissing.tooltip",{path:r.absolutePath})),e[26]=r.absolutePath,e[27]=i,e[28]=c):c=e[28],c}case"path-unreadable":{let d;e[29]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(A,{name:"error-warning",className:"h-3 w-3 text-[var(--status-warning)]"}),e[29]=d):d=e[29];let c;return e[30]!==r.absolutePath||e[31]!==i?(c=o(d,i("settings.plugins.registry.badge.pathUnreadable.tooltip",{path:r.absolutePath})),e[30]=r.absolutePath,e[31]=i,e[32]=c):c=e[32],c}case"path-ok":return null;default:return null}};function pg(s,e){return t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-xs",children:s})}),t.jsx(Dt,{children:e})]})}const Fl=s=>{const e=rt.c(26),{header:n,footer:a,children:r,className:i,variant:o}=s,d=o===void 0?"sidebar":o,c=fs(),x=l.useRef(null),[m,p]=l.useState(!1),[u,C]=l.useState(!1),f=d==="background"||c?"bg-background":"bg-sidebar",g=f==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const v=x.current;if(!v){p(!1),C(!1);return}if(!(v.scrollHeight>v.clientHeight+1)){p(!1),C(!1);return}p(v.scrollTop>1),C(v.scrollTop+v.clientHeight<v.scrollHeight-1)},e[0]=h):h=e[0];const D=h;let k;e[1]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{D()},e[1]=k):k=e[1];let w;e[2]!==r?(w=[r,D],e[2]=r,e[3]=w):w=e[3],l.useEffect(k,w);let E,N;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const v=x.current;if(!v)return;const j=()=>D();return v.addEventListener("scroll",j,{passive:!0}),()=>v.removeEventListener("scroll",j)},N=[D],e[4]=E,e[5]=N):(E=e[4],N=e[5]),l.useEffect(E,N);let y;e[6]!==f||e[7]!==i?(y=ce("flex h-full flex-col",f,i),e[6]=f,e[7]=i,e[8]=y):y=e[8];let b;e[9]!==r?(b=t.jsx(Gt,{ref:x,outerClassName:"flex-1 min-h-0",className:"space-y-0.5 px-3 py-2 overflow-x-hidden",children:r}),e[9]=r,e[10]=b):b=e[10];let P;e[11]!==g||e[12]!==m?(P=m&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${g} 0%, transparent 100%)`}}),e[11]=g,e[12]=m,e[13]=P):P=e[13];let z;e[14]!==g||e[15]!==u?(z=u&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${g} 0%, transparent 100%)`}}),e[14]=g,e[15]=u,e[16]=z):z=e[16];let M;e[17]!==z||e[18]!==b||e[19]!==P?(M=t.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[b,P,z]}),e[17]=z,e[18]=b,e[19]=P,e[20]=M):M=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==M||e[24]!==y?(I=t.jsxs("div",{className:y,children:[n,M,a]}),e[21]=a,e[22]=n,e[23]=M,e[24]=y,e[25]=I):I=e[25],I},Rr=s=>{const e=rt.c(23),{title:n,metadata:a,selected:r,onSelect:i,icon:o,actions:d,className:c}=s,x=r===void 0?!1:r,m=d&&d.length>0,p=x?"bg-interactive-selection":"hover:bg-interactive-hover";let u;e[0]!==c||e[1]!==p?(u=ce("group relative flex items-center rounded-md px-1.5 py-0.5 transition-all duration-200",p,c),e[0]=c,e[1]=p,e[2]=u):u=e[2];let C;e[3]!==n?(C=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n}),e[3]=n,e[4]=C):C=e[4];let f;e[5]!==o||e[6]!==C?(f=t.jsxs("div",{className:"flex items-center gap-1.5",children:[o,C]}),e[5]=o,e[6]=C,e[7]=f):f=e[7];let g;e[8]!==a?(g=a&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a}),e[8]=a,e[9]=g):g=e[9];let h;e[10]!==i||e[11]!==f||e[12]!==g?(h=t.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:[f,g]}),e[10]=i,e[11]=f,e[12]=g,e[13]=h):h=e[13];let D;e[14]!==d||e[15]!==m?(D=m&&t.jsxs(gs,{children:[t.jsx(us,{asChild:!0,children:t.jsx(J,{size:"icon",variant:"ghost",className:"h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:d.map(gg)})]}),e[14]=d,e[15]=m,e[16]=D):D=e[16];let k;e[17]!==h||e[18]!==D?(k=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[h,D]}),e[17]=h,e[18]=D,e[19]=k):k=e[19];let w;return e[20]!==u||e[21]!==k?(w=t.jsx("div",{className:u,children:k}),e[20]=u,e[21]=k,e[22]=w):w=e[22],w};function gg(s){const e=s.icon;return t.jsxs(vs,{onClick:n=>{n.stopPropagation(),s.onClick()},className:ce(s.destructive&&"text-destructive focus:text-destructive"),children:[e&&t.jsx(A,{name:e,className:"h-4 w-4 mr-px"}),s.label]},s.label)}const hg=s=>s.parsedKind==="npm"?"code-box":"folder",fg=s=>{const e=rt.c(144),{onItemSelect:n,onAddClick:a}=s,{t:r}=dt(),{entries:i,files:o,selectedId:d,setSelected:c,deleteEntry:x,deleteFile:m,loadPlugins:p}=cs(Ss(xg)),u=cs(bg),C=cs(yg),f=cs(vg),g=cs(jg),[h,D]=l.useState(null),[k,w]=l.useState(!1),[E,N]=l.useState(!1);let y,b;e[0]!==p?(y=()=>{p()},b=[p],e[0]=p,e[1]=y,e[2]=b):(y=e[1],b=e[2]),l.useEffect(y,b);let P,z;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const pe=()=>N(!0);return window.addEventListener("openchamber:settings-open-plugin-add",pe),()=>window.removeEventListener("openchamber:settings-open-plugin-add",pe)},z=[],e[3]=P,e[4]=z):(P=e[3],z=e[4]),l.useEffect(P,z);let M;if(e[5]!==i||e[6]!==u){M={userEntries:0,projectEntries:0};for(const pe of i){const nt=u[pe.spec];nt?.kind==="npm-ok"&&nt.hasUpdate&&(pe.scope==="user"?M.userEntries=M.userEntries+1:pe.scope==="project"&&(M.projectEntries=M.projectEntries+1))}e[5]=i,e[6]=u,e[7]=M}else M=e[7];const I=M;let v;e[8]!==i?(v=i.filter(wg),e[8]=i,e[9]=v):v=e[9];const j=v;let O;e[10]!==i?(O=i.filter(Ng),e[10]=i,e[11]=O):O=e[11];const T=O;let B;e[12]!==o?(B=o.filter(kg),e[12]=o,e[13]=B):B=e[13];const U=B;let Q;e[14]!==o?(Q=o.filter(Sg),e[14]=o,e[15]=Q):Q=e[15];const q=Q,R=i.length+o.length,Y=R===0;let F;e[16]!==a?(F=()=>{a?a():N(!0)},e[16]=a,e[17]=F):F=e[17];const W=F;let X;e[18]!==n||e[19]!==c?(X=pe=>{c(pe),n?.()},e[18]=n,e[19]=c,e[20]=X):X=e[20];const re=X;let Z;e[21]!==i||e[22]!==u||e[23]!==r||e[24]!==g?(Z=async pe=>{const nt=i.find(wt=>wt.id===pe);if(!nt)return;const st=u[nt.spec];if(!st||st.kind!=="npm-ok"||!st.hasUpdate||!st.latestVersion)return;const Ge=st.latestVersion;(await g(pe)).ok?_.success(r("settings.plugins.toast.updatedToLatest",{version:Ge})):_.error(r("settings.plugins.toast.refreshFailed"))},e[21]=i,e[22]=u,e[23]=r,e[24]=g,e[25]=Z):Z=e[25];const de=Z;let le;e[26]!==f||e[27]!==r?(le=async()=>{_.info(r("settings.plugins.toast.refreshing"));try{await f({force:!0})}catch{_.error(r("settings.plugins.toast.refreshFailed"))}},e[26]=f,e[27]=r,e[28]=le):le=e[28];const ee=le;let xe;e[29]!==x||e[30]!==m||e[31]!==h||e[32]!==r?(xe=async()=>{if(!h)return;w(!0);const pe=h.kind==="entry"?await x(h.id):await m(h.id);pe.ok?_.success(pe.message||r("settings.plugins.sidebar.toast.deleted",{name:h.label})):_.error(r("settings.plugins.sidebar.toast.deleteFailed")),D(null),w(!1)},e[29]=x,e[30]=m,e[31]=h,e[32]=r,e[33]=xe):xe=e[33];const we=xe;let he;e[34]!==re||e[35]!==de||e[36]!==u||e[37]!==d||e[38]!==r?(he=pe=>{const nt=u[pe.spec],st=nt?.kind==="npm-ok"&&nt.hasUpdate&&!!nt.latestVersion,Ge=[];return st&&Ge.push({label:r("settings.plugins.sidebar.actions.updateToLatest"),icon:"arrow-up-s",onClick:()=>{de(pe.id)}}),Ge.push({label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>D({kind:"entry",id:pe.id,label:pe.spec})}),t.jsx(Rr,{title:t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:pe.spec}),t.jsx(ug,{spec:pe.spec})]}),metadata:pe.parsedKind==="npm"?r("settings.plugins.sidebar.kind.npm"):r("settings.plugins.sidebar.kind.path"),selected:d===pe.id,onSelect:()=>re(pe.id),icon:t.jsx(A,{name:hg(pe),className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:Ge},pe.id)},e[34]=re,e[35]=de,e[36]=u,e[37]=d,e[38]=r,e[39]=he):he=e[39];const Ie=he;let be;e[40]!==re||e[41]!==d||e[42]!==r?(be=pe=>t.jsx(Rr,{title:pe.fileName,metadata:r("settings.plugins.sidebar.kind.file"),selected:d===pe.id,onSelect:()=>re(pe.id),icon:t.jsx(A,{name:"file-text",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:[{label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>D({kind:"file",id:pe.id,label:pe.fileName})}]},pe.id),e[40]=re,e[41]=d,e[42]=r,e[43]=be):be=e[43];const je=be;let ye;e[44]!==r?(ye=(pe,nt,st)=>{const Ge=st===void 0?0:st;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[pe,Ge>0&&t.jsx("span",{className:"ml-2 normal-case font-normal text-[var(--status-success)]",children:r(Ge===1?"settings.plugins.sidebar.group.updatesAvailable_one":"settings.plugins.sidebar.group.updatesAvailable_other",{count:Ge})})]}),nt]})},e[44]=r,e[45]=ye):ye=e[45];const se=ye;let ie;e[46]!==r?(ie=r("settings.plugins.sidebar.title"),e[46]=r,e[47]=ie):ie=e[47];let ge;e[48]!==ie?(ge=t.jsx("div",{className:"mb-3 flex items-center justify-between gap-3",children:t.jsx("h2",{className:"text-base font-semibold text-foreground",children:ie})}),e[48]=ie,e[49]=ge):ge=e[49];let V;e[50]!==r||e[51]!==R?(V=r("settings.plugins.sidebar.total",{count:R}),e[50]=r,e[51]=R,e[52]=V):V=e[52];let te;e[53]!==V?(te=t.jsx("span",{className:"typography-meta text-muted-foreground",children:V}),e[53]=V,e[54]=te):te=e[54];let ne;e[55]!==ee?(ne=()=>{ee()},e[55]=ee,e[56]=ne):ne=e[56];let ue;e[57]!==r?(ue=r("settings.plugins.sidebar.actions.refresh"),e[57]=r,e[58]=ue):ue=e[58];let Me;e[59]!==r?(Me=r("settings.plugins.sidebar.actions.refresh"),e[59]=r,e[60]=Me):Me=e[60];const ke=C?"size-4 animate-spin":"size-4";let Re;e[61]!==ke?(Re=t.jsx(A,{name:"refresh",className:ke}),e[61]=ke,e[62]=Re):Re=e[62];let Ae;e[63]!==C||e[64]!==ne||e[65]!==ue||e[66]!==Me||e[67]!==Re?(Ae=t.jsx(J,{type:"button","data-settings-item":"plugins.create",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:ne,disabled:C,"aria-label":ue,title:Me,children:Re}),e[63]=C,e[64]=ne,e[65]=ue,e[66]=Me,e[67]=Re,e[68]=Ae):Ae=e[68];let Pe;e[69]!==r?(Pe=r("settings.plugins.sidebar.actions.addTitle"),e[69]=r,e[70]=Pe):Pe=e[70];let Te;e[71]!==r?(Te=r("settings.plugins.sidebar.actions.addTitle"),e[71]=r,e[72]=Te):Te=e[72];let Fe;e[73]===Symbol.for("react.memo_cache_sentinel")?(Fe=t.jsx(A,{name:"add",className:"size-4"}),e[73]=Fe):Fe=e[73];let Be;e[74]!==W||e[75]!==Pe||e[76]!==Te?(Be=t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:W,"aria-label":Pe,title:Te,children:Fe}),e[74]=W,e[75]=Pe,e[76]=Te,e[77]=Be):Be=e[77];let We;e[78]!==Ae||e[79]!==Be?(We=t.jsxs("div",{className:"flex items-center gap-1",children:[Ae,Be]}),e[78]=Ae,e[79]=Be,e[80]=We):We=e[80];let ze;e[81]!==te||e[82]!==We?(ze=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[te,We]}),e[81]=te,e[82]=We,e[83]=ze):ze=e[83];let Qe;e[84]!==ge||e[85]!==ze?(Qe=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ge,ze]}),e[84]=ge,e[85]=ze,e[86]=Qe):Qe=e[86];let oe;e[87]!==Y||e[88]!==T||e[89]!==q||e[90]!==Ie||e[91]!==je||e[92]!==se||e[93]!==r||e[94]!==I||e[95]!==j||e[96]!==U?(oe=Y?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:r("settings.plugins.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:r("settings.plugins.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[j.length>0&&se(r("settings.plugins.sidebar.group.userEntries"),j.map(Ie),I.userEntries),U.length>0&&se(r("settings.plugins.sidebar.group.userFiles"),U.map(je)),T.length>0&&se(r("settings.plugins.sidebar.group.projectEntries"),T.map(Ie),I.projectEntries),q.length>0&&se(r("settings.plugins.sidebar.group.projectFiles"),q.map(je))]}),e[87]=Y,e[88]=T,e[89]=q,e[90]=Ie,e[91]=je,e[92]=se,e[93]=r,e[94]=I,e[95]=j,e[96]=U,e[97]=oe):oe=e[97];let H;e[98]!==Qe||e[99]!==oe?(H=t.jsx(Fl,{variant:"background",header:Qe,children:oe}),e[98]=Qe,e[99]=oe,e[100]=H):H=e[100];let me;e[101]!==E?(me=t.jsx(mg,{open:E,onOpenChange:N}),e[101]=E,e[102]=me):me=e[102];const Ne=h!==null;let Ee;e[103]!==k?(Ee=pe=>{!pe&&!k&&D(null)},e[103]=k,e[104]=Ee):Ee=e[104];let Ce;e[105]!==r?(Ce=r("settings.plugins.sidebar.deleteDialog.title"),e[105]=r,e[106]=Ce):Ce=e[106];let _e;e[107]!==Ce?(_e=t.jsx(Ut,{children:Ce}),e[107]=Ce,e[108]=_e):_e=e[108];const G=h?.label??"";let $;e[109]!==r||e[110]!==G?($=r("settings.plugins.sidebar.deleteDialog.description",{name:G}),e[109]=r,e[110]=G,e[111]=$):$=e[111];let fe;e[112]!==$?(fe=t.jsx(Wt,{children:$}),e[112]=$,e[113]=fe):fe=e[113];let L;e[114]!==_e||e[115]!==fe?(L=t.jsxs(_t,{children:[_e,fe]}),e[114]=_e,e[115]=fe,e[116]=L):L=e[116];let Le;e[117]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>D(null),e[117]=Le):Le=e[117];let Je;e[118]!==r?(Je=r("settings.common.actions.cancel"),e[118]=r,e[119]=Je):Je=e[119];let Xe;e[120]!==k||e[121]!==Je?(Xe=t.jsx(J,{size:"sm",variant:"ghost",onClick:Le,disabled:k,children:Je}),e[120]=k,e[121]=Je,e[122]=Xe):Xe=e[122];let et;e[123]!==k||e[124]!==r?(et=r(k?"settings.plugins.sidebar.actions.deleting":"settings.common.actions.delete"),e[123]=k,e[124]=r,e[125]=et):et=e[125];let at;e[126]!==we||e[127]!==k||e[128]!==et?(at=t.jsx(J,{size:"sm",variant:"destructive",onClick:we,disabled:k,children:et}),e[126]=we,e[127]=k,e[128]=et,e[129]=at):at=e[129];let ct;e[130]!==Xe||e[131]!==at?(ct=t.jsxs(Yt,{children:[Xe,at]}),e[130]=Xe,e[131]=at,e[132]=ct):ct=e[132];let Ze;e[133]!==L||e[134]!==ct?(Ze=t.jsxs(Bt,{className:"max-w-md",children:[L,ct]}),e[133]=L,e[134]=ct,e[135]=Ze):Ze=e[135];let He;e[136]!==Ne||e[137]!==Ee||e[138]!==Ze?(He=t.jsx($t,{open:Ne,onOpenChange:Ee,children:Ze}),e[136]=Ne,e[137]=Ee,e[138]=Ze,e[139]=He):He=e[139];let mt;return e[140]!==H||e[141]!==me||e[142]!==He?(mt=t.jsxs(t.Fragment,{children:[H,me,He]}),e[140]=H,e[141]=me,e[142]=He,e[143]=mt):mt=e[143],mt};function xg(s){return{entries:s.entries,files:s.files,selectedId:s.selectedId,setSelected:s.setSelected,deleteEntry:s.deleteEntry,deleteFile:s.deleteFile,loadPlugins:s.loadPlugins}}function bg(s){return s.registryInfo}function yg(s){return s.isLoadingRegistry}function vg(s){return s.loadRegistryInfo}function jg(s){return s.updateToLatest}function wg(s){return s.scope==="user"}function Ng(s){return s.scope==="project"}function kg(s){return s.scope==="user"}function Sg(s){return s.scope==="project"}const Tr=s=>{const e=rt.c(10),{children:n,className:a,outerClassName:r}=s;let i;e[0]!==r?(i=ce("h-full",r),e[0]=r,e[1]=i):i=e[1];let o;e[2]!==a?(o=ce("mx-auto max-w-3xl space-y-6 p-3 sm:p-6 sm:pt-8",a),e[2]=a,e[3]=o):o=e[3];let d;e[4]!==n||e[5]!==o?(d=t.jsx("div",{className:o,children:n}),e[4]=n,e[5]=o,e[6]=d):d=e[6];let c;return e[7]!==i||e[8]!==d?(c=t.jsx(Gt,{outerClassName:i,className:"w-full",children:d}),e[7]=i,e[8]=d,e[9]=c):c=e[9],c},Cg=({entryId:s,spec:e})=>{const{t:n}=dt(),a=cs(p=>p.registryInfo[e]),r=cs(p=>p.updateToLatest),[i,o]=l.useState(!1);if(!a)return null;if(a.kind==="npm-ok"){if(!a.hasUpdate||!a.latestVersion)return null;const p=a.latestVersion,u=a.currentVersion??"",C=async()=>{o(!0);try{(await r(s)).ok?_.success(n("settings.plugins.toast.updatedToLatest",{version:p})):_.error(n("settings.plugins.toast.refreshFailed"))}finally{o(!1)}};return t.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[t.jsx(A,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-success)]",children:n("settings.plugins.registry.banner.updateAvailable.title")}),t.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:n("settings.plugins.registry.banner.updateAvailable.description",{current:u,latest:p})})]}),t.jsx(J,{variant:"default",size:"sm",onClick:()=>{C()},disabled:i,children:n("settings.plugins.registry.banner.updateAvailable.action",{latest:p})})]})}if(a.kind==="path-ok")return null;if(a.kind==="npm-network")return t.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[t.jsx(A,{name:"cloud-off",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"typography-micro text-muted-foreground",children:n("settings.plugins.registry.badge.network.tooltip")})})]});const d=a.kind==="path-unreadable",c=d?"var(--status-warning)":"var(--status-error)",x=d?"alert":"error-warning",m=(()=>{switch(a.kind){case"npm-missing-version":return n("settings.plugins.registry.banner.invalid.missingVersion");case"npm-missing-package":return n("settings.plugins.registry.banner.invalid.missingPackage");case"npm-malformed":return n("settings.plugins.registry.banner.invalid.malformed");case"path-missing":return n("settings.plugins.registry.banner.invalid.pathMissing");case"path-unreadable":return n("settings.plugins.registry.banner.invalid.pathUnreadable")}})();return t.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[t.jsx(A,{name:x,className:"h-5 w-5 shrink-0 mt-0.5",style:{color:c}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"typography-label",style:{color:c},children:n("settings.plugins.registry.banner.invalid.title")}),t.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:m})]})]})};function Pg(s){const e=s.trim();if(e.length===0)return{ok:!0,value:void 0};try{const n=JSON.parse(e);return n===null||typeof n!="object"||Array.isArray(n)?{ok:!1}:{ok:!0,value:n}}catch{return{ok:!1}}}function Ol(s){return!s||Object.keys(s).length===0?"":JSON.stringify(s,null,2)}function no(s){return{mode:"entry",scope:s.scope,spec:s.spec,optionsJson:Ol(s.options),fileName:"",content:""}}function ao(s,e){return{mode:"file",scope:s.scope,spec:"",optionsJson:"",fileName:s.fileName,content:e}}const ro=s=>{const e=rt.c(4),{scope:n,label:a}=s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=ce("typography-micro font-medium rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-muted-foreground","border border-[var(--interactive-border)]"),e[0]=r):r=e[0];let i;return e[1]!==a||e[2]!==n?(i=t.jsx("span",{className:r,"data-scope":n,children:a}),e[1]=a,e[2]=n,e[3]=i):i=e[3],i},Ig=()=>{const{t:s}=dt(),e=cs(h=>h.selectedId),n=cs(h=>h.entries),a=cs(h=>h.files),r=cs(h=>h.draft),i=cs(h=>h.setDraft),o=cs(h=>h.updateEntry),d=cs(h=>h.updateFile),c=cs(h=>h.readFile),x=l.useMemo(()=>e?n.find(h=>h.id===e)??null:null,[n,e]),m=l.useMemo(()=>e?a.find(h=>h.id===e)??null:null,[a,e]),[p,u]=l.useState(!1),[C,f]=l.useState(!1),g=l.useRef(new Map);if(l.useEffect(()=>{let h=!1;return x?(i(no(x)),()=>{h=!0}):m?(f(!0),(async()=>{const D=await c(m.id);if(h)return;f(!1);const k=D?.content??"";g.current.set(m.id,k),i(ao(m,k))})(),()=>{h=!0}):(i(null),()=>{h=!0})},[x,m,c,i]),!e)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"plug",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.plugins.page.empty.select")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.plugins.page.empty.add")})]})});if(x&&r&&r.mode==="entry"){const h=Pg(r.optionsJson),D=h.ok,k=r.spec!==x.spec||r.optionsJson!==Ol(x.options),w=()=>{i(no(x))},E=async()=>{if(!D)return;const N=r.spec.trim();if(!N){_.error(s("settings.plugins.validation.specRequired"));return}u(!0);try{const y=await o(x.id,{spec:N,options:h.value});y.ok?y.reloadFailed?_.warning(y.message||s("settings.plugins.toast.reloadFailed"),{description:y.warning}):_.success(y.message||s("settings.plugins.toast.updated")):_.error(y.message||s("settings.plugins.toast.reloadFailed"))}finally{u(!1)}};return t.jsxs(Tr,{children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.plugins.page.header.entry")}),t.jsx(ro,{scope:x.scope,label:x.scope==="project"?s("settings.plugins.sidebar.group.projectEntries"):s("settings.plugins.sidebar.group.userEntries")})]})}),t.jsx(Cg,{entryId:x.id,spec:x.spec}),t.jsxs("div",{"data-settings-item":"plugins.spec",className:"space-y-1.5",children:[t.jsx("label",{className:"typography-meta text-muted-foreground",children:s("settings.plugins.page.field.spec")}),t.jsx(ot,{value:r.spec,onChange:N=>i({...r,spec:N.target.value}),placeholder:s("settings.plugins.page.field.spec.placeholder"),className:"font-mono typography-meta",spellCheck:!1})]}),t.jsxs("div",{"data-settings-item":"plugins.options",className:"space-y-1.5",children:[t.jsx("label",{className:"typography-meta text-muted-foreground",children:s("settings.plugins.page.field.options")}),t.jsx(hs,{value:r.optionsJson,onChange:N=>i({...r,optionsJson:N.target.value}),rows:10,className:ce("font-mono typography-meta min-h-[200px]",!D&&"border-[var(--status-error-border)]"),spellCheck:!1,placeholder:"{ }"}),!D&&t.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:s("settings.plugins.page.field.options.invalidJson")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(J,{variant:"default",size:"sm",onClick:()=>{E()},disabled:!k||!D||p,children:s("settings.plugins.page.action.save")}),t.jsx(J,{variant:"outline",size:"sm",onClick:w,disabled:!k||p,children:s("settings.plugins.page.action.discard")})]})]})}if(m&&r&&r.mode==="file"){const h=g.current.get(m.id)??"",D=r.content!==h||r.fileName!==m.fileName,k=()=>{(async()=>{f(!0);const N=(await c(m.id))?.content??"";f(!1),g.current.set(m.id,N),i(ao(m,N))})()},w=async()=>{u(!0);try{const E=await d(m.id,{content:r.content});E.ok?(g.current.set(m.id,r.content),E.reloadFailed?_.warning(E.message||s("settings.plugins.toast.reloadFailed"),{description:E.warning}):_.success(E.message||s("settings.plugins.toast.updated"))):_.error(E.message||s("settings.plugins.toast.reloadFailed"))}finally{u(!1)}};return t.jsxs(Tr,{children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.plugins.page.header.file")}),t.jsx(ro,{scope:m.scope,label:m.scope==="project"?s("settings.plugins.sidebar.group.projectFiles"):s("settings.plugins.sidebar.group.userFiles")}),t.jsx("span",{className:ce("typography-micro font-mono rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-foreground","border border-[var(--interactive-border)]"),children:m.fileName})]})}),t.jsxs("div",{"data-settings-item":"plugins.content",className:"space-y-1.5",children:[t.jsx("label",{className:"typography-meta text-muted-foreground",children:s("settings.plugins.page.field.content")}),t.jsx(hs,{value:r.content,onChange:E=>i({...r,content:E.target.value}),rows:16,className:"font-mono typography-meta min-h-[320px]",spellCheck:!1,disabled:C})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(J,{variant:"default",size:"sm",onClick:()=>{w()},disabled:!D||p||C,children:s("settings.plugins.page.action.save")}),t.jsx(J,{variant:"outline",size:"sm",onClick:k,disabled:p||C,children:s("settings.plugins.page.action.discard")})]})]})}return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx(A,{name:"loader-4",className:"mx-auto mb-3 h-6 w-6 animate-spin opacity-50"})})})},Dg="<built-in>",kn=s=>s?.path===Dg,Ag=s=>{const e=rt.c(150),{onItemSelect:n}=s,{t:a}=dt(),[r,i]=l.useState(null),[o,d]=l.useState(""),[c,x]=l.useState(null),[m,p]=l.useState(!1),[u,C]=l.useState(null),{selectedSkillName:f,skills:g,setSelectedSkill:h,setSkillDraft:D,createSkill:k,deleteSkill:w,getSkillDetail:E}=Hs(Ss(Eg));let N;e[0]!==n||e[1]!==h||e[2]!==D||e[3]!==g?(N=()=>{let pe="new-skill",nt=1;for(;g.some(st=>st.name===pe);)pe=`new-skill-${nt}`,nt++;D({name:pe,scope:"user",source:"opencode",description:""}),h(pe),n?.()},e[0]=n,e[1]=h,e[2]=D,e[3]=g,e[4]=N):N=e[4];const y=N;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=async pe=>{kn(pe)||x(pe)},e[5]=b):b=e[5];const P=b;let z;e[6]!==c||e[7]!==w||e[8]!==a?(z=async()=>{if(!c)return;if(kn(c)){x(null);return}p(!0),await w(c.name)?(_.success(a("settings.skills.sidebar.toast.skillDeleted",{name:c.name})),x(null)):_.error(a("settings.skills.sidebar.toast.deleteSkillFailed")),p(!1)},e[6]=c,e[7]=w,e[8]=a,e[9]=z):z=e[9];const M=z;let I;e[10]!==E||e[11]!==h||e[12]!==D||e[13]!==g||e[14]!==a?(I=async pe=>{if(kn(pe))return;const nt=pe.name;let st=1,Ge=`${nt}-copy`;for(;g.some(wt=>wt.name===Ge);)st++,Ge=`${nt}-copy-${st}`;const ht=await E(pe.name);if(!ht){_.error(a("settings.skills.sidebar.toast.duplicateLoadFailed"));return}D({name:Ge,scope:pe.scope||"user",source:pe.source||"opencode",description:(ht.sources.md.fields.includes("description"),""),instructions:""}),h(Ge)},e[10]=E,e[11]=h,e[12]=D,e[13]=g,e[14]=a,e[15]=I):I=e[15];const v=I;let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=pe=>{kn(pe)||(d(pe.name),i(pe))},e[16]=j):j=e[16];const O=j;let T;e[17]!==k||e[18]!==w||e[19]!==E||e[20]!==r||e[21]!==o||e[22]!==h||e[23]!==g||e[24]!==a?(T=async()=>{if(!r)return;if(kn(r)){i(null);return}const pe=o.trim().replace(/\s+/g,"-").toLowerCase();if(!pe){_.error(a("settings.skills.page.toast.skillNameRequired"));return}if(pe===r.name){i(null);return}if(g.some(Ge=>Ge.name===pe)){_.error(a("settings.skills.page.toast.skillExists"));return}if(!await E(r.name)){_.error(a("settings.skills.sidebar.toast.renameLoadFailed")),i(null);return}await k({name:pe,description:"Renamed skill",scope:r.scope,source:r.source})?await w(r.name)?(_.success(`Skill renamed to "${pe}"`),h(pe)):_.error(a("settings.skills.sidebar.toast.removeOldAfterRenameFailed")):_.error(a("settings.skills.sidebar.toast.renameFailed")),i(null)},e[17]=k,e[18]=w,e[19]=E,e[20]=r,e[21]=o,e[22]=h,e[23]=g,e[24]=a,e[25]=T):T=e[25];const B=T;let U;e[26]!==g?(U=g.filter(Mg),e[26]=g,e[27]=U):U=e[27];const Q=U;let q;e[28]!==g?(q=g.filter(Rg),e[28]=g,e[29]=q):q=e[29];const R=q;let Y;e[30]===Symbol.for("react.memo_cache_sentinel")?(Y=function(nt){const st={},Ge=[];for(const wt of nt)wt.group?(st[wt.group]||(st[wt.group]=[]),st[wt.group].push(wt)):Ge.push(wt);const ht=Object.keys(st).sort(Tg).map(wt=>({name:wt,skills:[...st[wt]].sort(Fg)}));return Ge.sort(Og),{sortedGroups:ht,ungrouped:Ge}},e[30]=Y):Y=e[30];const F=Y;let W;e[31]!==Q?(W=F(Q),e[31]=Q,e[32]=W):W=e[32];const X=W;let re;e[33]!==R?(re=F(R),e[33]=R,e[34]=re):re=e[34];const Z=re;let de;e[35]===Symbol.for("react.memo_cache_sentinel")?(de=ce("flex h-full flex-col","bg-background"),e[35]=de):de=e[35];let le;e[36]!==a?(le=a("settings.skills.sidebar.title"),e[36]=a,e[37]=le):le=e[37];let ee;e[38]!==le?(ee=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:le}),e[38]=le,e[39]=ee):ee=e[39];let xe;e[40]===Symbol.for("react.memo_cache_sentinel")?(xe=t.jsx(na,{className:"mb-3"}),e[40]=xe):xe=e[40];let we;e[41]!==g.length||e[42]!==a?(we=a("settings.skills.sidebar.total",{count:g.length}),e[41]=g.length,e[42]=a,e[43]=we):we=e[43];let he;e[44]!==we?(he=t.jsx("span",{className:"typography-meta text-muted-foreground",children:we}),e[44]=we,e[45]=he):he=e[45];let Ie;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),e[46]=Ie):Ie=e[46];let be;e[47]!==y?(be=t.jsx(J,{size:"sm","data-settings-item":"skills.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:y,children:Ie}),e[47]=y,e[48]=be):be=e[48];let je;e[49]!==he||e[50]!==be?(je=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[he,be]}),e[49]=he,e[50]=be,e[51]=je):je=e[51];let ye;e[52]!==ee||e[53]!==je?(ye=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ee,xe,je]}),e[52]=ee,e[53]=je,e[54]=ye):ye=e[54];let se;e[55]!==X||e[56]!==Z||e[57]!==v||e[58]!==n||e[59]!==u||e[60]!==Q||e[61]!==f||e[62]!==h||e[63]!==g.length||e[64]!==a||e[65]!==R?(se=t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:g.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.skills.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.skills.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[Q.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.skills.sidebar.section.project")}),X.sortedGroups.map(pe=>{const{name:nt,skills:st}=pe;return t.jsx(Er,{label:nt,count:st.length,storageKey:"project-skills",children:st.map(Ge=>t.jsx(ha,{skill:Ge,isSelected:f===Ge.name,onSelect:()=>{h(Ge.name),n?.()},onRename:()=>O(Ge),onDelete:()=>P(Ge),onDuplicate:()=>v(Ge),isMenuOpen:u===Ge.name,onMenuOpenChange:ht=>C(ht?Ge.name:null)},Ge.name))},nt)}),X.ungrouped.map(pe=>t.jsx(ha,{skill:pe,isSelected:f===pe.name,onSelect:()=>{h(pe.name),n?.()},onRename:()=>O(pe),onDelete:()=>P(pe),onDuplicate:()=>v(pe),isMenuOpen:u===pe.name,onMenuOpenChange:nt=>C(nt?pe.name:null)},pe.name))]}),R.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.skills.sidebar.section.user")}),Z.sortedGroups.map(pe=>{const{name:nt,skills:st}=pe;return t.jsx(Er,{label:nt,count:st.length,storageKey:"user-skills",children:st.map(Ge=>t.jsx(ha,{skill:Ge,isSelected:f===Ge.name,onSelect:()=>{h(Ge.name),n?.()},onRename:()=>O(Ge),onDelete:()=>P(Ge),onDuplicate:()=>v(Ge),isMenuOpen:u===Ge.name,onMenuOpenChange:ht=>C(ht?Ge.name:null)},Ge.name))},nt)}),Z.ungrouped.map(pe=>t.jsx(ha,{skill:pe,isSelected:f===pe.name,onSelect:()=>{h(pe.name),n?.()},onRename:()=>O(pe),onDelete:()=>P(pe),onDuplicate:()=>v(pe),isMenuOpen:u===pe.name,onMenuOpenChange:nt=>C(nt?pe.name:null)},pe.name))]})]})}),e[55]=X,e[56]=Z,e[57]=v,e[58]=n,e[59]=u,e[60]=Q,e[61]=f,e[62]=h,e[63]=g.length,e[64]=a,e[65]=R,e[66]=se):se=e[66];const ie=c!==null;let ge;e[67]!==m?(ge=pe=>{!pe&&!m&&x(null)},e[67]=m,e[68]=ge):ge=e[68];let V;e[69]!==a?(V=a("settings.skills.sidebar.deleteDialog.title"),e[69]=a,e[70]=V):V=e[70];let te;e[71]!==V?(te=t.jsx(Ut,{children:V}),e[71]=V,e[72]=te):te=e[72];const ne=c?.name??"";let ue;e[73]!==a||e[74]!==ne?(ue=a("settings.skills.sidebar.deleteDialog.description",{name:ne}),e[73]=a,e[74]=ne,e[75]=ue):ue=e[75];let Me;e[76]!==ue?(Me=t.jsx(Wt,{children:ue}),e[76]=ue,e[77]=Me):Me=e[77];let ke;e[78]!==te||e[79]!==Me?(ke=t.jsxs(_t,{children:[te,Me]}),e[78]=te,e[79]=Me,e[80]=ke):ke=e[80];let Re;e[81]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>x(null),e[81]=Re):Re=e[81];let Ae;e[82]!==a?(Ae=a("settings.common.actions.cancel"),e[82]=a,e[83]=Ae):Ae=e[83];let Pe;e[84]!==m||e[85]!==Ae?(Pe=t.jsx(J,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:Re,disabled:m,children:Ae}),e[84]=m,e[85]=Ae,e[86]=Pe):Pe=e[86];let Te;e[87]!==a?(Te=a("settings.common.actions.delete"),e[87]=a,e[88]=Te):Te=e[88];let Fe;e[89]!==M||e[90]!==m||e[91]!==Te?(Fe=t.jsx(J,{size:"sm",onClick:M,disabled:m,children:Te}),e[89]=M,e[90]=m,e[91]=Te,e[92]=Fe):Fe=e[92];let Be;e[93]!==Pe||e[94]!==Fe?(Be=t.jsxs(Yt,{children:[Pe,Fe]}),e[93]=Pe,e[94]=Fe,e[95]=Be):Be=e[95];let We;e[96]!==ke||e[97]!==Be?(We=t.jsxs(Bt,{className:"max-w-md",children:[ke,Be]}),e[96]=ke,e[97]=Be,e[98]=We):We=e[98];let ze;e[99]!==ie||e[100]!==ge||e[101]!==We?(ze=t.jsx($t,{open:ie,onOpenChange:ge,children:We}),e[99]=ie,e[100]=ge,e[101]=We,e[102]=ze):ze=e[102];const Qe=r!==null;let oe;e[103]===Symbol.for("react.memo_cache_sentinel")?(oe=pe=>!pe&&i(null),e[103]=oe):oe=e[103];let H;e[104]!==a?(H=a("settings.skills.sidebar.renameDialog.title"),e[104]=a,e[105]=H):H=e[105];let me;e[106]!==H?(me=t.jsx(Ut,{children:H}),e[106]=H,e[107]=me):me=e[107];const Ne=r?.name??"";let Ee;e[108]!==a||e[109]!==Ne?(Ee=a("settings.skills.sidebar.renameDialog.description",{name:Ne}),e[108]=a,e[109]=Ne,e[110]=Ee):Ee=e[110];let Ce;e[111]!==Ee?(Ce=t.jsx(Wt,{children:Ee}),e[111]=Ee,e[112]=Ce):Ce=e[112];let _e;e[113]!==me||e[114]!==Ce?(_e=t.jsxs(_t,{children:[me,Ce]}),e[113]=me,e[114]=Ce,e[115]=_e):_e=e[115];let G;e[116]===Symbol.for("react.memo_cache_sentinel")?(G=pe=>d(pe.target.value),e[116]=G):G=e[116];let $;e[117]!==a?($=a("settings.skills.sidebar.renameDialog.placeholder"),e[117]=a,e[118]=$):$=e[118];let fe;e[119]!==B?(fe=pe=>{pe.key==="Enter"&&B()},e[119]=B,e[120]=fe):fe=e[120];let L;e[121]!==o||e[122]!==$||e[123]!==fe?(L=t.jsx(ot,{value:o,onChange:G,placeholder:$,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:fe}),e[121]=o,e[122]=$,e[123]=fe,e[124]=L):L=e[124];let Le;e[125]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>i(null),e[125]=Le):Le=e[125];let Je;e[126]!==a?(Je=a("settings.common.actions.cancel"),e[126]=a,e[127]=Je):Je=e[127];let Xe;e[128]!==Je?(Xe=t.jsx(J,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:Le,children:Je}),e[128]=Je,e[129]=Xe):Xe=e[129];let et;e[130]!==a?(et=a("settings.common.actions.rename"),e[130]=a,e[131]=et):et=e[131];let at;e[132]!==B||e[133]!==et?(at=t.jsx(J,{size:"sm",onClick:B,children:et}),e[132]=B,e[133]=et,e[134]=at):at=e[134];let ct;e[135]!==Xe||e[136]!==at?(ct=t.jsxs(Yt,{children:[Xe,at]}),e[135]=Xe,e[136]=at,e[137]=ct):ct=e[137];let Ze;e[138]!==_e||e[139]!==L||e[140]!==ct?(Ze=t.jsxs(Bt,{children:[_e,L,ct]}),e[138]=_e,e[139]=L,e[140]=ct,e[141]=Ze):Ze=e[141];let He;e[142]!==Qe||e[143]!==Ze?(He=t.jsx($t,{open:Qe,onOpenChange:oe,children:Ze}),e[142]=Qe,e[143]=Ze,e[144]=He):He=e[144];let mt;return e[145]!==ye||e[146]!==se||e[147]!==ze||e[148]!==He?(mt=t.jsxs("div",{className:de,children:[ye,se,ze,He]}),e[145]=ye,e[146]=se,e[147]=ze,e[148]=He,e[149]=mt):mt=e[149],mt},ha=s=>{const e=rt.c(49),{skill:n,isSelected:a,onSelect:r,onDelete:i,onRename:o,onDuplicate:d,isMenuOpen:c,onMenuOpenChange:x}=s,{t:m}=dt();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=Xn(),e[0]=p):p=e[0];const u=p;let C;e[1]!==n.source||e[2]!==m?(C=n.source==="claude"?m("settings.skills.sidebar.badge.claude"):n.source==="agents"?m("settings.skills.sidebar.badge.agents"):m("settings.skills.sidebar.badge.opencode"),e[1]=n.source,e[2]=m,e[3]=C):C=e[3];const f=C;let g;e[4]!==n?(g=kn(n),e[4]=n,e[5]=g):g=e[5];const h=g,[D,k]=l.useState(!1);let w;e[6]!==i||e[7]!==d||e[8]!==o||e[9]!==m?(w=R=>t.jsxs(t.Fragment,{children:[t.jsxs(R,{onClick:Y=>{Y.stopPropagation(),o()},children:[t.jsx(A,{name:"edit",className:"h-4 w-4 mr-px"}),m("settings.common.actions.rename")]}),t.jsxs(R,{onClick:Y=>{Y.stopPropagation(),d()},children:[t.jsx(A,{name:"file-copy",className:"h-4 w-4 mr-px"}),m("settings.common.actions.duplicate")]}),t.jsxs(R,{onClick:Y=>{Y.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),m("settings.common.actions.delete")]})]}),e[6]=i,e[7]=d,e[8]=o,e[9]=m,e[10]=w):w=e[10];const E=w,N=!h&&D,y=a?"bg-interactive-selection":"hover:bg-interactive-hover";let b;e[11]!==y?(b=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y),e[11]=y,e[12]=b):b=e[12];let P;e[13]!==h?(P=!u&&!h?R=>{R.preventDefault(),k(!0)}:void 0,e[13]=h,e[14]=P):P=e[14];let z;e[15]!==b||e[16]!==P?(z=t.jsx("div",{className:b,onContextMenu:P}),e[15]=b,e[16]=P,e[17]=z):z=e[17];let M;e[18]!==n.name?(M=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[18]=n.name,e[19]=M):M=e[19];let I;e[20]!==n.scope?(I=t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50",children:n.scope}),e[20]=n.scope,e[21]=I):I=e[21];let v;e[22]!==f?(v=t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50",children:f}),e[22]=f,e[23]=v):v=e[23];let j;e[24]!==M||e[25]!==I||e[26]!==v?(j=t.jsxs("div",{className:"flex items-center gap-1.5",children:[M,I,v]}),e[24]=M,e[25]=I,e[26]=v,e[27]=j):j=e[27];let O;e[28]!==r||e[29]!==j?(O=t.jsx("button",{onClick:r,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}),e[28]=r,e[29]=j,e[30]=O):O=e[30];let T;e[31]!==h||e[32]!==c||e[33]!==x||e[34]!==E?(T=h?null:t.jsxs(gs,{open:c,onOpenChange:R=>{R&&k(!1),x(R)},children:[t.jsx(us,{asChild:!0,children:t.jsx(J,{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:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:E(vs)})]}),e[31]=h,e[32]=c,e[33]=x,e[34]=E,e[35]=T):T=e[35];let B;e[36]!==O||e[37]!==T?(B=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[O,T]}),e[36]=O,e[37]=T,e[38]=B):B=e[38];let U;e[39]!==B||e[40]!==z?(U=t.jsx(tn,{render:z,children:B}),e[39]=B,e[40]=z,e[41]=U):U=e[41];let Q;e[42]!==h||e[43]!==E?(Q=h?null:t.jsx(sn,{className:"w-fit min-w-20",children:E(qs)}),e[42]=h,e[43]=E,e[44]=Q):Q=e[44];let q;return e[45]!==U||e[46]!==Q||e[47]!==N?(q=t.jsxs(en,{open:N,onOpenChange:k,children:[U,Q]}),e[45]=U,e[46]=Q,e[47]=N,e[48]=q):q=e[48],q};function Eg(s){return{selectedSkillName:s.selectedSkillName,skills:s.skills,setSelectedSkill:s.setSelectedSkill,setSkillDraft:s.setSkillDraft,createSkill:s.createSkill,deleteSkill:s.deleteSkill,getSkillDetail:s.getSkillDetail}}function Mg(s){return s.scope==="project"}function Rg(s){return s.scope==="user"}function Tg(s,e){return s.localeCompare(e)}function Fg(s,e){return s.name.localeCompare(e.name)}function Og(s,e){return s.name.localeCompare(e.name)}const Lg=s=>s!==null&&typeof s=="object"&&"updateStatus"in s&&typeof s.updateStatus=="function",zg=s=>{const e=document.createElement("div");e.className="cm-vim-panel";const n=Bc(s);if(!n)return{top:!1,dom:e};n.state.statusbar=e;const a=n.state.vimPlugin;return Lg(a)&&a.updateStatus(),{top:!1,dom:e,destroy(){n.state.statusbar===e&&(n.state.statusbar=null)}}};function io(s){return s?[zc(),Kc.of(zg),$c()]:[]}const Kg={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},$g={case:"Match case",re:"Regular expression",word:"Match whole word"};function Bg(s){const e=s.querySelector(".cm-search");if(e){for(const[n,a]of Object.entries(Kg)){const r=e.querySelector(`button[name="${n}"]`);r&&!r.title&&(r.title=a)}for(const[n,a]of Object.entries($g)){const i=e.querySelector(`input[name="${n}"]`)?.parentElement;i&&!i.title&&(i.title=a)}}}const or=new WeakMap;function Ug(s,e){const n=Ra(s.state);if(!n.valid)return or.delete(s),0;const a=or.get(s);if(!e&&a?.doc===s.state.doc&&a.query.eq(n))return a.total;const r=n.getCursor(s.state);let i=0;for(let o=r.next();!o.done;o=r.next())i+=1;return or.set(s,{query:n,doc:s.state.doc,total:i}),i}function Vg(s){const e=Ra(s.state);if(!e.valid)return 0;const n=s.state.selection.main,a=e.getCursor(s.state);let r=0,i=0;for(let o=a.next();!o.done;o=a.next()){const d=o.value;if(r+=1,i===0&&(i=r),n.from===d.from&&n.to===d.to||n.from<d.to&&n.to>d.from||d.from>=n.head)return r}return i}function oo(s,e,n=!1){const a=s.querySelector(".cm-search");if(!a)return;let r=a.querySelector(".cm-search-message");if(!r){r=document.createElement("span"),r.className="cm-search-message",r.setAttribute("aria-live","polite");const d=a.querySelector('button[name="next"]'),c=d?.parentNode===a?d:a.firstChild;a.insertBefore(r,c)}const i=Ug(e,n),o=i===0?0:Vg(e);r.textContent=i===0?"":`${o}/${i}`}const lo=new xn,co=new xn,mo=new xn,uo=new xn,po=new xn,go=new xn,ho=new xn,fo=s=>s,lr=Jc,_g=Qc,Hg=Yc;class Wg extends Xc{constructor(e,n){super(),this.id=e,this.containerMap=n}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement("div"),e.className="oc-block-widget",e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}}const xo=(s,e)=>!s||s.length===0?[]:ul.define({create(n){const a=new Vr,r=[...s].sort((i,o)=>i.afterLine-o.afterLine);for(const i of r){const o=n.doc.lines;if(i.afterLine>o)continue;const d=n.doc.line(i.afterLine);a.add(d.to,d.to,za.widget({widget:new Wg(i.id,e),block:!0,side:1}))}return a.finish()},update(n,a){return n.map(a.changes)},provide:n=>Os.decorations.from(n)}),bo=s=>{if(!s)return[];const e=Math.max(1,s.start),n=Math.max(e,s.end);return ml.fromClass(class{decorations;constructor(a){this.decorations=this.build(a)}update(a){(a.docChanged||a.viewportChanged)&&(this.decorations=this.build(a.view))}build(a){const r=new Vr;for(let i=e;i<=n&&i<=a.state.doc.lines;i+=1){const o=a.state.doc.line(i);r.add(o.from,o.from,za.line({class:"oc-cm-selected-line"}))}return r.finish()}},{decorations:a=>a.decorations})};function yo({value:s,onChange:e,extensions:n,className:a,readOnly:r,lineNumbersConfig:i,highlightLines:o,onViewReady:d,onViewDestroy:c,blockWidgets:x,enableSearch:m,searchOpen:p,onSearchOpenChange:u,vimMode:C}){const f=l.useRef(null),g=l.useRef(null),h=l.useRef(s),D=l.useRef(e),k=l.useRef(d),w=l.useRef(c),E=l.useRef(u),N=l.useRef(x),y=l.useRef(C),b=l.useRef(new Map),[P,z]=l.useState([]),M=l.useCallback(v=>{const j=(v??[]).map(O=>{const T=b.current.get(O.id);return T?{id:O.id,content:O.content,container:T}:null}).filter(O=>O!==null);z(O=>O.length===j.length&&O.every((T,B)=>{const U=j[B];return T.id===U.id&&T.content===U.content&&T.container===U.container})?O:j)},[]),I=l.useCallback(v=>{const j=f.current,O=v??g.current;if(!j||!O)return;const T=O.dom.querySelector(".cm-gutters"),B=T instanceof HTMLElement?T.getBoundingClientRect().width:0;j.style.setProperty("--oc-editor-gutter-width",`${B}px`)},[]);return l.useEffect(()=>{h.current=s},[s]),l.useEffect(()=>{D.current=e},[e]),l.useEffect(()=>{k.current=d,w.current=c},[d,c]),l.useEffect(()=>{E.current=u},[u]),l.useEffect(()=>{N.current=x,M(x)},[x,M]),l.useEffect(()=>{if(!f.current)return;const v=(()=>{if(typeof document>"u")return null;const O=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(O)return O;const T=window.__OPENCHAMBER_CSP_NONCE__;return typeof T=="string"&&T.length>0?T:null})(),j=Uc.create({doc:h.current,extensions:[...v?[Os.cspNonce.of(v)]:[],Vc({fixed:!0}),lo.of(Zr(i)),_c(),Hc.of(" "),ho.of(io(C)),Wa.of([Wc,...qc,...Gc]),Os.updateListener.of(O=>{I(O.view),(O.viewportChanged||O.geometryChanged)&&M(N.current);const T=ei(O.startState),B=ei(O.state);T!==B&&E.current?.(B);const U=!Ra(O.startState).eq(Ra(O.state));if(B&&(T!==B||U||O.docChanged||O.selectionSet)&&oo(O.view.dom,O.view,T!==B||U||O.docChanged),!O.docChanged)return;const Q=O.state.doc.toString();h.current=Q,D.current(Q),M(N.current)}),co.of(Os.editable.of(!r)),mo.of(n??[]),uo.of(bo(o)),po.of(xo(x,b.current)),go.of(m?[ti({top:!0}),Wa.of(fo(si))]:[])]});return g.current=new Os({state:j,parent:f.current}),lr(g.current,g.current.state.doc.length,200),g.current.requestMeasure(),requestAnimationFrame(()=>{I(g.current),M(N.current)}),g.current&&k.current?.(g.current),()=>{w.current?.(),g.current?.destroy(),g.current=null,z([])}},[N,I,M]),l.useEffect(()=>{const v=g.current;v&&(v.dispatch({effects:[lo.reconfigure(Zr(i)),co.reconfigure(Os.editable.of(!r)),mo.reconfigure(n??[]),uo.reconfigure(bo(o)),po.reconfigure(xo(x,b.current)),go.reconfigure(m?[ti({top:!0}),Wa.of(fo(si))]:[])]}),lr(v,v.state.doc.length,200),v.requestMeasure(),requestAnimationFrame(()=>{I(v),M(N.current)}))},[n,o,i,r,x,m,I,M]),l.useEffect(()=>{const v=g.current;if(!v){y.current=C;return}y.current!==C&&(y.current=C,v.dispatch({effects:ho.reconfigure(io(C))}))},[C]),l.useEffect(()=>{const v=g.current;!v||m===!1||(p?(_g(v),requestAnimationFrame(()=>{Bg(v.dom),oo(v.dom,v,!0)})):Hg(v))},[p,m]),l.useEffect(()=>{const v=g.current;if(!v)return;const j=v.state.doc.toString();j!==s&&(v.dispatch({changes:{from:0,to:j.length,insert:s}}),lr(v,v.state.doc.length,300),v.requestMeasure(),requestAnimationFrame(()=>I(v)))},[s,I]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:f,className:ce("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",a)}),P.map(v=>Na.createPortal(v.content,v.container,v.id))]})}const qg=s=>{const e=rt.c(11),{currentMode:n,onToggle:a}=s,r=n==="preview",i=r?"Switch to edit mode":"Switch to preview mode",o=r?"Edit":"Preview";let d;e[0]!==r?(d=r?t.jsx(A,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(A,{name:"eye-off",className:"size-4","aria-hidden":"true"}),e[0]=r,e[1]=d):d=e[1];let c;e[2]!==i||e[3]!==a||e[4]!==d?(c=t.jsx(It,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"sm",onClick:a,"aria-label":i,className:"h-5 w-5 p-0",children:d})}),e[2]=i,e[3]=a,e[4]=d,e[5]=c):c=e[5];let x;e[6]!==o?(x=t.jsx(Dt,{sideOffset:8,children:o}),e[6]=o,e[7]=x):x=e[7];let m;return e[8]!==c||e[9]!==x?(m=t.jsxs(Pt,{children:[c,x]}),e[8]=c,e[9]=x,e[10]=m):m=e[10],m},ks=rn()(ta(Br((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const a=await Ed();return s({profiles:a,isLoading:!1}),!0}catch(a){return console.error("Failed to load git identity profiles:",a),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await Ad();if(n&&n.userName&&n.userEmail){const a={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"house"};s({globalIdentity:a})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await Dd();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=a=>{if(typeof a!="string")return null;const r=a.trim();return r.length>0?r:null};try{let a=null;if(a===null){const r=zs()?.settings;if(r)try{const o=(await r.load())?.settings||{};a=n(o.defaultGitIdentityId)}catch{}}if(a===null)try{const r=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(r.ok){const i=await r.json().catch(()=>null);a=n(i?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:a}),!0}catch(a){return console.error("Failed to load default git identity setting:",a),!1}},setDefaultGitIdentityId:async n=>{try{const a=typeof n=="string"?n.trim():"",r=a.length>0?a:"";return await Ct({defaultGitIdentityId:r}),s({defaultGitIdentityId:r.length>0?r:null}),!0}catch(a){return console.error("Failed to save default git identity setting:",a),!1}},createProfile:async n=>{try{const a={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return await Id(a),await e().loadProfiles(),!0}catch(a){return console.error("Failed to create git identity profile:",a),!1}},updateProfile:async(n,a)=>{try{const r=e().profiles.find(o=>o.id===n);if(!r)throw new Error("Profile not found");const i={...r,...a};return await Pd(n,i),await e().loadProfiles(),!0}catch(r){return console.error("Failed to update git identity profile:",r),!1}},deleteProfile:async n=>{try{return await Cd(n),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(a){return console.error("Failed to delete git identity profile:",a),!1}},getProfileById:n=>{const{profiles:a,globalIdentity:r}=e();return n==="global"?r||void 0:a.find(i=>i.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:a}=e();return a.filter(r=>!n.some(i=>i.authType==="token"&&i.host===r.host))}}),{name:"git-identities-store",storage:Ur(()=>Zn()),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=ks);const Gg=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,Jg=s=>{const e=s.trim(),n=e.startsWith("https://")?"https":e.startsWith("git@")?"ssh":"shorthand";if(n==="ssh")return`${e.split(":")[1].replace(/\.git$/i,"")}`;if(n==="https")return e.split("/").slice(3).filter(Boolean).join("/").replace(/\.git$/i,"");const a=e.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return a?`${a[1]}/${a[2].replace(/\.git$/i,"")}`:e},Qg=async()=>{try{const s=zs()?.settings;if(s)return(await s.load())?.settings||{};const e=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});return e.ok?await e.json().catch(()=>null):null}catch{return null}},Yg=s=>{const e=rt.c(160),{open:n,onOpenChange:a}=s,{t:r}=dt(),i=Vs(Xg),o=Vs(Zg),d=Vs(eh),c=Vs(th),x=Vs(sh),m=ks(nh),p=ks(ah),[u,C]=l.useState(""),[f,g]=l.useState(""),[h,D]=l.useState("");let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[0]=k):k=e[0];const[w,E]=l.useState(k),[N,y]=l.useState(null),[b,P]=l.useState(!1);let z;e[1]===Symbol.for("react.memo_cache_sentinel")?(z=[],e[1]=z):z=e[1];const[M,I]=l.useState(z),[v,j]=l.useState(null),O=l.useRef(0);let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=pe=>{O.current=O.current+1,P(!1),y(null),pe?.clearIdentity&&(I([]),j(null))},e[2]=T):T=e[2];const B=T;let U,Q;e[3]!==p||e[4]!==n?(U=()=>{n&&(O.current=O.current+1,C(""),g(""),D(""),y(null),P(!1),I([]),j(null),p(),(async()=>{const pe=await Qg(),nt=Array.isArray(pe?.skillCatalogs)?pe?.skillCatalogs:[];E(nt||[])})())},Q=[n,p],e[3]=p,e[4]=n,e[5]=U,e[6]=Q):(U=e[5],Q=e[6]),l.useEffect(U,Q);let q;e[7]!==f?(q=f.trim(),e[7]=f,e[8]=q):q=e[8];const R=q;let Y;e[9]!==h?(Y=h.trim(),e[9]=h,e[10]=Y):Y=e[10];const F=Y;let W;if(e[11]!==w||e[12]!==R||e[13]!==F){let pe;e[15]!==R||e[16]!==F?(pe=nt=>{const st=(nt.source||"").trim(),Ge=(nt.subpath||"").trim();return st===R&&Ge===F},e[15]=R,e[16]=F,e[17]=pe):pe=e[17],W=w.some(pe),e[11]=w,e[12]=R,e[13]=F,e[14]=W}else W=e[14];const X=W;let re;e[18]!==m||e[19]!==v||e[20]!==u||e[21]!==i||e[22]!==f||e[23]!==h||e[24]!==r?(re=async()=>{const pe=f.trim();if(!pe){_.error(r("settings.skills.catalog.add.toast.repositoryRequired"));return}u.trim()||C(Jg(pe)),P(!1),y(null);const nt=O.current+1;O.current=nt;const st=await i({source:pe,subpath:h.trim()||void 0,gitIdentityId:v||void 0});if(O.current!==nt)return;if(!st.ok){if(st.error?.kind==="authRequired"){if(fs()){_.error(r("settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode"));return}const ht=st.error.identities||[];if(I(ht),!v&&ht.length>0){const wt=m&&m!=="global"&&ht.some(Nt=>Nt.id===m)?m:ht[0].id;j(wt)}_.error(r("settings.skills.catalog.add.toast.authenticationRequiredScan"));return}_.error(st.error?.message||r("settings.skills.catalog.add.toast.scanFailed"));return}const Ge=st.items?.length||0;if(y(Ge),Ge===0){_.error(r("settings.skills.catalog.add.toast.noSkillsFound")),P(!1);return}I([]),P(!0),_.success(r("settings.skills.catalog.shared.toast.foundSkills",{count:Ge}))},e[18]=m,e[19]=v,e[20]=u,e[21]=i,e[22]=f,e[23]=h,e[24]=r,e[25]=re):re=e[25];const Z=re;let de;e[26]!==w||e[27]!==v||e[28]!==X||e[29]!==u||e[30]!==o||e[31]!==d||e[32]!==a||e[33]!==b||e[34]!==c||e[35]!==f||e[36]!==h||e[37]!==r?(de=async()=>{const pe=u.trim(),nt=f.trim(),st=h.trim();if(!pe){_.error(r("settings.skills.catalog.add.toast.catalogNameRequired"));return}if(!nt){_.error(r("settings.skills.catalog.add.toast.repositoryRequired"));return}if(!b){_.error(r("settings.skills.catalog.add.toast.scanBeforeAdd"));return}if(X){_.error(r("settings.skills.catalog.add.toast.catalogAlreadyExists"));return}const Ge={id:Gg(),label:pe,source:nt,...st?{subpath:st}:{},...v?{gitIdentityId:v}:{}},ht=[...w,Ge];try{await Ct({skillCatalogs:ht}),E(ht),_.success(r("settings.skills.catalog.add.toast.catalogAdded")),await o({refresh:!0}),await d(Ge.id,{refresh:!0}),c(Ge.id),a(!1)}catch(wt){const Nt=wt;_.error(Nt instanceof Error?Nt.message:r("settings.skills.catalog.add.toast.saveFailed"))}},e[26]=w,e[27]=v,e[28]=X,e[29]=u,e[30]=o,e[31]=d,e[32]=a,e[33]=b,e[34]=c,e[35]=f,e[36]=h,e[37]=r,e[38]=de):de=e[38];const le=de;let ee;e[39]!==r?(ee=r("settings.skills.catalog.add.title"),e[39]=r,e[40]=ee):ee=e[40];let xe;e[41]!==ee?(xe=t.jsx(Ut,{children:ee}),e[41]=ee,e[42]=xe):xe=e[42];let we;e[43]!==r?(we=r("settings.skills.catalog.add.descriptionPrefix"),e[43]=r,e[44]=we):we=e[44];let he;e[45]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx("code",{className:"font-mono",children:"SKILL.md"}),e[45]=he):he=e[45];let Ie;e[46]!==r?(Ie=r("settings.skills.catalog.add.descriptionSuffix"),e[46]=r,e[47]=Ie):Ie=e[47];let be;e[48]!==we||e[49]!==Ie?(be=t.jsxs(Wt,{children:[we," ",he,Ie]}),e[48]=we,e[49]=Ie,e[50]=be):be=e[50];let je;e[51]!==xe||e[52]!==be?(je=t.jsxs(_t,{children:[xe,be]}),e[51]=xe,e[52]=be,e[53]=je):je=e[53];let ye;e[54]!==r?(ye=r("settings.skills.catalog.add.field.catalogName"),e[54]=r,e[55]=ye):ye=e[55];let se;e[56]!==ye?(se=t.jsx("label",{className:"typography-ui-label text-foreground",children:ye}),e[56]=ye,e[57]=se):se=e[57];let ie;e[58]===Symbol.for("react.memo_cache_sentinel")?(ie=pe=>C(pe.target.value),e[58]=ie):ie=e[58];let ge;e[59]!==r?(ge=r("settings.skills.catalog.add.field.catalogNamePlaceholder"),e[59]=r,e[60]=ge):ge=e[60];let V;e[61]!==u||e[62]!==ge?(V=t.jsx(ot,{value:u,onChange:ie,placeholder:ge}),e[61]=u,e[62]=ge,e[63]=V):V=e[63];let te;e[64]!==se||e[65]!==V?(te=t.jsxs("div",{className:"space-y-2",children:[se,V]}),e[64]=se,e[65]=V,e[66]=te):te=e[66];let ne;e[67]!==r?(ne=r("settings.skills.catalog.add.field.repository"),e[67]=r,e[68]=ne):ne=e[68];let ue;e[69]!==ne?(ue=t.jsx("label",{className:"typography-ui-label text-foreground",children:ne}),e[69]=ne,e[70]=ue):ue=e[70];let Me;e[71]===Symbol.for("react.memo_cache_sentinel")?(Me=pe=>{g(pe.target.value),B({clearIdentity:!0})},e[71]=Me):Me=e[71];let ke;e[72]!==r?(ke=r("settings.skills.catalog.shared.field.repositoryPlaceholder"),e[72]=r,e[73]=ke):ke=e[73];let Re;e[74]!==f||e[75]!==ke?(Re=t.jsx(ot,{value:f,onChange:Me,placeholder:ke}),e[74]=f,e[75]=ke,e[76]=Re):Re=e[76];let Ae;e[77]!==r?(Ae=r("settings.skills.catalog.add.field.repositoryHint"),e[77]=r,e[78]=Ae):Ae=e[78];let Pe;e[79]!==Ae?(Pe=t.jsx("p",{className:"typography-micro text-muted-foreground",children:Ae}),e[79]=Ae,e[80]=Pe):Pe=e[80];let Te;e[81]!==ue||e[82]!==Re||e[83]!==Pe?(Te=t.jsxs("div",{className:"space-y-2",children:[ue,Re,Pe]}),e[81]=ue,e[82]=Re,e[83]=Pe,e[84]=Te):Te=e[84];let Fe;e[85]!==r?(Fe=r("settings.skills.catalog.add.field.optionalSubpath"),e[85]=r,e[86]=Fe):Fe=e[86];let Be;e[87]!==Fe?(Be=t.jsx("label",{className:"typography-ui-label text-foreground",children:Fe}),e[87]=Fe,e[88]=Be):Be=e[88];let We;e[89]===Symbol.for("react.memo_cache_sentinel")?(We=pe=>{D(pe.target.value),B({clearIdentity:!0})},e[89]=We):We=e[89];let ze;e[90]!==r?(ze=r("settings.skills.catalog.shared.field.subpathPlaceholder"),e[90]=r,e[91]=ze):ze=e[91];let Qe;e[92]!==h||e[93]!==ze?(Qe=t.jsx(ot,{value:h,onChange:We,placeholder:ze}),e[92]=h,e[93]=ze,e[94]=Qe):Qe=e[94];let oe;e[95]!==Be||e[96]!==Qe?(oe=t.jsxs("div",{className:"space-y-2",children:[Be,Qe]}),e[95]=Be,e[96]=Qe,e[97]=oe):oe=e[97];let H;e[98]!==v||e[99]!==M||e[100]!==r?(H=M.length>0&&!fs()?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-[var(--status-warning)]",children:r("settings.skills.catalog.shared.auth.title")}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:r("settings.skills.catalog.shared.auth.description")})]}),t.jsxs(Mt,{value:v||"",onValueChange:pe=>{j(pe),B()},children:[t.jsx(Rt,{className:"w-fit",children:t.jsx("span",{children:M.find(pe=>pe.id===v)?.name||r("settings.skills.catalog.shared.auth.chooseIdentity")})}),t.jsx(Tt,{align:"start",children:M.map(rh)})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:r("settings.skills.catalog.shared.auth.footerHint")})]}):null,e[98]=v,e[99]=M,e[100]=r,e[101]=H):H=e[101];let me;e[102]!==N||e[103]!==r?(me=N!==null?t.jsx("div",{className:"typography-meta text-muted-foreground",children:r("settings.skills.catalog.add.scanResult",{count:N})}):null,e[102]=N,e[103]=r,e[104]=me):me=e[104];let Ne;e[105]!==X||e[106]!==r?(Ne=X?t.jsx("div",{className:"typography-meta text-muted-foreground",children:r("settings.skills.catalog.add.duplicateMessage")}):null,e[105]=X,e[106]=r,e[107]=Ne):Ne=e[107];let Ee;e[108]!==te||e[109]!==Te||e[110]!==oe||e[111]!==H||e[112]!==me||e[113]!==Ne?(Ee=t.jsxs("div",{className:"space-y-4",children:[te,Te,oe,H,me,Ne]}),e[108]=te,e[109]=Te,e[110]=oe,e[111]=H,e[112]=me,e[113]=Ne,e[114]=Ee):Ee=e[114];let Ce;e[115]!==a?(Ce=()=>a(!1),e[115]=a,e[116]=Ce):Ce=e[116];let _e;e[117]!==r?(_e=r("settings.common.actions.cancel"),e[117]=r,e[118]=_e):_e=e[118];let G;e[119]!==Ce||e[120]!==_e?(G=t.jsx(J,{size:"sm",variant:"ghost",onClick:Ce,children:_e}),e[119]=Ce,e[120]=_e,e[121]=G):G=e[121];let $;e[122]!==Z?($=()=>{Z()},e[122]=Z,e[123]=$):$=e[123];let fe;e[124]!==x||e[125]!==f?(fe=x||!f.trim(),e[124]=x,e[125]=f,e[126]=fe):fe=e[126];let L;e[127]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(A,{name:"git-repository",className:"h-4 w-4"}),e[127]=L):L=e[127];let Le;e[128]!==x||e[129]!==r?(Le=r(x?"settings.skills.catalog.shared.actions.scanning":"settings.skills.catalog.shared.actions.scan"),e[128]=x,e[129]=r,e[130]=Le):Le=e[130];let Je;e[131]!==$||e[132]!==fe||e[133]!==Le?(Je=t.jsxs(J,{size:"sm",className:"gap-2",variant:"ghost",onClick:$,disabled:fe,children:[L,Le]}),e[131]=$,e[132]=fe,e[133]=Le,e[134]=Je):Je=e[134];let Xe;e[135]!==le?(Xe=()=>{le()},e[135]=le,e[136]=Xe):Xe=e[136];let et;e[137]!==X||e[138]!==u||e[139]!==b||e[140]!==f?(et=!b||X||!u.trim()||!f.trim(),e[137]=X,e[138]=u,e[139]=b,e[140]=f,e[141]=et):et=e[141];let at;e[142]!==r?(at=r("settings.skills.catalog.add.actions.addCatalog"),e[142]=r,e[143]=at):at=e[143];let ct;e[144]!==Xe||e[145]!==et||e[146]!==at?(ct=t.jsx(J,{size:"sm",onClick:Xe,disabled:et,children:at}),e[144]=Xe,e[145]=et,e[146]=at,e[147]=ct):ct=e[147];let Ze;e[148]!==G||e[149]!==Je||e[150]!==ct?(Ze=t.jsxs(Yt,{children:[G,Je,ct]}),e[148]=G,e[149]=Je,e[150]=ct,e[151]=Ze):Ze=e[151];let He;e[152]!==je||e[153]!==Ee||e[154]!==Ze?(He=t.jsxs(Bt,{className:"max-w-xl",children:[je,Ee,Ze]}),e[152]=je,e[153]=Ee,e[154]=Ze,e[155]=He):He=e[155];let mt;return e[156]!==a||e[157]!==n||e[158]!==He?(mt=t.jsx($t,{open:n,onOpenChange:a,children:He}),e[156]=a,e[157]=n,e[158]=He,e[159]=mt):mt=e[159],mt};function Xg(s){return s.scanRepo}function Zg(s){return s.loadCatalog}function eh(s){return s.loadSource}function th(s){return s.setSelectedSource}function sh(s){return s.isScanning}function nh(s){return s.defaultGitIdentityId}function ah(s){return s.loadDefaultGitIdentityId}function rh(s){return t.jsx(gt,{value:s.id,children:s.name},s.id)}const ih=s=>{const e=rt.c(85),{open:n,onOpenChange:a,conflicts:r,onConfirm:i}=s,{t:o}=dt();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const[c,x]=l.useState(d);let m,p;e[1]!==r||e[2]!==n?(m=()=>{if(!n)return;const le={};for(const ee of r)le[ee.skillName]="skip";x(le)},p=[n,r],e[1]=r,e[2]=n,e[3]=m,e[4]=p):(m=e[3],p=e[4]),l.useEffect(m,p);let u;e[5]!==r?(u=le=>{const ee={};for(const xe of r)ee[xe.skillName]=le;x(ee)},e[5]=r,e[6]=u):u=e[6];const C=u;let f;e[7]!==r||e[8]!==c?(f=r.length>0&&r.every(le=>c[le.skillName]),e[7]=r,e[8]=c,e[9]=f):f=e[9];const g=f;let h;e[10]!==o?(h=o("settings.skills.catalog.conflicts.title"),e[10]=o,e[11]=h):h=e[11];let D;e[12]!==h?(D=t.jsx(Ut,{children:h}),e[12]=h,e[13]=D):D=e[13];let k;e[14]!==o?(k=o("settings.skills.catalog.conflicts.description"),e[14]=o,e[15]=k):k=e[15];let w;e[16]!==k?(w=t.jsx(Wt,{children:k}),e[16]=k,e[17]=w):w=e[17];let E;e[18]!==D||e[19]!==w?(E=t.jsxs(_t,{children:[D,w]}),e[18]=D,e[19]=w,e[20]=E):E=e[20];let N;e[21]!==r.length||e[22]!==o?(N=o("settings.skills.catalog.conflicts.count",{count:r.length}),e[21]=r.length,e[22]=o,e[23]=N):N=e[23];let y;e[24]!==N?(y=t.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[24]=N,e[25]=y):y=e[25];let b;e[26]!==C?(b=()=>C("skip"),e[26]=C,e[27]=b):b=e[27];let P;e[28]!==o?(P=o("settings.skills.catalog.conflicts.actions.skipAll"),e[28]=o,e[29]=P):P=e[29];let z;e[30]!==b||e[31]!==P?(z=t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:b,children:P}),e[30]=b,e[31]=P,e[32]=z):z=e[32];let M;e[33]!==C?(M=()=>C("overwrite"),e[33]=C,e[34]=M):M=e[34];let I;e[35]!==o?(I=o("settings.skills.catalog.conflicts.actions.overwriteAll"),e[35]=o,e[36]=I):I=e[36];let v;e[37]!==M||e[38]!==I?(v=t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:M,children:I}),e[37]=M,e[38]=I,e[39]=v):v=e[39];let j;e[40]!==z||e[41]!==v?(j=t.jsxs("div",{className:"flex items-center gap-2",children:[z,v]}),e[40]=z,e[41]=v,e[42]=j):j=e[42];let O;e[43]!==y||e[44]!==j?(O=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y,j]}),e[43]=y,e[44]=j,e[45]=O):O=e[45];let T;if(e[46]!==r||e[47]!==c||e[48]!==o){let le;e[50]!==c||e[51]!==o?(le=ee=>t.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label truncate",children:ee.skillName}),t.jsx("div",{className:"typography-micro text-muted-foreground",children:o("settings.skills.catalog.conflicts.installedIn",{scope:ee.scope==="project"?o("settings.skills.catalog.conflicts.scope.project"):o("settings.skills.catalog.conflicts.scope.user"),source:ee.source==="agents"?o("settings.skills.catalog.conflicts.source.agents"):o("settings.skills.catalog.conflicts.source.opencode")})})]}),t.jsxs(Mt,{value:c[ee.skillName]||"skip",onValueChange:xe=>x(we=>({...we,[ee.skillName]:xe})),children:[t.jsx(Rt,{className:"w-fit",children:t.jsx("span",{className:"capitalize",children:(c[ee.skillName]||"skip")==="overwrite"?o("settings.skills.catalog.conflicts.decision.overwrite"):o("settings.skills.catalog.conflicts.decision.skip")})}),t.jsxs(Tt,{align:"end",children:[t.jsx(gt,{value:"skip",className:"pr-2 [&>span:first-child]:hidden",children:o("settings.skills.catalog.conflicts.decision.skip")}),t.jsx(gt,{value:"overwrite",className:"pr-2 [&>span:first-child]:hidden",children:o("settings.skills.catalog.conflicts.decision.overwrite")})]})]})]},ee.skillName),e[50]=c,e[51]=o,e[52]=le):le=e[52],T=r.map(le),e[46]=r,e[47]=c,e[48]=o,e[49]=T}else T=e[49];let B;e[53]!==T?(B=t.jsx("div",{className:"space-y-2",children:T}),e[53]=T,e[54]=B):B=e[54];let U;e[55]!==O||e[56]!==B?(U=t.jsxs("div",{className:"space-y-3",children:[O,B]}),e[55]=O,e[56]=B,e[57]=U):U=e[57];let Q;e[58]!==a?(Q=()=>a(!1),e[58]=a,e[59]=Q):Q=e[59];let q;e[60]!==o?(q=o("settings.common.actions.cancel"),e[60]=o,e[61]=q):q=e[61];let R;e[62]!==Q||e[63]!==q?(R=t.jsx(J,{size:"sm",variant:"ghost",onClick:Q,children:q}),e[62]=Q,e[63]=q,e[64]=R):R=e[64];let Y;e[65]!==c||e[66]!==i?(Y=()=>i(c),e[65]=c,e[66]=i,e[67]=Y):Y=e[67];const F=!g;let W;e[68]!==o?(W=o("settings.skills.catalog.conflicts.actions.continue"),e[68]=o,e[69]=W):W=e[69];let X;e[70]!==Y||e[71]!==F||e[72]!==W?(X=t.jsx(J,{size:"sm",onClick:Y,disabled:F,children:W}),e[70]=Y,e[71]=F,e[72]=W,e[73]=X):X=e[73];let re;e[74]!==R||e[75]!==X?(re=t.jsxs(Yt,{children:[R,X]}),e[74]=R,e[75]=X,e[76]=re):re=e[76];let Z;e[77]!==E||e[78]!==U||e[79]!==re?(Z=t.jsxs(Bt,{className:"max-w-2xl",children:[E,U,re]}),e[77]=E,e[78]=U,e[79]=re,e[80]=Z):Z=e[80];let de;return e[81]!==a||e[82]!==n||e[83]!==Z?(de=t.jsx($t,{open:n,onOpenChange:a,children:Z}),e[81]=a,e[82]=n,e[83]=Z,e[84]=de):de=e[84],de},qr=[{value:"user-opencode",scope:"user",source:"opencode",label:"User / OpenCode",description:"Global OpenCode config location"},{value:"project-opencode",scope:"project",source:"opencode",label:"Project / OpenCode",description:"Current project .opencode location"},{value:"user-agents",scope:"user",source:"agents",label:"User / Agents",description:"Global .agents compatibility location"},{value:"project-agents",scope:"project",source:"agents",label:"Project / Agents",description:"Current project .agents compatibility location"}];function Yn(s,e){return s==="project"&&e==="claude"?"project-claude":s==="project"&&e==="agents"?"project-agents":e==="claude"?"user-claude":s==="project"?"project-opencode":e==="agents"?"user-agents":"user-opencode"}function Ll(s){if(s==="user-claude")return{scope:"user",source:"claude"};if(s==="project-claude")return{scope:"project",source:"claude"};const e=qr.find(n=>n.value===s);return e?{scope:e.scope,source:e.source}:{scope:"user",source:"opencode"}}const oh=s=>{const e=rt.c(124),{open:n,onOpenChange:a,item:r}=s,{t:i}=dt(),o=Vs(lh),d=Vs(ch),[c,x]=l.useState("user"),[m,p]=l.useState("opencode"),u=is(dh),C=is(mh),[f,g]=l.useState(null),[h,D]=l.useState(!1);let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[0]=k):k=e[0];const[w,E]=l.useState(k),[N,y]=l.useState(null);let b,P;e[1]!==C||e[2]!==n?(b=()=>{n&&(x("user"),p("opencode"),g(C),D(!1),E([]),y(null))},P=[n,C],e[1]=C,e[2]=n,e[3]=b,e[4]=P):(b=e[3],P=e[4]),l.useEffect(b,P);let z;e[5]!==i?(z=oe=>{switch(oe){case"project-opencode":return i("settings.skills.location.option.projectOpencode.label");case"user-agents":return i("settings.skills.location.option.userAgents.label");case"project-agents":return i("settings.skills.location.option.projectAgents.label");default:return i("settings.skills.location.option.userOpencode.label")}},e[5]=i,e[6]=z):z=e[6];const M=z;let I;e[7]!==i?(I=oe=>{switch(oe){case"project-opencode":return i("settings.skills.location.option.projectOpencode.description");case"user-agents":return i("settings.skills.location.option.userAgents.description");case"project-agents":return i("settings.skills.location.option.projectAgents.description");default:return i("settings.skills.location.option.userOpencode.description")}},e[7]=i,e[8]=I):I=e[8];const v=I;let j;e:{if(u.length===0){j=null;break e}if(f&&u.some(oe=>oe.id===f)){j=f;break e}if(C&&u.some(oe=>oe.id===C)){j=C;break e}j=u[0]?.id??null}const O=j;let T;e:{if(c!=="project"){T=null;break e}const oe=O;if(!oe){T=null;break e}let H;if(e[9]!==oe||e[10]!==u){let Ne;e[12]!==oe?(Ne=Ee=>Ee.id===oe,e[12]=oe,e[13]=Ne):Ne=e[13],H=u.find(Ne),e[9]=oe,e[10]=u,e[11]=H}else H=e[11];T=H?.path??null}const B=T;let U;e[14]!==o||e[15]!==r||e[16]!==a||e[17]!==i?(U=async oe=>{const H={skillDir:oe.skillDir};r?.clawdhub&&(H.clawdhub={slug:r.clawdhub.slug,version:r.clawdhub.version});const me=await o({source:oe.source,subpath:oe.subpath,gitIdentityId:r?.gitIdentityId,scope:oe.scope,targetSource:oe.targetSource,selections:[H],conflictPolicy:"prompt",conflictDecisions:oe.conflictDecisions},{directory:oe.directoryOverride??null});if(me.ok){_.success(i("settings.skills.catalog.installSkill.toast.installed")),a(!1);return}if(me.error?.kind==="conflicts"){y({source:oe.source,subpath:oe.subpath,scope:oe.scope,targetSource:oe.targetSource,skillDir:oe.skillDir,directoryOverride:oe.directoryOverride??null}),E(me.error.conflicts),D(!0);return}if(me.error?.kind==="authRequired"){_.error(me.error.message||i("settings.skills.catalog.installSkill.toast.authRequired"));return}_.error(me.error?.message||i("settings.skills.catalog.installSkill.toast.installFailed"))},e[14]=o,e[15]=r,e[16]=a,e[17]=i,e[18]=U):U=e[18];const Q=U;if(!r)return null;let q;e[19]!==i?(q=i("settings.skills.catalog.installSkill.title"),e[19]=i,e[20]=q):q=e[20];let R;e[21]!==q?(R=t.jsx(Ut,{children:q}),e[21]=q,e[22]=R):R=e[22];let Y;e[23]!==i?(Y=i("settings.skills.catalog.installSkill.descriptionPrefix"),e[23]=i,e[24]=Y):Y=e[24];let F;e[25]!==r.skillName?(F=t.jsx("span",{className:"font-semibold text-foreground",children:r.skillName}),e[25]=r.skillName,e[26]=F):F=e[26];let W;e[27]!==i?(W=i("settings.skills.catalog.installSkill.descriptionSuffix"),e[27]=i,e[28]=W):W=e[28];let X;e[29]!==Y||e[30]!==F||e[31]!==W?(X=t.jsxs(Wt,{children:[Y," ",F," ",W]}),e[29]=Y,e[30]=F,e[31]=W,e[32]=X):X=e[32];let re;e[33]!==R||e[34]!==X?(re=t.jsxs(_t,{children:[R,X]}),e[33]=R,e[34]=X,e[35]=re):re=e[35];let Z;e[36]!==i?(Z=i("settings.skills.catalog.installSkill.field.destination"),e[36]=i,e[37]=Z):Z=e[37];let de;e[38]!==Z?(de=t.jsx("span",{className:"typography-ui-label text-foreground",children:Z}),e[38]=Z,e[39]=de):de=e[39];let le;e[40]!==c||e[41]!==m?(le=Yn(c,m),e[40]=c,e[41]=m,e[42]=le):le=e[42];let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=oe=>{const H=Ll(oe);x(H.scope),p(H.source==="agents"?"agents":"opencode")},e[43]=ee):ee=e[43];let xe;e[44]!==c?(xe=c==="user"?t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),e[44]=c,e[45]=xe):xe=e[45];let we;e[46]!==m?(we=m==="agents"?t.jsx(A,{name:"robot-2",className:"h-3.5 w-3.5"}):null,e[46]=m,e[47]=we):we=e[47];let he;e[48]!==M||e[49]!==c||e[50]!==m?(he=M(Yn(c,m)),e[48]=M,e[49]=c,e[50]=m,e[51]=he):he=e[51];let Ie;e[52]!==he?(Ie=t.jsx("span",{children:he}),e[52]=he,e[53]=Ie):Ie=e[53];let be;e[54]!==xe||e[55]!==we||e[56]!==Ie?(be=t.jsxs(Rt,{className:"w-fit gap-1.5",children:[xe,we,Ie]}),e[54]=xe,e[55]=we,e[56]=Ie,e[57]=be):be=e[57];let je;e[58]!==v||e[59]!==M?(je=qr.map(oe=>t.jsx(gt,{value:oe.value,className:"pr-2 [&>span:first-child]:hidden",children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[oe.scope==="user"?t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),oe.source==="agents"?t.jsx(A,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:M(oe.value)})]}),t.jsx("span",{className:"typography-micro text-muted-foreground ml-5",children:v(oe.value)})]})},oe.value)),e[58]=v,e[59]=M,e[60]=je):je=e[60];let ye;e[61]!==je?(ye=t.jsx(Tt,{align:"start",children:je}),e[61]=je,e[62]=ye):ye=e[62];let se;e[63]!==le||e[64]!==be||e[65]!==ye?(se=t.jsxs(Mt,{value:le,onValueChange:ee,children:[be,ye]}),e[63]=le,e[64]=be,e[65]=ye,e[66]=se):se=e[66];let ie;e[67]!==de||e[68]!==se?(ie=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[de,se]}),e[67]=de,e[68]=se,e[69]=ie):ie=e[69];let ge;e[70]!==u||e[71]!==O||e[72]!==c||e[73]!==i?(ge=c==="project"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.skills.catalog.installSkill.field.project")}),u.length===0?t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.skills.catalog.installSkill.field.noProjects")}):t.jsxs(Mt,{value:O??"",onValueChange:oe=>g(oe),disabled:u.length===1,children:[t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:i("settings.skills.catalog.installSkill.field.chooseProjectPlaceholder")})}),t.jsx(Tt,{align:"start",children:u.map(uh)})]})]}),e[70]=u,e[71]=O,e[72]=c,e[73]=i,e[74]=ge):ge=e[74];let V;e[75]!==r.warnings?(V=r.warnings?.length?t.jsx("div",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded",children:r.warnings.join(" · ")}):null,e[75]=r.warnings,e[76]=V):V=e[76];let te;e[77]!==ie||e[78]!==ge||e[79]!==V?(te=t.jsxs("div",{className:"mt-2 space-y-3",children:[ie,ge,V]}),e[77]=ie,e[78]=ge,e[79]=V,e[80]=te):te=e[80];let ne;e[81]!==a?(ne=()=>a(!1),e[81]=a,e[82]=ne):ne=e[82];let ue;e[83]!==i?(ue=i("settings.common.actions.cancel"),e[83]=i,e[84]=ue):ue=e[84];let Me;e[85]!==ne||e[86]!==ue?(Me=t.jsx(J,{size:"sm",variant:"ghost",onClick:ne,children:ue}),e[85]=ne,e[86]=ue,e[87]=Me):Me=e[87];const ke=d||!r.installable||c==="project"&&!B;let Re;e[88]!==B||e[89]!==Q||e[90]!==r.repoSource||e[91]!==r.repoSubpath||e[92]!==r.skillDir||e[93]!==c||e[94]!==m?(Re=()=>{Q({source:r.repoSource,subpath:r.repoSubpath,scope:c,targetSource:m,skillDir:r.skillDir,directoryOverride:B})},e[88]=B,e[89]=Q,e[90]=r.repoSource,e[91]=r.repoSubpath,e[92]=r.skillDir,e[93]=c,e[94]=m,e[95]=Re):Re=e[95];let Ae;e[96]!==d||e[97]!==i?(Ae=i(d?"settings.skills.catalog.installSkill.actions.installing":"settings.skills.catalog.installSkill.actions.install"),e[96]=d,e[97]=i,e[98]=Ae):Ae=e[98];let Pe;e[99]!==ke||e[100]!==Re||e[101]!==Ae?(Pe=t.jsx(J,{size:"sm",disabled:ke,onClick:Re,children:Ae}),e[99]=ke,e[100]=Re,e[101]=Ae,e[102]=Pe):Pe=e[102];let Te;e[103]!==Me||e[104]!==Pe?(Te=t.jsxs(Yt,{children:[Me,Pe]}),e[103]=Me,e[104]=Pe,e[105]=Te):Te=e[105];let Fe;e[106]!==re||e[107]!==te||e[108]!==Te?(Fe=t.jsxs(Bt,{className:"max-w-md",children:[re,te,Te]}),e[106]=re,e[107]=te,e[108]=Te,e[109]=Fe):Fe=e[109];let Be;e[110]!==a||e[111]!==n||e[112]!==Fe?(Be=t.jsx($t,{open:n,onOpenChange:a,children:Fe}),e[110]=a,e[111]=n,e[112]=Fe,e[113]=Be):Be=e[113];let We;e[114]!==N||e[115]!==Q?(We=oe=>{N&&(Q({source:N.source,subpath:N.subpath,scope:N.scope,targetSource:N.targetSource,skillDir:N.skillDir,conflictDecisions:oe,directoryOverride:N.directoryOverride??null}),D(!1))},e[114]=N,e[115]=Q,e[116]=We):We=e[116];let ze;e[117]!==w||e[118]!==h||e[119]!==We?(ze=t.jsx(ih,{open:h,onOpenChange:D,conflicts:w,onConfirm:We}),e[117]=w,e[118]=h,e[119]=We,e[120]=ze):ze=e[120];let Qe;return e[121]!==Be||e[122]!==ze?(Qe=t.jsxs(t.Fragment,{children:[Be,ze]}),e[121]=Be,e[122]=ze,e[123]=Qe):Qe=e[123],Qe};function lh(s){return s.installSkills}function ch(s){return s.isInstalling}function dh(s){return s.projects}function mh(s){return s.activeProjectId}function uh(s){return t.jsx(gt,{value:s.id,children:s.label||s.path},s.id)}const ph=async()=>{try{const s=zs()?.settings;if(s)return(await s.load())?.settings||{};const e=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});return e.ok?await e.json().catch(()=>null):null}catch{return null}},gh=({mode:s,onModeChange:e,showModeTabs:n=!0})=>{const{t:a}=dt(),{sources:r,itemsBySource:i,selectedSourceId:o,setSelectedSource:d,loadCatalog:c,loadSource:x,loadMoreClawdHub:m,isLoadingCatalog:p,isLoadingSource:u,isLoadingMore:C,loadedSourceIds:f,clawdhubHasMoreBySource:g,lastCatalogError:h}=Vs(Ss(R=>({sources:R.sources,itemsBySource:R.itemsBySource,selectedSourceId:R.selectedSourceId,setSelectedSource:R.setSelectedSource,loadCatalog:R.loadCatalog,loadSource:R.loadSource,loadMoreClawdHub:R.loadMoreClawdHub,isLoadingCatalog:R.isLoadingCatalog,isLoadingSource:R.isLoadingSource,isLoadingMore:R.isLoadingMore,loadedSourceIds:R.loadedSourceIds,clawdhubHasMoreBySource:R.clawdhubHasMoreBySource,lastCatalogError:R.lastCatalogError}))),[D,k]=l.useState(""),[w,E]=l.useState(!1),[N,y]=l.useState(!1),[b,P]=l.useState(null),[z,M]=l.useState(!1),[I,v]=l.useState(!1);l.useEffect(()=>{c()},[c]),l.useEffect(()=>{o&&(f[o]||x(o))},[o,f,x]);const j=l.useMemo(()=>o?i[o]||[]:[],[i,o]),O=l.useMemo(()=>{const R=D.trim().toLowerCase();return R?j.filter(Y=>{const F=Y.skillName.toLowerCase(),W=(Y.description||"").toLowerCase(),X=(Y.frontmatterName||"").toLowerCase();return F.includes(R)||W.includes(R)||X.includes(R)}):j},[j,D]),T=l.useMemo(()=>r.find(R=>R.id===o)||null,[r,o]),B=!!(o&&o.startsWith("custom:")),U=T?.source==="clawdhub:registry"||T?.sourceType==="clawdhub",Q=!!(o&&(g[o]??!0)),q=async()=>{if(!(!o||!B)){M(!0);try{const R=await ph(),F=(Array.isArray(R?.skillCatalogs)?R?.skillCatalogs:[]).filter(W=>W.id!==o);await Ct({skillCatalogs:F}),await c({refresh:!0}),v(!1)}finally{M(!1)}}};return t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4",children:[n&&t.jsx("div",{className:"mb-4",children:t.jsx("div",{className:"h-10",children:t.jsx(fn,{items:[{id:"manual",label:a("settings.skills.catalog.page.mode.manual")},{id:"external",label:a("settings.skills.catalog.page.mode.external")}],activeId:s,onSelect:R=>e(R),layoutMode:"fit",variant:"animated",animateActivePill:!1,className:"h-full"})})}),t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground px-1",children:a("settings.skills.catalog.page.title")})]}),t.jsxs("div",{"data-settings-item":"skills.catalog.source",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:a("settings.skills.catalog.page.section.sourceRepository")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1.5",children:[t.jsxs(Mt,{value:o||"",onValueChange:R=>d(R),children:[t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:a("settings.skills.catalog.page.field.selectSourcePlaceholder"),children:T?.label})}),t.jsx(Tt,{align:"start",children:r.map(R=>t.jsx(gt,{value:R.id,children:R.label},R.id))})]}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{o?x(o,{refresh:!0}):c({refresh:!0})},disabled:p||u,title:a("settings.skills.catalog.page.actions.refreshTitle"),children:t.jsx(A,{name:"refresh",className:ce("h-3.5 w-3.5",(p||u)&&"animate-spin")})}),B&&t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>v(!0),disabled:z,title:a("settings.skills.catalog.page.actions.removeCatalogTitle"),children:t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(J,{"data-settings-item":"skills.catalog.add-catalog",size:"xs",className:"!font-normal gap-1",onClick:()=>E(!0),children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"})," ",a("settings.skills.catalog.page.actions.addCatalog")]})]}),t.jsxs("div",{"data-settings-item":"skills.catalog.search",className:"py-1.5",children:[t.jsxs("div",{className:"relative",children:[t.jsx(A,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),t.jsx(ot,{value:D,onChange:R=>k(R.target.value),placeholder:a("settings.skills.catalog.shared.field.searchSkillsPlaceholder"),className:"h-7 pl-8 w-full sm:w-64"})]}),t.jsx("span",{className:"typography-meta text-muted-foreground mt-1 block",children:p?a("settings.skills.catalog.page.loading.catalog"):a("settings.skills.catalog.page.foundCount",{count:O.length})})]})]})]}),h&&t.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[t.jsx("div",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:a("settings.skills.catalog.page.error.catalogTitle")}),t.jsx("div",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:h.message})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("section",{className:"px-2 pb-2 pt-0",children:O.length===0&&!u?t.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[t.jsx("p",{className:"typography-body",children:a("settings.skills.catalog.page.empty.noSkillsTitle")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.skills.catalog.page.empty.noSkillsDescription")})]}):u?t.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[t.jsx(A,{name:"refresh",className:"mx-auto mb-3 h-5 w-5 animate-spin opacity-50"}),t.jsx("p",{className:"typography-meta",children:a("settings.skills.catalog.page.loading.skills")})]}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:O.map(R=>{const Y=R.installed?.isInstalled,F=R.installed?.scope;return t.jsx("div",{className:"py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:R.skillName}),Y&&t.jsx("span",{className:"typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:a("settings.skills.catalog.page.badge.installed",{scope:F||a("settings.skills.catalog.page.badge.unknown")})}),!R.installable&&t.jsx("span",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:a("settings.skills.catalog.page.badge.notInstallable")})]}),R.description?t.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 line-clamp-2",children:R.description}):t.jsx("div",{className:"typography-meta text-muted-foreground/50 mt-0.5 italic",children:a("settings.skills.catalog.shared.noDescription")}),R.clawdhub&&t.jsxs("div",{className:"typography-micro text-muted-foreground mt-1.5 flex items-center gap-3",children:[R.clawdhub.owner&&t.jsxs("span",{children:[a("settings.skills.catalog.page.byOwnerPrefix")," ",t.jsx("span",{className:"font-medium text-foreground/80",children:R.clawdhub.owner})]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(A,{name:"download",className:"h-3 w-3"}),R.clawdhub.downloads?.toLocaleString()??0]}),(R.clawdhub.stars??0)>0&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(A,{name:"star",className:"h-3 w-3"}),R.clawdhub.stars]}),t.jsxs("span",{className:"bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:["v",R.clawdhub.version]})]}),R.warnings?.length?t.jsx("div",{className:"typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit",children:R.warnings.join(" · ")}):null]}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal shrink-0",disabled:!R.installable,onClick:()=>{P(R),y(!0)},children:a("settings.skills.catalog.shared.actions.install")})]})},`${R.sourceId}:${R.skillDir}`)})})}),U&&Q&&!u&&O.length>0&&t.jsx("div",{className:"flex justify-center mt-2 px-2",children:t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{m()},disabled:C,children:a(C?"settings.skills.catalog.page.loading.more":"settings.skills.catalog.page.actions.loadMoreSkills")})})]}),t.jsx(Yg,{open:w,onOpenChange:E}),t.jsx(oh,{open:N,onOpenChange:y,item:b}),t.jsx($t,{open:I,onOpenChange:R=>{z||v(R)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:a("settings.skills.catalog.page.removeDialog.title")}),t.jsx(Wt,{children:a("settings.skills.catalog.page.removeDialog.description")})]}),t.jsxs(Yt,{children:[t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>v(!1),disabled:z,children:a("settings.common.actions.cancel")}),t.jsx(J,{size:"sm",variant:"destructive",onClick:()=>{q()},disabled:z,children:a("settings.skills.catalog.page.actions.removeCatalog")})]})]})})]})})};function vo(s,e){const n=s.metadata.variant==="dark",a=s.config?.fonts?.mono||"monospace",r=s.colors.syntax.highlights||{},i=s.colors.syntax.tokens||{},o=Os.theme({"&":{backgroundColor:"var(--background)",color:s.colors.syntax.base.foreground,fontSize:"var(--text-code)",lineHeight:"1.5rem",position:"relative"},".cm-scroller":{fontFamily:a,backgroundColor:"var(--background)"},".cm-comment":{color:s.colors.syntax.base.comment},".cm-keyword":{color:s.colors.syntax.base.keyword},".cm-string":{color:s.colors.syntax.base.string},".cm-string-2":{color:i.stringEscape||s.colors.syntax.base.string},".cm-number":{color:s.colors.syntax.base.number},".cm-operator":{color:s.colors.syntax.base.operator},".cm-punctuation":{color:i.punctuation||s.colors.syntax.base.comment},".cm-atom":{color:i.boolean||s.colors.syntax.base.number},".cm-builtin":{color:i.functionCall||s.colors.syntax.base.function},".cm-def":{color:i.variableGlobal||s.colors.syntax.base.variable},".cm-attribute":{color:i.variableOther||i.variableProperty||s.colors.syntax.base.operator},".cm-meta":{color:s.colors.syntax.base.comment},".cm-property":{color:i.variableProperty||s.colors.syntax.base.keyword},".cm-variable":{color:s.colors.syntax.base.variable},".cm-variable-2":{color:i.variableOther||s.colors.syntax.base.function},".cm-variable-3":{color:i.variableGlobal||s.colors.syntax.base.type},".cm-tag":{color:i.tag||s.colors.syntax.base.keyword},".cm-link":{color:i.url||s.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:s.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:s.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:s.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:r.lineNumber||s.colors.syntax.base.comment,borderRight:`1px solid ${s.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:r.lineNumberActive||s.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:s.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:s.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${s.colors.interactive.border}`,backgroundColor:s.colors.surface.elevated,color:s.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${s.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${s.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${s.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:s.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${s.colors.interactive.border}`,backgroundColor:s.colors.surface.background,color:s.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:s.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:s.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:s.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:s.colors.interactive.hover,borderColor:s.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:s.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:s.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:s.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:s.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:s.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:s.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:s.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:s.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${s.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:s.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:s.colors.interactive.hover,color:s.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:s.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${s.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:s.colors.interactive.selection,color:s.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${s.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:n}),d=ni.define([{tag:[Oe.comment,Oe.docComment,Oe.meta,Oe.documentMeta],class:"cm-comment"},{tag:[Oe.keyword,Oe.controlKeyword,Oe.moduleKeyword,Oe.definitionKeyword,Oe.modifier],class:"cm-keyword"},{tag:[Oe.operatorKeyword,Oe.operator,Oe.derefOperator,Oe.updateOperator,Oe.definitionOperator,Oe.typeOperator,Oe.controlOperator,Oe.logicOperator,Oe.bitwiseOperator,Oe.arithmeticOperator,Oe.compareOperator],class:"cm-operator"},{tag:[Oe.punctuation,Oe.separator,Oe.bracket,Oe.paren,Oe.brace,Oe.squareBracket,Oe.angleBracket],class:"cm-punctuation"},{tag:[Oe.string,Oe.regexp,Oe.attributeValue,Oe.special(Oe.string),Oe.monospace],class:"cm-string"},{tag:Oe.escape,class:"cm-string-2"},{tag:[Oe.number,Oe.bool,Oe.atom,Oe.null,Oe.self],class:"cm-number"},{tag:[Oe.function(Oe.variableName),Oe.function(Oe.definition(Oe.variableName)),Oe.function(Oe.propertyName),Oe.standard(Oe.variableName),Oe.special(Oe.variableName)],class:"cm-builtin"},{tag:Oe.definition(Oe.variableName),class:"cm-def"},{tag:[Oe.variableName,Oe.local(Oe.variableName),Oe.constant(Oe.variableName),Oe.literal],class:"cm-variable"},{tag:Oe.propertyName,class:"cm-property"},{tag:Oe.attributeName,class:"cm-attribute"},{tag:[Oe.className,Oe.typeName,Oe.namespace],class:"cm-variable-3"},{tag:[Oe.tagName,Oe.labelName,Oe.annotation,Oe.macroName],class:"cm-tag"},{tag:Oe.link,class:"cm-link"},{tag:[Oe.heading,Oe.heading1,Oe.heading2,Oe.heading3,Oe.heading4,Oe.heading5,Oe.heading6],class:"cm-keyword"}]),c=ni.define([{tag:[Oe.comment,Oe.docComment,Oe.meta,Oe.documentMeta],color:s.colors.syntax.base.comment},{tag:[Oe.keyword,Oe.controlKeyword,Oe.moduleKeyword,Oe.definitionKeyword,Oe.modifier],color:s.colors.syntax.base.keyword},{tag:[Oe.operatorKeyword,Oe.operator,Oe.derefOperator,Oe.updateOperator,Oe.definitionOperator,Oe.typeOperator,Oe.controlOperator,Oe.logicOperator,Oe.bitwiseOperator,Oe.arithmeticOperator,Oe.compareOperator],color:s.colors.syntax.base.operator},{tag:[Oe.string,Oe.regexp,Oe.attributeValue,Oe.special(Oe.string),Oe.monospace],color:s.colors.syntax.base.string},{tag:Oe.escape,color:i.stringEscape||s.colors.syntax.base.string},{tag:[Oe.number,Oe.bool,Oe.atom,Oe.null,Oe.self],color:s.colors.syntax.base.number},{tag:[Oe.function(Oe.variableName),Oe.function(Oe.definition(Oe.variableName)),Oe.function(Oe.propertyName),Oe.standard(Oe.variableName),Oe.special(Oe.variableName)],color:s.colors.syntax.base.function},{tag:Oe.definition(Oe.variableName),color:i.variableGlobal||s.colors.syntax.base.variable},{tag:[Oe.variableName,Oe.local(Oe.variableName),Oe.constant(Oe.variableName),Oe.literal],color:s.colors.syntax.base.variable},{tag:Oe.propertyName,color:i.variableProperty||s.colors.syntax.base.variable},{tag:Oe.attributeName,color:i.variableOther||s.colors.syntax.base.variable},{tag:[Oe.className,Oe.typeName,Oe.namespace],color:s.colors.syntax.base.type},{tag:[Oe.tagName,Oe.labelName,Oe.annotation,Oe.macroName],color:i.tag||s.colors.syntax.base.keyword},{tag:Oe.link,color:i.url||s.colors.syntax.base.function,textDecoration:"underline"},{tag:[Oe.punctuation,Oe.separator,Oe.bracket,Oe.paren,Oe.brace,Oe.squareBracket,Oe.angleBracket],color:i.punctuation||s.colors.syntax.base.comment}]);return e?.syntaxColors===!1?[o]:[o,aa(Zc,{fallback:!0}),aa(ed),aa(d),aa(c)]}const hh=180,zl=td.define(),fh=1,xh=2,bh=4,jo=new Map,yh=(s,e)=>{const n=`${s}|${e}`,a=jo.get(n);if(a)return a;let r="";s&&(r+=`color:${s};`),e&fh&&(r+="font-style:italic;"),e&xh&&(r+="font-weight:bold;"),e&bh&&(r+="text-decoration:underline;");const i=za.mark({attributes:{style:r}});return jo.set(n,i),i},vh=(s,e)=>{const n=new Vr,a=s.state.doc,r=Math.min(e.length,a.lines);for(let i=0;i<r;i+=1){const o=e[i];if(!o||o.length===0)continue;const d=a.line(i+1);let c=d.from;for(const[x,m,p]of o){if(x<=0)continue;const u=c,C=Math.min(c+x,d.to);c+=x,!(C<=u)&&(!m&&!p||n.add(u,C,yh(m,p)))}}return n.finish()},jh=ul.define({create(){return za.none},update(s,e){let n=s.map(e.changes);for(const a of e.effects)a.is(zl)&&(n=a.value);return n},provide:s=>Os.decorations.from(s)}),wh=s=>ml.fromClass(class{timer;generation=0;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},hh)}async tokenize(e){const n=++this.generation,a=e.state.doc.toString(),r=await Md(a,s.language,s.themeName,s.theme);r&&n===this.generation&&e.state.doc.length===a.length&&e.dispatch({effects:zl.of(vh(e,r))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Nh=s=>[jh,wh(s)],kh=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(gh,{mode:"external",onModeChange:Ah,showModeTabs:!1}),s[0]=e):e=s[0],e},Sh="SKILL.md",Ch="h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]",Aa=(s,e)=>{const n=sd({description:s}).trimEnd(),a=e.trimStart();return`---
|
|
23
|
+
${n}
|
|
24
|
+
---${a?`
|
|
25
|
+
|
|
26
|
+
${a}`:`
|
|
27
|
+
`}`},Ph=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),Kl=s=>{const e=s.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!e)return{description:null,instructions:s};let n=null;try{const a=nd(e[1]);if(Ph(a)){const r=a.description;typeof r=="string"&&(n=r)}}catch{n=null}return{description:n,instructions:e[2].replace(/^\r?\n/,"")}},Ih=(s,e)=>{const n=Kl(s);return Aa(e,n.instructions)},Dh=()=>{const{t:s}=dt(),{currentTheme:e}=Ua(),{selectedSkillName:n,getSkillByName:a,getSkillDetail:r,createSkill:i,updateSkill:o,skills:d,skillDraft:c,setSkillDraft:x,setSelectedSkill:m}=Hs(Ss(oe=>({selectedSkillName:oe.selectedSkillName,getSkillByName:oe.getSkillByName,getSkillDetail:oe.getSkillDetail,createSkill:oe.createSkill,updateSkill:oe.updateSkill,skills:oe.skills,skillDraft:oe.skillDraft,setSkillDraft:oe.setSkillDraft,setSelectedSkill:oe.setSelectedSkill}))),p=n?a(n):null,u=!!(c&&c.name===n&&!p),C=!!(n&&!p&&!c),f=p?.path==="<built-in>";l.useEffect(()=>{C&&m(null)},[C,m]);const[g,h]=l.useState(""),[D,k]=l.useState("user"),[w,E]=l.useState("opencode"),[N,y]=l.useState(""),[b,P]=l.useState(""),[z,M]=l.useState(()=>Aa("","")),[I,v]=l.useState("edit"),[j,O]=l.useState([]),[T,B]=l.useState([]),[U,Q]=l.useState(!1),[q,R]=l.useState(!1),[Y,F]=l.useState(""),[W,X]=l.useState(""),[re,Z]=l.useState(!1),[de,le]=l.useState(""),[ee,xe]=l.useState(""),[we,he]=l.useState(null),[Ie,be]=l.useState(!1),[je,ye]=l.useState(""),[se,ie]=l.useState(null),[ge,V]=l.useState(!1),te=u?g.trim()!==""||N.trim()!==""||b.trim()!==""||T.length>0:N!==Y||b!==W,ne=we?ee!==je:de.trim()!=="",ue=l.useCallback(oe=>{switch(oe){case"project-opencode":return s("settings.skills.location.option.projectOpencode.label");case"user-claude":return s("settings.skills.location.option.userClaude.label");case"project-claude":return s("settings.skills.location.option.projectClaude.label");case"user-agents":return s("settings.skills.location.option.userAgents.label");case"project-agents":return s("settings.skills.location.option.projectAgents.label");default:return s("settings.skills.location.option.userOpencode.label")}},[s]),Me=l.useCallback(oe=>{switch(oe){case"project-opencode":return s("settings.skills.location.option.projectOpencode.description");case"user-claude":return s("settings.skills.location.option.userClaude.description");case"project-claude":return s("settings.skills.location.option.projectClaude.description");case"user-agents":return s("settings.skills.location.option.userAgents.description");case"project-agents":return s("settings.skills.location.option.projectAgents.description");default:return s("settings.skills.location.option.userOpencode.description")}},[s]);l.useEffect(()=>{(async()=>{if(u&&c){const H=c.description||"",me=c.instructions||"";h(c.name||""),k(c.scope||"user"),E(c.source==="agents"?"agents":"opencode"),y(H),P(me),M(Aa(H,me)),F(""),X(""),O([]),B(c.pendingFiles||[])}else if(n&&p){R(!0);try{const H=await r(n);if(H){const me=H.sources.md,Ne=me.description||"",Ee=me.instructions||"";y(Ne),P(Ee),M(Aa(Ne,Ee)),F(Ne),X(Ee),O(me.supportingFiles||[])}}catch(H){console.error("Failed to load skill details:",H)}finally{R(!1)}}})()},[p,u,n,d,c,r]);const ke=l.useMemo(()=>{const oe=[vo(e)],H=ri(Sh);return H&&oe.push(H),oe.push(Os.lineWrapping),oe},[e]),Re=l.useMemo(()=>{const oe=de.trim()||"supporting-file.md",H=Rd(oe),me=!!H&&H!=="markdown",Ne=[vo(e,me?{syntaxColors:!1}:void 0)],Ee=ri(oe);return Ee&&Ne.push(Ee),me&&H&&Ne.push(Nh({language:H,themeName:e.metadata.id,theme:Nr(e)})),Ne.push(Os.lineWrapping),Ne},[e,de]),Ae=l.useCallback(oe=>{y(oe),M(H=>Ih(H,oe))},[]),Pe=l.useCallback(oe=>{M(oe);const H=Kl(oe);y(H.description??""),P(H.instructions)},[]),Te=async()=>{const oe=u?g.trim().replace(/\s+/g,"-").toLowerCase():n?.trim();if(!oe){_.error(s("settings.skills.page.toast.skillNameRequired"));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(oe)||oe.length>64){_.error(s("settings.skills.page.toast.invalidSkillName"));return}if(!N.trim()){_.error(s("settings.skills.page.toast.descriptionRequired"));return}if(u&&d.some(H=>H.name===oe)){_.error(s("settings.skills.page.toast.skillExists"));return}Q(!0);try{const H={name:oe,description:N.trim(),instructions:b.trim()||void 0,scope:u?D:void 0,source:u?w:void 0,targetPath:u?void 0:p?.path,supportingFiles:u&&T.length>0?T:void 0};let me;u?(me=await i(H),me&&(x(null),B([]),m(oe))):(me=await o(oe,H),me&&(F(N.trim()),X(b.trim()))),me?_.success(s(u?"settings.skills.page.toast.skillCreated":"settings.skills.page.toast.skillUpdated")):_.error(s(u?"settings.skills.page.toast.createSkillFailed":"settings.skills.page.toast.updateSkillFailed"))}catch(H){console.error("Error saving skill:",H),_.error(s("settings.skills.page.toast.saveUnexpectedError"))}finally{Q(!1)}},Fe=()=>{he(null),le(""),xe(""),ye(""),Z(!0)},Be=async oe=>{if(he(oe),le(oe),u){const me=T.find(Ne=>Ne.path===oe)?.content||"";xe(me),ye(me),Z(!0);return}if(n){be(!0),Z(!0);try{const{readSupportingFile:H}=Hs.getState(),me=await H(n,oe);xe(me||""),ye(me||"")}catch{_.error(s("settings.skills.page.toast.loadFileContentFailed")),xe(""),ye("")}finally{be(!1)}}},We=async()=>{if(!de.trim()){_.error(s("settings.skills.page.toast.fileNameRequired"));return}const oe=de.trim(),H=we!==null;if(u){if(H)B(Ee=>Ee.map(Ce=>Ce.path===we?{path:oe,content:ee}:Ce)),_.success(s("settings.skills.page.toast.fileUpdated",{path:oe}));else{if(T.some(Ee=>Ee.path===oe)){_.error(s("settings.skills.page.toast.fileExists"));return}B(Ee=>[...Ee,{path:oe,content:ee}]),_.success(s("settings.skills.page.toast.fileAdded",{path:oe}))}Z(!1),he(null);return}if(!n){_.error(s("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:me}=Hs.getState();if(await me(n,oe,ee)){_.success(H?s("settings.skills.page.toast.fileUpdated",{path:oe}):s("settings.skills.page.toast.fileCreated",{path:oe})),Z(!1),he(null);const Ee=await r(n);Ee&&O(Ee.sources.md.supportingFiles||[])}else _.error(s(H?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},ze=oe=>{if(u){B(H=>H.filter(me=>me.path!==oe)),_.success(s("settings.skills.page.toast.fileRemoved",{path:oe}));return}n&&ie(oe)},Qe=async()=>{if(!se||!n)return;V(!0);const{deleteSupportingFile:oe}=Hs.getState();if(await oe(n,se)){_.success(s("settings.skills.page.toast.fileDeleted",{path:se}));const me=await r(n);me&&O(me.sources.md.supportingFiles||[]),ie(null)}else _.error(s("settings.skills.page.toast.deleteFileFailed"));V(!1)};return!n&&!c||C?t.jsx("div",{className:"flex h-full items-center justify-center px-4",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.skills.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.skills.page.empty.description")})]})}):q?t.jsx("div",{className:"flex h-full items-center justify-center px-4",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx("p",{className:"typography-body",children:s("settings.skills.page.loading.details")})})}):t.jsxs(Gt,{outerClassName:"h-full",className:"w-full",children:[t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate flex items-center gap-2",children:u?s("settings.skills.page.title.newSkill"):n}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:p?s("settings.skills.page.subtitle.skillLocation",{location:ue(Yn(p.scope,p.source))}):s("settings.skills.page.subtitle.newSkill")})]})}),t.jsxs("div",{"data-settings-item":"skills.basic-information",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.skills.page.section.basicInformation")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[u&&t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.skills.page.field.skillNameLocation")}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:s("settings.skills.page.field.skillNameHint")}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx(ot,{value:g,onChange:oe=>h(oe.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:s("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),t.jsxs(Mt,{value:Yn(D,w),onValueChange:oe=>{const H=Ll(oe);k(H.scope),E(H.source==="agents"?"agents":"opencode")},children:[t.jsxs(Rt,{className:"w-fit gap-1.5",children:[D==="user"?t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),w==="agents"?t.jsx(A,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:ue(Yn(D,w))})]}),t.jsx(Tt,{align:"start",children:qr.map(oe=>t.jsx(gt,{value:oe.value,children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[oe.scope==="user"?t.jsx(A,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"folder",className:"h-3.5 w-3.5"}),oe.source==="agents"?t.jsx(A,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:ue(oe.value)})]}),t.jsx("span",{className:"typography-micro text-muted-foreground ml-6",children:Me(oe.value)})]})},oe.value))})]})]})]}),t.jsxs("div",{className:"py-1.5",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[s("settings.common.field.description")," ",t.jsx("span",{className:"text-[var(--status-error)]",children:"*"})]}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:s("settings.skills.page.field.descriptionHint")}),t.jsx("div",{className:"mt-1.5",children:t.jsx(hs,{value:N,onChange:oe=>Ae(oe.target.value),placeholder:s("settings.skills.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] max-h-32 bg-transparent",disabled:f})})]})]})]}),t.jsxs("div",{"data-settings-item":"skills.instructions",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.skills.page.section.instructions")}),t.jsx(qg,{currentMode:I==="preview"?"preview":"edit",onToggle:()=>v(oe=>oe==="preview"?"edit":"preview")})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx("div",{className:ce("overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",Ch),children:I==="preview"?t.jsx(Gt,{outerClassName:"h-full",className:"h-full",children:t.jsx("div",{className:"min-h-full px-4 py-3",children:t.jsx(wr,{content:z,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})}):t.jsx(yo,{value:z,onChange:Pe,readOnly:f,extensions:ke,className:"h-full",enableSearch:!0})})})]}),t.jsxs("div",{"data-settings-item":"skills.supporting-files",className:"mb-2",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.skills.page.section.supportingFiles")}),t.jsxs(J,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:Fe,disabled:f,children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"})," ",s("settings.skills.page.actions.addFile")]})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:(()=>{const oe=u?T:j;return oe.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground py-1.5",children:s("settings.skills.page.supportingFiles.empty")}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:oe.map(H=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>Be(H.path),children:[t.jsx(A,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:H.path}),u&&t.jsx("span",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:s("settings.skills.page.badge.pending")}),!f&&t.jsx(J,{size:"sm",variant:"ghost",className:"h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity",onClick:me=>{me.stopPropagation(),ze(H.path)},children:t.jsx(A,{name:"delete-bin",className:"h-3 w-3"})})]},H.path))})})()})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(J,{onClick:Te,disabled:f||U||!te,size:"xs",className:"!font-normal",children:s(U?"settings.common.actions.saving":u?"settings.skills.page.actions.createSkill":"settings.common.actions.saveChanges")})})]}),t.jsx($t,{open:se!==null,onOpenChange:oe=>{!oe&&!ge&&ie(null)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.skills.page.deleteFileDialog.title")}),t.jsx(Wt,{children:s("settings.skills.page.deleteFileDialog.description",{path:se??""})})]}),t.jsxs(Yt,{children:[t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>ie(null),disabled:ge,children:s("settings.common.actions.cancel")}),t.jsx(J,{size:"sm",variant:"destructive",onClick:Qe,disabled:ge,children:s("settings.common.actions.delete")})]})]})}),t.jsx($t,{open:re,onOpenChange:oe=>{Z(oe),oe||he(null)},children:t.jsxs(Bt,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[t.jsxs(_t,{className:"flex-shrink-0",children:[t.jsx(Ut,{children:s(we?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),t.jsx(Wt,{children:s(we?"settings.skills.page.fileDialog.descriptionEdit":"settings.skills.page.fileDialog.descriptionAdd")})]}),Ie?t.jsx("div",{className:"flex-1 flex items-center justify-center py-8",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.skills.page.loading.fileContent")})}):t.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col pt-2",children:[t.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:s("settings.skills.page.fileDialog.field.filePath")}),t.jsx(ot,{value:de,onChange:oe=>le(oe.target.value),placeholder:s("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]",disabled:we!==null}),!we&&t.jsx("p",{className:"typography-micro text-muted-foreground",children:s("settings.skills.page.fileDialog.field.filePathHint")})]}),t.jsxs("div",{className:"space-y-2 flex-1 min-h-0 flex flex-col",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground flex-shrink-0",children:s("settings.skills.page.fileDialog.field.content")}),t.jsx("div",{className:"h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",children:t.jsx(yo,{value:ee,onChange:xe,extensions:Re,className:"h-full",enableSearch:!0})})]})]}),t.jsxs(Yt,{className:"mt-4",children:[t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>{Z(!1),he(null)},children:s("settings.common.actions.cancel")}),t.jsx(J,{size:"sm",onClick:We,disabled:Ie||!ne,children:s(we?"settings.common.actions.saveChanges":"settings.skills.page.actions.createFile")})]})]})})]})},wo=s=>{const e=rt.c(2),{view:n}=s,a=n===void 0?"installed":n;let r;return e[0]!==a?(r=a==="catalog"?t.jsx(kh,{}):t.jsx(Dh,{}),e[0]=a,e[1]=r):r=e[1],r};function Ah(){}const Eh=s=>{const e=rt.c(38),{onItemSelect:n}=s,{t:a}=dt(),r=is(Mh),i=Ke(Rh),o=Ke(Th),{currentTheme:d}=Ua();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=fs(),e[0]=c):c=e[0];const x=c,m=Fh;let p,u;e[1]!==r||e[2]!==i||e[3]!==o?(p=()=>{if(r.length===0){i!==null&&o(null);return}i&&r.some(b=>b.id===i)||o(r[0].id)},u=[r,i,o],e[1]=r,e[2]=i,e[3]=o,e[4]=p,e[5]=u):(p=e[4],u=e[5]),l.useEffect(p,u);let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=ce("border-b px-3","pt-4 pb-3"),e[6]=C):C=e[6];let f;e[7]!==a?(f=a("settings.page.projects.title"),e[7]=a,e[8]=f):f=e[8];let g;e[9]!==f?(g=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:f}),e[9]=f,e[10]=g):g=e[10];let h;e[11]!==r.length||e[12]!==a?(h=a("settings.projects.sidebar.total",{count:r.length}),e[11]=r.length,e[12]=a,e[13]=h):h=e[13];let D;e[14]!==h?(D=t.jsx("span",{className:"typography-meta text-muted-foreground",children:h}),e[14]=h,e[15]=D):D=e[15];let k;e[16]!==a?(k=!x&&t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:m,"aria-label":a("settings.projects.sidebar.actions.addProject"),children:t.jsx(A,{name:"add",className:"size-4"})}),e[16]=a,e[17]=k):k=e[17];let w;e[18]!==D||e[19]!==k?(w=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[D,k]}),e[18]=D,e[19]=k,e[20]=w):w=e[20];let E;e[21]!==w||e[22]!==g?(E=t.jsxs("div",{className:C,children:[g,w]}),e[21]=w,e[22]=g,e[23]=E):E=e[23];let N;if(e[24]!==d||e[25]!==n||e[26]!==r||e[27]!==i||e[28]!==o){let b;e[30]!==d||e[31]!==n||e[32]!==i||e[33]!==o?(b=P=>{const z=P.id===i,M=P.icon?Td[P.icon]:null,I=P.color?bl[P.color]??null:null,v=M?t.jsx(A,{name:M,className:ce("h-4 w-4",z?"text-foreground":"text-muted-foreground/70"),style:I?{color:I}:void 0}):t.jsx(A,{name:"folder",className:ce("h-4 w-4",z?"text-foreground":"text-muted-foreground/70"),style:I?{color:I}:void 0}),j=P.iconImage?t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:P.iconBackground?{backgroundColor:P.iconBackground}:void 0,children:t.jsx(yl,{project:P,options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:v})}):v;return t.jsx(Rr,{title:P.label||P.path,icon:j,selected:z,onSelect:()=>{o(P.id),n?.()}},P.id)},e[30]=d,e[31]=n,e[32]=i,e[33]=o,e[34]=b):b=e[34],N=r.map(b),e[24]=d,e[25]=n,e[26]=r,e[27]=i,e[28]=o,e[29]=N}else N=e[29];let y;return e[35]!==E||e[36]!==N?(y=t.jsx(Fl,{variant:"background",header:E,children:N}),e[35]=E,e[36]=N,e[37]=y):y=e[37],y};function Mh(s){return s.projects}function Rh(s){return s.settingsProjectsSelectedId}function Th(s){return s.setSettingsProjectsSelectedId}function Fh(){xl.requestDirectoryDialog()}const Oh=({projectRef:s=null})=>{const{t:e}=dt(),{isMobile:n,isTablet:a}=Cs(),r=n||a,i=is(B=>B.getActiveProject()),o=s?.path??i?.path??null,d=Is(B=>B.getWorktreeMetadata),c=Fd(),x=ys(B=>B.homeDirectory),[m,p]=l.useState([]),[u,C]=l.useState(!1),[f,g]=l.useState(!1),[h,D]=l.useState(null),[k,w]=l.useState([]),[E,N]=l.useState(!1),y=l.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!o?null:{id:i.id,path:o},[i?.id,o,s?.id,s?.path]),b=l.useCallback(async()=>{if(!(!y||h===!1))try{const B=await ii(y);w(B)}catch{}},[y,h]);l.useEffect(()=>{if(!o)return;let B=!1;return D(null),(async()=>{try{const U=await Od(o);if(B)return;D(U)}catch{}})(),()=>{B=!0}},[o]),l.useEffect(()=>{if(!y){w([]),N(!1);return}if(h===!1){w([]),N(!1);return}let B=!1;return N(!0),w([]),(async()=>{try{const U=await ii(y);if(B)return;w(U)}catch{}finally{B||N(!1)}})(),()=>{B=!0}},[y,h]),l.useEffect(()=>{if(!y)return;let B=!1;return g(!0),(async()=>{try{const[U,Q]=await Promise.all([vl(y),jl(y)]);B||(p(U.length>0?U:[""]),C(Q))}catch{B||(p([""]),C(!1))}finally{B||g(!1)}})(),()=>{B=!0}},[y]);const P=l.useCallback((B,U)=>{p(Q=>{const q=[...Q];return q[B]=U,q})},[]),z=l.useCallback(()=>{p(B=>[...B,""])},[]),M=l.useCallback(async B=>{if(!y)return;const U=B.filter(Q=>Q.trim().length>0);await Ld(y,U)},[y]),I=l.useCallback(B=>{p(U=>{const Q=U.filter((q,R)=>R!==B);return M(Q),Q.length>0?Q:[""]})},[M]),v=l.useCallback(()=>{M(m)},[M,m]),j=l.useCallback(B=>{C(B),y&&zd(y,B)},[y]),O=l.useCallback(B=>{const U=re=>re.replace(/\\/g,"/").replace(/\/+$/,""),Q=U(B.path),q=c.filter(re=>{const Z=d(re.id);if(Z?.path&&U(Z.path)===Q)return!0;const de=re.directory;return!!(de&&U(de)===Q)}),R=new Set(q.map(re=>re.id)),Y=re=>{const Z=c.filter(le=>{const ee=le.parentID;return ee&&re.has(ee)});if(Z.length===0)return[];const de=new Set(Z.map(le=>le.id));return[...Z,...Y(de)]},F=Y(R),W=new Set,X=[...q,...F].filter(re=>W.has(re.id)?!1:(W.add(re.id),!0));xl.requestDelete({sessions:X,mode:"worktree",worktree:B})},[c,d]),T=l.useMemo(()=>c.map(B=>B.id).join(","),[c]);return l.useEffect(()=>{h&&o&&b()},[T,h,o,b]),o?h===!1?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.worktrees.state.gitOnly")}):t.jsxs("div",{className:"max-w-[44rem] space-y-5",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-normal text-foreground",children:e("settings.openchamber.worktrees.setup.title")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsxs(Dt,{sideOffset:8,className:"max-w-xs",children:[e("settings.openchamber.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",e("settings.openchamber.worktrees.setup.tooltipSuffix")]})]})]})}),f?t.jsx("p",{className:"typography-meta text-muted-foreground px-1",children:e("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:"space-y-2 px-1",children:[m.map((B,U)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(ot,{value:B,onChange:Q=>P(U,Q.target.value),onBlur:v,placeholder:e("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 w-[30rem] max-w-full font-mono text-xs"}),t.jsx("button",{type:"button",onClick:()=>{I(U)},className:"flex-shrink-0 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("settings.openchamber.worktrees.setup.removeCommandAria"),children:t.jsx(A,{name:"close",className:"h-4 w-4"})})]},U)),t.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:z,children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),e("settings.openchamber.worktrees.setup.addCommand")]}),t.jsxs("label",{"data-settings-item":"projects.worktree.setup.wait",className:"flex cursor-pointer items-center gap-2 py-1.5",children:[t.jsx(St,{checked:u,onChange:j,ariaLabel:e("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:ce("typography-ui-label font-normal",u?"text-foreground":"text-foreground/60"),children:e("settings.openchamber.worktrees.setup.waitForCommands")})]})]})]}),t.jsxs("div",{className:"space-y-2 border-t border-border/40 pt-4",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-normal text-foreground",children:e("settings.openchamber.worktrees.list.title")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:e("settings.openchamber.worktrees.list.tooltip")})]})]})}),E?t.jsx("p",{className:"typography-meta text-muted-foreground px-1",children:e("settings.openchamber.worktrees.list.loading")}):k.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70 px-1",children:e("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:"space-y-1 px-1 max-w-[32.5rem]",children:k.map(B=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("p",{className:"typography-meta text-foreground truncate min-w-0",children:B.label||B.branch||e("settings.openchamber.worktrees.list.detachedHead")}),t.jsx("span",{className:"typography-micro text-muted-foreground/60 px-1.5 py-[1px] rounded bg-sidebar-accent/40 flex-shrink-0 self-center leading-none",children:"OpenCode"})]}),t.jsx("p",{className:"typography-micro text-muted-foreground/60 truncate",children:Kd(B.path,x)})]}),t.jsx("button",{type:"button",onClick:()=>O(B),className:ce("flex-shrink-0 flex h-7 w-7 items-center justify-center rounded text-muted-foreground/50 hover:text-destructive hover:bg-destructive/10 transition-opacity focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",r?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":e("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:B.branch||B.label||B.path}),children:t.jsx(A,{name:"delete-bin",className:"h-4 w-4"})})]},B.path))})]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.worktrees.state.selectProject")})},No=(s,e)=>e.updatedAtMs-s.updatedAtMs,ms=rn((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,a]=await Promise.all([Vd(),li()]),r={};for(const i of a.sort(No))r[i.id]=i;e().listenerReady||await _d(i=>{s(o=>({statusesById:{...o.statusesById,[i.id]:i}}))}),s({instances:n.instances,statusesById:r,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await Ud();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await li(),a={};for(const r of n.sort(No))a[r.id]=r;s({statusesById:a})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await Bd({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(a){throw s({isSaving:!1,error:a instanceof Error?a.message:String(a)}),a}},upsertInstance:async n=>{const a=e().instances,r=a.some(i=>i.id===n.id)?a.map(i=>i.id===n.id?n:i):[n,...a];await e().setInstances(r)},createFromCommand:async(n,a,r)=>{const i=Hd(n,a);r&&r.trim()&&(i.nickname=r.trim()),await e().upsertInstance(i)},removeInstance:async n=>{await oi(n).catch(()=>{});const a=e().instances.filter(r=>r.id!==n);await e().setInstances(a),s(r=>{const i={...r.statusesById};return delete i[n],{statusesById:i}})},connect:async n=>{s({error:null});try{await $d(n),await e().refreshStatuses()}catch(a){throw s({error:a instanceof Error?a.message:String(a)}),a}},disconnect:async n=>{s({error:null});try{await oi(n),await e().refreshStatuses()}catch(a){throw s({error:a instanceof Error?a.message:String(a)}),a}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),$l=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],Lh=Object.fromEntries($l.map(s=>[s.key,s.Icon])),zh="openchamber:project-actions-updated",Kh=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},Lv=(s,e)=>`${Kh(s)}::${e}`,$h=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},ko=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},Bh=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=ko(e.localPort),a=ko(e.remotePort);if(!n||!a)return null;const r=$h(e.localHost||s.localForward.bindHost||"127.0.0.1"),i=(e.remoteHost||"127.0.0.1").trim(),o=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${o} - ${r}:${n} -> ${i}:${a}`,url:`http://${r}:${n}`}},Bl=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const a of n.portForwards){const r=Bh(n,a);r&&e.push(r)}return e},zv=(s,e)=>{const n=(s||"").trim();return n&&Bl(e).find(i=>i.id===n)?.url||null},Uh=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,Vh=()=>({id:Uh(),name:"",command:"",icon:"play"}),_h=({projectRef:s})=>{const{t:e}=dt(),n=l.useMemo(()=>ds(),[]),a=ms(b=>b.instances),r=ms(b=>b.load),[i,o]=l.useState([]),[d,c]=l.useState(!1),[x,m]=l.useState(!1),[p,u]=l.useState(null),[C,f]=l.useState({});l.useEffect(()=>{n&&r().catch(()=>{})},[n,r]),l.useEffect(()=>{let b=!1;return c(!0),(async()=>{try{const P=await Wd(s);if(b)return;o(P.actions),u(JSON.stringify({actions:P.actions}))}catch{if(b)return;o([]),u(JSON.stringify({actions:[]}))}finally{b||c(!1)}})(),()=>{b=!0}},[s]);const g=l.useMemo(()=>n?Bl(a):[],[a,n]),h=l.useMemo(()=>i.some(P=>P.name.trim().length===0||P.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[i,e]),D=l.useMemo(()=>p===null?!1:p!==JSON.stringify({actions:i}),[i,p]),k=l.useCallback(()=>{const b=Vh();o(P=>[...P,b]),f(P=>({...P,[b.id]:!0}))},[]),w=l.useCallback(b=>{o(P=>P.filter(z=>z.id!==b)),f(P=>{const z={...P};return delete z[b],z})},[]),E=l.useCallback((b,P)=>{o(z=>z.map(M=>M.id===b?P(M):M))},[]),N=l.useCallback(async()=>{if(h){_.error(h);return}m(!0);try{if(!await qd(s,{actions:i,primaryActionId:null})){_.error(e("settings.projects.actions.toast.saveFailed"));return}u(JSON.stringify({actions:i})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(zh,{detail:{projectId:s.id}})),_.success(e("settings.projects.actions.toast.saved"))}catch{_.error(e("settings.projects.actions.toast.saveFailed"))}finally{m(!1)}},[i,s,e,h]),y=!x&&!d&&D&&!h;return t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 flex items-start justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:e("settings.projects.actions.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.description")})]}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:k,children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]})]}),t.jsxs("section",{className:"pb-2 pt-0 space-y-2",children:[d?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):i.length===0?t.jsx("div",{className:"py-2",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")})}):t.jsx("div",{className:"space-y-0 max-w-[30rem]",children:i.map(b=>{const P=b.icon||"play",z=Lh[P]||"play",M=C[b.id]??!1,I=b.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(pn,{open:M,onOpenChange:v=>{f(j=>({...j,[b.id]:v}))},className:ce("py-1.5"),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(gn,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[M?t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(A,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(A,{name:z,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:I})})})]}),t.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>w(b.id),children:t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(hn,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-6 pl-3 pr-3",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs(gs,{children:[t.jsx(us,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(A,{name:z,className:"h-4 w-4"})})}),t.jsx(ps,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:$l.map(v=>{const j=v.Icon,O=(b.icon||"play")===v.key;return t.jsx("button",{type:"button",onClick:()=>E(b.id,T=>({...T,icon:v.key})),className:ce("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",O&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:v.label}),children:t.jsx(A,{name:j,className:"h-4 w-4"})},v.key)})})})]}),t.jsx(ot,{value:b.name,onChange:v=>E(b.id,j=>({...j,name:v.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 max-w-[14rem]"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(hs,{value:b.command,onChange:v=>E(b.id,j=>({...j,command:v.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] max-w-[30rem] font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":b.autoOpenUrl===!0,onClick:()=>E(b.id,v=>({...v,...v.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:v=>{(v.key===" "||v.key==="Enter")&&(v.preventDefault(),E(b.id,j=>({...j,...j.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(St,{checked:b.autoOpenUrl===!0,onChange:v=>E(b.id,j=>({...j,...v?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:I})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),b.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ot,{value:b.openUrl||"",onChange:v=>E(b.id,j=>({...j,openUrl:v.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),g.length>0?t.jsxs(Mt,{value:b.desktopOpenSshForward&&g.some(v=>v.id===b.desktopOpenSshForward)?b.desktopOpenSshForward:"__none__",onValueChange:v=>{E(b.id,j=>({...j,...v==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:v}}))},children:[t.jsx(Rt,{className:"h-7 w-full max-w-[30rem]",children:t.jsx(Kt,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),g.map(v=>t.jsx(gt,{value:v.id,children:v.label},v.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},b.id)})}),t.jsxs("div",{className:"pt-3",children:[h?t.jsx("p",{className:"typography-meta mb-2 text-[var(--status-warning)]",children:h}):null,t.jsx(J,{type:"button",size:"xs",className:"!font-normal",onClick:N,disabled:!y,children:e(x?"settings.common.actions.saving":"settings.projects.actions.actions.save")})]})]})]})},Hh=()=>{const s=rt.c(197),{t:e}=dt(),n=is(Wh),a=is(qh),r=is(Gh),i=is(Jh),o=is(Qh),d=Ke(Yh),c=Ke(Xh),{currentTheme:x}=Ua();let m;e:{if(!d){m=null;break e}let lt;s[0]!==n||s[1]!==d?(lt=n.find(Et=>Et.id===d)??null,s[0]=n,s[1]=d,s[2]=lt):lt=s[2],m=lt}const p=m;let u,C;s[3]!==n||s[4]!==d||s[5]!==c?(u=()=>{if(n.length===0){c(null);return}d&&n.some(lt=>lt.id===d)||c(n[0].id)},C=[n,d,c],s[3]=n,s[4]=d,s[5]=c,s[6]=u,s[7]=C):(u=s[6],C=s[7]),l.useEffect(u,C);const[f,g]=l.useState(""),[h,D]=l.useState(null),[k,w]=l.useState(null),[E,N]=l.useState(null),[y,b]=l.useState(!1),[P,z]=l.useState(!1),[M,I]=l.useState(!1),[v,j]=l.useState(!1),[O,T]=l.useState(null),[B,U]=l.useState(null),[Q,q]=l.useState(!1),R=l.useRef(null);let Y;s[8]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{T(null),U(Zh)},s[8]=Y):Y=s[8];const F=Y;let W;e:{if(!p){W=null;break e}let lt;s[9]!==p.id||s[10]!==p.path?(lt={id:p.id,path:p.path},s[9]=p.id,s[10]=p.path,s[11]=lt):lt=s[11],W=lt}const X=W;let re,Z;s[12]!==p?(re=()=>{if(!p){g(""),D(null),w(null),N(null);return}g(p.label??""),D(p.icon??null),w(p.color??null),N(p.iconBackground??null),j(!1),F(),q(!1)},Z=[p,F],s[12]=p,s[13]=re,s[14]=Z):(re=s[13],Z=s[14]),l.useEffect(re,Z);let de,le;s[15]===Symbol.for("react.memo_cache_sentinel")?(de=()=>()=>{F()},le=[F],s[15]=de,s[16]=le):(de=s[15],le=s[16]),l.useEffect(de,le);let ee;s[17]!==k||s[18]!==h||s[19]!==E||s[20]!==f||s[21]!==v||s[22]!==O||s[23]!==p?(ee=!!p&&(f.trim()!==(p?.label??"").trim()||h!==(p?.icon??null)||k!==(p?.color??null)||E!==(p?.iconBackground??null)||v||!!O),s[17]=k,s[18]=h,s[19]=E,s[20]=f,s[21]=v,s[22]=O,s[23]=p,s[24]=ee):ee=s[24];const xe=ee;let we;s[25]!==k||s[26]!==h||s[27]!==E||s[28]!==f||s[29]!==v||s[30]!==O||s[31]!==i||s[32]!==p||s[33]!==e||s[34]!==a||s[35]!==r?(we=async()=>{if(!p)return;if(O){b(!0);const Et=await r(p.id,O);if(b(!1),!Et.ok){_.error(Et.error||e("settings.projects.page.toast.uploadIconFailed"));return}_.success(e("settings.projects.page.toast.iconUpdated")),F(),j(!1)}const lt=v&&!!p.iconImage;if(lt){z(!0);const Et=await i(p.id);if(z(!1),!Et.ok){_.error(Et.error||e("settings.projects.page.toast.removeIconFailed"));return}_.success(e("settings.projects.page.toast.iconRemoved")),j(!1),N(null)}a(p.id,{label:f.trim(),icon:h,color:k,iconBackground:lt?null:E})},s[25]=k,s[26]=h,s[27]=E,s[28]=f,s[29]=v,s[30]=O,s[31]=i,s[32]=p,s[33]=e,s[34]=a,s[35]=r,s[36]=we):we=s[36];const he=we,Ie=k?bl[k]??null:null,be=!!p?.iconImage,je=!!(O&&B),ye=p?.iconImage?.source==="custom",se=be&&!v||je,ie=se,V=!Q&&(je||!!(p&&be&&!v));let te;s[37]!==y||s[38]!==p?(te=lt=>{!p||!lt||y||(j(!1),q(!1),T(lt),U(Et=>(Et&&URL.revokeObjectURL(Et),URL.createObjectURL(lt))))},s[37]=y,s[38]=p,s[39]=te):te=s[39];const ne=te;let ue;s[40]!==je||s[41]!==ie||s[42]!==be||s[43]!==P||s[44]!==p?(ue=()=>{!p||!ie||P||(je&&F(),j(!!be),q(!1))},s[40]=je,s[41]=ie,s[42]=be,s[43]=P,s[44]=p,s[45]=ue):ue=s[45];const Me=ue;let ke;s[46]!==o||s[47]!==M||s[48]!==p||s[49]!==e?(ke=async()=>{!p||M||(F(),j(!1),q(!1),I(!0),o(p.id).then(lt=>{if(!lt.ok){_.error(lt.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(lt.skipped){_.success(e("settings.projects.page.toast.customIconAlreadySet"));return}_.success(e("settings.projects.page.toast.iconDiscovered"))}).finally(()=>{I(!1)}))},s[46]=o,s[47]=M,s[48]=p,s[49]=e,s[50]=ke):ke=s[50];const Re=ke;if(!p){let lt;s[51]!==e?(lt=e("settings.projects.page.empty.noProjects"),s[51]=e,s[52]=lt):lt=s[52];let Et;return s[53]!==lt?(Et=t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsx("div",{className:"mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:lt})})}),s[53]=lt,s[54]=Et):Et=s[54],Et}let Ae;s[55]!==p.label||s[56]!==e?(Ae=p.label??e("settings.projects.page.title.default"),s[55]=p.label,s[56]=e,s[57]=Ae):Ae=s[57];let Pe;s[58]!==Ae?(Pe=t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:Ae}),s[58]=Ae,s[59]=Pe):Pe=s[59];let Te;s[60]!==p.path?(Te=t.jsx("p",{className:"typography-meta text-muted-foreground truncate",title:p.path,children:p.path}),s[60]=p.path,s[61]=Te):Te=s[61];let Fe;s[62]!==Pe||s[63]!==Te?(Fe=t.jsx("div",{className:"mb-4 flex items-center justify-between gap-4",children:t.jsxs("div",{className:"min-w-0",children:[Pe,Te]})}),s[62]=Pe,s[63]=Te,s[64]=Fe):Fe=s[64];let Be;s[65]!==e?(Be=e("settings.projects.page.field.projectName"),s[65]=e,s[66]=Be):Be=s[66];let We;s[67]!==Be?(We=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:Be})}),s[67]=Be,s[68]=We):We=s[68];let ze;s[69]===Symbol.for("react.memo_cache_sentinel")?(ze=lt=>g(lt.target.value),s[69]=ze):ze=s[69];let Qe;s[70]!==e?(Qe=e("settings.projects.page.field.projectNamePlaceholder"),s[70]=e,s[71]=Qe):Qe=s[71];let oe;s[72]!==f||s[73]!==Qe?(oe=t.jsx("div",{className:"mt-1.5 flex min-w-0 items-center gap-2",children:t.jsx(ot,{value:f,onChange:ze,placeholder:Qe,className:"h-7 min-w-0 w-full sm:max-w-[19rem]"})}),s[72]=f,s[73]=Qe,s[74]=oe):oe=s[74];let H;s[75]!==We||s[76]!==oe?(H=t.jsxs("div",{"data-settings-item":"projects.name",className:"py-1.5",children:[We,oe]}),s[75]=We,s[76]=oe,s[77]=H):H=s[77];let me;s[78]!==e?(me=e("settings.projects.page.field.accentColor"),s[78]=e,s[79]=me):me=s[79];let Ne;s[80]!==me?(Ne=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:me})}),s[80]=me,s[81]=Ne):Ne=s[81];let Ee;s[82]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>w(null),s[82]=Ee):Ee=s[82];const Ce=k===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let _e;s[83]!==Ce?(_e=ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ce),s[83]=Ce,s[84]=_e):_e=s[84];let G;s[85]!==e?(G=e("settings.projects.page.field.none"),s[85]=e,s[86]=G):G=s[86];let $;s[87]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(A,{name:"close",className:"h-4 w-4 text-muted-foreground"}),s[87]=$):$=s[87];let fe;s[88]!==_e||s[89]!==G?(fe=t.jsx("button",{type:"button",onClick:Ee,className:_e,title:G,children:$}),s[88]=_e,s[89]=G,s[90]=fe):fe=s[90];let L;s[91]!==k?(L=Gd.map(lt=>t.jsx("button",{type:"button",onClick:()=>w(lt.key),className:ce("h-7 w-7 rounded-md border transition-colors",k===lt.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:lt.cssVar},title:lt.label},lt.key)),s[91]=k,s[92]=L):L=s[92];let Le;s[93]!==fe||s[94]!==L?(Le=t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[fe,L]}),s[93]=fe,s[94]=L,s[95]=Le):Le=s[95];let Je;s[96]!==Ne||s[97]!==Le?(Je=t.jsxs("div",{"data-settings-item":"projects.accent-color",className:"py-1.5",children:[Ne,Le]}),s[96]=Ne,s[97]=Le,s[98]=Je):Je=s[98];let Xe;s[99]!==e?(Xe=e("settings.projects.page.field.projectIcon"),s[99]=e,s[100]=Xe):Xe=s[100];let et;s[101]!==Xe?(et=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:Xe})}),s[101]=Xe,s[102]=et):et=s[102];let at;s[103]!==ne?(at=t.jsx("input",{ref:R,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:lt=>{const Et=lt.target.files?.[0]??null;ne(Et),lt.currentTarget.value=""}}),s[103]=ne,s[104]=at):at=s[104];let ct;s[105]===Symbol.for("react.memo_cache_sentinel")?(ct=()=>D(null),s[105]=ct):ct=s[105];const Ze=h===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let He;s[106]!==Ze?(He=ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ze),s[106]=Ze,s[107]=He):He=s[107];let mt;s[108]!==e?(mt=e("settings.projects.page.field.none"),s[108]=e,s[109]=mt):mt=s[109];let pe;s[110]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(A,{name:"close",className:"h-4 w-4 text-muted-foreground"}),s[110]=pe):pe=s[110];let nt;s[111]!==He||s[112]!==mt?(nt=t.jsx("button",{type:"button",onClick:ct,className:He,title:mt,children:pe}),s[111]=He,s[112]=mt,s[113]=nt):nt=s[113];let st;s[114]!==Ie||s[115]!==h?(st=Jd.map(lt=>{const Et=lt.Icon;return t.jsx("button",{type:"button",onClick:()=>D(lt.key),className:ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",h===lt.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:lt.label,children:t.jsx(A,{name:Et,className:"w-4 h-4",style:Ie&&h===lt.key?{color:Ie}:void 0})},lt.key)}),s[114]=Ie,s[115]=h,s[116]=st):st=s[116];let Ge;s[117]!==nt||s[118]!==st?(Ge=t.jsxs("div",{className:"mt-1.5 flex max-w-[22rem] flex-wrap items-center gap-2",children:[nt,st]}),s[117]=nt,s[118]=st,s[119]=Ge):Ge=s[119];let ht;s[120]!==x||s[121]!==se||s[122]!==je||s[123]!==E||s[124]!==B||s[125]!==p||s[126]!==V||s[127]!==e?(ht=se&&V&&t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:E?{backgroundColor:E}:void 0,children:je&&B?t.jsx("img",{src:B,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>q(!0)}):p?t.jsx(yl,{project:p,options:{themeVariant:x.metadata.variant,iconColor:x.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>q(!0)}):null})})]}),s[120]=x,s[121]=se,s[122]=je,s[123]=E,s[124]=B,s[125]=p,s[126]=V,s[127]=e,s[128]=ht):ht=s[128];let wt;s[129]!==se||s[130]!==E||s[131]!==e?(wt=se&&t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:E??"#000000",onChange:lt=>N(lt.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":e("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(ot,{value:E??"",onChange:lt=>N(lt.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(J,{type:"button",size:"xs",variant:"outline",onClick:()=>N(null),className:"h-7 w-7 p-0","aria-label":e("settings.projects.page.field.clearIconBackgroundAria"),title:e("settings.projects.page.field.clearBackground"),disabled:!E,children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]}),s[129]=se,s[130]=E,s[131]=e,s[132]=wt):wt=s[132];let Nt;s[133]!==Re||s[134]!==ye||s[135]!==M||s[136]!==y||s[137]!==e?(Nt=!ye&&t.jsxs(t.Fragment,{children:[t.jsx(J,{size:"xs",className:"h-6 !font-normal",onClick:()=>R.current?.click(),disabled:y,children:e(y?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(J,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{Re()},disabled:M,children:e(M?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),s[133]=Re,s[134]=ye,s[135]=M,s[136]=y,s[137]=e,s[138]=Nt):Nt=s[138];let ae;s[139]!==Me||s[140]!==ie||s[141]!==P||s[142]!==e?(ae=ie&&t.jsx(J,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{Me()},disabled:P,children:e(P?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),s[139]=Me,s[140]=ie,s[141]=P,s[142]=e,s[143]=ae):ae=s[143];let Ue;s[144]!==P||s[145]!==v||s[146]!==e?(Ue=v&&t.jsx(J,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>j(!1),disabled:P,children:e("settings.projects.page.actions.undoRemove")}),s[144]=P,s[145]=v,s[146]=e,s[147]=Ue):Ue=s[147];let tt;s[148]!==Nt||s[149]!==ae||s[150]!==Ue?(tt=t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[Nt,ae,Ue]}),s[148]=Nt,s[149]=ae,s[150]=Ue,s[151]=tt):tt=s[151];let Ye;s[152]!==et||s[153]!==at||s[154]!==Ge||s[155]!==ht||s[156]!==wt||s[157]!==tt?(Ye=t.jsxs("div",{"data-settings-item":"projects.icon",className:"py-1.5",children:[et,at,Ge,ht,wt,tt]}),s[152]=et,s[153]=at,s[154]=Ge,s[155]=ht,s[156]=wt,s[157]=tt,s[158]=Ye):Ye=s[158];let ft;s[159]!==H||s[160]!==Je||s[161]!==Ye?(ft=t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[H,Je,Ye]}),s[159]=H,s[160]=Je,s[161]=Ye,s[162]=ft):ft=s[162];let $e;s[163]!==xe||s[164]!==P||s[165]!==y||s[166]!==f?($e=!xe||f.trim().length===0||y||P,s[163]=xe,s[164]=P,s[165]=y,s[166]=f,s[167]=$e):$e=s[167];let Ve;s[168]!==e?(Ve=e("settings.common.actions.saveChanges"),s[168]=e,s[169]=Ve):Ve=s[169];let it;s[170]!==he||s[171]!==$e||s[172]!==Ve?(it=t.jsx("div",{className:"mt-0.5 px-2 py-1",children:t.jsx(J,{onClick:he,disabled:$e,size:"xs",className:"!font-normal",children:Ve})}),s[170]=he,s[171]=$e,s[172]=Ve,s[173]=it):it=s[173];let xt;s[174]!==ft||s[175]!==it?(xt=t.jsxs("div",{className:"mb-8",children:[ft,it]}),s[174]=ft,s[175]=it,s[176]=xt):xt=s[176];let At;s[177]!==X?(At=X&&t.jsx(_h,{projectRef:X}),s[177]=X,s[178]=At):At=s[178];let Zt;s[179]!==At?(Zt=t.jsx("div",{"data-settings-item":"projects.worktree",className:"mb-8",children:t.jsx("section",{className:"px-2 pb-2 pt-0",children:At})}),s[179]=At,s[180]=Zt):Zt=s[180];let ts;s[181]!==e?(ts=e("settings.projects.page.section.worktree"),s[181]=e,s[182]=ts):ts=s[182];let ss;s[183]!==ts?(ss=t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:ts})}),s[183]=ts,s[184]=ss):ss=s[184];let Vt;s[185]!==X?(Vt=X&&t.jsx(Oh,{projectRef:X}),s[185]=X,s[186]=Vt):Vt=s[186];let Se;s[187]!==Vt?(Se=t.jsx("section",{className:"px-2 pb-2 pt-0",children:Vt}),s[187]=Vt,s[188]=Se):Se=s[188];let vt;s[189]!==ss||s[190]!==Se?(vt=t.jsxs("div",{className:"mb-8",children:[ss,Se]}),s[189]=ss,s[190]=Se,s[191]=vt):vt=s[191];let jt;return s[192]!==Fe||s[193]!==xt||s[194]!==Zt||s[195]!==vt?(jt=t.jsx(Gt,{outerClassName:"h-full",className:"w-full bg-background",children:t.jsxs("div",{className:"mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8",children:[Fe,xt,Zt,vt]})}),s[192]=Fe,s[193]=xt,s[194]=Zt,s[195]=vt,s[196]=jt):jt=s[196],jt};function Wh(s){return s.projects}function qh(s){return s.updateProjectMeta}function Gh(s){return s.uploadProjectIcon}function Jh(s){return s.removeProjectIcon}function Qh(s){return s.discoverProjectIcon}function Yh(s){return s.settingsProjectsSelectedId}function Xh(s){return s.setSettingsProjectsSelectedId}function Zh(s){return s&&URL.revokeObjectURL(s),null}const Ul=s=>({v:1,serverUrl:s.serverUrl.trim().replace(/\/+$/,""),token:s.token.trim(),...s.label?.trim()?{label:s.label.trim()}:{}}),ef=s=>{const e=new URLSearchParams;return e.set("v",String(s.v)),e.set("server",s.serverUrl),e.set("token",s.token),s.label&&e.set("label",s.label),`openchamber://connect?${e.toString()}`},tf=s=>{const e=s.trim();if(!e)return null;try{const n=new URL(e);if(n.protocol!=="openchamber:"||n.hostname!=="connect")return null;const a=n.searchParams.get("v"),r=n.searchParams.get("server")?.trim()||"",i=n.searchParams.get("token")?.trim()||"",o=n.searchParams.get("label")?.trim()||"";if(a!=="1"||!r||!i)return null;try{const d=new URL(r);if(d.protocol!=="http:"&&d.protocol!=="https:")return null}catch{return null}return Ul({serverUrl:r,token:i,label:o})}catch{return null}},Fr=()=>Math.floor(2e4+Math.random()*3e4),sf=s=>{const e=(s instanceof Error?s.message:String(s)).toLowerCase();return e.includes("address already in use")||e.includes("eaddrinuse")||e.includes("port already in use")},So=s=>{switch(s){case"config_resolved":return"settings.remoteInstances.page.phase.resolvingConfiguration";case"auth_check":return"settings.remoteInstances.page.phase.checkingAuth";case"master_connecting":return"settings.remoteInstances.page.phase.establishingSsh";case"remote_probe":return"settings.remoteInstances.page.phase.probingRemote";case"installing":return"settings.remoteInstances.page.phase.installingOpenChamber";case"updating":return"settings.remoteInstances.page.phase.updatingOpenChamber";case"server_detecting":return"settings.remoteInstances.page.phase.detectingServer";case"server_starting":return"settings.remoteInstances.page.phase.startingServer";case"forwarding":return"settings.remoteInstances.page.phase.forwardingPorts";case"ready":return"settings.remoteInstances.sidebar.phase.ready";case"degraded":return"settings.remoteInstances.page.phase.reconnecting";case"error":return"settings.remoteInstances.sidebar.phase.error";default:return"settings.remoteInstances.sidebar.phase.idle"}},nf=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),Vl=s=>!!(s&&nf.has(s)),Co=s=>s==="ready"?"bg-[var(--status-success)] animate-pulse":s==="error"?"bg-[var(--status-error)] animate-pulse":s==="degraded"||Vl(s)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",af=s=>s.type==="dynamic"?`${s.localHost||"127.0.0.1"}:${s.localPort||0}`:s.type==="remote"?`${s.remoteHost||"127.0.0.1"}:${s.remotePort||0} -> ${s.localHost||"127.0.0.1"}:${s.localPort||0}`:`${s.localHost||"127.0.0.1"}:${s.localPort||0} -> ${s.remoteHost||"127.0.0.1"}:${s.remotePort||0}`,rf=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:Fr(),remoteHost:"127.0.0.1",remotePort:80}),of=s=>s.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",$s=s=>{const e=rt.c(8),{label:n,hint:a}=s;let r;e[0]!==n?(r=t.jsx("span",{children:n}),e[0]=n,e[1]=r):r=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),e[2]=i):i=e[2];let o;e[3]!==a?(o=t.jsxs(Pt,{children:[i,t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:t.jsx("div",{className:"typography-meta text-foreground",children:a})})]}),e[3]=a,e[4]=o):o=e[4];let d;return e[5]!==r||e[6]!==o?(d=t.jsxs("span",{className:"inline-flex items-center gap-1 typography-meta text-muted-foreground",children:[r,o]}),e[5]=r,e[6]=o,e[7]=d):d=e[7],d},lf=s=>{switch(s){case"remote":return"settings.remoteInstances.page.forwardTypeDescription.remote";case"dynamic":return"settings.remoteInstances.page.forwardTypeDescription.dynamic";default:return"settings.remoteInstances.page.forwardTypeDescription.local"}},Po=(s,e)=>{const n=(s||"").trim();return`${!n||n==="127.0.0.1"||n==="::1"?"localhost":n}:${e||0}`},cf=s=>{const e=(s||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},df=s=>{const e=s.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!e)return s;const n=Number(e[1]),a=Number.isFinite(n)?new Date(n).toISOString():e[1],r=(e[2]||"INFO").toUpperCase(),i=e[3]||"";return`[${a}] [${r}] ${i}`},cr=s=>{const e=s.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},mf=s=>{const e=s.sshCommand.trim(),n=s.nickname?.trim(),a=s.portForwards.map(r=>({...r,localHost:r.localHost?.trim()||"127.0.0.1",localPort:typeof r.localPort=="number"?Math.max(1,Math.min(65535,Math.round(r.localPort))):void 0,remoteHost:r.remoteHost?.trim(),remotePort:typeof r.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(r.remotePort))):void 0}));return{...s,sshCommand:e,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(s.connectionTimeoutSec||60))),localForward:{...s.localForward,bindHost:s.localForward.bindHost==="localhost"||s.localForward.bindHost==="0.0.0.0"?s.localForward.bindHost:"127.0.0.1",preferredLocalPort:typeof s.localForward.preferredLocalPort=="number"?Math.max(1,Math.min(65535,Math.round(s.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...s.remoteOpenchamber,preferredPort:typeof s.remoteOpenchamber.preferredPort=="number"?Math.max(1,Math.min(65535,Math.round(s.remoteOpenchamber.preferredPort))):void 0},portForwards:a}},uf=()=>{const{t:s}=dt(),{clientAuth:e}=Wr(),n=ds(),a=ms(K=>K.instances),r=ms(K=>K.statusesById),i=ms(K=>K.importCandidates),o=ms(K=>K.isLoading),d=ms(K=>K.isImportsLoading),c=ms(K=>K.isSaving),x=ms(K=>K.error),m=ms(K=>K.load),p=ms(K=>K.loadImports),u=ms(K=>K.refreshStatuses),C=ms(K=>K.upsertInstance),f=ms(K=>K.createFromCommand),g=ms(K=>K.removeInstance),h=ms(K=>K.connect),D=ms(K=>K.disconnect),k=ms(K=>K.retry),w=Ke(K=>K.settingsRemoteInstancesSelectedId),E=Ke(K=>K.setSettingsRemoteInstancesSelectedId),N=l.useMemo(()=>w&&a.find(K=>K.id===w)||null,[a,w]),[y,b]=l.useState(null),[P,z]=l.useState(!1),[M,I]=l.useState(!1),[v,j]=l.useState(null),[O,T]=l.useState([]),[B,U]=l.useState(null),[Q,q]=l.useState(""),[R,Y]=l.useState(!1),[F,W]=l.useState({}),[X,re]=l.useState(!1),[Z,de]=l.useState(!1),[le,ee]=l.useState(()=>Date.now()),[xe,we]=l.useState([]),[he,Ie]=l.useState("local"),[be,je]=l.useState(!1),[ye,se]=l.useState(!1),[ie,ge]=l.useState(""),[V,te]=l.useState(""),[ne,ue]=l.useState(""),[Me,ke]=l.useState(""),[Re,Ae]=l.useState(null),[Pe,Te]=l.useState(!1),[Fe,Be]=l.useState(!1),[We,ze]=l.useState(null),[Qe,oe]=l.useState(""),[H,me]=l.useState(""),[Ne,Ee]=l.useState(""),[Ce,_e]=l.useState([]),[G,$]=l.useState(!1),[fe,L]=l.useState(""),[Le,Je]=l.useState(null),[Xe,et]=l.useState(null),[at,ct]=l.useState(null),[Ze,He]=l.useState(null),mt=l.useMemo(()=>Ce.filter(K=>!!K.revokedAt).length,[Ce]),[pe,nt]=l.useState(!1),[st,Ge]=l.useState("ssh user@example.com"),[ht,wt]=l.useState("");l.useEffect(()=>{m(),p()},[m,p]);const Nt=l.useCallback(async()=>{je(!0),Ae(null);try{const K=await ci();we(K.hosts||[]),Ie(K.defaultHostId||"local")}catch(K){Ae(K instanceof Error?K.message:String(K))}finally{je(!1)}},[]);l.useEffect(()=>{Nt()},[Nt]);const ae=l.useCallback(async(K,qe=he)=>{se(!0),Ae(null);try{await di({hosts:K,defaultHostId:qe,initialHostChoiceCompleted:!0}),we(K),Ie(qe)}catch(kt){Ae(kt instanceof Error?kt.message:String(kt))}finally{se(!1)}},[he]),Ue=l.useCallback(async()=>{const K=mi(V);if(!K){Ae(s("desktopHostSwitcher.error.invalidUrl"));return}const qe=K.persistedUrl,Ot={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:ie.trim()||$n(qe),url:qe,apiUrl:qe,...ne.trim()?{clientToken:ne.trim()}:{}};await ae([Ot,...xe],he),ge(""),te(""),ue(""),Te(!1),K.redeemUrl&&cr(K.redeemUrl)},[he,xe,ie,ne,V,ae,s]),tt=l.useCallback(async()=>{const K=tf(Me);if(!K){Ae(s("settings.remoteInstances.direct.error.invalidConnectLink"));return}const qe=qa(K.serverUrl);if(!qe){Ae(s("desktopHostSwitcher.error.invalidUrl"));return}const kt=xe.find(Ot=>qa(Ot.apiUrl||Ot.url)===qe);if(kt){const Ot=xe.map(rs=>rs.id===kt.id?{...rs,label:K.label||rs.label,url:qe,apiUrl:qe,clientToken:K.token}:rs);await ae(Ot,he)}else{const Ot=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`;await ae([{id:Ot,label:K.label||$n(qe),url:qe,apiUrl:qe,clientToken:K.token},...xe],he)}ke(""),Ae(null),Be(!1)},[Me,he,xe,ae,s]),Ye=l.useCallback(async K=>{const qe=xe.filter(Ot=>Ot.id!==K);await ae(qe,he===K?"local":he),We===K&&ze(null)},[he,We,xe,ae]),ft=l.useCallback(K=>{ze(K.id),oe(K.label),me(K.apiUrl||K.url),Ee(K.clientToken||""),Ae(null)},[]),$e=l.useCallback(async()=>{if(!We)return;const K=mi(H);if(!K){Ae(s("desktopHostSwitcher.error.invalidUrl"));return}const qe=K.persistedUrl,kt=xe.map(Ot=>Ot.id===We?{...Ot,label:Qe.trim()||$n(qe),url:qe,apiUrl:qe,clientToken:Ne.trim()||void 0}:Ot);await ae(kt,he),ze(null),K.redeemUrl&&cr(K.redeemUrl)},[he,Qe,Ne,H,We,xe,ae,s]),Ve=l.useCallback(async()=>{const K=st.trim();if(!K){_.error(s("settings.remoteInstances.page.toast.sshCommandRequired"));return}const qe=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await f(qe,K,ht.trim()||s("settings.remoteInstances.sidebar.newSshInstanceName")),E(qe),nt(!1),Ge("ssh user@example.com"),wt(""),_.success(s("settings.remoteInstances.page.toast.instanceCreated"))}catch(kt){_.error(s("settings.remoteInstances.sidebar.toast.createFailed"),{description:kt instanceof Error?kt.message:String(kt)})}},[f,E,st,ht,s]),it=l.useCallback(async K=>{await ae(xe,K)},[xe,ae]),xt=l.useCallback(async()=>{if(e){$(!0),et(null);try{_e(await e.listClients())}catch(K){et(K instanceof Error?K.message:String(K))}finally{$(!1)}}},[e]);l.useEffect(()=>{xt()},[xt]);const At=l.useCallback(async()=>{if(e){et(null);try{const K=await e.createClient({label:fe.trim()||void 0});Je(K.token),L(""),await xt()}catch(K){et(K instanceof Error?K.message:String(K))}}},[e,xt,fe]),Zt=l.useCallback(async()=>{if(e){et(null);try{const K=qa(ea())||window.location.origin,qe=await e.createClient({label:fe.trim()||"Paired client"}),kt=Ul({serverUrl:K,token:qe.token,label:fe||"OpenChamber"}),Ot=ef(kt);Je(qe.token),ct(Ot),He(await pl.toDataURL(Ot,{width:192,margin:1})),L(""),await xt()}catch(K){et(K instanceof Error?K.message:String(K))}}},[e,xt,fe]),ts=l.useCallback(async K=>{if(!e)return;const qe=K.clientKind==="desktop-local";et(null);try{if(await e.revokeClient(K.id),qe&&ds()){const kt=await ci();await di({hosts:kt.hosts,defaultHostId:kt.defaultHostId,initialHostChoiceCompleted:kt.initialHostChoiceCompleted,localClientToken:null}),_e(Ot=>Ot.map(rs=>rs.id===K.id?{...rs,revokedAt:new Date().toISOString()}:rs)),$m({apiBaseUrl:ea(),clientToken:null,runtimeKey:"local"});return}await xt()}catch(kt){et(kt instanceof Error?kt.message:String(kt))}},[e,xt]),ss=l.useCallback(async()=>{if(e){et(null);try{await e.purgeRevokedClients(),await xt()}catch(K){et(K instanceof Error?K.message:String(K))}}},[e,xt]);l.useEffect(()=>{b(N)},[N]),l.useEffect(()=>{if(!w)return;const K=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||u()},2e3);return()=>{window.clearInterval(K)}},[u,w]),l.useEffect(()=>{let K=null,qe=Date.now();const kt=()=>{const rs=Date.now();rs-qe>=1e3&&(ee(rs),qe=rs),K=requestAnimationFrame(kt)};(typeof document>"u"||document.visibilityState==="visible")&&(K=requestAnimationFrame(kt));const Ot=()=>{document.visibilityState==="visible"&&K===null?K=requestAnimationFrame(kt):document.visibilityState!=="visible"&&K!==null&&(cancelAnimationFrame(K),K=null)};return document.addEventListener("visibilitychange",Ot),()=>{document.removeEventListener("visibilitychange",Ot),K!==null&&cancelAnimationFrame(K)}},[]);const Vt=w?r[w]:null,Se=Vt?.phase,vt=Se==="ready",jt=Se==="degraded",lt=Vl(Se),qt=vt||(lt||jt),os=Vt?Math.max(0,le-Vt.updatedAtMs):0,as=jt&&os>12e3,Es=l.useMemo(()=>!y||!N?!1:JSON.stringify(y)!==JSON.stringify(N),[y,N]),Jt=l.useCallback(K=>{b(qe=>qe&&K(qe))},[]),Ds=l.useCallback(async()=>{if(!y)return;const K=mf(y);if(!K.sshCommand.trim()){_.error(s("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(!(K.localForward.bindHost==="0.0.0.0"&&!window.confirm(s("settings.remoteInstances.page.confirm.bindAllInterfaces")))){if(K.auth.sshPassword?.enabled&&K.auth.sshPassword.value?.trim()&&K.auth.sshPassword.store!=="settings"){const qe=window.confirm(s("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext"));K.auth.sshPassword.store=qe?"settings":"never",qe||(K.auth.sshPassword.value=void 0)}if(K.auth.openchamberPassword?.enabled&&K.auth.openchamberPassword.value?.trim()&&K.auth.openchamberPassword.store!=="settings"){const qe=window.confirm(s("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext"));K.auth.openchamberPassword.store=qe?"settings":"never",qe||(K.auth.openchamberPassword.value=void 0)}try{await C(K),_.success(s("settings.remoteInstances.page.toast.instanceSaved"))}catch(qe){_.error(s("settings.remoteInstances.page.toast.saveFailed"),{description:qe instanceof Error?qe.message:String(qe)})}}},[y,s,C]),Ns=l.useCallback(async(K,qe)=>{const kt=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await f(kt,`ssh ${qe}`,K),E(kt),_.success(s("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(Ot){return _.error(s("settings.remoteInstances.sidebar.toast.createFailed"),{description:Ot instanceof Error?Ot.message:String(Ot)}),!1}},[f,E,s]),De=l.useCallback(()=>{R||(U(null),q(""))},[R]),pt=l.useCallback((K,qe)=>{if(qe){U(K),q(of(K));return}Ns(K,K)},[Ns]),Ft=l.useCallback(async()=>{const K=B,qe=Q.trim();if(K){if(!qe){_.error(s("settings.remoteInstances.page.toast.destinationRequired"));return}Y(!0);try{await Ns(K,qe)&&(U(null),q(""))}finally{Y(!1)}}},[Ns,Q,B,s]),Xt=l.useCallback(async()=>{if(N)try{await h(N.id);return}catch(K){if(!sf(K)||!window.confirm(s("settings.remoteInstances.sidebar.confirm.localPortInUseRetry")))throw K;const kt={...N,localForward:{...N.localForward,preferredLocalPort:Fr()}};await C(kt),await h(kt.id),_.success(s("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[h,N,s,C]),Qt=l.useCallback(async K=>(await Qd(K,600)).map(kt=>df(kt)),[]),Fn=l.useCallback(async()=>{if(y){z(!0),I(!0),j(null);try{const K=await Qt(y.id);T(K)}catch(K){T([]),j(K instanceof Error?K.message:String(K))}finally{I(!1)}}},[y,Qt]);l.useEffect(()=>{if(!P||!y)return;let K=!1;const qe=async()=>{try{const Ot=await Qt(y.id);K||(T(Ot),j(null))}catch(Ot){K||j(Ot instanceof Error?Ot.message:String(Ot))}};qe();const kt=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||qe()},1e3);return()=>{K=!0,window.clearInterval(kt)}},[y,P,Qt]);const Ks=l.useMemo(()=>O.join(`
|
|
28
|
+
`),[O]),On=l.useCallback(()=>{if(!Ks.trim()){_.error(s("settings.remoteInstances.page.toast.noLogsToCopy"));return}mn(Ks).then(K=>{K.ok&&_.success(s("settings.remoteInstances.page.toast.logsCopied"))})},[Ks,s]),_a=l.useCallback(async()=>{if(y)try{await Yd(y.id),T([]),_.success(s("settings.remoteInstances.page.toast.logsCleared"))}catch(K){_.error(s("settings.remoteInstances.page.toast.clearLogsFailed"),{description:K instanceof Error?K.message:String(K)})}},[y,s]),Gs=l.useCallback(async()=>{if(!Vt?.localUrl){_.error(s("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}const K=Vt.localUrl.trim();if(!K){_.error(s("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}cr(K)},[Vt?.localUrl,s]),Js=l.useCallback(()=>{if(!y)return;re(!0),(qt?D(y.id):Xt()).catch(qe=>{const kt=qt?vt?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";_.error(s(kt),{description:qe instanceof Error?qe.message:String(qe)})}).finally(()=>{re(!1)})},[qt,Xt,D,y,vt,s]),Qs=l.useCallback(()=>{if(!y||lt)return;de(!0),(jt?D(y.id).then(()=>Xt()):k(y.id)).catch(qe=>{_.error(s("settings.remoteInstances.page.toast.retryFailed"),{description:qe instanceof Error?qe.message:String(qe)})}).finally(()=>{de(!1)})},[Xt,D,y,lt,jt,k,s]),Ln=s(lt?"settings.remoteInstances.page.actions.connecting":jt?as?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),Ha=!X&&!Z&&(Se==="error"||Se==="idle"||!Se||jt&&as)&&!lt,zn=s(vt?"settings.remoteInstances.sidebar.actions.disconnect":qt?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!y)return t.jsxs(Tr,{children:[e?t.jsxs("div",{"data-settings-item":"remote-instances.client-auth",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.clientAuth.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.description")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[t.jsx(ot,{className:"h-8",value:fe,onChange:K=>L(K.target.value),placeholder:s("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{At()},children:s("settings.remoteInstances.clientAuth.actions.create")}),t.jsx(J,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Zt()},children:s("settings.remoteInstances.clientAuth.actions.pair")})]}),at?t.jsxs("div",{className:"flex flex-col gap-3 rounded-md border border-[var(--interactive-border)] p-2 sm:flex-row",children:[Ze?t.jsx("img",{src:Ze,alt:s("settings.remoteInstances.clientAuth.qrAlt"),className:"size-48 self-start"}):null,t.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.pairingUrl")}),t.jsx("code",{className:"block select-all break-all typography-code text-foreground",children:at}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{mn(at)},children:[t.jsx(A,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.common.actions.copyAll")]})]})]}):null,Le?t.jsxs("div",{className:"space-y-1 rounded-md border border-[var(--interactive-border)] p-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.createdToken")}),t.jsx("code",{className:"block select-all break-all typography-code text-foreground",children:Le})]}):null,t.jsxs("div",{className:"space-y-1",children:[mt>0?t.jsx("div",{className:"flex justify-end",children:t.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ss()},children:s("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,G?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.state.loading")}):Ce.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.state.empty")}):Ce.map(K=>{const qe=K.clientKind==="desktop-local";return t.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:K.label}),qe?t.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:s("settings.remoteInstances.clientAuth.state.thisDevice")}):null]}),t.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:K.revokedAt?s("settings.remoteInstances.clientAuth.state.revoked"):K.lastUsedAt?s("settings.remoteInstances.clientAuth.lastUsed",{date:K.lastUsedAt}):s("settings.remoteInstances.clientAuth.neverUsed")})]}),t.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ts(K)},disabled:!!K.revokedAt,children:s("settings.remoteInstances.clientAuth.actions.revoke")})]},K.id)})]}),Xe?t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Xe}):null]})]}):null,n?t.jsxs("div",{"data-settings-item":"remote-instances.direct-hosts",className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.direct.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.remoteInstances.direct.note")}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Be(!0),disabled:ye,children:s("settings.remoteInstances.direct.import.action")}),t.jsxs(J,{type:"button",size:"xs",className:"!font-normal",onClick:()=>Te(!0),disabled:ye,children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.direct.actions.add")]})]})]}),t.jsx("div",{className:"space-y-1",children:be?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.state.loading")}):xe.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.state.empty")}):xe.map(K=>t.jsx("div",{className:"py-1.5",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:$n(K.label)}),he===K.id?t.jsx("span",{className:"typography-micro text-muted-foreground",children:s("desktopHostSwitcher.header.default")}):null]}),t.jsx("p",{className:"typography-micro text-muted-foreground font-mono truncate",children:$n(K.apiUrl||K.url)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{it(K.id)},disabled:ye||he===K.id,"aria-label":s("desktopHostSwitcher.actions.setAsDefaultAria"),children:he===K.id?t.jsx(A,{name:"star-fill",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"star",className:"h-3.5 w-3.5"})}),t.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ft(K),disabled:ye,children:[t.jsx(A,{name:"pencil",className:"h-3.5 w-3.5"}),s("desktopHostSwitcher.actions.edit")]}),t.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Ye(K.id)},disabled:ye,children:[t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.delete")]})]})]})},K.id))}),Re?t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Re}):null]})]}):null,n?t.jsx($t,{open:Pe,onOpenChange:Te,children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.remoteInstances.direct.actions.add")}),t.jsx(Wt,{children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Ue()},children:[t.jsx(ot,{className:"h-8",value:ie,onChange:K=>ge(K.target.value),placeholder:s("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ye}),t.jsx(ot,{className:"h-8",value:V,onChange:K=>te(K.target.value),placeholder:s("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ye,autoFocus:!0}),t.jsx(ot,{className:"h-8",value:ne,onChange:K=>ue(K.target.value),placeholder:s("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ye}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Te(!1),disabled:ye,children:s("settings.common.actions.cancel")}),t.jsx(J,{type:"submit",size:"xs",className:"!font-normal",disabled:ye||!V.trim(),children:s("settings.remoteInstances.direct.actions.add")})]})]})]})}):null,n?t.jsx($t,{open:!!We,onOpenChange:K=>{K||ze(null)},children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("desktopHostSwitcher.actions.edit")}),t.jsx(Wt,{children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),$e()},children:[t.jsx(ot,{className:"h-8",value:Qe,onChange:K=>oe(K.target.value),placeholder:s("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ye}),t.jsx(ot,{className:"h-8",value:H,onChange:K=>me(K.target.value),placeholder:s("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ye,autoFocus:!0}),t.jsx(ot,{className:"h-8",value:Ne,onChange:K=>Ee(K.target.value),placeholder:s("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ye}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ze(null),disabled:ye,children:s("settings.common.actions.cancel")}),t.jsx(J,{type:"submit",size:"xs",className:"!font-normal",disabled:ye,children:s("settings.common.actions.saveChanges")})]})]})]})}):null,n?t.jsx($t,{open:Fe,onOpenChange:Be,children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.remoteInstances.direct.import.action")}),t.jsx(Wt,{children:s("settings.remoteInstances.direct.import.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),tt()},children:[t.jsx(ot,{className:"h-8",value:Me,onChange:K=>ke(K.target.value),placeholder:s("settings.remoteInstances.direct.import.placeholder"),disabled:ye,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Be(!1),disabled:ye,children:s("settings.common.actions.cancel")}),t.jsx(J,{type:"submit",size:"xs",className:"!font-normal",disabled:ye||!Me.trim(),children:s("settings.remoteInstances.direct.import.action")})]})]})]})}):null,n?t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsx("div",{className:"mb-1 px-1 space-y-0.5",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.sidebar.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.sidebar.total",{count:a.length})})]}),t.jsxs(J,{type:"button",size:"xs",className:"!font-normal",onClick:()=>nt(!0),children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.sidebar.actions.addSshInstance")]})]})}),t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-1",children:o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.noneFound")}):a.map(K=>{const qe=r[K.id],kt=K.nickname?.trim()||K.sshParsed?.destination||K.id,Ot=qe?.phase,rs=Ot==="ready";return t.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:`h-2 w-2 rounded-full ${Co(Ot)}`}),t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:kt})]}),t.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[s(So(Ot)),qe?.localUrl?` · ${qe.localUrl}`:""]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(rs?D(K.id):h(K.id)).catch(Ps=>_.error(s(rs?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:Ps instanceof Error?Ps.message:String(Ps)}))},children:[rs?t.jsx(A,{name:"stop",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"plug-2",className:"h-3.5 w-3.5"}),s(rs?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),t.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>E(K.id),children:[t.jsx(A,{name:"pencil",className:"h-3.5 w-3.5"}),s("desktopHostSwitcher.actions.edit")]}),t.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(s("settings.remoteInstances.page.confirm.removeInstance"))&&g(K.id).catch(Ps=>_.error(s("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:Ps instanceof Error?Ps.message:String(Ps)}))},children:[t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.delete")]})]})]},K.id)})})]}):null,n?t.jsx($t,{open:pe,onOpenChange:nt,children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.remoteInstances.sidebar.actions.addSshInstance")}),t.jsx(Wt,{children:s("settings.remoteInstances.page.section.instanceDescription")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Ve()},children:[t.jsx(ot,{className:"h-8",value:ht,onChange:K=>wt(K.target.value),placeholder:s("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:c}),t.jsx(ot,{className:"h-8",value:st,onChange:K=>Ge(K.target.value),placeholder:s("settings.remoteInstances.page.field.sshCommandPlaceholder"),disabled:c,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>nt(!1),disabled:c,children:s("settings.common.actions.cancel")}),t.jsx(J,{type:"submit",size:"xs",className:"!font-normal",disabled:c||!st.trim(),children:s("settings.common.actions.create")})]})]})]})}):null,n?t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsx("div",{className:"mb-1 px-1 space-y-0.5",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.import.sectionTitle")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:d?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.loading")}):i.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.noneFound")}):t.jsx("div",{children:i.map(K=>t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-3 last:border-b-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[K.host,K.pattern?` ${s("settings.remoteInstances.page.import.patternSuffix")}`:""]}),t.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:K.sshCommand})]}),t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{pt(K.host,K.pattern)},children:s("settings.common.actions.import")})]},`${K.source}:${K.host}`))})})]}):null,t.jsx($t,{open:!!B,onOpenChange:K=>{K||De()},children:t.jsxs(Bt,{className:"sm:max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.remoteInstances.page.patternDialog.title")}),t.jsx(Wt,{children:B?s("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:B}):s("settings.remoteInstances.page.patternDialog.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Ft()},children:[t.jsx(ot,{value:Q,onChange:K=>q(K.target.value),placeholder:s("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:De,disabled:R,children:s("settings.common.actions.cancel")}),t.jsx(J,{type:"submit",size:"xs",className:"!font-normal",disabled:R,children:s("settings.remoteInstances.page.actions.create")})]})]})]})})]});const Ts=y.remoteOpenchamber.mode==="managed",bn=y.nickname?.trim()||y.sshParsed?.destination||y.id;return t.jsx($t,{open:!!y,onOpenChange:K=>{K||E(null)},children:t.jsxs(Bt,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[t.jsxs("div",{className:"mb-6 px-1",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:bn}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${Co(Se)}`}),t.jsx("span",{children:s(So(Se))}),Vt?.localUrl?t.jsx("span",{className:"font-mono text-foreground/80",children:Vt.localUrl}):null,as?t.jsx("span",{children:s("settings.remoteInstances.page.status.reconnectStale")}):null]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.actions")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.actionsDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(J,{type:"button",variant:qt?"outline":"default",size:"xs",className:"!font-normal",onClick:Js,disabled:X||Z,children:[qt?t.jsx(A,{name:"stop",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"plug-2",className:"h-3.5 w-3.5"}),zn]}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Qs,disabled:!Ha,children:[t.jsx(A,{name:"refresh",className:`h-3.5 w-3.5 ${lt||jt&&!as?"animate-spin":""}`}),Ln]}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Fn()},children:[t.jsx(A,{name:"terminal-window",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.logs")]}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal text-[var(--status-error)] border-[var(--status-error)]/30 hover:text-[var(--status-error)]",onClick:()=>{window.confirm(s("settings.remoteInstances.page.confirm.removeInstance"))&&g(y.id).then(()=>{E(null),_.success(s("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(qe=>{_.error(s("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:qe instanceof Error?qe.message:String(qe)})})},children:[t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.sidebar.actions.remove")]})]}),Vt?.localUrl?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx("span",{children:s("settings.remoteInstances.page.status.currentLocalUrl")}),t.jsx("span",{className:"font-mono text-foreground/90",children:Vt.localUrl})]}):null]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.instance")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.instanceDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.sshCommand")}),t.jsx(ot,{className:"h-7 md:max-w-xl",value:y.sshCommand,onChange:K=>Jt(qe=>({...qe,sshCommand:K.target.value})),placeholder:s("settings.remoteInstances.page.field.sshCommandPlaceholder")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.nickname")}),t.jsx(ot,{className:"h-7 md:max-w-sm",value:y.nickname||"",onChange:K=>Jt(qe=>({...qe,nickname:K.target.value})),placeholder:s("settings.remoteInstances.page.field.nicknamePlaceholder")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.connectionTimeoutSeconds")}),t.jsx(bs,{containerClassName:"w-fit",min:5,max:240,step:1,className:"w-16 tabular-nums",value:y.connectionTimeoutSec,onValueChange:K=>{Jt(qe=>({...qe,connectionTimeoutSec:Number.isFinite(K)?K:qe.connectionTimeoutSec}))}})]})]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.remoteServer")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.remoteServerDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.mode"),hint:s("settings.remoteInstances.page.field.modeHint")})}),t.jsxs(Mt,{value:y.remoteOpenchamber.mode,onValueChange:K=>Jt(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,mode:K==="external"?"external":"managed"}})),children:[t.jsx(Rt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.modePlaceholder")})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"managed",children:s("settings.remoteInstances.page.field.modeManaged")}),t.jsx(gt,{value:"external",children:s("settings.remoteInstances.page.field.modeExternal")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.preferredRemotePort"),hint:s("settings.remoteInstances.page.field.preferredRemotePortHint")})}),t.jsx(bs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:y.remoteOpenchamber.preferredPort,onValueChange:K=>{Jt(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,preferredPort:Number.isFinite(K)&&K>0?K:void 0}}))},onClear:()=>{Jt(K=>({...K,remoteOpenchamber:{...K.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]}),Ts?t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.installMethod"),hint:s("settings.remoteInstances.page.field.installMethodHint")})}),t.jsxs(Mt,{value:y.remoteOpenchamber.installMethod,onValueChange:K=>Jt(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,installMethod:K==="npm"||K==="download_release"||K==="upload_bundle"?K:"bun"}})),children:[t.jsx(Rt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"bun",children:"bun"}),t.jsx(gt,{value:"npm",children:"npm"}),t.jsx(gt,{value:"download_release",children:s("settings.remoteInstances.page.field.installMethodDownloadRelease")}),t.jsx(gt,{value:"upload_bundle",children:s("settings.remoteInstances.page.field.installMethodUploadBundle")})]})]})]}):null,Ts?t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.keepServerRunning"),hint:s("settings.remoteInstances.page.field.keepServerRunningHint")})}),t.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:t.jsx(Oa,{checked:y.remoteOpenchamber.keepRunning,onCheckedChange:K=>Jt(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,keepRunning:K}}))})})]}):null]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.mainTunnel")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.mainTunnelDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.bindHost"),hint:s("settings.remoteInstances.page.field.bindHostHint")})}),t.jsxs(Mt,{value:y.localForward.bindHost,onValueChange:K=>{K==="0.0.0.0"&&!window.confirm(s("settings.remoteInstances.page.confirm.bindAllInterfaces"))||Jt(qe=>({...qe,localForward:{...qe.localForward,bindHost:K==="localhost"||K==="0.0.0.0"?K:"127.0.0.1"}}))},children:[t.jsx(Rt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"127.0.0.1",children:"127.0.0.1"}),t.jsx(gt,{value:"localhost",children:"localhost"}),t.jsx(gt,{value:"0.0.0.0",children:"0.0.0.0"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.preferredLocalPort"),hint:s("settings.remoteInstances.page.field.preferredLocalPortHint")})}),t.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[t.jsx(bs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:y.localForward.preferredLocalPort,onValueChange:K=>{Jt(qe=>({...qe,localForward:{...qe.localForward,preferredLocalPort:Number.isFinite(K)&&K>0?K:void 0}}))},onClear:()=>{Jt(K=>({...K,localForward:{...K.localForward,preferredLocalPort:void 0}}))},emptyLabel:s("settings.remoteInstances.page.field.auto")}),t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:s("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>Jt(K=>({...K,localForward:{...K.localForward,preferredLocalPort:Fr()}})),children:t.jsx(A,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]})]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.authentication")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.authenticationDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.sshPasswordOptional")}),t.jsx(ot,{className:"h-7 md:max-w-sm",type:"password",value:y.auth.sshPassword?.value||"",onChange:K=>Jt(qe=>({...qe,auth:{...qe.auth,sshPassword:{enabled:K.target.value.trim().length>0,value:K.target.value,store:qe.auth.sshPassword?.store||"never"}}})),placeholder:s("settings.remoteInstances.page.field.sshPasswordPlaceholder")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.uiPasswordOptional")}),t.jsx(ot,{className:"h-7 md:max-w-sm",type:"password",value:y.auth.openchamberPassword?.value||"",onChange:K=>Jt(qe=>({...qe,auth:{...qe.auth,openchamberPassword:{enabled:K.target.value.trim().length>0,value:K.target.value,store:qe.auth.openchamberPassword?.store||"never"}}})),placeholder:s("settings.remoteInstances.page.field.uiPasswordPlaceholder")})]})]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.portForwards")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.portForwardsDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[y.portForwards.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground/80",children:s("settings.remoteInstances.page.empty.noExtraForwards")}):null,y.portForwards.map((K,qe)=>{const kt=Lt=>{Jt(es=>({...es,portForwards:es.portForwards.map((vn,pc)=>pc===qe?Lt(vn):vn)}))},Ot=K.type==="remote"?"Local target":"Local listen",rs=K.type==="remote"?"Local host and port on your machine that receives traffic from remote -R listener.":"Local host and port where this forward listens on your machine.",Kn=K.type==="remote"?"Remote listen":"Remote target",Ps=K.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",yn=Po(K.localHost||"localhost",K.localPort),S=Po(K.remoteHost||"localhost",K.remotePort),bt=K.type==="local"&&typeof K.localPort=="number"&&K.localPort>0,zt=bt?`http://${cf(K.localHost)}:${K.localPort}`:"",ns=!!F[K.id],Ms=K.type==="local"?s("settings.remoteInstances.page.forwardType.local"):K.type==="remote"?s("settings.remoteInstances.page.forwardType.remote"):s("settings.remoteInstances.page.forwardType.dynamic");return t.jsxs(pn,{open:ns,onOpenChange:Lt=>{W(es=>({...es,[K.id]:Lt}))},className:`${qe>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0 flex items-center gap-2",children:t.jsxs(gn,{className:"flex items-center gap-2 group",children:[t.jsx(A,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${ns?"rotate-180":""}`}),t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:af(K)}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:Ms})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oa,{checked:K.enabled,onCheckedChange:Lt=>kt(es=>({...es,enabled:Lt})),"aria-label":s("settings.remoteInstances.page.actions.enableForwardAria")}),t.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>Jt(Lt=>({...Lt,portForwards:Lt.portForwards.filter(es=>es.id!==K.id)})),children:t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),t.jsx(hn,{className:"pt-2",children:t.jsxs("div",{className:"space-y-0 pb-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:s(lf(K.type))}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:s("settings.remoteInstances.page.field.forwardType"),hint:s("settings.remoteInstances.page.field.forwardTypeHint")})}),t.jsxs(Mt,{value:K.type,onValueChange:Lt=>kt(es=>({...es,type:Lt==="dynamic"||Lt==="remote"?Lt:"local"})),children:[t.jsx(Rt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.typePlaceholder")})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"local",children:s("settings.remoteInstances.page.forwardType.local")}),t.jsx(gt,{value:"remote",children:s("settings.remoteInstances.page.forwardType.remote")}),t.jsx(gt,{value:"dynamic",children:s("settings.remoteInstances.page.forwardType.dynamic")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:Ot,hint:rs})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(ot,{className:"h-7 w-32",value:K.localHost||"127.0.0.1",onChange:Lt=>kt(es=>({...es,localHost:Lt.target.value})),placeholder:s("settings.remoteInstances.page.field.localHostPlaceholder")}),t.jsx("span",{className:"text-muted-foreground",children:":"}),t.jsx(bs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:K.localPort,onValueChange:Lt=>{kt(es=>({...es,localPort:Number.isFinite(Lt)&&Lt>0?Lt:void 0}))},onClear:()=>{kt(Lt=>({...Lt,localPort:void 0}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]})]}),K.type!=="dynamic"?t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx($s,{label:Kn,hint:Ps})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(ot,{className:"h-7 w-32",value:K.remoteHost||"",onChange:Lt=>kt(es=>({...es,remoteHost:Lt.target.value})),placeholder:s("settings.remoteInstances.page.field.remoteHostPlaceholder")}),t.jsx("span",{className:"text-muted-foreground",children:":"}),t.jsx(bs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:K.remotePort,onValueChange:Lt=>{kt(es=>({...es,remotePort:Number.isFinite(Lt)&&Lt>0?Lt:void 0}))},onClear:()=>{kt(Lt=>({...Lt,remotePort:void 0}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]})]}):null,t.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:K.type==="dynamic"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:yn}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.localSocks5")})]}):K.type==="remote"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"server",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:S}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.remote")}),t.jsx(A,{name:"arrow-right",className:"h-3.5 w-3.5"}),t.jsx(A,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:yn}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.local")})]}):t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:yn}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.local")}),t.jsx(A,{name:"arrow-right",className:"h-3.5 w-3.5"}),t.jsx(A,{name:"server",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:S}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.remote")})]})}),bt?t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ws(zt).then(Lt=>{Lt||_.error(s("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[t.jsx(A,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},K.id)}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const K=rf();Jt(qe=>({...qe,portForwards:[...qe.portForwards,K]})),W(qe=>({...qe,[K.id]:!0}))},children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.addForward")]})]})]}),t.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(J,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Ds()},disabled:!Es||c,children:s("settings.common.actions.saveChanges")}),Vt?.localUrl?t.jsxs(t.Fragment,{children:[t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{mn(Vt.localUrl||"").then(K=>{K.ok&&_.success(s("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[t.jsx(A,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.copyLocalUrl")]}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Gs()},children:[t.jsx(A,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.open")]})]}):null,x?t.jsx("div",{className:"ml-auto typography-meta text-[var(--status-error)]",children:x}):null]})}),t.jsx($t,{open:P,onOpenChange:z,children:t.jsxs(Bt,{className:"sm:max-w-2xl",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.remoteInstances.page.logsDialog.title")}),t.jsx(Wt,{children:y?.nickname?.trim()||y?.sshParsed?.destination||y?.id||s("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:On,disabled:M||!Ks.trim(),children:[t.jsx(A,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.common.actions.copyAll")]}),t.jsxs(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{_a()},disabled:M,children:[t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.clear")]})]}),M?t.jsx("div",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.logsDialog.loading")}):v?t.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:v}):t.jsx("pre",{className:"max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words",children:O.length>0?O.join(`
|
|
29
|
+
`):s("settings.remoteInstances.page.logsDialog.empty")})]})}),t.jsx($t,{open:!!B,onOpenChange:K=>{K||De()},children:t.jsxs(Bt,{className:"sm:max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:s("settings.remoteInstances.page.patternDialog.title")}),t.jsx(Wt,{children:B?s("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:B}):s("settings.remoteInstances.page.patternDialog.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Ft()},children:[t.jsx(ot,{value:Q,onChange:K=>q(K.target.value),placeholder:s("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:De,disabled:R,children:s("settings.common.actions.cancel")}),t.jsx(J,{type:"submit",size:"xs",className:"!font-normal",disabled:R,children:s("settings.common.actions.create")})]})]})]})})]})})},pf="__add_provider__",gf=()=>{const s=ws.getDirectory();return typeof s=="string"&&s.trim().length>0?s.trim():null},hf=({onItemSelect:s})=>{const{t:e}=dt(),n=ut(u=>u.providers),a=ut(u=>u.selectedProviderId),r=ut(u=>u.setSelectedProvider),i=is(u=>u.activeProjectId),[o,d]=l.useState({}),c=l.useMemo(()=>gf(),[i]);l.useEffect(()=>{if(n.length===0){d({});return}let u=!1;return(async()=>{const f=n.map(async g=>{try{const h=c?`?directory=${encodeURIComponent(c)}`:"",D=await yt(`/api/provider/${encodeURIComponent(g.id)}/source${h}`,{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const k=await D.json().catch(()=>null),w=k?.sources??k?.data?.sources;if(!w||u)return;d(E=>({...E,[g.id]:w}))}catch{}});await Promise.all(f)})(),()=>{u=!0}},[c,n]);const x="bg-background",m=l.useMemo(()=>n.filter(u=>!!o[u.id]?.project?.exists),[n,o]),p=l.useMemo(()=>n.filter(u=>!o[u.id]?.project?.exists),[n,o]);return t.jsxs("div",{className:ce("flex h-full flex-col",x),children:[t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:e("settings.providers.sidebar.title")}),t.jsx(na,{className:"mb-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.providers.sidebar.total",{count:n.length})}),t.jsx(J,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:()=>{r(pf),s?.()},"aria-label":e("settings.providers.sidebar.actions.connectProviderAria"),title:e("settings.providers.sidebar.actions.connectProviderTitle"),children:t.jsx(A,{name:"add",className:"h-3.5 w-3.5"})})]})]}),t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:n.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"stack",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.providers.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.providers.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[p.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.providers.sidebar.section.userProviders")}),p.map(u=>t.jsx(Io,{provider:u,selectedProviderId:a,onSelect:()=>{r(u.id),s?.()}},u.id))]}),m.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ce("px-2 pb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",p.length>0?"pt-3":"pt-2"),children:e("settings.providers.sidebar.section.projectProviders")}),m.map(u=>t.jsx(Io,{provider:u,selectedProviderId:a,onSelect:()=>{r(u.id),s?.()}},u.id))]})]})})]})},Io=s=>{const e=rt.c(17),{provider:n,selectedProviderId:a,onSelect:r}=s,i=Array.isArray(n.models)?n.models.length:0,o=n.id===a,d=n.id,c=o?"bg-interactive-selection":"hover:bg-interactive-hover";let x;e[0]!==c?(x=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",c),e[0]=c,e[1]=x):x=e[1];let m;e[2]!==n.id?(m=t.jsx(En,{providerId:n.id,className:"h-4 w-4 flex-shrink-0"}),e[2]=n.id,e[3]=m):m=e[3];const p=n.name||n.id;let u;e[4]!==p?(u=t.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:p}),e[4]=p,e[5]=u):u=e[5];let C;e[6]!==i?(C=t.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:i}),e[6]=i,e[7]=C):C=e[7];let f;e[8]!==r||e[9]!==m||e[10]!==u||e[11]!==C?(f=t.jsxs("button",{type:"button",onClick:r,className:"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[m,u,C]}),e[8]=r,e[9]=m,e[10]=u,e[11]=C,e[12]=f):f=e[12];let g;return e[13]!==n.id||e[14]!==x||e[15]!==f?(g=t.jsx("div",{className:x,children:f},d),e[13]=n.id,e[14]=x,e[15]=f,e[16]=g):g=e[16],g},ff=s=>s,xf=s=>new Intl.NumberFormat(_r(),{notation:"compact",compactDisplay:"short",maximumFractionDigits:1,minimumFractionDigits:0}).format(s),Do=s=>{if(typeof s!="number"||Number.isNaN(s))return null;if(s===0)return"0";const e=xf(s);return e.endsWith(".0")?e.slice(0,-2):e},fa="__add_provider__",Tn=s=>typeof s=="object"&&s!==null,Ao=s=>{const e=typeof s.type=="string"?s.type:"",n=`${s.name??""} ${s.label??""}`.toLowerCase(),a=`${e} ${n}`.toLowerCase();return a.includes("oauth")?"oauth":a.includes("api")?"api":e.toLowerCase()},bf=s=>{if(!Tn(s))return{};const e={};for(const[n,a]of Object.entries(s))Array.isArray(a)&&(e[n]=a.filter(r=>Tn(r)));return e},yf=s=>{if(typeof s=="string")return{id:s};if(!Tn(s))return null;const e=typeof s.id=="string"&&s.id||typeof s.providerID=="string"&&s.providerID||typeof s.slug=="string"&&s.slug||typeof s.name=="string"&&s.name;if(!e)return null;const n=typeof s.name=="string"?s.name:void 0;return{id:e,name:n}},vf=s=>{let e=[];Array.isArray(s)?e=s:Tn(s)&&(Array.isArray(s.all)?e=s.all:Array.isArray(s.providers)&&(e=s.providers));const n=e.map(r=>yf(r)).filter(r=>!!r),a=new Set;return n.filter(r=>a.has(r.id)?!1:(a.add(r.id),!0))},jf=()=>{const{t:s}=dt(),e=ut(V=>V.providers),n=ut(V=>V.selectedProviderId),a=ut(V=>V.setSelectedProvider),r=ut(V=>V.getModelMetadata),i=Ke(V=>V.hiddenModels),o=Ke(V=>V.toggleHiddenModel),d=Ke(V=>V.hideAllModels),c=Ke(V=>V.showAllModels),[x,m]=l.useState({}),[p,u]=l.useState(!1),[C,f]=l.useState({}),[g,h]=l.useState(null),[D,k]=l.useState(""),[w,E]=l.useState(null),[N,y]=l.useState({}),[b,P]=l.useState({}),[z,M]=l.useState([]),[I,v]=l.useState(!1),[j,O]=l.useState(null),[T,B]=l.useState(""),[U,Q]=l.useState(""),[q,R]=l.useState(!1),[Y,F]=l.useState({}),[W,X]=l.useState(!1),re=n===fa;l.useEffect(()=>{!n&&e.length>0&&a(e[0].id)},[e,n,a]),l.useEffect(()=>{if(!re)return;let V=!0;return(async()=>{u(!0);try{const ne=await ws.getSdkClient().provider.auth();if(ne.error)throw new Error(`provider.auth failed: ${String(ne.error)}`);if(!V)return;m(bf(ne.data))}catch(ne){if(!V)return;console.error("Failed to load provider auth methods:",ne),_.error(s("settings.providers.page.toast.authMethodsLoadFailed"))}finally{V&&u(!1)}})(),()=>{V=!1}},[re,s]),l.useEffect(()=>{if(!ff(re))return;let V=!0;return(async()=>{v(!0),O(null);try{const ne=await ws.getSdkClient().provider.list();if(ne.error)throw new Error(`provider.list failed: ${String(ne.error)}`);if(!V)return;M(vf(ne.data))}catch(ne){if(!V)return;console.error("Failed to load available providers:",ne),O(s("settings.providers.page.state.unableToLoadProviderList"))}finally{V&&v(!1)}})(),()=>{V=!1}},[re,s]);const Z=l.useMemo(()=>new Set(e.map(V=>V.id)),[e]),de=l.useMemo(()=>z.filter(V=>!Z.has(V.id)).sort((V,te)=>{const ne=(V.name||V.id).toLowerCase(),ue=(te.name||te.id).toLowerCase();return ne.localeCompare(ue)}),[z,Z]);l.useEffect(()=>{n===fa&&T&&!de.some(V=>V.id===T)&&B("")},[n,T,de]),l.useEffect(()=>{if(n===fa){X(!0);return}X(!1)},[n,s]),l.useEffect(()=>{if(!n||n===fa)return;let V=!1;return(async()=>{try{const ne=await yt(`/api/provider/${encodeURIComponent(n)}/source`,{method:"GET",headers:{Accept:"application/json"}}),ue=await ne.json().catch(()=>null);if(!ne.ok)throw new Error(ue?.error||s("settings.providers.page.toast.providerSourcesLoadFailed"));const Me=ue?.sources??ue?.data?.sources;!V&&Me&&F(ke=>({...ke,[n]:Me}))}catch(ne){V||console.error("Failed to load provider sources:",ne)}})(),()=>{V=!0}},[n,s]);const le=e.find(V=>V.id===n),ee=n?Y[n]:void 0,xe=async V=>{const te=C[V]?.trim()??"";if(!te){_.error(s("settings.providers.page.toast.apiKeyRequired"));return}const ne=`api:${V}`;h(ne);try{if((await ws.getSdkClient().auth.set({providerID:V,auth:{type:"api",key:te}})).error)throw new Error(s("settings.providers.page.toast.apiKeySaveFailed"));_.success(s("settings.providers.page.toast.apiKeySaved")),f(Me=>({...Me,[V]:""})),await Dn({scopes:["providers"],mode:"active"}),a(V)}catch(ue){console.error("Failed to save API key:",ue),_.error(s("settings.providers.page.toast.apiKeySaveFailed"))}finally{h(null)}},we=async(V,te)=>{const ne=`oauth:${V}:${te}`;h(ne);try{const ue=await ws.getSdkClient().provider.oauth.authorize({providerID:V,method:te});if(ue.error)throw new Error(s("settings.providers.page.toast.oauthStartFailed"));const Me=Tn(ue.data)?ue.data:{},ke=Me.data,Re=Tn(ke)?ke:Me,Ae=typeof Re.url=="string"&&Re.url||typeof Re.verification_uri_complete=="string"&&Re.verification_uri_complete||typeof Re.verification_uri=="string"&&Re.verification_uri||void 0,Pe=typeof Re.instructions=="string"&&Re.instructions||typeof Re.message=="string"&&Re.message||void 0,Te=typeof Re.user_code=="string"&&Re.user_code||typeof Re.code=="string"&&Re.code||typeof Re.userCode=="string"&&Re.userCode||void 0;if(!Ae&&!Pe&&!Te)throw new Error(s("settings.providers.page.toast.oauthDetailsMissing"));const Fe=`${V}:${te}`;P(Be=>({...Be,[Fe]:{url:Ae,instructions:Pe,userCode:Te}})),Ae&&Ws(Ae),E({providerId:V,methodIndex:te}),_.message(s("settings.providers.page.toast.completeOAuthInBrowser"))}catch(ue){console.error("Failed to start OAuth flow:",ue),_.error(s("settings.providers.page.toast.oauthStartFailed"))}finally{h(null)}},he=async(V,te)=>{const ne=`${V}:${te}`,ue=N[ne]?.trim(),Me=`oauth-complete:${V}:${te}`;h(Me);try{const ke={method:te};if(ue&&(ke.code=ue),(await ws.getSdkClient().provider.oauth.callback({providerID:V,method:ke.method,code:ke.code})).error)throw new Error(s("settings.providers.page.toast.oauthCompleteFailed"));_.success(s("settings.providers.page.toast.oauthCompleted")),y(Ae=>({...Ae,[ne]:""})),E(null),await Dn({scopes:["providers"],mode:"active"}),a(V)}catch(ke){console.error("Failed to complete OAuth flow:",ke),_.error(s("settings.providers.page.toast.oauthCompleteFailed"))}finally{h(null)}},Ie=async V=>{const te=await mn(V);if(te.ok){_.success(s("settings.providers.page.toast.oauthLinkCopied"));return}console.error("Failed to copy OAuth link:",te.error),_.error(s("settings.providers.page.toast.oauthLinkCopyFailed"))},be=async V=>{const te=await mn(V);if(te.ok){_.success(s("settings.providers.page.toast.deviceCodeCopied"));return}console.error("Failed to copy device code:",te.error),_.error(s("settings.providers.page.toast.deviceCodeCopyFailed"))},je=async V=>{const te=`disconnect:${V}`;h(te);try{const ne=await yt(`/api/provider/${encodeURIComponent(V)}/auth?scope=all`,{method:"DELETE",headers:{Accept:"application/json"}}),ue=await ne.json().catch(()=>null);if(!ne.ok)throw new Error(ue?.error||s("settings.providers.page.toast.providerDisconnectFailed"));_.success(s("settings.providers.page.toast.providerDisconnected")),await Dn({scopes:["providers"],mode:"active"})}catch(ne){console.error("Failed to disconnect provider:",ne),_.error(s("settings.providers.page.toast.providerDisconnectFailed"))}finally{h(null)}};if(!re&&e.length===0)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"stack",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.providers.page.empty.noProvidersDetected")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.providers.page.empty.checkOpenCodeConfiguration")})]})});if(re)return t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{"data-settings-item":"providers.connect",className:"mb-4",children:t.jsx("h1",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.providers.page.connect.title")})}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h2",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.connect.selectProviderTitle")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.providers.page.connect.providerField")}),I?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.state.loading")}):j?t.jsx("p",{className:"typography-meta text-muted-foreground",children:j}):de.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.connect.allProvidersConnected")}):t.jsxs(gs,{open:q,onOpenChange:V=>{R(V),V||Q("")},children:[t.jsx(us,{asChild:!0,children:t.jsxs("button",{type:"button",className:ce("flex items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover h-6 w-fit"),children:[t.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[T?t.jsx(En,{providerId:T,className:"h-3.5 w-3.5 flex-shrink-0"}):null,t.jsx("span",{className:ce("truncate typography-ui-label font-normal",T?"text-foreground":"text-muted-foreground"),children:T?de.find(V=>V.id===T)?.name||T:s("settings.providers.page.connect.selectProviderPlaceholder")})]}),t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/50"})]})}),t.jsxs(ps,{align:"start",className:"w-[280px] p-0",onCloseAutoFocus:V=>V.preventDefault(),children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2",onKeyDown:V=>V.stopPropagation(),children:[t.jsx(A,{name:"search",className:"h-4 w-4 text-muted-foreground"}),t.jsx("input",{type:"text",value:U,onChange:V=>Q(V.target.value),onKeyDown:V=>V.stopPropagation(),placeholder:s("settings.providers.page.connect.searchProvidersPlaceholder"),className:"flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),t.jsx(Gt,{outerClassName:"max-h-[240px]",className:"p-1",children:(()=>{const V=de.filter(te=>{const ne=U.toLowerCase();return(te.name||te.id).toLowerCase().includes(ne)||te.id.toLowerCase().includes(ne)});return V.length===0?t.jsx("p",{className:"py-4 text-center typography-meta text-muted-foreground",children:s("settings.providers.page.connect.noProvidersFound")}):V.map(te=>t.jsxs(vs,{onSelect:()=>{B(te.id),R(!1),Q("")},className:"flex items-center justify-between",children:[t.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(En,{providerId:te.id,className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:te.name||te.id})]}),T===te.id&&t.jsx(A,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},te.id))})()})]})]})]})})]}),T&&t.jsxs("div",{"data-settings-item":"providers.auth",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h2",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.auth.title")})}),p?t.jsx("p",{className:"typography-meta text-muted-foreground px-2",children:s("settings.providers.page.auth.loadingMethods")}):t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-4",children:[t.jsxs("div",{className:"py-1.5",children:[t.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[s("settings.providers.page.auth.apiKeyLabel"),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.providers.page.auth.apiKeyTooltip")})]})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5",children:[t.jsx(ot,{type:"password",value:C[T]??"",onChange:V=>f(te=>({...te,[T]:V.target.value})),placeholder:s("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),t.jsx(J,{size:"xs",className:"!font-normal shrink-0",onClick:()=>xe(T),disabled:g===`api:${T}`,children:g===`api:${T}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.saveKey")})]})]}),(()=>{const te=(x[T]??[]).filter(ne=>Ao(ne)==="oauth");return te.length===0?null:t.jsx("div",{className:"space-y-4 border-t border-[var(--surface-subtle)] pt-2",children:te.map((ne,ue)=>{const Me=ne.label||ne.name||s("settings.providers.page.auth.oauthMethodFallback",{index:String(ue+1)}),ke=`${T}:${ue}`,Re=w?.providerId===T&&w?.methodIndex===ue;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:Me}),(ne.description||ne.help)&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:String(ne.description||ne.help)})]}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>we(T,ue),disabled:g===`oauth:${T}:${ue}`,children:s("settings.providers.page.actions.connect")})]}),b[ke]?.instructions&&t.jsx("p",{className:"typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded",children:b[ke]?.instructions}),b[ke]?.userCode&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(ot,{value:b[ke]?.userCode,readOnly:!0,className:"font-mono text-center tracking-widest"}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>be(b[ke]?.userCode??""),children:s("settings.providers.page.actions.copyCode")})]}),b[ke]?.url&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(ot,{value:b[ke]?.url,readOnly:!0,className:"text-xs text-muted-foreground"}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ws(b[ke]?.url??""),children:s("settings.providers.page.actions.open")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(b[ke]?.url??""),children:s("settings.providers.page.actions.copy")})]})]}),Re&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(ot,{value:N[ke]??"",onChange:Ae=>y(Pe=>({...Pe,[ke]:Ae.target.value})),placeholder:s("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs"}),t.jsx(J,{size:"xs",className:"!font-normal",onClick:()=>he(T,ue),disabled:g===`oauth-complete:${T}:${ue}`,children:g===`oauth-complete:${T}:${ue}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.complete")})]})]},`${T}-${Me}`)})})})()]})]})]})});if(!le)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"stack",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.providers.page.empty.selectProviderFromSidebar")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.providers.page.empty.reviewDetailsAndConfigureAuth")})]})});const ye=Array.isArray(le.models)?le.models:[],ie=(x[le.id]??[]).filter(V=>Ao(V)==="oauth"),ge=ye.filter(V=>{const te=typeof V?.name=="string"?V.name:"",ne=typeof V?.id=="string"?V.id:"",ue=D.trim().toLowerCase();return ue?te.toLowerCase().includes(ue)||ne.toLowerCase().includes(ue):!0});return t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx(En,{providerId:le.id,className:"h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:le.name||le.id}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:t.jsx("span",{className:"font-mono",children:le.id})})]})]}),t.jsxs("div",{"data-settings-item":"providers.auth",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.auth.title")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>X(V=>!V),children:s(W?"settings.providers.page.actions.hide":"settings.providers.page.actions.reconnect")})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:W?p?t.jsx("div",{className:"py-1.5 typography-meta text-muted-foreground",children:s("settings.providers.page.auth.loadingMethods")}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"py-1.5",children:[t.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[s("settings.providers.page.auth.apiKeyLabel"),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.providers.page.auth.apiKeyTooltip")})]})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5",children:[t.jsx(ot,{type:"password",value:C[le.id]??"",onChange:V=>f(te=>({...te,[le.id]:V.target.value})),placeholder:s("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),t.jsx(J,{size:"xs",className:"!font-normal shrink-0",onClick:()=>xe(le.id),disabled:g===`api:${le.id}`,children:g===`api:${le.id}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.saveKey")})]})]}),ie.length>0&&t.jsx("div",{className:"space-y-4 border-t border-[var(--surface-subtle)] pt-2",children:ie.map((V,te)=>{const ne=V.label||V.name||s("settings.providers.page.auth.oauthMethodFallback",{index:String(te+1)}),ue=`${le.id}:${te}`,Me=w?.providerId===le.id&&w?.methodIndex===te;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:ne}),(V.description||V.help)&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:String(V.description||V.help)})]}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>we(le.id,te),disabled:g===`oauth:${le.id}:${te}`,children:s("settings.providers.page.actions.connect")})]}),b[ue]?.instructions&&t.jsx("p",{className:"typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded",children:b[ue]?.instructions}),b[ue]?.userCode&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(ot,{value:b[ue]?.userCode,readOnly:!0,className:"font-mono text-center tracking-widest"}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>be(b[ue]?.userCode??""),children:s("settings.providers.page.actions.copyCode")})]}),b[ue]?.url&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(ot,{value:b[ue]?.url,readOnly:!0,className:"text-xs text-muted-foreground"}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ws(b[ue]?.url??""),children:s("settings.providers.page.actions.open")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(b[ue]?.url??""),children:s("settings.providers.page.actions.copy")})]})]}),Me&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(ot,{value:N[ue]??"",onChange:ke=>y(Re=>({...Re,[ue]:ke.target.value})),placeholder:s("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs"}),t.jsx(J,{size:"xs",className:"!font-normal",onClick:()=>he(le.id,te),disabled:g===`oauth-complete:${le.id}:${te}`,children:g===`oauth-complete:${le.id}:${te}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.complete")})]})]},`${le.id}-${ne}`)})})]}):t.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[t.jsx(A,{name:"check",className:"w-4 h-4 text-[var(--status-success)] shrink-0"}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.providers.page.auth.connected")}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-1",children:s("settings.providers.page.auth.useReconnectHint")})]})})]}),t.jsxs("div",{"data-settings-item":"providers.connection-details",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.connectionDetails.title")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col",children:ee&&(ee.auth.exists||ee.user.exists||ee.project.exists||ee.custom?.exists)?t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[s("settings.providers.page.connectionDetails.configuredIn")," ",[ee.auth.exists?s("settings.providers.page.connectionDetails.source.authCredentials"):null,ee.user.exists?s("settings.providers.page.connectionDetails.source.userConfig"):null,ee.project.exists?s("settings.providers.page.connectionDetails.source.projectConfig"):null,ee.custom?.exists?s("settings.providers.page.connectionDetails.source.customConfig"):null].filter(Boolean).join(", ")]}):t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.connectionDetails.noActiveSource")})}),t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>je(le.id),disabled:g===`disconnect:${le.id}`,children:g===`disconnect:${le.id}`?s("settings.providers.page.actions.disconnecting"):s("settings.providers.page.actions.disconnect")})]})})]}),t.jsxs("div",{"data-settings-item":"providers.models",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:"typography-ui-header font-medium text-foreground",children:[s("settings.providers.page.models.title"),ye.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",ye.length,")"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const V=ye.map(te=>typeof te?.id=="string"?te.id:"").filter(te=>te.length>0);d(le.id,V)},children:s("settings.providers.page.actions.hideAll")}),t.jsx(J,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>c(le.id),children:s("settings.providers.page.actions.showAll")})]})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0",children:[t.jsxs("div",{className:"relative mb-2",children:[t.jsx(A,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),t.jsx(ot,{value:D,onChange:V=>k(V.target.value),placeholder:s("settings.providers.page.models.filterPlaceholder"),className:"h-7 pl-8 w-full"})]}),ge.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground py-4 text-center",children:s("settings.providers.page.models.noModelsMatchFilter")}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:ge.map(V=>{const te=typeof V?.id=="string"?V.id:"",ne=typeof V?.name=="string"?V.name:te,ue=te?r(le.id,te):void 0,Me=i.some(Pe=>Pe.providerID===le.id&&Pe.modelID===te),ke=Do(ue?.limit?.context),Re=Do(ue?.limit?.output),Ae=[];return ue?.tool_call&&Ae.push({key:"tools",icon:"tools",label:s("settings.providers.page.models.capability.toolCalling")}),ue?.reasoning&&Ae.push({key:"reasoning",icon:"brain-ai-3",label:s("settings.providers.page.models.capability.reasoning")}),ue?.attachment&&Ae.push({key:"image",icon:"file-image",label:s("settings.providers.page.models.capability.imageInput")}),t.jsx("div",{className:"py-1.5",children:t.jsxs("div",{className:ce("flex items-center gap-3",Me&&"opacity-50"),children:[t.jsx("span",{className:"typography-meta font-medium text-foreground truncate flex-1 min-w-0",children:ne}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(ke||Re)&&t.jsxs("span",{className:"typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:[ke?`${ke} ${s("settings.providers.page.models.tokenBadge.context")}`:"",ke&&Re?" · ":"",Re?`${Re} ${s("settings.providers.page.models.tokenBadge.output")}`:""]}),Ae.length>0&&t.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:Ae.map(({key:Pe,icon:Te,label:Fe})=>t.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]",title:Fe,"aria-label":Fe,children:t.jsx(A,{name:Te,className:"h-3 w-3"})},Pe))}),t.jsx("button",{type:"button",onClick:()=>o(le.id,te),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50",title:s(Me?"settings.providers.page.models.actions.showModelInSelectors":"settings.providers.page.models.actions.hideModelFromSelectors"),"aria-label":s(Me?"settings.providers.page.models.actions.showModel":"settings.providers.page.models.actions.hideModel"),children:Me?t.jsx(A,{name:"eye-off",className:"h-3.5 w-3.5"}):t.jsx(A,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},te)})})]})]})]})})},an=[{id:"claude",name:"Claude"},{id:"codex",name:"Codex"},{id:"cursor",name:"Cursor"},{id:"github-copilot",name:"GitHub Copilot"},{id:"google",name:"Google"},{id:"kimi-for-coding",name:"Kimi for Coding"},{id:"nano-gpt",name:"NanoGPT"},{id:"openrouter",name:"OpenRouter"},{id:"zai-coding-plan",name:"z.ai"},{id:"zhipuai-coding-plan",name:"Zhipu AI Coding Plan"},{id:"minimax-cn-coding-plan",name:"MiniMax Coding Plan (minimaxi.com)"},{id:"minimax-coding-plan",name:"MiniMax Coding Plan (minimax.io)"},{id:"ollama-cloud",name:"Ollama Cloud"},{id:"wafer",name:"Wafer.ai"}];function Eo(s){const e=s.indexOf("/");if(e!==-1){const n=s.substring(0,e);if(n==="gemini"||n==="antigravity")return s.substring(e+1)}return s}const wf=[{id:"gemini-auth",label:"Gemini",matcher:s=>s.startsWith("gemini/"),order:1},{id:"antigravity-auth",label:"Antigravity",matcher:s=>s.startsWith("antigravity/"),order:2}],_l={google:wf};function Hl(s,e){const n=_l[e]??[];for(const a of n)if(a.matcher(s))return a;return null}function Nf(s){return _l[s]??[]}function kf(s){return[...s].sort((e,n)=>e.order-n.order)}function Kv(s,e){const n=new Map;for(const a of Object.keys(s)){const i=Hl(a,e)?.id??null;n.has(i)||n.set(i,[]),n.get(i).push(a)}return n}function Sf(s,e,n){const a=new Map;for(const r of s){const i=e(r),d=Hl(i,n)?.id??null;a.has(d)||a.set(d,[]),a.get(d).push(r)}return a}function Cf(s,e){return e.filter(n=>{const a=n.toLowerCase(),r=a.includes("/")?a.split("/")[1]:a;return!!(r.startsWith("gemini-3-")||r.startsWith("claude-"))})}const Gr=6e4,Mo=s=>{const e=an.map(u=>u.id),n=typeof s?.usageAutoRefresh=="boolean"?s.usageAutoRefresh:!1,a=typeof s?.usageRefreshIntervalMs=="number"&&Number.isFinite(s.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(s.usageRefreshIntervalMs))):Gr,r=s?.usageDisplayMode==="remaining"?"remaining":"usage",i=typeof s?.usageShowPredValues=="boolean"?s.usageShowPredValues:!1,o=Array.isArray(s?.usageDropdownProviders)?s?.usageDropdownProviders:null,d=o?o.filter(u=>typeof u=="string"&&e.includes(u)):e,c={},x=s?.usageSelectedModels;if(x&&typeof x=="object")for(const[u,C]of Object.entries(x))Array.isArray(C)&&(c[u]=C.filter(f=>typeof f=="string"));const m={},p=s?.usageExpandedFamilies;if(p&&typeof p=="object")for(const[u,C]of Object.entries(p))Array.isArray(C)&&(m[u]=C.filter(f=>typeof f=="string"));return{autoRefresh:n,refreshIntervalMs:a,displayMode:r,showPredValues:i,dropdownProviderIds:d,selectedModels:c,expandedFamilies:m}},Pf=async()=>{const s=zs()?.settings;if(s)try{const n=(await s.load())?.settings;return Mo(n??null)}catch{}if(!fs()){const e=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(e.ok){const n=await e.json().catch(()=>null);return Mo(n)}}return{autoRefresh:!1,refreshIntervalMs:Gr,displayMode:"usage",showPredValues:!1,dropdownProviderIds:an.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Ht=rn()(ta((s,e)=>({results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Gr,displayMode:"usage",showPredValues:!1,dropdownProviderIds:an.map(n=>n.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{try{const n=await Pf();s(n)}catch(n){console.warn("Failed to load usage settings:",n)}},fetchAllQuotas:async()=>{s({isLoading:!0,error:null});const n=an.map(a=>a.id);try{await Promise.all(n.map(a=>e().fetchProviderQuota(a))),s({isLoading:!1,lastUpdated:Date.now()})}catch(a){const r=a instanceof Error?a.message:"Failed to fetch quotas";s({isLoading:!1,error:r})}},fetchProviderQuota:async n=>{s(a=>({isFetchingProvider:{...a.isFetchingProvider,[n]:!0}}));try{const a=await yt(`/api/quota/${encodeURIComponent(n)}`),r=await a.json().catch(()=>null);if(!a.ok)throw new Error(r?.error||"Failed to fetch quota");const i=r;s(o=>{const d=o.results.filter(c=>c.providerId!==n);return d.push(i),{results:d,error:null}})}catch(a){const r=a instanceof Error?a.message:"Failed to fetch quota",i={providerId:n,providerName:n,ok:!1,configured:!1,error:r,usage:null,fetchedAt:Date.now()};s(o=>{const d=o.results.filter(c=>c.providerId!==n);return d.push(i),{results:d,error:r}})}finally{s(a=>({isFetchingProvider:{...a.isFetchingProvider,[n]:!1}}))}},setSelectedProvider:n=>s({selectedProviderId:n}),setAutoRefresh:n=>s({autoRefresh:n}),setRefreshInterval:n=>{const a=Math.max(3e4,Math.min(3e5,Math.round(n)));s({refreshIntervalMs:a})},setDisplayMode:n=>s({displayMode:n}),setShowPredValues:n=>s({showPredValues:n}),setDropdownProviderIds:n=>s({dropdownProviderIds:n}),setSelectedModels:(n,a)=>{s(r=>({selectedModels:{...r.selectedModels,[n]:a}}))},toggleModelSelected:(n,a)=>{s(r=>{const i=r.selectedModels[n]??[],d=i.includes(a)?i.filter(c=>c!==a):[...i,a];return{selectedModels:{...r.selectedModels,[n]:d}}})},setExpandedFamilies:(n,a)=>{s(r=>({expandedFamilies:{...r.expandedFamilies,[n]:a}})),Ct({usageExpandedFamilies:e().expandedFamilies})},toggleFamilyExpanded:(n,a)=>{s(r=>{const i=r.expandedFamilies[n]??[],d=i.includes(a)?i.filter(c=>c!==a):[...i,a];return{expandedFamilies:{...r.expandedFamilies,[n]:d}}}),Ct({usageExpandedFamilies:e().expandedFamilies})},applyDefaultSelections:(n,a)=>{if((e().selectedModels[n]?.length??0)>0)return;const i=Cf(n,a);i.length!==0&&(s(o=>({selectedModels:{...o.selectedModels,[n]:i}})),Ct({usageSelectedModels:e().selectedModels}))}}),{name:"quota-store"})),If=()=>{const s=rt.c(5),e=Ht(Df),n=Ht(Af),a=Ht(Ef);let r,i;s[0]!==e||s[1]!==a||s[2]!==n?(r=()=>{if(!e)return;const o=window.setInterval(()=>{a()},n);return()=>window.clearInterval(o)},i=[e,n,a],s[0]=e,s[1]=a,s[2]=n,s[3]=r,s[4]=i):(r=s[3],i=s[4]),l.useEffect(r,i)};function Df(s){return s.autoRefresh}function Af(s){return s.refreshIntervalMs}function Ef(s){return s.fetchAllQuotas}const Mf=s=>{const e=s?.windows??{},n=Object.values(e).map(a=>a.usedPercent).filter(a=>typeof a=="number");return n.length===0?null:Math.max(...n)},Rf=s=>{const e=rt.c(122),{onItemSelect:n}=s,{t:a}=dt(),r=Ht(Tf),i=Ht(Ff),o=Ht(Of),d=Ht(Lf),c=Ht(zf),x=Ht(Kf),m=Ht($f),p=Ht(Bf),u=Ht(Uf),C=Ht(Vf),f=Ht(_f),g=Ht(Hf),h=Ht(Wf),D=Ht(qf);let k,w;e[0]!==D?(k=()=>{D()},w=[D],e[0]=D,e[1]=k,e[2]=w):(k=e[1],w=e[2]),l.useEffect(k,w);const E=Gf;let N;e[3]!==u?(N=Ne=>{u(Ne),E({usageAutoRefresh:Ne})},e[3]=u,e[4]=N):N=e[4];const y=N;let b;e[5]!==C?(b=Ne=>{const Ee=Number(Ne);Number.isFinite(Ee)&&(C(Ee),E({usageRefreshIntervalMs:Ee}))},e[5]=C,e[6]=b):b=e[6];const P=b;let z;e[7]!==f?(z=Ne=>{Ne!=="usage"&&Ne!=="remaining"||(f(Ne),E({usageDisplayMode:Ne}))},e[7]=f,e[8]=z):z=e[8];const M=z;let I;e[9]!==h?(I=Ne=>{h(Ne),E({usageShowPredValues:Ne})},e[9]=h,e[10]=I):I=e[10];const v=I;let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=ce("flex h-full flex-col","bg-background"),e[11]=j):j=e[11];let O;e[12]!==a?(O=a("settings.usage.sidebar.title"),e[12]=a,e[13]=O):O=e[13];let T;e[14]!==O?(T=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:O}),e[14]=O,e[15]=T):T=e[15];let B;e[16]!==a?(B=a("settings.usage.sidebar.total",{count:an.length}),e[16]=a,e[17]=B):B=e[17];let U;e[18]!==B?(U=t.jsx("span",{className:"typography-meta text-muted-foreground",children:B}),e[18]=B,e[19]=U):U=e[19];let Q;e[20]!==a?(Q=a("settings.usage.sidebar.actions.toggleAutoRefreshAria"),e[20]=a,e[21]=Q):Q=e[21];let q;e[22]!==y||e[23]!==Q||e[24]!==x?(q=t.jsx(It,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(St,{checked:x,onChange:y,ariaLabel:Q})})}),e[22]=y,e[23]=Q,e[24]=x,e[25]=q):q=e[25];let R;e[26]!==a?(R=a("settings.usage.sidebar.tooltip.autoRefresh"),e[26]=a,e[27]=R):R=e[27];let Y;e[28]!==R?(Y=t.jsx(Dt,{side:"bottom",children:R}),e[28]=R,e[29]=Y):Y=e[29];let F;e[30]!==q||e[31]!==Y?(F=t.jsxs(Pt,{children:[q,Y]}),e[30]=q,e[31]=Y,e[32]=F):F=e[32];const W=String(m),X=!x;let re;e[33]!==a?(re=a("settings.usage.sidebar.field.intervalPlaceholder"),e[33]=a,e[34]=re):re=e[34];let Z;e[35]!==re?(Z=t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:re})}),e[35]=re,e[36]=Z):Z=e[36];let de;e[37]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsxs(Tt,{children:[t.jsx(gt,{value:"30000",children:"30s"}),t.jsx(gt,{value:"60000",children:"1m"}),t.jsx(gt,{value:"300000",children:"5m"})]}),e[37]=de):de=e[37];let le;e[38]!==P||e[39]!==W||e[40]!==X||e[41]!==Z?(le=t.jsxs(Mt,{value:W,onValueChange:P,disabled:X,children:[Z,de]}),e[38]=P,e[39]=W,e[40]=X,e[41]=Z,e[42]=le):le=e[42];let ee;e[43]!==d?(ee=()=>d(),e[43]=d,e[44]=ee):ee=e[44];let xe;e[45]!==a?(xe=a("settings.usage.sidebar.actions.refreshAria"),e[45]=a,e[46]=xe):xe=e[46];let we;e[47]!==a?(we=a("settings.usage.sidebar.actions.refreshTitle"),e[47]=a,e[48]=we):we=e[48];const he=c&&"animate-spin";let Ie;e[49]!==he?(Ie=ce("h-3.5 w-3.5",he),e[49]=he,e[50]=Ie):Ie=e[50];let be;e[51]!==Ie?(be=t.jsx(A,{name:"refresh",className:Ie}),e[51]=Ie,e[52]=be):be=e[52];let je;e[53]!==c||e[54]!==ee||e[55]!==xe||e[56]!==we||e[57]!==be?(je=t.jsx(J,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:ee,"aria-label":xe,title:we,disabled:c,children:be}),e[53]=c,e[54]=ee,e[55]=xe,e[56]=we,e[57]=be,e[58]=je):je=e[58];let ye;e[59]!==F||e[60]!==le||e[61]!==je?(ye=t.jsxs("div",{className:"flex items-center gap-2",children:[F,le,je]}),e[59]=F,e[60]=le,e[61]=je,e[62]=ye):ye=e[62];let se;e[63]!==U||e[64]!==ye?(se=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[U,ye]}),e[63]=U,e[64]=ye,e[65]=se):se=e[65];let ie;e[66]!==a?(ie=a("settings.usage.sidebar.field.display"),e[66]=a,e[67]=ie):ie=e[67];let ge;e[68]!==ie?(ge=t.jsx("span",{className:"typography-micro text-muted-foreground",children:ie}),e[68]=ie,e[69]=ge):ge=e[69];let V;e[70]!==a?(V=a("settings.usage.sidebar.field.displayModePlaceholder"),e[70]=a,e[71]=V):V=e[71];let te;e[72]!==V?(te=t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:V})}),e[72]=V,e[73]=te):te=e[73];let ne;e[74]!==a?(ne=a("settings.usage.sidebar.field.displayModeUsage"),e[74]=a,e[75]=ne):ne=e[75];let ue;e[76]!==ne?(ue=t.jsx(gt,{value:"usage",children:ne}),e[76]=ne,e[77]=ue):ue=e[77];let Me;e[78]!==a?(Me=a("settings.usage.sidebar.field.displayModeRemaining"),e[78]=a,e[79]=Me):Me=e[79];let ke;e[80]!==Me?(ke=t.jsx(gt,{value:"remaining",children:Me}),e[80]=Me,e[81]=ke):ke=e[81];let Re;e[82]!==ue||e[83]!==ke?(Re=t.jsxs(Tt,{children:[ue,ke]}),e[82]=ue,e[83]=ke,e[84]=Re):Re=e[84];let Ae;e[85]!==M||e[86]!==te||e[87]!==Re||e[88]!==p?(Ae=t.jsxs(Mt,{value:p,onValueChange:M,children:[te,Re]}),e[85]=M,e[86]=te,e[87]=Re,e[88]=p,e[89]=Ae):Ae=e[89];let Pe;e[90]!==ge||e[91]!==Ae?(Pe=t.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[ge,Ae]}),e[90]=ge,e[91]=Ae,e[92]=Pe):Pe=e[92];let Te;e[93]!==a?(Te=a("settings.usage.sidebar.field.showPredictions"),e[93]=a,e[94]=Te):Te=e[94];let Fe;e[95]!==Te?(Fe=t.jsx("span",{className:"typography-micro text-muted-foreground",children:Te}),e[95]=Te,e[96]=Fe):Fe=e[96];let Be;e[97]!==a?(Be=a("settings.usage.sidebar.field.showPredictions"),e[97]=a,e[98]=Be):Be=e[98];let We;e[99]!==v||e[100]!==g||e[101]!==Be?(We=t.jsx(St,{checked:g,onChange:v,ariaLabel:Be}),e[99]=v,e[100]=g,e[101]=Be,e[102]=We):We=e[102];let ze;e[103]!==Fe||e[104]!==We?(ze=t.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[Fe,We]}),e[103]=Fe,e[104]=We,e[105]=ze):ze=e[105];let Qe;e[106]!==se||e[107]!==Pe||e[108]!==ze||e[109]!==T?(Qe=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[T,se,Pe,ze]}),e[106]=se,e[107]=Pe,e[108]=ze,e[109]=T,e[110]=Qe):Qe=e[110];let oe;e[111]!==n||e[112]!==r||e[113]!==i||e[114]!==o||e[115]!==a?(oe=an.map(Ne=>{const Ee=r.find(L=>L.providerId===Ne.id),Ce=Mf(Ee?.usage),_e=wl(Ce),G=Ne.id===i,$=Ee?.configured??!1,fe=$?_e==="critical"?{backgroundColor:"var(--status-error)"}:_e==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"}:{backgroundColor:"var(--surface-muted-foreground)",opacity:.4};return t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",G?"bg-interactive-selection":"hover:bg-interactive-hover"),children:t.jsxs("button",{type:"button",onClick:()=>{o(Ne.id),n?.()},className:"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:fe}),t.jsx(En,{providerId:Ne.id,className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:Ne.name}),!$&&t.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:a("settings.usage.sidebar.status.notSet")})]})},Ne.id)}),e[111]=n,e[112]=r,e[113]=i,e[114]=o,e[115]=a,e[116]=oe):oe=e[116];let H;e[117]!==oe?(H=t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:oe}),e[117]=oe,e[118]=H):H=e[118];let me;return e[119]!==Qe||e[120]!==H?(me=t.jsxs("div",{className:j,children:[Qe,H]}),e[119]=Qe,e[120]=H,e[121]=me):me=e[121],me};function Tf(s){return s.results}function Ff(s){return s.selectedProviderId}function Of(s){return s.setSelectedProvider}function Lf(s){return s.fetchAllQuotas}function zf(s){return s.isLoading}function Kf(s){return s.autoRefresh}function $f(s){return s.refreshIntervalMs}function Bf(s){return s.displayMode}function Uf(s){return s.setAutoRefresh}function Vf(s){return s.setRefreshInterval}function _f(s){return s.setDisplayMode}function Hf(s){return s.showPredValues}function Wf(s){return s.setShowPredValues}function qf(s){return s.loadSettings}async function Gf(s){try{await Ct(s)}catch(e){console.warn("Failed to save usage settings:",e)}}const Jf=s=>{const e=rt.c(20),{percent:n,tonePercent:a,className:r,expectedMarkerPercent:i}=s;let o;e[0]!==n?(o=Xd(n)??0,e[0]=n,e[1]=o):o=e[1];const d=o,c=a??n;let x;e[2]!==c?(x=wl(c),e[2]=c,e[3]=x):x=e[3];const m=x,p=i!=null?Math.max(0,Math.min(100,i)):null;let u;e[4]!==m?(u=m==="critical"?{backgroundColor:"var(--status-error)"}:m==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=m,e[5]=u):u=e[5];const C=u;let f;e[6]!==r?(f=ce("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",r),e[6]=r,e[7]=f):f=e[7];const g=`${d}%`;let h;e[8]!==C||e[9]!==g?(h={...C,width:g},e[8]=C,e[9]=g,e[10]=h):h=e[10];let D;e[11]!==d||e[12]!==h?(D=t.jsx("div",{className:"h-full transition-all duration-300",style:h,role:"progressbar","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100}),e[11]=d,e[12]=h,e[13]=D):D=e[13];let k;e[14]!==p?(k=p!=null&&p>0&&p<100&&t.jsx("div",{className:"absolute top-0 h-full w-0.5 bg-foreground",style:{left:`${p}%`},title:`Expected usage if spread evenly: ${Math.round(p)}% of quota`,"aria-hidden":"true"}),e[14]=p,e[15]=k):k=e[15];let w;return e[16]!==f||e[17]!==D||e[18]!==k?(w=t.jsxs("div",{className:f,children:[D,k]}),e[16]=f,e[17]=D,e[18]=k,e[19]=w):w=e[19],w},Qf=s=>{const e=rt.c(67),{paceInfo:n,className:a,compact:r}=s,i=r===void 0?!1:r,{t:o}=dt();let d;e[0]!==n.status?(d=Zd(n.status),e[0]=n.status,e[1]=d):d=e[1];const c=d;let x;e:{switch(n.status){case"on-track":{let b;e[2]!==o?(b=o("settings.usage.pace.status.onTrack"),e[2]=o,e[3]=b):b=e[3],x=b;break e}case"slightly-fast":{let b;e[4]!==o?(b=o("settings.usage.pace.status.slightlyFast"),e[4]=o,e[5]=b):b=e[5],x=b;break e}case"too-fast":{let b;e[6]!==o?(b=o("settings.usage.pace.status.tooFast"),e[6]=o,e[7]=b):b=e[7],x=b;break e}case"exhausted":{let b;e[8]!==o?(b=o("settings.usage.pace.status.usedUp"),e[8]=o,e[9]=b):b=e[9],x=b;break e}}x=void 0}const m=x;let p;e[10]!==n.predictText||e[11]!==o?(p=o("settings.usage.pace.predictionTooltip",{prediction:n.predictText}),e[10]=n.predictText,e[11]=o,e[12]=p):p=e[12];const u=p;if(i){let b;e[13]!==a?(b=ce("flex items-center gap-1.5",a),e[13]=a,e[14]=b):b=e[14];let P;e[15]!==c?(P={backgroundColor:c},e[15]=c,e[16]=P):P=e[16];let z;e[17]!==m||e[18]!==P?(z=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:P,title:m}),e[17]=m,e[18]=P,e[19]=z):z=e[19];let M;e[20]!==c?(M={color:c},e[20]=c,e[21]=M):M=e[21];const I=n.isExhausted?void 0:u;let v;e[22]!==n.isExhausted||e[23]!==n.predictText||e[24]!==n.remainingSeconds||e[25]!==o?(v=n.isExhausted?t.jsx(t.Fragment,{children:o("settings.usage.pace.wait",{duration:ui(n.remainingSeconds)})}):t.jsx(t.Fragment,{children:o("settings.usage.pace.prediction",{prediction:n.predictText})}),e[22]=n.isExhausted,e[23]=n.predictText,e[24]=n.remainingSeconds,e[25]=o,e[26]=v):v=e[26];let j;e[27]!==v||e[28]!==M||e[29]!==I?(j=t.jsx("span",{className:"typography-micro tabular-nums",style:M,title:I,children:v}),e[27]=v,e[28]=M,e[29]=I,e[30]=j):j=e[30];let O;return e[31]!==j||e[32]!==b||e[33]!==z?(O=t.jsxs("div",{className:b,children:[z,j]}),e[31]=j,e[32]=b,e[33]=z,e[34]=O):O=e[34],O}let C;e[35]!==a?(C=ce("flex items-center justify-between gap-2",a),e[35]=a,e[36]=C):C=e[36];let f;e[37]!==n.isExhausted||e[38]!==n.paceRateText||e[39]!==o?(f=!n.isExhausted&&t.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.usage.pace.rate",{rate:n.paceRateText})}),e[37]=n.isExhausted,e[38]=n.paceRateText,e[39]=o,e[40]=f):f=e[40];let g;e[41]!==f?(g=t.jsx("div",{className:"flex items-center gap-1.5",children:f}),e[41]=f,e[42]=g):g=e[42];let h;e[43]!==c?(h={color:c},e[43]=c,e[44]=h):h=e[44];let D;e[45]!==n.isExhausted||e[46]!==n.predictText||e[47]!==n.remainingSeconds||e[48]!==u||e[49]!==m||e[50]!==o?(D=n.isExhausted?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium",children:m}),t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.waitSeparator")}),t.jsx("span",{className:"font-medium",children:ui(n.remainingSeconds)})]}):t.jsxs("span",{title:u,children:[t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.predictionLabel")}),t.jsx("span",{className:"font-medium",children:n.predictText})]}),e[45]=n.isExhausted,e[46]=n.predictText,e[47]=n.remainingSeconds,e[48]=u,e[49]=m,e[50]=o,e[51]=D):D=e[51];let k;e[52]!==h||e[53]!==D?(k=t.jsx("span",{className:"typography-micro tabular-nums",style:h,children:D}),e[52]=h,e[53]=D,e[54]=k):k=e[54];let w;e[55]!==c?(w={backgroundColor:c},e[55]=c,e[56]=w):w=e[56];let E;e[57]!==m||e[58]!==w?(E=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:w,title:m}),e[57]=m,e[58]=w,e[59]=E):E=e[59];let N;e[60]!==k||e[61]!==E?(N=t.jsxs("div",{className:"flex items-center gap-1.5",children:[k,E]}),e[60]=k,e[61]=E,e[62]=N):N=e[62];let y;return e[63]!==N||e[64]!==C||e[65]!==g?(y=t.jsxs("div",{className:C,children:[g,N]}),e[63]=N,e[64]=C,e[65]=g,e[66]=y):y=e[66],y},dr=s=>{const e=rt.c(54),{title:n,window:a,subtitle:r,showToggle:i,toggleEnabled:o,onToggle:d}=s,c=i===void 0?!1:i,x=o===void 0?!1:o,m=Ht(Yf),p=Ht(Xf),u=Ke(Zf),C=m==="remaining"?a.remainingPercent:a.usedPercent,f=m==="remaining"?"remaining":"used";let g;e[0]!==C||e[1]!==a.valueLabel?(g=em(a.valueLabel,C),e[0]=C,e[1]=a.valueLabel,e[2]=g):g=e[2];const h=g,D=a.resetAfterFormatted??a.resetAtFormatted;let k;e[3]!==D||e[4]!==u||e[5]!==a.resetAt?(k=tm(a.resetAt,D,u),e[3]=D,e[4]=u,e[5]=a.resetAt,e[6]=k):k=e[6];const w=k;let E;e[7]!==n?(E=sm(n),e[7]=n,e[8]=E):E=e[8];const N=E;let y;e[9]!==n||e[10]!==a.resetAt||e[11]!==a.usedPercent||e[12]!==a.windowSeconds?(y=nm(a.usedPercent,a.resetAt,a.windowSeconds,n),e[9]=n,e[10]=a.resetAt,e[11]=a.usedPercent,e[12]=a.windowSeconds,e[13]=y):y=e[13];const b=y;let P;e:{if(!b||b.dailyAllocationPercent===null){P=null;break e}const Z=am(b.elapsedRatio);P=m==="remaining"?100-Z:Z}const z=P;let M;e[14]!==d||e[15]!==c||e[16]!==x?(M=c&&t.jsx(St,{checked:x,onChange:Z=>d?.(Z),ariaLabel:"Show in dropdown"}),e[14]=d,e[15]=c,e[16]=x,e[17]=M):M=e[17];let I;e[18]!==N?(I=t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:N}),e[18]=N,e[19]=I):I=e[19];let v;e[20]!==r?(v=r&&t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:r}),e[20]=r,e[21]=v):v=e[21];let j;e[22]!==I||e[23]!==v?(j=t.jsxs("div",{className:"min-w-0 flex flex-col",children:[I,v]}),e[22]=I,e[23]=v,e[24]=j):j=e[24];let O;e[25]!==j||e[26]!==M?(O=t.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[M,j]}),e[25]=j,e[26]=M,e[27]=O):O=e[27];const T=h==="-"?"":h;let B;e[28]!==T?(B=t.jsx("div",{className:"typography-ui-label text-foreground tabular-nums flex items-center justify-end",children:T}),e[28]=T,e[29]=B):B=e[29];let U;e[30]!==O||e[31]!==B?(U=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[O,B]}),e[30]=O,e[31]=B,e[32]=U):U=e[32];let Q;e[33]!==C||e[34]!==z||e[35]!==a.usedPercent?(Q=t.jsx(Jf,{percent:C,tonePercent:a.usedPercent,expectedMarkerPercent:z,className:"h-1.5"}),e[33]=C,e[34]=z,e[35]=a.usedPercent,e[36]=Q):Q=e[36];const q=w?`Resets ${w}`:"";let R;e[37]!==q?(R=t.jsx("span",{className:"typography-micro text-muted-foreground",children:q}),e[37]=q,e[38]=R):R=e[38];let Y;e[39]!==f?(Y=t.jsx("span",{className:"typography-micro text-muted-foreground",children:f}),e[39]=f,e[40]=Y):Y=e[40];let F;e[41]!==R||e[42]!==Y?(F=t.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[R,Y]}),e[41]=R,e[42]=Y,e[43]=F):F=e[43];let W;e[44]!==Q||e[45]!==F?(W=t.jsxs("div",{className:"mt-2.5",children:[Q,F]}),e[44]=Q,e[45]=F,e[46]=W):W=e[46];let X;e[47]!==b||e[48]!==p?(X=b&&p&&t.jsx("div",{className:"mt-1.5",children:t.jsx(Qf,{paceInfo:b})}),e[47]=b,e[48]=p,e[49]=X):X=e[49];let re;return e[50]!==U||e[51]!==W||e[52]!==X?(re=t.jsxs("div",{className:"py-3",children:[U,W,X]}),e[50]=U,e[51]=W,e[52]=X,e[53]=re):re=e[53],re};function Yf(s){return s.displayMode}function Xf(s){return s.showPredValues}function Zf(s){return s.timeFormatPreference}const ex=(s,e)=>{if(!s)return"-";try{return Nl(s,e,{fallback:"-"})}catch{return"-"}},tx=()=>{const{t:s}=dt(),e=Ke(j=>j.timeFormatPreference),n=Ht(j=>j.results),a=Ht(j=>j.selectedProviderId),r=Ht(j=>j.setSelectedProvider),i=Ht(j=>j.loadSettings),o=Ht(j=>j.fetchAllQuotas),d=Ht(j=>j.isLoading),c=Ht(j=>j.lastUpdated),x=Ht(j=>j.error),m=Ht(j=>j.dropdownProviderIds),p=Ht(j=>j.setDropdownProviderIds),u=Ht(j=>j.selectedModels),C=Ht(j=>j.toggleModelSelected),f=Ht(j=>j.applyDefaultSelections);If(),l.useEffect(()=>{i(),o()},[i,o]),l.useEffect(()=>{if(a||n.length===0)return;const j=n.find(O=>O.configured)?.providerId;r(j??an[0]?.id??null)},[n,a,r]);const g=n.find(j=>j.providerId===a)??null,D=an.find(j=>j.id===a)?.name??a??s("settings.usage.sidebar.title"),k=g?.usage,w=a?m.includes(a):!1,E=l.useCallback(j=>{if(!a)return;const O=j?Array.from(new Set([...m,a])):m.filter(T=>T!==a);p(O),Ct({usageDropdownProviders:O})},[m,a,p]),N=l.useMemo(()=>k?.models?Object.entries(k.models).map(([j,O])=>({name:j,windows:O})).filter(j=>Object.keys(j.windows.windows).length>0):[],[k?.models]);l.useEffect(()=>{a&&N.length>0&&f(a,N.map(j=>j.name))},[a,N,f]);const y=l.useMemo(()=>!a||N.length===0?new Map:Sf(N,j=>j.name,a),[N,a]),b=l.useMemo(()=>{if(!a)return[];const j=Nf(a);return kf(j)},[a]),[P,z]=l.useState(()=>({})),M=l.useCallback(j=>{z(O=>({...O,[j]:!O[j]}))},[]),I=l.useCallback(j=>{if(!a)return;C(a,j);const O=u[a]??[],B=O.includes(j)?O.filter(Q=>Q!==j):[...O,j],U={...u,[a]:B};Ct({usageSelectedModels:U})},[a,u,C]),v=a?u[a]??[]:[];return a?t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx(En,{providerId:a,className:"h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.usage.page.header.providerUsage",{provider:D})}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:d?t.jsx("span",{className:"animate-pulse",children:s("settings.usage.page.header.refreshing")}):s("settings.usage.page.header.lastUpdated",{time:ex(c,e)})})]})]}),t.jsx("div",{"data-settings-item":"usage.header-menu",className:"mb-8 px-2",children:t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":w,onClick:()=>E(!w),onKeyDown:j=>{(j.key===" "||j.key==="Enter")&&(j.preventDefault(),E(!w))},children:[t.jsx(St,{checked:w,onChange:E,ariaLabel:s("settings.usage.page.options.showInHeaderAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.usage.page.options.showInHeader")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.usage.page.options.showInHeaderTooltip")})]})]})]})}),!g&&t.jsx("div",{className:"mb-8 px-2",children:t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.usage.page.state.noData")})}),x&&t.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[t.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:s("settings.usage.page.state.refreshFailedTitle")}),t.jsx("p",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:x})]}),g&&!g.configured&&t.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3",children:[t.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:s("settings.usage.page.state.providerNotConfiguredTitle")}),t.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80 mt-1",children:s("settings.usage.page.state.providerNotConfiguredDescription")})]}),k?.windows&&Object.keys(k.windows).length>0&&t.jsx("div",{"data-settings-item":"usage.model-quotas",className:"mb-8",children:t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Object.entries(k.windows).map(([j,O])=>t.jsx(dr,{title:j,window:O},j))})})}),N.length>0&&t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.usage.page.section.modelQuotas")})}),t.jsxs("div",{className:"space-y-3",children:[b.map(j=>{const O=y.get(j.id)??[];if(O.length===0)return null;const T=P[j.id]??!1;return t.jsx("section",{className:"p-2",children:t.jsxs(pn,{open:!T,onOpenChange:()=>M(j.id),children:[t.jsxs(gn,{className:"flex w-full items-center justify-between py-0.5 group",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[t.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:j.label}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",O.length,")"]})]}),T?t.jsx(A,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(hn,{children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:O.map(B=>{const U=Object.entries(B.windows.windows);if(U.length===0)return null;const[Q,q]=U[0],R=v.includes(B.name);return t.jsx(dr,{title:Q,subtitle:Eo(B.name),window:q,showToggle:!0,toggleEnabled:R,onToggle:()=>I(B.name)},B.name)})})})]})},j.id)}),(()=>{const j=y.get(null)??[];if(j.length===0)return null;const O=P.other??!1;return t.jsx("section",{className:"p-2",children:t.jsxs(pn,{open:!O,onOpenChange:()=>M("other"),children:[t.jsxs(gn,{className:"flex w-full items-center justify-between py-0.5 group",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[t.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:s("settings.usage.page.section.otherModels")}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",j.length,")"]})]}),O?t.jsx(A,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(hn,{children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:j.map(T=>{const B=Object.entries(T.windows.windows);if(B.length===0)return null;const[U,Q]=B[0],q=v.includes(T.name);return t.jsx(dr,{title:U,subtitle:Eo(T.name),window:Q,showToggle:!0,toggleEnabled:q,onToggle:()=>I(T.name)},T.name)})})})]})})})()]})]}),g?.configured&&k&&Object.keys(k.windows??{}).length===0&&N.length===0&&t.jsxs("div",{className:"mb-8 px-2",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.usage.page.state.noQuotaWindowsTitle")}),t.jsx("p",{className:"typography-meta text-muted-foreground mt-1",children:s("settings.usage.page.state.noQuotaWindowsDescription")})]})]})}):t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t.jsx("p",{className:"typography-body",children:s("settings.usage.page.empty.selectProvider")})})},sx="git.commit.generate",Or=rn(s=>({selectedPromptId:sx,setSelectedPromptId:e=>{s(n=>n.selectedPromptId===e?n:{selectedPromptId:e})}})),nx=s=>{const e=rt.c(23),{onItemSelect:n}=s,{t:a}=dt(),r=Or(ax),i=Or(rx);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={groupKey:"settings.magicPrompts.sidebar.group.git",items:[{id:"git.commit.generate",titleKey:"settings.magicPrompts.sidebar.item.gitCommitGenerate"},{id:"git.pr.generate",titleKey:"settings.magicPrompts.sidebar.item.gitPrGenerate"},{id:"git.conflict.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitConflictResolve"},{id:"git.integrate.cherrypick.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve"}]},e[0]=o):o=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={groupKey:"settings.magicPrompts.sidebar.group.github",items:[{id:"github.pr.review",titleKey:"settings.magicPrompts.sidebar.item.githubPrReview"},{id:"github.issue.review",titleKey:"settings.magicPrompts.sidebar.item.githubIssueReview"},{id:"github.pr.checks.review",titleKey:"settings.magicPrompts.sidebar.item.githubPrFailedChecksReview"},{id:"github.pr.comments.review",titleKey:"settings.magicPrompts.sidebar.item.githubPrCommentsReview"},{id:"github.pr.comment.single",titleKey:"settings.magicPrompts.sidebar.item.githubSinglePrCommentReview"}]},e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={groupKey:"settings.magicPrompts.sidebar.group.planning",items:[{id:"plan.todo",titleKey:"settings.magicPrompts.sidebar.item.planTodo"},{id:"plan.improve",titleKey:"settings.magicPrompts.sidebar.item.planImprove"},{id:"plan.implement",titleKey:"settings.magicPrompts.sidebar.item.planImplement"}]},e[2]=c):c=e[2];let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=[o,d,c,{groupKey:"settings.magicPrompts.sidebar.group.session",items:[{id:"session.explore",titleKey:"settings.magicPrompts.sidebar.item.sessionExplore"},{id:"session.summary",titleKey:"settings.magicPrompts.sidebar.item.sessionSummary"},{id:"session.review",titleKey:"settings.magicPrompts.sidebar.item.sessionWorkspaceReview"},{id:"session.plan",titleKey:"settings.magicPrompts.sidebar.item.sessionFeaturePlan"},{id:"session.catchup",titleKey:"settings.magicPrompts.sidebar.item.sessionCatchUp"},{id:"session.debug",titleKey:"settings.magicPrompts.sidebar.item.sessionDebug"},{id:"session.weigh",titleKey:"settings.magicPrompts.sidebar.item.sessionWeigh"},{id:"session.fusion",titleKey:"settings.magicPrompts.sidebar.item.sessionFusion"}]}],e[3]=x):x=e[3];const m=x;let p;e[4]!==a?(p=a("settings.magicPrompts.sidebar.title"),e[4]=a,e[5]=p):p=e[5];let u;e[6]!==p?(u=t.jsx("h2",{className:"text-base font-semibold text-foreground",children:p}),e[6]=p,e[7]=u):u=e[7];let C;e[8]!==a?(C=a("settings.magicPrompts.sidebar.description"),e[8]=a,e[9]=C):C=e[9];let f;e[10]!==C?(f=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:C}),e[10]=C,e[11]=f):f=e[11];let g;e[12]!==u||e[13]!==f?(g=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[u,f]}),e[12]=u,e[13]=f,e[14]=g):g=e[14];let h;e[15]!==n||e[16]!==r||e[17]!==i||e[18]!==a?(h=t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:m.map(k=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:a(k.groupKey)}),k.items.map(w=>{const E=r===w.id;return t.jsx("button",{type:"button",onClick:()=>{i(w.id),n?.()},className:ce("flex w-full items-center rounded-md px-2 py-1.5 text-left transition-colors",E?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-ui-label truncate font-normal",children:a(w.titleKey)})},w.id)})]},k.groupKey))}),e[15]=n,e[16]=r,e[17]=i,e[18]=a,e[19]=h):h=e[19];let D;return e[20]!==h||e[21]!==g?(D=t.jsxs("div",{className:"flex h-full flex-col bg-background",children:[g,h]}),e[20]=h,e[21]=g,e[22]=D):D=e[22],D};function ax(s){return s.selectedPromptId}function rx(s){return s.setSelectedPromptId}const Ro={"git.commit.generate":{titleKey:"settings.magicPrompts.page.group.gitCommitGenerate.title",descriptionKey:"settings.magicPrompts.page.group.gitCommitGenerate.description",blocks:[{id:"git.commit.generate.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.commit.generate.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.pr.generate":{titleKey:"settings.magicPrompts.page.group.gitPrGenerate.title",descriptionKey:"settings.magicPrompts.page.group.gitPrGenerate.description",blocks:[{id:"git.pr.generate.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.pr.generate.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.review":{titleKey:"settings.magicPrompts.page.group.githubPrReview.title",descriptionKey:"settings.magicPrompts.page.group.githubPrReview.description",blocks:[{id:"github.pr.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.issue.review":{titleKey:"settings.magicPrompts.page.group.githubIssueReview.title",descriptionKey:"settings.magicPrompts.page.group.githubIssueReview.description",blocks:[{id:"github.issue.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.issue.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.checks.review":{titleKey:"settings.magicPrompts.page.group.githubPrFailedChecksReview.title",descriptionKey:"settings.magicPrompts.page.group.githubPrFailedChecksReview.description",blocks:[{id:"github.pr.checks.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.checks.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.comments.review":{titleKey:"settings.magicPrompts.page.group.githubPrCommentsReview.title",descriptionKey:"settings.magicPrompts.page.group.githubPrCommentsReview.description",blocks:[{id:"github.pr.comments.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.comments.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.comment.single":{titleKey:"settings.magicPrompts.page.group.githubSinglePrCommentReview.title",descriptionKey:"settings.magicPrompts.page.group.githubSinglePrCommentReview.description",blocks:[{id:"github.pr.comment.single.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.comment.single.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.conflict.resolve":{titleKey:"settings.magicPrompts.page.group.gitConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitConflictResolve.description",blocks:[{id:"git.conflict.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.conflict.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.integrate.cherrypick.resolve":{titleKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.description",blocks:[{id:"git.integrate.cherrypick.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.integrate.cherrypick.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.improve":{titleKey:"settings.magicPrompts.page.group.planImprove.title",descriptionKey:"settings.magicPrompts.page.group.planImprove.description",blocks:[{id:"plan.improve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.improve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.todo":{titleKey:"settings.magicPrompts.page.group.planTodo.title",descriptionKey:"settings.magicPrompts.page.group.planTodo.description",blocks:[{id:"plan.todo.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.todo.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.implement":{titleKey:"settings.magicPrompts.page.group.planImplement.title",descriptionKey:"settings.magicPrompts.page.group.planImplement.description",blocks:[{id:"plan.implement.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.implement.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.summary":{titleKey:"settings.magicPrompts.page.group.sessionSummary.title",descriptionKey:"settings.magicPrompts.page.group.sessionSummary.description",blocks:[{id:"session.summary.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.summary.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.review":{titleKey:"settings.magicPrompts.page.group.sessionWorkspaceReview.title",descriptionKey:"settings.magicPrompts.page.group.sessionWorkspaceReview.description",blocks:[{id:"session.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.plan":{titleKey:"settings.magicPrompts.page.group.sessionFeaturePlan.title",descriptionKey:"settings.magicPrompts.page.group.sessionFeaturePlan.description",blocks:[{id:"session.plan.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.plan.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.catchup":{titleKey:"settings.magicPrompts.page.group.sessionCatchUp.title",descriptionKey:"settings.magicPrompts.page.group.sessionCatchUp.description",blocks:[{id:"session.catchup.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.catchup.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.debug":{titleKey:"settings.magicPrompts.page.group.sessionDebug.title",descriptionKey:"settings.magicPrompts.page.group.sessionDebug.description",blocks:[{id:"session.debug.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.debug.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.weigh":{titleKey:"settings.magicPrompts.page.group.sessionWeigh.title",descriptionKey:"settings.magicPrompts.page.group.sessionWeigh.description",blocks:[{id:"session.weigh.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.weigh.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.explore":{titleKey:"settings.magicPrompts.page.group.sessionExplore.title",descriptionKey:"settings.magicPrompts.page.group.sessionExplore.description",blocks:[{id:"session.explore.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.explore.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.fusion":{titleKey:"settings.magicPrompts.page.group.sessionFusion.title",descriptionKey:"settings.magicPrompts.page.group.sessionFusion.description",blocks:[{id:"session.fusion.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.fusion.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]}},To=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),mr=s=>s.endsWith(".visible"),ix=()=>{const{t:s}=dt(),e=l.useCallback(y=>s(y),[s]),n=Or(y=>y.selectedPromptId),[a,r]=l.useState(!0),[i,o]=l.useState({}),[d,c]=l.useState({}),[x,m]=l.useState({}),[p,u]=l.useState({}),[C,f]=l.useState(!1);l.useEffect(()=>{let y=!0;return(async()=>{r(!0);try{const P=await lm();if(!y)return;o(P)}catch(P){console.warn("Failed to load magic prompts:",P),_.error(s("settings.magicPrompts.page.toast.loadFailed"))}finally{y&&r(!1)}})(),()=>{y=!1}},[s]);const g=Ro[n]??Ro["git.commit.generate"],h=l.useCallback(y=>To(i,y)?i[y]:Ga(y),[i]),D=l.useCallback(y=>d[y]??h(y),[d,h]),k=l.useCallback((y,b)=>{c(P=>P[y]===b?P:{...P,[y]:b})},[]),w=l.useCallback(async y=>{const b=D(y);if(mr(y)&&b.trim().length===0){_.error(s("settings.magicPrompts.page.toast.visiblePromptRequired"));return}m(P=>({...P,[y]:!0}));try{const P=b===Ga(y)?await pi(y):await rm(y,b);o(P.overrides),_.success(s("settings.magicPrompts.page.toast.saved"))}catch(P){const z=P instanceof Error?P.message:String(P);_.error(s("settings.magicPrompts.page.toast.saveFailed"),{description:z})}finally{m(P=>({...P,[y]:!1}))}},[D,s]),E=l.useCallback(async y=>{u(b=>({...b,[y]:!0}));try{const b=await pi(y);o(b.overrides),c(P=>({...P,[y]:Ga(y)})),_.success(s("settings.magicPrompts.page.toast.resetSuccess"))}catch(b){const P=b instanceof Error?b.message:String(b);_.error(s("settings.magicPrompts.page.toast.resetFailed"),{description:P})}finally{u(b=>({...b,[y]:!1}))}},[s]),N=l.useCallback(async()=>{f(!0);try{const y=await im();o(y.overrides),c({}),_.success(s("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(y){const b=y instanceof Error?y.message:String(y);_.error(s("settings.magicPrompts.page.toast.resetAllFailed"),{description:b})}finally{f(!1)}},[s]);return a?t.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":s("settings.magicPrompts.page.loading.aria")}),t.jsx("span",{className:"typography-ui",children:s("settings.magicPrompts.page.loading.text")})]}):t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto w-full max-w-4xl px-6 py-6 space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsx("div",{className:"space-y-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground",children:e(g.titleKey)}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:e(g.descriptionKey)})]})]})}),t.jsx(J,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{N()},disabled:C||Object.keys(i).length===0,children:s(C?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")})]}),g.blocks.map((y,b)=>{const P=om(y.id),z=h(y.id),M=D(y.id),I=To(i,y.id),v=M!==z,j=mr(y.id)&&M.trim().length===0,O=x[y.id]===!0,T=p[y.id]===!0;return t.jsxs("section",{"data-settings-item":mr(y.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",className:b>0?"space-y-3 pt-5 border-t border-border":"space-y-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:e(y.titleKey)}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:P.description})]})]}),P.placeholders&&P.placeholders.length>0&&t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[s("settings.magicPrompts.page.placeholdersLabel")," ",P.placeholders.map(B=>`{{${B.key}}}`).join(", ")]})]}),t.jsx(hs,{value:M,onChange:B=>k(y.id,B.target.value),className:"min-h-[220px] font-mono text-sm"}),j&&t.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:s("settings.magicPrompts.page.validation.visiblePromptRequired")}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground",children:s(v?"settings.magicPrompts.page.status.unsavedChanges":I?"settings.magicPrompts.page.status.usingSavedOverride":"settings.magicPrompts.page.status.usingBuiltinDefault")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(J,{variant:"outline",size:"sm",onClick:()=>{E(y.id)},disabled:!I||O||T,children:s(T?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),t.jsx(J,{size:"sm",onClick:()=>{w(y.id)},disabled:!v||O||T||j,children:s(O?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},y.id)})]})})},ox=s=>{const e=rt.c(89),{onItemSelect:n}=s,{t:a}=dt(),[r,i]=l.useState(null),[o,d]=l.useState(null),[c,x]=l.useState(null),{selectedSnippetName:m,snippets:p,setSelectedSnippet:u,setSnippetDraft:C,deleteSnippet:f,loadSnippets:g}=Va(Ss(lx));let h,D;e[0]!==g?(h=()=>{g()},D=[g],e[0]=g,e[1]=h,e[2]=D):(h=e[1],D=e[2]),l.useEffect(h,D);let k;e[3]!==n||e[4]!==u||e[5]!==C||e[6]!==p?(k=async()=>{const se=new Set(p.map(cx));let ie="new-snippet",ge=1;for(;se.has(ie);)ie=`new-snippet-${ge++}`;C({name:ie,scope:"global"}),u(ie),n?.()},e[3]=n,e[4]=u,e[5]=C,e[6]=p,e[7]=k):k=e[7];const w=k;let E;e[8]!==r||e[9]!==f||e[10]!==a?(E=async()=>{if(!r)return;await f(r.name)?(_.success(a("settings.snippets.sidebar.toast.deleted")),i(null)):_.error(a("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=r,e[9]=f,e[10]=a,e[11]=E):E=e[11];const N=E;let y;e[12]!==p?(y=[...p].sort(dx),e[12]=p,e[13]=y):y=e[13];const b=y;let P;e[14]===Symbol.for("react.memo_cache_sentinel")?(P=ce("flex h-full flex-col","bg-background"),e[14]=P):P=e[14];let z;e[15]!==a?(z=a("settings.snippets.sidebar.title"),e[15]=a,e[16]=z):z=e[16];let M;e[17]!==z?(M=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:z}),e[17]=z,e[18]=M):M=e[18];let I;e[19]!==p.length||e[20]!==a?(I=a("settings.snippets.sidebar.total",{count:p.length}),e[19]=p.length,e[20]=a,e[21]=I):I=e[21];let v;e[22]!==I?(v=t.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[22]=I,e[23]=v):v=e[23];let j;e[24]!==a?(j=a("settings.snippets.sidebar.actions.create"),e[24]=a,e[25]=j):j=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),e[26]=O):O=e[26];let T;e[27]!==w||e[28]!==j?(T=t.jsx(J,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:w,"aria-label":j,children:O}),e[27]=w,e[28]=j,e[29]=T):T=e[29];let B;e[30]!==v||e[31]!==T?(B=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,T]}),e[30]=v,e[31]=T,e[32]=B):B=e[32];let U;e[33]!==B||e[34]!==M?(U=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[M,B]}),e[33]=B,e[34]=M,e[35]=U):U=e[35];let Q;if(e[36]!==n||e[37]!==o||e[38]!==c||e[39]!==m||e[40]!==u||e[41]!==b||e[42]!==a){let se;e[44]!==n||e[45]!==o||e[46]!==c||e[47]!==m||e[48]!==u||e[49]!==a?(se=ie=>t.jsxs(en,{open:c===ie.name,onOpenChange:ge=>x(ge?ie.name:null),children:[t.jsxs(tn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",m===ie.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:ge=>{ge.preventDefault(),x(ie.name)}}),children:[t.jsxs("button",{onClick:()=>{u(ie.name),n?.()},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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",ie.name]}),t.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:a(`snippets.source.${ie.source}`)})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:ie.description||ie.content.replace(/\s+/g," ").substring(0,80)})]}),t.jsxs(gs,{open:o===ie.name,onOpenChange:ge=>{ge&&x(null),d(ge?ie.name:null)},children:[t.jsx(us,{asChild:!0,children:t.jsx(J,{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","aria-label":a("settings.snippets.sidebar.actions.more",{name:ie.name}),children:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:t.jsxs(vs,{onClick:ge=>{ge.stopPropagation(),i(ie)},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]})})]})]}),t.jsx(sn,{className:"w-fit min-w-20",children:t.jsxs(qs,{onClick:ge=>{ge.stopPropagation(),i(ie)},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]})})]},`${ie.source}:${ie.filePath}`),e[44]=n,e[45]=o,e[46]=c,e[47]=m,e[48]=u,e[49]=a,e[50]=se):se=e[50],Q=b.map(se),e[36]=n,e[37]=o,e[38]=c,e[39]=m,e[40]=u,e[41]=b,e[42]=a,e[43]=Q}else Q=e[43];let q;e[51]!==Q?(q=t.jsx(Gt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:Q}),e[51]=Q,e[52]=q):q=e[52];const R=r!==null;let Y;e[53]===Symbol.for("react.memo_cache_sentinel")?(Y=se=>{se||i(null)},e[53]=Y):Y=e[53];let F;e[54]!==a?(F=a("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=a,e[55]=F):F=e[55];let W;e[56]!==F?(W=t.jsx(Ut,{children:F}),e[56]=F,e[57]=W):W=e[57];const X=r?.name??"";let re;e[58]!==a||e[59]!==X?(re=a("settings.snippets.sidebar.dialog.deleteDescription",{name:X}),e[58]=a,e[59]=X,e[60]=re):re=e[60];let Z;e[61]!==re?(Z=t.jsx(Wt,{children:re}),e[61]=re,e[62]=Z):Z=e[62];let de;e[63]!==W||e[64]!==Z?(de=t.jsxs(_t,{children:[W,Z]}),e[63]=W,e[64]=Z,e[65]=de):de=e[65];let le;e[66]===Symbol.for("react.memo_cache_sentinel")?(le=()=>i(null),e[66]=le):le=e[66];let ee;e[67]!==a?(ee=a("settings.common.actions.cancel"),e[67]=a,e[68]=ee):ee=e[68];let xe;e[69]!==ee?(xe=t.jsx(J,{size:"sm",variant:"ghost",onClick:le,children:ee}),e[69]=ee,e[70]=xe):xe=e[70];let we;e[71]!==a?(we=a("settings.common.actions.delete"),e[71]=a,e[72]=we):we=e[72];let he;e[73]!==N||e[74]!==we?(he=t.jsx(J,{size:"sm",onClick:N,children:we}),e[73]=N,e[74]=we,e[75]=he):he=e[75];let Ie;e[76]!==xe||e[77]!==he?(Ie=t.jsxs(Yt,{children:[xe,he]}),e[76]=xe,e[77]=he,e[78]=Ie):Ie=e[78];let be;e[79]!==de||e[80]!==Ie?(be=t.jsxs(Bt,{className:"max-w-md",children:[de,Ie]}),e[79]=de,e[80]=Ie,e[81]=be):be=e[81];let je;e[82]!==R||e[83]!==be?(je=t.jsx($t,{open:R,onOpenChange:Y,children:be}),e[82]=R,e[83]=be,e[84]=je):je=e[84];let ye;return e[85]!==U||e[86]!==q||e[87]!==je?(ye=t.jsxs("div",{className:P,children:[U,q,je]}),e[85]=U,e[86]=q,e[87]=je,e[88]=ye):ye=e[88],ye};function lx(s){return{selectedSnippetName:s.selectedSnippetName,snippets:s.snippets,setSelectedSnippet:s.setSelectedSnippet,setSnippetDraft:s.setSnippetDraft,deleteSnippet:s.deleteSnippet,loadSnippets:s.loadSnippets}}function cx(s){return s.name}function dx(s,e){return s.name.localeCompare(e.name)}const mx=()=>{const{t:s}=dt(),{selectedSnippetName:e,snippets:n,snippetDraft:a,setSnippetDraft:r,updateSnippet:i,createSnippet:o}=Va(Ss(P=>({selectedSnippetName:P.selectedSnippetName,snippets:P.snippets,snippetDraft:P.snippetDraft,setSnippetDraft:P.setSnippetDraft,updateSnippet:P.updateSnippet,createSnippet:P.createSnippet}))),d=l.useMemo(()=>e?n.find(P=>P.name===e||P.aliases.includes(e))??null:null,[e,n]),c=!!(a&&a.name===e&&!d),[x,m]=l.useState(""),[p,u]=l.useState("global"),[C,f]=l.useState(""),[g,h]=l.useState(""),[D,k]=l.useState(""),[w,E]=l.useState(!1),N=l.useRef(null);l.useEffect(()=>{if(c&&a){const P={draftName:a.name||"",draftScope:a.scope||"global",description:a.description||"",aliases:(a.aliases||[]).join(", "),content:a.content||""};m(P.draftName),u(P.draftScope),f(P.description),h(P.aliases),k(P.content),N.current=P}else if(d){const P={draftName:"",draftScope:"global",description:d.description??"",aliases:d.aliases.join(", "),content:d.content};f(P.description),h(P.aliases),k(P.content),N.current=P}},[d,c,e,a]);const y=l.useMemo(()=>{const P=N.current;return P?c&&x!==P.draftName||c&&p!==P.draftScope?!0:C!==P.description||g!==P.aliases||D!==P.content:!1},[g,D,C,x,p,c]),b=async()=>{const P=c?x.trim().replace(/\s+/g,"-"):e?.trim();if(!P){_.error(s("settings.snippets.page.toast.nameRequired"));return}if(!D.trim()){_.error(s("settings.snippets.page.toast.contentRequired"));return}const z=g.split(",").map(M=>M.trim()).filter(Boolean);E(!0);try{if(!(c?await o(P,D,{aliases:z,description:C,scope:p}):await i(P,{content:D,aliases:z,description:C}))){_.error(s("settings.snippets.page.toast.saveFailed"));return}_.success(s("settings.snippets.page.toast.saved")),c&&r(null)}finally{E(!1)}};return e?t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4 min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:c?s("settings.snippets.page.title.new"):`#${e}`}),d?t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:d.filePath}):null]}),t.jsxs("div",{className:"mb-8 space-y-3 px-2",children:[t.jsxs("div",{children:[c?t.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"#"}),t.jsx(ot,{value:x,onChange:P=>m(P.target.value),placeholder:s("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),t.jsxs(Mt,{value:p,onValueChange:P=>u(P),children:[t.jsx(Rt,{className:"w-fit min-w-[100px]",children:t.jsx(Kt,{})}),t.jsxs(Tt,{align:"end",children:[t.jsx(gt,{value:"global",children:s("settings.common.scope.global")}),t.jsx(gt,{value:"project",children:s("settings.common.scope.project")})]})]})]}):null,t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.common.field.description")}),t.jsx(ot,{value:C,onChange:P=>f(P.target.value),placeholder:s("settings.snippets.page.field.descriptionPlaceholder"),className:"mt-1.5 h-7 w-full max-w-sm px-2"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.snippets.page.field.aliases")}),t.jsx(ot,{value:g,onChange:P=>h(P.target.value),placeholder:s("settings.snippets.page.field.aliasesPlaceholder"),className:"mt-1.5 h-7 w-full max-w-sm px-2"})]})]}),t.jsxs("div",{"data-settings-item":"snippets.content",className:"mb-2 px-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.snippets.page.field.content")}),t.jsx(hs,{value:D,onChange:P=>k(P.target.value),placeholder:s("settings.snippets.page.field.contentPlaceholder"),rows:12,className:"mt-1.5 w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),t.jsx("p",{className:"mt-2 typography-meta text-muted-foreground",children:s("settings.snippets.page.hint")})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(J,{onClick:b,disabled:w||!y,size:"xs",className:"!font-normal",children:s(w?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(A,{name:"file-text",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.snippets.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.snippets.page.empty.description")})]})})},Wl=()=>{const{t:s}=dt(),e=ut(p=>p.settingsGitmojiEnabled),n=ut(p=>p.setSettingsGitmojiEnabled),a=Bm(),r=Ke(p=>p.gitChangesViewMode),i=Ke(p=>p.setGitChangesViewMode),[o,d]=l.useState(!0),c=l.useMemo(()=>[{id:"flat",label:s("settings.openchamber.git.option.flatList")},{id:"tree",label:s("settings.openchamber.git.option.treeView")}],[s]);l.useEffect(()=>{(async()=>{try{let u=null;if(!u){const C=zs()?.settings;if(C)try{const g=(await C.load())?.settings;g&&(u={gitmojiEnabled:typeof g.gitmojiEnabled=="boolean"?g.gitmojiEnabled:void 0,gitChangesViewMode:g.gitChangesViewMode==="flat"||g.gitChangesViewMode==="tree"?g.gitChangesViewMode:void 0})}catch{}}if(!u){const C=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});C.ok&&(u=await C.json())}u&&(typeof u.gitmojiEnabled=="boolean"&&n(u.gitmojiEnabled),(u.gitChangesViewMode==="flat"||u.gitChangesViewMode==="tree")&&i(u.gitChangesViewMode))}catch(u){console.warn("Failed to load git settings:",u)}finally{d(!1)}})()},[i,n]);const x=l.useCallback(async p=>{n(p);try{await Ct({gitmojiEnabled:p})}catch(u){console.warn("Failed to save gitmoji setting:",u)}},[n]),m=l.useCallback(p=>{p!==r&&(i(p),Ct({gitChangesViewMode:p}))},[r,i]);return o?null:t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.git.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{"data-settings-item":"git.changes-view",className:"pt-1 pb-1",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.git.changesViewTitle")}),t.jsx("div",{role:"radiogroup","aria-label":s("settings.openchamber.git.changesViewAria"),className:"mt-0.5 space-y-0",children:c.map(p=>{const u=r===p.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":u,onClick:()=>{m(p.id)},onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),m(p.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Cn,{checked:u,onChange:()=>{m(p.id)},ariaLabel:s("settings.openchamber.git.optionAria",{option:p.label})}),t.jsx("span",{className:u?"typography-ui-label font-normal text-foreground":"typography-ui-label font-normal text-foreground/50",children:p.label})]},p.id)})})]}),t.jsxs("div",{"data-settings-item":"git.gitmoji",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":e,onClick:()=>{x(!e)},onKeyDown:p=>{(p.key===" "||p.key==="Enter")&&(p.preventDefault(),x(!e))},children:[t.jsx(St,{checked:e,onChange:p=>{x(p)},ariaLabel:s("settings.openchamber.git.enableGitmojiAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.git.enableGitmoji")})]}),t.jsxs("div",{"data-settings-item":"git.gitignored-files",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":a,onClick:()=>Xa(!a),onKeyDown:p=>{(p.key===" "||p.key==="Enter")&&(p.preventDefault(),Xa(!a))},children:[t.jsx(St,{checked:a,onChange:Xa,ariaLabel:s("settings.openchamber.git.showGitignoredAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.git.showGitignored")})]})]})]})},ql=()=>{const{t:s}=dt(),{isMobile:e}=Cs(),n=zs()?.github,a=_s(v=>v.status),r=_s(v=>v.isLoading),i=_s(v=>v.hasChecked),o=_s(v=>v.refreshStatus),d=_s(v=>v.setStatus),c=l.useCallback(async v=>{await Ws(v)},[]),[x,m]=l.useState(!1),[p,u]=l.useState(null),[C,f]=l.useState(null),g=l.useRef(null),h=l.useCallback(()=>{g.current!=null&&(window.clearInterval(g.current),g.current=null),f(null)},[]);l.useEffect(()=>((async()=>{try{i||await o(n)}catch(v){console.warn("Failed to load GitHub auth status:",v)}})(),()=>{h()}),[i,o,n,h]);const D=l.useCallback(async()=>{m(!0);try{const v=n?await n.authStart():await(async()=>{const O=await yt("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),T=await O.json().catch(()=>null);if(!O.ok||!T||!("deviceCode"in T))throw new Error(T?.error||O.statusText);return T})();u(v),f(Math.max(1,v.interval)*1e3);const j=v.verificationUriComplete||v.verificationUri;c(j)}catch(v){console.error("Failed to start GitHub connect:",v),_.error(s("settings.github.page.toast.startConnectFailed"))}finally{m(!1)}},[c,n,s]),k=l.useCallback(async v=>{if(n)return n.authComplete(v);const j=await yt("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:v})}),O=await j.json().catch(()=>null);if(!j.ok||!O)throw new Error(O?.error||j.statusText);return O},[n]);l.useEffect(()=>{if(!(!p?.deviceCode||!C)&&g.current==null)return g.current=window.setInterval(()=>{(async()=>{try{const v=await k(p.deviceCode);if(v.connected){_.success(s("settings.github.page.toast.connected")),u(null),h(),await o(n,{force:!0});return}v.status==="slow_down"&&f(j=>j?j+5e3:5e3),(v.status==="expired_token"||v.status==="access_denied")&&(_.error(v.error||s("settings.github.page.toast.authorizationFailed")),u(null),h())}catch(v){console.warn("GitHub polling failed:",v)}})()},C),()=>{g.current!=null&&(window.clearInterval(g.current),g.current=null)}},[p,C,k,o,n,h,s]);const w=l.useCallback(async v=>{m(!0);try{if(n)await n.authSetGhCliDisabled(v);else{const j=await yt("/api/github/auth/gh-cli",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({disabled:v})}),O=await j.json().catch(()=>null);if(!j.ok)throw new Error(O?.error||j.statusText)}_.success(s(v?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled")),await o(n,{force:!0})}catch(j){console.error("Failed to update gh CLI setting:",j),_.error(s("settings.github.page.toast.ghCliUpdateFailed"))}finally{m(!1)}},[o,n,s]),E=l.useCallback(async()=>{m(!0);try{if(h(),u(null),n)await n.authDisconnect();else{const v=await yt("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}});if(!v.ok)throw new Error(v.statusText)}_.success(s("settings.github.page.toast.disconnected")),await o(n,{force:!0})}catch(v){console.error("Failed to disconnect GitHub:",v),_.error(s("settings.github.page.toast.disconnectFailed"))}finally{m(!1)}},[o,n,h,s]),N=l.useCallback(async v=>{if(v){m(!0);try{const j=n?await n.authActivate(v):await(async()=>{const O=await yt("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:v})}),T=await O.json().catch(()=>null);if(!O.ok||!T)throw new Error(T?.error||O.statusText);return T})();d(j),_.success(s("settings.github.page.toast.accountSwitched"))}catch(j){console.error("Failed to switch GitHub account:",j),_.error(s("settings.github.page.toast.accountSwitchFailed"))}finally{m(!1)}}},[n,d,s]);if(r)return null;const y=!!a?.connected,b=a?.user,z=(a?.accounts??[]).filter(v=>!v.current),M=a?.ghCli??null,I=M?.active?s("settings.github.page.accountSource.cli"):s("settings.github.page.accountSource.oauth");return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-3 px-1 flex items-start justify-between gap-4",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.github.page.oauth.title")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.github.page.tooltip.connectAccount")})]})]})}),t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[y?t.jsxs("div",{className:ce("px-4 py-3",e?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[t.jsxs("div",{className:ce("flex min-w-0 items-center gap-4",e?"w-full":void 0),children:[b?.avatarUrl?t.jsx("img",{src:b.avatarUrl,alt:b.login?s("settings.github.page.avatarAlt.withLogin",{login:b.login}):s("settings.github.page.avatarAlt.fallback"),className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):t.jsx("div",{className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:b?.name?.trim()||b?.login||"GitHub"}),t.jsxs("div",{className:ce("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",e?"flex-wrap":"truncate"),children:[t.jsx(A,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"font-mono",children:b?.login||s("settings.github.page.label.unknownUser")}),b?.email&&t.jsx("span",{className:"opacity-50",children:"•"}),b?.email&&t.jsx("span",{children:b.email}),t.jsx("span",{className:"opacity-50",children:"•"}),t.jsx("span",{children:I})]}),a?.scope&&t.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:s("settings.github.page.label.scopes",{value:a.scope})}),M?.active&&t.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:s("settings.github.page.ghCli.activeDescription")})]})]}),M?.active?t.jsx(J,{size:"sm",variant:"outline",onClick:()=>w(!0),disabled:x,className:ce(e?"w-full":void 0),children:s("settings.github.page.ghCli.actions.disable")}):t.jsx(J,{size:"sm",variant:"outline",onClick:E,disabled:x,className:ce("text-[var(--status-error)] hover:text-[var(--status-error)]",e?"w-full":void 0),children:s("settings.github.page.actions.disconnect")})]}):t.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-4",children:[t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.github.page.status.notConnected")})}),t.jsx(J,{size:"sm",variant:"default",onClick:D,disabled:x,children:s("settings.github.page.actions.connect")})]}),z.length>0&&t.jsxs("div",{className:"mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1",children:[t.jsx("div",{className:"typography-micro text-muted-foreground mb-2 px-1",children:s("settings.github.page.label.otherAccounts")}),t.jsx("div",{className:"space-y-1",children:z.map(v=>{const j=v.user,O=v.source==="gh-cli"?s("settings.github.page.accountSource.cli"):s("settings.github.page.accountSource.oauth");return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[j?.avatarUrl?t.jsx("img",{src:j.avatarUrl,alt:j.login?s("settings.github.page.avatarAlt.withLogin",{login:j.login}):s("settings.github.page.avatarAlt.fallback"),className:"h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):t.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:t.jsx(A,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),t.jsxs("div",{className:"min-w-0 flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:j?.name?.trim()||j?.login||"GitHub"}),j?.login&&t.jsxs("span",{className:"typography-micro text-muted-foreground truncate",children:[t.jsx("span",{className:"font-mono",children:j.login}),t.jsx("span",{className:"mx-1 opacity-50",children:"·"}),t.jsx("span",{children:O})]})]})]}),t.jsx(J,{size:"sm",variant:"ghost",onClick:()=>N(v.id),disabled:x,children:s("settings.github.page.actions.switchTo")})]},v.id)})})]})]}),y&&t.jsx("div",{className:"mt-2 px-2 pb-2",children:t.jsx(J,{size:"sm",variant:"outline",onClick:D,disabled:x,className:ce(e?"w-full":void 0),children:s("settings.github.page.actions.addAccount")})}),p&&t.jsxs("div",{className:"mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h4",{className:"typography-ui-label text-foreground",children:s("settings.github.page.flow.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.github.page.flow.description")})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3 mt-4",children:[t.jsx("div",{className:"font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]",children:p.userCode}),t.jsx(J,{size:"sm",asChild:!0,children:t.jsx("a",{href:p.verificationUriComplete||p.verificationUri,target:"_blank",rel:"noopener noreferrer",children:s("settings.github.page.actions.openGithub")})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[t.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:s("settings.github.page.flow.waiting")}),t.jsx(J,{size:"sm",variant:"ghost",disabled:x,onClick:()=>{h(),u(null)},children:s("settings.common.actions.cancel")})]})]}),M?.available&&!M?.active&&(!M.user||M.disabled)&&t.jsxs("div",{className:"mt-6",children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground mb-3 px-1",children:s("settings.github.page.ghCli.title")}),t.jsx("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden",children:t.jsxs("div",{className:ce("px-4 py-3",e?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[t.jsxs("div",{className:ce("flex min-w-0 items-center gap-4",e?"w-full":void 0),children:[M.user?.avatarUrl?t.jsx("img",{src:M.user.avatarUrl,alt:M.user.login?s("settings.github.page.avatarAlt.withLogin",{login:M.user.login}):s("settings.github.page.avatarAlt.fallback"),className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):t.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:t.jsx(A,{name:"github-fill",className:"h-4 w-4 text-muted-foreground"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[!M.disabled&&M.user&&t.jsx("div",{className:"typography-ui-label text-foreground truncate",children:M.user.name?.trim()||M.user.login||"GitHub"}),!M.disabled&&M.user?.login&&t.jsxs("div",{className:ce("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",e?"flex-wrap":"truncate"),children:[t.jsx(A,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"font-mono",children:M.user.login}),M.user.email&&t.jsx("span",{className:"opacity-50",children:"•"}),M.user.email&&t.jsx("span",{children:M.user.email})]}),t.jsx("div",{className:ce("typography-meta text-muted-foreground",M.disabled?"opacity-60":void 0),children:M.disabled?s("settings.github.page.ghCli.disabledDescription"):s("settings.github.page.ghCli.fallbackDescription")})]})]}),t.jsx(J,{size:"sm",variant:"outline",onClick:()=>w(!M.disabled),disabled:x,className:ce(e?"w-full":void 0),children:M.disabled?s("settings.github.page.ghCli.actions.enable"):s("settings.github.page.ghCli.actions.disable")})]})})]})]})},Fo=[{key:"keyword",label:"Green",cssVar:"var(--syntax-keyword)"},{key:"error",label:"Red",cssVar:"var(--status-error)"},{key:"string",label:"Cyan",cssVar:"var(--syntax-string)"},{key:"function",label:"Orange",cssVar:"var(--syntax-function)"},{key:"type",label:"Yellow",cssVar:"var(--syntax-type)"}],ux=[{key:"branch",Icon:"git-branch",label:"Branch"},{key:"briefcase",Icon:"briefcase",label:"Work"},{key:"house",Icon:"home",label:"Personal"},{key:"graduation",Icon:"graduation-cap",label:"School"},{key:"code",Icon:"code",label:"Code"}],px=({open:s,onOpenChange:e,profileId:n,importData:a})=>{const{t:r}=dt(),i=ks(Z=>Z.getProfileById),o=ks(Z=>Z.createProfile),d=ks(Z=>Z.updateProfile),c=ks(Z=>Z.deleteProfile),x=l.useMemo(()=>n&&n!=="new"&&!a?i(n):null,[n,i,a]),m=n==="new"||a!=null,p=n==="global",[u,C]=l.useState(""),[f,g]=l.useState(""),[h,D]=l.useState(""),[k,w]=l.useState("ssh"),[E,N]=l.useState(""),[y,b]=l.useState(!1),[P,z]=l.useState(""),[M,I]=l.useState(""),[v,j]=l.useState("keyword"),[O,T]=l.useState("branch"),[B,U]=l.useState(!1),[Q,q]=l.useState(!1),[R,Y]=l.useState(!1);l.useEffect(()=>{if(s){if(a){const Z=a.host.split("/"),de=Z.length>=3?Z[Z.length-1]:a.host;C(de),g(a.username),D(""),w("token"),N(""),b(!1),z(""),I(a.host),j("string"),T("code")}else if(m)C(""),g(""),D(""),w("ssh"),N(""),b(!1),z(""),I(""),j("keyword"),T("branch");else if(x)C(x.name),g(x.userName),D(x.userEmail),w(x.authType||"ssh"),N(x.sshKey||""),b(x.signCommits===!0),z(x.signingKey||""),I(x.host||""),j(x.color||"keyword"),T(x.icon||"branch");else if(p){const Z=i("global");Z&&(C(Z.name),g(Z.userName),D(Z.userEmail),w(Z.authType||"ssh"),N(Z.sshKey||""),b(!1),z(""),I(Z.host||""),j(Z.color||"keyword"),T(Z.icon||"branch"))}}},[s,n,x,m,a,p,i]);const F=async()=>{if(!f.trim()||!h.trim()){_.error(r("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(k==="token"&&!M.trim()){_.error(r("settings.gitIdentities.editor.toast.hostRequiredForToken"));return}if(y&&!P.trim()){_.error(r("settings.gitIdentities.editor.toast.signingKeyRequired"));return}U(!0);try{const Z={name:u.trim()||f.trim(),userName:f.trim(),userEmail:h.trim(),authType:k,sshKey:k==="ssh"&&E.trim()||null,signCommits:y,signingKey:P.trim()||null,host:k==="token"&&M.trim()||null,color:v,icon:O};let de;if(m)de=await o(Z);else if(n)de=await d(n,Z);else return;de?(_.success(r(m?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):_.error(r(m?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(Z){console.error("Error saving profile:",Z),_.error(r("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{U(!1)}},W=async()=>{if(!(!n||m)){Y(!0);try{await c(n)?(_.success(r("settings.gitIdentities.editor.toast.profileDeleted")),q(!1),e(!1)):_.error(r("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(Z){console.error("Error deleting profile:",Z),_.error(r("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{Y(!1)}}},X=l.useMemo(()=>Fo.find(de=>de.key===v)?.cssVar||"var(--syntax-keyword)",[v]),re=a?r("settings.gitIdentities.editor.title.importCredential"):m?r("settings.gitIdentities.editor.title.newIdentity"):p?r("settings.gitIdentities.editor.title.globalIdentity"):x?.name||r("settings.gitIdentities.editor.title.editIdentity");return t.jsxs(t.Fragment,{children:[t.jsx($t,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:re}),t.jsx(Wt,{children:r(p?"settings.gitIdentities.editor.description.globalReadOnly":m?"settings.gitIdentities.editor.description.newProfile":"settings.gitIdentities.editor.description.editProfile")})]}),t.jsxs("div",{className:"space-y-5 py-2",children:[!p&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"typography-ui-label text-foreground block mb-1.5",children:r("settings.gitIdentities.editor.field.profileName")}),t.jsx(ot,{value:u,onChange:Z=>C(Z.target.value),placeholder:r("settings.gitIdentities.editor.field.profileNamePlaceholder"),className:"h-8"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.color")}),t.jsx("div",{className:"flex gap-1.5",children:Fo.map(Z=>t.jsx("button",{type:"button",onClick:()=>j(Z.key),className:ce("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",v===Z.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:Z.cssVar},title:Z.label},Z.key))})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.icon")}),t.jsx("div",{className:"flex gap-1.5",children:ux.map(Z=>{const de=Z.Icon;return t.jsx("button",{type:"button",onClick:()=>T(Z.key),className:ce("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",O===Z.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:Z.label,children:t.jsx(A,{name:de,className:"w-3.5 h-3.5",style:{color:O===Z.key?X:"var(--surface-muted-foreground)"}})},Z.key)})})]})]}),!p&&t.jsx("div",{className:"border-t border-border/40"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.userName")}),!p&&t.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.userNameTooltip")})]})]}),t.jsx(ot,{value:f,onChange:Z=>g(Z.target.value),placeholder:r("settings.gitIdentities.editor.field.userNamePlaceholder"),required:!p,readOnly:p,disabled:p,className:"h-8"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.emailAddress")}),!p&&t.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.emailAddressTooltip")})]})]}),t.jsx(ot,{type:"email",value:h,onChange:Z=>D(Z.target.value),placeholder:r("settings.gitIdentities.editor.field.emailAddressPlaceholder"),required:!p,readOnly:p,disabled:p,className:"h-8"})]})]}),!p&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border/40"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.authMethod")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(J,{size:"sm",type:"button",variant:"chip","aria-pressed":k==="ssh",onClick:()=>w("ssh"),children:[t.jsx(A,{name:"lock-2",className:"w-3.5 h-3.5 mr-1"})," SSH"]}),t.jsxs(J,{size:"sm",type:"button",variant:"chip","aria-pressed":k==="token",onClick:()=>w("token"),children:[t.jsx(A,{name:"key",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.gitIdentities.editor.field.authToken")]})]})]}),k==="ssh"&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.sshKeyPath")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.sshKeyPathTooltip")})]})]}),t.jsx(ot,{value:E,onChange:Z=>N(Z.target.value),placeholder:r("settings.gitIdentities.editor.field.sshKeyPathPlaceholder"),className:"h-8 font-mono text-xs"})]}),t.jsxs("div",{className:"border-t border-border/40 pt-3 space-y-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(St,{checked:y,onChange:b,ariaLabel:r("settings.gitIdentities.editor.field.signCommits")}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.signCommits")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:r("settings.gitIdentities.editor.section.commitSigning")})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.signingKey")})}),t.jsx(ot,{value:P,onChange:Z=>z(Z.target.value),placeholder:r("settings.gitIdentities.editor.field.signingKeyPlaceholder"),disabled:!y,className:"h-8 font-mono text-xs"})]})]}),k==="token"&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.host")}),t.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.hostTooltip")})]})]}),t.jsx(ot,{value:M,onChange:Z=>I(Z.target.value),placeholder:r("settings.gitIdentities.editor.field.hostPlaceholder"),required:!0,className:"h-8 font-mono text-xs"})]})]})]})]}),t.jsxs(Yt,{className:"gap-2",children:[!p&&!m&&t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>q(!0),className:"text-[var(--status-error)] hover:text-[var(--status-error)] border-[var(--status-error)]/30 hover:bg-[var(--status-error)]/10 mr-auto",children:[t.jsx(A,{name:"delete-bin",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.common.actions.delete")]}),t.jsx(J,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"text-foreground hover:bg-interactive-hover hover:text-foreground",children:r(p?"settings.gitIdentities.editor.actions.close":"settings.common.actions.cancel")}),!p&&t.jsx(J,{size:"sm",onClick:F,disabled:B,children:r(B?"settings.common.actions.saving":m?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})}),t.jsx($t,{open:Q,onOpenChange:Z=>{R||q(Z)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Ut,{children:r("settings.gitIdentities.page.deleteDialog.title")}),t.jsx(Wt,{children:r("settings.gitIdentities.page.deleteDialog.description",{name:x?.name||u})})]}),t.jsxs(Yt,{children:[t.jsx(J,{variant:"ghost",onClick:()=>q(!1),disabled:R,children:r("settings.common.actions.cancel")}),t.jsx(J,{size:"sm",variant:"destructive",onClick:()=>{W()},disabled:R,children:r("settings.common.actions.delete")})]})]})})]})},gx={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart"},hx={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},fx=()=>{const s=rt.c(118),{t:e}=dt(),{profiles:n,globalIdentity:a,defaultGitIdentityId:r,deleteProfile:i,loadProfiles:o,loadGlobalIdentity:d,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:x,setDefaultGitIdentityId:m,getUnimportedCredentials:p}=ks(Ss(bx)),[u,C]=l.useState(!1),[f,g]=l.useState(null),[h,D]=l.useState(null),[k,w]=l.useState(null),[E,N]=l.useState(!1);let y,b;s[0]!==x||s[1]!==c||s[2]!==d||s[3]!==o?(y=()=>{o(),d(),c(),x()},b=[o,d,c,x],s[0]=x,s[1]=c,s[2]=d,s[3]=o,s[4]=y,s[5]=b):(y=s[4],b=s[5]),l.useEffect(y,b);let P,z,M,I,v,j,O,T,B,U,Q,q,R,Y;if(s[6]!==r||s[7]!==k||s[8]!==i||s[9]!==p||s[10]!==a||s[11]!==n||s[12]!==m||s[13]!==e){const Re=p();let Ae;s[28]===Symbol.for("react.memo_cache_sentinel")?(Ae=(Ne,Ee)=>{g(Ne),D(Ee??null),C(!0)},s[28]=Ae):Ae=s[28];const Pe=Ae;let Te;s[29]!==r||s[30]!==m||s[31]!==e?(Te=async Ne=>{const Ee=r===Ne?null:Ne;if(!await m(Ee)){_.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}_.success(e(Ee?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},s[29]=r,s[30]=m,s[31]=e,s[32]=Te):Te=s[32];const Fe=Te;let Be;s[33]!==k||s[34]!==i||s[35]!==e?(Be=async()=>{if(!k)return;N(!0),await i(k.id)?(_.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:k.name})),w(null)):_.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),N(!1)},s[33]=k,s[34]=i,s[35]=e,s[36]=Be):Be=s[36],z=Be,P=Gt,v="h-full",j="w-full bg-background",M="mx-auto w-full max-w-3xl space-y-6 p-3 sm:p-6 sm:pt-8",s[37]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("div",{"data-settings-item":"git.github-account",children:t.jsx(ql,{})}),s[37]=I):I=s[37],q="git.identities",R="border-t border-border/40 pt-6";let We;s[38]!==e?(We=e("settings.gitIdentities.page.section.title"),s[38]=e,s[39]=We):We=s[39];let ze;s[40]!==We?(ze=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:We})}),s[40]=We,s[41]=ze):ze=s[41];let Qe,oe;s[42]===Symbol.for("react.memo_cache_sentinel")?(Qe=()=>Pe("new"),oe=t.jsx(A,{name:"add",className:"w-3.5 h-3.5 mr-1"}),s[42]=Qe,s[43]=oe):(Qe=s[42],oe=s[43]);let H;s[44]!==e?(H=e("settings.common.badge.new"),s[44]=e,s[45]=H):H=s[45];let me;s[46]!==H?(me=t.jsxs(J,{size:"sm",variant:"outline",onClick:Qe,children:[oe," ",H]}),s[46]=H,s[47]=me):me=s[47],s[48]!==ze||s[49]!==me?(Y=t.jsxs("div",{className:"mb-3 px-1 flex items-start justify-between gap-4",children:[ze,me]}),s[48]=ze,s[49]=me,s[50]=Y):Y=s[50],O="rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",T=a&&t.jsx(Oo,{profile:a,isDefault:r==="global",onEdit:()=>Pe("global"),onToggleDefault:()=>Fe("global"),isReadOnly:!0,hasBorder:n.length>0||Re.length>0}),B=n.map((Ne,Ee)=>t.jsx(Oo,{profile:Ne,isDefault:r===Ne.id,onEdit:()=>Pe(Ne.id),onToggleDefault:()=>Fe(Ne.id),onDelete:()=>w(Ne),hasBorder:Ee<n.length-1||Re.length>0},Ne.id)),U=!a&&n.length===0&&Re.length===0&&t.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[t.jsx(A,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),t.jsx("p",{className:"typography-ui-label",children:e("settings.gitIdentities.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.gitIdentities.page.empty.description")})]}),Q=Re.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-4 py-2 border-t border-[var(--surface-subtle)]",children:t.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.gitIdentities.page.discoveredCredentials.title")})}),Re.map((Ne,Ee)=>t.jsx(xx,{credential:Ne,onImport:()=>Pe("new",{host:Ne.host,username:Ne.username}),hasBorder:Ee<Re.length-1},`${Ne.host}-${Ne.username}`))]}),s[6]=r,s[7]=k,s[8]=i,s[9]=p,s[10]=a,s[11]=n,s[12]=m,s[13]=e,s[14]=P,s[15]=z,s[16]=M,s[17]=I,s[18]=v,s[19]=j,s[20]=O,s[21]=T,s[22]=B,s[23]=U,s[24]=Q,s[25]=q,s[26]=R,s[27]=Y}else P=s[14],z=s[15],M=s[16],I=s[17],v=s[18],j=s[19],O=s[20],T=s[21],B=s[22],U=s[23],Q=s[24],q=s[25],R=s[26],Y=s[27];let F;s[51]!==O||s[52]!==T||s[53]!==B||s[54]!==U||s[55]!==Q?(F=t.jsxs("div",{className:O,children:[T,B,U,Q]}),s[51]=O,s[52]=T,s[53]=B,s[54]=U,s[55]=Q,s[56]=F):F=s[56];let W;s[57]!==F||s[58]!==q||s[59]!==R||s[60]!==Y?(W=t.jsxs("div",{"data-settings-item":q,className:R,children:[Y,F]}),s[57]=F,s[58]=q,s[59]=R,s[60]=Y,s[61]=W):W=s[61];let X;s[62]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(Wl,{}),s[62]=X):X=s[62];let re;s[63]!==M||s[64]!==I||s[65]!==W?(re=t.jsxs("div",{className:M,children:[I,W,X]}),s[63]=M,s[64]=I,s[65]=W,s[66]=re):re=s[66];let Z;s[67]!==P||s[68]!==v||s[69]!==j||s[70]!==re?(Z=t.jsx(P,{outerClassName:v,className:j,children:re}),s[67]=P,s[68]=v,s[69]=j,s[70]=re,s[71]=Z):Z=s[71];let de;s[72]!==h||s[73]!==u||s[74]!==f?(de=t.jsx(px,{open:u,onOpenChange:C,profileId:f,importData:h}),s[72]=h,s[73]=u,s[74]=f,s[75]=de):de=s[75];const le=k!==null;let ee;s[76]!==E?(ee=Re=>{E||Re||w(null)},s[76]=E,s[77]=ee):ee=s[77];let xe;s[78]!==e?(xe=e("settings.gitIdentities.page.deleteDialog.title"),s[78]=e,s[79]=xe):xe=s[79];let we;s[80]!==xe?(we=t.jsx(Ut,{children:xe}),s[80]=xe,s[81]=we):we=s[81];const he=k?.name??"";let Ie;s[82]!==e||s[83]!==he?(Ie=e("settings.gitIdentities.page.deleteDialog.description",{name:he}),s[82]=e,s[83]=he,s[84]=Ie):Ie=s[84];let be;s[85]!==Ie?(be=t.jsx(Wt,{children:Ie}),s[85]=Ie,s[86]=be):be=s[86];let je;s[87]!==we||s[88]!==be?(je=t.jsxs(_t,{children:[we,be]}),s[87]=we,s[88]=be,s[89]=je):je=s[89];let ye;s[90]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>w(null),s[90]=ye):ye=s[90];let se;s[91]!==e?(se=e("settings.common.actions.cancel"),s[91]=e,s[92]=se):se=s[92];let ie;s[93]!==E||s[94]!==se?(ie=t.jsx(J,{variant:"ghost",onClick:ye,disabled:E,children:se}),s[93]=E,s[94]=se,s[95]=ie):ie=s[95];let ge;s[96]!==z?(ge=()=>{z()},s[96]=z,s[97]=ge):ge=s[97];let V;s[98]!==e?(V=e("settings.common.actions.delete"),s[98]=e,s[99]=V):V=s[99];let te;s[100]!==E||s[101]!==ge||s[102]!==V?(te=t.jsx(J,{size:"sm",variant:"destructive",onClick:ge,disabled:E,children:V}),s[100]=E,s[101]=ge,s[102]=V,s[103]=te):te=s[103];let ne;s[104]!==ie||s[105]!==te?(ne=t.jsxs(Yt,{children:[ie,te]}),s[104]=ie,s[105]=te,s[106]=ne):ne=s[106];let ue;s[107]!==je||s[108]!==ne?(ue=t.jsxs(Bt,{className:"max-w-md",children:[je,ne]}),s[107]=je,s[108]=ne,s[109]=ue):ue=s[109];let Me;s[110]!==le||s[111]!==ee||s[112]!==ue?(Me=t.jsx($t,{open:le,onOpenChange:ee,children:ue}),s[110]=le,s[111]=ee,s[112]=ue,s[113]=Me):Me=s[113];let ke;return s[114]!==Z||s[115]!==de||s[116]!==Me?(ke=t.jsxs(t.Fragment,{children:[Z,de,Me]}),s[114]=Z,s[115]=de,s[116]=Me,s[117]=ke):ke=s[117],ke},Oo=s=>{const e=rt.c(56),{profile:n,isDefault:a,onEdit:r,onToggleDefault:i,onDelete:o,isReadOnly:d,hasBorder:c}=s,{t:x}=dt(),[m,p]=l.useState(!1),u=gx[n.icon||"branch"]||"git-branch",C=hx[n.color||""],f=n.authType||"ssh";let g;e[0]!==r?(g=W=>{W.currentTarget===W.target&&(W.key!=="Enter"&&W.key!==" "||(W.preventDefault(),r()))},e[0]=r,e[1]=g):g=e[1];const h=g;let D;e[2]!==a||e[3]!==d||e[4]!==o||e[5]!==i||e[6]!==x?(D=W=>t.jsxs(t.Fragment,{children:[t.jsx(W,{onClick:X=>{X.stopPropagation(),i()},children:x(a?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!d&&o&&t.jsxs(W,{onClick:X=>{X.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[t.jsx(A,{name:"delete-bin",className:"h-4 w-4 mr-px"}),x("settings.common.actions.delete")]})]}),e[2]=a,e[3]=d,e[4]=o,e[5]=i,e[6]=x,e[7]=D):D=e[7];const k=D,w=c&&"border-b border-[var(--surface-subtle)]";let E;e[8]!==w?(E=ce("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",w),e[8]=w,e[9]=E):E=e[9];let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=W=>{W.preventDefault(),p(!0)},e[10]=N):N=e[10];let y;e[11]!==h||e[12]!==r||e[13]!==E?(y=t.jsx("div",{className:E,onClick:r,role:"button",tabIndex:0,onKeyDown:h,onContextMenu:N}),e[11]=h,e[12]=r,e[13]=E,e[14]=y):y=e[14];let b;e[15]!==C?(b={color:C},e[15]=C,e[16]=b):b=e[16];let P;e[17]!==u||e[18]!==b?(P=t.jsx(A,{name:u,className:"w-4 h-4 shrink-0",style:b}),e[17]=u,e[18]=b,e[19]=P):P=e[19];let z;e[20]!==n.name?(z=t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:n.name}),e[20]=n.name,e[21]=z):z=e[21];let M;e[22]!==f?(M=t.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:f}),e[22]=f,e[23]=M):M=e[23];let I;e[24]!==a||e[25]!==x?(I=a&&t.jsx("span",{className:"typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25",children:x("settings.gitIdentities.page.badge.default")}),e[24]=a,e[25]=x,e[26]=I):I=e[26];let v;e[27]!==d||e[28]!==x?(v=d&&t.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:x("settings.agents.sidebar.badge.system")}),e[27]=d,e[28]=x,e[29]=v):v=e[29];let j;e[30]!==M||e[31]!==I||e[32]!==v||e[33]!==z?(j=t.jsxs("div",{className:"flex items-center gap-1.5",children:[z,M,I,v]}),e[30]=M,e[31]=I,e[32]=v,e[33]=z,e[34]=j):j=e[34];const O=f==="token"&&n.host?n.host:n.userEmail;let T;e[35]!==O?(T=t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:O}),e[35]=O,e[36]=T):T=e[36];let B;e[37]!==j||e[38]!==T?(B=t.jsxs("div",{className:"min-w-0",children:[j,T]}),e[37]=j,e[38]=T,e[39]=B):B=e[39];let U;e[40]!==B||e[41]!==P?(U=t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[P,B]}),e[40]=B,e[41]=P,e[42]=U):U=e[42];let Q;e[43]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsx(us,{asChild:!0,children:t.jsx(J,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:yx,children:t.jsx(A,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[43]=Q):Q=e[43];let q;e[44]!==k?(q=t.jsxs(gs,{children:[Q,t.jsx(ps,{align:"end",className:"w-fit min-w-28",children:k(vs)})]}),e[44]=k,e[45]=q):q=e[45];let R;e[46]!==U||e[47]!==q||e[48]!==y?(R=t.jsxs(tn,{render:y,children:[U,q]}),e[46]=U,e[47]=q,e[48]=y,e[49]=R):R=e[49];let Y;e[50]!==k?(Y=t.jsx(sn,{className:"w-fit min-w-28",children:k(qs)}),e[50]=k,e[51]=Y):Y=e[51];let F;return e[52]!==m||e[53]!==R||e[54]!==Y?(F=t.jsxs(en,{open:m,onOpenChange:p,children:[R,Y]}),e[52]=m,e[53]=R,e[54]=Y,e[55]=F):F=e[55],F},xx=s=>{const e=rt.c(21),{credential:n,onImport:a,hasBorder:r}=s,{t:i}=dt();let o;e[0]!==n.host?(o=n.host.split("/"),e[0]=n.host,e[1]=o):o=e[1];const d=o,c=d.length>=3?d[d.length-1]:n.host,x=n.host.includes("/"),m=r&&"border-b border-[var(--surface-subtle)]";let p;e[2]!==m?(p=ce("flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30",m),e[2]=m,e[3]=p):p=e[3];let u;e[4]!==c?(u=t.jsx("span",{className:"typography-ui-label text-foreground truncate block",children:c}),e[4]=c,e[5]=u):u=e[5];const C=x?n.host:n.username;let f;e[6]!==C?(f=t.jsx("span",{className:"typography-micro text-muted-foreground/60 truncate block leading-tight",children:C}),e[6]=C,e[7]=f):f=e[7];let g;e[8]!==u||e[9]!==f?(g=t.jsxs("div",{className:"min-w-0",children:[u,f]}),e[8]=u,e[9]=f,e[10]=g):g=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(A,{name:"download",className:"h-3 w-3"}),e[11]=h):h=e[11];let D;e[12]!==i?(D=i("settings.gitIdentities.page.actions.import"),e[12]=i,e[13]=D):D=e[13];let k;e[14]!==a||e[15]!==D?(k=t.jsxs(J,{size:"sm",variant:"ghost",onClick:a,className:"gap-1 shrink-0",children:[h,D]}),e[14]=a,e[15]=D,e[16]=k):k=e[16];let w;return e[17]!==k||e[18]!==p||e[19]!==g?(w=t.jsxs("div",{className:p,children:[g,k]}),e[17]=k,e[18]=p,e[19]=g,e[20]=w):w=e[20],w};function bx(s){return{profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,deleteProfile:s.deleteProfile,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDiscoveredCredentials:s.loadDiscoveredCredentials,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId,setDefaultGitIdentityId:s.setDefaultGitIdentityId,getUnimportedCredentials:s.getUnimportedCredentials}}function yx(s){return s.stopPropagation()}const Gl=()=>{const s=cm();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},vx=()=>{const s=rt.c(2),[e,n]=l.useState(jx);let a,r;return s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],o=()=>{n(Gl())};o();for(const d of i)typeof d.addEventListener=="function"?d.addEventListener("change",o):typeof d.addListener=="function"&&d.addListener(o);return window.addEventListener("appinstalled",o),window.addEventListener("focus",o),()=>{for(const d of i)typeof d.removeEventListener=="function"?d.removeEventListener("change",o):typeof d.removeListener=="function"&&d.removeListener(o);window.removeEventListener("appinstalled",o),window.removeEventListener("focus",o)}},r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),l.useEffect(a,r),e};function jx(){return Gl()}const wx=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark"}],Nx=[{id:"dynamic",labelKey:"settings.openchamber.visual.option.diffLayout.dynamic.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.dynamic.description"},{id:"inline",labelKey:"settings.openchamber.visual.option.diffLayout.inline.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.inline.description"},{id:"side-by-side",labelKey:"settings.openchamber.visual.option.diffLayout.sideBySide.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.sideBySide.description"}],kx=[{id:"svg",labelKey:"settings.openchamber.visual.option.mermaidRendering.svg.label",descriptionKey:"settings.openchamber.visual.option.mermaidRendering.svg.description"},{id:"ascii",labelKey:"settings.openchamber.visual.option.mermaidRendering.ascii.label",descriptionKey:"settings.openchamber.visual.option.mermaidRendering.ascii.description"}],Hn="OpenChamber - AI Coding Assistant",Lo=[{id:"system",labelKey:"settings.openchamber.visual.option.pwaOrientation.system.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.system.description"},{id:"portrait",labelKey:"settings.openchamber.visual.option.pwaOrientation.portrait.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.portrait.description"},{id:"landscape",labelKey:"settings.openchamber.visual.option.pwaOrientation.landscape.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.landscape.description"}],zo=[{id:"native",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.description"},{id:"resize-content",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.description"}],Sx=[{value:"default",labelKey:"settings.openchamber.visual.option.mobileLayout.default"},{value:"new",labelKey:"settings.openchamber.visual.option.mobileLayout.new"}],ur=s=>s==="portrait"||s==="landscape"?s:"system",Cx=[{id:"markdown",labelKey:"settings.openchamber.visual.option.userMessageRendering.markdown.label",descriptionKey:"settings.openchamber.visual.option.userMessageRendering.markdown.description"},{id:"plain",labelKey:"settings.openchamber.visual.option.userMessageRendering.plain.label",descriptionKey:"settings.openchamber.visual.option.userMessageRendering.plain.description"}],Px=[{id:"sorted",labelKey:"settings.openchamber.visual.option.chatRenderMode.sorted.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.sorted.description"},{id:"live",labelKey:"settings.openchamber.visual.option.chatRenderMode.live.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.live.description"}],Ko=[{id:"auto",labelKey:"settings.openchamber.visual.option.messageTransport.auto.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.auto.description"},{id:"ws",labelKey:"settings.openchamber.visual.option.messageTransport.ws.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.ws.description"},{id:"sse",labelKey:"settings.openchamber.visual.option.messageTransport.sse.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.sse.description"}],Ix=[{id:"collapsed",labelKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.label",descriptionKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.description"},{id:"summary",labelKey:"settings.openchamber.visual.option.activityRenderMode.summary.label",descriptionKey:"settings.openchamber.visual.option.activityRenderMode.summary.description"}],$o=[{id:"auto",labelKey:"settings.openchamber.visual.option.timeFormat.auto.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.auto.description"},{id:"24h",labelKey:"settings.openchamber.visual.option.timeFormat.24h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.24h.description"},{id:"12h",labelKey:"settings.openchamber.visual.option.timeFormat.12h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.12h.description"}],Bo=[{id:"auto",labelKey:"settings.openchamber.visual.option.weekStart.auto.label",descriptionKey:"settings.openchamber.visual.option.weekStart.auto.description"},{id:"monday",labelKey:"settings.openchamber.visual.option.weekStart.monday.label"},{id:"sunday",labelKey:"settings.openchamber.visual.option.weekStart.sunday.label"}],Dx=s=>s==="markdown"?"markdown":"plain",Jr=({visibleSettings:s})=>{const{locale:e,locales:n,setLocale:a,label:r,t:i}=dt(),o=l.useCallback(S=>i(S),[i]),{isMobile:d}=Cs(),{browserTab:c}=vx(),x=Um(),m=Ke(S=>S.showReasoningTraces),p=Ke(S=>S.setShowReasoningTraces),u=Ke(S=>S.collapsibleThinkingBlocks),C=Ke(S=>S.setCollapsibleThinkingBlocks),f=Ke(S=>S.mermaidRenderingMode),g=Ke(S=>S.setMermaidRenderingMode),h=Ke(S=>S.userMessageRenderingMode),D=Ke(S=>S.setUserMessageRenderingMode),k=Ke(S=>S.collapsibleUserMessages),w=Ke(S=>S.setCollapsibleUserMessages),E=Ke(S=>S.stickyUserHeader),N=Ke(S=>S.setStickyUserHeader),y=Ke(S=>S.expandedEditorToolbar),b=Ke(S=>S.setExpandedEditorToolbar),P=Ke(S=>S.wideChatLayoutEnabled),z=Ke(S=>S.setWideChatLayoutEnabled),M=Ke(S=>S.chatRenderMode),I=Ke(S=>S.setChatRenderMode),v=Ke(S=>S.activityRenderMode),j=Ke(S=>S.setActivityRenderMode),O=Ke(S=>S.fontSize),T=Ke(S=>S.setFontSize),B=Ke(S=>S.terminalFontSize),U=Ke(S=>S.setTerminalFontSize),Q=Ke(S=>S.uiFont),q=Ke(S=>S.setUiFont),R=Ke(S=>S.monoFont),Y=Ke(S=>S.setMonoFont),F=Ke(S=>S.padding),W=Ke(S=>S.setPadding),X=Ke(S=>S.inputBarOffset),re=Ke(S=>S.setInputBarOffset),Z=Ke(S=>S.mobileKeyboardMode),de=Ke(S=>S.setMobileKeyboardMode),le=Ke(S=>S.diffLayoutPreference),ee=Ke(S=>S.setDiffLayoutPreference),xe=Ke(S=>S.showTerminalQuickKeysOnDesktop),we=Ke(S=>S.setShowTerminalQuickKeysOnDesktop),he=Ke(S=>S.fileEditorKeymap),Ie=Ke(S=>S.setFileEditorKeymap),be=ji(S=>S.queueModeEnabled),je=ji(S=>S.setQueueMode),ye=Ke(S=>S.persistChatDraft),se=Ke(S=>S.setPersistChatDraft),ie=Ke(S=>S.inputSpellcheckEnabled),ge=Ke(S=>S.setInputSpellcheckEnabled),V=Ke(S=>S.showToolFileIcons),te=Ke(S=>S.setShowToolFileIcons),ne=Ke(S=>S.showTurnChangedFiles),ue=Ke(S=>S.setShowTurnChangedFiles),Me=Ke(S=>S.showExpandedBashTools),ke=Ke(S=>S.setShowExpandedBashTools),Re=Ke(S=>S.showExpandedEditTools),Ae=Ke(S=>S.setShowExpandedEditTools),Pe=Ke(S=>S.timeFormatPreference),Te=Ke(S=>S.setTimeFormatPreference),Fe=Ke(S=>S.weekStartPreference),Be=Ke(S=>S.setWeekStartPreference),We=Ke(S=>S.showSplitAssistantMessageActions),ze=Ke(S=>S.setShowSplitAssistantMessageActions),Qe=ut(S=>S.settingsMessageStreamTransport),oe=ut(S=>S.setSettingsMessageStreamTransport),H=ut(S=>S.settingsDefaultFileViewerPreview),me=ut(S=>S.setSettingsDefaultFileViewerPreview),Ne=Ke(S=>S.isSettingsDialogOpen),{themeMode:Ee,setThemeMode:Ce,availableThemes:_e,customThemesLoading:G,reloadCustomThemes:$,lightThemeId:fe,darkThemeId:L,setLightThemePreference:Le,setDarkThemePreference:Je}=Ua(),[Xe,et]=l.useState(!1),at=l.useMemo(()=>ds()&&typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.macVibrancySupported===!0,[]),ct=typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.macVibrancy===!0,[Ze,He]=l.useState(ct),[mt,pe]=l.useState(!1),nt=l.useMemo(()=>ds()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),st=Ke(S=>S.dockBadgeEnabled),Ge=Ke(S=>S.setDockBadgeEnabled),[ht,wt]=l.useState(0),Nt=Ke(S=>S.reportUsage),ae=Ke(S=>S.setReportUsage),Ue=l.useCallback(S=>{ae(S),Ct({reportUsage:S})},[ae]),tt=Ne&&(s?s.includes("chatRenderMode"):!0);l.useEffect(()=>{if(!tt)return;let S=null,bt=Date.now();const zt=()=>{const Ms=Date.now();Ms-bt>=420&&(wt(Lt=>(Lt+1)%24),bt=Ms),S=requestAnimationFrame(zt)};(typeof document>"u"||document.visibilityState==="visible")&&(S=requestAnimationFrame(zt));const ns=()=>{document.visibilityState==="visible"&&S===null?S=requestAnimationFrame(zt):document.visibilityState!=="visible"&&S!==null&&(cancelAnimationFrame(S),S=null)};return document.addEventListener("visibilitychange",ns),()=>{document.removeEventListener("visibilitychange",ns),S!==null&&cancelAnimationFrame(S)}},[tt]);const Ye=l.useCallback(S=>{D(S),Ct({userMessageRenderingMode:S})},[D]),ft=l.useCallback(S=>{N(S),Ct({stickyUserHeader:S})},[N]),$e=l.useCallback(S=>{b(S),Ct({expandedEditorToolbar:S})},[b]),Ve=l.useCallback(S=>{w(S),Ct({collapsibleUserMessages:S})},[w]),it=l.useCallback(S=>{z(S),Ct({wideChatLayoutEnabled:S})},[z]),xt=l.useCallback(S=>{ze(S),Ct({showSplitAssistantMessageActions:S})},[ze]),At=l.useCallback(S=>{ge(S),Ct({inputSpellcheckEnabled:S})},[ge]),Zt=l.useCallback(S=>{I(S),Ct({chatRenderMode:S})},[I]),ts=l.useCallback(S=>{oe(S),Ct({messageStreamTransport:S})},[oe]),ss=l.useCallback(S=>{j(S),Ct({activityRenderMode:S})},[j]),Vt=l.useCallback(S=>{g(S),Ct({mermaidRenderingMode:S})},[g]),Se=l.useCallback(S=>{te(S),Ct({showToolFileIcons:S})},[te]),vt=l.useCallback(S=>{ue(S),Ct({showTurnChangedFiles:S})},[ue]),jt=l.useCallback(S=>{me(S),Ct({defaultFileViewerPreview:S}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:S}}))},[me]),lt=l.useCallback(S=>{ke(S),Ct({showExpandedBashTools:S})},[ke]),Et=l.useCallback(S=>{Ae(S),Ct({showExpandedEditTools:S})},[Ae]),qt=l.useCallback(S=>{Te(S),Ct({timeFormatPreference:S})},[Te]),os=l.useCallback(S=>{Be(S),Ct({weekStartPreference:S})},[Be]),as=l.useMemo(()=>_e.filter(S=>S.metadata.variant==="light").sort((S,bt)=>S.metadata.name.localeCompare(bt.metadata.name)),[_e]),Es=l.useMemo(()=>_e.filter(S=>S.metadata.variant==="dark").sort((S,bt)=>S.metadata.name.localeCompare(bt.metadata.name)),[_e]),Jt=l.useMemo(()=>as.find(S=>S.metadata.id===fe)??as[0],[as,fe]),Ds=l.useMemo(()=>Es.find(S=>S.metadata.id===L)??Es[0],[Es,L]),Ns=l.useCallback((S,bt)=>{const zt=bt==="dark"?" Dark":" Light";return S.endsWith(zt)?S.slice(0,-zt.length):S},[]),De=S=>s?s.includes(S):!0,pt=fs(),Ft=De("theme")&&!pt,Xt=De("theme")||De("timeFormat")||De("weekStart"),Qt=d&&dn()&&!ds()&&!pt,Fn=pt?Xt:De("theme")||Qt||De("pwaInstallName")||De("pwaOrientation")||De("timeFormat")||De("weekStart"),Ks=De("fontSize")||De("terminalFontSize")||De("spacing")||De("inputBarOffset"),On=De("terminalQuickKeys")&&!d||De("fileEditorKeymap")||De("expandedEditorToolbar"),_a=De("mermaidRendering")||De("userMessageRendering")||De("chatRenderMode")||De("messageTransport")||De("activityRenderMode")&&M==="sorted"||De("collapsibleUserMessages")||De("stickyUserHeader")||De("wideChatLayout")||De("splitAssistantMessageActions")||De("diffLayout")||De("dotfiles")||De("fileViewerPreview")||De("reasoning")||De("queueMode")||De("persistDraft")||De("showToolFileIcons")||De("expandedTools")||!d&&De("inputSpellcheck"),Gs=De("pwaInstallName")&&dn()&&c&&!ds()&&!pt,Js=De("pwaOrientation")&&dn()&&!ds()&&!pt,Qs=De("mobileKeyboardMode")&&dn()&&!ds()&&!pt&&Vm(),[Ln,Ha]=l.useState(()=>Zm()),[zn,Ts]=l.useState(""),[bn,K]=l.useState("system"),qe=l.useMemo(()=>{const S=$o.find(bt=>bt.id===Pe);return o(S?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[Pe,o]),kt=l.useMemo(()=>{const S=Bo.find(bt=>bt.id===Fe);return o(S?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[Fe,o]),Ot=l.useMemo(()=>{const S=Lo.find(bt=>bt.id===bn);return S?o(S.labelKey):void 0},[bn,o]),rs=l.useMemo(()=>{const S=zo.find(bt=>bt.id===Z);return S?o(S.labelKey):void 0},[Z,o]),Kn=l.useCallback(S=>{S!==Ln&&(Ha(S),eu(S),window.location.reload())},[Ln]),Ps=l.useCallback(async S=>{if(typeof window>"u")return;const bt=window,ns=S.trim().replace(/\s+/g," ").slice(0,64);if(await Ct({pwaAppName:ns}),typeof bt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const Ms=bt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(ns);Ts(Ms);return}Ts(ns||Hn),bt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),yn=l.useCallback(async S=>{if(typeof window>"u")return;const bt=window,zt=ur(S);if(await Ct({pwaOrientation:zt}),typeof bt.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const ns=bt.__OPENCHAMBER_SET_PWA_ORIENTATION__(zt);K(ns);return}K(zt),bt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return l.useEffect(()=>{if(typeof window>"u"||!Gs&&!Js&&!Qs)return;let S=!1;return(async()=>{try{const zt=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!zt.ok){S||Ts(Hn);return}const ns=await zt.json().catch(()=>({})),Lt=(typeof ns?.pwaAppName=="string"?ns.pwaAppName:"").trim().replace(/\s+/g," ").slice(0,64),es=ur(ns?.pwaOrientation),vn=Ci(ns?.mobileKeyboardMode);S||(Gs&&Ts(Lt||Hn),Js&&K(es),Qs&&de(vn))}catch{S||(Gs&&Ts(Hn),Js&&K("system"),Qs&&de("native"))}})(),()=>{S=!0}},[de,Qs,Gs,Js]),t.jsxs("div",{className:"space-y-8",children:[Fn&&t.jsxs("div",{className:"mb-8 space-y-6",children:[Ft&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsx("span",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.colorMode")}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:wx.map(S=>t.jsx(J,{variant:"chip",size:"xs","aria-pressed":Ee===S.value,className:"!font-normal",onClick:()=>Ce(S.value),children:o(S.labelKey)},S.value))})]}),Qt&&t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5 py-1.5",children:[t.jsx("span",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.mobileLayout")}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Sx.map(S=>t.jsx(J,{variant:"chip",size:"xs","aria-pressed":Ln===S.value,className:"!font-normal",onClick:()=>Kn(S.value),children:o(S.labelKey)},S.value))})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[t.jsxs("div",{"data-settings-item":"appearance.light-theme",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.lightTheme")}),t.jsxs(Mt,{value:Jt?.metadata.id??"",onValueChange:Le,children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.selectLightThemeAria"),className:"w-fit",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),children:Jt?Ns(Jt.metadata.name,"light"):void 0})}),t.jsx(Tt,{children:as.map(S=>t.jsx(gt,{value:S.metadata.id,children:Ns(S.metadata.name,"light")},S.metadata.id))})]})]}),t.jsxs("div",{"data-settings-item":"appearance.dark-theme",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.darkTheme")}),t.jsxs(Mt,{value:Ds?.metadata.id??"",onValueChange:Je,children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.selectDarkThemeAria"),className:"w-fit",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),children:Ds?Ns(Ds.metadata.name,"dark"):void 0})}),t.jsx(Tt,{children:Es.map(S=>t.jsx(gt,{value:S.metadata.id,children:Ns(S.metadata.name,"dark")},S.metadata.id))})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[t.jsx("button",{type:"button",disabled:G||Xe,onClick:()=>{const S=Date.now();et(!0),$().finally(()=>{const bt=Date.now()-S;if(bt<500){window.setTimeout(()=>{et(!1)},500-bt);return}et(!1)})},className:"inline-flex items-center typography-ui-label font-normal text-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground/80 disabled:cursor-not-allowed disabled:text-muted-foreground/60",children:i(Xe?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx("button",{type:"button",className:"flex items-center justify-center rounded-md p-1 text-muted-foreground/70 hover:text-foreground","aria-label":i("settings.openchamber.visual.field.themeImportInfoAria"),children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5"})})}),t.jsx(Dt,{sideOffset:8,children:i("settings.openchamber.visual.field.themeImportInfoTooltip")})]})]}),at&&t.jsxs("div",{"data-settings-item":"appearance.window-transparency",className:"flex flex-col gap-1.5 border-t border-border/40 pt-3",children:[t.jsxs("div",{className:"group flex cursor-pointer items-start gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":Ze,onClick:()=>{mt||He(!Ze)},onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),mt||He(!Ze))},children:[t.jsx(St,{checked:Ze,onChange:He,disabled:mt,ariaLabel:i("settings.openchamber.visual.field.macVibrancy")}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.macVibrancy")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.macVibrancyHint")})]})]}),Ze!==ct&&t.jsx("div",{className:"pl-6",children:t.jsx(J,{variant:"outline",size:"sm",disabled:mt,onClick:()=>{pe(!0),_m("desktop_set_vibrancy",{enabled:Ze})},children:i(mt?"settings.openchamber.visual.actions.restarting":"settings.openchamber.visual.actions.saveAndRestart")})})]}),nt&&t.jsx("div",{"data-settings-item":"appearance.dock-badge",className:"flex flex-col gap-1.5 border-t border-border/40 pt-3",children:t.jsxs("div",{className:"group flex cursor-pointer items-start gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":st,onClick:()=>Ge(!st),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Ge(!st))},children:[t.jsx(St,{checked:st,onChange:Ge,ariaLabel:i("settings.openchamber.visual.field.dockBadge")}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.dockBadge")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.dockBadgeHint")})]})]})})]}),Xt&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.localization")}),t.jsxs("div",{"data-settings-item":"appearance.language",className:"grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.appearance.language.label")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.appearance.language.description")})]}),t.jsxs(Mt,{value:e,onValueChange:S=>a(S),children:[t.jsx(Rt,{"aria-label":i("settings.appearance.language.select"),className:"w-fit",children:t.jsx(Kt,{children:r(e)})}),t.jsx(Tt,{children:n.map(S=>t.jsx(gt,{value:S,children:r(S)},S))})]})]}),(De("timeFormat")||De("weekStart"))&&t.jsxs("div",{className:"grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[De("timeFormat")&&t.jsxs("div",{"data-settings-item":"appearance.time-format",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.timeFormat")}),t.jsxs(Mt,{value:Pe,onValueChange:S=>qt(S),children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.selectTimeFormatAria"),className:"w-fit",children:t.jsx(Kt,{children:qe})}),t.jsx(Tt,{children:$o.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]})]}),De("weekStart")&&t.jsxs("div",{"data-settings-item":"appearance.week-start",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.weekStartsOn")}),t.jsxs(Mt,{value:Fe,onValueChange:S=>os(S),children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.selectWeekStartAria"),className:"w-fit",children:t.jsx(Kt,{children:kt})}),t.jsx(Tt,{children:Bo.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]})]})]})]}),(Gs||Js||Qs)&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[Gs&&t.jsxs("div",{"data-settings-item":"appearance.pwa-install-name",className:"py-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.installAppName")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.installAppNameHint")})]}),t.jsxs("div",{className:"flex w-full max-w-[28rem] items-center gap-2",children:[t.jsx(ot,{value:zn,onChange:S=>{Ts(S.target.value)},onBlur:()=>{Ps(zn)},onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),Ps(zn))},className:"h-7",maxLength:64,"aria-label":i("settings.openchamber.visual.field.pwaInstallAppNameAria")}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Ts(Hn),Ps("")},className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Js&&t.jsxs("div",{"data-settings-item":"appearance.pwa-orientation",className:"py-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.installOrientation")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.installOrientationHint")})]}),t.jsxs("div",{className:"flex w-full max-w-[18rem] items-center gap-2",children:[t.jsxs(Mt,{value:bn,onValueChange:S=>{const bt=ur(S);K(bt),yn(bt)},children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.pwaInstallOrientationAria"),className:"w-full",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:Ot})}),t.jsx(Tt,{children:Lo.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K("system"),yn("system")},disabled:bn==="system",className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Qs&&t.jsxs("div",{"data-settings-item":"appearance.mobile-keyboard-mode",className:"py-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.mobileKeyboardMode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.mobileKeyboardModeHint")})]}),t.jsxs("div",{className:"flex w-full max-w-[18rem] items-center gap-2",children:[t.jsxs(Mt,{value:Z,onValueChange:S=>{const bt=Ci(S);de(bt),Ct({mobileKeyboardMode:bt})},children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.mobileKeyboardModeAria"),className:"w-full",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:rs})}),t.jsx(Tt,{children:zo.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>{de("native"),Ct({mobileKeyboardMode:"native"})},disabled:Z==="native",className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]})]}),Ks&&t.jsx("div",{className:"mb-8 space-y-3",children:t.jsxs("section",{className:"p-2 space-y-0.5",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.spacingAndLayout")}),t.jsxs("div",{className:"pl-2",children:[De("fontSize")&&!d&&t.jsxs("div",{"data-settings-item":"appearance.interface-font-size",className:"flex items-center gap-8 py-1",children:[t.jsx("div",{className:"flex min-w-0 flex-col w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.interfaceFont")})}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[t.jsxs(Mt,{value:Q,onValueChange:S=>q(S),children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.selectInterfaceFontAria"),className:"w-[13rem]",children:t.jsx(Kt,{children:wi.find(S=>S.id===Q)?.label})}),t.jsx(Tt,{children:wi.map(S=>t.jsx(gt,{value:S.id,children:t.jsx("span",{style:{fontFamily:S.stack},children:S.label})},S.id))})]}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>q(Ni),disabled:Q===Ni,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),De("terminalFontSize")&&t.jsxs("div",{className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.codeFont")})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsxs(Mt,{value:R,onValueChange:S=>Y(S),children:[t.jsx(Rt,{"aria-label":i("settings.openchamber.visual.field.selectCodeFontAria"),className:"w-[13rem]",children:t.jsx(Kt,{children:ki.find(S=>S.id===R)?.label})}),t.jsx(Tt,{children:ki.map(S=>t.jsx(gt,{value:S.id,children:t.jsx("span",{style:{fontFamily:S.stack},children:S.label})},S.id))})]}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>Y(Si),disabled:R===Si,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetCodeFontAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),De("fontSize")&&!d&&t.jsxs("div",{className:"flex items-center gap-8 py-1",children:[t.jsx("div",{className:"flex min-w-0 flex-col w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.interfaceFontSize")})}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[t.jsx(bs,{value:O,onValueChange:T,min:50,max:200,step:5,"aria-label":i("settings.openchamber.visual.field.fontSizePercentageAria"),className:"w-16"}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>T(100),disabled:O===100,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetFontSizeAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),De("terminalFontSize")&&t.jsxs("div",{"data-settings-item":"appearance.terminal-font-size",className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.terminalFontSize")})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsx(bs,{value:B,onValueChange:U,min:9,max:52,step:1,className:"w-16"}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>U(13),disabled:B===13,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),De("spacing")&&t.jsxs("div",{"data-settings-item":"appearance.spacing-density",className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.spacingDensity")})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsx(bs,{value:F,onValueChange:W,min:50,max:200,step:5,className:"w-16"}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>W(100),disabled:F===100,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetSpacingAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),De("inputBarOffset")&&t.jsxs("div",{"data-settings-item":"appearance.input-bar-offset",className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.inputBarOffset")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.inputBarOffsetTooltip")})]})]})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsx(bs,{value:X,onValueChange:re,min:0,max:100,step:5,className:"w-16"}),t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:()=>re(0),disabled:X===0,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:i("settings.common.actions.reset"),children:t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]})]})}),On&&t.jsx("div",{className:"space-y-3",children:t.jsxs("section",{className:"px-2 pb-2 pt-0",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.navigation")}),De("fileEditorKeymap")&&t.jsxs("div",{"data-settings-item":"appearance.file-editor-keymap",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-start sm:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:i("settings.openchamber.visual.field.fileEditorKeymap")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.field.fileEditorKeymap"),className:"space-y-0",children:["default","vim"].map(S=>{const bt=he===S,zt=i(`settings.openchamber.visual.option.fileEditorKeymap.${S}`);return t.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-2 py-0.5 text-left",role:"radio","aria-checked":bt,onClick:()=>Ie(S),children:[t.jsx("span",{"aria-hidden":!0,className:ce("relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out",bt?"bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none":"bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]"),children:t.jsx("span",{className:ce("block h-[5px] w-[5px] rounded-full bg-white",!bt&&"opacity-0")})}),t.jsx("span",{className:ce("typography-ui-label font-normal",bt?"text-foreground":"text-foreground/50"),children:zt})]},S)})})]}),De("expandedEditorToolbar")&&t.jsxs("div",{"data-settings-item":"appearance.expanded-editor-toolbar",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":y,onClick:()=>$e(!y),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),$e(!y))},children:[t.jsx(St,{checked:y,onChange:$e,ariaLabel:i("settings.openchamber.visual.field.expandedEditorToolbarAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.expandedEditorToolbar")})]}),De("terminalQuickKeys")&&!d&&t.jsxs("div",{"data-settings-item":"appearance.terminal-quick-keys",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":xe,onClick:()=>we(!xe),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),we(!xe))},children:[t.jsx(St,{checked:xe,onChange:we,ariaLabel:i("settings.openchamber.visual.field.terminalQuickKeysAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.terminalQuickKeys")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.terminalQuickKeysTooltip")})]})]})]})]})}),_a&&t.jsxs("div",{className:"space-y-3",children:[(De("userMessageRendering")||De("mermaidRendering")||De("chatRenderMode")||De("messageTransport")||De("activityRenderMode")&&M==="sorted"||De("diffLayout")&&!pt)&&t.jsxs("div",{className:"grid grid-cols-1 gap-y-2 md:grid-cols-[minmax(0,16rem)_minmax(0,16rem)] md:justify-start md:gap-x-2",children:[De("chatRenderMode")&&t.jsxs("section",{"data-settings-item":"chat.render-mode",className:"p-2 md:col-span-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.chatRenderMode")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.chatRenderModeAria"),className:"mt-1 grid w-full max-w-[26rem] grid-cols-1 gap-3 sm:grid-cols-2",children:Px.map(S=>{const bt=M===S.id,zt=ht%12;return t.jsxs("button",{type:"button",onClick:()=>Zt(S.id),"aria-pressed":bt,className:ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",bt?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsx("span",{className:ce("typography-ui-label",bt?"text-foreground":"text-muted-foreground"),children:o(S.labelKey)}),t.jsx("div",{className:"mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2",children:S.id==="live"?t.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(ns=>{const Ms=ns*3+1,Lt=zt-Ms+1,es=Lt<=0?0:Lt===1?42:Lt===2?68:92,vn=es>0;return t.jsxs("div",{className:ce("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",vn?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),t.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none",style:{width:`${es}%`}})]},ns)})}):t.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(ns=>{const Ms=zt>=(ns+1)*3;return t.jsxs("div",{className:ce("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",Ms?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),t.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30",style:{width:"92%"}})]},ns)})})})]},S.id)})})]}),De("messageTransport")&&t.jsxs("section",{"data-settings-item":"chat.message-transport",className:"p-2 md:col-span-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.messageStreamTransport")}),t.jsxs("div",{className:"mt-1 flex max-w-[24rem] flex-col gap-2",children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Ko.map(S=>t.jsx(J,{variant:"chip",size:"xs","aria-pressed":Qe===S.id,className:"!font-normal",onClick:()=>ts(S.id),children:o(S.labelKey)},S.id))}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:(()=>{const S=Ko.find(bt=>bt.id===Qe);return S?.descriptionKey?o(S.descriptionKey):""})()})]})]}),De("activityRenderMode")&&M==="sorted"&&t.jsxs("section",{className:"p-2 md:col-span-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.activityDefault")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.activityDefaultAria"),className:"mt-0.5 space-y-0",children:Ix.map(S=>{const bt=v===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":bt,onClick:()=>ss(S.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),ss(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Cn,{checked:bt,onChange:()=>ss(S.id),ariaLabel:i("settings.openchamber.visual.field.activityDefaultModeAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",bt?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),De("expandedTools")&&t.jsxs("section",{className:"p-2 md:col-span-2 space-y-0.5",children:[t.jsx("div",{className:"typography-ui-header font-medium text-foreground py-1.5",children:i("settings.openchamber.visual.section.showToolsOpenedByDefault")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":Me,onClick:()=>lt(!Me),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),lt(!Me))},children:[t.jsx(St,{checked:Me,onChange:lt,ariaLabel:i("settings.openchamber.visual.field.showExpandedBashToolsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.bash")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":Re,onClick:()=>Et(!Re),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Et(!Re))},children:[t.jsx(St,{checked:Re,onChange:Et,ariaLabel:i("settings.openchamber.visual.field.showExpandedEditToolsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.editTools")})]})]}),De("userMessageRendering")&&t.jsxs("section",{className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.userMessageRendering")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.userMessageRenderingAria"),className:"mt-0.5 space-y-0",children:Cx.map(S=>{const bt=Dx(h)===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":bt,onClick:()=>Ye(S.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),Ye(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Cn,{checked:bt,onChange:()=>Ye(S.id),ariaLabel:i("settings.openchamber.visual.field.userMessageRenderingAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",bt?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),De("mermaidRendering")&&t.jsxs("section",{className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.mermaidRendering")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.mermaidRenderingAria"),className:"mt-0.5 space-y-0",children:kx.map(S=>{const bt=f===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":bt,onClick:()=>Vt(S.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),Vt(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Cn,{checked:bt,onChange:()=>Vt(S.id),ariaLabel:i("settings.openchamber.visual.field.mermaidRenderingAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",bt?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),De("diffLayout")&&!pt&&t.jsxs("section",{className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.diffLayout")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.diffLayoutAria"),className:"mt-0.5 space-y-0",children:Nx.map(S=>{const bt=le===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":bt,onClick:()=>ee(S.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),ee(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Cn,{checked:bt,onChange:()=>ee(S.id),ariaLabel:i("settings.openchamber.visual.field.diffLayoutAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",bt?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]})]}),(De("collapsibleUserMessages")||De("stickyUserHeader")||De("wideChatLayout")||De("splitAssistantMessageActions")||De("dotfiles")||De("fileViewerPreview")||De("queueMode")||De("persistDraft")||De("showToolFileIcons")||De("showTurnChangedFiles")||!d&&De("inputSpellcheck")||De("reasoning"))&&t.jsxs("section",{className:"p-2 space-y-0.5",children:[De("reasoning")&&t.jsxs("div",{"data-settings-item":"chat.reasoning-traces",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":m,onClick:()=>p(!m),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),p(!m))},children:[t.jsx(St,{checked:m,onChange:p,ariaLabel:i("settings.openchamber.visual.field.showReasoningTracesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showReasoningTraces")})]}),De("reasoning")&&m&&t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":u,onClick:()=>C(!u),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),C(!u))},children:[t.jsx(St,{checked:u,onChange:C,ariaLabel:i("settings.openchamber.visual.field.collapsibleThinkingBlocksAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.collapsibleThinkingBlocks")})]}),De("collapsibleUserMessages")&&t.jsxs("div",{"data-settings-item":"chat.collapsible-user-messages",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":k,onClick:()=>Ve(!k),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Ve(!k))},children:[t.jsx(St,{checked:k,onChange:Ve,ariaLabel:i("settings.openchamber.visual.field.collapsibleUserMessagesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.collapsibleUserMessages")})]}),De("stickyUserHeader")&&t.jsxs("div",{"data-settings-item":"chat.sticky-user-header",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":E,onClick:()=>ft(!E),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),ft(!E))},children:[t.jsx(St,{checked:E,onChange:ft,ariaLabel:i("settings.openchamber.visual.field.stickyUserHeaderAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.stickyUserHeader")})]}),De("wideChatLayout")&&t.jsxs("div",{"data-settings-item":"chat.wide-layout",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":P,onClick:()=>it(!P),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),it(!P))},children:[t.jsx(St,{checked:P,onChange:it,ariaLabel:i("settings.openchamber.visual.field.wideChatLayoutAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.wideChatLayout")})]}),De("splitAssistantMessageActions")&&t.jsxs("div",{"data-settings-item":"chat.inline-assistant-actions",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":We,onClick:()=>xt(!We),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),xt(!We))},children:[t.jsx(St,{checked:We,onChange:xt,ariaLabel:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showSplitAssistantMessageActions")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 cursor-help text-muted-foreground/60"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip")})]})]})]}),De("showToolFileIcons")&&t.jsxs("div",{"data-settings-item":"chat.tool-file-icons",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":V,onClick:()=>Se(!V),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Se(!V))},children:[t.jsx(St,{checked:V,onChange:Se,ariaLabel:i("settings.openchamber.visual.field.showToolFileIconsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showToolFileIcons")})]}),De("showTurnChangedFiles")&&t.jsxs("div",{"data-settings-item":"chat.changed-files",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":ne,onClick:()=>vt(!ne),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),vt(!ne))},children:[t.jsx(St,{checked:ne,onChange:vt,ariaLabel:i("settings.openchamber.visual.field.showTurnChangedFilesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showTurnChangedFiles")})]}),De("dotfiles")&&!fs()&&t.jsxs("div",{"data-settings-item":"chat.dotfiles",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":x,onClick:()=>Za(!x),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Za(!x))},children:[t.jsx(St,{checked:x,onChange:Za,ariaLabel:i("settings.openchamber.visual.field.showDotfilesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showDotfiles")})]}),De("fileViewerPreview")&&t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":H,onClick:()=>jt(!H),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),jt(!H))},children:[t.jsx("span",{onClick:S=>S.stopPropagation(),children:t.jsx(St,{checked:H,onChange:jt,ariaLabel:i("settings.openchamber.defaults.field.openFilesPreviewAria")})}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.defaults.field.openFilesPreview")})]}),De("queueMode")&&t.jsxs("div",{"data-settings-item":"chat.queue-mode",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":be,onClick:()=>je(!be),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),je(!be))},children:[t.jsx(St,{checked:be,onChange:je,ariaLabel:i("settings.openchamber.visual.field.queueMessagesByDefaultAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.queueMessagesByDefault")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.queueMessagesByDefaultTooltip",{modifier:kl()})})]})]})]}),De("persistDraft")&&t.jsxs("div",{"data-settings-item":"chat.persist-drafts",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":ye,onClick:()=>se(!ye),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),se(!ye))},children:[t.jsx(St,{checked:ye,onChange:se,ariaLabel:i("settings.openchamber.visual.field.persistDraftMessagesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.persistDraftMessages")})]}),!d&&De("inputSpellcheck")&&t.jsxs("div",{"data-settings-item":"chat.spellcheck",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":ie,onClick:()=>At(!ie),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),At(!ie))},children:[t.jsx(St,{checked:ie,onChange:At,ariaLabel:i("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.enableSpellcheckInTextInputs")})]})]})]}),De("reportUsage")&&t.jsx("div",{className:"space-y-3",children:t.jsxs("section",{className:"px-2 pb-2 pt-0",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground mb-2",children:i("settings.openchamber.visual.section.privacy")}),t.jsxs("div",{"data-settings-item":"appearance.usage-reports",className:"flex items-start gap-2 py-1.5",children:[t.jsx(St,{checked:Nt,onChange:Ue,ariaLabel:i("settings.openchamber.visual.field.sendAnonymousUsageReportsAria")}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[t.jsx("div",{className:"group flex cursor-pointer",role:"button",tabIndex:0,"aria-pressed":Nt,onClick:()=>Ue(!Nt),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Ue(!Nt))},children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.sendAnonymousUsageReports")})}),t.jsx("span",{className:"typography-meta text-muted-foreground pointer-events-none",children:i("settings.openchamber.visual.field.sendAnonymousUsageReportsHint")})]})]})]})})]})},Ax=1,Ex=365,Uo=30,Mx=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],Jl=()=>{const s=rt.c(113),{t:e}=dt(),n=Ke(Rx),a=Ke(Tx),r=Ke(Fx),i=Ke(Ox),o=Ke(Lx),d=Ke(zx);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={autoRun:!1},s[0]=c):c=s[0];const{candidates:x,isRunning:m,runCleanup:p,action:u}=dm(c),C=x.length;let f;s[1]!==p||s[2]!==e?(f=async()=>{const ne=await p({force:!0});if(ne.completedIds.length===0&&ne.failedIds.length===0){_.message(ne.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}ne.completedIds.length>0&&_.success(ne.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:ne.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:ne.completedIds.length})),ne.failedIds.length>0&&_.error(ne.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:ne.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:ne.failedIds.length}))},s[1]=p,s[2]=e,s[3]=f):f=s[3];const g=f;let h;s[4]!==e?(h=e("settings.openchamber.sessionRetention.title"),s[4]=e,s[5]=h):h=s[5];let D;s[6]!==h?(D=t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:h}),s[6]=h,s[7]=D):D=s[7];let k;s[8]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),s[8]=k):k=s[8];let w;s[9]!==e?(w=e("settings.openchamber.sessionRetention.tooltip"),s[9]=e,s[10]=w):w=s[10];let E;s[11]!==w?(E=t.jsxs(Pt,{children:[k,t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:w})]}),s[11]=w,s[12]=E):E=s[12];let N;s[13]!==D||s[14]!==E?(N=t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[D,E]})}),s[13]=D,s[14]=E,s[15]=N):N=s[15];let y,b;s[16]!==n||s[17]!==i?(y=()=>i(!n),b=ne=>{(ne.key===" "||ne.key==="Enter")&&(ne.preventDefault(),i(!n))},s[16]=n,s[17]=i,s[18]=y,s[19]=b):(y=s[18],b=s[19]);let P;s[20]!==e?(P=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),s[20]=e,s[21]=P):P=s[21];let z;s[22]!==n||s[23]!==i||s[24]!==P?(z=t.jsx(St,{checked:n,onChange:i,ariaLabel:P}),s[22]=n,s[23]=i,s[24]=P,s[25]=z):z=s[25];let M;s[26]!==e?(M=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),s[26]=e,s[27]=M):M=s[27];let I;s[28]!==M?(I=t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),s[28]=M,s[29]=I):I=s[29];let v;s[30]!==n||s[31]!==z||s[32]!==I||s[33]!==y||s[34]!==b?(v=t.jsxs("div",{"data-settings-item":"sessions.auto-cleanup",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":n,onClick:y,onKeyDown:b,children:[z,I]}),s[30]=n,s[31]=z,s[32]=I,s[33]=y,s[34]=b,s[35]=v):v=s[35];let j;s[36]!==e?(j=e("settings.openchamber.sessionRetention.field.retentionPeriod"),s[36]=e,s[37]=j):j=s[37];let O;s[38]!==j?(O=t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:j})}),s[38]=j,s[39]=O):O=s[39];let T;s[40]!==e?(T=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),s[40]=e,s[41]=T):T=s[41];let B;s[42]!==a||s[43]!==o||s[44]!==T?(B=t.jsx(bs,{value:a,onValueChange:o,min:Ax,max:Ex,step:1,"aria-label":T,className:"w-20 tabular-nums"}),s[42]=a,s[43]=o,s[44]=T,s[45]=B):B=s[45];let U;s[46]!==e?(U=e("settings.openchamber.sessionRetention.field.days"),s[46]=e,s[47]=U):U=s[47];let Q;s[48]!==U?(Q=t.jsx("span",{className:"typography-ui-label text-muted-foreground",children:U}),s[48]=U,s[49]=Q):Q=s[49];let q;s[50]!==o?(q=()=>o(Uo),s[50]=o,s[51]=q):q=s[51];const R=a===Uo;let Y;s[52]!==e?(Y=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),s[52]=e,s[53]=Y):Y=s[53];let F;s[54]!==e?(F=e("settings.common.actions.reset"),s[54]=e,s[55]=F):F=s[55];let W;s[56]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(A,{name:"restart",className:"h-3.5 w-3.5"}),s[56]=W):W=s[56];let X;s[57]!==q||s[58]!==R||s[59]!==Y||s[60]!==F?(X=t.jsx(J,{size:"sm",type:"button",variant:"ghost",onClick:q,disabled:R,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":Y,title:F,children:W}),s[57]=q,s[58]=R,s[59]=Y,s[60]=F,s[61]=X):X=s[61];let re;s[62]!==B||s[63]!==Q||s[64]!==X?(re=t.jsxs("div",{className:"flex items-center gap-2 sm:w-fit",children:[B,Q,X]}),s[62]=B,s[63]=Q,s[64]=X,s[65]=re):re=s[65];let Z;s[66]!==O||s[67]!==re?(Z=t.jsxs("div",{"data-settings-item":"sessions.retention-period",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[O,re]}),s[66]=O,s[67]=re,s[68]=Z):Z=s[68];let de;s[69]!==e?(de=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),s[69]=e,s[70]=de):de=s[70];let le;s[71]!==de?(le=t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:de})}),s[71]=de,s[72]=le):le=s[72];let ee;s[73]!==r||s[74]!==d||s[75]!==e?(ee=Mx.map(ne=>t.jsx(J,{type:"button",variant:"chip",size:"xs","aria-pressed":r===ne.value,className:"!font-normal",onClick:()=>d(ne.value),children:e(ne.labelKey)},ne.value)),s[73]=r,s[74]=d,s[75]=e,s[76]=ee):ee=s[76];let xe;s[77]!==ee?(xe=t.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:w-fit",children:ee}),s[77]=ee,s[78]=xe):xe=s[78];let we;s[79]!==le||s[80]!==xe?(we=t.jsxs("div",{"data-settings-item":"sessions.retention-action",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[le,xe]}),s[79]=le,s[80]=xe,s[81]=we):we=s[81];let he;s[82]!==v||s[83]!==Z||s[84]!==we?(he=t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[v,Z,we]}),s[82]=v,s[83]=Z,s[84]=we,s[85]=he):he=s[85];let Ie;s[86]!==e?(Ie=e("settings.openchamber.sessionRetention.manualCleanup.title"),s[86]=e,s[87]=Ie):Ie=s[87];let be;s[88]!==Ie?(be=t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("p",{className:"typography-meta text-foreground font-medium",children:Ie})}),s[88]=Ie,s[89]=be):be=s[89];let je;s[90]!==m||s[91]!==e?(je=e(m?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),s[90]=m,s[91]=e,s[92]=je):je=s[92];let ye;s[93]!==g||s[94]!==m||s[95]!==je?(ye=t.jsx("div",{className:"flex items-center gap-2 sm:w-fit",children:t.jsx(J,{type:"button",variant:"outline",size:"xs",onClick:g,disabled:m,className:"!font-normal",children:je})}),s[93]=g,s[94]=m,s[95]=je,s[96]=ye):ye=s[96];let se;s[97]!==be||s[98]!==ye?(se=t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8",children:[be,ye]}),s[97]=be,s[98]=ye,s[99]=se):se=s[99];let ie;s[100]!==u||s[101]!==C||s[102]!==e?(ie=u==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:C}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:C}),s[100]=u,s[101]=C,s[102]=e,s[103]=ie):ie=s[103];let ge;s[104]!==ie?(ge=t.jsx("p",{className:"typography-meta text-muted-foreground",children:ie}),s[104]=ie,s[105]=ge):ge=s[105];let V;s[106]!==se||s[107]!==ge?(V=t.jsxs("div",{className:"mt-1 px-2 py-1.5 space-y-1",children:[se,ge]}),s[106]=se,s[107]=ge,s[108]=V):V=s[108];let te;return s[109]!==he||s[110]!==V||s[111]!==N?(te=t.jsxs("div",{className:"mb-8",children:[N,he,V]}),s[109]=he,s[110]=V,s[111]=N,s[112]=te):te=s[112],te};function Rx(s){return s.autoDeleteEnabled}function Tx(s){return s.autoDeleteAfterDays}function Fx(s){return s.sessionRetentionAction}function Ox(s){return s.setAutoDeleteEnabled}function Lx(s){return s.setAutoDeleteAfterDays}function zx(s){return s.setSessionRetentionAction}const Vo=(s,e,n)=>!s||!Number.isFinite(s)?e:new Intl.DateTimeFormat(_r(),{dateStyle:"medium",timeStyle:"short",hour12:n==="auto"?void 0:n==="12h"}).format(s),Ql=()=>{const{t:s}=dt(),e=Ke(b=>b.timeFormatPreference),[n,a]=l.useState(!1),[r,i]=l.useState(!0),[o,d]=l.useState(!1),[c,x]=l.useState(null),[m,p]=l.useState(!1),[u,C]=l.useState([]),[f,g]=l.useState(mm),[h,D]=l.useState(""),k=l.useMemo(()=>um(),[]),w=l.useCallback(async()=>{i(!0),D("");try{const b=await pm();C(b)}catch(b){const P=b instanceof Error?b.message:s("settings.openchamber.passkeys.toast.loadFailed");D(P)}finally{i(!1)}},[s]);l.useEffect(()=>{let b=!1;return(async()=>{try{if(!k.supported){b||(a(!1),i(!1));return}b||a(!0)}catch{b||a(!1)}if(!b){const P=await Ja();if(g(P),!P.enabled){C([]),i(!1);return}await w()}})(),()=>{b=!0,gi()}},[w,k.supported]);const E=l.useCallback(async()=>{if(!f.enabled){const b=s("settings.openchamber.passkeys.toast.enableUiPasswordFirst");D(b),_.message(b);return}if(!n){D(k.reason),_.message(k.reason);return}if(o){gi(),d(!1);return}D(""),d(!0);try{await gm(),g(await Ja()),await w(),_.success(s("settings.openchamber.passkeys.toast.added"))}catch(b){if(hm(b)){_.message(s("settings.openchamber.passkeys.toast.setupCanceled"));return}const P=b instanceof Error?b.message:s("settings.openchamber.passkeys.toast.addFailed");D(P),_.error(P)}finally{d(!1)}},[o,w,f.enabled,k.reason,n,s]),N=l.useCallback(async b=>{x(b),D("");try{await fm(b),g(await Ja()),await w(),_.success(s("settings.openchamber.passkeys.toast.removed"))}catch(P){const z=P instanceof Error?P.message:s("settings.openchamber.passkeys.toast.removeFailed");D(z),_.error(z)}finally{x(null)}},[w,s]),y=l.useCallback(async()=>{p(!0),D("");try{await xm(),window.location.reload()}catch(b){const P=b instanceof Error?b.message:s("settings.openchamber.passkeys.toast.clearAuthFailed");D(P),_.error(P),p(!1)}},[s]);return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.passkeys.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.passkeys.field.currentDevice")})}),t.jsxs("div",{className:"flex items-center gap-2 sm:w-fit",children:[t.jsx(J,{type:"button",variant:o?"secondary":"outline",size:"xs",onClick:()=>{E()},disabled:r||m,className:"!font-normal",children:s(o?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),t.jsx(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>{y()},disabled:r||o||m,className:"!font-normal text-muted-foreground hover:text-foreground",children:s(m?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]})]}),!f.enabled&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.uiPasswordRequired")}),f.enabled&&!n&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:k.reason}),r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.loading")}):u.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.noneSaved")}):t.jsx("div",{className:"space-y-1 pt-1",children:u.map(b=>t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:b.label})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:b.lastUsedAt?s("settings.openchamber.passkeys.item.lastUsed",{time:Vo(b.lastUsedAt,s("settings.openchamber.passkeys.time.neverUsed"),e)}):s("settings.openchamber.passkeys.item.added",{time:Vo(b.createdAt,s("settings.openchamber.passkeys.time.neverUsed"),e)})}),t.jsx(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>{N(b.id)},disabled:c===b.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:c===b.id?s("settings.openchamber.passkeys.actions.removing"):s("settings.common.actions.delete")})]})]},b.id))})]}),h&&t.jsx("div",{className:"mt-1 px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:h})})]})},Kx=s=>{const e=un(s);return e||{providerId:"",modelId:""}},Yl=()=>{const{t:s}=dt(),e=ut(I=>I.setProvider),n=ut(I=>I.setModel),a=ut(I=>I.setAgent),r=ut(I=>I.setCurrentVariant),i=ut(I=>I.setSettingsDefaultModel),o=ut(I=>I.setSettingsDefaultVariant),d=ut(I=>I.setSettingsDefaultAgent),c=Ke(I=>I.showDeletionDialog),x=Ke(I=>I.setShowDeletionDialog),m=ut(I=>I.providers),[p,u]=l.useState(),[C,f]=l.useState(),[g,h]=l.useState(),[D,k]=l.useState(!0),w=l.useMemo(()=>Kx(p),[p]);l.useEffect(()=>{(async()=>{try{let v=null;if(!v){const j=zs()?.settings;if(j)try{const T=(await j.load())?.settings;T&&(v={defaultModel:typeof T.defaultModel=="string"?T.defaultModel:void 0,defaultVariant:typeof T.defaultVariant=="string"?T.defaultVariant:void 0,defaultAgent:typeof T.defaultAgent=="string"?T.defaultAgent:void 0})}catch{}}if(!v){const j=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});j.ok&&(v=await j.json())}if(v){const j=typeof v.defaultModel=="string"&&v.defaultModel.trim().length>0?v.defaultModel.trim():void 0,O=typeof v.defaultVariant=="string"&&v.defaultVariant.trim().length>0?v.defaultVariant.trim():void 0,T=typeof v.defaultAgent=="string"&&v.defaultAgent.trim().length>0?v.defaultAgent.trim():void 0;j!==void 0&&u(j),O!==void 0&&f(O),T!==void 0&&h(T)}}catch(v){console.warn("Failed to load defaults settings:",v)}finally{k(!1)}})()},[]);const E=l.useCallback(async(I,v)=>{const j=I&&v?`${I}/${v}`:void 0;u(j),f(void 0),o(void 0),r(void 0),i(j),I&&v&&m.find(T=>T.id===I)&&(e(I),n(v));try{await Ct({defaultModel:j??"",defaultVariant:""});const O=await yt("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultModel:j})});O.ok||console.warn("Failed to save default model to server:",O.status,O.statusText)}catch(O){console.warn("Failed to save default model:",O)}},[m,r,n,e,i,o]),N="__default__",y=l.useCallback(I=>I===N?s("settings.openchamber.defaults.option.default"):I.charAt(0).toUpperCase()+I.slice(1),[s]),b=l.useCallback(async I=>{const v=I===N?void 0:I||void 0;f(v),o(v),r(v);try{await Ct({defaultVariant:v??""})}catch(j){console.warn("Failed to save default variant:",j)}},[r,o]),P=l.useCallback(async I=>{const v=I||void 0;h(v),d(v),I&&a(I);try{await Ct({defaultAgent:v??""})}catch(j){console.warn("Failed to save default agent:",j)}},[a,d]),z=l.useMemo(()=>{if(!w.providerId||!w.modelId)return[];const j=m.find(O=>O.id===w.providerId)?.models.find(O=>O.id===w.modelId)?.variants;return j?Object.keys(j):[]},[w.modelId,w.providerId,m]),M=z.length>0;return l.useEffect(()=>{!M&&C&&(f(void 0),o(void 0),r(void 0),Ct({defaultVariant:""}).catch(()=>{}))},[C,r,o,M]),D?null:t.jsxs("div",{className:"mb-6",children:[t.jsx("div",{className:"mb-0.5 px-1",children:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.defaults.title")})})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"mt-0 mb-1 typography-meta text-muted-foreground",children:[s("settings.openchamber.defaults.summaryPrefix")," ",w.providerId?t.jsxs("span",{className:"text-foreground",children:[w.providerId,"/",w.modelId,M?` (${C??s("settings.openchamber.defaults.option.defaultLowercase")})`:""]}):t.jsx("span",{className:"text-foreground",children:s("settings.openchamber.defaults.summaryOpenCodeDefault")}),g&&t.jsxs(t.Fragment,{children:[" / ",t.jsx("span",{className:"text-foreground",children:g})]})]}),t.jsxs("div",{"data-settings-item":"sessions.default-model",className:ce("flex flex-col gap-2 py-1 sm:flex-row sm:items-center sm:gap-8"),children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.defaultModel")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(Hr,{providerId:w.providerId,modelId:w.modelId,onChange:E})})]}),t.jsxs("div",{"data-settings-item":"sessions.default-thinking",className:"flex flex-col gap-2 py-1 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.defaultThinking")})}),t.jsx("div",{className:"flex items-center gap-2 sm:w-fit",children:t.jsxs(Mt,{value:C??N,onValueChange:b,disabled:!M,children:[t.jsx(Rt,{className:"w-fit min-w-[120px]",children:t.jsx(Kt,{placeholder:s("settings.openchamber.defaults.field.thinkingPlaceholder"),children:y(C??N)})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:N,children:s("settings.openchamber.defaults.option.default")}),z.map(I=>t.jsx(gt,{value:I,children:y(I)},I))]})]})})]}),t.jsxs("div",{"data-settings-item":"sessions.default-agent",className:"flex flex-col gap-2 py-1 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.defaultAgent")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(fl,{agentName:g||"",onChange:P})})]}),t.jsxs("div",{"data-settings-item":"sessions.deletion-dialog",className:"group flex cursor-pointer items-center gap-2 py-1",role:"button",tabIndex:0,"aria-pressed":c,onClick:()=>x(!c),onKeyDown:I=>{(I.key===" "||I.key==="Enter")&&(I.preventDefault(),x(!c))},children:[t.jsx(St,{checked:c,onChange:x,ariaLabel:s("settings.openchamber.defaults.field.showDeletionDialogAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.showDeletionDialog")})]})]})]})},_o={completion:{titleKey:"settings.notifications.page.template.defaults.completion.title",messageKey:"settings.notifications.page.template.defaults.completion.message"},error:{titleKey:"settings.notifications.page.template.defaults.error.title",messageKey:"settings.notifications.page.template.defaults.error.message"},question:{titleKey:"settings.notifications.page.template.defaults.question.title",messageKey:"settings.notifications.page.template.defaults.question.message"},subtask:{titleKey:"settings.notifications.page.template.defaults.subtask.title",messageKey:"settings.notifications.page.template.defaults.subtask.message"}},$x={completion:"settings.notifications.page.template.event.completion",subtask:"settings.notifications.page.template.event.subtask",error:"settings.notifications.page.template.event.error",question:"settings.notifications.page.template.event.question"},Bx=()=>{const{t:s}=dt(),e=l.useMemo(()=>ds(),[]),n=l.useMemo(()=>fs(),[]),a=!e&&!n,r=Ke(F=>F.nativeNotificationsEnabled),i=Ke(F=>F.setNativeNotificationsEnabled),o=Ke(F=>F.notificationMode),d=Ke(F=>F.setNotificationMode),c=Ke(F=>F.notifyOnSubtasks),x=Ke(F=>F.setNotifyOnSubtasks),m=Ke(F=>F.notifyOnCompletion),p=Ke(F=>F.setNotifyOnCompletion),u=Ke(F=>F.notifyOnError),C=Ke(F=>F.setNotifyOnError),f=Ke(F=>F.notifyOnQuestion),g=Ke(F=>F.setNotifyOnQuestion),h=Ke(F=>F.notificationTemplates),D=Ke(F=>F.setNotificationTemplates),[k,w]=l.useState("default"),[E,N]=l.useState(!1),[y,b]=l.useState(!1),[P,z]=l.useState(!1);l.useEffect(()=>{if(!a){N(!1),b(!1);return}typeof Notification<"u"&&w(Notification.permission);const F=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;N(F),(async()=>{if(!F){b(!1);return}try{const X=await navigator.serviceWorker.getRegistration();if(!X){b(!1);return}const re=await X.pushManager.getSubscription();b(!!re)}catch{b(!1)}})()},[a]);const M=async F=>{if(e){i(F);return}if(!a){i(F);return}if(F&&typeof Notification<"u"&&Notification.permission==="default")try{const W=await Notification.requestPermission();w(W),W==="granted"?i(!0):_.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.description")})}catch(W){console.error("Failed to request notification permission:",W),_.error(s("settings.notifications.page.toast.requestPermissionFailed"))}else i(!!(F&&k==="granted"))},I=e||n||a&&typeof Notification<"u"&&Notification.permission==="granted",v=(F,W,X)=>{D({...h,[F]:{...h[F],[W]:X}})},j=F=>{const W="=".repeat((4-F.length%4)%4),X=(F+W).replace(/-/g,"+").replace(/_/g,"/"),re=atob(X),Z=new Uint8Array(re.length);for(let de=0;de<re.length;de+=1)Z[de]=re.charCodeAt(de);return Z},O=async(F,W,X)=>{let re=null;const Z=new Promise((de,le)=>{re=setTimeout(()=>{le(new Error(X))},W)});try{return await Promise.race([F,Z])}finally{re&&clearTimeout(re)}},T=async F=>{if(F.active)return;const W=F.installing||F.waiting;W&&W.state!=="activated"&&await O(new Promise(X=>{const re=()=>{W.state==="activated"&&(W.removeEventListener("statechange",re),X())};W.addEventListener("statechange",re),re()}),15e3,"Service worker activation timed out")},B=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const F=[{label:"no-options",opts:null},{label:"scope-root",opts:{scope:"/"}},{label:"type-classic",opts:{type:"classic"}},{label:"type-classic-scope",opts:{type:"classic",scope:"/"}},{label:"updateViaCache-none",opts:{type:"classic",updateViaCache:"none",scope:"/"}}];let W=null;for(const X of F)try{const re=X.opts?navigator.serviceWorker.register("/sw.js",X.opts):navigator.serviceWorker.register("/sw.js");return await O(re,1e4,`Service worker registration timed out (${X.label})`)}catch(re){W=re}throw W instanceof Error?W:new Error("Service worker registration failed")},U=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const F=await navigator.serviceWorker.getRegistration();if(F)return F;const W=await B();try{await W.update()}catch{}return await T(W),W},Q=F=>{const W=F,X=[`type=${typeof F}`,`toString=${String(F)}`,`name=${String(W?.name??"")}`,`message=${String(W?.message??"")}`];let re="";try{re=JSON.stringify(F)}catch{}return{summary:X.filter(Boolean).join(" | "),json:re,stack:typeof W?.stack=="string"?W.stack:""}},q=async()=>{const F=zs();if(!F?.notifications){_.error(s("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await F.notifications.notifyAgentCompletion({title:s("settings.notifications.page.testNotification.title"),body:s("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?_.success(s("settings.notifications.page.toast.testNotificationSent")):_.error(s("settings.notifications.page.toast.testNotificationFailed"))}catch(W){console.error("Test notification failed:",W),_.error(s("settings.notifications.page.toast.testNotificationFailed"))}},R=async()=>{if(!E){_.error(s("settings.notifications.page.toast.pushUnsupported"));return}const F=zs();if(!F?.push){_.error(s("settings.notifications.page.toast.pushApiUnavailable"));return}z(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const xe=await Notification.requestPermission();if(w(xe),xe!=="granted"){_.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){_.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const W=await F.push.getVapidPublicKey();if(!W?.publicKey){_.error(s("settings.notifications.page.toast.pushKeyLoadFailed"));return}const X=await U();await T(X);const re=await X.pushManager.getSubscription();if(!("pushManager"in X)||!X.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const de=(re??await O(X.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j(W.publicKey)}),15e3,"Push subscription timed out")).toJSON(),le=de.keys;if(!de.endpoint||!le?.p256dh||!le.auth)throw new Error("Push subscription missing keys");if(!(await O(F.push.subscribe({endpoint:de.endpoint,keys:{p256dh:le.p256dh,auth:le.auth},origin:typeof window<"u"?window.location.origin:void 0}),15e3,"Push subscribe request timed out"))?.ok){_.error(s("settings.notifications.page.toast.enableBackgroundFailed"));return}b(!0),_.success(s("settings.notifications.page.toast.backgroundEnabled"))}catch(W){console.error("[Push] Enable failed:",W);const X=Q(W);_.error(s("settings.notifications.page.toast.enableBackgroundFailed"),{description:X.summary})}finally{z(!1)}},Y=async()=>{if(!E){b(!1);return}const F=zs();if(!F?.push){_.error(s("settings.notifications.page.toast.pushApiUnavailable"));return}z(!0);try{const X=await(await U()).pushManager.getSubscription();if(!X){b(!1);return}const re=X.endpoint;await X.unsubscribe(),await F.push.unsubscribe({endpoint:re}),b(!1),_.success(s("settings.notifications.page.toast.backgroundDisabled"))}finally{z(!1)}};return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{"data-settings-item":"notifications.delivery",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.delivery.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":r&&I,onClick:()=>{M(!(r&&I))},onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),M(!(r&&I)))},children:[t.jsx(St,{checked:r&&I,onChange:F=>{M(F)},ariaLabel:s("settings.notifications.page.delivery.enableAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.delivery.enableLabel")})]}),r&&I&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":o==="always",onClick:()=>d(o==="always"?"hidden-only":"always"),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),d(o==="always"?"hidden-only":"always"))},children:[t.jsx(St,{checked:o==="always",onChange:F=>d(F?"always":"hidden-only"),ariaLabel:s("settings.notifications.page.delivery.focusedAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.delivery.focusedLabel")})]}),t.jsx("div",{className:"py-2",children:t.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>{q()},children:s("settings.notifications.page.delivery.testAction")})})]})]}),a&&t.jsxs("div",{className:"mt-1 px-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.notifications.page.delivery.browserPermissionHint")}),k==="denied"&&t.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:s("settings.notifications.page.delivery.permissionDenied")}),k==="granted"&&!r&&t.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:s("settings.notifications.page.delivery.permissionGrantedButDisabled")})]}),n&&t.jsx("div",{className:"mt-1 px-2",children:t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.notifications.page.delivery.vscodeHint")})})]}),r&&I&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-settings-item":"notifications.events",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.events.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":m,onClick:()=>p(!m),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),p(!m))},children:[t.jsx(St,{checked:m,onChange:p,ariaLabel:s("settings.notifications.page.events.completionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.completionLabel")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":c,onClick:()=>x(!c),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),x(!c))},children:[t.jsx(St,{checked:c,onChange:x,ariaLabel:s("settings.notifications.page.events.subtaskAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.subtaskLabel")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":u,onClick:()=>C(!u),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),C(!u))},children:[t.jsx(St,{checked:u,onChange:C,ariaLabel:s("settings.notifications.page.events.errorAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.errorLabel")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":f,onClick:()=>g(!f),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),g(!f))},children:[t.jsx(St,{checked:f,onChange:g,ariaLabel:s("settings.notifications.page.events.questionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.questionLabel")})]})]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.template.title")}),t.jsxs("p",{className:"typography-meta text-muted-foreground mt-0.5",children:[s("settings.notifications.page.template.variablesLabel")," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{project_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{worktree}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{branch}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{session_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{agent_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{model_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{last_message}"})]})]}),t.jsx("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3",children:["completion","subtask","error","question"].map(F=>t.jsxs("section",{className:"p-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground font-normal capitalize block",children:s($x[F])}),t.jsxs("div",{className:"mt-1.5 space-y-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:s("settings.notifications.page.template.field.title")}),t.jsx(ot,{value:h[F].title,onChange:W=>v(F,"title",W.target.value),className:"h-7",placeholder:s(_o[F].titleKey)})]}),t.jsxs("div",{children:[t.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:s("settings.notifications.page.template.field.message")}),t.jsx(ot,{value:h[F].message,onChange:W=>v(F,"message",W.target.value),className:"h-7",placeholder:s(_o[F].messageKey)})]})]})]},F))})]})]}),a&&t.jsxs("div",{"data-settings-item":"notifications.push",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.push.title")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex items-start gap-2 py-1.5",children:[t.jsx(St,{checked:E?y:!1,disabled:!E||P,onChange:F=>{F?R():Y()},ariaLabel:s("settings.notifications.page.push.enableAria")}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:ce("typography-ui-label",E?"text-foreground":"text-muted-foreground"),children:s("settings.notifications.page.push.enableLabel")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s(E?"settings.notifications.page.push.supportedHint":"settings.notifications.page.push.unsupportedHint")})]}),P&&t.jsx("div",{className:"pt-0.5 text-muted-foreground",children:t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":s("settings.notifications.page.push.loadingAria")})})]})})]})]})},js=s=>{if(!s)return;s.pause();const{src:e}=s;e.startsWith("blob:")&&URL.revokeObjectURL(e),s.removeAttribute("src"),s.load()},Ux=[{value:"en-US",label:"English"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"},{value:"de-DE",label:"Deutsch"},{value:"ja-JP",label:"日本語"},{value:"zh-CN",label:"中文"},{value:"pt-BR",label:"Português"},{value:"it-IT",label:"Italiano"},{value:"ko-KR",label:"한국어"},{value:"uk-UA",label:"Українська"}],Vx=s=>{const e=rt.c(45),{modelId:n}=s,{t:a}=dt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Gn.getModelStatus(),e[0]=r):r=e[0];const[i,o]=ve.useState(r),[d,c]=ve.useState(!1);let x,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const y=b=>o(b);return Gn.onModelStatusChange=y,Wx},m=[],e[1]=x,e[2]=m):(x=e[1],m=e[2]),ve.useEffect(x,m);const p=Gn.getCurrentModelId(),u=i.state==="downloading"||i.state==="loading";let C,f;e[3]!==i.state?(C=()=>{i.state!=="downloading"&&i.state!=="loading"&&c(!1)},f=[i.state],e[3]=i.state,e[4]=C,e[5]=f):(C=e[4],f=e[5]),ve.useEffect(C,f);let g;e[6]!==n?(g=async()=>{c(!0);try{await Gn.loadModel(n)}catch{}},e[6]=n,e[7]=g):g=e[7];const h=g;if(i.state==="ready"&&p===n){let y;e[8]!==a?(y=a("settings.voice.page.stt.wasmLoaded"),e[8]=a,e[9]=y):y=e[9];let b;return e[10]!==y?(b=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"typography-ui-compact text-green-600 dark:text-green-400",children:y})}),e[10]=y,e[11]=b):b=e[11],b}if(u){let y;e[12]!==i.progress||e[13]!==i.state?(y=i.state==="downloading"?Math.round(i.progress):void 0,e[12]=i.progress,e[13]=i.state,e[14]=y):y=e[14];const b=y;let P;e[15]!==i.state||e[16]!==a?(P=i.state==="downloading"?a("settings.voice.page.stt.wasmDownloading"):a("settings.voice.page.stt.wasmLoading"),e[15]=i.state,e[16]=a,e[17]=P):P=e[17];const z=b!==void 0?` (${b}%)`:"";let M;return e[18]!==P||e[19]!==z?(M=t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs("span",{className:"typography-ui-compact text-muted-foreground",children:[P,z]})}),e[18]=P,e[19]=z,e[20]=M):M=e[20],M}if(i.state==="error"){let y;e[21]!==i.error?(y=t.jsx("span",{className:"typography-ui-compact text-destructive",children:i.error}),e[21]=i.error,e[22]=y):y=e[22];let b;e[23]!==a?(b=a("settings.voice.page.stt.wasmRetry"),e[23]=a,e[24]=b):b=e[24];let P;e[25]!==h||e[26]!==d||e[27]!==b?(P=t.jsx(J,{variant:"chip",size:"xs",disabled:d,onClick:h,children:b}),e[25]=h,e[26]=d,e[27]=b,e[28]=P):P=e[28];let z;return e[29]!==y||e[30]!==P?(z=t.jsxs("div",{className:"flex items-center gap-2",children:[y,P]}),e[29]=y,e[30]=P,e[31]=z):z=e[31],z}let D;e[32]!==a?(D=a("settings.voice.page.stt.wasmNotLoaded"),e[32]=a,e[33]=D):D=e[33];let k;e[34]!==D?(k=t.jsx("span",{className:"typography-ui-compact text-muted-foreground",children:D}),e[34]=D,e[35]=k):k=e[35];let w;e[36]!==a?(w=a("settings.voice.page.stt.wasmDownload"),e[36]=a,e[37]=w):w=e[37];let E;e[38]!==h||e[39]!==d||e[40]!==w?(E=t.jsx(J,{variant:"chip",size:"xs",disabled:d,onClick:h,children:w}),e[38]=h,e[39]=d,e[40]=w,e[41]=E):E=e[41];let N;return e[42]!==E||e[43]!==k?(N=t.jsxs("div",{className:"flex items-center gap-2",children:[k,E]}),e[42]=E,e[43]=k,e[44]=N):N=e[44],N},_x=[{value:"alloy",label:"Alloy"},{value:"ash",label:"Ash"},{value:"ballad",label:"Ballad"},{value:"coral",label:"Coral"},{value:"echo",label:"Echo"},{value:"fable",label:"Fable"},{value:"nova",label:"Nova"},{value:"onyx",label:"Onyx"},{value:"sage",label:"Sage"},{value:"shimmer",label:"Shimmer"},{value:"verse",label:"Verse"},{value:"marin",label:"Marin"},{value:"cedar",label:"Cedar"}],Hx=()=>{const{t:s}=dt(),{isMobile:e}=Cs(),{isSupported:n,language:a,setLanguage:r}=bm(),i=ut(L=>L.voiceProvider),o=ut(L=>L.setVoiceProvider),d=ut(L=>L.speechRate),c=ut(L=>L.setSpeechRate),x=ut(L=>L.speechPitch),m=ut(L=>L.setSpeechPitch),p=ut(L=>L.speechVolume),u=ut(L=>L.setSpeechVolume),C=ut(L=>L.sayVoice),f=ut(L=>L.setSayVoice),g=ut(L=>L.browserVoice),h=ut(L=>L.setBrowserVoice),D=ut(L=>L.openaiVoice),k=ut(L=>L.setOpenaiVoice),w=ut(L=>L.openaiApiKey),E=ut(L=>L.setOpenaiApiKey),N=ut(L=>L.openaiCompatibleUrl),y=ut(L=>L.setOpenaiCompatibleUrl),b=ut(L=>L.openaiCompatibleApiKey),P=ut(L=>L.setOpenaiCompatibleApiKey),z=ut(L=>L.openaiCompatibleVoice),M=ut(L=>L.setOpenaiCompatibleVoice),I=ut(L=>L.openaiCompatibleTtsModel),v=ut(L=>L.setOpenaiCompatibleTtsModel),j=ut(L=>L.showMessageTTSButtons),O=ut(L=>L.ttsInputMode),T=ut(L=>L.setTtsInputMode),B=ut(L=>L.sttProvider),U=ut(L=>L.setSttProvider),Q=ut(L=>L.sttServerUrl),q=ut(L=>L.setSttServerUrl),R=ut(L=>L.sttApiKey),Y=ut(L=>L.setSttApiKey),F=ut(L=>L.sttModel),W=ut(L=>L.setSttModel),X=ut(L=>L.wasmSttModel),re=ut(L=>L.setWasmSttModel),Z=ut(L=>L.sttLanguage),de=ut(L=>L.setSttLanguage),le=ut(L=>L.sttSilenceThresholdDb),ee=ut(L=>L.setSttSilenceThresholdDb),xe=ut(L=>L.sttSilenceHoldMs),we=ut(L=>L.setSttSilenceHoldMs),he=ut(L=>L.sttTranscribeOnStop),Ie=ut(L=>L.setSttTranscribeOnStop),be=ut(L=>L.setShowMessageTTSButtons),je=ut(L=>L.voiceModeEnabled),ye=ut(L=>L.setVoiceModeEnabled),[se,ie]=ve.useState(!1),[ge,V]=ve.useState([]),[te,ne]=ve.useState(!1),[ue,Me]=ve.useState(null),[ke,Re]=ve.useState(!1),[Ae,Pe]=ve.useState(!1),[Te,Fe]=ve.useState(null),[Be,We]=ve.useState(!1),[ze,Qe]=ve.useState(null),[oe,H]=ve.useState([]),[me,Ne]=ve.useState(!1);ve.useEffect(()=>((async()=>{const Le=await Qa.waitForVoices();H(Le)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{H(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const Ee=ve.useMemo(()=>oe.filter(L=>L.lang).sort((L,Le)=>{const Je=L.lang.startsWith("en"),Xe=Le.lang.startsWith("en");if(Je&&!Xe)return-1;if(!Je&&Xe)return 1;const et=L.lang.localeCompare(Le.lang);return et!==0?et:L.name.localeCompare(Le.name)}),[oe]),Ce=ve.useCallback(()=>{if(me){Qa.cancelSpeech(),Ne(!1);return}const L=oe.find(et=>et.name===g),Le=L?.name??s("settings.voice.page.preview.browserVoiceFallback"),Je=s("settings.voice.page.preview.voiceLine",{voiceName:Le});Ne(!0);const Xe=new SpeechSynthesisUtterance(Je);Xe.rate=d,Xe.pitch=x,Xe.volume=p,L&&(Xe.voice=L,Xe.lang=L.lang),Xe.onend=()=>Ne(!1),Xe.onerror=()=>Ne(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(Xe)},[g,oe,d,x,p,me,s]);ve.useEffect(()=>()=>{me&&Qa.cancelSpeech()},[me]),ve.useEffect(()=>{if(!je||i!=="openai"&&i!=="openai-compatible"){Re(w.trim().length>0);return}(async()=>{try{const Xe=(await(await yt("/api/tts/status")).json()).available,et=w.trim().length>0;Re(Xe||et)}catch{Re(w.trim().length>0)}})()},[w,je,i]),ve.useEffect(()=>{if(!je){ie(!1),V([]);return}yt("/api/tts/say/status").then(L=>L.json()).then(L=>{if(ie(L.available),L.voices){const Le=L.voices.filter((Je,Xe,et)=>et.findIndex(at=>at.name===Je.name)===Xe).sort((Je,Xe)=>Je.name.localeCompare(Xe.name));V(Le)}}).catch(()=>{ie(!1)})},[je]);const _e=ve.useCallback(async()=>{if(ue){js(ue),Me(null),ne(!1);return}ne(!0);let L=null;try{const Le=await yt("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.voiceLine",{voiceName:C}),voice:C,rate:Math.round(100+(d-.5)*200)})});if(!Le.ok)throw new Error("Preview failed");const Je=await Le.blob(),Xe=URL.createObjectURL(Je);L=new Audio(Xe),L.onended=()=>{js(L),Me(null),ne(!1)},L.onerror=()=>{js(L),Me(null),ne(!1)},Me(L),await L.play()}catch{js(L),Me(null),ne(!1)}},[C,d,ue,s]);ve.useEffect(()=>()=>{js(ue)},[ue]);const G=ve.useCallback(async()=>{if(Te){js(Te),Fe(null),Pe(!1);return}Pe(!0);let L=null;try{const Le=await yt("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.voiceLine",{voiceName:D}),voice:D,speed:d,apiKey:w||void 0})});if(!Le.ok){const et=await Le.json().catch(()=>({error:"Unknown error"}));throw new Error(et.error||`HTTP ${Le.status}`)}const Je=await Le.blob(),Xe=URL.createObjectURL(Je);L=new Audio(Xe),L.onended=()=>{js(L),Fe(null),Pe(!1)},L.onerror=()=>{js(L),Fe(null),Pe(!1)},Fe(L),await L.play()}catch{js(L),Fe(null),Pe(!1)}},[D,d,Te,w,s]);ve.useEffect(()=>()=>{js(Te)},[Te]);const $=ve.useCallback(async()=>{if(ze){js(ze),Qe(null),We(!1);return}if(!N.trim())return;We(!0);let L=null;try{const Le=await yt("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.customServerLine"),voice:z,model:I||void 0,speed:d,baseURL:N,apiKey:b||void 0})});if(!Le.ok){const et=await Le.json().catch(()=>({error:"Unknown error"}));throw new Error(et.error||`HTTP ${Le.status}`)}const Je=await Le.blob(),Xe=URL.createObjectURL(Je);L=new Audio(Xe),L.onended=()=>{js(L),Qe(null),We(!1)},L.onerror=()=>{js(L),Qe(null),We(!1)},Qe(L),await L.play()}catch{js(L),Qe(null),We(!1)}},[N,z,I,b,d,ze,s]);ve.useEffect(()=>()=>{js(ze)},[ze]);const fe="flex-1 min-w-0 h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50";return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{"data-settings-item":"voice.voice-setup",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.voice.page.section.voiceSetup")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":je,onClick:()=>ye(!je),onKeyDown:L=>{(L.key===" "||L.key==="Enter")&&(L.preventDefault(),ye(!je))},children:[t.jsx(St,{checked:je,onChange:ye,ariaLabel:s("settings.voice.page.field.enableVoiceModeAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.enableVoiceMode")})]}),je&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.provider")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:t.jsxs("ul",{className:"space-y-1",children:[t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.browser")})," ",s("settings.voice.page.tooltip.browser")]}),t.jsxs("li",{children:[t.jsx("strong",{children:"OpenAI:"})," ",s("settings.voice.page.tooltip.openai")]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.custom")})," ",s("settings.voice.page.tooltip.custom")]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.say")})," ",s("settings.voice.page.tooltip.say")]})]})})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(J,{variant:"chip",size:"xs","aria-pressed":i==="browser",onClick:()=>o("browser"),className:"!font-normal",children:s("settings.voice.page.provider.browser")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":i==="openai",onClick:()=>o("openai"),className:"!font-normal",children:"OpenAI"}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":i==="openai-compatible",onClick:()=>o("openai-compatible"),className:"!font-normal",children:s("settings.voice.page.provider.custom")}),se&&t.jsxs(J,{variant:"chip",size:"xs","aria-pressed":i==="say",onClick:()=>o("say"),className:"!font-normal",children:[t.jsx(A,{name:"apple",className:"w-3.5 h-3.5 mr-0.5"}),s("settings.voice.page.provider.say")]})]})]})}),i==="openai"&&t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!ke&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.apiKey")}),t.jsx("span",{className:ce("typography-meta ml-2",ke?"text-muted-foreground":"text-[var(--status-error)]/80"),children:s(ke&&!w?"settings.voice.page.field.apiKeyHintUsingConfig":ke?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired")}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"password",value:w,onChange:L=>E(L.target.value),placeholder:"sk-...",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),w&&t.jsx("button",{type:"button",onClick:()=>E(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(A,{name:"close",className:"w-3.5 h-3.5"})})]})]}),i==="openai-compatible"&&t.jsxs("div",{className:"py-1.5 space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!N.trim()&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.serverUrl")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.serverUrlHint")}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"text",value:N,onChange:L=>y(L.target.value),placeholder:"http://localhost:8880/v1",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),N&&t.jsx("button",{type:"button",onClick:()=>y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(A,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"API Key"}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:"Optional"}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"password",value:b,onChange:L=>P(L.target.value),placeholder:"sk-...",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),b&&t.jsx("button",{type:"button",onClick:()=>P(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(A,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.model")}),t.jsx("div",{className:"relative mt-1.5 max-w-xs",children:t.jsx("input",{type:"text",value:I,onChange:L=>v(L.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.voice")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.voiceIdentifierHint")}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx("div",{className:"relative max-w-xs flex-1",children:t.jsx("input",{type:"text",value:z,onChange:L=>M(L.target.value),placeholder:"af_sky",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})}),t.jsx(J,{size:"xs",variant:"ghost",onClick:$,title:s("settings.voice.page.actions.preview"),disabled:!N.trim(),children:Be?t.jsx(A,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(A,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.voice")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[i==="openai"&&ke&&t.jsxs(t.Fragment,{children:[t.jsxs(Mt,{value:D,onValueChange:k,children:[t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder")})}),t.jsx(Tt,{children:_x.map(L=>t.jsx(gt,{value:L.value,children:L.label},L.value))})]}),t.jsx(J,{size:"xs",variant:"ghost",onClick:G,title:s("settings.voice.page.actions.preview"),children:Ae?t.jsx(A,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(A,{name:"play",className:"w-3.5 h-3.5"})})]}),i==="openai-compatible"&&t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.voice.page.field.configuredAbove")}),i==="say"&&se&&ge.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs(Mt,{value:C,onValueChange:f,children:[t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder")})}),t.jsx(Tt,{children:ge.map(L=>t.jsx(gt,{value:L.name,children:L.name},L.name))})]}),t.jsx(J,{size:"xs",variant:"ghost",onClick:_e,title:s("settings.voice.page.actions.preview"),children:te?t.jsx(A,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(A,{name:"play",className:"w-3.5 h-3.5"})})]}),i==="browser"&&Ee.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs(Mt,{value:g||"$auto",onValueChange:L=>h(L==="$auto"?"":L),children:[t.jsx(Rt,{className:"w-fit max-w-[200px]",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.auto")})}),t.jsxs(Tt,{children:[t.jsx(gt,{value:"$auto",children:s("settings.voice.page.field.auto")}),Ee.map(L=>t.jsxs(gt,{value:L.name,children:[L.name," (",L.lang,")"]},L.name))]})]}),t.jsx(J,{size:"xs",variant:"ghost",onClick:Ce,title:s("settings.voice.page.actions.preview"),children:me?t.jsx(A,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(A,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.speechRate")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:.5,max:2,step:.1,value:d,onChange:L=>c(Number(L.target.value)),disabled:!n,className:fe}),t.jsx(bs,{value:d,onValueChange:c,min:.5,max:2,step:.1,className:"w-16 tabular-nums"})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.speechPitch")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:.5,max:2,step:.1,value:x,onChange:L=>m(Number(L.target.value)),disabled:!n,className:fe}),t.jsx(bs,{value:x,onValueChange:m,min:.5,max:2,step:.1,className:"w-16 tabular-nums"})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.speechVolume")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:0,max:1,step:.1,value:p,onChange:L=>u(Number(L.target.value)),disabled:!n,className:fe}),e?t.jsx(bs,{value:Math.round(p*100),onValueChange:L=>u(L/100),min:0,max:100,step:10,className:"w-16 tabular-nums"}):t.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right",children:[Math.round(p*100),"%"]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.language")}),t.jsx("div",{className:"flex items-center gap-2 w-fit",children:t.jsxs(Mt,{value:a,onValueChange:r,disabled:!n,children:[t.jsx(Rt,{className:"w-fit",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.selectLanguagePlaceholder")})}),t.jsx(Tt,{children:Ux.map(L=>t.jsx(gt,{value:L.value,children:L.label},L.value))})]})})]})]})]})]}),je&&t.jsxs("div",{"data-settings-item":"voice.speech-recognition",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.voice.page.section.speechRecognition")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsx("div",{className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.provider")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:t.jsxs("ul",{className:"space-y-1",children:[t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.browser")})," ",s("settings.voice.page.tooltip.sttBrowser")]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.server")})," ",s("settings.voice.page.tooltip.sttServer")]})]})})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(J,{variant:"chip",size:"xs","aria-pressed":B==="browser",onClick:()=>U("browser"),className:"!font-normal",children:s("settings.voice.page.provider.browser")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":B==="server",onClick:()=>U("server"),className:"!font-normal",children:s("settings.voice.page.provider.server")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":B==="wasm",onClick:()=>U("wasm"),className:"!font-normal",children:s("settings.voice.page.provider.wasm")})]})]})}),B==="server"&&t.jsxs("div",{className:"py-1.5 space-y-2",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":he,onClick:()=>Ie(!he),onKeyDown:L=>{(L.key===" "||L.key==="Enter")&&(L.preventDefault(),Ie(!he))},children:[t.jsx(St,{checked:he,onChange:Ie,ariaLabel:s("settings.voice.page.field.transcribeOnStopAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.transcribeOnStop")})]}),!ym.isSupported()&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:s("settings.voice.page.field.sttBrowserSupportError")}),t.jsxs("div",{children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!Q.trim()&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.serverUrl")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.sttServerUrlHint")}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"text",value:Q,onChange:L=>q(L.target.value),placeholder:"http://localhost:8001/v1",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),Q&&t.jsx("button",{type:"button",onClick:()=>q(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(A,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"API Key"}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:"Optional"}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"password",value:R,onChange:L=>Y(L.target.value),placeholder:"sk-...",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),R&&t.jsx("button",{type:"button",onClick:()=>Y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(A,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.model")}),t.jsx("div",{className:"relative mt-1.5 max-w-xs",children:t.jsx("input",{type:"text",value:F,onChange:L=>W(L.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.language")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.sttLanguageHint")}),t.jsx("div",{className:"relative mt-1.5 max-w-[8rem]",children:t.jsx("input",{type:"text",value:Z,onChange:L=>de(L.target.value),placeholder:"auto",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})})]}),t.jsxs("div",{className:"flex items-center gap-8 py-0.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.silenceThreshold")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:-60,max:-20,step:1,value:le,onChange:L=>ee(Number(L.target.value)),className:fe}),t.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3.5rem] text-right",children:[le," dB"]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-0.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.silenceHold")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:500,max:3e3,step:100,value:xe,onChange:L=>we(Number(L.target.value)),className:fe}),t.jsx(bs,{value:xe,onValueChange:we,min:500,max:3e3,step:100,className:"w-20 tabular-nums"}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.voice.page.field.millisecondsUnit")})]})]})]}),B==="wasm"&&t.jsxs("div",{className:"py-1.5 space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-muted-foreground",children:s("settings.voice.page.stt.wasmModel")}),t.jsxs(Mt,{value:X,onValueChange:re,children:[t.jsx(Rt,{className:"mt-0.5",children:t.jsx(Kt,{placeholder:s("settings.voice.page.stt.wasmModel")})}),t.jsx(Tt,{children:hi.map(L=>t.jsx(gt,{value:L.id,children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:L.name}),t.jsxs("span",{className:"typography-ui-compact text-muted-foreground",children:[L.size," · ",L.languages]})]})},L.id))})]}),t.jsx("p",{className:"typography-ui-compact text-muted-foreground mt-0.5",children:hi.find(L=>L.id===X)?.description})]}),t.jsx(Vx,{modelId:X})]})]})]}),t.jsxs("div",{"data-settings-item":"voice.playback",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.voice.page.section.playbackAndSummary")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":j,onClick:()=>be(!j),onKeyDown:L=>{(L.key===" "||L.key==="Enter")&&(L.preventDefault(),be(!j))},children:[t.jsx(St,{checked:j,onChange:be,ariaLabel:s("settings.voice.page.field.messageReadAloudButtonAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.messageReadAloudButton")})]}),t.jsx("div",{className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.ttsInputMode")})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(J,{variant:"chip",size:"xs","aria-pressed":O==="sanitized",onClick:()=>T("sanitized"),className:"!font-normal",children:s("settings.voice.page.field.ttsInputModeSanitized")}),t.jsx(J,{variant:"chip",size:"xs","aria-pressed":O==="raw",onClick:()=>T("raw"),className:"!font-normal",children:s("settings.voice.page.field.ttsInputModeRaw")})]})]})})]}),je&&n&&t.jsx("div",{className:"mt-2 px-2",children:t.jsxs("p",{className:"typography-meta text-muted-foreground",children:[s("settings.voice.page.hint.shiftClickPrefix")," ",t.jsx("kbd",{className:"px-1 py-0.5 mx-0.5 rounded border border-[var(--interactive-border)] bg-background typography-mono text-[10px]",children:"Shift"})," + ",t.jsx("kbd",{className:"px-1 py-0.5 mx-0.5 rounded border border-[var(--interactive-border)] bg-background typography-mono text-[10px]",children:"Click"})," ",s("settings.voice.page.hint.shiftClickSuffix")]})})]})]})};function Wx(){Gn.onModelStatusChange=null}const xa=[{value:"1800000",label:"30m",ms:1800*1e3},{value:"180000",label:"3m",ms:180*1e3},{value:"7200000",label:"2h",ms:7200*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3}],ba=[{value:"3600000",label:"1h",ms:3600*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"43200000",label:"12h",ms:720*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3},{value:"604800000",label:"1w",ms:10080*60*1e3},{value:"2592000000",label:"30d",ms:720*60*60*1e3}],qx="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",Gx="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",pr=[{value:"quick",labelKey:"settings.openchamber.tunnel.option.mode.quick.label",tooltipKey:"settings.openchamber.tunnel.option.mode.quick.tooltip"},{value:"managed-remote",labelKey:"settings.openchamber.tunnel.option.mode.managedRemote.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedRemote.tooltip"},{value:"managed-local",labelKey:"settings.openchamber.tunnel.option.mode.managedLocal.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedLocal.tooltip"}],Jx=[".yml",".yaml",".json"],Qx="settings.openchamber.tunnel.error.invalidConfigExtension",Wn=s=>{const e=s.trim().toLowerCase();return Jx.some(n=>e.endsWith(n))},Yx=s=>s==="ngrok"?"ngrok":"cloudflared",Xl=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const s=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return s.includes("win")?"win32":s.includes("mac")?"darwin":"linux"},Xx=(s,e=Xl())=>s==="ngrok"?e==="win32"?"winget install ngrok -s msstore":e==="darwin"?"brew install ngrok":"https://ngrok.com/download":e==="win32"?"winget install --id Cloudflare.cloudflared":e==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflared/downloads/",gr=(s,e)=>{const n=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():s,a=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():Yx(n),r=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():Xl(),i=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():Xx(n,r);return{provider:n,dependency:a,installCommand:i}},Zl=s=>s==="cloudflare"?"Cloudflare":s==="ngrok"?"Ngrok":s,Ho=s=>{const e=rt.c(11),{provider:n}=s;let a;e[0]!==n?(a=Zl(n),e[0]=n,e[1]=a):a=e[1];const r=a,d=n==="cloudflare"||n==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let c;e[2]!==d?(c=ce("size-4 shrink-0",d),e[2]=d,e[3]=c):c=e[3];let x;e[4]!==c?(x=t.jsx(A,{name:"cloud",className:c}),e[4]=c,e[5]=x):x=e[5];let m;e[6]!==r?(m=t.jsx("span",{children:r}),e[6]=r,e[7]=m):m=e[7];let p;return e[8]!==x||e[9]!==m?(p=t.jsxs("span",{className:"flex items-center gap-2",children:[x,m]}),e[8]=x,e[9]=m,e[10]=p):p=e[10],p},Zs=s=>s==="quick"?"quick":s==="managed-remote"?"managed-remote":s==="managed-local"?"managed-local":"quick",Lr=(s,e,n)=>s.find(r=>r.ms===e)?.value||n,Wo=(s,e,n)=>{const a=Lr(s,e,n);return s.find(r=>r.value===a)?.label||a},qo=s=>{const e=Math.max(0,s),n=Math.floor(e/1e3),a=Math.floor(n/3600),r=Math.floor(n%3600/60),i=n%60;return a>0?`${a}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`},Zx=(s,e)=>Nl(s,e,{hour:"2-digit",precision:"second"}),Ea=s=>{const e=s.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},eb=s=>{if(!Array.isArray(s))return[];const e=new Set,n=new Set,a=[];for(const r of s){if(!r||typeof r!="object")continue;const i=r,o=typeof i.id=="string"?i.id.trim():"",d=typeof i.name=="string"?i.name.trim():"",c=Ea(typeof i.hostname=="string"?i.hostname:"");!o||!d||!c||e.has(o)||n.has(c)||(e.add(o),n.add(c),a.push({id:o,name:d,hostname:c}))}return a},tb=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,sb=()=>{const{t:s}=dt(),e=Ke(ae=>ae.timeFormatPreference),n=l.useCallback(ae=>s(ae),[s]),[a,r]=l.useState("checking"),[i,o]=l.useState(null),[d,c]=l.useState(null),[x,m]=l.useState(null),[p,u]=l.useState(null),[C,f]=l.useState(null),[g,h]=l.useState(!1),[D,k]=l.useState(!1),[w,E]=l.useState(!1),[N,y]=l.useState("cloudflare"),[b,P]=l.useState(()=>gr("cloudflare")),[z,M]=l.useState([]),[I,v]=l.useState("quick"),[j,O]=l.useState(null),[T,B]=l.useState([]),[U,Q]=l.useState({}),[q,R]=l.useState(""),[Y,F]=l.useState({}),[W,X]=l.useState(new Set),[re,Z]=l.useState(!1),[de,le]=l.useState(""),[ee,xe]=l.useState(""),[we,he]=l.useState(""),[Ie,be]=l.useState(1800*1e3),[je,ye]=l.useState(480*60*1e3),[se,ie]=l.useState(""),[ge,V]=l.useState([]),[te,ne]=l.useState(()=>Date.now()),[ue,Me]=l.useState(null),ke=s(Qx),Re=l.useRef(null),Ae=l.useMemo(()=>j?!Wn(j):!1,[j]),Pe=l.useMemo(()=>T.find(ae=>ae.id===q)||T[0]||null,[T,q]),Te=l.useMemo(()=>ge.map(ae=>{const Ue=ae.expiresAt<=te,tt=ae.status==="active"&&!Ue,Ye=tt?qo(ae.expiresAt-te):ae.inactiveReason==="expired"||Ue?"expired":"inactive",ft=Ye==="expired"?s("settings.openchamber.tunnel.state.expired"):ae.inactiveReason==="tunnel-revoked"?s("settings.openchamber.tunnel.state.revoked"):s("settings.openchamber.tunnel.state.inactive"),$e=Zs(ae.mode);return{...ae,isActive:tt,mode:$e,remainingTextForSession:Ye,inactiveLabel:ft}}),[te,ge,s]),Fe=l.useMemo(()=>i?.connectUrl?i.bootstrapExpiresAt===null?!0:i.bootstrapExpiresAt>te:!1,[te,i?.bootstrapExpiresAt,i?.connectUrl]),Be=l.useMemo(()=>!i||a!=="active"&&a!=="stopping"?!1:d===I,[d,a,i,I]),We=l.useMemo(()=>!i||a!=="active"||!d?!1:d!==I,[d,a,i,I]),ze=l.useMemo(()=>{if(typeof ue=="number"&&Number.isFinite(ue)&&ue>0)return ue;if(typeof window>"u")return null;const Ue=ea()||window.location.href;let tt=0;try{tt=Number(new URL(Ue).port)}catch{tt=Number(window.location.port)}return Number.isFinite(tt)&&tt>0?tt:null},[ue]),Qe=l.useMemo(()=>z.find(ae=>ae.provider===N)??null,[z,N]),oe=l.useMemo(()=>{const ae=new Set(Qe?.modes?.map(Ue=>Ue.key).filter(Ue=>Ue==="quick"||Ue==="managed-remote"||Ue==="managed-local"));return ae.size===0?pr:pr.filter(Ue=>ae.has(Ue.value))},[Qe]),H=l.useMemo(()=>oe.some(ae=>ae.value==="managed-remote"||ae.value==="managed-local"),[oe]),me=l.useMemo(()=>b.provider===N?b:gr(N),[b,N]),Ne=l.useCallback(async ae=>{await Ws(ae)},[]),Ee=l.useCallback((ae,Ue)=>(P(gr(Ue,ae)),ae.available===!0),[]),Ce=l.useCallback(async(ae,Ue)=>{try{const tt=await yt("/api/openchamber/tunnel/check",{query:{provider:ae},...Ue?{signal:Ue}:{}});if(!tt.ok)return null;const Ye=await tt.json();if(Ue?.aborted)return null;const ft=Ee(Ye,ae);return r($e=>$e==="checking"||$e==="starting"||$e==="active"||$e==="stopping"?$e:ft?"idle":"not-available"),ft}catch{return null}},[Ee]),_e=l.useCallback(async ae=>{try{const[Ue,tt,Ye,ft]=await Promise.all([yt("/api/openchamber/tunnel/check",{signal:ae}),yt("/api/openchamber/tunnel/status",{signal:ae}),yt("/api/config/settings",{signal:ae,headers:{Accept:"application/json"}}),yt("/api/openchamber/tunnel/providers",{signal:ae})]),$e=await Ue.json(),Ve=await tt.json(),it=Ye.ok?await Ye.json():{},xt=ft.ok?await ft.json():{},At=Ve.ttlConfig?.bootstrapTtlMs??(it?.tunnelBootstrapTtlMs===null?null:typeof it?.tunnelBootstrapTtlMs=="number"?it.tunnelBootstrapTtlMs:1800*1e3),Zt=typeof Ve.ttlConfig?.sessionTtlMs=="number"?Ve.ttlConfig.sessionTtlMs:typeof it?.tunnelSessionTtlMs=="number"?it.tunnelSessionTtlMs:480*60*1e3,ts=Zs(Ve.mode??it?.tunnelMode),ss=typeof it?.tunnelProvider=="string"&&it.tunnelProvider.trim().length>0?it.tunnelProvider.trim().toLowerCase():"cloudflare",Vt=typeof it?.managedLocalTunnelConfigPath=="string"&&it.managedLocalTunnelConfigPath.trim()||null,Se=Ee($e,ss),vt=eb(Ve?.managedRemoteTunnelPresets),jt=typeof Ve.managedRemoteTunnelHostname=="string"?Ve.managedRemoteTunnelHostname:"",lt=vt.length>0?vt:jt?[{id:`legacy-${Ea(jt)}`,name:jt,hostname:Ea(jt)}]:[],Et=lt[0]?.id||"";if(be(At),ye(Zt),y(ss),M(Array.isArray(xt?.providers)?xt.providers:[]),v(ts),O(Vt),B(lt),R(Et),V(Array.isArray(Ve.activeSessions)?Ve.activeSessions:[]),c(Ve.activeTunnelMode?Zs(Ve.activeTunnelMode):Ve.active&&Ve.mode?Zs(Ve.mode):null),X(new Set(Array.isArray(Ve.managedRemoteTunnelTokenPresetIds)?Ve.managedRemoteTunnelTokenPresetIds:[])),Me(typeof Ve.localPort=="number"?Ve.localPort:null),Ve.active&&Ve.url){o({url:Ve.url,connectUrl:null,bootstrapExpiresAt:typeof Ve.bootstrapExpiresAt=="number"?Ve.bootstrapExpiresAt:null}),r("active");return}r(Se?"idle":"not-available")}catch{ae.aborted||(r("error"),u(s("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[Ee,s]);l.useEffect(()=>{const ae=new AbortController;return _e(ae.signal),()=>ae.abort()},[_e]),l.useEffect(()=>{if(!i?.connectUrl){m(null);return}let ae=!1;return pl.toDataURL(i.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(Ue=>{ae||m(Ue)}).catch(()=>{ae||m(null)}),()=>{ae=!0}},[i?.connectUrl]),l.useEffect(()=>{if(!i?.bootstrapExpiresAt){ie(s("settings.openchamber.tunnel.state.noExpiry"));return}let ae=null,Ue=Date.now();const tt=()=>{const $e=i.bootstrapExpiresAt?i.bootstrapExpiresAt-Date.now():0;$e<=0?ie(s("settings.openchamber.tunnel.state.expired")):ie(qo($e))},Ye=()=>{const $e=Date.now();$e-Ue>=1e3&&(tt(),Ue=$e),ae=requestAnimationFrame(Ye)};tt(),(typeof document>"u"||document.visibilityState==="visible")&&(ae=requestAnimationFrame(Ye));const ft=()=>{document.visibilityState==="visible"&&ae===null?ae=requestAnimationFrame(Ye):document.visibilityState!=="visible"&&ae!==null&&(cancelAnimationFrame(ae),ae=null)};return document.addEventListener("visibilitychange",ft),()=>{document.removeEventListener("visibilitychange",ft),ae!==null&&cancelAnimationFrame(ae)}},[s,i?.bootstrapExpiresAt]),l.useEffect(()=>{let ae=null,Ue=Date.now();const tt=()=>{const ft=Date.now();ft-Ue>=1e3&&(ne(ft),Ue=ft),ae=requestAnimationFrame(tt)};(typeof document>"u"||document.visibilityState==="visible")&&(ae=requestAnimationFrame(tt));const Ye=()=>{document.visibilityState==="visible"&&ae===null?ae=requestAnimationFrame(tt):document.visibilityState!=="visible"&&ae!==null&&(cancelAnimationFrame(ae),ae=null)};return document.addEventListener("visibilitychange",Ye),()=>{document.removeEventListener("visibilitychange",Ye),ae!==null&&cancelAnimationFrame(ae)}},[]),l.useEffect(()=>{if(a==="starting"||a==="stopping"||a==="checking")return;let ae=!1;const Ue=async()=>{try{const Ye=await yt("/api/openchamber/tunnel/status");if(!Ye.ok||ae)return;const ft=await Ye.json();if(ae)return;V(Array.isArray(ft.activeSessions)?ft.activeSessions:[]),X(new Set(Array.isArray(ft.managedRemoteTunnelTokenPresetIds)?ft.managedRemoteTunnelTokenPresetIds:[])),Me(typeof ft.localPort=="number"?ft.localPort:null)}catch{}},tt=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Ue()},5e3);return()=>{ae=!0,window.clearInterval(tt)}},[a]);const G=l.useCallback(async ae=>{E(!0);try{await Ct(ae),Object.prototype.hasOwnProperty.call(ae,"tunnelMode")&&ae.tunnelMode&&v(ae.tunnelMode),Object.prototype.hasOwnProperty.call(ae,"tunnelProvider")&&typeof ae.tunnelProvider=="string"&&y(ae.tunnelProvider),Object.prototype.hasOwnProperty.call(ae,"managedLocalTunnelConfigPath")&&O(ae.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(ae,"managedRemoteTunnelPresets")&&ae.managedRemoteTunnelPresets&&B(ae.managedRemoteTunnelPresets)}catch{_.error(s("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{E(!1)}},[s]),$=l.useCallback(async(ae,Ue)=>{k(!0);try{await Ct({tunnelBootstrapTtlMs:ae,tunnelSessionTtlMs:Ue})}catch{_.error(s("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{k(!1)}},[s]),fe=l.useCallback(async ae=>{const Ue=ae.token.trim();if(Ue)try{const tt={...Y,[ae.presetId]:Ue};await Ct({managedRemoteTunnelPresetTokens:tt}),X(Ye=>{const ft=new Set(Ye);return ft.add(ae.presetId),ft})}catch{_.error(s("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[Y,s]),L=l.useCallback(async ae=>{f(null),u(null);const Ue=z.find(Ye=>Ye.provider===ae),tt=Ue?.modes?.some(Ye=>Ye.key===I)?I:Zs(Ue?.modes?.[0]?.key);await G({tunnelProvider:ae,tunnelMode:tt}),Ce(ae)},[z,Ce,G,I]),Le=l.useCallback(async()=>{const ae=await Cl({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(ae.success&&typeof ae.path=="string"&&ae.path.trim().length>0){const Ue=ae.path.trim();if(!Wn(Ue)){_.error(ke);return}O(Ue),await G({managedLocalTunnelConfigPath:Ue});return}Re.current?.click()},[ke,G]),Je=l.useCallback(ae=>{const Ue=ae.trim();O(Ue.length>0?Ue:null)},[]),Xe=l.useCallback(async()=>{if(j&&!Wn(j)){_.error(ke);return}await G({managedLocalTunnelConfigPath:j})},[ke,j,G]),et=l.useCallback(async()=>{O(null),await G({managedLocalTunnelConfigPath:null})},[G]),at=l.useCallback(async ae=>{const Ue=ae.target.files?.[0];if(!Ue)return;const tt=Ue.name.trim();if(tt.length!==0){if(!Wn(tt)){_.error(ke);return}O(tt),await G({managedLocalTunnelConfigPath:tt}),ae.target.value=""}},[ke,G]),ct=l.useCallback(async()=>{if(u(null),f(null),I==="managed-local"&&j&&!Wn(j)){u(ke),_.error(ke);return}r("starting");try{let ae="",Ue="";if(I==="managed-remote"){if(!Pe){r("idle"),f(s("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),_.error(s("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}ae=Pe.hostname,Ue=(Y[Pe.id]||"").trim(),await G({tunnelMode:"managed-remote",managedRemoteTunnelPresets:T})}const tt=await yt("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:N,mode:I,...I==="managed-remote"&&Pe?{managedRemoteTunnelPresetId:Pe.id,managedRemoteTunnelPresetName:Pe.name}:{},...I==="managed-remote"&&ae?{managedRemoteTunnelHostname:ae}:{},...I==="managed-remote"&&Ue?{managedRemoteTunnelToken:Ue}:{},...I==="managed-local"&&j?{configPath:j}:{}})}),Ye=await tt.json();if(!tt.ok||!Ye.ok){if(I==="managed-remote"&&typeof Ye.error=="string"&&Ye.error.includes("Managed remote tunnel token is required")){r("idle"),f(s("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),_.error(s("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}r("error"),u(Ye.error||s("settings.openchamber.tunnel.toast.startFailed")),_.error(Ye.error||s("settings.openchamber.tunnel.toast.startFailed"));return}const ft=typeof Ye.url=="string"?Ye.url:"";if(!ft){r("error"),u(s("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),_.error(s("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(o({url:ft,connectUrl:typeof Ye.connectUrl=="string"?Ye.connectUrl:null,bootstrapExpiresAt:typeof Ye.bootstrapExpiresAt=="number"?Ye.bootstrapExpiresAt:null}),c(Ye.activeTunnelMode?Zs(Ye.activeTunnelMode):Ye.mode?Zs(Ye.mode):I),V(Array.isArray(Ye.activeSessions)?Ye.activeSessions:[]),Array.isArray(Ye.managedRemoteTunnelTokenPresetIds)&&X(new Set(Ye.managedRemoteTunnelTokenPresetIds)),typeof Ye.localPort=="number"&&Me(Ye.localPort),typeof Ye.mode=="string"&&v(Zs(Ye.mode)),r("active"),Ye.replacedTunnel){const $e=typeof Ye.revokedBootstrapCount=="number"?Ye.revokedBootstrapCount:0,Ve=typeof Ye.invalidatedSessionCount=="number"?Ye.invalidatedSessionCount:0;$e===1&&Ve===1?_.warning(s("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):$e===1?_.warning(s("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:Ve})):Ve===1?_.warning(s("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:$e})):_.warning(s("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:$e,invalidatedSessionCount:Ve}))}else _.success(s("settings.openchamber.tunnel.toast.linkReady"))}catch{r("error"),u(s("settings.openchamber.tunnel.toast.startFailed")),_.error(s("settings.openchamber.tunnel.toast.startFailed"))}},[ke,T,G,Pe,Y,s,N,I,j]),Ze=l.useCallback(async()=>{r("stopping");try{await yt("/api/openchamber/tunnel/stop",{method:"POST"});const ae=await yt("/api/openchamber/tunnel/status");if(ae.ok){const Ue=await ae.json();V(Array.isArray(Ue.activeSessions)?Ue.activeSessions:[]),X(new Set(Array.isArray(Ue.managedRemoteTunnelTokenPresetIds)?Ue.managedRemoteTunnelTokenPresetIds:[])),Me(typeof Ue.localPort=="number"?Ue.localPort:null)}o(null),c(null),m(null),r("idle"),_.success(s("settings.openchamber.tunnel.toast.stopped"))}catch{r("error"),u(s("settings.openchamber.tunnel.toast.stopFailed")),_.error(s("settings.openchamber.tunnel.toast.stopFailed"))}},[s]),He=l.useCallback(async()=>{if(i?.connectUrl)try{await navigator.clipboard.writeText(i.connectUrl),h(!0),_.success(s("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>h(!1),2e3)}catch{_.error(s("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[s,i?.connectUrl]),mt=l.useCallback(async ae=>{const Ue=xa.find(tt=>tt.value===ae);Ue&&(be(Ue.ms),await $(Ue.ms,je))},[$,je]),pe=l.useCallback(async ae=>{const Ue=ba.find(tt=>tt.value===ae);!Ue||Ue.ms===null||(ye(Ue.ms),await $(Ie,Ue.ms))},[Ie,$]),nt=l.useCallback(async ae=>{f(null),u(null),a!=="active"&&a!=="stopping"&&a!=="starting"&&r("idle"),await G({tunnelMode:ae,managedRemoteTunnelPresets:T})},[T,G,a]),st=l.useCallback(async(ae,Ue)=>{try{await Ct({managedRemoteTunnelPresets:Ue})}catch{_.error(s("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[s]),Ge=l.useCallback(ae=>{const Ue=T.find(tt=>tt.id===ae);Ue&&(R(Ue.id),f(null),st(Ue,T))},[T,st]),ht=l.useCallback(async()=>{const ae=de.trim(),Ue=Ea(ee),tt=we.trim();if(!ae){_.error(s("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!Ue){_.error(s("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!tt){_.error(s("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(T.some($e=>$e.hostname===Ue)){_.error(s("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Ye={id:tb(),name:ae,hostname:Ue},ft=[...T,Ye];B(ft),R(Ye.id),Q($e=>({...$e,[Ye.id]:!0})),F($e=>({...$e,[Ye.id]:tt})),f(null),Z(!1),le(""),xe(""),he(""),await G({tunnelMode:"managed-remote",managedRemoteTunnelPresets:ft,managedRemoteTunnelPresetTokens:{...Y,[Ye.id]:tt}}),await fe({presetId:Ye.id,presetName:Ye.name,hostname:Ye.hostname,token:tt}),_.success(s("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[T,ee,de,we,fe,G,Y,s]),wt=l.useCallback(async ae=>{const Ue=T.find(Ve=>Ve.id===ae);if(!Ue)return;const tt=T.filter(Ve=>Ve.id!==Ue.id),Ye=tt[0]?.id||"",ft=q===Ue.id?Ye:q,$e=Object.fromEntries(Object.entries(Y).filter(([Ve,it])=>Ve!==Ue.id&&it.trim().length>0));B(tt),R(ft),Q(Ve=>{const it={...Ve};return delete it[Ue.id],it}),F(Ve=>{const it={...Ve};return delete it[Ue.id],it}),X(Ve=>{const it=new Set(Ve);return it.delete(Ue.id),it}),f(null),await G({managedRemoteTunnelPresets:tt,managedRemoteTunnelPresetTokens:$e}),_.success(s("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[T,G,q,Y,s]),Nt="gap-2 border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:bg-[var(--primary-hover)] hover:text-[var(--primary-foreground)]";return a==="checking"?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":s("settings.openchamber.tunnel.state.loading")})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.openchamber.tunnel.title")}),t.jsx("p",{className:"typography-meta mt-0 text-muted-foreground/70",children:s("settings.openchamber.tunnel.description")}),t.jsx("p",{className:"typography-meta mt-0 text-muted-foreground/60",children:s("settings.openchamber.tunnel.note.serverSideEnforced")}),t.jsx("p",{className:"typography-meta mt-0 text-muted-foreground/60",children:s("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),Te.length>0&&t.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:t.jsxs("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)]/30 p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[t.jsx(A,{name:"information",className:"size-4 text-[var(--status-info)]"}),t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.section.redeemedAccessLinks")})]}),t.jsx("div",{className:"space-y-1",children:Te.map(ae=>{const Ue=ae.mode==="quick",tt=ae.mode==="managed-remote",Ye=Ue?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":tt?"border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)]":"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",ft=ae.isActive?Ue?"text-[var(--status-warning)]":tt?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",$e=s(Ue?"settings.openchamber.tunnel.badge.quick":tt?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded border border-[var(--surface-subtle)] bg-[var(--surface-elevated)] px-2 py-1.5",children:[t.jsx(A,{name:"checkbox-blank-circle-fill",className:ce("size-2.5 shrink-0",ft)}),t.jsx("span",{className:ce("typography-micro rounded border px-1.5 py-0.5 uppercase",Ye),children:$e}),t.jsx("span",{className:"typography-meta text-muted-foreground/80",children:s("settings.openchamber.tunnel.session.redeemedAt",{time:Zx(ae.createdAt,e)})}),t.jsx("span",{className:"typography-meta text-foreground",children:ae.isActive?s("settings.openchamber.tunnel.session.expiresIn",{remaining:ae.remainingTextForSession}):ae.inactiveLabel===s("settings.openchamber.tunnel.state.inactive")?s("settings.openchamber.tunnel.state.inactive"):s("settings.openchamber.tunnel.session.inactiveWithReason",{reason:ae.inactiveLabel})})]},ae.sessionId)})})]})}),a==="not-available"&&t.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5 p-3",children:[t.jsx(A,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"typography-meta font-medium text-foreground",children:s("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:me.dependency})}),t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.openchamber.tunnel.notAvailable.installHint")}),t.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:me.installCommand})]})]})}),t.jsxs("section",{className:"space-y-4 px-2 pb-2 pt-0",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{"data-settings-item":"tunnel.provider",className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.provider")}),t.jsxs(Mt,{value:N,onValueChange:ae=>{L(ae)},disabled:w||a==="starting"||a==="stopping",children:[t.jsx(Rt,{className:"max-w-[16rem]",children:t.jsx(Kt,{placeholder:s("settings.openchamber.tunnel.field.providerPlaceholder"),children:Zl(N)})}),t.jsxs(Tt,{children:[z.length>0?z.map(ae=>t.jsx(gt,{value:ae.provider,children:t.jsx(Ho,{provider:ae.provider})},ae.provider)):t.jsx(gt,{value:"cloudflare",children:t.jsx(Ho,{provider:"cloudflare"})}),t.jsx(gt,{value:"__more-soon",disabled:!0,children:s("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})]}),t.jsxs("div",{"data-settings-item":"tunnel.type",className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.tunnelType")}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:oe.map(ae=>t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(J,{variant:"chip",size:"xs","aria-pressed":I===ae.value,className:"!font-normal",onClick:()=>{nt(ae.value)},disabled:w||a==="starting"||a==="stopping",children:n(ae.labelKey)})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:n(ae.tooltipKey)})]},ae.value))})]})]}),t.jsxs("div",{"data-settings-item":"tunnel.ttl",className:"mt-2 grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label shrink-0 text-foreground",children:s("settings.openchamber.tunnel.field.connectLinkTtl")}),t.jsxs(Mt,{value:Lr(xa,Ie,"1800000"),onValueChange:ae=>{mt(ae)},disabled:D||w||a==="starting"||a==="stopping",children:[t.jsx(Rt,{className:"max-w-[11rem] min-w-0",children:t.jsx(Kt,{className:"truncate",children:Wo(xa,Ie,"1800000")})}),t.jsx(Tt,{children:xa.map(ae=>t.jsx(gt,{value:ae.value,children:ae.label},ae.value))})]})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label shrink-0 text-foreground",children:s("settings.openchamber.tunnel.field.tunnelSessionTtl")}),t.jsxs(Mt,{value:Lr(ba,je,"28800000"),onValueChange:ae=>{pe(ae)},disabled:D||w||a==="starting"||a==="stopping",children:[t.jsx(Rt,{className:"max-w-[11rem] min-w-0",children:t.jsx(Kt,{className:"truncate",children:Wo(ba,je,"28800000")})}),t.jsx(Tt,{children:ba.map(ae=>t.jsx(gt,{value:ae.value,children:ae.label},ae.value))})]})]})]}),I==="quick"&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning)]/35 bg-[var(--status-warning)]/10 p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(A,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:s("settings.openchamber.tunnel.option.mode.quick.tooltip")}),H&&t.jsx("p",{className:"typography-meta mt-1 text-[var(--status-warning)]",children:s("settings.openchamber.tunnel.warning.quickModeReliability")})]})]})}),I==="managed-remote"&&t.jsxs("div",{"data-settings-item":"tunnel.managed-remote",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[typeof ze=="number"&&t.jsx("div",{className:"rounded-md border border-[var(--status-info-border)] bg-[var(--status-info-background)]/35 px-2 py-1.5",children:t.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[s("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",t.jsxs("code",{children:["http://localhost:",ze]})]})}),t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),t.jsxs(J,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Z(ae=>!ae),disabled:a==="starting"||a==="stopping"||w,children:[t.jsx(A,{name:"add",className:"h-3.5 w-3.5"}),s("settings.common.actions.create")]})]}),T.length>0?t.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:T.map((ae,Ue)=>{const tt=Y[ae.id]||"",Ye=W.has(ae.id),ft=U[ae.id]??!1;return t.jsx("div",{className:ce(Ue<T.length-1&&"border-b border-[var(--surface-subtle)]"),children:t.jsxs(pn,{open:ft,onOpenChange:$e=>{Q(Ve=>({...Ve,[ae.id]:$e})),$e&&Ge(ae.id)},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2 px-3",children:[t.jsxs(gn,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pr-1 text-left hover:bg-[var(--interactive-hover)]",disabled:a==="starting"||a==="stopping"||w,children:[ft?t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(A,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:ae.name})]}),t.jsx(J,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":s("settings.openchamber.tunnel.actions.removePresetAria",{name:ae.name}),onClick:()=>{wt(ae.id)},disabled:a==="starting"||a==="stopping"||w,children:t.jsx(A,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(hn,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[t.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[s("settings.openchamber.tunnel.field.hostnameLabel")," ",t.jsx("code",{children:ae.hostname})]}),t.jsx(ot,{type:"password",value:tt,onChange:$e=>{const Ve=$e.target.value;f(null),F(it=>({...it,[ae.id]:Ve}))},onBlur:$e=>{const Ve=$e.currentTarget.value.trim();Ve&&fe({presetId:ae.id,presetName:ae.name,hostname:ae.hostname,token:Ve})},placeholder:s(Ye?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:a==="starting"||a==="stopping"}),t.jsx("div",{className:"flex items-center justify-end",children:t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal",disabled:a==="starting"||a==="stopping"||tt.trim().length===0,onClick:()=>{fe({presetId:ae.id,presetName:ae.name,hostname:ae.hostname,token:tt})},children:s("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},ae.id)})}):t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),re&&t.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[t.jsx(ot,{value:de,onChange:ae=>le(ae.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:w||a==="starting"||a==="stopping"}),t.jsx(ot,{value:ee,onChange:ae=>xe(ae.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:w||a==="starting"||a==="stopping"}),t.jsx(ot,{type:"password",value:we,onChange:ae=>he(ae.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:w||a==="starting"||a==="stopping"}),typeof ze=="number"&&t.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[s("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",t.jsxs("code",{children:["http://localhost:",ze]}),"."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ht()},disabled:w||a==="starting"||a==="stopping",children:s("settings.common.actions.saveChanges")}),t.jsx(J,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Z(!1),le(""),xe(""),he("")},disabled:w||a==="starting"||a==="stopping",children:s("settings.common.actions.cancel")})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("p",{className:"typography-meta text-muted-foreground/80",children:s("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground/70 hover:text-foreground","aria-label":s("settings.openchamber.tunnel.field.managedRemoteTokenInfoAria"),children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5"})})}),t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:s("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]})]}),!Pe&&C&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:C})]}),I==="managed-local"&&t.jsx("div",{"data-settings-item":"tunnel.managed-local-config",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.configurationFile")}),t.jsx("input",{ref:Re,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:ae=>{at(ae)}}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ot,{value:j||"",onChange:ae=>{Je(ae.target.value)},onBlur:()=>{Xe()},placeholder:s("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:a==="starting"||a==="stopping"||w}),t.jsx(J,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Le()},disabled:a==="starting"||a==="stopping"||w,children:t.jsx(A,{name:"folder",className:"size-3.5"})}),j&&t.jsx(J,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{et()},disabled:a==="starting"||a==="stopping"||w,children:t.jsx(A,{name:"close",className:"size-3.5"})})]}),t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s(j?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),Ae&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:ke})]})}),!Be&&t.jsxs("div",{"data-settings-item":"tunnel.start",className:"space-y-6",children:[t.jsx("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)] p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(A,{name:"information",className:"mt-0.5 size-4 shrink-0 text-[var(--status-info)]"}),t.jsxs("div",{className:"space-y-1",children:[I==="managed-remote"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:s("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")}),t.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{Ne(qx)},children:[s("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),t.jsx(A,{name:"external-link",className:"size-3.5"})]})]}),I==="managed-local"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:s("settings.openchamber.tunnel.note.managedLocalUsesConfig")}),t.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{Ne(Gx)},children:[s("settings.openchamber.tunnel.actions.openManagedLocalDocs"),t.jsx(A,{name:"external-link",className:"size-3.5"})]})]}),t.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:s("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:n(pr.find(ae=>ae.value===I)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label")})})]})]})}),I==="managed-remote"&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect")}),t.jsxs(Mt,{value:q||(T[0]?.id??""),onValueChange:ae=>{Ge(ae)},disabled:w||a==="starting"||a==="stopping"||T.length<=1,children:[t.jsx(Rt,{children:t.jsx(Kt,{placeholder:s("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:Pe?.name})}),t.jsx(Tt,{fitContent:!0,children:T.map(ae=>t.jsx(gt,{value:ae.id,children:ae.name},ae.id))})]})]}),We&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(A,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:s("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]})}),t.jsx(J,{size:"sm",variant:"outline",onClick:ct,disabled:a==="starting"||w||I==="managed-remote"&&!Pe||I==="managed-local"&&Ae,className:ce(Nt,a==="starting"&&"opacity-70"),children:a==="starting"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"})," ",s("settings.openchamber.tunnel.actions.startingTunnel")]}):s("settings.openchamber.tunnel.actions.startTunnel")})]})]}),Be&&i&&t.jsxs("section",{"data-settings-item":"tunnel.start",className:"space-y-4 px-2 pb-2 pt-0",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),t.jsx("p",{className:"typography-meta font-medium text-foreground",children:s("settings.openchamber.tunnel.state.tunnelReady")})]}),t.jsxs("div",{children:[t.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:s("settings.openchamber.tunnel.field.publicUrlHint")}),t.jsx("code",{className:"typography-code block truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:i.url})]}),Fe&&i.connectUrl&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:s("settings.openchamber.tunnel.field.connectLink")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"typography-code flex-1 truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:i.connectUrl}),t.jsxs(J,{size:"sm",variant:"ghost",onClick:He,className:"shrink-0 gap-1.5",children:[g?t.jsx(A,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):t.jsx(A,{name:"file-copy",className:"size-3.5"}),s(g?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),t.jsxs("p",{className:"typography-meta mt-1 text-muted-foreground/70",children:[s("settings.openchamber.tunnel.field.expires"),": ",i.bootstrapExpiresAt?se:s("settings.openchamber.tunnel.state.never")]})]}),t.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border/50 bg-[var(--surface-elevated)] p-4",children:[x?t.jsx("img",{src:x,alt:s("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-48"}):t.jsx("div",{className:"size-48 rounded bg-muted/30"}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.tunnel.note.scanQrToConnect")})]})]})]}),t.jsx("div",{className:"pt-1",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(J,{size:"sm",variant:"outline",onClick:ct,disabled:a==="stopping"||w||I==="managed-local"&&Ae,className:Nt,children:[t.jsx(A,{name:"restart",className:"size-3.5"}),s("settings.openchamber.tunnel.actions.newConnectLink")]}),t.jsx(J,{size:"sm",variant:"ghost",onClick:Ze,disabled:a==="stopping"||w,className:"gap-2 text-[var(--status-error)]",children:a==="stopping"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"})," ",s("settings.openchamber.tunnel.actions.stopping")]}):s("settings.openchamber.tunnel.actions.stopTunnel")})]})})]}),a==="error"&&p&&t.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:p}),t.jsx(J,{size:"sm",variant:"ghost",onClick:ct,children:s("settings.openchamber.tunnel.actions.retry")})]})]})},ec=()=>{const{t:s}=dt(),[e,n]=ve.useState(""),[a,r]=ve.useState(!0),[i,o]=ve.useState(!1),d=Ke(u=>u.showOpenCodeUpdateNotifications),c=Ke(u=>u.setShowOpenCodeUpdateNotifications);ve.useEffect(()=>{let u=!1;return(async()=>{try{const C=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!C.ok)return;const f=await C.json().catch(()=>null);if(u||!f)return;const g=typeof f.opencodeBinary=="string"?f.opencodeBinary.trim():"";n(g)}catch{}finally{u||r(!1)}})(),()=>{u=!0}},[]);const x=ve.useCallback(async()=>{if(!(typeof window>"u")&&ds())try{const u=await Cl();u.success&&u.path&&u.path.trim().length>0&&n(u.path.trim())}catch{}},[]),m=ve.useCallback(async()=>{o(!0);try{await Ct({opencodeBinary:e.trim()}),await Dn({message:s("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}finally{o(!1)}},[s,e]),p=ve.useCallback(u=>{c(u),Ct({showOpenCodeUpdateNotifications:u})},[c]);return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.opencodeCli.title")}),t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsxs(Dt,{sideOffset:8,className:"max-w-xs",children:[s("settings.openchamber.opencodeCli.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs",children:"opencode"}),s("settings.openchamber.opencodeCli.tooltipSuffix")]})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{"data-settings-item":"sessions.opencode-binary",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-3",children:[t.jsx("div",{className:"flex min-w-0 flex-col shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.opencodeCli.field.binaryPath")})}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:w-[20rem]",children:[t.jsx(ot,{value:e,onChange:u=>n(u.target.value),placeholder:s("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:a||i,className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(J,{type:"button",variant:"outline",size:"xs",onClick:x,disabled:a||i||!ds(),className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.opencodeCli.actions.browseAria"),title:s("settings.openchamber.opencodeCli.actions.browse"),children:t.jsx(A,{name:"folder",className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"py-1.5",children:t.jsxs("div",{className:"typography-micro text-muted-foreground/70",children:[s("settings.openchamber.opencodeCli.tipPrefix")," ",t.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",s("settings.openchamber.opencodeCli.tipMiddle")," ",t.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]})}),t.jsxs("label",{"data-settings-item":"sessions.opencode-update-notifications",className:"flex cursor-pointer items-center gap-2 py-1.5",children:[t.jsx(St,{checked:d,onChange:p,ariaLabel:s("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.opencodeCli.field.showUpdateNotifications")})]}),t.jsx("div",{className:"flex justify-start py-1.5",children:t.jsx(J,{type:"button",size:"xs",onClick:m,disabled:a||i,className:"shrink-0 !font-normal",children:s(i?"settings.common.actions.saving":"settings.openchamber.opencodeCli.actions.saveAndReload")})})]})]})},tc=()=>{const{t:s}=dt(),e=ds()&&sa(),[n,a]=ve.useState(!1),[r,i]=ve.useState(!1),[o,d]=ve.useState(""),[c,x]=ve.useState(""),[m,p]=ve.useState(!1),[u,C]=ve.useState(null),[f,g]=ve.useState(!0),[h,D]=ve.useState(!1),[k,w]=ve.useState(!1),[E,N]=ve.useState(!1),[y,b]=ve.useState(!1),[P,z]=ve.useState(null),[M,I]=ve.useState(null);ve.useEffect(()=>{if(!e){g(!1);return}let F=!1;return(async()=>{try{const W=await yt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!W.ok)throw new Error(s("settings.openchamber.desktopNetwork.error.loadFailed"));const X=await W.json().catch(()=>null);if(F)return;const re=X?.desktopLanAccessEnabled===!0,Z=typeof X?.desktopUiPassword=="string"?X.desktopUiPassword:"";a(re),i(re),d(Z),x(Z),p(X?.desktopLanAccessActive===!0),C(typeof X?.desktopLanAccessBlockedReason=="string"?X.desktopLanAccessBlockedReason:null),z(null)}catch(W){F||z(W instanceof Error?W.message:s("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{F||g(!1)}})(),()=>{F=!0}},[e,s]),ve.useEffect(()=>{if(!e){w(!1);return}let F=!1;return(async()=>{const W=await Hm();F||(w(W?.supported===!0),N(W?.enabled===!0))})(),()=>{F=!0}},[e]),ve.useEffect(()=>{if(!e||!r){I(null);return}let F=!1;return(async()=>{const W=await Wm();F||I(W)})(),()=>{F=!0}},[r,e]);const v=r!==n||c!==o,j=ve.useMemo(()=>{if(typeof window>"u")return null;const W=ea()||window.location.href;let X=0;try{X=Number(new URL(W).port)}catch{X=Number(window.location.port)}return Number.isFinite(X)&&X>0?X:null},[]),O=r&&m&&M&&j?`http://${M}:${j}`:null,T=r&&!c.trim(),B=n&&!m&&u==="missing-password",U=f||h||!v||T,Q=ve.useCallback(()=>{i(F=>!F)},[]),q=ve.useCallback(F=>{x(F),F.trim()||i(!1)},[]),R=ve.useCallback(async()=>{if(!k||y)return;const F=!E;N(F),b(!0),z(null);try{const W=await qm(F);if(!W?.supported)throw new Error(s("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));N(W.enabled)}catch(W){N(!F),z(W instanceof Error?W.message:s("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{b(!1)}},[y,E,k,s]),Y=ve.useCallback(async()=>{if(v){D(!0),z(null);try{if(!(await yt("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({desktopLanAccessEnabled:r,desktopUiPassword:c})})).ok)throw new Error(s("settings.openchamber.desktopNetwork.error.saveFailed"));if(a(r),d(c),!await Gm())throw new Error(s("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(F){z(F instanceof Error?F.message:s("settings.openchamber.desktopNetwork.error.saveFailed")),D(!1)}}},[c,r,v,s]);return e?t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.desktopNetwork.title")})}),t.jsxs("section",{className:"space-y-2 px-2 pb-2 pt-0",children:[k?t.jsxs("div",{"data-settings-item":"sessions.desktop-launch-at-login",className:"group flex cursor-pointer items-start gap-2 py-1.5",role:"button",tabIndex:0,onClick:R,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),R())},children:[t.jsx(St,{checked:E,onChange:R,ariaLabel:s("settings.openchamber.desktopNetwork.field.launchAtLoginAria"),disabled:y}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.desktopNetwork.field.launchAtLogin")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopNetwork.field.launchAtLoginDescription")})]})]}):null,t.jsxs("div",{"data-settings-item":"sessions.desktop-ui-password",className:"space-y-1 py-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",htmlFor:"desktop-ui-password",children:s("settings.openchamber.desktopPassword.field.password")}),t.jsx(ot,{id:"desktop-ui-password",type:"password",className:"h-7 max-w-sm",value:c,onChange:F=>q(F.target.value),placeholder:s("settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:f||h,required:r,"aria-invalid":T}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopPassword.field.passwordDescription")})]}),t.jsxs("div",{"data-settings-item":"sessions.desktop-lan-access",className:"group flex cursor-pointer items-start gap-2 py-1.5",role:"button",tabIndex:0,onClick:Q,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),Q())},children:[t.jsx(St,{checked:r,onChange:Q,ariaLabel:s("settings.openchamber.desktopNetwork.field.allowLanAccessAria"),disabled:f||h}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.desktopNetwork.field.allowLanAccess")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopNetwork.field.allowLanAccessDescription")}),t.jsx("div",{className:"typography-micro text-[var(--status-warning)]/85",children:s("settings.openchamber.desktopNetwork.field.warning")}),T||B?t.jsx("div",{className:"typography-micro text-[var(--status-warning)]/85",children:s("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]})]}),P?t.jsx("div",{className:"px-2 typography-micro text-[var(--status-error)]",children:P}):null,O?t.jsxs("div",{className:"px-2 typography-micro text-muted-foreground/80",children:[s(v&&!n?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),t.jsx("span",{className:"font-mono text-foreground",children:O})]}):null,t.jsx("div",{className:"flex justify-start py-1.5",children:t.jsx(J,{type:"button",size:"xs",onClick:Y,disabled:U,className:"shrink-0 !font-normal",children:s(h?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})})]})]}):null},nb=new Set(["shift","control","alt","meta"]),ab=s=>{if(nb.has(s.key.toLowerCase()))return null;const e=[];(s.metaKey||s.ctrlKey)&&e.push("mod"),s.shiftKey&&e.push("shift"),s.altKey&&e.push("alt");const n=wm(s.key);return n?(e.push(n),Nn(e.join("+"))):null},rb=()=>{const s=rt.c(61),{t:e}=dt();let n;s[0]!==e?(n=ee=>e(ee),s[0]=e,s[1]=n):n=s[1];const a=n,r=Ke(ib),i=Ke(ob),o=Ke(lb),d=Ke(cb);let c;s[2]===Symbol.for("react.memo_cache_sentinel")?(c=vm(),s[2]=c):c=s[2];const x=c;let m;s[3]!==a?(m=(ee,xe)=>{const we=`settings.openchamber.keyboardShortcuts.action.${ee}.label`,he=a(we);return he===we?xe:he},s[3]=a,s[4]=m):m=s[4];const p=m,[u,C]=l.useState(null);let f;s[5]===Symbol.for("react.memo_cache_sentinel")?(f={},s[5]=f):f=s[5];const[g,h]=l.useState(f),[D,k]=l.useState(""),[w,E]=l.useState(""),[N,y]=l.useState(null),b=db;let P;s[6]!==r?(P=(ee,xe)=>{const we=Nn(xe);for(const he of x){if(he.id===ee)continue;const Ie=fi(he.id,r);if(Nn(Ie)===we)return he.id}return null},s[6]=r,s[7]=P):P=s[7];const z=P;let M;s[8]!==z||s[9]!==i||s[10]!==r||s[11]!==e?(M=(ee,xe)=>{const we=Nn(xe),he=z(ee,we);if(he){y({actionId:ee,combo:we,conflictActionId:he}),k("");return}const Ie={...r,[ee]:we};i(ee,we),b(Ie),y(null),k(""),E(xi(we)?e("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut"):""),h(be=>{const je={...be};return delete je[ee],je})},s[8]=z,s[9]=i,s[10]=r,s[11]=e,s[12]=M):M=s[12];const I=M;let v;s[13]!==N||s[14]!==i||s[15]!==r||s[16]!==e?(v=()=>{if(!N)return;const ee={...r,[N.conflictActionId]:bi,[N.actionId]:N.combo};i(N.conflictActionId,bi),i(N.actionId,N.combo),b(ee),y(null),k(""),E(xi(N.combo)?e("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut"):""),h(xe=>{const we={...xe};return delete we[N.actionId],we})},s[13]=N,s[14]=i,s[15]=r,s[16]=e,s[17]=v):v=s[17];const j=v;let O;s[18]!==o||s[19]!==r?(O=ee=>{const xe={...r};delete xe[ee],o(ee),b(xe),h(we=>{const he={...we};return delete he[ee],he}),y(null),k(""),E("")},s[18]=o,s[19]=r,s[20]=O):O=s[20];const T=O;let B;s[21]!==e?(B=e("settings.openchamber.keyboardShortcuts.title"),s[21]=e,s[22]=B):B=s[22];let U;s[23]!==B?(U=t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:B}),s[23]=B,s[24]=U):U=s[24];let Q;s[25]!==d?(Q=()=>{d(),b({}),h({}),y(null),k(""),E("")},s[25]=d,s[26]=Q):Q=s[26];let q;s[27]!==e?(q=e("settings.openchamber.keyboardShortcuts.actions.resetAll"),s[27]=e,s[28]=q):q=s[28];let R;s[29]!==Q||s[30]!==q?(R=t.jsx(J,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Q,children:q}),s[29]=Q,s[30]=q,s[31]=R):R=s[31];let Y;s[32]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx(It,{asChild:!0,children:t.jsx(A,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),s[32]=Y):Y=s[32];let F;s[33]!==e?(F=e("settings.openchamber.keyboardShortcuts.tooltip"),s[33]=e,s[34]=F):F=s[34];let W;s[35]!==F?(W=t.jsxs(Pt,{children:[Y,t.jsx(Dt,{sideOffset:8,className:"max-w-xs",children:F})]}),s[35]=F,s[36]=W):W=s[36];let X;s[37]!==R||s[38]!==W||s[39]!==U?(X=t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[U,R,W]})}),s[37]=R,s[38]=W,s[39]=U,s[40]=X):X=s[40];let re;s[41]!==j||s[42]!==D||s[43]!==N||s[44]!==e||s[45]!==w?(re=(D||w||N)&&t.jsxs("div",{className:"mb-2 space-y-2 px-1",children:[N&&t.jsxs("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[t.jsx("span",{className:"typography-meta text-foreground",children:e("settings.openchamber.keyboardShortcuts.overwritePrompt")}),t.jsxs("div",{className:"flex gap-2 shrink-0",children:[t.jsx(J,{type:"button",size:"xs",className:"!font-normal",onClick:j,children:e("settings.openchamber.keyboardShortcuts.actions.overwrite")}),t.jsx(J,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>y(null),children:e("settings.common.actions.cancel")})]})]}),D&&t.jsx("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground",children:D}),w&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground",children:w})]}),s[41]=j,s[42]=D,s[43]=N,s[44]=e,s[45]=w,s[46]=re):re=s[46];let Z;s[47]!==p||s[48]!==u||s[49]!==g||s[50]!==T||s[51]!==I||s[52]!==r||s[53]!==e?(Z=x.map((ee,xe)=>{const we=fi(ee.id,r),he=g[ee.id],Ie=he??we,be=typeof he=="string"&&Nn(he)!==Nn(we);return t.jsxs("div",{className:ce("flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",xe>0&&"border-t border-[var(--surface-subtle)]"),children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:p(ee.id,ee.label)})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsx(ot,{readOnly:!0,value:u===ee.id?e("settings.openchamber.keyboardShortcuts.field.pressKeys"):jm(Ie),onFocus:()=>{C(ee.id),k("")},onBlur:()=>{u===ee.id&&C(null)},onKeyDown:je=>{if(je.preventDefault(),je.stopPropagation(),je.key==="Escape"){C(null);return}const ye=ab(je);ye&&(h(se=>({...se,[ee.id]:ye})),C(null),y(null),k(""))},className:"h-7 w-40 min-w-0 typography-ui-label text-center"}),t.jsx(J,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{const je=g[ee.id];if(!je){k(e("settings.openchamber.keyboardShortcuts.error.captureFirst"));return}I(ee.id,je)},disabled:!be,children:e("settings.common.actions.saveChanges")}),t.jsx(J,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>T(ee.id),children:e("settings.common.actions.reset")})]})]},ee.id)}),s[47]=p,s[48]=u,s[49]=g,s[50]=T,s[51]=I,s[52]=r,s[53]=e,s[54]=Z):Z=s[54];let de;s[55]!==Z?(de=t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:Z}),s[55]=Z,s[56]=de):de=s[56];let le;return s[57]!==X||s[58]!==re||s[59]!==de?(le=t.jsxs("div",{"data-settings-item":"shortcuts.keyboard-shortcuts",className:"mb-8",children:[X,re,de]}),s[57]=X,s[58]=re,s[59]=de,s[60]=le):le=s[60],le};function ib(s){return s.shortcutOverrides}function ob(s){return s.setShortcutOverride}function lb(s){return s.clearShortcutOverride}function cb(s){return s.resetAllShortcutOverrides}function db(s){Ct({shortcutOverrides:s})}const sc=()=>{const s=rt.c(2),[e,n]=l.useState(0);let a,r;return s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>Jm(()=>n(jb)),r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),l.useEffect(a,r),e},mb=s=>{const e=rt.c(20),{section:n}=s,{isMobile:a}=Cs();sc();let r;e[0]!==a?(r=a&&dn(),e[0]=a,e[1]=r):r=e[1];const i=r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=fs(),e[2]=o):o=e[2];const d=o;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ds()&&sa(),e[3]=c):c=e[3];const x=c;if(!n){let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(Jr,{}),e[4]=f):f=e[4];let g,h,D;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Yl,{})}),h=x&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(tc,{})}),D=!d&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(ec,{})}),e[5]=g,e[6]=h,e[7]=D):(g=e[5],h=e[6],D=e[7]);let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Jl,{})}),e[8]=k):k=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Ql,{})}),e[9]=w):w=e[9];let E;e[10]!==i?(E=i&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Dl,{})}),e[10]=i,e[11]=E):E=e[11];let N;return e[12]!==E?(N=t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"openchamber-page-body mx-auto max-w-3xl space-y-3 p-3 sm:space-y-6 sm:p-6 sm:pt-8",children:[f,g,h,D,k,w,E]})}),e[12]=E,e[13]=N):N=e[13],N}let m;e[14]!==n?(m=()=>{switch(n){case"visual":return t.jsx(pb,{});case"chat":return t.jsx(gb,{});case"sessions":return t.jsx(hb,{});case"shortcuts":return t.jsx(ub,{});case"git":return t.jsx(fb,{});case"github":return t.jsx(xb,{});case"notifications":return t.jsx(bb,{});case"voice":return t.jsx(yb,{});case"tunnel":return t.jsx(vb,{});default:return null}},e[14]=n,e[15]=m):m=e[15];const p=m;let u;e[16]!==p?(u=p(),e[16]=p,e[17]=u):u=e[17];let C;return e[18]!==u?(C=t.jsx(Gt,{outerClassName:"h-full",className:"w-full",children:t.jsx("div",{className:"openchamber-page-body mx-auto max-w-3xl space-y-6 p-3 sm:p-6 sm:pt-8",children:u})}),e[18]=u,e[19]=C):C=e[19],C},ub=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(rb,{}),s[0]=e):e=s[0],e},pb=()=>{const s=rt.c(3);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs(),s[0]=e):e=s[0];const n=e;let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=n?[]:["weekStart"],s[1]=a):a=s[1];let r;return s[2]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Jr,{visibleSettings:["theme","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a,"fontSize","terminalFontSize","fileEditorKeymap","spacing","inputBarOffset","expandedEditorToolbar",...n?[]:["terminalQuickKeys"],"reportUsage"]}),s[2]=r):r=s[2],r},gb=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Jr,{visibleSettings:["chatRenderMode","messageTransport","activityRenderMode","userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","expandedTools","collapsibleUserMessages","stickyUserHeader","wideChatLayout","splitAssistantMessageActions","diffLayout","dotfiles","fileViewerPreview","queueMode","persistDraft","inputSpellcheck"]}),s[0]=e):e=s[0],e},hb=()=>{const s=rt.c(7);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs(),s[0]=e):e=s[0];const n=e;sc();let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=ds()&&sa(),s[1]=a):a=s[1];const r=a;let i,o,d;s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Yl,{}),o=r&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(tc,{})}),d=!n&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(ec,{})}),s[2]=i,s[3]=o,s[4]=d):(i=s[2],o=s[3],d=s[4]);let c;s[5]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Jl,{})}),s[5]=c):c=s[5];let x;return s[6]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsxs("div",{className:"space-y-6",children:[i,o,d,c,t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Ql,{})})]}),s[6]=x):x=s[6],x},fb=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"space-y-6",children:t.jsx(Wl,{})}),s[0]=e):e=s[0],e},xb=()=>{const s=rt.c(1);if(fs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(ql,{}),s[0]=e):e=s[0],e},bb=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Bx,{}),s[0]=e):e=s[0],e},yb=()=>{const s=rt.c(1);if(fs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Hx,{}),s[0]=e):e=s[0],e},vb=()=>{const s=rt.c(1);if(fs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(sb,{}),s[0]=e):e=s[0],e};function jb(s){return s+1}const nc=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"usage",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"skills",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"skills",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"git",kind:"single",keywords:["git","github","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji","oauth","prs","issues"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"appearance",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"general",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"general",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"advanced",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"Remote Tunnel",group:"advanced",kind:"single",keywords:["tunnel","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"advanced",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile}],wb={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function In(s){const e=s.trim().toLowerCase();return nc.find(n=>n.slug===e)??null}function Qr(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=wb[e];if(n)return n;const a=In(e);return a?a.slug:"home"}const Nb=[{id:"appearance.language",page:"appearance",titleKey:"settings.appearance.language.label",descriptionKey:"settings.appearance.language.description",keywords:["locale","translation","ui language"]},{id:"appearance.time-format",page:"appearance",titleKey:"settings.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"],isAvailable:s=>!s.isVSCode},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:s=>!s.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:s=>!s.isVSCode},{id:"appearance.window-transparency",page:"appearance",titleKey:"settings.openchamber.visual.field.macVibrancy",descriptionKey:"settings.openchamber.visual.field.macVibrancyHint",keywords:["transparent","transparency","vibrancy","blur","macos","opaque"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"appearance.dock-badge",page:"appearance",titleKey:"settings.openchamber.visual.field.dockBadge",descriptionKey:"settings.openchamber.visual.field.dockBadgeHint",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:s=>s.isMac},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:s=>s.isWeb&&!s.isDesktop&&!s.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:s=>s.isWeb&&!s.isDesktop&&!s.isVSCode},{id:"appearance.mobile-keyboard-mode",page:"appearance",titleKey:"settings.openchamber.visual.field.mobileKeyboardMode",descriptionKey:"settings.openchamber.visual.field.mobileKeyboardModeHint",keywords:["mobile","keyboard","resize"],isAvailable:s=>s.isMobile&&s.isWeb&&!s.isDesktop&&!s.isVSCode},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:s=>!s.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"]},{id:"appearance.expanded-editor-toolbar",page:"appearance",titleKey:"settings.openchamber.visual.field.expandedEditorToolbar",keywords:["editor","toolbar","tabs","docked","files"]},{id:"appearance.file-editor-keymap",page:"appearance",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.terminal-quick-keys",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:s=>!s.isMobile&&!s.isVSCode},{id:"appearance.usage-reports",page:"appearance",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"chat.render-mode",page:"chat",titleKey:"settings.openchamber.visual.section.chatRenderMode",keywords:["messages","conversation","rendering"]},{id:"chat.message-transport",page:"chat",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.sticky-user-header",page:"chat",titleKey:"settings.openchamber.visual.field.stickyUserHeader",keywords:["messages","header"]},{id:"chat.collapsible-user-messages",page:"chat",titleKey:"settings.openchamber.visual.field.collapsibleUserMessages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",titleKey:"settings.openchamber.visual.field.wideChatLayout",keywords:["layout","wide","messages"]},{id:"chat.inline-assistant-actions",page:"chat",titleKey:"settings.openchamber.visual.field.showSplitAssistantMessageActions",descriptionKey:"settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip",keywords:["copy","save image","read aloud"]},{id:"chat.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{id:"chat.changed-files",page:"chat",titleKey:"settings.openchamber.visual.field.showTurnChangedFiles",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"chat",titleKey:"settings.openchamber.visual.field.showDotfiles",keywords:["hidden files"],isAvailable:s=>!s.isVSCode},{id:"chat.queue-mode",page:"chat",titleKey:"settings.openchamber.visual.field.queueMessagesByDefault",descriptionKey:"settings.openchamber.visual.field.queueMessagesByDefaultTooltip",keywords:["queue","enter","send"]},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:s=>!s.isMobile},{id:"sessions.default-model",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultModel",keywords:["model","provider","new sessions"]},{id:"sessions.default-thinking",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultThinking",keywords:["thinking","reasoning","variant"]},{id:"sessions.default-agent",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultAgent",keywords:["agent","new sessions"]},{id:"sessions.deletion-dialog",page:"sessions",titleKey:"settings.openchamber.defaults.field.showDeletionDialog",keywords:["delete","confirmation"]},{id:"sessions.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"sessions",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"sessions",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"sessions",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"sessions",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:s=>!s.isVSCode},{id:"sessions.opencode-update-notifications",page:"sessions",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:s=>!s.isVSCode},{id:"git.github-account",page:"git",titleKey:"settings.github.page.actions.connect",keywords:["github","account","oauth","prs","issues"]},{id:"git.identities",page:"git",titleKey:"settings.gitIdentities.page.section.title",descriptionKey:"settings.gitIdentities.page.empty.description",keywords:["identity","profile","author","email","credentials","signing","commit signing","ssh signing","gpg"]},{id:"git.changes-view",page:"git",titleKey:"settings.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.header-menu",page:"usage",titleKey:"settings.usage.page.options.showInHeader",descriptionKey:"settings.usage.page.options.showInHeaderTooltip",keywords:["quota","header","dropdown"]},{id:"usage.model-quotas",page:"usage",titleKey:"settings.usage.page.section.modelQuotas",keywords:["models","quota","limits","tokens"]},{id:"projects.name",page:"projects",titleKey:"settings.projects.page.field.projectName",keywords:["label","display name","project metadata"]},{id:"projects.accent-color",page:"projects",titleKey:"settings.projects.page.field.accentColor",keywords:["color","appearance","project metadata"]},{id:"projects.icon",page:"projects",titleKey:"settings.projects.page.field.projectIcon",keywords:["icon","favicon","upload","project metadata"]},{id:"projects.worktree",page:"projects",titleKey:"settings.projects.page.section.worktree",keywords:["worktree","branch","repository"]},{id:"projects.worktree.setup.wait",page:"projects",titleKey:"settings.openchamber.worktrees.setup.waitForCommands",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"remote-instances.client-auth",page:"remote-instances",titleKey:"settings.remoteInstances.clientAuth.title",descriptionKey:"settings.remoteInstances.clientAuth.description",keywords:["pairing link","client token","connect desktop","remote access"],isAvailable:s=>!s.isVSCode},{id:"remote-instances.direct-hosts",page:"remote-instances",titleKey:"settings.remoteInstances.direct.title",descriptionKey:"settings.remoteInstances.direct.description",keywords:["server url","connection token","import link","host switcher"],isAvailable:s=>s.isDesktop},{id:"behavior.system-prompt",page:"behavior",titleKey:"settings.behavior.page.section.systemPrompt",descriptionKey:"settings.behavior.page.warning.title",keywords:["agents.md","global instructions","system prompt"]},{id:"behavior.response-style",page:"behavior",titleKey:"settings.behavior.page.section.responseStyle",descriptionKey:"settings.behavior.page.responseStyle.tooltip",keywords:["tone","concise","detailed","custom instructions"]},{id:"agents.create",page:"agents",titleKey:"settings.agents.page.title.new",keywords:["create","add","new agent"]},{id:"agents.name",page:"agents",titleKey:"settings.agents.page.field.agentName",keywords:["agent","name"]},{id:"agents.mode",page:"agents",titleKey:"settings.agents.page.field.mode",descriptionKey:"settings.agents.page.field.modeTooltip",keywords:["primary","subagent","visibility"]},{id:"agents.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","allow","ask","deny"]},{id:"commands.create",page:"commands",titleKey:"settings.commands.page.title.new",keywords:["create","add","new command"]},{id:"commands.name",page:"commands",titleKey:"settings.commands.page.field.commandName",keywords:["slash command","name"]},{id:"commands.agent",page:"commands",titleKey:"settings.commands.page.field.overrideAgent",keywords:["agent","execution"]},{id:"commands.model",page:"commands",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"commands.template",page:"commands",titleKey:"settings.commands.page.section.template",keywords:["prompt","template","arguments","shell","file"]},{id:"mcp.create",page:"mcp",titleKey:"settings.mcp.sidebar.actions.addServerTitle",keywords:["create","add","server"]},{id:"mcp.server",page:"mcp",titleKey:"settings.mcp.page.server.title",keywords:["server","name","transport"]},{id:"mcp.command",page:"mcp",titleKey:"settings.mcp.page.connection.command",keywords:["stdio","local","command"]},{id:"mcp.environment",page:"mcp",titleKey:"settings.mcp.page.env.title",keywords:["env","variables","api key"]},{id:"mcp.advanced",page:"mcp",titleKey:"settings.mcp.page.advanced.title",keywords:["oauth","headers","timeout"]},{id:"plugins.create",page:"plugins",titleKey:"settings.plugins.sidebar.actions.addTitle",keywords:["add","plugin","npm","path","file"]},{id:"plugins.spec",page:"plugins",titleKey:"settings.plugins.page.field.spec",keywords:["npm","package","path"]},{id:"plugins.options",page:"plugins",titleKey:"settings.plugins.page.field.options",keywords:["json","configuration"]},{id:"plugins.content",page:"plugins",titleKey:"settings.plugins.page.field.content",keywords:["file","code"]},{id:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.page.auth.title",keywords:["api key","oauth","credentials"]},{id:"providers.connection-details",page:"providers",titleKey:"settings.providers.page.connectionDetails.title",keywords:["config","source","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"skills.create",page:"skills.installed",titleKey:"settings.skills.page.title.newSkill",keywords:["create","add","new skill"]},{id:"skills.basic-information",page:"skills.installed",titleKey:"settings.skills.page.section.basicInformation",keywords:["name","location","description"]},{id:"skills.instructions",page:"skills.installed",titleKey:"settings.skills.page.section.instructions",keywords:["markdown","skill.md","content"]},{id:"skills.supporting-files",page:"skills.installed",titleKey:"settings.skills.page.section.supportingFiles",keywords:["files","resources"]},{id:"skills.catalog.source",page:"skills.catalog",titleKey:"settings.skills.catalog.page.section.sourceRepository",keywords:["catalog","repository","source","refresh"]},{id:"skills.catalog.search",page:"skills.catalog",titleKey:"settings.skills.catalog.shared.field.searchSkillsPlaceholder",keywords:["find skills","install skills","catalog search"]},{id:"skills.catalog.add-catalog",page:"skills.catalog",titleKey:"settings.skills.catalog.page.actions.addCatalog",keywords:["external repository","add source","catalog"]},{id:"magic-prompts.visible-prompt",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.visiblePrompt",keywords:["prompt text","user message","template"],isAvailable:s=>!s.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:s=>!s.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:s=>!s.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.keyboardShortcuts.tooltip",keywords:["keyboard","hotkeys","bindings"]},{id:"voice.voice-setup",page:"voice",titleKey:"settings.voice.page.section.voiceSetup",keywords:["tts","voice mode","provider","speech rate","speech pitch","speech volume","language"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","transcribe","whisper","microphone","silence threshold"]},{id:"voice.playback",page:"voice",titleKey:"settings.voice.page.section.playbackAndSummary",keywords:["read aloud","tts input mode","summary","markdown"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:s=>!s.isVSCode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:s=>!s.isVSCode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:s=>!s.isVSCode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:s=>!s.isVSCode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:s=>!s.isVSCode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:s=>!s.isVSCode},{id:"notifications.delivery",page:"notifications",titleKey:"settings.notifications.page.delivery.title",keywords:["desktop notifications","system notifications"]},{id:"notifications.events",page:"notifications",titleKey:"settings.notifications.page.events.title",keywords:["completion","subtasks","errors","questions"]},{id:"notifications.push",page:"notifications",titleKey:"settings.notifications.page.push.title",keywords:["background","push"],isAvailable:s=>s.isWeb&&!s.isDesktop&&!s.isVSCode}];function Go(s){return s.trim().toLocaleLowerCase()}function kb({query:s,runtimeCtx:e,visiblePageSlugs:n,t:a,getPageTitle:r}){const i=Go(s);if(!i)return[];const o=n?new Set(n):null,d=i.split(/\s+/).filter(Boolean);return Nb.flatMap(c=>{if(o&&!o.has(c.page))return[];const x=In(c.page);if(!x||x.isAvailable&&!x.isAvailable(e)||c.isAvailable&&!c.isAvailable(e))return[];const m=a(c.titleKey),p=c.descriptionKey?a(c.descriptionKey):null,u=Go([m,p,r(c.page),...c.keywords??[]].filter(Boolean).join(" "));return d.every(C=>u.includes(C))?[{...c,title:m,description:p,pageTitle:r(c.page)}]:[]})}const zr=176,Kr=280,Jo=8,ac="__openchamberSettingsDetail";function hr(s){return Math.min(Kr,Math.max(zr,s))}const Sb=["appearance","chat","notifications","sessions","shortcuts","git","magic-prompts","snippets","projects","remote-instances","agents","behavior","commands","mcp","plugins","providers","usage","skills.installed","skills.catalog","voice","tunnel","about"],Cb={icon:"chat-thread"},Pb="__add_provider__";function Ib(s,e){const n=fs(),a=!s&&dn();return{isVSCode:n,isWeb:a,isDesktop:s,isMobile:e}}function Qo(s,e){return s.isAvailable?s.isAvailable(e):!0}function $r(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function qn(s,e){const n=new Set(e);let a=s,r=1;for(;n.has(a);)a=`${s}-${r}`,r+=1;return a}function fr(s){if(!$r(s))return null;const e=s[ac];if(!$r(e))return null;const n=e.page,a=e.stage;return typeof n!="string"||a!=="page-content"?null:{page:Qr(n),stage:a}}function Db(){return typeof window>"u"||!$r(window.history.state)?{}:window.history.state}function rc(s){switch(s){case"projects":return"folders";case"remote-instances":return"server";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return Cb.icon;case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"code-box";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"global";case"about":return"information";case"home":return null;default:return"robot-2"}}const xr=s=>{const e=rt.c(95),{onOpen:n}=s,{t:a}=dt();let r;e[0]!==a?(r=a("settings.view.home.title"),e[0]=a,e[1]=r):r=e[1];let i;e[2]!==r?(i=t.jsx("h1",{className:"typography-ui-header font-semibold text-foreground",children:r}),e[2]=r,e[3]=i):i=e[3];let o;e[4]!==a?(o=a("settings.view.home.description"),e[4]=a,e[5]=o):o=e[5];let d;e[6]!==o?(d=t.jsx("p",{className:"typography-ui text-muted-foreground",children:o}),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==i||e[9]!==d?(c=t.jsxs("div",{className:"space-y-1",children:[i,d]}),e[8]=i,e[9]=d,e[10]=c):c=e[10];let x;e[11]!==n?(x=()=>n("providers"),e[11]=n,e[12]=x):x=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[13]=m):m=e[13];let p;e[14]!==a?(p=a("settings.view.home.cards.providers.title"),e[14]=a,e[15]=p):p=e[15];let u;e[16]!==p?(u=t.jsx("div",{className:"typography-ui-label text-foreground",children:p}),e[16]=p,e[17]=u):u=e[17];let C;e[18]!==a?(C=a("settings.view.home.cards.providers.description"),e[18]=a,e[19]=C):C=e[19];let f;e[20]!==C?(f=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:C}),e[20]=C,e[21]=f):f=e[21];let g;e[22]!==f||e[23]!==x||e[24]!==u?(g=t.jsxs("button",{type:"button",onClick:x,className:m,children:[u,f]}),e[22]=f,e[23]=x,e[24]=u,e[25]=g):g=e[25];let h;e[26]!==n?(h=()=>n("agents"),e[26]=n,e[27]=h):h=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[28]=D):D=e[28];let k;e[29]!==a?(k=a("settings.view.home.cards.agents.title"),e[29]=a,e[30]=k):k=e[30];let w;e[31]!==k?(w=t.jsx("div",{className:"typography-ui-label text-foreground",children:k}),e[31]=k,e[32]=w):w=e[32];let E;e[33]!==a?(E=a("settings.view.home.cards.agents.description"),e[33]=a,e[34]=E):E=e[34];let N;e[35]!==E?(N=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:E}),e[35]=E,e[36]=N):N=e[36];let y;e[37]!==h||e[38]!==w||e[39]!==N?(y=t.jsxs("button",{type:"button",onClick:h,className:D,children:[w,N]}),e[37]=h,e[38]=w,e[39]=N,e[40]=y):y=e[40];let b;e[41]!==n?(b=()=>n("skills.catalog"),e[41]=n,e[42]=b):b=e[42];let P;e[43]===Symbol.for("react.memo_cache_sentinel")?(P=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[43]=P):P=e[43];let z;e[44]!==a?(z=a("settings.view.home.cards.skillsCatalog.title"),e[44]=a,e[45]=z):z=e[45];let M;e[46]!==z?(M=t.jsx("div",{className:"typography-ui-label text-foreground",children:z}),e[46]=z,e[47]=M):M=e[47];let I;e[48]!==a?(I=a("settings.view.home.cards.skillsCatalog.description"),e[48]=a,e[49]=I):I=e[49];let v;e[50]!==I?(v=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:I}),e[50]=I,e[51]=v):v=e[51];let j;e[52]!==b||e[53]!==M||e[54]!==v?(j=t.jsxs("button",{type:"button",onClick:b,className:P,children:[M,v]}),e[52]=b,e[53]=M,e[54]=v,e[55]=j):j=e[55];let O;e[56]!==n?(O=()=>n("mcp"),e[56]=n,e[57]=O):O=e[57];let T;e[58]===Symbol.for("react.memo_cache_sentinel")?(T=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[58]=T):T=e[58];let B;e[59]!==a?(B=a("settings.view.home.cards.mcp.title"),e[59]=a,e[60]=B):B=e[60];let U;e[61]!==B?(U=t.jsx("div",{className:"typography-ui-label text-foreground",children:B}),e[61]=B,e[62]=U):U=e[62];let Q;e[63]!==a?(Q=a("settings.view.home.cards.mcp.description"),e[63]=a,e[64]=Q):Q=e[64];let q;e[65]!==Q?(q=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:Q}),e[65]=Q,e[66]=q):q=e[66];let R;e[67]!==O||e[68]!==U||e[69]!==q?(R=t.jsxs("button",{type:"button",onClick:O,className:T,children:[U,q]}),e[67]=O,e[68]=U,e[69]=q,e[70]=R):R=e[70];let Y;e[71]!==n?(Y=()=>n("usage"),e[71]=n,e[72]=Y):Y=e[72];let F;e[73]===Symbol.for("react.memo_cache_sentinel")?(F=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[73]=F):F=e[73];let W;e[74]!==a?(W=a("settings.view.home.cards.usage.title"),e[74]=a,e[75]=W):W=e[75];let X;e[76]!==W?(X=t.jsx("div",{className:"typography-ui-label text-foreground",children:W}),e[76]=W,e[77]=X):X=e[77];let re;e[78]!==a?(re=a("settings.view.home.cards.usage.description"),e[78]=a,e[79]=re):re=e[79];let Z;e[80]!==re?(Z=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:re}),e[80]=re,e[81]=Z):Z=e[81];let de;e[82]!==Y||e[83]!==X||e[84]!==Z?(de=t.jsxs("button",{type:"button",onClick:Y,className:F,children:[X,Z]}),e[82]=Y,e[83]=X,e[84]=Z,e[85]=de):de=e[85];let le;e[86]!==g||e[87]!==y||e[88]!==j||e[89]!==R||e[90]!==de?(le=t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[g,y,j,R,de]}),e[86]=g,e[87]=y,e[88]=j,e[89]=R,e[90]=de,e[91]=le):le=e[91];let ee;return e[92]!==le||e[93]!==c?(ee=t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl px-6 py-6 space-y-6",children:[c,le]})}),e[92]=le,e[93]=c,e[94]=ee):ee=e[94],ee},Ab=s=>{const e=rt.c(127),{onClose:n,forceMobile:a,isWindowed:r,visiblePageSlugs:i,initialMobileStage:o}=s,d=o===void 0?"nav":o,{t:c}=dt(),x=Cs(),m=a??x.isMobile,p=Ke(Eb),u=Ke(Mb),C=Ke(Rb);let f;e[0]!==p?(f=Qr(p),e[0]=p,e[1]=f):f=e[1];const g=f,[h,D]=l.useState(d),k=l.useRef(null),[w,E]=l.useState(216),[N,y]=l.useState(""),[b,P]=l.useState(null),[z,M]=l.useState(0),[I,v]=l.useState(!1),[j,O]=l.useState(!1),T=l.useRef(0),B=l.useRef(w),U=l.useRef(null);let Q;e[2]===Symbol.for("react.memo_cache_sentinel")?(Q=[],e[2]=Q):Q=e[2];const q=l.useRef(Q),R=l.useRef(0),Y=l.useRef(!1);let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=ds(),e[3]=F):F=e[3];const W=F;let X;e[4]===Symbol.for("react.memo_cache_sentinel")?(X=ds()&&sa(),e[4]=X):X=e[4];const re=X;let Z;e[5]===Symbol.for("react.memo_cache_sentinel")?(Z=ds()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",e[5]=Z):Z=e[5];const de=Z;let le;e[6]!==m?(le=Ib(W,m),e[6]=m,e[7]=le):le=e[7];const ee=le;let xe;if(e[8]!==m||e[9]!==ee||e[10]!==i){const De=i?new Set(i):null;let pt;e[12]!==ee?(pt=Qt=>Qo(Qt,ee),e[12]=ee,e[13]=pt):pt=e[13];let Ft;e[14]!==ee.isVSCode?(Ft=Qt=>!(ee.isVSCode&&Qt.slug==="projects"),e[14]=ee.isVSCode,e[15]=Ft):Ft=e[15];let Xt;e[16]!==m?(Xt=Qt=>!(m&&Qt.slug==="shortcuts"),e[16]=m,e[17]=Xt):Xt=e[17],xe=nc.filter(Tb).filter(Qt=>!De||De.has(Qt.slug)).filter(pt).filter(Ft).filter(Xt),e[8]=m,e[9]=ee,e[10]=i,e[11]=xe}else xe=e[11];const we=xe;let he;e[18]===Symbol.for("react.memo_cache_sentinel")?(he=new Map(Sb.map(Fb)),e[18]=he):he=e[18];const Ie=he;let be;if(e[19]!==we){let De;e[21]===Symbol.for("react.memo_cache_sentinel")?(De=(pt,Ft)=>(Ie.get(pt.slug)??999)-(Ie.get(Ft.slug)??999),e[21]=De):De=e[21],be=we.slice().sort(De),e[19]=we,e[20]=be}else be=e[20];const je=be,ye=is(Ob);let se,ie;e[22]!==I?(se=()=>{if(typeof window>"u")return;const De=()=>{if(!I){const pt=hr(Math.floor(window.innerWidth*.12));E(pt)}};return window.addEventListener("resize",De),()=>window.removeEventListener("resize",De)},ie=[I],e[22]=I,e[23]=se,e[24]=ie):(se=e[23],ie=e[24]),l.useEffect(se,ie);let ge,V;e[25]!==j?(ge=()=>{if(!j)return;const De=Ft=>{const Xt=Ft.clientX-T.current,Qt=hr(B.current+Xt);E(Qt),v(!0)},pt=()=>O(!1);return window.addEventListener("pointermove",De),window.addEventListener("pointerup",pt,{once:!0}),()=>{window.removeEventListener("pointermove",De),window.removeEventListener("pointerup",pt)}},V=[j],e[25]=j,e[26]=ge,e[27]=V):(ge=e[26],V=e[27]),l.useEffect(ge,V);let te;e[28]!==w?(te=De=>{O(!0),T.current=De.clientX,B.current=w,De.preventDefault()},e[28]=w,e[29]=te):te=e[29];const ne=te;let ue;e[30]!==w?(ue=De=>{const pt=De.shiftKey?Jo*4:Jo;let Ft;e:switch(De.key){case"ArrowLeft":{Ft=w-pt;break e}case"ArrowRight":{Ft=w+pt;break e}case"Home":{Ft=zr;break e}case"End":{Ft=Kr;break e}default:return}De.preventDefault(),E(hr(Ft)),v(!0)},e[30]=w,e[31]=ue):ue=e[31];const Me=ue;let ke;e[32]!==u||e[33]!==r||e[34]!==ee.isVSCode||e[35]!==g?(ke=()=>{if(!(!u&&!ee.isVSCode&&!r)){if(g==="agents"){$a.getState().loadAgents();return}if(g==="commands"){Ba.getState().loadCommands();return}if(g==="mcp"){Rn.getState().loadMcpConfigs();return}if(g==="plugins"){cs.getState().loadPlugins();return}(g==="skills.installed"||g==="skills.catalog")&&(Hs.getState().loadSkills(),Vs.getState().loadCatalog()),g==="snippets"&&Va.getState().loadSnippets()}},e[32]=u,e[33]=r,e[34]=ee.isVSCode,e[35]=g,e[36]=ke):ke=e[36];let Re;e[37]!==ye||e[38]!==u||e[39]!==r||e[40]!==ee.isVSCode||e[41]!==g?(Re=[ye,u,r,ee.isVSCode,g],e[37]=ye,e[38]=u,e[39]=r,e[40]=ee.isVSCode,e[41]=g,e[42]=Re):Re=e[42],l.useEffect(ke,Re);let Ae;e[43]!==m||e[44]!==C?(Ae=De=>{if(C(De),k.current=De,!m)return;const pt=In(De);if(!pt||pt.slug==="home"){D("nav");return}D(pt.kind==="split"?"page-sidebar":"page-content")},e[43]=m,e[44]=C,e[45]=Ae):Ae=e[45];const Pe=Ae;let Te;e[46]!==g?(Te=In(g),e[46]=g,e[47]=Te):Te=e[47];const Fe=Te;let Be;e[48]===Symbol.for("react.memo_cache_sentinel")?(Be={appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel"},e[48]=Be):Be=e[48];const We=Be;let ze;e[49]!==c?(ze=De=>{switch(De){case"projects":return c("settings.page.projects.title");case"remote-instances":return c("settings.page.remoteInstances.title");case"providers":return c("settings.page.providers.title");case"usage":return c("settings.page.usage.title");case"agents":return c("settings.page.agents.title");case"behavior":return c("settings.page.behavior.title");case"commands":return c("settings.page.commands.title");case"mcp":return c("settings.page.mcp.title");case"plugins":return c("settings.page.plugins.title");case"skills.installed":return c("settings.page.skills.title");case"skills.catalog":return c("settings.page.skillsCatalog.title");case"git":return c("settings.page.git.title");case"appearance":return c("settings.page.appearance.title");case"chat":return c("settings.page.chat.title");case"shortcuts":return c("settings.page.shortcuts.title");case"sessions":return c("settings.page.sessions.title");case"magic-prompts":return c("settings.page.magicPrompts.title");case"snippets":return c("settings.page.snippets.title");case"notifications":return c("settings.page.notifications.title");case"voice":return c("settings.page.voice.title");case"tunnel":return c("settings.page.tunnel.title");case"about":return c("settings.page.about.title");default:return c("settings.view.home.title")}},e[49]=c,e[50]=ze):ze=e[50];const Qe=ze;let oe;e[51]!==Qe||e[52]!==ee||e[53]!==N||e[54]!==c||e[55]!==i?(oe=kb({query:N,runtimeCtx:{...ee,isDesktopLocalOrigin:re,isMac:de},visiblePageSlugs:i,t:c,getPageTitle:Qe}),e[51]=Qe,e[52]=ee,e[53]=N,e[54]=c,e[55]=i,e[56]=oe):oe=e[56];const H=oe,me=Ub;let Ne;if(e[57]!==H){Ne=[];const De=new Map;for(const pt of H){let Ft=De.get(pt.page);Ft||(Ft={page:pt.page,pageTitle:pt.pageTitle,results:[]},De.set(pt.page,Ft),Ne.push(Ft)),Ft.results.push(pt)}e[57]=H,e[58]=Ne}else Ne=e[58];const Ee=Ne;let Ce;e[59]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>{M(0),R.current=0,Y.current=!1},e[59]=Ce):Ce=e[59];let _e;e[60]!==N?(_e=[N],e[60]=N,e[61]=_e):_e=e[61],l.useEffect(Ce,_e);let G,$;e[62]!==z?(G=()=>{R.current=z},$=[z],e[62]=z,e[63]=G,e[64]=$):(G=e[63],$=e[64]),l.useEffect(G,$);let fe,L;e[65]!==z?(fe=()=>{q.current[z]?.scrollIntoView({block:"nearest"})},L=[z],e[65]=z,e[66]=fe,e[67]=L):(fe=e[66],L=e[67]),l.useEffect(fe,L);let Le,Je;e[68]!==z||e[69]!==H.length?(Le=()=>{z>=H.length&&M(Math.max(0,H.length-1)),q.current.length=H.length},Je=[z,H.length],e[68]=z,e[69]=H.length,e[70]=Le,e[71]=Je):(Le=e[70],Je=e[71]),l.useEffect(Le,Je);let Xe;e[72]!==m||e[73]!==Pe?(Xe=De=>{const pt=me(De);P(pt),Pe(De.page),m&&D("page-content"),De.id==="plugins.create"&&typeof window<"u"&&window.setTimeout(Vb,50)},e[72]=m,e[73]=Pe,e[74]=Xe):Xe=e[74];const et=Xe;let at;e[75]!==et||e[76]!==N||e[77]!==H?(at=De=>{if(N.trim()){if(De.key==="Escape"){De.preventDefault(),y("");return}if(H.length!==0){if(De.key==="ArrowDown"){De.preventDefault(),Y.current=!0,M(pt=>(pt+1)%H.length);return}if(De.key==="ArrowUp"){De.preventDefault(),Y.current=!0,M(pt=>(pt-1+H.length)%H.length);return}if(De.key==="Enter"){De.preventDefault();const pt=(R.current%H.length+H.length)%H.length,Ft=H[pt]??H[0];Ft&&et(Ft)}}}},e[75]=et,e[76]=N,e[77]=H,e[78]=at):at=e[78];const ct=at;let Ze;e[79]!==b?(Ze=()=>{const De=b;if(!De)return;let pt=!1;const Ft=window.requestAnimationFrame(()=>{if(pt)return;const Xt=typeof CSS<"u"&&CSS.escape?CSS.escape(De):De.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Qt=U.current?.querySelector(`[data-settings-item="${Xt}"]`);Qt&&(P(null),Qt.scrollIntoView({block:"center",behavior:"smooth"}),Qt.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Qt.removeAttribute("data-settings-search-highlight")},1600))});return()=>{pt=!0,window.cancelAnimationFrame(Ft)}},e[79]=b,e[80]=Ze):Ze=e[80];let He;e[81]!==b||e[82]!==g?(He=[b,g],e[81]=b,e[82]=g,e[83]=He):He=e[83],l.useEffect(Ze,He);let mt;e[84]!==c?(mt=()=>t.jsx("div",{className:"flex h-full items-center justify-center px-6",children:t.jsxs("div",{className:"max-w-md text-center",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:c("settings.view.unavailable.title")}),t.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:c("settings.view.unavailable.description")})]})}),e[84]=c,e[85]=mt):mt=e[85];const pe=mt,nt=_b;let st;e[86]!==Pe||e[87]!==pe||e[88]!==ee?(st=De=>{const pt=In(De);if(pt&&!Qo(pt,ee))return pe();switch(De){case"home":return t.jsx(xr,{onOpen:Pe});case"projects":return t.jsx(Hh,{});case"remote-instances":return t.jsx(uf,{});case"agents":return t.jsx(Xu,{});case"behavior":return t.jsx(np,{});case"commands":return t.jsx(up,{});case"mcp":return t.jsx(Up,{});case"plugins":return t.jsx(Ig,{});case"skills.installed":return t.jsx(wo,{view:"installed"});case"skills.catalog":return t.jsx(wo,{view:"catalog"});case"providers":return t.jsx(jf,{});case"usage":return t.jsx(tx,{});case"about":return t.jsx("div",{className:"h-full overflow-auto px-5 py-6",children:t.jsx(Dl,{})});case"magic-prompts":return t.jsx(ix,{});case"snippets":return t.jsx(mx,{});case"git":return t.jsx(fx,{});case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":{const Ft=We[De]??"visual";return t.jsx(mb,{section:Ft})}default:return t.jsx(xr,{onOpen:Pe})}},e[86]=Pe,e[87]=pe,e[88]=ee,e[89]=st):st=e[89];const Ge=st;let ht,wt;e[90]!==m||e[91]!==h||e[92]!==g?(ht=()=>{if(!m||h!=="nav"||g==="home"||k.current===g)return;const De=In(g);!De||De.slug==="home"||(k.current=g,D(De.kind==="split"?"page-sidebar":"page-content"))},wt=[m,h,g],e[90]=m,e[91]=h,e[92]=g,e[93]=ht,e[94]=wt):(ht=e[93],wt=e[94]),l.useEffect(ht,wt);const Nt=m&&h!=="nav",ae=m&&h==="page-content"&&g==="skills.installed",Ue=h==="page-content"&&Fe?.kind==="split"&&!ae;let tt;e[95]!==ae||e[96]!==Nt||e[97]!==c?(tt=c(ae?"settings.view.actions.back":Nt?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),e[95]=ae,e[96]=Nt,e[97]=c,e[98]=tt):tt=e[98];const Ye=tt,ft=kl();let $e;e[99]!==ee.isVSCode?($e=De=>{if(typeof window>"u"||ee.isVSCode)return;const pt=fr(window.history.state);pt?.page===De&&pt.stage==="page-content"||window.history.pushState({...Db(),[ac]:{page:De,stage:"page-content"}},"",window.location.href)},e[99]=ee.isVSCode,e[100]=$e):$e=e[100];const Ve=$e;let it;e[101]!==Ve||e[102]!==g?(it=()=>{D("page-content"),g==="skills.installed"&&Ve(g)},e[101]=Ve,e[102]=g,e[103]=it):it=e[103];const xt=it;let At;e[104]!==ae||e[105]!==ee.isVSCode||e[106]!==g?(At=()=>{if(ae){if((typeof window<"u"?fr(window.history.state):null)?.page===g&&!ee.isVSCode){window.history.back();return}D("page-sidebar");return}D("nav")},e[104]=ae,e[105]=ee.isVSCode,e[106]=g,e[107]=At):At=e[107];const Zt=At;let ts,ss;e[108]!==m||e[109]!==ee.isVSCode||e[110]!==g?(ts=()=>{if(!m||ee.isVSCode)return;const De=pt=>{if(g!=="skills.installed")return;if(fr(pt.state)?.page==="skills.installed"){D("page-content");return}D(Hb)};return window.addEventListener("popstate",De),()=>{window.removeEventListener("popstate",De)}},ss=[m,ee.isVSCode,g],e[108]=m,e[109]=ee.isVSCode,e[110]=g,e[111]=ts,e[112]=ss):(ts=e[111],ss=e[112]),l.useEffect(ts,ss);let Vt;e[113]===Symbol.for("react.memo_cache_sentinel")?(Vt=()=>{D("page-sidebar")},e[113]=Vt):Vt=e[113];const Se=Vt,vt=()=>{const De=N.trim().length>0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[t.jsx("div",{className:"px-2 pt-3",children:t.jsxs("div",{className:"flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8",children:[t.jsx(A,{name:"search",className:"h-4 w-4 shrink-0"}),t.jsx("input",{value:N,onChange:pt=>y(pt.target.value),onKeyDown:ct,placeholder:c("settings.view.search.placeholder"),"aria-label":c("settings.view.search.aria"),className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),De&&t.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":c("settings.view.search.clear"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5",children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden",children:t.jsx("div",{className:"flex flex-col gap-0.5 pt-4 pb-2 px-2",children:De?H.length>0?(()=>{let pt=0;return Ee.map(Ft=>t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:Ft.pageTitle}),Ft.results.map(Xt=>{const Qt=pt;pt=pt+1;const Fn=Qt===z,Ks=!!Xt.description;return t.jsxs("button",{type:"button",ref:On=>{q.current[Qt]=On},onMouseMove:()=>{Y.current=!1,M(Qt)},onClick:()=>et(Xt),className:ce("flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ks?"min-h-11 py-1.5":"py-2",Fn?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Xt.title}),Ks&&t.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:Xt.description})]},Xt.id)})]},Ft.page))})():t.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:c("settings.view.search.noResults")}):je.map(pt=>{const Ft=g===pt.slug,Xt=rc(pt.slug);return!Xt&&pt.slug!=="mcp"?null:t.jsx(Pt,{children:t.jsx(It,{asChild:!0,children:t.jsxs("button",{type:"button",onClick:()=>Pe(pt.slug),"aria-current":Ft?"page":void 0,className:ce("flex h-8 items-center gap-2 rounded-md px-2 overflow-hidden",Ft?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[pt.slug==="mcp"?t.jsx(ru,{className:"h-4 w-4 shrink-0"}):t.jsx(A,{name:Xt,className:"h-4 w-4 shrink-0"}),t.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[t.jsx("span",{className:"typography-ui-label font-normal truncate",children:Qe(pt.slug)}),(pt.slug==="voice"||pt.slug==="tunnel")&&t.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:c("settings.view.badge.beta")})]})]})})},pt.slug)})})}),t.jsx("div",{className:"overflow-hidden transition-opacity duration-150 opacity-100",children:t.jsx("div",{className:"border-t border-border bg-sidebar px-2 py-1 space-y-0.5",children:!ee.isVSCode&&t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsxs("button",{type:"button",className:ce("flex h-7 w-full items-center gap-2 rounded-md px-2 overflow-hidden whitespace-nowrap","text-sm font-semibold text-sidebar-foreground/90","hover:text-sidebar-foreground hover:bg-interactive-hover"),onClick:qb,children:[t.jsx(A,{name:"restart",className:"h-4 w-4 shrink-0"}),t.jsx("span",{children:c("settings.view.actions.reloadOpenCode")})]})}),t.jsx(Dt,{children:c("settings.view.actions.reloadOpenCodeTooltip")})]})})})]})},jt=()=>{if(h==="nav")return t.jsx("div",{className:ce("flex-1 min-h-0 overflow-hidden",ee.isVSCode?"bg-background":"bg-sidebar"),children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(Ys,{children:vt()})})});if(!Fe)return t.jsx("div",{className:"flex-1 bg-background"});if(h==="page-sidebar"){if(Fe.kind!=="split"){const pt=Ge(g);return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:pt})})}return t.jsx("div",{className:ce("flex-1 min-h-0 overflow-hidden",ee.isVSCode?"bg-background":"bg-sidebar"),children:t.jsx(Ys,{children:nt(g,{onItemSelect:xt})})})}const De=Ge(g);return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:De})})};let lt;e[114]!==Fe||e[115]!==Pe||e[116]!==Ge||e[117]!==ee.isVSCode||e[118]!==g?(lt=()=>!Fe||g==="home"?t.jsx(xr,{onOpen:Pe}):Fe.kind==="split"?t.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:ce("w-[264px] min-w-[264px] border-r",ee.isVSCode?"bg-background":"bg-sidebar"),style:{borderColor:"var(--interactive-border)"},children:t.jsx(Ys,{children:nt(g,{})})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:Ge(g)})})]}):t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:Ge(g)})}),e[114]=Fe,e[115]=Pe,e[116]=Ge,e[117]=ee.isVSCode,e[118]=g,e[119]=lt):lt=e[119];const Et=lt,qt="true";let os;e[120]===Symbol.for("react.memo_cache_sentinel")?(os=ce("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),e[120]=os):os=e[120];const as=m?t.jsxs("div",{className:ce("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b px-3","bg-background"),style:{borderColor:"var(--interactive-border)"},children:[Nt||n?t.jsx("button",{type:"button",onClick:Nt?Zt:n,"aria-label":Ye,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(A,{name:"arrow-left-s",className:"h-5 w-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:h==="nav"?c("settings.view.home.title"):Fe?Qe(Fe.slug):c("settings.view.home.title")}),Ue&&t.jsx("button",{type:"button",onClick:Se,"aria-label":c("settings.view.actions.openSectionList"),className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(A,{name:"list-unordered",className:"h-5 w-5"})}),n&&t.jsx("button",{type:"button",onClick:n,"aria-label":c("settings.view.actions.closeSettings"),title:c("settings.view.actions.closeSettingsWithShortcut",{shortcut:ft}),className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(A,{name:"close",className:"h-5 w-5"})})]}):t.jsxs(t.Fragment,{children:[Nt&&t.jsx("div",{className:ce("absolute left-3 z-50",r?"top-2":"top-3"),children:t.jsx("button",{type:"button",onClick:Zt,"aria-label":c("settings.view.actions.back"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(A,{name:"arrow-left-s",className:"h-5 w-5"})})}),n&&t.jsx("div",{className:ce("absolute right-0.5 z-50",r?"top-0.5":"top-1"),children:t.jsx("button",{type:"button",onClick:n,"aria-label":c("settings.view.actions.closeSettings"),title:c("settings.view.actions.closeSettingsWithShortcut",{shortcut:ft}),className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(A,{name:"close",className:"h-5 w-5"})})})]}),Es="flex flex-1 min-h-0 overflow-hidden",Jt=m?jt():t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ce("relative flex h-full min-h-0 flex-col overflow-hidden border-r",W?"bg-sidebar":ee.isVSCode?"bg-background":"bg-sidebar",j?"":"transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]"),style:{width:`${w}px`,minWidth:`${w}px`,borderColor:"var(--interactive-border)"},children:[t.jsx("div",{className:ce("absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",j?"bg-primary/30":"bg-transparent hover:bg-primary/20"),tabIndex:0,onPointerDown:ne,onKeyDown:Me,role:"separator","aria-orientation":"vertical","aria-valuemin":zr,"aria-valuemax":Kr,"aria-valuenow":w,"aria-label":c("settings.view.actions.resizeNavigation")}),t.jsx(Ys,{children:vt()})]}),t.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Et()})]});let Ds;e[121]!==Jt?(Ds=t.jsx("div",{className:Es,children:Jt}),e[121]=Jt,e[122]=Ds):Ds=e[122];let Ns;return e[123]!==os||e[124]!==as||e[125]!==Ds?(Ns=t.jsxs("div",{ref:U,"data-settings-view":qt,className:os,children:[as,Ds]}),e[123]=os,e[124]=as,e[125]=Ds,e[126]=Ns):Ns=e[126],Ns};function Eb(s){return s.settingsPage}function Mb(s){return s.isSettingsDialogOpen}function Rb(s){return s.setSettingsPage}function Tb(s){return s.slug!=="home"}function Fb(s,e){return[s,e]}function Ob(s){return s.activeProjectId}function Lb(s){return s.name}function zb(s){return s.name}function Kb(s){return s.name}function $b(s){return s.name}function Bb(s){return s.name}function Ub(s){if(s.id.startsWith("agents.")){const e=$a.getState(),n=qn("new-agent",e.agents.map(Lb));return e.setAgentDraft({name:n,scope:"user"}),e.setSelectedAgent(n),s.id==="agents.create"?"agents.name":s.id}if(s.id.startsWith("commands.")){const e=Ba.getState(),n=qn("new-command",e.commands.map(zb));return e.setCommandDraft({name:n,scope:"user"}),e.setSelectedCommand(n),s.id==="commands.create"?"commands.name":s.id}if(s.id.startsWith("mcp.")){const e=Rn.getState(),n=qn("new-mcp-server",e.mcpServers.map(Kb));return e.setMcpDraft({name:n,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),e.setSelectedMcp(n),s.id==="mcp.create"?"mcp.server":s.id}if(s.id.startsWith("snippets.")){const e=Va.getState(),n=qn("new-snippet",e.snippets.map($b));return e.setSnippetDraft({name:n,scope:"global"}),e.setSelectedSnippet(n),s.id==="snippets.create"?"snippets.content":s.id}if(s.id.startsWith("skills.")){const e=Hs.getState(),n=qn("new-skill",e.skills.map(Bb));return e.setSkillDraft({name:n,scope:"user",source:"opencode",description:"",instructions:""}),e.setSelectedSkill(n),s.id==="skills.create"?"skills.basic-information":s.id}return s.id==="providers.connect"&&ut.getState().setSelectedProvider(Pb),s.id==="plugins.create"?"plugins.spec":s.id}function Vb(){window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))}function _b(s,e){switch(s){case"projects":return t.jsx(Eh,{onItemSelect:e.onItemSelect});case"agents":return t.jsx(Hu,{onItemSelect:e.onItemSelect});case"commands":return t.jsx(ap,{onItemSelect:e.onItemSelect});case"mcp":return t.jsx(pp,{onItemSelect:e.onItemSelect});case"plugins":return t.jsx(fg,{onItemSelect:e.onItemSelect});case"skills.installed":return t.jsx(Ag,{onItemSelect:e.onItemSelect});case"providers":return t.jsx(hf,{onItemSelect:e.onItemSelect});case"usage":return t.jsx(Rf,{onItemSelect:e.onItemSelect});case"magic-prompts":return t.jsx(nx,{onItemSelect:e.onItemSelect});case"snippets":return t.jsx(ox,{onItemSelect:e.onItemSelect});default:return null}}function Hb(s){return s==="page-content"?"page-sidebar":s}function Wb(){}function qb(){Dn({message:"Restarting OpenCode…",mode:"projects",scopes:["all"]}).catch(Wb)}const $v=Object.freeze(Object.defineProperty({__proto__:null,SettingsView:Ab,getSettingsNavIcon:rc},Symbol.toStringTag,{value:"Module"})),Gb=["chat","git","diff","terminal","files","diagram"],Jb=["settings","agents","commands","skills","providers","usage","git-identities"],As={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function Yo(s){const e=Qb();return{sessionId:Yb(e),tab:Xb(e),settingsPath:Zb(e),diffFile:ey(e)}}function Qb(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Yb(s){const e=s.get(As.SESSION);return!e||e.trim().length===0?null:e.trim()}function Xb(s){const e=s.get(As.TAB);if(!e)return null;const n=e.toLowerCase().trim();return Gb.includes(n)?n:null}function Zb(s){const e=s.get(As.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(Jb.includes(n),n)}function ey(s){const e=s.get(As.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function Xo(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(As.SESSION)||s.has(As.TAB)||s.has(As.SETTINGS)||s.has(As.FILE)}catch{return!1}}const ty="chat";function ic(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(As.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(As.SETTINGS,n),e}return s.tab!==ty&&e.set(As.TAB,s.tab),s.tab==="diff"&&s.diffFile&&s.diffFile.trim().length>0&&e.set(As.FILE,s.diffFile),e}function sy(s,e){const n=typeof window<"u"?window.location.pathname:"/",a=s.toString();return a?`${n}?${a}`:n}function ny(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=ic(s),a=[...e.entries()].sort((i,o)=>i[0].localeCompare(o[0])),r=[...n.entries()].sort((i,o)=>i[0].localeCompare(o[0]));if(a.length!==r.length)return!1;for(let i=0;i<a.length;i++)if(a[i][0]!==r[i][0]||a[i][1]!==r[i][1])return!1;return!0}catch{return!0}}function ay(s,e={}){if(!(typeof window>"u")&&!ry()&&!(!e.force&&ny(s)))try{const n=ic(s),a=sy(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",a):window.history.pushState({route:s},"",a)}catch{}}function ry(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function iy(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Bv(){const s=l.useMemo(()=>iy(),[]),e=l.useRef(!1),n=l.useRef(!1),a=Is(p=>p.setCurrentSession),r=Ke(p=>p.setActiveMainTab),i=Ke(p=>p.setSettingsDialogOpen),o=Ke(p=>p.setSettingsPage),d=Ke(p=>p.navigateToDiff),c=l.useCallback(async p=>{if(!n.current){n.current=!0;try{if(p.sessionId){const u=Is.getState().currentSessionId;p.sessionId!==u&&await a(p.sessionId)}if(p.settingsPath){o(Qr(p.settingsPath)),i(!0);return}Ke.getState().isSettingsDialogOpen&&i(!1),p.tab&&r(p.tab),p.diffFile&&(p.tab==="diff"||!p.tab)&&d(p.diffFile)}finally{n.current=!1}}},[a,r,i,o,d]),x=l.useCallback(()=>{const p=Is.getState(),u=Ke.getState();return{sessionId:p.currentSessionId,tab:u.activeMainTab,isSettingsOpen:u.isSettingsDialogOpen,settingsPath:u.settingsPage,diffFile:u.pendingDiffFile}},[]),m=l.useCallback((p={})=>{if(s||n.current)return;const u=x();ay(u,p)},[s,x]);l.useEffect(()=>{if(e.current||(e.current=!0,!Xo()))return;const p=Yo();(async()=>(await c(p),s||m({replace:!0})))()},[c,s,m]),l.useEffect(()=>{if(s)return;let p=Is.getState().currentSessionId;return Is.subscribe(C=>{const f=C.currentSessionId;f===p||n.current||(p=f,m())})},[s,m]),l.useEffect(()=>{if(s)return;let p=Ke.getState().activeMainTab,u=Ke.getState().isSettingsDialogOpen,C=Ke.getState().settingsPage,f=Ke.getState().pendingDiffFile;return Ke.subscribe(h=>{if(n.current)return;const D=h.activeMainTab!==p,k=h.isSettingsDialogOpen!==u,w=h.settingsPage!==C,E=h.pendingDiffFile!==f&&h.activeMainTab==="diff";p=h.activeMainTab,u=h.isSettingsDialogOpen,C=h.settingsPage,f=h.pendingDiffFile,(D||k||w||E)&&m()})},[s,m]),l.useEffect(()=>{if(typeof window>"u"||s)return;const p=()=>{const u=Yo();if(Xo())c(u);else{const C=Ke.getState();C.isSettingsDialogOpen&&i(!1),C.activeMainTab!=="chat"&&r("chat")}};return window.addEventListener("popstate",p),()=>{window.removeEventListener("popstate",p)}},[c,s,r,i])}function Uv(){const s=rt.c(5),e=Il(ly),n=l.useRef(e);let a,r;s[0]!==e?(a=()=>{n.current=e},r=[e],s[0]=e,s[1]=a,s[2]=r):(a=s[1],r=s[2]),l.useEffect(a,r);let i,o;s[3]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{let d=!1,c=null;const x=oy,m=p=>{d||(c=window.setTimeout(async()=>{const u=await n.current(),C=typeof u=="number"&&Number.isFinite(u)?x(u):36e5;m(C)},p))};return m(3e3),()=>{d=!0,c!==null&&window.clearTimeout(c)}},o=[],s[3]=i,s[4]=o):(i=s[3],o=s[4]),l.useEffect(i,o)}function oy(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function ly(s){return s.checkForUpdates}const oc={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},cy=oc.M;function dy(s){const e=s.index?.trim(),n=s.working_dir?.trim();return e&&e!=="?"?e.charAt(0):n?n.charAt(0):e?.charAt(0)||n?.charAt(0)||"M"}function my(s){const e=dy(s);return oc[e]??cy}const uy=l.memo(function(e){const n=rt.c(58),{file:a,actionLabel:r,actionSymbol:i,onAction:o,onViewDiff:d,onRevert:c,isReverting:x,stats:m,rowPaddingClassName:p,indentPx:u,actionAtStart:C,showRevert:f}=e,g=u===void 0?0:u,h=C===void 0?!1:C,D=f===void 0?!0:f;let k;n[0]!==a?(k=my(a),n[0]=a,n[1]=k):k=n[1];const w=k,{t:E}=dt(),N=w.description,y=m?.insertions??0,b=m?.deletions??0;let P;n[2]!==o||n[3]!==d?(P=he=>{he.key===" "?(he.preventDefault(),o()):he.key==="Enter"&&(he.preventDefault(),d())},n[2]=o,n[3]=d,n[4]=P):P=n[4];const z=P;let M;n[5]!==o?(M=he=>{he.preventDefault(),he.stopPropagation(),o()},n[5]=o,n[6]=M):M=n[6];const I=M;let v;n[7]!==c?(v=he=>{he.preventDefault(),he.stopPropagation(),c()},n[7]=c,n[8]=v):v=n[8];const j=v;let O;n[9]!==r||n[10]!==i||n[11]!==I?(O=t.jsx("button",{type:"button",onClick:I,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":r,title:r,children:i}),n[9]=r,n[10]=i,n[11]=I,n[12]=O):O=n[12];const T=O,B=`group flex items-center gap-2 py-1.5 cursor-pointer ${p??"px-3"}`;let U;n[13]!==g?(U=g>0?{paddingLeft:`${g}px`}:void 0,n[13]=g,n[14]=U):U=n[14];const Q=h?T:null;let q;n[15]!==w.color?(q={color:w.color},n[15]=w.color,n[16]=q):q=n[16];let R;n[17]!==w.code||n[18]!==N||n[19]!==q?(R=t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:q,title:N,"aria-label":N,children:w.code}),n[17]=w.code,n[18]=N,n[19]=q,n[20]=R):R=n[20];let Y;n[21]!==a.path?(Y=t.jsx(Nm,{filePath:a.path,className:"h-3.5 w-3.5 shrink-0"}),n[21]=a.path,n[22]=Y):Y=n[22];let F;if(n[23]!==a.path){e:{const he=a.path.lastIndexOf("/");if(he===-1){let ge;n[25]===Symbol.for("react.memo_cache_sentinel")?(ge={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},n[25]=ge):ge=n[25],F=t.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ge,title:a.path,children:a.path});break e}const Ie=a.path.slice(0,he),be=a.path.slice(he);let je;n[26]===Symbol.for("react.memo_cache_sentinel")?(je={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},n[26]=je):je=n[26];let ye;n[27]===Symbol.for("react.memo_cache_sentinel")?(ye=t.jsx("span",{className:"text-muted-foreground",children:"/"}),n[27]=ye):ye=n[27];const se=t.jsx("span",{className:"text-foreground",children:be.slice(1)});let ie;n[28]!==se?(ie=t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[ye,se]}),n[28]=se,n[29]=ie):ie=n[29],F=t.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:a.path,children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:je,children:Ie}),ie]})}n[23]=a.path,n[24]=F}else F=n[24];let W;n[30]===Symbol.for("react.memo_cache_sentinel")?(W={color:"var(--status-success)"},n[30]=W):W=n[30];let X;n[31]!==y?(X=t.jsxs("span",{style:W,children:["+",y]}),n[31]=y,n[32]=X):X=n[32];let re,Z;n[33]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),Z={color:"var(--status-error)"},n[33]=re,n[34]=Z):(re=n[33],Z=n[34]);let de;n[35]!==b?(de=t.jsxs("span",{style:Z,children:["-",b]}),n[35]=b,n[36]=de):de=n[36];let le;n[37]!==X||n[38]!==de?(le=t.jsxs("span",{className:"shrink-0 typography-micro",children:[X,re,de]}),n[37]=X,n[38]=de,n[39]=le):le=n[39];let ee;n[40]!==a.path||n[41]!==j||n[42]!==x||n[43]!==D||n[44]!==E?(ee=D?t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx("button",{type:"button",onClick:j,disabled:x,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:a.path}),children:x?t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(A,{name:"arrow-go-back",className:"size-3.5"})})}),t.jsx(Dt,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,n[40]=a.path,n[41]=j,n[42]=x,n[43]=D,n[44]=E,n[45]=ee):ee=n[45];const xe=h?null:T;let we;return n[46]!==z||n[47]!==d||n[48]!==U||n[49]!==Q||n[50]!==R||n[51]!==Y||n[52]!==F||n[53]!==le||n[54]!==ee||n[55]!==xe||n[56]!==B?(we=t.jsxs("div",{className:B,role:"button",tabIndex:0,onClick:d,onKeyDown:z,style:U,children:[Q,R,Y,F,le,ee,xe]}),n[46]=z,n[47]=d,n[48]=U,n[49]=Q,n[50]=R,n[51]=Y,n[52]=F,n[53]=le,n[54]=ee,n[55]=xe,n[56]=B,n[57]=we):we=n[57],we}),Zo=14,lc=s=>s.replace(/\\/g,"/").replace(/^\/+/,"").trim(),el=(s,e)=>({id:`dir:${s}`,path:s,name:e,children:new Map,directFiles:[],files:[]}),py=s=>{const e=el("","");for(const n of s){const a=lc(n.path);if(!a)continue;const i=a.split("/").filter(Boolean).slice(0,-1);let o=e;if(o.files.push(n),i.length>0){let d="";for(const c of i){d=d?`${d}/${c}`:c;const x=o.children.get(c);if(x){x.files.push(n),o=x;continue}const m=el(d,c);m.files.push(n),o.children.set(c,m),o=m}}o.directFiles.push(n)}return e},gy=(s,e)=>{const n=[],a=(r,i)=>{const o=Array.from(r.children.values()).sort((c,x)=>c.path.localeCompare(x.path));for(const c of o)n.push({key:c.id,kind:"directory",depth:i,directory:c}),e.has(c.path)&&a(c,i+1);const d=[...r.directFiles].sort((c,x)=>c.path.localeCompare(x.path));for(const c of d)n.push({key:`file:${lc(c.path)}`,kind:"file",depth:i,file:c})};return a(s,0),n},hy=1e3,ya=34,br=30,va="pl-0 pr-2",yr=(s,e)=>`${s} ${e}`,Vv=s=>{const e=rt.c(158),{groups:n,diffStats:a,revertingPaths:r,isRevertingAll:i,headerBackgroundClassName:o,onVisiblePathsChange:d,onRevertAll:c,onRevertDirectory:x}=s,m=i===void 0?!1:i,p=o===void 0?"bg-sidebar":o,{t:u}=dt(),C=l.useRef(null),g=Ke(fy)==="tree";let h;e[0]!==n?(h=n.filter(xy),e[0]=n,e[1]=h):h=e[1];const D=h;let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=new Set,e[2]=k):k=e[2];const[w,E]=l.useState(k);let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=new Set,e[3]=N):N=e[3];const[y,b]=l.useState(N),[P,z]=l.useState(!1),[M,I]=l.useState(null);let v;e[4]!==D?(v=D.map(by),e[4]=D,e[5]=v):v=e[5];const j=v;let O;e[6]!==j||e[7]!==D?(O=[],D.forEach(($e,Ve)=>{Array.from(j[Ve]?.children.values()??[]).forEach(it=>{O.push(yr($e.id,it.path))})}),e[6]=j,e[7]=D,e[8]=O):O=e[8];const T=O;let B,U;e[9]!==g||e[10]!==T?(B=()=>{g&&b($e=>{const Ve=new Set,it=new Set(T);return $e.forEach(xt=>{(xt.slice(xt.indexOf(" ")+1).includes("/")||it.has(xt))&&Ve.add(xt)}),T.forEach(xt=>Ve.add(xt)),Ve})},U=[g,T],e[9]=g,e[10]=T,e[11]=B,e[12]=U):(B=e[11],U=e[12]),l.useEffect(B,U);let Q;if(e[13]!==w||e[14]!==y||e[15]!==g||e[16]!==c||e[17]!==j||e[18]!==D){if(Q=[],D.forEach(($e,Ve)=>{if(Q.push({type:"header",key:`header:${$e.id}`,groupIndex:Ve}),!w.has($e.id)){if(g){const it=new Set;y.forEach(At=>{At.startsWith(`${$e.id} `)&&it.add(At.slice($e.id.length+1))}),gy(j[Ve],it).forEach(At=>{At.kind==="file"?Q.push({type:"file",key:`${$e.id}:${At.key}`,groupIndex:Ve,file:At.file,depth:At.depth}):Q.push({type:"directory",key:`${$e.id}:${At.key}`,groupIndex:Ve,directory:At.directory,depth:At.depth})});return}$e.entries.forEach(it=>{Q.push({type:"file",key:`${$e.id}:file:${it.path}`,groupIndex:Ve,file:it,depth:0})})}}),c&&D.length>0){let $e;e[20]===Symbol.for("react.memo_cache_sentinel")?($e={type:"revert-all",key:"revert-all"},e[20]=$e):$e=e[20],Q.push($e)}e[13]=w,e[14]=y,e[15]=g,e[16]=c,e[17]=j,e[18]=D,e[19]=Q}else Q=e[19];const q=Q,R=q.length,Y=R>=hy,F=l.useRef(null),[W,X]=l.useState(0);let re;e[21]===Symbol.for("react.memo_cache_sentinel")?(re=$e=>{const Ve=F.current,it=Ve?Ve.findItemIndex($e):Math.floor($e/ya);X(xt=>xt===it?xt:it)},e[21]=re):re=e[21];const Z=re;let de,le;e[22]!==d||e[23]!==R||e[24]!==q||e[25]!==Y||e[26]!==W?(de=()=>{if(!d)return;const $e=yy;if(R===0){d([]);return}if(!Y){const Ve=[];for(const it of q)if(it.type==="file"&&(Ve.push(it.file.path),Ve.length>=br))break;d(Ve);return}d(q.slice(W,W+Math.ceil((C.current?.clientHeight??0)/ya)+br).map(Ve=>$e(Ve)).filter(vy).slice(0,br))},le=[d,R,q,Y,W],e[22]=d,e[23]=R,e[24]=q,e[25]=Y,e[26]=W,e[27]=de,e[28]=le):(de=e[27],le=e[28]),l.useEffect(de,le);let ee;e[29]===Symbol.for("react.memo_cache_sentinel")?(ee=$e=>{E(Ve=>{const it=new Set(Ve);return it.has($e)?it.delete($e):it.add($e),it})},e[29]=ee):ee=e[29];const xe=ee;let we;e[30]===Symbol.for("react.memo_cache_sentinel")?(we=($e,Ve)=>{b(it=>{const xt=new Set(it),At=yr($e,Ve);return xt.has(At)?xt.delete(At):xt.add(At),xt})},e[30]=we):we=e[30];const he=we;let Ie;e[31]!==D?(Ie=new Set,D.forEach($e=>$e.entries.forEach(Ve=>Ie.add(Ve.path))),e[31]=D,e[32]=Ie):Ie=e[32];let be;e[33]!==Ie?(be=Array.from(Ie),e[33]=Ie,e[34]=be):be=e[34];const je=be,ye=je.length;let se;e[35]!==m||e[36]!==M||e[37]!==r?(se=M?m||M.paths.some($e=>r.has($e)):!1,e[35]=m,e[36]=M,e[37]=r,e[38]=se):se=e[38];const ie=se;let ge;e[39]!==je||e[40]!==m||e[41]!==c?(ge=async()=>{!c||m||je.length===0||(await c(je),z(!1))},e[39]=je,e[40]=m,e[41]=c,e[42]=ge):ge=e[42];const V=ge;let te;e[43]!==ie||e[44]!==x||e[45]!==M?(te=async()=>{!x||!M||ie||(await x(M.paths),I(null))},e[43]=ie,e[44]=x,e[45]=M,e[46]=te):te=e[46];const ne=te;let ue;e[47]!==w||e[48]!==p?(ue=($e,Ve)=>{const it=w.has($e.id),xt=$e.entries.length;return t.jsxs("div",{className:ce("sticky top-0 z-10 flex items-center gap-2 py-2",p,va,!Ve&&"mt-1 border-t border-border/40"),children:[t.jsx("button",{type:"button",onClick:()=>$e.onActionAll($e.entries.map(jy)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":$e.actionAllLabel,title:$e.actionAllLabel,children:$e.actionSymbol}),t.jsxs("button",{type:"button",onClick:()=>xe($e.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!it,children:[t.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:$e.title}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:xt}),t.jsx(A,{name:"arrow-down-s",className:ce("size-3.5 shrink-0 text-muted-foreground transition-transform",it&&"-rotate-90")})]})]})},e[47]=w,e[48]=p,e[49]=ue):ue=e[49];const Me=ue;let ke;e[50]!==y||e[51]!==m||e[52]!==x||e[53]!==r||e[54]!==u?(ke=($e,Ve,it)=>{const xt=y.has(yr($e.id,Ve.path)),At=Ve.files.map(wy),Zt=m||At.some(ts=>r.has(ts));return t.jsxs("div",{className:ce("group flex items-center gap-2 py-1.5",va),style:{paddingLeft:`${it*Zo}px`},children:[t.jsxs("button",{type:"button",onClick:()=>he($e.id,Ve.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":xt?u("gitView.changes.collapseDirectoryAria",{path:Ve.path}):u("gitView.changes.expandDirectoryAria",{path:Ve.path}),children:[xt?t.jsx(A,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):t.jsx(A,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:Ve.path,children:Ve.name}),t.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:Ve.files.length})]}),$e.showRevertActions!==!1&&x?t.jsx("button",{type:"button",onClick:()=>I({path:Ve.path,paths:At,count:At.length}),disabled:Zt,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":u("gitView.changes.revertDirectoryAria",{path:Ve.path}),title:u("gitView.changes.revertDirectoryTooltip"),children:Zt?t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(A,{name:"arrow-go-back",className:"size-3.5"})}):null,t.jsx("button",{type:"button",onClick:()=>$e.onActionAll(Ve.files.map(Ny)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":u($e.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:Ve.path}),title:u($e.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:Ve.path}),children:$e.actionSymbol})]})},e[50]=y,e[51]=m,e[52]=x,e[53]=r,e[54]=u,e[55]=ke):ke=e[55];const Re=ke;let Ae;e[56]!==a||e[57]!==m||e[58]!==g||e[59]!==Re||e[60]!==Me||e[61]!==r||e[62]!==u||e[63]!==D?(Ae=($e,Ve)=>{if($e.type==="revert-all")return t.jsx("div",{className:ce("flex justify-end py-2",va),children:t.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>z(!0),disabled:m,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[t.jsx(A,{name:"arrow-go-back",className:"size-3.5"}),u("gitView.changes.revertAll")]})});const it=D[$e.groupIndex];if(!it)return null;if($e.type==="header")return Me(it,Ve);if($e.type==="directory")return Re(it,$e.directory,$e.depth);const xt=$e.file;return t.jsx(uy,{file:xt,actionLabel:it.getActionLabel(xt.path),actionSymbol:it.actionSymbol,onAction:()=>it.onActionFile(xt.path),stats:a?.[xt.path],onViewDiff:()=>it.onViewDiff(xt.path),onRevert:()=>it.onRevertFile(xt.path),isReverting:r.has(xt.path)||m,rowPaddingClassName:va,indentPx:$e.depth*Zo,actionAtStart:!g,showRevert:it.showRevertActions!==!1})},e[56]=a,e[57]=m,e[58]=g,e[59]=Re,e[60]=Me,e[61]=r,e[62]=u,e[63]=D,e[64]=Ae):Ae=e[64];const Pe=Ae;let Te;e[65]!==q?(Te=$e=>{const Ve=q[$e],it=q[$e-1];return!Ve||!it||Ve.type!=="file"&&Ve.type!=="directory"||it.type!=="file"&&it.type!=="directory"?!1:it.groupIndex===Ve.groupIndex},e[65]=q,e[66]=Te):Te=e[66];const Fe=Te;let Be;e[67]!==Pe||e[68]!==q||e[69]!==Y||e[70]!==Fe||e[71]!==u?(Be=t.jsx(km,{ref:C,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:Y?t.jsx(ad,{ref:F,data:q,itemSize:ya,bufferSize:ya*12,scrollRef:C,onScroll:Z,children:($e,Ve)=>t.jsx("div",{className:ce("relative",Fe(Ve)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:Pe($e,Ve===0)},$e.key)}):t.jsx("div",{role:"list","aria-label":u("gitView.changes.changedFilesAria"),children:q.map(($e,Ve)=>t.jsx("div",{className:ce("relative",Fe(Ve)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:Pe($e,Ve===0)},$e.key))})}),e[67]=Pe,e[68]=q,e[69]=Y,e[70]=Fe,e[71]=u,e[72]=Be):Be=e[72];let We;e[73]===Symbol.for("react.memo_cache_sentinel")?(We=t.jsx(Sm,{containerRef:C,disableHorizontal:!0}),e[73]=We):We=e[73];let ze;e[74]!==Be?(ze=t.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[Be,We]}),e[74]=Be,e[75]=ze):ze=e[75];let Qe;e[76]!==m?(Qe=$e=>{!m&&!$e&&z(!1)},e[76]=m,e[77]=Qe):Qe=e[77];let oe;e[78]!==u?(oe=u("gitView.changes.revertAllDialogTitle"),e[78]=u,e[79]=oe):oe=e[79];let H;e[80]!==oe?(H=t.jsx(Ut,{children:oe}),e[80]=oe,e[81]=H):H=e[81];let me;e[82]!==ye||e[83]!==u?(me=ye===1?u("gitView.changes.revertAllDescriptionSingle",{count:ye}):u("gitView.changes.revertAllDescriptionPlural",{count:ye}),e[82]=ye,e[83]=u,e[84]=me):me=e[84];let Ne;e[85]!==me?(Ne=t.jsx(Wt,{children:me}),e[85]=me,e[86]=Ne):Ne=e[86];let Ee;e[87]!==H||e[88]!==Ne?(Ee=t.jsxs(_t,{children:[H,Ne]}),e[87]=H,e[88]=Ne,e[89]=Ee):Ee=e[89];let Ce;e[90]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>z(!1),e[90]=Ce):Ce=e[90];let _e;e[91]!==u?(_e=u("gitView.common.cancel"),e[91]=u,e[92]=_e):_e=e[92];let G;e[93]!==m||e[94]!==_e?(G=t.jsx(J,{variant:"outline",size:"sm",onClick:Ce,disabled:m,children:_e}),e[93]=m,e[94]=_e,e[95]=G):G=e[95];let $;e[96]!==V?($=()=>{V()},e[96]=V,e[97]=$):$=e[97];let fe;e[98]!==m||e[99]!==u?(fe=u(m?"gitView.changes.reverting":"gitView.changes.revertAll"),e[98]=m,e[99]=u,e[100]=fe):fe=e[100];let L;e[101]!==m||e[102]!==$||e[103]!==fe?(L=t.jsx(J,{variant:"destructive",size:"sm",onClick:$,disabled:m,children:fe}),e[101]=m,e[102]=$,e[103]=fe,e[104]=L):L=e[104];let Le;e[105]!==G||e[106]!==L?(Le=t.jsxs(Yt,{children:[G,L]}),e[105]=G,e[106]=L,e[107]=Le):Le=e[107];let Je;e[108]!==Ee||e[109]!==Le?(Je=t.jsxs(Bt,{className:"max-w-md",children:[Ee,Le]}),e[108]=Ee,e[109]=Le,e[110]=Je):Je=e[110];let Xe;e[111]!==P||e[112]!==Qe||e[113]!==Je?(Xe=t.jsx($t,{open:P,onOpenChange:Qe,children:Je}),e[111]=P,e[112]=Qe,e[113]=Je,e[114]=Xe):Xe=e[114];const et=!!M;let at;e[115]!==ie?(at=$e=>{!ie&&!$e&&I(null)},e[115]=ie,e[116]=at):at=e[116];let ct;e[117]!==u?(ct=u("gitView.changes.revertDirectoryDialogTitle"),e[117]=u,e[118]=ct):ct=e[118];let Ze;e[119]!==ct?(Ze=t.jsx(Ut,{children:ct}),e[119]=ct,e[120]=Ze):Ze=e[120];let He;e[121]!==M||e[122]!==u?(He=M?M.count===1?u("gitView.changes.revertDirectoryDescriptionSingle",{count:M.count,path:M.path}):u("gitView.changes.revertDirectoryDescriptionPlural",{count:M.count,path:M.path}):null,e[121]=M,e[122]=u,e[123]=He):He=e[123];let mt;e[124]!==He?(mt=t.jsx(Wt,{children:He}),e[124]=He,e[125]=mt):mt=e[125];let pe;e[126]!==Ze||e[127]!==mt?(pe=t.jsxs(_t,{children:[Ze,mt]}),e[126]=Ze,e[127]=mt,e[128]=pe):pe=e[128];let nt;e[129]===Symbol.for("react.memo_cache_sentinel")?(nt=()=>I(null),e[129]=nt):nt=e[129];let st;e[130]!==u?(st=u("gitView.common.cancel"),e[130]=u,e[131]=st):st=e[131];let Ge;e[132]!==ie||e[133]!==st?(Ge=t.jsx(J,{variant:"outline",size:"sm",onClick:nt,disabled:ie,children:st}),e[132]=ie,e[133]=st,e[134]=Ge):Ge=e[134];let ht;e[135]!==ne?(ht=()=>{ne()},e[135]=ne,e[136]=ht):ht=e[136];const wt=ie||!M;let Nt;e[137]!==ie||e[138]!==u?(Nt=u(ie?"gitView.changes.reverting":"gitView.changes.revertDirectory"),e[137]=ie,e[138]=u,e[139]=Nt):Nt=e[139];let ae;e[140]!==ht||e[141]!==wt||e[142]!==Nt?(ae=t.jsx(J,{variant:"destructive",size:"sm",onClick:ht,disabled:wt,children:Nt}),e[140]=ht,e[141]=wt,e[142]=Nt,e[143]=ae):ae=e[143];let Ue;e[144]!==Ge||e[145]!==ae?(Ue=t.jsxs(Yt,{children:[Ge,ae]}),e[144]=Ge,e[145]=ae,e[146]=Ue):Ue=e[146];let tt;e[147]!==pe||e[148]!==Ue?(tt=t.jsxs(Bt,{className:"max-w-md",children:[pe,Ue]}),e[147]=pe,e[148]=Ue,e[149]=tt):tt=e[149];let Ye;e[150]!==et||e[151]!==at||e[152]!==tt?(Ye=t.jsx($t,{open:et,onOpenChange:at,children:tt}),e[150]=et,e[151]=at,e[152]=tt,e[153]=Ye):Ye=e[153];let ft;return e[154]!==ze||e[155]!==Xe||e[156]!==Ye?(ft=t.jsxs(t.Fragment,{children:[ze,Xe,Ye]}),e[154]=ze,e[155]=Xe,e[156]=Ye,e[157]=ft):ft=e[157],ft};function fy(s){return s.gitChangesViewMode}function xy(s){return s.entries.length>0}function by(s){return py(s.entries)}function yy(s){return s&&s.type==="file"?s.file.path:null}function vy(s){return!!s}function jy(s){return s.path}function wy(s){return s.path}function Ny(s){return s.path}const vr=38,ja=200,ky=s=>{const e=rt.c(20),{value:n,onChange:a,placeholder:r,disabled:i,hasTouchInput:o,isMobile:d}=s,c=i===void 0?!1:i,x=o===void 0?!1:o,m=d===void 0?!1:d,{t:p}=dt(),u=l.useRef(null),C=Ke(Sy);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const z=u.current;if(!z)return;const M=document.activeElement===z,I=()=>{z.style.height=`${vr}px`;const j=z.scrollHeight,O=Math.min(Math.max(j,vr),ja);z.style.height=`${O}px`,z.style.overflowY=j>ja?"auto":"hidden",j>ja&&!M&&(z.scrollTop=z.scrollHeight)};I();const v=window.requestAnimationFrame(I);return()=>{window.cancelAnimationFrame(v)}},e[0]=f):f=e[0];let g;e[1]!==n?(g=[n],e[1]=n,e[2]=g):g=e[2],l.useLayoutEffect(f,g);let h;e[3]!==a?(h=z=>a(z.target.value),e[3]=a,e[4]=h):h=e[4];let D;e[5]!==r||e[6]!==p?(D=r??p("gitView.commit.messagePlaceholder"),e[5]=r,e[6]=p,e[7]=D):D=e[7];const k=x?"on":"off",w=x?"sentences":"off",E=m||C,N=c&&"opacity-50";let y;e[8]!==N?(y=ce("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",N),e[8]=N,e[9]=y):y=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b={minHeight:vr,maxHeight:ja},e[10]=b):b=e[10];let P;return e[11]!==c||e[12]!==E||e[13]!==y||e[14]!==h||e[15]!==D||e[16]!==k||e[17]!==w||e[18]!==n?(P=t.jsx("textarea",{ref:u,value:n,onChange:h,placeholder:D,rows:1,disabled:c,autoCorrect:k,autoCapitalize:w,spellCheck:E,className:y,style:b}),e[11]=c,e[12]=E,e[13]=y,e[14]=h,e[15]=D,e[16]=k,e[17]=w,e[18]=n,e[19]=P):P=e[19],P};function Sy(s){return s.inputSpellcheckEnabled}const Cy=s=>{const e=rt.c(30),{highlights:n,onInsert:a}=s,{t:r}=dt();if(n.length===0)return null;let i;e[0]!==n||e[1]!==a?(i=()=>{a(n)},e[0]=n,e[1]=a,e[2]=i):i=e[2];const o=i;let d;e[3]!==r?(d=r("gitView.commit.aiHighlights.title"),e[3]=r,e[4]=d):d=e[4];let c;e[5]!==d?(c=t.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=c):c=e[6];let x;e[7]!==r?(x=r("gitView.commit.aiHighlights.insertAria"),e[7]=r,e[8]=x):x=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(A,{name:"arrow-down",className:"size-4"}),e[9]=m):m=e[9];let p;e[10]!==o||e[11]!==x?(p=t.jsx(It,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"icon",className:"size-6",onClick:o,"aria-label":x,children:m})}),e[10]=o,e[11]=x,e[12]=p):p=e[12];let u;e[13]!==r?(u=r("gitView.commit.aiHighlights.insertTooltip"),e[13]=r,e[14]=u):u=e[14];let C;e[15]!==u?(C=t.jsx(Dt,{sideOffset:8,children:u}),e[15]=u,e[16]=C):C=e[16];let f;e[17]!==p||e[18]!==C?(f=t.jsxs(Pt,{children:[p,C]}),e[17]=p,e[18]=C,e[19]=f):f=e[19];let g;e[20]!==c||e[21]!==f?(g=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c,f]}),e[20]=c,e[21]=f,e[22]=g):g=e[22];let h;e[23]!==n?(h=n.map(Py),e[23]=n,e[24]=h):h=e[24];let D;e[25]!==h?(D=t.jsx("ul",{className:"space-y-1",children:h}),e[25]=h,e[26]=D):D=e[26];let k;return e[27]!==g||e[28]!==D?(k=t.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[g,D]}),e[27]=g,e[28]=D,e[29]=k):k=e[29],k};function Py(s,e){return t.jsx("li",{className:"typography-meta text-foreground",children:s},`${s}-${e}`)}const _v=s=>{const e=rt.c(75),{stagedCount:n,commitMessage:a,onCommitMessageChange:r,generatedHighlights:i,onInsertHighlights:o,onGenerateMessage:d,isGeneratingMessage:c,onCommit:x,onCommitAndPush:m,commitAction:p,hasPendingIndexMutation:u,gitmojiEnabled:C,onOpenGitmojiPicker:f}=s,g=u===void 0?!1:u,{t:h}=dt(),D=n>0;let k;e[0]!==p||e[1]!==a||e[2]!==g||e[3]!==D?(k=a.trim()&&D&&p===null&&!g,e[0]=p,e[1]=a,e[2]=g,e[3]=D,e[4]=k):k=e[4];const w=k,{isMobile:E,hasTouchInput:N}=Cs();let y;e[5]!==h?(y=h("gitView.commit.title"),e[5]=h,e[6]=y):y=e[6];let b;e[7]!==y?(b=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:y}),e[7]=y,e[8]=b):b=e[8];let P;e[9]!==D||e[10]!==h?(P=D?null:t.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:h("gitView.commit.stageFilesHint")}),e[9]=D,e[10]=h,e[11]=P):P=e[11];let z;e[12]!==b||e[13]!==P?(z=t.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[b,P]}),e[12]=b,e[13]=P,e[14]=z):z=e[14];let M;e[15]!==i||e[16]!==o?(M=t.jsx(Cy,{highlights:i,onInsert:o}),e[15]=i,e[16]=o,e[17]=M):M=e[17];let I;e[18]!==h?(I=h("gitView.commit.messagePlaceholder"),e[18]=h,e[19]=I):I=e[19];const v=p!==null;let j;e[20]!==a||e[21]!==N||e[22]!==E||e[23]!==r||e[24]!==I||e[25]!==v?(j=t.jsx(ky,{value:a,onChange:r,placeholder:I,disabled:v,hasTouchInput:N,isMobile:E}),e[20]=a,e[21]=N,e[22]=E,e[23]=r,e[24]=I,e[25]=v,e[26]=j):j=e[26];let O;e[27]!==C||e[28]!==f||e[29]!==h?(O=C&&t.jsxs(J,{variant:"outline",size:"sm",onClick:f,className:"w-fit",type:"button",children:[t.jsx(A,{name:"emotion-happy",className:"size-4"}),h("gitView.commit.addGitmoji")]}),e[27]=C,e[28]=f,e[29]=h,e[30]=O):O=e[30];const T=c||p!==null||g||n===0;let B;e[31]!==h?(B=h("gitView.commit.generateAria"),e[31]=h,e[32]=B):B=e[32];let U;e[33]!==c?(U=c?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=c,e[34]=U):U=e[34];let Q;e[35]!==h?(Q=h("gitView.commit.generate"),e[35]=h,e[36]=Q):Q=e[36];let q;e[37]!==Q?(q=t.jsx("span",{className:"commit-actions__label",children:Q}),e[37]=Q,e[38]=q):q=e[38];let R;e[39]!==d||e[40]!==T||e[41]!==B||e[42]!==U||e[43]!==q?(R=t.jsxs(J,{variant:"outline",size:"sm",onClick:d,disabled:T,type:"button","aria-label":B,className:"commit-actions__btn",children:[U,q]}),e[39]=d,e[40]=T,e[41]=B,e[42]=U,e[43]=q,e[44]=R):R=e[44];let Y;e[45]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx("div",{className:"flex-1"}),e[45]=Y):Y=e[45];const F=!w||c;let W;e[46]!==h?(W=h("gitView.commit.commitAria"),e[46]=h,e[47]=W):W=e[47];let X;e[48]!==p||e[49]!==h?(X=p==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label",children:h("gitView.commit.committing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"git-commit",className:"size-4"}),t.jsx("span",{className:"commit-actions__label",children:h("gitView.commit.commit")})]}),e[48]=p,e[49]=h,e[50]=X):X=e[50];let re;e[51]!==x||e[52]!==F||e[53]!==W||e[54]!==X?(re=t.jsx(J,{size:"sm",variant:"outline",onClick:x,disabled:F,className:"commit-actions__btn whitespace-nowrap","aria-label":W,children:X}),e[51]=x,e[52]=F,e[53]=W,e[54]=X,e[55]=re):re=e[55];let Z;e[56]!==w||e[57]!==p||e[58]!==c||e[59]!==E||e[60]!==m||e[61]!==h?(Z=E?t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(J,{variant:"default",size:"sm",onClick:()=>m(),disabled:!w||c,className:"h-7 w-7 p-0","aria-label":h("gitView.commit.pushAria"),children:p==="commitAndPush"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"arrow-up",className:"size-3.5"})})}),t.jsx(Dt,{side:"top",children:t.jsx("p",{children:h("gitView.commit.push")})})]}):t.jsx(J,{size:"sm",variant:"default",onClick:()=>m(),disabled:!w||c,className:"commit-actions__btn","aria-label":h("gitView.commit.pushAria"),children:p==="commitAndPush"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:h("gitView.commit.pushing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"arrow-up",className:"size-3.5"}),t.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:h("gitView.commit.push")})]})}),e[56]=w,e[57]=p,e[58]=c,e[59]=E,e[60]=m,e[61]=h,e[62]=Z):Z=e[62];let de;e[63]!==R||e[64]!==re||e[65]!==Z?(de=t.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[R,Y,re,Z]}),e[63]=R,e[64]=re,e[65]=Z,e[66]=de):de=e[66];let le;e[67]!==j||e[68]!==O||e[69]!==de||e[70]!==M?(le=t.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,j,O,de]}),e[67]=j,e[68]=O,e[69]=de,e[70]=M,e[71]=le):le=e[71];let ee;return e[72]!==le||e[73]!==z?(ee=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[z,le]}),e[72]=le,e[73]=z,e[74]=ee):ee=e[74],ee},Iy=s=>{const e=rt.c(41),{syncAction:n,remotes:a,onFetch:r,onSync:i,onRemoveRemote:o,disabled:d,removingRemoteName:c,aheadCount:x,behindCount:m,trackingRemoteName:p,hasUncommittedChanges:u}=s,C=a===void 0?[]:a,f=c===void 0?null:c,g=x===void 0?0:x,h=m===void 0?0:m,D=u===void 0?!1:u,{t:k}=dt(),w=l.useRef(!1),E=!!f,N=C.find(ie=>ie.name===p)??C[0],y=h>0&&D,b=d||n!==null||E||!N||y,P=d||n!==null||E||C.length===0,z=g>0||h>0;let M;e[0]!==k?(M=k("gitView.sync.sync"),e[0]=k,e[1]=M):M=e[1];const I=h>0?`↓${h}`:null,v=g>0?`↑${g}`:null;let j;e[2]!==M||e[3]!==I||e[4]!==v?(j=[M,I,v].filter(Boolean),e[2]=M,e[3]=I,e[4]=v,e[5]=j):j=e[5];const O=j.join(" "),T=y?k("gitView.sync.commitOrStashTooltip"):N?z?k("gitView.sync.syncChangesTooltip",{ahead:g,behind:h}):k("gitView.sync.syncChanges"):k("gitView.sync.noRemoteTooltip"),B=()=>{N&&i(N)},U="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden";let Q;e[6]===Symbol.for("react.memo_cache_sentinel")?(Q=ce("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=Q):Q=e[6];let q;e[7]!==k?(q=k("gitView.sync.syncChanges"),e[7]=k,e[8]=q):q=e[8];let R;e[9]!==n?(R=n==="sync"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=R):R=e[10];let Y;e[11]!==O?(Y=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:O}),e[11]=O,e[12]=Y):Y=e[12];let F;e[13]!==B||e[14]!==b||e[15]!==q||e[16]!==R||e[17]!==Y?(F=t.jsx(It,{asChild:!0,children:t.jsxs("button",{type:"button",onClick:B,disabled:b,className:Q,"aria-label":q,children:[R,Y]})}),e[13]=B,e[14]=b,e[15]=q,e[16]=R,e[17]=Y,e[18]=F):F=e[18];let W;e[19]!==T?(W=t.jsx(Dt,{sideOffset:8,children:T}),e[19]=T,e[20]=W):W=e[20];let X;e[21]!==F||e[22]!==W?(X=t.jsxs(Pt,{children:[F,W]}),e[21]=F,e[22]=W,e[23]=X):X=e[23];const re=gs;let Z;e[24]===Symbol.for("react.memo_cache_sentinel")?(Z=ce("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[24]=Z):Z=e[24];let de;e[25]!==k?(de=k("gitView.sync.moreActionsAria"),e[25]=k,e[26]=de):de=e[26];let le;e[27]===Symbol.for("react.memo_cache_sentinel")?(le=t.jsx(A,{name:"arrow-down-s",className:"size-4"}),e[27]=le):le=e[27];let ee;e[28]!==P||e[29]!==de?(ee=t.jsx(us,{asChild:!0,children:t.jsx("button",{type:"button",className:Z,disabled:P,"aria-label":de,children:le})}),e[28]=P,e[29]=de,e[30]=ee):ee=e[30];const xe=ps,we="start",he=-40,Ie="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",be=C.map(ie=>t.jsx(vs,{onSelect:ge=>{if(w.current){ge.preventDefault(),w.current=!1;return}r(ie)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(A,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:k("gitView.sync.fetchFromRemote",{name:ie.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ie.fetchUrl})]})}),o&&ie.name!==p?t.jsx(J,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||E,onPointerDown:ge=>{w.current=!0,ge.preventDefault(),ge.stopPropagation()},onClick:ge=>{w.current=!0,ge.preventDefault(),ge.stopPropagation(),o(ie)},"aria-label":k("gitView.header.removeRemoteAria",{name:ie.name}),title:k("gitView.header.removeRemoteTitle",{name:ie.name}),children:f===ie.name?t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(A,{name:"close",className:"size-3.5"})}):null]})},ie.name));let je;e[31]!==xe||e[32]!==be?(je=t.jsx(xe,{align:we,alignOffset:he,className:Ie,children:be}),e[31]=xe,e[32]=be,e[33]=je):je=e[33];let ye;e[34]!==re||e[35]!==ee||e[36]!==je?(ye=t.jsxs(re,{children:[ee,je]}),e[34]=re,e[35]=ee,e[36]=je,e[37]=ye):ye=e[37];let se;return e[38]!==X||e[39]!==ye?(se=t.jsxs("div",{className:U,children:[X,ye]}),e[38]=X,e[39]=ye,e[40]=se):se=e[40],se};function Dy(s){const e=rt.c(85),{draft:n,onEdit:a,onDelete:r,className:i,maxWidth:o}=s,{t:d}=dt(),x=Ka()?.currentTheme,[m,p]=ve.useState(!1),[u,C]=ve.useState(!1),f=typeof n.text=="string"?n.text:"";let g;e[0]!==f?(g=f.length>150||f.split(`
|
|
30
|
+
`).length>3,e[0]=f,e[1]=g):g=e[1];const h=g;let D;e[2]!==i?(D=ce("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200",i),e[2]=i,e[3]=D):D=e[3];const k=x?.colors?.surface?.elevated,w=x?.colors?.interactive?.border,E=o?`${Math.max(200,Math.floor(o))}px`:void 0;let N;e[4]!==k||e[5]!==w||e[6]!==E?(N={backgroundColor:k,borderColor:w,maxWidth:E},e[4]=k,e[5]=w,e[6]=E,e[7]=N):N=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=V=>{V.preventDefault(),C(!0)},e[8]=y):y=e[8];let b;e[9]!==D||e[10]!==N?(b=t.jsx("div",{className:D,style:N,"data-comment-card":"true",onContextMenu:y}),e[9]=D,e[10]=N,e[11]=b):b=e[11];let P;e[12]!==n.fileLabel?(P=t.jsx("span",{className:"truncate max-w-[200px]",title:n.fileLabel,children:n.fileLabel}),e[12]=n.fileLabel,e[13]=P):P=e[13];let z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("span",{children:"•"}),e[14]=z):z=e[14];let M;e[15]!==n.endLine||e[16]!==n.startLine||e[17]!==d?(M=d("inlineComment.range.lines",{start:n.startLine,end:n.endLine}),e[15]=n.endLine,e[16]=n.startLine,e[17]=d,e[18]=M):M=e[18];let I;e[19]!==M?(I=t.jsx("span",{children:M}),e[19]=M,e[20]=I):I=e[20];let v;e[21]!==n.side?(v=n.side&&t.jsxs("span",{children:["(",n.side,")"]}),e[21]=n.side,e[22]=v):v=e[22];let j;e[23]!==I||e[24]!==v||e[25]!==P?(j=t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5",children:[P,z,I,v]}),e[23]=I,e[24]=v,e[25]=P,e[26]=j):j=e[26];const O=m||!h,T=!m&&h&&"line-clamp-3";let B;e[27]!==T?(B=ce("text-sm whitespace-pre-wrap break-words leading-relaxed",T),e[27]=T,e[28]=B):B=e[28];let U;e[29]!==f||e[30]!==B?(U=t.jsx("div",{className:B,children:f}),e[29]=f,e[30]=B,e[31]=U):U=e[31];let Q;e[32]!==h||e[33]!==m||e[34]!==d?(Q=h&&t.jsx(gn,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"sm",className:"h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start",children:m?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"arrow-up-s",className:"size-3 mr-1"}),d("inlineComment.actions.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"arrow-down-s",className:"size-3 mr-1"}),d("inlineComment.actions.showMore")]})})}),e[32]=h,e[33]=m,e[34]=d,e[35]=Q):Q=e[35];let q;e[36]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx(hn,{}),e[36]=q):q=e[36];let R;e[37]!==O||e[38]!==U||e[39]!==Q?(R=t.jsxs(pn,{open:O,onOpenChange:p,children:[U,Q,q]}),e[37]=O,e[38]=U,e[39]=Q,e[40]=R):R=e[40];let Y;e[41]!==j||e[42]!==R?(Y=t.jsxs("div",{className:"flex-1 min-w-0",children:[j,R]}),e[41]=j,e[42]=R,e[43]=Y):Y=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(us,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"icon",className:"h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground",children:t.jsx(A,{name:"more",className:"size-4"})})}),e[44]=F):F=e[44];let W;e[45]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(A,{name:"edit",className:"size-4 mr-2"}),e[45]=W):W=e[45];let X;e[46]!==d?(X=d("inlineComment.actions.editComment"),e[46]=d,e[47]=X):X=e[47];let re;e[48]!==a||e[49]!==X?(re=t.jsxs(vs,{onClick:a,children:[W,X]}),e[48]=a,e[49]=X,e[50]=re):re=e[50];let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(A,{name:"delete-bin",className:"size-4 mr-2"}),e[51]=Z):Z=e[51];let de;e[52]!==d?(de=d("inlineComment.actions.deleteComment"),e[52]=d,e[53]=de):de=e[53];let le;e[54]!==r||e[55]!==de?(le=t.jsxs(vs,{onClick:r,className:"text-destructive",children:[Z,de]}),e[54]=r,e[55]=de,e[56]=le):le=e[56];let ee;e[57]!==re||e[58]!==le?(ee=t.jsxs(gs,{children:[F,t.jsxs(ps,{align:"end",children:[re,le]})]}),e[57]=re,e[58]=le,e[59]=ee):ee=e[59];let xe;e[60]!==Y||e[61]!==ee?(xe=t.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[Y,ee]}),e[60]=Y,e[61]=ee,e[62]=xe):xe=e[62];let we;e[63]!==xe||e[64]!==b?(we=t.jsx(tn,{render:b,children:xe}),e[63]=xe,e[64]=b,e[65]=we):we=e[65];let he;e[66]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx(A,{name:"edit",className:"size-4 mr-2"}),e[66]=he):he=e[66];let Ie;e[67]!==d?(Ie=d("inlineComment.actions.editComment"),e[67]=d,e[68]=Ie):Ie=e[68];let be;e[69]!==a||e[70]!==Ie?(be=t.jsxs(qs,{onClick:a,children:[he,Ie]}),e[69]=a,e[70]=Ie,e[71]=be):be=e[71];let je;e[72]===Symbol.for("react.memo_cache_sentinel")?(je=t.jsx(A,{name:"delete-bin",className:"size-4 mr-2"}),e[72]=je):je=e[72];let ye;e[73]!==d?(ye=d("inlineComment.actions.deleteComment"),e[73]=d,e[74]=ye):ye=e[74];let se;e[75]!==r||e[76]!==ye?(se=t.jsxs(qs,{onClick:r,className:"text-destructive focus:text-destructive",children:[je,ye]}),e[75]=r,e[76]=ye,e[77]=se):se=e[77];let ie;e[78]!==be||e[79]!==se?(ie=t.jsxs(sn,{children:[be,se]}),e[78]=be,e[79]=se,e[80]=ie):ie=e[80];let ge;return e[81]!==u||e[82]!==we||e[83]!==ie?(ge=t.jsxs(en,{open:u,onOpenChange:C,children:[we,ie]}),e[81]=u,e[82]=we,e[83]=ie,e[84]=ge):ge=e[84],ge}function tl(s){const e=rt.c(62),{initialText:n,onTextChange:a,onSave:r,onCancel:i,fileLabel:o,lineRange:d,isEditing:c,className:x,maxWidth:m}=s,p=n===void 0?"":n,u=c===void 0?!1:c,{t:C}=dt(),g=Ka()?.currentTheme,{isMobile:h}=Cs(),[D,k]=l.useState(p),w=ve.useRef(null);let E;e[0]!==a?(E=ne=>{k(ne),a?.(ne)},e[0]=a,e[1]=E):E=e[1];const N=E,y=ve.useRef(d);let b,P;e[2]!==d?(b=()=>{d&&(y.current=d)},P=[d],e[2]=d,e[3]=b,e[4]=P):(b=e[3],P=e[4]),ve.useEffect(b,P);const z=Oy,M=z(d);let I,v;e[5]!==h?(I=()=>{const ne=w.current;if(!ne)return;const ue=ne.closest(".overlay-scrollbar-container"),Me=ue?.scrollTop??window.scrollY,ke=ue?.scrollLeft??window.scrollX;if(h){ne.scrollIntoView({behavior:"auto",block:"nearest"});try{ne.focus({preventScroll:!0})}catch{ne.focus()}return}try{ne.focus({preventScroll:!0})}catch{ne.focus()}const Re=ne.value.length;try{ne.setSelectionRange(Re,Re)}catch{}requestAnimationFrame(()=>{ue?(ue.scrollTop=Me,ue.scrollLeft=ke):window.scrollTo({top:Me,left:ke})})},v=[h],e[5]=h,e[6]=I,e[7]=v):(I=e[6],v=e[7]),ve.useEffect(I,v);let j;e[8]!==i||e[9]!==r||e[10]!==D?(j=ne=>{(ne.metaKey||ne.ctrlKey)&&ne.key==="Enter"?(ne.preventDefault(),D.trim()&&r(D,z(y.current))):ne.key==="Escape"&&(ne.preventDefault(),i())},e[8]=i,e[9]=r,e[10]=D,e[11]=j):j=e[11];const O=j;let T;e[12]!==r||e[13]!==D?(T=ne=>{ne.stopPropagation(),D.trim()&&r(D,z(y.current))},e[12]=r,e[13]=D,e[14]=T):T=e[14];const B=T;let U;e[15]!==x?(U=ce("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200",x),e[15]=x,e[16]=U):U=e[16];const Q=g?.colors?.surface?.elevated,q=g?.colors?.interactive?.border,R=m?`${Math.max(200,Math.floor(m))}px`:void 0;let Y;e[17]!==Q||e[18]!==q||e[19]!==R?(Y={backgroundColor:Q,borderColor:q,maxWidth:R},e[17]=Q,e[18]=q,e[19]=R,e[20]=Y):Y=e[20];const F="true",W=Fy,X=Ty,re="p-3",Z=(o||d)&&t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2",children:[o&&t.jsx("span",{className:"truncate max-w-[200px]",children:o}),o&&d&&t.jsx("span",{children:"•"}),M&&t.jsx("span",{children:C("inlineComment.range.lines",{start:M.start,end:M.end})})]});let de;e[21]!==N?(de=ne=>N(ne.target.value),e[21]=N,e[22]=de):de=e[22];let le;e[23]!==h||e[24]!==C?(le=C(h?"inlineComment.input.placeholderShort":"inlineComment.input.placeholder"),e[23]=h,e[24]=C,e[25]=le):le=e[25];let ee;e[26]!==O||e[27]!==de||e[28]!==le||e[29]!==D?(ee=t.jsx(hs,{simple:!0,ref:w,value:D,onChange:de,onKeyDown:O,placeholder:le,outerClassName:"rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]",className:"min-h-[80px] px-3 py-2.5 text-sm resize-y"}),e[26]=O,e[27]=de,e[28]=le,e[29]=D,e[30]=ee):ee=e[30];let xe;e[31]!==C?(xe=C("inlineComment.actions.cancel"),e[31]=C,e[32]=xe):xe=e[32];let we;e[33]!==i||e[34]!==xe?(we=t.jsx(J,{variant:"ghost",size:"sm",onClick:i,onPointerDown:Ry,onTouchStart:My,className:"h-8 text-muted-foreground hover:text-foreground",children:xe}),e[33]=i,e[34]=xe,e[35]=we):we=e[35];let he;e[36]!==D?(he=D.trim(),e[36]=D,e[37]=he):he=e[37];const Ie=!he,be=g?.colors?.status?.success,je=g?.colors?.status?.successForeground;let ye;e[38]!==be||e[39]!==je?(ye={backgroundColor:be,color:je},e[38]=be,e[39]=je,e[40]=ye):ye=e[40];let se;e[41]!==u||e[42]!==C?(se=C(u?"inlineComment.actions.save":"inlineComment.actions.comment"),e[41]=u,e[42]=C,e[43]=se):se=e[43];let ie;e[44]!==B||e[45]!==Ie||e[46]!==ye||e[47]!==se?(ie=t.jsx(J,{size:"sm",onClick:B,onPointerDown:Ey,onTouchStart:Ay,disabled:Ie,className:"h-8 min-w-[80px]",style:ye,children:se}),e[44]=B,e[45]=Ie,e[46]=ye,e[47]=se,e[48]=ie):ie=e[48];let ge;e[49]!==we||e[50]!==ie?(ge=t.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[we,ie]}),e[49]=we,e[50]=ie,e[51]=ge):ge=e[51];let V;e[52]!==Z||e[53]!==ee||e[54]!==ge?(V=t.jsxs("div",{className:re,children:[Z,ee,ge]}),e[52]=Z,e[53]=ee,e[54]=ge,e[55]=V):V=e[55];let te;return e[56]!==U||e[57]!==Y||e[58]!==W||e[59]!==X||e[60]!==V?(te=t.jsx("div",{className:U,style:Y,"data-comment-input":F,onPointerDown:W,onTouchStart:X,children:V}),e[56]=U,e[57]=Y,e[58]=W,e[59]=X,e[60]=V,e[61]=te):te=e[61],te}function Ay(s){return s.stopPropagation()}function Ey(s){return s.stopPropagation()}function My(s){return s.stopPropagation()}function Ry(s){return s.stopPropagation()}function Ty(s){return s.stopPropagation()}function Fy(s){return s.stopPropagation()}function Oy(s){if(!s)return;const e=Math.min(s.start,s.end),n=Math.max(s.start,s.end);return{...s,start:e,end:n}}const Ly=s=>{const e=Math.min(s.startLine,s.endLine),n=Math.max(s.startLine,s.endLine);return{...s,startLine:e,endLine:n}},sl=s=>{const e=Math.min(s.start,s.end),n=Math.max(s.start,s.end);return{...s,start:e,end:n}};function zy(s){const e=rt.c(40),{t:n}=dt(),{source:a,fileLabel:r,language:i,getCodeForRange:o,toStoreRange:d,fromDraftRange:c}=s,x=Is(_y),m=Is(Vy),p=ra(Uy),u=ra(By),C=ra($y),f=ra(Ky),[g,h]=l.useState(null),[D,k]=l.useState(""),[w,E]=l.useState(null),N=x??(m?"draft":null);let y;e:{if(!N||!r){let F;e[0]===Symbol.for("react.memo_cache_sentinel")?(F=[],e[0]=F):F=e[0],y=F;break e}let q;e[1]!==f||e[2]!==N?(q=f[N]??[],e[1]=f,e[2]=N,e[3]=q):q=e[3];const R=q;let Y;if(e[4]!==r||e[5]!==R||e[6]!==a){let F;e[8]!==r||e[9]!==a?(F=W=>W.source===a&&W.fileLabel===r,e[8]=r,e[9]=a,e[10]=F):F=e[10],Y=R.filter(F),e[4]=r,e[5]=R,e[6]=a,e[7]=Y}else Y=e[7];y=Y}const b=y;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{h(null),k(""),E(null)},e[11]=P):P=e[11];const z=P;let M;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{z()},e[12]=M):M=e[12];const I=M;let v;e[13]!==c?(v=q=>{const R=sl(c(q));h(R),k(q.text),E(q.id)},e[13]=c,e[14]=v):v=e[14];const j=v;let O;e[15]!==w||e[16]!==C?(O=q=>{C(q.sessionKey,q.id),w===q.id&&z()},e[15]=w,e[16]=C,e[17]=O):O=e[17];const T=O;let B;e[18]!==p||e[19]!==w||e[20]!==r||e[21]!==o||e[22]!==i||e[23]!==g||e[24]!==N||e[25]!==a||e[26]!==n||e[27]!==d||e[28]!==u?(B=(q,R)=>{const Y=R??g,F=q.trim();if(!Y||!F||!r)return;if(!N){_.error(n("inlineComment.toast.selectSessionToSave"));return}const W=sl(Y),X=Ly(d(W)),re=o(W);w?u(N,w,{fileLabel:r,startLine:X.startLine,endLine:X.endLine,side:X.side,code:re,language:i,text:F}):p({sessionKey:N,source:a,fileLabel:r,startLine:X.startLine,endLine:X.endLine,side:X.side,code:re,language:i,text:F}),z()},e[18]=p,e[19]=w,e[20]=r,e[21]=o,e[22]=i,e[23]=g,e[24]=N,e[25]=a,e[26]=n,e[27]=d,e[28]=u,e[29]=B):B=e[29];const U=B;let Q;return e[30]!==D||e[31]!==T||e[32]!==b||e[33]!==w||e[34]!==c||e[35]!==U||e[36]!==g||e[37]!==N||e[38]!==j?(Q={sessionKey:N,drafts:b,selection:g,setSelection:h,commentText:D,setCommentText:k,editingDraftId:w,setEditingDraftId:E,reset:z,cancel:I,startEdit:j,deleteDraft:T,saveComment:U,fromDraftRange:c},e[30]=D,e[31]=T,e[32]=b,e[33]=w,e[34]=c,e[35]=U,e[36]=g,e[37]=N,e[38]=j,e[39]=Q):Q=e[39],Q}function Ky(s){return s.drafts}function $y(s){return s.removeDraft}function By(s){return s.updateDraft}function Uy(s){return s.addDraft}function Vy(s){return s.newSessionDraft?.open}function _y(s){return s.currentSessionId}const Ma=s=>{if(s.type==="new"){const e=Math.min(s.selection.start,s.selection.end),n=Math.max(s.selection.start,s.selection.end);return`new-comment-${s.selection.side??"additions"}-${e}-${n}`}return`draft-${s.draft.id}`},Hy=s=>{const{drafts:e,editingDraftId:n,selection:a}=s,r=[];for(const i of e){if(!Number.isFinite(i.endLine))continue;const o=Math.max(1,Math.floor(i.endLine)),d=i.side==="original"?"deletions":"additions";r.push({lineNumber:o,side:d,metadata:{type:i.id===n?"edit":"saved",draft:i}})}return a&&!n&&r.push({lineNumber:Math.max(a.start,a.end),side:a.side??"additions",metadata:{type:"new",selection:a}}),r};function Wy(s){const e=s.trim();if(!e)return null;if(/^-?\d+(\.\d+)?$/.test(e)){const n=Number.parseFloat(e);return Number.isFinite(n)?n:null}if(e.endsWith("px")){const n=Number.parseFloat(e.slice(0,-2));return Number.isFinite(n)?n:null}return null}function nl(s){if(!(!s||s<=0))return Math.max(200,Math.floor(s))}function qy(s){const{diffRootRef:e,drafts:n,selection:a,editingDraftId:r,commentText:i,onTextChange:o,fileLabel:d,onSave:c,onCancel:x,onEdit:m,onDelete:p}=s,[u,C]=l.useState(0),[f,g]=l.useState(null),h=l.useMemo(()=>!a||r?null:Ma({type:"new",selection:a}),[r,a]),D=l.useMemo(()=>{const E=n.map(N=>Ma({type:N.id===r?"edit":"saved",draft:N}));return h&&E.push(h),E},[n,r,h]),k=l.useCallback(E=>{const N=e.current;if(!N)return null;const y=N.querySelector("diffs-container");if(!(y instanceof HTMLElement))return null;const b=y.querySelector(`[data-annotation-id="${E}"]`);if(b instanceof HTMLElement)return b;const P=y.shadowRoot;return P?P.querySelector(`[data-annotation-id="${E}"]`):null},[e]);l.useEffect(()=>{if(D.length===0)return;let E=!1,N=0;const y=12,b=()=>{E||D.every(z=>!!k(z))||N>=y||(N+=1,requestAnimationFrame(()=>{E||(C(z=>z+1),b())}))};return b(),()=>{E=!0}},[D,k]),l.useEffect(()=>{const E=e.current;if(!E)return;const N=()=>{const b=getComputedStyle(E),P=Wy(b.getPropertyValue("--oc-context-panel-width")),z=E.getBoundingClientRect(),M=P??z.width;g(M>0?M:null)};N();const y=new ResizeObserver(()=>{N()});return y.observe(E),window.addEventListener("resize",N),()=>{y.disconnect(),window.removeEventListener("resize",N)}},[e]);const w=l.useCallback(E=>{const y=e.current?.getBoundingClientRect(),b=E.closest("[data-annotation-content]"),P=b instanceof HTMLElement?b.getBoundingClientRect():E.getBoundingClientRect(),z=[P.width];y&&z.push(y.right-P.left);const M=z.filter(I=>Number.isFinite(I)&&I>0);return M.length>0?nl(Math.min(...M)):nl(f)},[e,f]);return t.jsxs(t.Fragment,{children:[n.map(E=>{const N=Ma({type:E.id===r?"edit":"saved",draft:E}),y=k(N);if(!y)return null;const b=w(y);return E.id===r?Na.createPortal(t.jsx(tl,{initialText:i,onTextChange:o,fileLabel:d,lineRange:{start:E.startLine,end:E.endLine,side:E.side==="original"?"deletions":"additions"},isEditing:!0,onSave:c,onCancel:x,maxWidth:b}),y,`draft-edit-${E.id}`):Na.createPortal(t.jsx(Dy,{draft:E,onEdit:()=>m(E),onDelete:()=>p(E),maxWidth:b}),y,`draft-card-${E.id}`)}),a&&!r&&h&&(()=>{const E=k(h);if(!E)return null;const N=w(E);return Na.createPortal(t.jsx(tl,{initialText:i,onTextChange:o,fileLabel:d,lineRange:a,isEditing:!1,onSave:c,onCancel:x,maxWidth:N}),E,h)})()]})}const al=5e5,Gy=`
|
|
31
|
+
:host {
|
|
32
|
+
font-family: var(--font-mono);
|
|
33
|
+
font-size: var(--text-code);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pre, [data-code] {
|
|
37
|
+
font-family: var(--font-mono);
|
|
38
|
+
font-size: var(--text-code);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Mobile touch selection support */
|
|
42
|
+
[data-line-number] {
|
|
43
|
+
touch-action: manipulation;
|
|
44
|
+
-webkit-tap-highlight-color: transparent;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Ensure interactive line numbers work on touch */
|
|
49
|
+
pre[data-interactive-line-numbers] [data-line-number] {
|
|
50
|
+
touch-action: manipulation;
|
|
51
|
+
}
|
|
52
|
+
`,Jy=`
|
|
53
|
+
${Gy}
|
|
54
|
+
|
|
55
|
+
:host {
|
|
56
|
+
--diffs-bg-separator-override: var(--surface-elevated);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[data-diff-header],
|
|
60
|
+
[data-diff] {
|
|
61
|
+
[data-separator] {
|
|
62
|
+
height: 24px !important;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-separator="line-info-basic"] {
|
|
67
|
+
height: 24px !important;
|
|
68
|
+
background: var(--diffs-bg) !important;
|
|
69
|
+
position: relative;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-diff-type="single"] [data-gutter],
|
|
73
|
+
[data-diff-type="split"] [data-deletions] [data-gutter] {
|
|
74
|
+
[data-separator-wrapper] {
|
|
75
|
+
position: absolute;
|
|
76
|
+
left: 100%;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: unset;
|
|
80
|
+
width: max-content;
|
|
81
|
+
background: transparent;
|
|
82
|
+
color: var(--diffs-fg-number);
|
|
83
|
+
font-family: var(--diffs-header-font-family, var(--font-sans));
|
|
84
|
+
font-size: 0.75rem;
|
|
85
|
+
line-height: 1;
|
|
86
|
+
margin-left: calc(-2ch - 2px);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[data-separator-wrapper][data-separator-multi-button] {
|
|
90
|
+
margin-left: calc(-3ch - 2px);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-expand-button],
|
|
94
|
+
[data-separator-content] {
|
|
95
|
+
display: block;
|
|
96
|
+
align-self: unset;
|
|
97
|
+
min-width: unset;
|
|
98
|
+
min-height: unset;
|
|
99
|
+
padding: 0;
|
|
100
|
+
flex-shrink: 0;
|
|
101
|
+
grid-column: unset;
|
|
102
|
+
border: none;
|
|
103
|
+
width: auto;
|
|
104
|
+
height: auto;
|
|
105
|
+
background-color: transparent;
|
|
106
|
+
color: inherit;
|
|
107
|
+
font: inherit;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[data-expand-button]:not([data-expand-all-button]) {
|
|
111
|
+
&[data-expand-down]::before {
|
|
112
|
+
content: '\\2191';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&[data-expand-up]::before {
|
|
116
|
+
content: '\\2193';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[data-expand-both]::before {
|
|
120
|
+
content: '\\2195';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
svg {
|
|
124
|
+
display: none;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
[data-separator-content] {
|
|
129
|
+
background: transparent;
|
|
130
|
+
margin-left: calc(2px + 1ch);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
[data-expand-all-button] {
|
|
134
|
+
position: relative;
|
|
135
|
+
margin-left: 14px;
|
|
136
|
+
text-transform: lowercase;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
[data-expand-all-button]::before {
|
|
140
|
+
content: '';
|
|
141
|
+
display: block;
|
|
142
|
+
position: absolute;
|
|
143
|
+
top: 50%;
|
|
144
|
+
left: -8px;
|
|
145
|
+
margin-top: -1px;
|
|
146
|
+
width: 3px;
|
|
147
|
+
height: 3px;
|
|
148
|
+
border-radius: 2px;
|
|
149
|
+
background-color: var(--diffs-fg-number);
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
[data-separator-content]:hover,
|
|
154
|
+
[data-expand-button]:hover,
|
|
155
|
+
[data-expand-all-button]:hover {
|
|
156
|
+
color: var(--diffs-fg);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[data-expand-all-button]:hover {
|
|
160
|
+
text-decoration: underline;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`;function Qy(s){let e=2166136261;for(let n=0;n<s.length;n+=1)e^=s.charCodeAt(n),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function rl(s){const e=s.length>400?`${s.slice(0,200)}${s.slice(-200)}`:s;return`${s.length}:${Qy(e)}`}const Yy=(s,e,n,a)=>{const r=a.side==="deletions",o=(n?(r?n.deletionLines:n.additionLines).join(""):r?s:e).split(`
|
|
164
|
+
`),d=Math.min(a.start,a.end),c=Math.max(a.start,a.end),x=Math.max(1,d),m=Math.min(o.length,c);return x>m?"":o.slice(x-1,m).join(`
|
|
165
|
+
`)},Xy=(s,e)=>s===e?!0:!s||!e?!1:s.start===e.start&&s.end===e.end&&s.side===e.side,Zy=s=>s==="auto"||s==="scroll"||s==="overlay",ev=s=>{let e=s?.parentElement??null;for(;e;){const n=window.getComputedStyle(e);if(Zy(n.overflowY))return e;e=e.parentElement}return null},tv=(s,e)=>{if(!s||!e||typeof window>"u")return()=>{};const n=ev(s);if(!n)return()=>{};const a=e.getBoundingClientRect().height;if(!a)return()=>{};const r=s.getBoundingClientRect().top-n.getBoundingClientRect().top,i=e.style.minHeight;e.style.minHeight=`${Math.ceil(a)}px`;let o=!1;return()=>{if(o)return;o=!0,e.style.minHeight=i;const c=s.getBoundingClientRect().top-n.getBoundingClientRect().top-r;c&&(n.scrollTop+=c)}},sv=(s,e)=>{if(typeof window>"u")return()=>{};let n=null,a=null,r=!1;const i=()=>{r||(a?.disconnect(),a=null,n=window.requestAnimationFrame(()=>{n=window.requestAnimationFrame(()=>{r||e()})}))},o=()=>s.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=o())=>!!c?.querySelector("[data-line]");return d()?i():typeof MutationObserver<"u"?(a=new MutationObserver(()=>{const c=o();if(c){if(d(c)){i();return}a?.disconnect(),a=new MutationObserver(()=>{d(c)&&i()}),a.observe(c,{childList:!0,subtree:!0})}}),a.observe(s,{childList:!0,subtree:!0})):n=window.requestAnimationFrame(i),()=>{r=!0,a?.disconnect(),n!==null&&window.cancelAnimationFrame(n)}},wa=new WeakMap,nv={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function av(s){const e=s.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const n=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:n instanceof HTMLElement?n:void 0}}return{key:document,root:document,content:void 0}}function rv(s){if(typeof document>"u")return null;const e=av(s);let n=wa.get(e.key);if(!n){const r=new ld;r.setup(e.root,e.content),n={virtualizer:r,refs:0},wa.set(e.key,n)}n.refs+=1;let a=!1;return{virtualizer:n.virtualizer,root:e.root,release:()=>{if(a)return;a=!0;const r=wa.get(e.key);r&&(r.refs-=1,!(r.refs>0)&&(r.virtualizer.cleanUp(),wa.delete(e.key)))}}}const iv=(s,e,n)=>{if(typeof window>"u")return()=>{};const a=[],r=()=>{try{s.rerender()}catch{}const i=e?.root;i instanceof HTMLElement?i.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),n()};return a.push(window.requestAnimationFrame(r)),a.push(window.requestAnimationFrame(()=>{a.push(window.requestAnimationFrame(r))})),()=>{for(const i of a)window.cancelAnimationFrame(i)}},Hv=({original:s,modified:e,fileDiff:n,language:a,fileName:r,renderSideBySide:i,wrapLines:o,layout:d="fill",enableComments:c=!0})=>{const x=Ka(),m=x?.currentTheme.metadata.variant==="dark",p=x?.availableThemes.find(V=>V.metadata.id===x.lightThemeId)??Ta(!1),u=x?.availableThemes.find(V=>V.metadata.id===x.darkThemeId)??Ta(!0),{isMobile:C}=Cs(),f=zy({source:"diff",fileLabel:r||"unknown",language:a,getCodeForRange:V=>Yy(s,e,n,V),toStoreRange:V=>({startLine:V.start,endLine:V.end,side:V.side==="deletions"?"original":"modified"}),fromDraftRange:V=>({start:V.startLine,end:V.endLine,side:V.side==="original"?"deletions":"additions"})}),{drafts:g,selection:h,setSelection:D,commentText:k,setCommentText:w,editingDraftId:E,saveComment:N,cancel:y,startEdit:b,deleteDraft:P}=f,z=ve.useRef(null),M=ve.useRef(null),I=ve.useRef(""),v=ve.useRef(!1),j=ve.useRef(null);ve.useEffect(()=>{z.current=h},[h]),ve.useEffect(()=>{M.current=E},[E]),ve.useEffect(()=>{I.current=k},[k]);const O=ve.useCallback(V=>{if(!c||v.current)return;const te=z.current;if(!(!V&&te&&I.current.trim())){if(C&&te&&V&&V.side===te.side){const ne=Math.min(te.start,V.start),ue=Math.max(te.end,V.end);D({...V,start:ne,end:ue})}else D(V);V&&(M.current||w(""))}},[c,C,w,D]),T=ve.useCallback(()=>{y()},[y]),B=ve.useCallback(V=>{const te=document.createElement("div");te.style.position="relative";const ne=Ma(V.metadata);return te.dataset.annotationId=ne,te.dataset.annotationSide=V.side,te.dataset.annotationLine=String(V.lineNumber),te},[]),U=ve.useCallback((V,te)=>{N(V,te??h??void 0)},[N,h]),Q=ve.useCallback(V=>{D(V);const te=X.current;if(te)try{v.current=!0,te.setSelectedLines(V),j.current=V}catch{}finally{v.current=!1}},[D]),q=ve.useCallback(V=>{const te=V.closest("[data-line-type]")?.getAttribute("data-line-type")??V.getAttribute("data-line-type");if(te==="change-deletion")return"deletions";if(te==="change-addition")return"additions";const ne=V.getAttribute("data-column-side")??V.getAttribute("data-side")??V.closest("[data-column-side]")?.getAttribute("data-column-side");if(ne==="deletions"||ne==="left"||ne==="original")return"deletions";if(ne==="additions"||ne==="right"||ne==="modified")return"additions";const ue=V.closest("[data-line-type]");if(ue instanceof HTMLElement){const Me=ue.getBoundingClientRect(),ke=V.getBoundingClientRect(),Re=Me.left+Me.width/2;return ke.left+ke.width/2<Re?"deletions":"additions"}return"additions"},[]);Fa(p),Fa(u);const R=`${p.metadata.id}:${u.metadata.id}:${m?"dark":"light"}`,Y=ve.useMemo(()=>{if(n){const V=n.deletionLines.reduce((ne,ue)=>ne+ue.length,0),te=n.additionLines.reduce((ne,ue)=>ne+ue.length,0);return Math.max(V,te)>al}return Math.max(s.length,e.length)>al},[n,e.length,s.length]),F=ve.useRef(null),W=ve.useRef(null),X=ve.useRef(null),re=ve.useRef(null),Z=ve.useRef(null),de=ve.useRef(null),le=ve.useRef(void 0),ee=ve.useRef(void 0),xe=ve.useRef(void 0),we=ve.useRef(void 0),[,he]=l.useReducer(V=>V+1,0),Ie=Dr(Y?"unified":i?"split":"unified"),be=ve.useMemo(()=>Nr(p),[p]),je=ve.useMemo(()=>Nr(u),[u]);l.useLayoutEffect(()=>{const V=F.current;if(!V)return;const te=V.querySelector("diffs-container");if(!te)return;const ne=m?je:be,ue=(Qe,oe)=>Qe.colors?.[oe],Me=ue(be,"terminal.ansiGreen"),ke=ue(be,"terminal.ansiRed"),Re=ue(be,"terminal.ansiBlue"),Ae=ue(je,"terminal.ansiGreen"),Pe=ue(je,"terminal.ansiRed"),Te=ue(je,"terminal.ansiBlue");te.style.setProperty("--shiki-light",be.fg),te.style.setProperty("--shiki-light-bg",be.bg),Me&&te.style.setProperty("--shiki-light-addition-color",Me),ke&&te.style.setProperty("--shiki-light-deletion-color",ke),Re&&te.style.setProperty("--shiki-light-modified-color",Re),te.style.setProperty("--shiki-dark",je.fg),te.style.setProperty("--shiki-dark-bg",je.bg),Ae&&te.style.setProperty("--shiki-dark-addition-color",Ae),Pe&&te.style.setProperty("--shiki-dark-deletion-color",Pe),Te&&te.style.setProperty("--shiki-dark-modified-color",Te),te.style.setProperty("--diffs-bg",ne.bg),te.style.setProperty("--diffs-fg",ne.fg);const Fe=m?Ae:Me,Be=m?Pe:ke,We=m?Te:Re;Fe&&te.style.setProperty("--diffs-addition-color-override",Fe),Be&&te.style.setProperty("--diffs-deletion-color-override",Be),We&&te.style.setProperty("--diffs-modified-color-override",We);const ze=te.shadowRoot?.querySelector("pre");ze&&(ze.style.setProperty("--shiki-light",be.fg),ze.style.setProperty("--shiki-light-bg",be.bg),Me&&ze.style.setProperty("--shiki-light-addition-color",Me),ke&&ze.style.setProperty("--shiki-light-deletion-color",ke),Re&&ze.style.setProperty("--shiki-light-modified-color",Re),ze.style.setProperty("--shiki-dark",je.fg),ze.style.setProperty("--shiki-dark-bg",je.bg),Ae&&ze.style.setProperty("--shiki-dark-addition-color",Ae),Pe&&ze.style.setProperty("--shiki-dark-deletion-color",Pe),Te&&ze.style.setProperty("--shiki-dark-modified-color",Te),ze.style.setProperty("--diffs-bg",ne.bg),ze.style.setProperty("--diffs-fg",ne.fg),Fe&&ze.style.setProperty("--diffs-addition-color-override",Fe),Be&&ze.style.setProperty("--diffs-deletion-color-override",Be),We&&ze.style.setProperty("--diffs-modified-color-override",We))},[je,R,m,be]);const ye=ve.useMemo(()=>({theme:{dark:u.metadata.id,light:p.metadata.id},themeType:m?"dark":"light",diffStyle:i?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:Y?0:1e3,maxLineLengthForHighlighting:Y?1:1e3,tokenizeMaxLineLength:Y?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:o?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:c,enableHoverUtility:!1,onLineSelected:c?O:void 0,unsafeCSS:Jy,renderAnnotation:c?B:void 0}),[u.metadata.id,c,m,Y,p.metadata.id,i,o,O,B]),se=ve.useMemo(()=>c?Hy({drafts:g,editingDraftId:E,selection:h}):[],[E,c,g,h]),ie=ve.useRef(se);if(ve.useEffect(()=>{ie.current=se},[se]),ve.useEffect(()=>{const V=W.current;return()=>{X.current?.cleanUp(),X.current=null,re.current?.release(),re.current=null,Z.current=null,de.current=null,le.current=void 0,ee.current=void 0,xe.current=void 0,we.current=void 0,V&&(V.innerHTML="")}},[]),ve.useEffect(()=>{if(typeof window>"u")return;const V=W.current,te=F.current;if(!V||!Ie)return;const ne=tv(te,V);let ue=re.current;ue||(ue=rv(V),re.current=ue),re.current=ue;const Me=ue?.virtualizer??null,ke=n?void 0:{name:r||"",contents:s,lang:a,cacheKey:`old:${R}:${r}:${rl(s)}`},Re=n?void 0:{name:r||"",contents:e,lang:a,cacheKey:`new:${R}:${r}:${rl(e)}`},Ae=n?ee.current!==n:ee.current!==void 0||!ke||!Re||!xe.current||!we.current||!ai(xe.current,ke)||!ai(we.current,Re),Pe=X.current,Te=!!(Pe&&(Z.current!==Me||de.current!==Ie||Me&&(le.current!==ye.hunkSeparators||Ae)));Te&&(Pe?.cleanUp(),X.current=null,V.innerHTML="");let Fe=X.current;const Be=!Te&&Pe?!rd(Pe.options,ye):!1;if(Fe?Fe.setOptions(ye):(Fe=ue?new id(ye,ue.virtualizer,nv,Ie):new od(ye,Ie),X.current=Fe,j.current=null),Z.current=Me,de.current=Ie,le.current=Me?ye.hunkSeparators:void 0,ee.current=n,xe.current=ke,we.current=Re,n)Fe.render({fileDiff:n,forceRender:Be,lineAnnotations:ie.current,containerWrapper:V});else{if(!ke||!Re)return;Fe.render({oldFile:ke,newFile:Re,forceRender:Be,lineAnnotations:ie.current,containerWrapper:V})}const We=sv(V,()=>{ne(),iv(Fe,ue,he)});return()=>{We(),ne()}},[R,n,r,a,e,ye,s,Ie]),ve.useEffect(()=>{const V=X.current;if(V){try{V.setLineAnnotations(se)}catch(te){console.error("Failed to apply diff line annotations",te);try{V.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(X.current===V){try{V.rerender()}catch{}he()}})}},[se]),ve.useEffect(()=>{const V=X.current;if(!V||h!==null)return;const te=j.current;if(!Xy(h,te))try{v.current=!0,V.setSelectedLines(h),j.current=h}catch{}finally{v.current=!1}},[h]),ve.useEffect(()=>{if(!c)return;const V=W.current;if(!V)return;let te=null,ne=()=>{};const ue=()=>{const ke=V.querySelector("diffs-container")?.shadowRoot;if(!ke){te=requestAnimationFrame(ue);return}const Re=Ae=>{if(!(Ae instanceof MouseEvent)||Ae.button!==0||!(Ae.target instanceof Element))return;const Pe=Ae.target.closest("[data-column-number]");if(!(Pe instanceof HTMLElement))return;const Te=Pe.getAttribute("data-column-number"),Fe=Te?parseInt(Te,10):NaN;if(Number.isNaN(Fe))return;const Be=q(Pe);O({start:Fe,end:Fe,side:Be}),Ae.preventDefault(),Ae.stopPropagation()};ke.addEventListener("click",Re,!0),ne=()=>{ke.removeEventListener("click",Re,!0)}};return ue(),()=>{te!==null&&cancelAnimationFrame(te),ne()}},[R,c,r,O,q]),ve.useEffect(()=>{const V=W.current;if(!V)return;let te=null,ne=null;const Me=setTimeout(()=>{const ke=V.querySelector("diffs-container");if(!(ke instanceof HTMLElement))return;const Re=ke.shadowRoot;te=new MutationObserver(()=>{ne&&cancelAnimationFrame(ne),ne=requestAnimationFrame(()=>{he(),ne=null})}),te.observe(ke,{childList:!0,subtree:!0}),Re&&te.observe(Re,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(Me),ne&&cancelAnimationFrame(ne),te?.disconnect()}},[R,r]),typeof window>"u")return null;const ge=c?t.jsx(qy,{diffRootRef:F,drafts:g,selection:h,editingDraftId:E,commentText:k,onTextChange:w,fileLabel:r?.split("/").pop()??"",onSave:U,onCancel:T,onEdit:V=>{Q({start:V.startLine,end:V.endLine,side:V.side==="original"?"deletions":"additions"}),b(V)},onDelete:P}):null;return d==="fill"?t.jsx("div",{className:ce("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:t.jsxs("div",{className:"flex-1 relative min-h-0",children:[t.jsx(Gt,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:t.jsx("div",{ref:F,className:"size-full relative",children:t.jsx("div",{ref:W,className:"size-full"})})}),ge]})}):t.jsxs("div",{className:ce("relative","w-full"),children:[t.jsx("div",{ref:F,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative",children:t.jsx("div",{ref:W,className:"w-full"})}),ge]})},ov=()=>{const s=rt.c(13),[e,n]=ve.useState(!1);let a,r;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(ds())},r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),ve.useEffect(a,r);let i;s[2]!==e?(i=async u=>e?await Qm(u):{success:!0,path:u},s[2]=e,s[3]=i):i=s[3];const o=i;let d;s[4]!==e?(d=async u=>e?await Ym():{success:!0},s[4]=e,s[5]=d):d=s[5];const c=d;let x;s[6]!==e?(x=async u=>e?await Xm():{success:!0},s[6]=e,s[7]=x):x=s[7];const m=x;let p;return s[8]!==e||s[9]!==o||s[10]!==c||s[11]!==m?(p={isDesktop:e,requestAccess:o,startAccessing:c,stopAccessing:m},s[8]=e,s[9]=o,s[10]=c,s[11]=m,s[12]=p):p=s[12],p},lv=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),cv=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:a,onCheckout:r,onCreate:i,remotes:o=[],disabled:d=!1})=>{const{t:c}=dt(),[x,m]=l.useState(!1),[p,u]=l.useState(""),[C,f]=l.useState(!1),[g,h]=l.useState(!1),[D,k]=l.useState(""),[w,E]=l.useState(!1),N=l.useRef(null),y=l.useCallback(U=>{U.stopPropagation()},[]),b=o.length>1,P=l.useMemo(()=>lv(D),[D]),z=l.useMemo(()=>{const U=p.toLowerCase();return U?e.filter(Q=>Q.toLowerCase().includes(U)):e},[p,e]),M=l.useMemo(()=>{const U=p.toLowerCase();return U?n.filter(Q=>Q.toLowerCase().includes(U)):n},[p,n]),I=U=>{if(U===s){m(!1);return}r(U),m(!1),u("")},v=()=>{f(!0),setTimeout(()=>N.current?.focus(),50)},j=async()=>{if(!(!P||w)){if(b){h(!0);return}E(!0);try{await i(P,o[0]),k(""),f(!1),m(!1)}finally{E(!1)}}},O=async U=>{if(!(!P||w)){E(!0);try{await i(P,U),k(""),f(!1),h(!1),m(!1)}finally{E(!1)}}},T=()=>{h(!1)},B=()=>{k(""),f(!1),h(!1)};return l.useEffect(()=>{x||(u(""),f(!1),h(!1),k(""))},[x]),t.jsxs(gs,{open:x,onOpenChange:m,children:[t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(us,{asChild:!0,children:t.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:d,children:[t.jsx(A,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||c("gitView.branch.detachedHead")}),t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(Dt,{sideOffset:8,children:c("gitView.branch.currentBranchTooltip")})]}),t.jsx(ps,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(kr,{className:"h-full min-h-0",children:[t.jsx(Sr,{placeholder:c("gitView.branch.searchPlaceholder"),value:p,onValueChange:u,onKeyDown:y}),t.jsxs(Cr,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Pr,{children:c("gitView.branch.empty")}),t.jsx(Us,{children:g?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:T,disabled:w,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(A,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[c("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:P})," ",c("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:o.map(U=>t.jsxs("button",{type:"button",onClick:()=>O(U),disabled:w,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[w?t.jsx(A,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,U.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:U.pushUrl})]},U.name))})]}):C?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:N,placeholder:c("gitView.branch.newBranchPlaceholder"),value:D,onChange:U=>k(U.target.value),onClick:U=>U.stopPropagation(),onKeyDown:U=>{y(U),U.key==="Enter"?(U.preventDefault(),j()):U.key==="Escape"&&(U.preventDefault(),B())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:j,disabled:!P||w,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:w?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:B,disabled:w,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(A,{name:"close",className:"size-4"})})]}):t.jsxs(Rs,{onSelect:v,children:[t.jsx(A,{name:"add",className:"size-4"}),t.jsx("span",{children:c("gitView.branch.create")})]})}),t.jsx(Pn,{}),t.jsxs(Us,{heading:c("gitView.branch.localBranches"),children:[z.map(U=>t.jsxs(Rs,{onSelect:()=>I(U),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:U}),(a?.[U]?.ahead||a?.[U]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[a[U].ahead||0," ahead ·"," ",a[U].behind||0," behind"]})]}),s===U&&t.jsx("span",{className:"typography-micro text-primary",children:c("gitView.branch.currentBadge")})]},`local-${U}`)),z.length===0&&t.jsx(Rs,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noLocalBranches")})})]}),t.jsx(Pn,{}),t.jsxs(Us,{heading:c("gitView.branch.remoteBranches"),children:[M.map(U=>t.jsx(Rs,{onSelect:()=>I(U),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:U})},`remote-${U}`)),M.length===0&&t.jsx(Rs,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noRemoteBranches")})})]})]})]})})]})},dv=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),mv=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:a}=dt(),[r,i]=l.useState(!1),[o,d]=l.useState(s||""),[c,x]=l.useState(!1),m=l.useRef(null),p=()=>{!s||!e||(d(s),i(!0),setTimeout(()=>m.current?.focus(),0))},u=async()=>{if(!s||!e||!o.trim())return;const g=dv(o);if(g===s){i(!1);return}x(!0);try{await e(s,g),i(!1),d("")}finally{x(!1)}},C=()=>{i(!1),d("")},f=g=>{g.key==="Enter"?(g.preventDefault(),u()):g.key==="Escape"&&(g.preventDefault(),C())};return r?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:g=>{g.preventDefault(),u()},children:[t.jsx(A,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:m,value:o,onChange:g=>d(g.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:a("gitView.branch.namePlaceholder"),onKeyDown:f,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:c,"aria-label":a(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:a(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:C,disabled:c,"aria-label":a("gitView.branch.renameCancel"),title:a("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(A,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(A,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||a("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:p,title:a("gitView.branch.renameTitle"),children:t.jsx(A,{name:"edit",className:"size-4"})})]})]})},uv={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3"},pv={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function cc(s){return s&&pv[s]||"var(--primary)"}const il=s=>{const e=rt.c(8),{icon:n,className:a,colorToken:r}=s,i=uv[n??"branch"]??"user-3";let o;e[0]!==r?(o=cc(r),e[0]=r,e[1]=o):o=e[1];let d;e[2]!==o?(d={color:o},e[2]=o,e[3]=d):d=e[3];let c;return e[4]!==a||e[5]!==i||e[6]!==d?(c=t.jsx(A,{name:i,className:a,style:d}),e[4]=a,e[5]=i,e[6]=d,e[7]=c):c=e[7],c},dc=s=>{const e=rt.c(35),{activeProfile:n,identities:a,onSelect:r,isApplying:i,iconOnly:o}=s,d=o===void 0?!1:o,{t:c}=dt(),x=i||a.length===0,m=n?.color;let p;e[0]!==m?(p=cc(m),e[0]=m,e[1]=p):p=e[1];let u;e[2]!==p?(u={color:p},e[2]=p,e[3]=u):u=e[3];let C;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==i?(C=i?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(il,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=i,e[7]=C):C=e[7];let f;e[8]!==n?.name||e[9]!==d||e[10]!==c?(f=!d&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||c("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=d,e[10]=c,e[11]=f):f=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=g):g=e[12];let h;e[13]!==x||e[14]!==u||e[15]!==C||e[16]!==f?(h=t.jsx(It,{asChild:!0,children:t.jsx(us,{asChild:!0,children:t.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:u,disabled:x,children:[C,f,g]})})}),e[13]=x,e[14]=u,e[15]=C,e[16]=f,e[17]=h):h=e[17];let D;e[18]!==c?(D=c("gitView.header.identityTooltip"),e[18]=c,e[19]=D):D=e[19];let k;e[20]!==D?(k=t.jsx(Dt,{sideOffset:8,children:D}),e[20]=D,e[21]=k):k=e[21];let w;e[22]!==k||e[23]!==h?(w=t.jsxs(Pt,{children:[h,k]}),e[22]=k,e[23]=h,e[24]=w):w=e[24];let E;e[25]!==n?.id||e[26]!==a||e[27]!==r||e[28]!==c?(E=a.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:c("gitView.header.noProfiles")})}):a.map(b=>{const P=n?.id===b.id;return t.jsx(vs,{onSelect:()=>r(b),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(il,{icon:b.icon,colorToken:b.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:b.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:b.userEmail})]}),P?t.jsx(A,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},b.id)}),e[25]=n?.id,e[26]=a,e[27]=r,e[28]=c,e[29]=E):E=e[29];let N;e[30]!==E?(N=t.jsx(ps,{align:"end",className:"w-64",children:E}),e[30]=E,e[31]=N):N=e[31];let y;return e[32]!==w||e[33]!==N?(y=t.jsxs(gs,{children:[w,N]}),e[32]=w,e[33]=N,e[34]=y):y=e[34],y},gv=s=>{const e=rt.c(21),{comparison:n,trackingBranch:a,tooltipDelayMs:r}=s,i=r===void 0?1e3:r,{t:o}=dt(),d=`${n.remote}/${n.branch}`,c=n.ahead===0&&n.behind===0;let x;e[0]!==o||e[1]!==d||e[2]!==a?(x=a?o("gitView.header.upstreamTooltipTracking",{target:d,tracking:a}):o("gitView.header.upstreamTooltip",{target:d}),e[0]=o,e[1]=d,e[2]=a,e[3]=x):x=e[3];const m=x;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(A,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=p):p=e[4];let u;e[5]!==d?(u=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:d}),e[5]=d,e[6]=u):u=e[6];let C;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==c||e[10]!==o?(C=c?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:o("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=c,e[10]=o,e[11]=C):C=e[11];let f;e[12]!==u||e[13]!==C?(f=t.jsx(It,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[p,u,C]})}),e[12]=u,e[13]=C,e[14]=f):f=e[14];let g;e[15]!==m?(g=t.jsx(Dt,{sideOffset:8,children:m}),e[15]=m,e[16]=g):g=e[16];let h;return e[17]!==f||e[18]!==g||e[19]!==i?(h=t.jsxs(Pt,{delayDuration:i,children:[f,g]}),e[17]=f,e[18]=g,e[19]=i,e[20]=h):h=e[20],h},Wv=s=>{const e=rt.c(54),{status:n,localBranches:a,remoteBranches:r,branchInfo:i,syncAction:o,remotes:d,onFetch:c,onSync:x,onRemoveRemote:m,removingRemoteName:p,onCheckoutBranch:u,onCreateBranch:C,onRenameBranch:f,activeIdentityProfile:g,availableIdentities:h,onSelectIdentity:D,isApplyingIdentity:k,isWorktreeMode:w,onOpenHistory:E,onOpenGraph:N,onOpenStashes:y,actionTabItems:b,activeActionTab:P,onSelectActionTab:z}=s,{t:M}=dt();if(!n)return null;let I;e[0]!==N||e[1]!==E||e[2]!==y||e[3]!==M?(I=E||N||y?t.jsxs(gs,{children:[t.jsxs(Pt,{children:[t.jsx(It,{asChild:!0,children:t.jsx(us,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":M("gitView.header.repositoryViews"),children:t.jsx(A,{name:"git-repository",className:"size-4"})})})}),t.jsx(Dt,{sideOffset:8,children:M("gitView.header.repositoryViews")})]}),t.jsxs(ps,{align:"end",children:[E?t.jsxs(vs,{onSelect:E,children:[t.jsx(A,{name:"history",className:"size-4"}),M("gitView.history.title")]}):null,N?t.jsxs(vs,{onSelect:N,children:[t.jsx(A,{name:"git-merge",className:"size-4"}),M("gitView.graph.title")]}):null,y?t.jsxs(vs,{onSelect:y,children:[t.jsx(A,{name:"archive-stack",className:"size-4"}),M("gitView.stashes.title")]}):null]})]}):null,e[0]=N,e[1]=E,e[2]=y,e[3]=M,e[4]=I):I=e[4];let v;e[5]!==I?(v=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:I}),e[5]=I,e[6]=v):v=e[6];const j=v,O=!n;let T;e[7]!==n.tracking?(T=n.tracking?.split("/")[0],e[7]=n.tracking,e[8]=T):T=e[8];const B=(n.files?.length??0)>0;let U;e[9]!==c||e[10]!==m||e[11]!==x||e[12]!==d||e[13]!==p||e[14]!==n.ahead||e[15]!==n.behind||e[16]!==o||e[17]!==O||e[18]!==T||e[19]!==B?(U=t.jsx(Iy,{syncAction:o,remotes:d,onFetch:c,onSync:x,onRemoveRemote:m,removingRemoteName:p,disabled:O,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:T,hasUncommittedChanges:B}),e[9]=c,e[10]=m,e[11]=x,e[12]=d,e[13]=p,e[14]=n.ahead,e[15]=n.behind,e[16]=o,e[17]=O,e[18]=T,e[19]=B,e[20]=U):U=e[20];const Q=U;let q;e[21]!==n.tracking||e[22]!==n.upstreamComparison?(q=n.upstreamComparison?t.jsx(gv,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[21]=n.tracking,e[22]=n.upstreamComparison,e[23]=q):q=e[23];const R=q;let Y;e[24]!==g||e[25]!==h||e[26]!==k||e[27]!==D?(Y=t.jsx(dc,{activeProfile:g,identities:h,onSelect:D,isApplying:k,iconOnly:!0}),e[24]=g,e[25]=h,e[26]=k,e[27]=D,e[28]=Y):Y=e[28];const F=Y;let W;e[29]!==i||e[30]!==w||e[31]!==a||e[32]!==u||e[33]!==C||e[34]!==f||e[35]!==r||e[36]!==d||e[37]!==n.current?(W=t.jsx("div",{className:"min-w-0 flex-1",children:w?t.jsx(mv,{currentBranch:n.current,onRename:f}):t.jsx(cv,{currentBranch:n.current,localBranches:a,remoteBranches:r,branchInfo:i,onCheckout:u,onCreate:C,remotes:d})}),e[29]=i,e[30]=w,e[31]=a,e[32]=u,e[33]=C,e[34]=f,e[35]=r,e[36]=d,e[37]=n.current,e[38]=W):W=e[38];let X;e[39]!==F||e[40]!==j?(X=t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[j,F]}),e[39]=F,e[40]=j,e[41]=X):X=e[41];let re;e[42]!==X||e[43]!==W?(re=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[W,X]}),e[42]=X,e[43]=W,e[44]=re):re=e[44];let Z;e[45]!==b||e[46]!==P||e[47]!==z||e[48]!==Q||e[49]!==R?(Z=b&&P&&z?t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(fn,{items:b,activeId:P,onSelect:z,layoutMode:"fit",variant:"active-pill",iconOnlyActiveTab:!0,activePillButtonClassName:"h-7",className:"h-full"})}),R?t.jsx("div",{className:"min-w-0 shrink",children:R}):null,t.jsx("div",{className:"shrink-0",children:Q})]}):null,e[45]=b,e[46]=P,e[47]=z,e[48]=Q,e[49]=R,e[50]=Z):Z=e[50];let de;return e[51]!==re||e[52]!==Z?(de=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[re,Z]}),e[51]=re,e[52]=Z,e[53]=de):de=e[53],de},hv=s=>s==="/",La=s=>s.replace(/\\/g,"/"),Yr=s=>{if(!s||hv(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Mn=s=>s.endsWith("/"),fv=s=>{const e=s.trim();return!e||Mn(e)?e:`${e}/`},Xr=s=>s.lastIndexOf("/"),mc=s=>{if(Mn(s))return s;const e=Xr(s);return e<0?s:s.slice(0,e+1)},xv=s=>{const e=Xr(s);return s.slice(e+1)},uc=s=>{const e=Yr(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Xr(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},bv=s=>Mn(s)&&uc(s)!==null,yv=(s,e)=>`${mc(s)}${e}/`,ln=s=>{if(!s)return null;const e=Yr(La(s.trim()));return e?e.toLowerCase():null},ol=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},vv=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,jr=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},jv=async()=>{try{const s=await yt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return La(e.home.trim())}}catch{}return ws.getFilesystemHome().catch(()=>null)},qv=({open:s,onOpenChange:e})=>{const{t:n}=dt(),a=ys($=>$.homeDirectory),r=is($=>$.projects),i=is($=>$.addProject),o=ks($=>$.profiles),d=ks($=>$.globalIdentity),c=ks($=>$.defaultGitIdentityId),x=ks($=>$.loadProfiles),m=ks($=>$.loadGlobalIdentity),p=ks($=>$.loadDefaultGitIdentityId),{isDesktop:u,requestAccess:C,startAccessing:f}=ov(),{isMobile:g}=Cs(),h=l.useRef(null),D=l.useRef(null),k=l.useRef(new Map),[w,E]=l.useState(""),[N,y]=l.useState("~/"),[b,P]=l.useState([]),[z,M]=l.useState(!1),[I,v]=l.useState(!1),[j,O]=l.useState(0),[T,B]=l.useState(!1),[U,Q]=l.useState(!1),[q,R]=l.useState(0),[Y,F]=l.useState(!1),[W,X]=l.useState(""),[re,Z]=l.useState(null),[de,le]=l.useState(!1),ee=w||a,xe=l.useMemo(()=>new Set(r.map($=>ln($.path)).filter($=>!!$)),[r]);l.useEffect(()=>{if(!s)return;y("~/"),P([]),O(0),B(!1),Q(!1),F(!1),X(""),Z(null),le(!1),requestAnimationFrame(()=>jr(h.current));let $=!1;return(async()=>{const L=await jv();$||(E(L||a||""),requestAnimationFrame(()=>jr(h.current)))})(),()=>{$=!0}},[a,s]),l.useEffect(()=>{s&&(x(),m(),p())},[p,x,m,s]);const we=l.useMemo(()=>{const $=new Map;d&&$.set(d.id,d);for(const fe of o)$.set(fe.id,fe);return Array.from($.values())},[o,d]);l.useEffect(()=>{if(!s||!Y||re!==null)return;const $=typeof c=="string"?c.trim():"";if($&&we.some(L=>L.id===$)){Z($);return}const fe=we.find(L=>L.authType==="ssh"||L.sshKey);fe&&Z(fe.id)},[we,c,Y,s,re]);const he=l.useMemo(()=>we.find($=>$.id===re)??null,[we,re]),Ie=l.useMemo(()=>mc(N),[N]),be=l.useMemo(()=>Mn(N)?"":xv(N),[N]),je=l.useMemo(()=>ee?ol(Ie,ee):"",[Ie,ee]);l.useEffect(()=>{if(!s||!je){P([]);return}let $=!1;return M(!0),v(!1),ws.listLocalDirectory(je).then(fe=>{if($)return;v(!1);const L=fe.filter(Le=>Le.isDirectory).map(Le=>({name:Le.name,path:La(Le.path)})).sort((Le,Je)=>Le.name.localeCompare(Je.name));P(L)}).catch(()=>{$||(P([]),v(!0))}).finally(()=>{$||M(!1)}),()=>{$=!0}},[je,s]);const ye=l.useMemo(()=>{const $=be.toLowerCase(),fe=de||be.startsWith(".");return b.filter(L=>L.name.toLowerCase().startsWith($)&&(fe||!L.name.startsWith(".")))},[be,b,de]),se=l.useMemo(()=>{const $=[];bv(N)&&$.push({type:"up",value:"browse:up",name:"..",path:uc(N)});for(const fe of ye){const L=ln(fe.path);$.push({type:"directory",value:`browse:${fe.path}`,name:fe.name,path:fe.path,disabled:!!(L&&xe.has(L))})}return $},[xe,ye,N]);l.useEffect(()=>{O(0)},[N,se.length]);const ie=l.useMemo(()=>ee?Yr(ol(N,ee)):"",[ee,N]),ge=ln(ie),V=!!(ge&&xe.has(ge)),te=l.useMemo(()=>be?ye.find($=>$.name===be)??null:null,[be,ye]),ne=!!(ie&&!V&&(Mn(N)&&I||!Mn(N)&&be.trim().length>0&&te===null)),ue=!T&&!U&&!V&&!!ie,Me=ue&&W.trim().length>0,ke=se[j]??null,Re=!!(ke&&(ke.type==="up"||ke.type==="directory"&&!ke.disabled)),Ae=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",Pe=n(V?"directoryExplorerDialog.actions.alreadyAdded":Y?T?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":T?"directoryExplorerDialog.actions.adding":ne?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");l.useLayoutEffect(()=>{const $=D.current;if(!$)return;const fe=()=>R(Math.ceil($.getBoundingClientRect().width));if(fe(),typeof ResizeObserver>"u")return;const L=new ResizeObserver(fe);return L.observe($),()=>L.disconnect()},[Pe]),l.useLayoutEffect(()=>{const $=h.current;$&&($.scrollLeft=$.scrollWidth)},[q,N]),l.useLayoutEffect(()=>{s&&jr(h.current)},[s]),l.useLayoutEffect(()=>{const $=se[j];$&&k.current.get($.value)?.scrollIntoView({block:"nearest"})},[j,se]);const Te=l.useCallback(()=>{e(!1)},[e]),Fe=l.useCallback(($,fe)=>{$.stopPropagation();const L=ln(fe);if(L&&xe.has(L))return;i(fe)||_.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")})},[i,xe,n]),Be=l.useCallback(async $=>{if(!$||T)return;const fe=ln($);if(fe&&xe.has(fe))return;let L=$;B(!0);try{const Le=!Y&&ne&&ln($)===ln(ie);if(Y){const Xe=W.trim();if(!Xe){_.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}L=(await ws.cloneRepository({remoteUrl:Xe,destinationPath:$,gitIdentityId:he?.id??null})).path}else Le&&await ws.createDirectory($);if(!i(L)){_.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Te()}catch(Le){_.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Le instanceof Error?Le.message:n("directoryExplorerDialog.toast.unknownError")})}finally{B(!1)}},[i,xe,W,Te,Y,T,he?.id,ne,ie,n]),We=l.useCallback($=>{y(fv($))},[]),ze=l.useCallback($=>{y(yv(N,$.name))},[N]),Qe=l.useCallback($=>{if($){if($.type==="up"){$.path&&We($.path);return}$.disabled||ze($)}},[We,ze]),oe=l.useCallback(async()=>{if(!(!u||U)){Q(!0);try{const $=await C(ie);if(!$.success||!$.path){$.error&&$.error!=="Directory selection cancelled"&&_.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:$.error});return}const fe=await f($.path);if(!fe.success){_.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:fe.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await Be($.path)}catch($){_.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:$ instanceof Error?$.message:n("directoryExplorerDialog.toast.unknownError")})}finally{Q(!1)}}},[Be,u,U,C,f,n,ie]),H=l.useCallback($=>{if($.key==="ArrowDown"){$.preventDefault(),O(fe=>Math.min(se.length-1,fe+1));return}if($.key==="ArrowUp"){$.preventDefault(),O(fe=>Math.max(0,fe-1));return}if($.key==="Enter"){if($.preventDefault(),vv($)){Be(ie);return}Re&&Qe(ke);return}$.key==="Backspace"&&N===""&&($.preventDefault(),Te())},[Qe,Be,Te,Re,ke,N,se.length,ie]),me=t.jsxs("button",{type:"button",onClick:()=>le($=>!$),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[de?t.jsx(A,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(A,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),Ne=t.jsxs("div",{className:"px-2.5 py-1.5",children:[Y?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(ot,{value:W,onChange:$=>X($.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(dc,{activeProfile:he,identities:we,onSelect:$=>Z($.id),isApplying:T,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(A,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(ot,{ref:h,value:N,onChange:$=>y(La($.target.value)),onKeyDown:H,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!g&&q>0?{paddingRight:`${q+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),g?null:t.jsx(J,{ref:D,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:Y?!Me:!ue,onMouseDown:$=>$.preventDefault(),onClick:()=>{Be(ie)},title:Pe,children:Pe})]})]}),Ee=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),z?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):se.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:se.map(($,fe)=>{const L=fe===j;return t.jsxs("button",{ref:Le=>{Le?k.current.set($.value,Le):k.current.delete($.value)},type:"button",disabled:$.type==="directory"&&$.disabled,onMouseEnter:()=>O(fe),onMouseDown:Le=>Le.preventDefault(),onClick:()=>Qe($),className:ce("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",L&&"bg-interactive-selection text-interactive-selection-foreground",!L&&"hover:bg-interactive-hover/50",$.type==="directory"&&$.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[$.type==="up"?t.jsx(A,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(A,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:$.name})}),$.type==="directory"&&$.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):$.type==="directory"?t.jsx("button",{type:"button",onMouseDown:Le=>Le.stopPropagation(),onClick:Le=>Fe(Le,$.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(A,{name:"add",className:"h-3.5 w-3.5"})}):null]},$.value)})})]})}),Ce=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[Ne,Ee]}),_e=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(A,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(A,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(A,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:Ae}),t.jsx(A,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),G=()=>t.jsxs(t.Fragment,{children:[g?null:_e,t.jsxs("div",{className:ce("flex w-full flex-row justify-end gap-2 sm:w-auto",g&&"justify-stretch"),children:[u?t.jsx(J,{variant:"ghost",size:"xs",onClick:oe,disabled:T||U||Y,children:n(U?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(J,{variant:"ghost",size:"xs",onClick:()=>F($=>!$),disabled:T||U,className:ce(g&&"flex-1"),children:n(Y?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),g?t.jsx(J,{size:"xs",onClick:()=>{Be(ie)},disabled:Y?!Me:!ue,className:"flex-1",children:Pe}):null]})]});return g?t.jsx(Qn,{open:s,onClose:Te,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px] max-w-full",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:G()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:me}),Ce]})}):t.jsx($t,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(_t,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Ut,{children:n("directoryExplorerDialog.title")}),t.jsx(Wt,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),me]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:Ce}),t.jsx(Yt,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:G()})]})})};function ll(s){const{localBranches:e,remoteBranches:n,query:a}=s,r=a.trim();if(!r)return{matching:[],otherLocal:e,otherRemote:n};const i=yi(e,r,m=>m),o=yi(n,r,m=>m),d=[],c=i.other,x=o.other;for(const m of i.matching)d.push({label:m,value:m,source:"local"});for(const m of o.matching)d.push({label:m,value:`remotes/${m}`,source:"remote"});return d.sort((m,p)=>{const u=m.label.localeCompare(p.label,void 0,{sensitivity:"accent"});return u!==0?u:m.source!==p.source?m.source.localeCompare(p.source):m.value.localeCompare(p.value)}),{matching:d,otherLocal:c,otherRemote:x}}function wv({open:s,onOpenChange:e,onSelect:n}){const{t:a}=dt(),r=Ke(se=>se.isMobile),{github:i}=Wr(),o=_s(se=>se.status),d=_s(se=>se.hasChecked),c=Ke(se=>se.setSettingsDialogOpen),x=Ke(se=>se.setSettingsPage),m=is(se=>se.getActiveProject()),p=m?.path??null,u=ve.useMemo(()=>p&&m?{id:m.id,path:p}:null,[m,p]),[C,f]=ve.useState("issues"),[g,h]=ve.useState(""),[D,k]=ve.useState([]),[w,E]=ve.useState([]),[N,y]=ve.useState(!1),[b,P]=ve.useState(!1),[z,M]=ve.useState(null),[I,v]=ve.useState(null),[j,O]=ve.useState(null),[T,B]=ve.useState(!1),[U,Q]=ve.useState(new Map),[q,R]=ve.useState(1),[Y,F]=ve.useState(!1),W=Cm(g,350),X=ve.useCallback(async se=>{if(!(!p||!i)&&!(d&&o?.connected===!1)){y(!0),M(null),R(1),F(!1);try{if(C==="issues"&&i.issuesList){const ie=await i.issuesList(p,{page:1,query:se});ie.connected===!1?(M(a("session.githubIntegration.error.notConnected")),k([])):(k(ie.issues??[]),R(ie.page??1),F(!!ie.hasMore))}else if(C==="prs"&&i.prsList){const ie=await i.prsList(p,{page:1,query:se});ie.connected===!1?(M(a("session.githubIntegration.error.notConnected")),E([])):(E(ie.prs??[]),R(ie.page??1),F(!!ie.hasMore))}}catch(ie){M(ie instanceof Error?ie.message:a("session.githubIntegration.error.loadDataFailed"))}finally{y(!1)}}},[p,i,d,o,C,a]);ve.useEffect(()=>{if(!s||!p||d&&o?.connected===!1||!i)return;if(!W.trim()){X();return}const se=new AbortController;y(!0),M(null),R(1),F(!1);const ie=C==="issues"&&i.issuesList?i.issuesList(p,{page:1,query:W.trim()}):C==="prs"&&i.prsList?i.prsList(p,{page:1,query:W.trim()}):null;if(!ie){y(!1);return}return ie.then(ge=>{se.signal.aborted||("issues"in ge?ge.connected===!1?(M(a("session.githubIntegration.error.notConnected")),k([])):(k(ge.issues??[]),R(ge.page??1),F(!!ge.hasMore)):"prs"in ge&&(ge.connected===!1?(M(a("session.githubIntegration.error.notConnected")),E([])):(E(ge.prs??[]),R(ge.page??1),F(!!ge.hasMore))))}).catch(ge=>{se.signal.aborted||M(ge instanceof Error?ge.message:a("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{se.signal.aborted||y(!1)}),()=>se.abort()},[s,p,i,d,o,C,W,X,a]);const re=ve.useCallback(async()=>{if(!(!p||!i)&&!(N||b)&&Y){P(!0);try{const se=q+1;if(C==="issues"&&i.issuesList){const ie=W.trim()?await i.issuesList(p,{page:se,query:W.trim()}):await i.issuesList(p,{page:se});ie.connected!==!1&&(k(ge=>[...ge,...ie.issues??[]]),R(ie.page??se),F(!!ie.hasMore))}else if(C==="prs"&&i.prsList){const ie=W.trim()?await i.prsList(p,{page:se,query:W.trim()}):await i.prsList(p,{page:se});ie.connected!==!1&&(E(ge=>[...ge,...ie.prs??[]]),R(ie.page??se),F(!!ie.hasMore))}}catch{}finally{P(!1)}}},[p,i,C,q,Y,N,b,W]);ve.useEffect(()=>{if(!s){f("issues"),h(""),k([]),E([]),v(null),O(null),B(!1),M(null),Q(new Map),R(1),F(!1);return}X()},[s,X]);const Z=ve.useCallback(async se=>{if(!(!u||!se)&&!U.has(se))try{const ge=(await Sl(u,{mode:"new",branchName:se,worktreeName:se})).errors.find(V=>V.code==="branch_in_use");Q(V=>new Map(V).set(se,{isValid:!ge,error:ge?a(ge.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{Q(ie=>new Map(ie).set(se,{isValid:!1,error:a("session.githubIntegration.validation.failed")}))}},[u,U,a]);ve.useEffect(()=>{!s||C!=="prs"||w.forEach(se=>{se.head&&Z(se.head)})},[s,C,w,Z]);const de=d&&o?.connected===!0,le=()=>{x("github"),c(!0)},ee=se=>{v(se),O(null)},xe=se=>{O(se),v(null)},we=()=>{I?n({type:"issue",item:I}):j&&n({type:"pr",item:j,includeDiff:T}),e(!1)},he=()=>{v(null),O(null),B(!1)},Ie=I||j&&U.get(j.head??"")?.isValid!==!1,be=se=>se.head?U.get(se.head)?.isValid===!1:!0,je=t.jsx(t.Fragment,{children:de?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(A,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(ot,{value:g,onChange:se=>h(se.target.value),placeholder:a(C==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs("div",{className:"h-full overflow-y-auto",children:[N&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(A,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),z&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(A,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:z})]})}),!N&&!z&&C==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[D.length>0?D.map(se=>t.jsx("button",{onClick:()=>ee(se),className:ce("w-full text-left px-2 py-1.5 rounded transition-colors",I?.number===se.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",se.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:se.title}),se.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[se.sourceRepo.owner,"/",se.sourceRepo.repo]}):null]})]})},`${se.sourceRepo?.owner??""}-${se.sourceRepo?.repo??""}-${se.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:a("session.githubIntegration.empty.noIssuesFound")}),Y&&!b&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{re()},className:"h-7 text-xs",children:a("session.githubIntegration.actions.loadMore")})}),b&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(A,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!N&&!z&&C==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[w.length>0?w.map(se=>{const ie=be(se),ge=se.head?U.get(se.head):void 0;return t.jsx("button",{onClick:()=>!ie&&xe(se),disabled:ie,className:ce("w-full text-left px-2 py-1.5 rounded transition-colors",j?.number===se.number?"bg-interactive-selection text-interactive-selection-foreground":ie?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",se.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:se.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[se.head," → ",se.base]}),se.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[se.sourceRepo.owner,"/",se.sourceRepo.repo]}):null,ie&&ge?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:ge.error})]})]})]})},`${se.sourceRepo?.owner??""}-${se.sourceRepo?.repo??""}-${se.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:a("session.githubIntegration.empty.noPullRequestsFound")}),Y&&!b&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{re()},className:"h-7 text-xs",children:a("session.githubIntegration.actions.loadMore")})}),b&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(A,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(A,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:a("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:a("session.githubIntegration.connect.description")})]}),t.jsx(J,{onClick:le,size:"sm",children:a("session.githubIntegration.connect.action")})]})}),ye=t.jsxs("div",{className:ce("w-full",r?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:ce("flex items-center gap-4",r?"w-full justify-center order-1":"flex-1"),children:[!r&&(I||j)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(A,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:I?a("session.githubIntegration.selected.issueNumber",{number:I.number}):a("session.githubIntegration.selected.prNumber",{number:j?.number??""})}),t.jsx("button",{onClick:he,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]}),C==="prs"&&j&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(St,{checked:T,onChange:se=>B(se),ariaLabel:a("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:a("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:ce("flex gap-2",r?"w-full order-2":"justify-end"),children:[t.jsx(J,{variant:"outline",size:"sm",onClick:()=>e(!1),className:ce(r&&"flex-1"),children:a("session.githubIntegration.actions.cancel")}),t.jsx(J,{size:"sm",onClick:we,disabled:!Ie,className:ce(r&&"flex-1"),children:a("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:r?t.jsx(Qn,{open:s,title:a("session.githubIntegration.title"),onClose:()=>e(!1),footer:de?ye:void 0,renderHeader:se=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:a("session.githubIntegration.title")}),se]}),t.jsx("div",{className:"w-full",children:t.jsx(fn,{items:[{id:"issues",label:a("session.githubIntegration.tabs.issues"),icon:t.jsx(A,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:a("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(A,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:C,onSelect:ie=>{f(ie),h("")},variant:"active-pill",layoutMode:"fit"})}),(I||j)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(A,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:I?a("session.githubIntegration.selected.issueNumber",{number:I.number}):a("session.githubIntegration.selected.prNumber",{number:j?.number??""})}),t.jsx("button",{onClick:he,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:je}):t.jsx($t,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(_t,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ut,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(A,{name:"github",className:"h-5 w-5"}),a("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(fn,{items:[{id:"issues",label:a("session.githubIntegration.tabs.issues"),icon:t.jsx(A,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:a("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(A,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:C,onSelect:se=>{f(se),h("")},variant:"active-pill",layoutMode:"fit"})})]})}),je,t.jsx(Yt,{className:"mt-1",children:ye})]})})})}const Jn=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),xs=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),cl="oc:lastWorktreeSourceBranch",Nv=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",dl=(s,e,n)=>{const a=Jn(s.head||"");if(!a)throw new Error("PR head branch is missing");if(e.includes(a))return{existingBranch:a,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:a};const r=n.find(x=>{const m=x.indexOf("/");return m<=0||m>=x.length-1?!1:x.slice(m+1)===a});if(r){const x=r.indexOf("/"),m=r.slice(0,x);return{existingBranch:`remotes/${r}`,setUpstream:!0,upstreamRemote:m,upstreamBranch:a,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${m}/${a}`}}const i=String(s.headLabel||"").split(":")[0]?.trim(),o=s.headRepo?.owner||i||"pr-head",d=`pr-${Nv(o)}`,c=s.headRepo?.sshUrl||s.headRepo?.cloneUrl||"";if(!c)throw new Error("PR head repository URL is unavailable");return{existingBranch:`remotes/${d}/${a}`,setUpstream:!0,upstreamRemote:d,upstreamBranch:a,ensureRemoteName:d,ensureRemoteUrl:c,sourceLabel:`${d}/${a}`}},kv=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
166
|
+
${JSON.stringify(e,null,2)}`},Sv=s=>`GitHub pull request context (JSON)
|
|
167
|
+
${JSON.stringify(s,null,2)}`;function Gv({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:a}=dt(),{github:r,git:i}=Wr(),o=Ke(G=>G.isMobile),d=_s(G=>G.status),c=_s(G=>G.hasChecked),x=is(G=>G.getActiveProject()),m=x?.path??null,p=ve.useMemo(()=>m&&x?{id:x.id,path:m}:null,[x,m]),[u,C]=ve.useState("new-branch"),[f,g]=ve.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[h,D]=ve.useState({selectedBranch:"",worktreeName:""}),k=Pm(m),w=Im(m),E=Dm(G=>G.fetchBranches),N=ve.useMemo(()=>k?.all?k.all.filter(G=>!G.startsWith("remotes/")).sort():[],[k]),y=ve.useMemo(()=>k?.all?k.all.filter(G=>G.startsWith("remotes/")).map(G=>G.replace(/^remotes\//,"")).sort():[],[k]),b=Is(G=>G.availableWorktreesByProject),P=ve.useMemo(()=>{if(!m)return new Set;const G=b.get(m)??[];return new Set(G.map($=>$.name))},[b,m]),z=ve.useCallback((G=10)=>{for(let $=0;$<G;$++){const fe=Ya();if(!P.has(fe))return fe}return`${Ya()}-${Date.now().toString(36).slice(-4)}`},[P]),[M,I]=ve.useState(!1),[v,j]=ve.useState(!1),[O,T]=ve.useState(!1),[B,U]=ve.useState(!1),[Q,q]=ve.useState(!1),[R,Y]=ve.useState(""),[F,W]=ve.useState(""),X=ve.useRef(null),re=ve.useRef(null),Z=ve.useRef(null),de=ve.useRef(null),le=ve.useCallback(G=>{G.stopPropagation()},[]),ee=ve.useCallback(G=>{let $=G;for(;$&&$!==document.body;){const{overflowY:fe}=window.getComputedStyle($);if((fe==="auto"||fe==="scroll")&&$.scrollHeight>$.clientHeight)return $;$=$.parentElement}return null},[]),xe=ve.useCallback(G=>{G&&(G.scrollTop=0)},[]),we=ve.useCallback(G=>{const $=G.current?.querySelector('[data-slot="command-list"]')??null;xe($)},[xe]),he=ve.useCallback(G=>{const $=ee(G.current);xe($)},[ee,xe]),Ie=ve.useMemo(()=>ll({localBranches:N,remoteBranches:y,query:R}),[N,y,R]),be=ve.useMemo(()=>ll({localBranches:N,remoteBranches:y,query:F}),[N,y,F]),je=R.trim().length>0,ye=F.trim().length>0,se=Ie.matching.length>0,ie=be.matching.length>0,ge=!!(m&&i),V=ve.useCallback(()=>{!m||!i||E(m,i)},[m,i,E]);ve.useEffect(()=>{!s||!m||!i||k?.all||E(m,i)},[s,m,i,k?.all,E]),ve.useEffect(()=>{!v&&!B&&Y("")},[v,B]),ve.useEffect(()=>{!O&&!Q&&W("")},[O,Q]),ve.useEffect(()=>{v&&we(X),B&&he(Z)},[v,B,R,we,he]),ve.useEffect(()=>{O&&we(re),Q&&he(de)},[O,Q,F,we,he]);const[te,ne]=ve.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[ue,Me]=ve.useState(!1),[ke,Re]=ve.useState(null),Ae=ve.useCallback(()=>{const G=ut.getState(),$=G.getVisibleAgents();if(G.settingsDefaultAgent){const fe=$.find(L=>L.name===G.settingsDefaultAgent);if(fe)return fe.name}return $.find(fe=>fe.name==="build")?.name||$[0]?.name},[]),Pe=ve.useCallback(()=>{const G=ut.getState(),$=G.settingsDefaultModel;if(!$)return null;const fe=un($);if(!fe)return null;const{providerId:L,modelId:Le}=fe;return G.getModelMetadata(L,Le)?{providerID:L,modelID:Le}:null},[]),Te=ve.useCallback((G,$)=>{const fe=ut.getState(),L=fe.settingsDefaultVariant,Le=fe.currentProviderId===G&&fe.currentModelId===$?fe.currentVariant:void 0,et=fe.providers.find(at=>at.id===G)?.models.find(at=>at.id===$)?.variants;if(!et)return L||Le||void 0;if(L&&Object.prototype.hasOwnProperty.call(et,L))return L;if(Le&&Object.prototype.hasOwnProperty.call(et,Le))return Le},[]),Fe=ve.useCallback(async G=>{if(!m||!r)return;const $=ut.getState(),fe=Am.getState().lastUsedProvider,L=Pe(),Le=L?.providerID||$.currentProviderId||fe?.providerID,Je=L?.modelID||$.currentModelId||fe?.modelID,Xe=Ae()||$.currentAgentName||void 0;if(!Le||!Je){_.error(a("session.newWorktree.error.noModelSelected"));return}const et=Te(Le,Je);if(G.issue){if(!r.issueGet||!r.issueComments)return;const at=await r.issueGet(m,G.issue.number);if(at.connected===!1||!at.repo||!at.issue)throw new Error("Failed to load issue context");const ct=await r.issueComments(m,G.issue.number);if(ct.connected===!1)throw new Error("Failed to load issue comments");const Ze=await ia("github.issue.review.visible",{issue_number:String(G.issue.number)}),He=await ia("github.issue.review.instructions"),mt=kv({repo:at.repo,issue:at.issue,comments:ct.comments??[]});await Is.getState().sendMessage(Ze,Le,Je,Xe,void 0,void 0,[{text:He,synthetic:!0},{text:mt,synthetic:!0}],et,void 0,{sessionId:G.sessionId}),_.success(a("session.newWorktree.toast.sessionFromIssue"));return}if(G.pr){if(!r.prContext)return;const at=await r.prContext(m,G.pr.number,{includeDiff:G.includeDiff,includeCheckDetails:!1});if(at.connected===!1||!at.repo||!at.pr)throw new Error("Failed to load PR context");const ct=await ia("github.pr.review.visible",{pr_number:String(G.pr.number)}),Ze=await ia("github.pr.review.instructions"),He=Sv(at);await Is.getState().sendMessage(ct,Le,Je,Xe,void 0,void 0,[{text:Ze,synthetic:!0},{text:He,synthetic:!0}],et,void 0,{sessionId:G.sessionId}),_.success(a("session.newWorktree.toast.sessionFromPr"))}},[r,m,Ae,Pe,Te,a]),Be=u==="new-branch"?f:h;ve.useEffect(()=>{if(!k?.all||!m||f.sourceBranch)return;(async()=>{try{const $=await Em(m).catch(()=>null),fe=localStorage.getItem(cl),L=fe&&k.all?.includes(fe)?fe:$&&k.all?.includes($)?$:k.all?.includes("main")?"main":k.all?.includes("master")?"master":k.all?.[0]||"";L&&g(Le=>({...Le,sourceBranch:L}))}catch{}})()},[k,m,f.sourceBranch]),ve.useEffect(()=>{if(!s)return;C("new-branch"),D({selectedBranch:"",worktreeName:""}),j(!1),T(!1),U(!1),q(!1),Y(""),W(""),ne({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const G=z();g({branchName:G,worktreeName:G,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,z]),ve.useEffect(()=>{if(u!=="new-branch"||!f.isSyncingWorktreeName)return;const G=Jn(f.branchName),$=xs(G);g(fe=>({...fe,worktreeName:$}))},[u,f.branchName,f.isSyncingWorktreeName]);const We=ve.useCallback(async()=>{if(!p||!te.touched||ue)return;ke&&ke.abort();const G=new AbortController;Re(G),ne($=>({...$,isValidating:!0}));try{const $=u==="new-branch"?f.branchName:h.selectedBranch,fe=Be.worktreeName,L=Jn($),Le=xs(fe);let Je=null,Xe=null;if(L||(Je=a("session.newWorktree.error.branchNameRequired")),Le||(Xe=a("session.newWorktree.error.worktreeDirectoryRequired")),L&&Le){const et=u==="new-branch"?f.linkedPr:null,at=et?dl(et,N,y):null,ct=await Sl(p,{mode:u==="existing-branch"||at?"existing":"new",branchName:L,worktreeName:Le,existingBranch:at?.existingBranch??(u==="existing-branch"?L:void 0),...at?.ensureRemoteName?{ensureRemoteName:at.ensureRemoteName}:{},...at?.ensureRemoteUrl?{ensureRemoteUrl:at.ensureRemoteUrl}:{}});if(G.signal.aborted)return;ct.ok||ct.errors.forEach(Ze=>{if(Ze.code==="worktree_exists"){Xe=Xe??Ze.message;return}Ze.code.startsWith("branch_")&&(Je=Je??Ze.message)})}G.signal.aborted||ne(et=>({...et,isValidating:!1,branchError:Je,worktreeError:Xe}))}catch{G.signal.aborted||ne($=>({...$,isValidating:!1}))}},[p,u,f.branchName,f.linkedPr,h.selectedBranch,Be.worktreeName,N,y,te.touched,ke,ue,a]),ze=u==="new-branch"?f.branchName:h.selectedBranch;ve.useEffect(()=>{if(!s||!p||!te.touched||ue)return;const G=setTimeout(()=>{We()},300);return()=>clearTimeout(G)},[Be.worktreeName,ze,s,p,We,te.touched,ue]);const Qe=async()=>{if(!p||!m){_.error(a("session.newWorktree.error.noActiveProject"));return}ne(Le=>({...Le,touched:!0}));const G=u==="new-branch"?f.branchName:h.selectedBranch,$=Be.worktreeName,fe=Jn(G),L=xs($);if(!fe){_.error(a("session.newWorktree.error.branchNameRequired"));return}if(!L){_.error(a("session.newWorktree.error.worktreeDirectoryRequired"));return}ke&&(ke.abort(),Re(null)),ne(Le=>({...Le,isValidating:!1,branchError:null,worktreeError:null})),Me(!0);try{const Le=u==="new-branch"?f.linkedPr:null,Je=u==="new-branch"?f.linkedIssue:null,Xe=u==="new-branch"?f.linkedPr:null,et=u==="new-branch"?f.includePrDiff:!1,at=!!(Je||Xe),ct=await vl(p),Ze=f.sourceBranch;let He="";const mt=(()=>{if(Le){const Ge=dl(Le,N,y);return He=Ge.sourceLabel,{preferredName:fe||L,mode:"existing",branchName:fe,worktreeName:L,existingBranch:Ge.existingBranch,setupCommands:ct,setUpstream:Ge.setUpstream,upstreamRemote:Ge.upstreamRemote,upstreamBranch:Ge.upstreamBranch,returnAfterDirectoryCreated:!0,...Ge.ensureRemoteName?{ensureRemoteName:Ge.ensureRemoteName}:{},...Ge.ensureRemoteUrl?{ensureRemoteUrl:Ge.ensureRemoteUrl}:{}}}return He=u==="new-branch"?Ze:"",{preferredName:fe||L,mode:u==="existing-branch"?"existing":"new",branchName:u==="existing-branch"?void 0:fe,worktreeName:L,existingBranch:u==="existing-branch"?fe:void 0,setupCommands:ct,returnAfterDirectoryCreated:!0,...Ze&&u==="new-branch"?{startRef:Ze}:{}}})(),pe=await Mm(m,mt),nt=await Rm(p,pe);let st=null;if(at){await jl(p)&&await Tm(nt.path);const Ge=Je?`#${Je.number} ${Je.title}`.trim():Xe?`#${Xe.number} ${Xe.title}`.trim():a("session.newWorktree.newSessionTitle"),ht=await Fm(Ge,nt.path,null);if(!ht?.id)throw new Error("Failed to create session");st=ht.id,n?.(nt.path,{sessionId:st}),e(!1),Me(!1),Om(ht.id,Ge).catch(()=>{});try{Is.getState().initializeNewOpenChamberSession(ht.id,ut.getState().agents)}catch{}}else e(!1),Me(!1);f.sourceBranch&&u==="new-branch"&&!f.linkedPr&&localStorage.setItem(cl,f.sourceBranch),_.success(a("session.newWorktree.toast.worktreeCreated"),{description:a("session.newWorktree.toast.worktreeCreatedDescription",{target:`${nt.branch||nt.name}${He?` ${a("session.newWorktree.fromSource",{source:He})}`:""}`})}),st?Fe({sessionId:st,directory:nt.path,issue:Je,pr:Xe,includeDiff:et}).catch(Ge=>{const ht=Ge instanceof Error?Ge.message:a("session.newWorktree.error.sendGitHubContextFailed");_.error(a("session.newWorktree.error.sendGitHubContextFailed"),{description:ht})}):n?.(nt.path)}catch(Le){const Je=Le instanceof Error?Le.message:a("session.newWorktree.error.createWorktreeFailed");_.error(a("session.newWorktree.error.createWorktreeFailed"),{description:Je})}finally{Me(!1)}},oe=G=>{C(G),ne($=>({...$,touched:!1,branchError:null,worktreeError:null}))},H=G=>{if(!G){g($=>({...$,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(G.type==="issue"){const $=G.item,fe=`issue-${$.number}-${Ya()}`;g(L=>({...L,linkedIssue:$,linkedPr:null,includePrDiff:!1,branchName:fe,worktreeName:xs(fe),isSyncingWorktreeName:!0}))}else if(G.type==="pr"){const $=G.item;g(fe=>({...fe,linkedPr:$,linkedIssue:null,includePrDiff:G.includeDiff??!1,branchName:$.head,worktreeName:xs($.head),isSyncingWorktreeName:!0}))}},me=c&&d?.connected===!0,Ee=(u==="existing-branch"?!!h.selectedBranch&&!!h.worktreeName&&!te.branchError&&!te.worktreeError:!!Jn(f.branchName)&&!!f.worktreeName&&!te.branchError&&!te.worktreeError)&&!ue,Ce=()=>{g(G=>({...G,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},_e=t.jsxs("div",{className:ce("flex gap-2",o?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:ce("flex items-center gap-1.5 text-destructive",o?"w-full justify-center order-first":"mr-auto"),children:te.touched&&(te.branchError||te.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:te.branchError||te.worktreeError})]})}),t.jsxs("div",{className:ce("flex gap-2",o&&"w-full"),children:[t.jsx(J,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:ue,className:ce(o&&"flex-1"),children:a("session.newWorktree.actions.cancel")}),t.jsxs(J,{size:"sm",onClick:Qe,disabled:!Ee||ue,className:ce("gap-1.5",o&&"flex-1"),children:[ue&&t.jsx(A,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),a(ue?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[o?t.jsxs(Qn,{open:s,title:a("session.newWorktree.title"),onClose:()=>e(!1),footer:_e,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(fn,{items:[{id:"new-branch",label:a("session.newWorktree.mode.newBranch"),icon:t.jsx(A,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:a("session.newWorktree.mode.existingBranch"),icon:t.jsx(A,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:u,onSelect:G=>oe(G),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[u==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>U(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:h.selectedBranch?"text-foreground":"text-muted-foreground",children:h.selectedBranch||a("session.newWorktree.chooseBranch")}),t.jsx(A,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:V,disabled:!ge||w,title:a("session.newWorktree.fetchBranches"),children:w?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"refresh",className:"size-4"})})]}),t.jsx(Qn,{open:B,title:a("session.newWorktree.selectBranch"),onClose:()=>U(!1),children:t.jsxs("div",{className:"space-y-4",ref:Z,children:[t.jsx(ot,{value:R,onChange:G=>Y(G.target.value),placeholder:a("session.newWorktree.searchBranches"),className:"h-8"}),w?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):N.length===0&&y.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[je&&se&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.matching.map(G=>t.jsx("button",{onClick:()=>{D($=>({...$,selectedBranch:G.value,worktreeName:xs(G.label)})),ne($=>({...$,touched:!0})),U(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",h.selectedBranch===G.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:G.label})},`${G.source}-${G.value}`))})]}),je&&!se&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),Ie.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(je?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.otherLocal.map(G=>t.jsx("button",{onClick:()=>{D($=>({...$,selectedBranch:G,worktreeName:xs(G)})),ne($=>({...$,touched:!0})),U(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",h.selectedBranch===G?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:G})},G))})]}),Ie.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(je?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.otherRemote.map(G=>t.jsx("button",{onClick:()=>{D($=>({...$,selectedBranch:`remotes/${G}`,worktreeName:xs(G)})),ne($=>({...$,touched:!0})),U(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",h.selectedBranch===`remotes/${G}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:G})},`remotes/${G}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.branchName")}),u==="new-branch"&&me&&t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1.5 h-7",children:[t.jsx(A,{name:"github",className:"size-4 text-status-success"}),f.linkedIssue||f.linkedPr?a("session.newWorktree.actions.change"):a("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(ot,{value:f.branchName,onChange:G=>{g($=>({...$,branchName:G.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ne(G=>({...G,touched:!0})),placeholder:a("session.newWorktree.branchNamePlaceholder"),disabled:!!f.linkedPr,className:ce("h-8",te.touched&&te.branchError&&"border-destructive",f.linkedPr&&"bg-muted text-muted-foreground")}),f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(A,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.usingPrBranch",{branch:f.linkedPr.head})})]}),f.linkedIssue&&!f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(A,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.fromIssue",{number:f.linkedIssue.number,title:f.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:a("session.newWorktree.worktreeDirectory")}),u!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const G=xs(u==="new-branch"?f.branchName:"");g($=>({...$,worktreeName:G,isSyncingWorktreeName:!0}))},disabled:!f.branchName||f.worktreeName===xs(f.branchName),className:ce("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",f.worktreeName===xs(f.branchName)||!f.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:a("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(A,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:a("session.newWorktree.actions.reset")})]})]}),t.jsx(ot,{value:Be.worktreeName,onChange:G=>{u==="new-branch"?g($=>({...$,worktreeName:G.target.value,isSyncingWorktreeName:!1})):D($=>({...$,worktreeName:G.target.value}))},onBlur:()=>ne(G=>({...G,touched:!0})),placeholder:a("session.newWorktree.worktreeDirectoryPlaceholder"),className:ce("h-8",te.touched&&te.worktreeError&&"border-destructive")})]}),u==="new-branch"&&!f.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.sourceBranch")}),t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>q(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:f.sourceBranch?"text-foreground":"text-muted-foreground",children:f.sourceBranch||a("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(A,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),f.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("session.newWorktree.newBranchFromSource",{source:f.sourceBranch})}),t.jsx(Qn,{open:Q,title:a("session.newWorktree.selectSourceBranch"),onClose:()=>q(!1),children:t.jsxs("div",{className:"space-y-4",ref:de,children:[t.jsx(ot,{value:F,onChange:G=>W(G.target.value),placeholder:a("session.newWorktree.searchBranches"),className:"h-8"}),w?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):N.length===0&&y.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ye&&ie&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:be.matching.map(G=>t.jsx("button",{onClick:()=>{g($=>({...$,sourceBranch:G.value})),q(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",f.sourceBranch===G.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:G.label})},`${G.source}-${G.value}`))})]}),ye&&!ie&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),be.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(ye?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:be.otherLocal.map(G=>t.jsx("button",{onClick:()=>{g($=>({...$,sourceBranch:G})),q(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",f.sourceBranch===G?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:G})},G))})]}),be.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(ye?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:be.otherRemote.map(G=>t.jsx("button",{onClick:()=>{g($=>({...$,sourceBranch:`remotes/${G}`})),q(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",f.sourceBranch===`remotes/${G}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:G})},`remotes/${G}`))})]})]})]})})]}),(f.linkedIssue||f.linkedPr)&&u==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),f.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.issueNumber",{number:f.linkedIssue.number})}),f.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.prNumber",{number:f.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:f.linkedIssue?.title||f.linkedPr?.title}),t.jsx("a",{href:f.linkedIssue?.url||f.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:G=>G.stopPropagation(),children:t.jsx(A,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Ce,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]}),f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[f.linkedPr.head," → ",f.linkedPr.base]}),f.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:a("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx($t,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(_t,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ut,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(A,{name:"git-branch",className:"h-5 w-5"}),a("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(fn,{items:[{id:"new-branch",label:a("session.newWorktree.mode.newBranch"),icon:t.jsx(A,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:a("session.newWorktree.mode.existingBranch"),icon:t.jsx(A,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:u,onSelect:G=>oe(G),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[u==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(gs,{open:v,onOpenChange:j,children:[t.jsx(us,{asChild:!0,children:t.jsxs(J,{variant:"outline",size:"sm",className:"h-9 min-w-[220px] max-w-full justify-between gap-2",children:[t.jsx("span",{className:ce("truncate",h.selectedBranch?"text-foreground":"text-muted-foreground"),children:h.selectedBranch||a("session.newWorktree.chooseBranch")}),t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(ps,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:X,children:t.jsxs(kr,{shouldFilter:!1,children:[t.jsx(Sr,{placeholder:a("session.newWorktree.searchBranches"),value:R,onValueChange:Y,onKeyDown:le}),t.jsx(Cr,{disableHorizontal:!0,children:w?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):N.length===0&&y.length===0?t.jsx(Pr,{children:a("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[je&&se&&t.jsx(Us,{heading:a("session.newWorktree.matchingBranches"),children:Ie.matching.map(G=>t.jsx(Rs,{value:G.value,onSelect:()=>{D($=>({...$,selectedBranch:G.value,worktreeName:xs(G.label)})),ne($=>({...$,touched:!0})),j(!1)},children:t.jsx("span",{className:"typography-small break-all",children:G.label})},`${G.source}-${G.value}`))}),je&&!se&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),Ie.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[je&&t.jsx(Pn,{}),t.jsx(Us,{heading:a(je?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:Ie.otherLocal.map(G=>t.jsx(Rs,{value:G,onSelect:()=>{D($=>({...$,selectedBranch:G,worktreeName:xs(G)})),ne($=>({...$,touched:!0})),j(!1)},children:t.jsx("span",{className:"typography-small break-all",children:G})},`local-${G}`))})]}),Ie.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(Ie.otherLocal.length>0||je)&&t.jsx(Pn,{}),t.jsx(Us,{heading:a(je?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:Ie.otherRemote.map(G=>t.jsx(Rs,{value:`remotes/${G}`,onSelect:()=>{D($=>({...$,selectedBranch:`remotes/${G}`,worktreeName:xs(G)})),ne($=>({...$,touched:!0})),j(!1)},children:t.jsx("span",{className:"typography-small break-all",children:G})},`remote-${G}`))})]})]})})]})})]}),t.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:V,disabled:!ge||w,title:a("session.newWorktree.fetchBranches"),children:w?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.branchName")}),u==="new-branch"&&me&&t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1.5 h-7",children:[t.jsx(A,{name:"github",className:"size-4 text-status-success"}),f.linkedIssue||f.linkedPr?a("session.newWorktree.actions.change"):a("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(ot,{value:f.branchName,onChange:G=>{g($=>({...$,branchName:G.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ne(G=>({...G,touched:!0})),placeholder:a("session.newWorktree.branchNamePlaceholder"),disabled:!!f.linkedPr,className:ce("h-8",te.touched&&te.branchError&&"border-destructive",f.linkedPr&&"bg-muted text-muted-foreground")}),f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(A,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.usingPrBranch",{branch:f.linkedPr.head})})]}),f.linkedIssue&&!f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(A,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.fromIssue",{number:f.linkedIssue.number,title:f.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:a("session.newWorktree.worktreeDirectory")}),u!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const G=xs(u==="new-branch"?f.branchName:"");g($=>({...$,worktreeName:G,isSyncingWorktreeName:!0}))},disabled:!f.branchName||f.worktreeName===xs(f.branchName),className:ce("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",f.worktreeName===xs(f.branchName)||!f.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:a("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(A,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:a("session.newWorktree.actions.reset")})]})]}),t.jsx(ot,{value:Be.worktreeName,onChange:G=>{u==="new-branch"?g($=>({...$,worktreeName:G.target.value,isSyncingWorktreeName:!1})):D($=>({...$,worktreeName:G.target.value}))},onBlur:()=>ne(G=>({...G,touched:!0})),placeholder:a("session.newWorktree.worktreeDirectoryPlaceholder"),className:ce("h-8",te.touched&&te.worktreeError&&"border-destructive")})]}),u==="new-branch"&&!f.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.sourceBranch")}),t.jsxs(gs,{open:O,onOpenChange:T,children:[t.jsx(us,{asChild:!0,children:t.jsxs(J,{variant:"outline",size:"sm",className:"h-9 min-w-[220px] max-w-full justify-between gap-2",children:[t.jsx("span",{className:ce("truncate",f.sourceBranch?"text-foreground":"text-muted-foreground"),children:f.sourceBranch||a("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(ps,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:re,children:t.jsxs(kr,{shouldFilter:!1,children:[t.jsx(Sr,{placeholder:a("session.newWorktree.searchBranches"),value:F,onValueChange:W,onKeyDown:le}),t.jsx(Cr,{disableHorizontal:!0,children:w?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):N.length===0&&y.length===0?t.jsx(Pr,{children:a("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ye&&ie&&t.jsx(Us,{heading:a("session.newWorktree.matchingBranches"),children:be.matching.map(G=>t.jsx(Rs,{value:G.value,onSelect:()=>{g($=>({...$,sourceBranch:G.value})),T(!1)},children:t.jsx("span",{className:"typography-small break-all",children:G.label})},`${G.source}-${G.value}`))}),ye&&!ie&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),be.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[ye&&t.jsx(Pn,{}),t.jsx(Us,{heading:a(ye?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:be.otherLocal.map(G=>t.jsx(Rs,{value:G,onSelect:()=>{g($=>({...$,sourceBranch:G})),T(!1)},children:t.jsx("span",{className:"typography-small break-all",children:G})},`local-${G}`))})]}),be.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(be.otherLocal.length>0||ye)&&t.jsx(Pn,{}),t.jsx(Us,{heading:a(ye?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:be.otherRemote.map(G=>t.jsx(Rs,{value:`remotes/${G}`,onSelect:()=>{g($=>({...$,sourceBranch:`remotes/${G}`})),T(!1)},children:t.jsx("span",{className:"typography-small break-all",children:G})},`remote-${G}`))})]})]})})]})})]}),f.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("session.newWorktree.newBranchFromSource",{source:f.sourceBranch})})]}),(f.linkedIssue||f.linkedPr)&&u==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),f.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.issueNumber",{number:f.linkedIssue.number})}),f.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.prNumber",{number:f.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:f.linkedIssue?.title||f.linkedPr?.title}),t.jsx("a",{href:f.linkedIssue?.url||f.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:G=>G.stopPropagation(),children:t.jsx(A,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Ce,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(A,{name:"close",className:"h-3.5 w-3.5"})})]}),f.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[f.linkedPr.head," → ",f.linkedPr.base]}),f.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:a("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(Yt,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:te.touched&&(te.branchError||te.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:te.branchError||te.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(J,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:ue,children:a("session.newWorktree.actions.cancel")}),t.jsxs(J,{size:"sm",onClick:Qe,disabled:!Ee||ue,className:"gap-1.5",children:[ue&&t.jsx(A,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),a(ue?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(wv,{open:M,onOpenChange:I,onSelect:H})]})}export{yo as $,Dl as A,hn as B,Vv as C,qv as D,Kv as E,Nf as F,kf as G,zi as H,tl as I,ks as J,Wv as K,sn as L,Ev as M,Gv as N,Rv as O,Hv as P,an as Q,Ov as R,Iy as S,qs as T,Jf as U,tn as V,en as W,zy as X,sl as Y,vo as Z,Nh as _,_v as a,qg as a0,nc as a1,rc as a2,vx as a3,Mv as a4,Ap as a5,Rl as a6,Ip as a7,$v as a8,Gy as b,Bv as c,Tv as d,Il as e,Rn as f,ls as g,Ab as h,Ht as i,If as j,Eo as k,ru as l,Fv as m,Av as n,Dy as o,ms as p,Kh as q,zh as r,zv as s,Lv as t,Uv as u,Lh as v,fn as w,Qf as x,pn as y,gn as z};
|