@openchamber/web 1.14.0 → 1.14.1
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/dist/assets/{DiagramView-CIaZCGUT.js → DiagramView-Cb58svCq.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-D2yCDL5A.js +7 -0
- package/dist/assets/{MultiRunWindow-Bsbr3i8y.js → MultiRunWindow-BPSxV_B7.js} +1 -1
- package/dist/assets/{OnboardingScreen-3IAKkM5k.js → OnboardingScreen-Sl-6JgaP.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-CLm6tF5n.js → SessionSwitcherDropdown-4FWg9xMC.js} +1 -1
- package/dist/assets/{SettingsWindow-K-ErjehP.js → SettingsWindow-CY8q4msv.js} +1 -1
- package/dist/assets/{TerminalView-DF7-jlam.js → TerminalView-fTYjnQkh.js} +1 -1
- package/dist/assets/{es-DQIFCjC2.js → es-bWcuDy_2.js} +1 -1
- package/dist/assets/{fr-CJRav0LS.js → fr-DzRs3OzV.js} +2 -2
- package/dist/assets/index-KnWk9fmM.css +1 -0
- package/dist/assets/index-ZJTzZ0_U.js +2 -0
- package/dist/assets/{ja-CjAaqvHO.js → ja-BqUX_UD3.js} +2 -2
- package/dist/assets/{ko-BEbFxvrd.js → ko-BQo10SNx.js} +2 -2
- package/dist/assets/main-BDoqLlQB.js +236 -0
- package/dist/assets/{main-C2put7uQ.js → main-DUGyTrDt.js} +2 -2
- package/dist/assets/miniChat-DNDiX8GA.js +2 -0
- package/dist/assets/mobile-DnghtOCb.js +2 -0
- package/dist/assets/pl-Bgx_ATJT.js +15 -0
- package/dist/assets/{pt-BR-9Sk3esQZ.js → pt-BR-B1yXRvoX.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CdDj0ms1.js → renderElectronMiniChatApp-BB4C1K7t.js} +2 -2
- package/dist/assets/renderMobileApp-CZgaXKi5.js +16 -0
- package/dist/assets/runtimeEndpointReset-By39StyB.js +167 -0
- package/dist/assets/{uk-DW_dTfoO.js → uk-C9k8SP8q.js} +1 -1
- package/dist/assets/{useAppFontEffects-DTO332li.js → useAppFontEffects-BUUJYbAZ.js} +129 -117
- package/dist/assets/{zh-CN-r2_euV7U.js → zh-CN-Bri-Vo5y.js} +1 -1
- package/dist/assets/{zh-TW-BdPx3NWh.js → zh-TW-DAUGzmYG.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/index.js +27 -5
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +10 -0
- package/server/lib/opencode/models-metadata.js +61 -0
- package/server/lib/opencode/openchamber-routes.js +7 -40
- package/server/lib/opencode/settings-helpers.js +13 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/session-assist/DOCUMENTATION.md +66 -0
- package/server/lib/session-assist/runtime.js +394 -0
- package/server/lib/small-model/DOCUMENTATION.md +78 -0
- package/server/lib/small-model/call.js +380 -0
- package/server/lib/small-model/catalog.js +13 -0
- package/server/lib/small-model/index.js +167 -0
- package/server/lib/small-model/resolve.js +131 -0
- package/server/lib/small-model/resolve.test.js +197 -0
- package/server/lib/small-model/routes.js +44 -0
- package/dist/assets/MarkdownRendererImpl-DWgOeIpO.js +0 -7
- package/dist/assets/index-5eUDDB6w.js +0 -2
- package/dist/assets/index-CgpE7F8T.css +0 -1
- package/dist/assets/main-DuQEoz31.js +0 -214
- package/dist/assets/miniChat-o3AAQ-8r.js +0 -2
- package/dist/assets/mobile-X0421aWz.js +0 -2
- package/dist/assets/pl-D4kzai5T.js +0 -15
- package/dist/assets/renderMobileApp-cZ_HZKSe.js +0 -16
- package/dist/assets/runtimeEndpointReset-BYLVW9e7.js +0 -167
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import{al as wc,b as nt,am as Nc,j as t,H as he,an as kc,ao as Sc,a as ln,d as ta,p as Wr,R as l,N as Ss,ac as Cc,ad as Pc,ab as Ic,ae as Ac,a9 as Dc,aa as Ec,af as Mc,ap as Rc,aq as Tc,ar as Fc,u as Lc,k as Oc,m as zc,t as Kc,C as $c,S as Uc,as as Bc,a7 as Vc,D as _c,o as Hc,at as Wc,au as qc,av as Gc,aw as Jc,ax as Qc,Y as Fs,ay as Yc,az as jn,aA as ri,aB as Xc,aC as Zc,aD as Wa,aE as ed,aF as td,aG as sd,aH as ii,aI as Ma,aJ as oi,i as wa,aK as yl,aL as qr,aM as Oa,aN as vl,aO as li,aP as nd,aQ as ad,aR as rd,aS as id,aT as ci,aU as Fe,aV as aa,aW as od,aX as ld,aY as cd,aZ as dd,a_ as md,a$ as jl,a8 as ud,b0 as di,b1 as pd,b2 as gd,b3 as hd,b4 as fd}from"./vendor-.bun-C6iL44L9.js";import{dC as za,y as Ra,z as Ta,p as ce,dD as Na,dE as ka,dF as Sa,b as ns,c as it,I as D,aF as It,aG as At,aH as Et,an as xd,aD as Ws,b7 as Ot,b6 as zt,b5 as Kt,bL as Wt,A as kr,bk as Gr,w as hn,aC as Cs,t as W,a1 as wl,B as G,dG as Mn,dH as bd,dI as yd,dr as vd,dJ as jd,dK as wd,dL as Nd,D as Ns,dM as kd,cY as Sd,cZ as Cd,c_ as Pd,cb as Id,ay as us,aA as ps,cc as Ad,aB as gs,a$ as Ka,dN as Dd,dO as An,b4 as $t,bx as Bt,bT as Jt,q as Ze,dP as ea,ax as js,X as lt,dn as Ed,bM as Rt,bN as Tt,bO as Lt,bP as Ft,bQ as gt,bi as hs,b0 as Jr,dQ as fn,bj as kt,dR as Nl,dS as Md,dT as Rd,dU as $a,dV as Hs,dW as Rn,b2 as kl,dX as tn,dY as Td,dZ as Fd,d_ as Ld,d$ as Od,e0 as zd,e1 as Kd,e2 as Vs,e3 as $d,x as Ua,ch as mi,n as Ud,cj as Sr,aa as Sl,H as Bd,P as Cl,K as Pl,cl as Vd,R as ui,d5 as _d,dl as Il,da as Al,dc as Hd,e4 as Wd,u as Cr,cH as qd,e5 as pi,e6 as Gd,e7 as Jd,e8 as gi,e9 as Qd,ea as Yd,eb as Xd,ec as Zd,aE as em,ed as tm,L as sm,N as nm,d as Qr,aP as hi,ee as fi,ef as xi,aS as Vn,eg as Pr,eh as am,ei as rm,aj as Tn,ai as Dl,ah as im,ej as om,ek as bi,ak as lm,al as cm,ac as dm,aJ as mm,aK as um,aL as El,el as qa,em as yi,en as pm,eo as gm,ep as hm,eq as fm,dd as Ba,Y as _s,er as xm,es as bm,et as ym,eu as vm,ev as jm,ew as Ga,ex as vi,ey as wm,ez as Nm,eA as km,eB as Sm,W as Cm,eC as Pm,eD as Ja,eE as Im,aY as ji,eF as Pn,aX as Am,eG as Dm,eH as wi,eI as Ni,ck as Em,a2 as Xs,F as Mm,S as Rm,eJ as Tm,cu as ra,bp as Ir,bq as Ar,br as Dr,bs as Er,bt as Bs,bu as Ms,bU as Dn,M as Xn,eK as ki,c4 as Fm,eL as Ml,bW as Lm,dh as Om,i as zm,eM as Qa,a9 as Km,bc as ia,b_ as $m,eN as Um,eO as Bm,db as Vm,eP as _m,eQ as Hm,dA as Wm,eR as qm}from"./useAppFontEffects-DTO332li.js";import{F as Yr,h as ht,o as ys,b as bs,a3 as Gm,a4 as Si,a5 as Jm,a6 as Qm,y as fs,M as gn,u as ze,m as zn,P as Ci,k as Pt,a as Kn,d as Os,l as is,s as Ym,a7 as Rl,H as Xm,a8 as Ya,G as Zm,a9 as Pi,aa as eu,z as tu,ab as Ii,ac as Ai,ad as Di,ae as Ei,af as Xa,ag as Mi,E as Tl,ah as su,ai as nu,aj as au,ak as ru,a2 as iu,f as ou,al as lu,am as cu,an as du,ao as mu}from"./index-5eUDDB6w.js";import{g as uu,s as pu}from"./mobileLayoutPreference-Dio-WWkI.js";function gu(){return new Worker(wc,{type:"module"})}const hu=["typescript","javascript","tsx","jsx","json","markdown"],Mr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Ri,Ti;const Fi=s=>{const e=Mr[s],n=new Nc({workerFactory:gu,poolSize:e.poolSize,totalASTLRUCacheSize:e.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:hu,lineDiffType:e.lineDiffType,preferredHighlighter:"shiki-wasm"});return n.initialize(),n},fu=s=>{if(!(typeof window>"u"))return s==="split"?(Ti??=Fi("split"),Ti):(Ri??=Fi("unified"),Ri)},xu=s=>{const e=nt.c(7),{children:n,renderTheme:a}=s,r=Rr("unified"),i=Rr("split");let o,d;e[0]!==a||e[1]!==i||e[2]!==r?(o=()=>{r&&r.setRenderOptions({theme:a,lineDiffType:Mr.unified.lineDiffType}),i&&i.setRenderOptions({theme:a,lineDiffType:Mr.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]),he.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},$v=s=>{const e=nt.c(11),{children:n}=s,a=za();let r,i;if(e[0]!==a?.availableThemes||e[1]!==a?.darkThemeId||e[2]!==a?.lightThemeId){const f=Ra(!1),u=Ra(!0),p=a?.lightThemeId??f.metadata.id,m=a?.darkThemeId??u.metadata.id;i=a?.availableThemes.find(P=>P.metadata.id===p)??f,r=a?.availableThemes.find(P=>P.metadata.id===m)??u,Ta(i),Ta(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(xu,{renderTheme:d,children:n}),e[8]=n,e[9]=d,e[10]=c):c=e[10],c},Rr=s=>{const e=nt.c(2),n=s===void 0?"unified":s;let a;return e[0]!==n?(a=fu(n),e[0]=n,e[1]=a):a=e[1],a};function bu(s){const e=nt.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 Fa=he.forwardRef((s,e)=>{const n=nt.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(kc,{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(Sc,{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});Fa.displayName="Switch";const oa=()=>{try{const e=ns.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();const n=ys.getDirectory();if(n?.trim())return n.trim()}catch(s){console.warn("[McpConfigStore] Error resolving config directory:",s)}return null},Li=s=>s?Object.entries(s).map(([e,n])=>({key:e,value:n})):[],Oi=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,Za=800,yu=5e3,vu="__default__",Tr=new Map,er=new Map,Fl=s=>s?.trim()||vu,tr=s=>{Tr.delete(Fl(s))},Ln=ln()(ta(Wr((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=Fl(a),i=Date.now(),o=Tr.get(r)??0,d=e().mcpServers.length>0;if(!n?.force&&d&&i-o<yu)return!0;const c=er.get(r);if(!n?.force&&c)return c;const f=(async()=>{s({isLoading:!0});try{const u=a?`?directory=${encodeURIComponent(a)}`:"",p=await ht(`/api/config/mcp${u}`,{headers:a?{"x-opencode-directory":a}:void 0});if(!p.ok)throw new Error("Failed to load MCP configs");const m=await p.json();return s({mcpServers:m,isLoading:!1}),Tr.set(r,Date.now()),!0}catch(u){return console.error("[McpConfigStore] Failed to load MCP configs:",u),s({isLoading:!1}),!1}})();er.set(r,f);try{return await f}finally{er.delete(r)}},createMcp:async n=>{Na("Creating MCP server configuration…");let a=!1;try{const r=zi(n),i=oa(),o=i?`?directory=${encodeURIComponent(i)}`:"",d=await ht(`/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 tr(i),c?.requiresReload?(a=!0,await ka({message:c.message,delayMs:c.reloadDelayMs??Za,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||Sa()}},updateMcp:async(n,a)=>{Na("Updating MCP server configuration…");let r=!1;try{const i=zi(a),o=oa(),d=o?`?directory=${encodeURIComponent(o)}`:"",c=await ht(`/api/config/mcp/${encodeURIComponent(n)}${d}`,{method:"PATCH",headers:{"Content-Type":"application/json",...o?{"x-opencode-directory":o}:{}},body:JSON.stringify(i)}),f=await c.json().catch(()=>null);if(!c.ok)throw new Error(f?.error||"Failed to update MCP server");return tr(o),f?.requiresReload?(r=!0,await ka({message:f.message,delayMs:f.reloadDelayMs??Za,scopes:["all"]}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:f?.reloadFailed===!0,message:f?.message,warning:f?.warning}):(await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:f?.reloadFailed===!0,message:f?.message,warning:f?.warning})}catch(i){throw console.error("[McpConfigStore] Failed to update MCP:",i),i}finally{r||Sa()}},deleteMcp:async n=>{Na("Deleting MCP server configuration…");let a=!1;try{const r=oa(),i=r?`?directory=${encodeURIComponent(r)}`:"",o=await ht(`/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 tr(r),d?.requiresReload&&(a=!0,await ka({message:d.message,delayMs:d.reloadDelayMs??Za,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||Sa()}},getMcpByName:n=>e().mcpServers.find(a=>a.name===n)}),{name:"mcp-config-store",storage:Yr(),partialize:s=>({selectedMcpName:s.selectedMcpName})}),{name:"mcp-config-store"}));function zi(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=Oi(s.environment)??{}),s.headers!==void 0&&(e.headers=Oi(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 ju={},wu={},Us=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},Sn=s=>Us(s)??"__global__",mn=s=>{const e=Us(s);return e?ys.getScopedApiClient(e):ys.getApiClient()},os=ln()(ta((s,e)=>({byDirectory:{},diagnosticsByDirectory:{},loadingKeys:{},lastErrorKeys:{},getStatusForDirectory:n=>{const a=Sn(n??bs.getState().currentDirectory);return e().byDirectory[a]??ju},getDiagnosticForDirectory:n=>{const a=Sn(n??bs.getState().currentDirectory);return e().diagnosticsByDirectory[a]??wu},getErrorForDirectory:n=>{const a=Sn(n??bs.getState().currentDirectory);return e().lastErrorKeys[a]??null},refresh:async n=>{const a=Us(n?.directory??bs.getState().currentDirectory),r=Sn(a);n?.silent||s(i=>({loadingKeys:{...i.loadingKeys,[r]:!0},lastErrorKeys:{...i.lastErrorKeys,[r]:null}}));try{const d=(await mn(a).mcp.status()).data??{};s(c=>({byDirectory:{...c.byDirectory,[r]:d},diagnosticsByDirectory:{...c.diagnosticsByDirectory,[r]:Object.fromEntries(Object.entries(c.diagnosticsByDirectory[r]??{}).filter(([f])=>!d[f]))},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=Us(a??bs.getState().currentDirectory),i=Sn(r),o=mn(r);try{await o.mcp.connect({name:n},{throwOnError:!0})}catch(d){const c=d instanceof Error?d.message:"Connection failed";throw s(f=>({diagnosticsByDirectory:{...f.diagnosticsByDirectory,[i]:{...f.diagnosticsByDirectory[i]??{},[n]:{status:"failed",error:c}}}})),d}await e().refresh({directory:r,silent:!0})},disconnect:async(n,a)=>{const r=Us(a??bs.getState().currentDirectory);await mn(r).mcp.disconnect({name:n},{throwOnError:!0}),await e().refresh({directory:r,silent:!0})},startAuth:async(n,a)=>{const r=Us(a??bs.getState().currentDirectory),d=(await mn(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=Us(r??bs.getState().currentDirectory);await mn(i).mcp.auth.callback({name:n,code:a},{throwOnError:!0}),await e().refresh({directory:i,silent:!0})},clearAuth:async(n,a)=>{const r=Us(a??bs.getState().currentDirectory);await mn(r).mcp.auth.remove({name:n},{throwOnError:!0}),await e().refresh({directory:r,silent:!0})},testConnection:async(n,a)=>{const r=Us(a??bs.getState().currentDirectory),i=Sn(r),o=mn(r),c=e().getStatusForDirectory(r)[n]?.status==="connected";let f,u;try{await o.mcp.connect({name:n},{throwOnError:!0})}catch(P){f=P instanceof Error?P.message:"Connection failed",s(g=>({diagnosticsByDirectory:{...g.diagnosticsByDirectory,[i]:{...g.diagnosticsByDirectory[i]??{},[n]:{status:"failed",error:f??"Connection failed"}}}}))}await e().refresh({directory:r,silent:!0});const p=e().getStatusForDirectory(r)[n],m=p;if(!c&&p?.status==="connected"){try{await o.mcp.disconnect({name:n},{throwOnError:!0})}catch(P){u=`Connection test succeeded, but cleanup disconnect failed: ${P instanceof Error?P.message:"Disconnect failed"}`}await e().refresh({directory:r,silent:!0})}return{status:m??e().getStatusForDirectory(r)[n],error:f,warning:u}}}))),Nu=(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}},ku=s=>{switch(s?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},Uv=({active:s,className:e,headerAction:n,listClassName:a,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:o}=it(),c=bs(k=>k.currentDirectory)??null,f=os(k=>k.getStatusForDirectory(c)),u=os(k=>k.refresh),p=os(k=>k.connect),m=os(k=>k.disconnect),P=Ln(k=>k.mcpServers),g=Ln(k=>k.loadMcpConfigs),[h,x]=l.useState(!1),[R,C]=l.useState(null);l.useEffect(()=>{u({directory:c,silent:!0})},[u,c]),l.useEffect(()=>{g({force:!0})},[g]),l.useEffect(()=>{s&&Promise.all([u({directory:c,silent:!0}),g({force:!0})])},[s,u,c,g]);const N=l.useMemo(()=>{const k=new Set(Object.keys(f));for(const j of P)j?.name&&k.add(j.name);return Array.from(k).sort((j,b)=>j.localeCompare(b))},[P,f]),T=l.useCallback(k=>{if(k?.preventDefault(),h)return;x(!0);const j=new Promise(b=>setTimeout(b,500));Promise.all([u({directory:c}),j]).finally(()=>{x(!1)})},[h,u,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:h,onClick:T,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(D,{name:"refresh",className:ce("h-4 w-4",h&&"animate-spin")})})]})]})}),t.jsxs("div",{className:ce("max-h-64 overflow-y-auto py-2",i&&"space-y-1 py-3",a),children:[N.map(k=>{const j=f[k],b=ku(j),A=j?.status==="connected",$=R===k,F=Nu(j,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(It,{children:[t.jsx(At,{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":F})}),t.jsx(Et,{side:"left",children:t.jsx("p",{children:F})})]}),t.jsx("span",{className:ce("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:k})]})}),t.jsx(Fa,{checked:A,disabled:$,className:"data-[checked]:bg-status-info",onCheckedChange:async I=>{C(k);try{I?await p(k,c):await m(k,c)}finally{C(null)}}})]},k)}),N.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})]})};function Su(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=xd();return s}catch{return"unknown"}}function Cu(){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 Pu(){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 Iu(s){const e=ze.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});return n.set("deviceClass",Su()),n.set("arch",Cu()),n.set("platform",Pu()),s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",zn()?"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 Ki(s,e){try{const n=Iu(s),a=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e||s==="vscode"&&a&&n.set("currentVersion",a);const r=await ht(`/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 Au(){return Qm()?"desktop":fs()?"vscode":gn()?"web":null}const $i={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Ll=ln()((s,e)=>({...$i,checkForUpdates:async()=>{const n=Au();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let a=null,r=null;if(n==="desktop"){const i=await Si();return s({checking:!1,available:i?.available??!1,info:i,lastChecked:Date.now(),nextCheckInSec:null}),r}else n==="web"?(a=await Ki("web"),r=a?.nextSuggestedCheckInSec??null):n==="vscode"&&(r=(await Ki("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 Si();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 Jm(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 Gm())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($i)}})),Ui="https://github.com/btriapitsyn/openchamber/releases";function Du(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(Gr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function Eu(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Bi(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function Mu(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 Ru(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 Vi=2e3,Tu=600*1e3;async function Fu(){try{const s=await ht("/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 Lu(){try{return(await ht("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function Ou(s,e=Math.ceil(Tu/Vi),n=Vi){for(let a=0;a<e;a++){try{const r=await ht("/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 Lu())return!0}catch{}await new Promise(r=>setTimeout(r,n))}return!1}const _i=({open:s,onOpenChange:e,info:n,downloading:a,downloaded:r,progress:i,error:o,onDownload:d,onRestart:c,runtimeType:f="desktop"})=>{const{t:u}=it(),[p,m]=he.useState(!1),[P,g]=he.useState("idle"),[h,x]=he.useState(null),R=n?.version?`${Ui}/tag/v${n.version}`:Ui,C=i?.total?Math.round(i.downloaded/i.total*100):0,N=f==="web",T=n?.updateCommand||"openchamber update";he.useEffect(()=>{s||(g("idle"),x(null))},[s]);const k=async()=>{(await hn(T)).ok&&(m(!0),setTimeout(()=>m(!1),2e3))},j=he.useCallback(async F=>{await Ws(F)},[]),b=he.useCallback(async()=>{g("updating"),x(null);const F=await Fu();if(!F.success){g("error"),x(F.error||u("updateDialog.error.updateFailed"));return}F.autoRestart&&(g("restarting"),await new Promise(v=>setTimeout(v,2e3))),g("reconnecting"),await Ou(n?.currentVersion)?window.location.reload():(g("error"),x(u("updateDialog.error.takingLonger")))},[n?.currentVersion,u]),A=P!=="idle"&&P!=="error",$=he.useMemo(()=>{if(!n?.body)return null;const F=n.body.trim();if(!F)return null;const I=Ru(F);if(I.length===0)return{kind:"raw",title:u("updateDialog.changelog.title"),content:Bi(F)};const v=[...I].sort((w,L)=>Mu(w.version,L.version));return{kind:"sections",title:u("updateDialog.changelog.title"),sections:v.map(w=>({version:w.version,dateLabel:Du(w.date),content:Bi(Eu(w.raw)||F)}))}},[n?.body,u]);return t.jsx(Ot,{open:s,onOpenChange:A?void 0:e,children:t.jsxs(zt,{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(Kt,{className:"flex items-center gap-2.5",children:[t.jsx(D,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:u(P==="restarting"||P==="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:[N&&A&&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(D,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[P==="updating"&&u("updateDialog.status.installingUpdate"),P==="restarting"&&u("updateDialog.status.serverRestarting"),P==="reconnecting"&&u("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:u("updateDialog.status.autoReloadHint")})]}),$&&!A&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Wt,{className:"max-h-[400px] p-0",fillContainer:!1,children:$.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:F=>{const v=F.target.closest("a");v&&v.href&&(F.preventDefault(),F.stopPropagation(),j(v.href))},children:t.jsx(kr,{content:$.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:$.sections.map(F=>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",F.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:F.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 w=I.target.closest("a");w&&w.href&&(I.preventDefault(),I.stopPropagation(),j(w.href))},children:t.jsx(kr,{content:F.content,disableLinkSafety:!0,enableFileReferences:!1})})]},F.version))})})}),N&&P==="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(D,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:u("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:T}),t.jsx("button",{onClick:k,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:u(p?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:p?t.jsx(D,{name:"check",className:"h-4 w-4"}):t.jsx(D,{name:"clipboard",className:"h-4 w-4"})})]})]}),!N&&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:u("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[C,"%"]})]}),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:`${C}%`}})})]}),(o||h)&&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||h})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:R,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(D,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!N&&!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(D,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.downloadUpdate")]}),!N&&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(D,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.downloading")]}),!N&&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(D,{name:"restart",className:"h-4 w-4"}),u("updateDialog.actions.restartToUpdate")]}),N&&!A&&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(D,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.updateNow")]}),N&&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(D,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.updating")]})]})]})]})})},Hi="https://github.com/openchamber/openchamber",zu="https://discord.gg/ZYRSdnwwKA",Wi="https://x.com/openchamber_dev",Ku=800,Ol=({initialUpdateDialogOpen:s=!1})=>{const{t:e}=it(),[n,a]=l.useState(s),[r,i]=l.useState(!1),[o,d]=l.useState(null),[c,f]=l.useState(null),u=Ll(Ss(h=>({info:h.info,checking:h.checking,available:h.available,error:h.error,downloading:h.downloading,downloaded:h.downloaded,progress:h.progress,runtimeType:h.runtimeType,checkForUpdates:h.checkForUpdates,downloadUpdate:h.downloadUpdate,restartToUpdate:h.restartToUpdate}))),{isMobile:p}=Cs(),m=o||u.info?.currentVersion||"unknown";l.useEffect(()=>{let h=!1;return(async()=>{try{const R=await ht("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!R.ok)return;const C=await R.json().catch(()=>null),N=typeof C?.openchamberVersion=="string"&&C.openchamberVersion.trim().length>0?C.openchamberVersion.trim():null;h||d(N)}catch{h||d(null)}})(),()=>{h=!0}},[]),l.useEffect(()=>{let h=!1;return(async()=>{try{const R=await ht("/api/opencode/upgrade-status",{method:"GET",headers:{Accept:"application/json"}});if(!R.ok)return;const C=await R.json().catch(()=>null),N=typeof C?.currentVersion=="string"&&C.currentVersion.trim().length>0?C.currentVersion.trim():null;h||f(N)}catch{h||f(null)}})(),()=>{h=!0}},[]);const P=l.useRef(!1);l.useEffect(()=>{if(u.checking)i(!0),P.current=!0;else if(r){const h=setTimeout(()=>{i(!1),P.current&&!u.available&&!u.error&&(W.success(e("settings.openchamber.about.toast.latestVersion")),P.current=!1)},Ku);return()=>clearTimeout(h)}},[e,u.checking,r,u.available,u.error]);const g=u.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(wl,{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:m})}),t.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:c||e("settings.openchamber.about.state.unknown")})})]})]}),t.jsxs("div",{className:"flex justify-center",children:[!u.available&&!u.error&&t.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:()=>u.checkForUpdates(),disabled:g,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[g?t.jsx(D,{name:"loader",className:"size-4 animate-spin"}):t.jsx(D,{name:"refresh",className:"size-4"}),e(g?"settings.openchamber.about.state.checking":"settings.openchamber.about.actions.checkForUpdates")]}),!g&&u.available&&t.jsxs(G,{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(D,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.updateToVersion",{version:u.info?.version||""})]})]}),u.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:u.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:Hi,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(D,{name:"github-fill",className:"size-5"}),t.jsx("span",{children:"GitHub"})]}),t.jsxs("a",{href:zu,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(D,{name:"discord-fill",className:"size-5"}),t.jsx("span",{children:"Discord"})]})]}),t.jsxs("a",{href:Wi,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(D,{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(_i,{open:n,onOpenChange:a,info:u.info,downloading:u.downloading,downloaded:u.downloaded,progress:u.progress,error:u.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:u.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:m})]}),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:[u.checking&&t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(D,{name:"loader",className:"h-4 w-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!u.checking&&u.available&&t.jsxs(G,{size:"sm",variant:"default",onClick:()=>a(!0),children:[t.jsx(D,{name:"download",className:"h-4 w-4 mr-1"}),e("settings.openchamber.about.actions.updateToVersion",{version:u.info?.version||""})]}),!u.checking&&!u.available&&!u.error&&t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),t.jsx(G,{size:"sm",variant:"outline",onClick:()=>u.checkForUpdates(),disabled:u.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),u.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:u.error})}),t.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[t.jsxs("a",{href:Hi,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(D,{name:"github-fill",className:"h-4 w-4"}),t.jsx("span",{children:"GitHub"})]}),t.jsxs("a",{href:Wi,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(D,{name:"twitter-xfill",className:"h-4 w-4"}),t.jsx("span",{children:"@openchamber_dev"})]})]})]}),t.jsx(_i,{open:n,onOpenChange:a,info:u.info,downloading:u.downloading,downloaded:u.downloaded,progress:u.progress,error:u.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:u.runtimeType})]})},Bv=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),$u=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Uu=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Bu=s=>!s||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),_n="opencode-update-available",ca="opencode-upgrade-progress",Vu=5e3,_u=[1e4,6e4],qi="opencode-update-toast-dismissed-version",Vv=()=>{const{t:s}=it(),e=ze(o=>o.showOpenCodeUpdateNotifications),n=he.useRef(new Set),a=he.useRef(!1);he.useEffect(()=>{e||W.dismiss(_n)},[e]);const r=he.useCallback(()=>{W.dismiss(ca),Mn({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),i=he.useCallback(async()=>{if(!a.current){a.current=!0,W.dismiss(_n),W.message(s("opencodeUpdate.toast.upgrading.title"),{id:ca,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(D,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const o=await ht("/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"));W.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(D,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:r}})}catch(o){W.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 he.useEffect(()=>{const o=p=>{if(!ze.getState().showOpenCodeUpdateNotifications){W.dismiss(_n);return}$u({version:p,dismissedVersion:Ci().getItem(qi),seenVersions:n.current})&&(n.current.add(p),W.info(s("opencodeUpdate.toast.available.title"),{id:_n,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:()=>{Ci().setItem(qi,p),Pt({openCodeUpdateToastDismissedVersion:p}),W.dismiss(_n)}}}))},d=p=>{const m=Uu(p.detail);o(m)};let c=!1;const f=[],u=async p=>{try{const m=await ht("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!m.ok)throw new Error(m.statusText||"OpenCode upgrade status check failed");const P=await m.json().catch(()=>null),g=Bu(P);!c&&g&&o(g)}catch{const m=_u[p];!c&&m!==void 0&&f.push(setTimeout(()=>{u(p+1)},m))}};return e&&f.push(setTimeout(()=>{u(0)},Vu)),window.addEventListener("openchamber:opencode-update-available",d),()=>{c=!0;for(const p of f)clearTimeout(p);window.removeEventListener("openchamber:opencode-update-available",d)}},[i,e,s]),null},_v=()=>{const s=nt.c(3),[e,n]=l.useState(Hu),{isUpdating:a}=e;let r,i;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>yd(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(wl,{width:80,height:80,isAnimated:!0})}),s[2]=o):o=s[2],o};function Hu(){return bd()}class Wu 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(vd,{className:"w-full max-w-md",children:[t.jsx(jd,{className:"text-center",children:t.jsxs(wd,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(D,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(Nd,{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(G,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(D,{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 qu(s){const e=nt.c(22),{t:n}=it();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 f;e[12]!==a||e[13]!==r||e[14]!==i||e[15]!==o||e[16]!==d||e[17]!==c?(f={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]=f):f=e[18];let u;return e[19]!==s||e[20]!==f?(u=t.jsx(Wu,{...s,texts:f}),e[19]=s,e[20]=f,e[21]=u):u=e[21],u}const Hv=s=>{const e=nt.c(5),{readOnly:n}=s,a=n===void 0?!1:n,i=Ns(Gu)||void 0;let o;e[0]!==a?(o=t.jsx(kd,{readOnly:a}),e[0]=a,e[1]=o):o=e[1];let d;return e[2]!==i||e[3]!==o?(d=t.jsx(qu,{sessionId:i,children:o}),e[2]=i,e[3]=o,e[4]=d):d=e[4],d};function Gu(s){return s.currentSessionId}function sn(s){const e=nt.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(Cc,{...n}),e[2]=n,e[3]=a):a=e[3],a}function nn(s){const e=nt.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(Pc,{...n}),e[2]=n,e[3]=a):a=e[3],a}function an(s){const e=nt.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 f;e[10]!==a?(f=ce(Sd,a),e[10]=a,e[11]=f):f=e[11];let u;e[12]!==n||e[13]!==i||e[14]!==c||e[15]!==f?(u=t.jsx(Ic,{"data-slot":"dropdown-menu-content",style:c,className:f,...i,children:n}),e[12]=n,e[13]=i,e[14]=c,e[15]=f,e[16]=u):u=e[16];let p;return e[17]!==d||e[18]!==u?(p=t.jsx(Dc,{children:t.jsx(Ec,{className:d,children:u})}),e[17]=d,e[18]=u,e[19]=p):p=e[19],p}function qs(s){const e=nt.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(Cd,n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(Ac,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i}function Wv(s){const e=nt.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(Pd,n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(Mc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i}const zl=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),sa=s=>{const e=nt.c(39),{className:n}=s,{t:a}=it(),r=ns(Ju),i=ns(Qu),o=ns(Yu),d=fs();let c;e[0]!==r?(c=[...r].sort(Xu),e[0]=r,e[1]=c):c=e[1];const f=c;let u;e:{if(f.length===0){u=null;break e}let L;e[2]!==i||e[3]!==f?(L=f.find(E=>E.id===i)??f[0],e[2]=i,e[3]=f,e[4]=L):L=e[4],u=L}const p=u;if(d||f.length===0)return null;let m;e[5]!==p||e[6]!==a?(m=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]=m):m=e[7];const P=m;let g;e[8]!==P?(g=zl(P),e[8]=P,e[9]=g):g=e[9];const h=g;let x;e[10]!==n?(x=ce(n),e[10]=n,e[11]=x):x=e[11];let R;e[12]!==a?(R=a("settings.shared.projectSelector.switchProjectAria"),e[12]=a,e[13]=R):R=e[13];let C;e[14]!==a?(C=a("settings.shared.projectSelector.switchProjectTitle"),e[14]=a,e[15]=C):C=e[15];let N,T;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=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"),T=t.jsx(D,{name:"folder",className:"h-4 w-4 opacity-70"}),e[16]=N,e[17]=T):(N=e[16],T=e[17]);let k;e[18]!==h?(k=t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:h}),e[18]=h,e[19]=k):k=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[20]=j):j=e[20];let b;e[21]!==k||e[22]!==R||e[23]!==C?(b=t.jsx(us,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":R,title:C,className:N,children:[T,k,j]})}),e[21]=k,e[22]=R,e[23]=C,e[24]=b):b=e[24];const A=p?.id??"";let $;e[25]!==o?($=L=>{L&&o(L)},e[25]=o,e[26]=$):$=e[26];let F;e[27]!==f?(F=f.map(Zu),e[27]=f,e[28]=F):F=e[28];let I;e[29]!==A||e[30]!==$||e[31]!==F?(I=t.jsx(ps,{align:"start",className:"w-auto",children:t.jsx(Ad,{value:A,onValueChange:$,children:F})}),e[29]=A,e[30]=$,e[31]=F,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 w;return e[36]!==v||e[37]!==x?(w=t.jsx("div",{className:x,children:v}),e[36]=v,e[37]=x,e[38]=w):w=e[38],w};function Ju(s){return s.projects}function Qu(s){return s.activeProjectId}function Yu(s){return s.setActiveProject}function Xu(s,e){return(s.label||s.path).localeCompare(e.label||e.path)}function Zu(s){const e=s.label?.trim()?s.label.trim():s.path.split("/").filter(Boolean).pop()||s.path,n=zl(e);return t.jsx(Id,{value:s.id,children:t.jsx("span",{className:"min-w-0 truncate typography-ui",children:n})},s.id)}function ep(s,e){return`opencode:sidebar-group:${s}:${e}`}const Fr=s=>{const e=nt.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=ep(r,n),e[0]=n,e[1]=r,e[2]=c):c=e[2];const f=c,u=l.useId();let p;e[3]!==d||e[4]!==f?(p=()=>{try{const I=localStorage.getItem(f);if(I!==null)return I==="true"}catch{}return d},e[3]=d,e[4]=f,e[5]=p):p=e[5];const[m,P]=he.useState(p);let g,h;e[6]!==m||e[7]!==f?(g=()=>{try{localStorage.setItem(f,String(m))}catch{}},h=[f,m],e[6]=m,e[7]=f,e[8]=g,e[9]=h):(g=e[8],h=e[9]),he.useEffect(g,h);let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>P(tp),e[10]=x):x=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=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]=R):R=e[11];const C=!m&&"-rotate-90";let N;e[12]!==C?(N=ce("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",C),e[12]=C,e[13]=N):N=e[13];let T;e[14]!==N?(T=t.jsx(D,{name:"arrow-down-s",className:N}),e[14]=N,e[15]=T):T=e[15];let k;e[16]!==n?(k=t.jsx("span",{className:"flex-1 truncate",children:n}),e[16]=n,e[17]=k):k=e[17];let j;e[18]!==a?(j=t.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=j):j=e[19];let b;e[20]!==u||e[21]!==m||e[22]!==T||e[23]!==k||e[24]!==j?(b=t.jsxs("button",{type:"button",onClick:x,"aria-expanded":m,"aria-controls":u,className:R,children:[T,k,j]}),e[20]=u,e[21]=m,e[22]=T,e[23]=k,e[24]=j,e[25]=b):b=e[25];const A=!m;let $;e[26]!==o||e[27]!==u||e[28]!==A?($=t.jsx("div",{id:u,hidden:A,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]=u,e[28]=A,e[29]=$):$=e[29];let F;return e[30]!==b||e[31]!==$?(F=t.jsxs("div",{children:[b,$]}),e[30]=b,e[31]=$,e[32]=F):F=e[32],F};function tp(s){return!s}const sp=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},np=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())},Gi=s=>{const e=np(sp(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},ap=({onItemSelect:s})=>{const{t:e}=it(),[n,a]=l.useState(null),[r,i]=l.useState(""),[o,d]=l.useState(null),[c,f]=l.useState(null),[u,p]=l.useState(!1),[m,P]=l.useState(null),{selectedAgentName:g,agents:h,setSelectedAgent:x,setAgentDraft:R,createAgent:C,deleteAgent:N,loadAgents:T}=Ka(Ss(M=>({selectedAgentName:M.selectedAgentName,agents:M.agents,setSelectedAgent:M.setSelectedAgent,setAgentDraft:M.setAgentDraft,createAgent:M.createAgent,deleteAgent:M.deleteAgent,loadAgents:M.loadAgents})));l.useEffect(()=>{T()},[T]);const k="bg-background",j=()=>{const M="new-agent";let X=M,ee=1;for(;h.some(K=>K.name===X);)X=`${M}-${ee}`,ee++;R({name:X,scope:"user"}),x(X),s?.()},b=async M=>{if(An(M)){W.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(M),f("delete")},A=async M=>{An(M)&&(d(M),f("reset"))},$=()=>{d(null),f(null)},F=async()=>{if(!(!o||!c)){p(!0);try{const M=await N(o.name,o.scope);M.ok?(M.requiresManualRestart?W.warning(e("settings.agents.page.toast.savedManualRestart")):c==="delete"?W.success(e("settings.agents.sidebar.toast.agentDeleted",{name:o.name})):W.success(e("settings.agents.sidebar.toast.agentReset",{name:o.name})),$()):c==="delete"?W.error(e("settings.agents.sidebar.toast.deleteFailed")):W.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(M){const X=M instanceof Error?M.message:"",ee=/built-in|not deletable|not found/i.test(X);c==="delete"?W.error(e(ee?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):W.error(e("settings.agents.sidebar.toast.resetFailed"))}p(!1)}},I=M=>{const X=M.name;let ee=1,K=`${X}-copy`;for(;h.some(ne=>ne.name===K);)ee++,K=`${X}-copy-${ee}`;const O=M,Y=M.model?.providerID&&M.model?.modelID?`${M.model.providerID}/${M.model.modelID}`:null,U=M;R({name:K,scope:O.scope||"user",description:M.description,model:Y,variant:M.variant,temperature:M.temperature,top_p:M.topP,prompt:M.prompt,mode:M.mode,permission:Gi(M.permission),disable:U.disable}),x(K)},v=M=>{i(M.name),a(M)},w=async()=>{if(!n)return;const M=r.trim().replace(/\s+/g,"-");if(!M){W.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(M===n.name){a(null);return}if(h.some(O=>O.name===M)){W.error(e("settings.agents.sidebar.toast.agentExists"));return}const X=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,ee=n,K=await C({name:M,description:n.description,model:X,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:Gi(n.permission),disable:ee.disable,scope:ee.scope});if(K.ok){const O=await N(n.name,ee.scope);O.ok?(K.requiresManualRestart||O.requiresManualRestart?W.warning(e("settings.agents.page.toast.savedManualRestart")):W.success(e("settings.agents.sidebar.toast.agentRenamed",{name:M})),x(M)):W.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed"))}else W.error(e("settings.agents.sidebar.toast.renameFailed"));a(null)},L=M=>{switch(M){case"primary":return t.jsx(D,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return t.jsx(D,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return t.jsx(D,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},E=h.filter(M=>!Dd(M)),_=E.filter(An),B=E.filter(M=>!An(M)),{groupedCustomAgents:Z,ungroupedCustomAgents:Q}=he.useMemo(()=>{const M={},X=[];for(const K of B){const O=K;O.group?(M[O.group]||(M[O.group]=[]),M[O.group].push(K)):X.push(K)}return{groupedCustomAgents:Object.keys(M).sort((K,O)=>K.localeCompare(O)).map(K=>({name:K,agents:M[K]})),ungroupedCustomAgents:X}},[B]);return t.jsxs("div",{className:ce("flex h-full flex-col",k),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(sa,{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:E.length})}),t.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:j,children:t.jsx(D,{name:"add",className:"h-3.5 w-3.5"})})]})]}),t.jsx(Wt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:E.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(D,{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:[_.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")}),_.map(M=>t.jsx(sr,{agent:M,isSelected:g===M.name,onSelect:()=>{x(M.name),s?.()},onReset:()=>A(M),onDuplicate:()=>I(M),getAgentModeIcon:L,isMenuOpen:m===M.name,onMenuOpenChange:X=>P(X?M.name:null)},M.name))]}),B.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")}),Z.map(({name:M,agents:X})=>t.jsx(Fr,{label:M,count:X.length,storageKey:"agents",children:X.map(ee=>t.jsx(sr,{agent:ee,isSelected:g===ee.name,onSelect:()=>{x(ee.name),s?.()},onRename:()=>v(ee),onDelete:()=>b(ee),onDuplicate:()=>I(ee),getAgentModeIcon:L,isMenuOpen:m===ee.name,onMenuOpenChange:K=>P(K?ee.name:null)},ee.name))},M)),Q.map(M=>t.jsx(sr,{agent:M,isSelected:g===M.name,onSelect:()=>{x(M.name),s?.()},onRename:()=>v(M),onDelete:()=>b(M),onDuplicate:()=>I(M),getAgentModeIcon:L,isMenuOpen:m===M.name,onMenuOpenChange:X=>P(X?M.name:null)},M.name))]})]})}),t.jsx(Ot,{open:o!==null&&c!==null,onOpenChange:M=>{!M&&!u&&$()},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:e(c==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),t.jsx(Bt,{children:c==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:o?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:o?.name??""})})]}),t.jsxs(Jt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:$,disabled:u,children:e("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",onClick:F,disabled:u,children:e(c==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),t.jsx(Ot,{open:n!==null,onOpenChange:M=>!M&&a(null),children:t.jsxs(zt,{children:[t.jsxs($t,{children:[t.jsx(Kt,{children:e("settings.agents.sidebar.renameDialog.title")}),t.jsx(Bt,{children:e("settings.agents.sidebar.renameDialog.description",{name:n?.name??""})})]}),t.jsx(Ze,{value:r,onChange:M=>i(M.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:M=>{M.key==="Enter"&&w()}}),t.jsxs(Jt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>a(null),children:e("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",onClick:w,children:e("settings.common.actions.rename")})]})]})})]})},sr=s=>{const e=nt.c(52),{agent:n,isSelected:a,onSelect:r,onDelete:i,onReset:o,onRename:d,onDuplicate:c,getAgentModeIcon:f,isMenuOpen:u,onMenuOpenChange:p}=s,{t:m}=it(),P=n;let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=ea(),e[0]=g):g=e[0];const h=g,[x,R]=l.useState(!1);let C;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==o||e[5]!==m?(C=ee=>t.jsxs(t.Fragment,{children:[d&&t.jsxs(ee,{onClick:K=>{K.stopPropagation(),d()},children:[t.jsx(D,{name:"edit",className:"h-4 w-4 mr-px"}),m("settings.common.actions.rename")]}),t.jsxs(ee,{onClick:K=>{K.stopPropagation(),c()},children:[t.jsx(D,{name:"file-copy",className:"h-4 w-4 mr-px"}),m("settings.common.actions.duplicate")]}),o&&t.jsxs(ee,{onClick:K=>{K.stopPropagation(),o()},children:[t.jsx(D,{name:"restart",className:"h-4 w-4 mr-px"}),m("settings.common.actions.reset")]}),i&&t.jsxs(ee,{onClick:K=>{K.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{name:"delete-bin",className:"h-4 w-4 mr-px"}),m("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=o,e[5]=m,e[6]=C):C=e[6];const N=C,T=a?"bg-interactive-selection":"hover:bg-interactive-hover";let k;e[7]!==T?(k=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",T),e[7]=T,e[8]=k):k=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=h?void 0:ee=>{ee.preventDefault(),R(!0)},e[9]=j):j=e[9];let b;e[10]!==k?(b=t.jsx("div",{className:k,onContextMenu:j}),e[10]=k,e[11]=b):b=e[11];let A;e[12]!==n.name?(A=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=A):A=e[13];let $;e[14]!==n.mode||e[15]!==f?($=f(n.mode),e[14]=n.mode,e[15]=f,e[16]=$):$=e[16];let F;e[17]!==n||e[18]!==P.scope||e[19]!==m?(F=(P.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)?m("settings.agents.sidebar.badge.system"):P.scope}),e[17]=n,e[18]=P.scope,e[19]=m,e[20]=F):F=e[20];let I;e[21]!==A||e[22]!==$||e[23]!==F?(I=t.jsxs("div",{className:"flex items-center gap-1.5",children:[A,$,F]}),e[21]=A,e[22]=$,e[23]=F,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 w;e[27]!==r||e[28]!==I||e[29]!==v?(w=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]=w):w=e[30];let L;e[31]!==p?(L=ee=>{ee&&R(!1),p(ee)},e[31]=p,e[32]=L):L=e[32];let E;e[33]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(us,{asChild:!0,children:t.jsx(G,{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(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=E):E=e[33];let _;e[34]!==N?(_=t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:N(js)}),e[34]=N,e[35]=_):_=e[35];let B;e[36]!==u||e[37]!==L||e[38]!==_?(B=t.jsxs(gs,{open:u,onOpenChange:L,children:[E,_]}),e[36]=u,e[37]=L,e[38]=_,e[39]=B):B=e[39];let Z;e[40]!==w||e[41]!==B?(Z=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[w,B]}),e[40]=w,e[41]=B,e[42]=Z):Z=e[42];let Q;e[43]!==Z||e[44]!==b?(Q=t.jsx(nn,{render:b,children:Z}),e[43]=Z,e[44]=b,e[45]=Q):Q=e[45];let M;e[46]!==N?(M=t.jsx(an,{className:"w-fit min-w-20",children:N(qs)}),e[46]=N,e[47]=M):M=e[47];let X;return e[48]!==x||e[49]!==Q||e[50]!==M?(X=t.jsxs(sn,{open:x,onOpenChange:R,children:[Q,M]}),e[48]=x,e[49]=Q,e[50]=M,e[51]=X):X=e[51],X};function Ji(s,e,n){return Math.min(n,Math.max(e,s))}function rp(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 Qi(s,e){const n=rp(e);return n<=0?s:Number(s.toFixed(n))}const vs=he.forwardRef((s,e)=>{const n=nt.c(125);let a,r,i,o,d,c,f,u,p,m,P,g,h;n[0]!==s?({value:h,onValueChange:f,min:p,max:m,step:P,className:a,containerClassName:r,onBlur:d,disabled:i,fallbackValue:o,onClear:c,emptyLabel:g,...u}=s,n[0]=s,n[1]=a,n[2]=r,n[3]=i,n[4]=o,n[5]=d,n[6]=c,n[7]=f,n[8]=u,n[9]=p,n[10]=m,n[11]=P,n[12]=g,n[13]=h):(a=n[1],r=n[2],i=n[3],o=n[4],d=n[5],c=n[6],f=n[7],u=n[8],p=n[9],m=n[10],P=n[11],g=n[12],h=n[13]);const x=p===void 0?-1/0:p,R=m===void 0?1/0:m,C=P===void 0?1:P,N=g===void 0?"—":g,{t:T}=it();let k;n[14]!==h?(k=()=>h===void 0?"":String(h),n[14]=h,n[15]=k):k=n[15];const[j,b]=he.useState(k),{isMobile:A}=Cs(),$=he.useRef(!1),F=he.useRef(null);let I;n[16]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{if(typeof document>"u"||typeof window>"u")return;F.current?.();const Ee=Le=>{Le.preventDefault(),Le.stopPropagation(),Le.stopImmediatePropagation?.(),F.current?.()},Pe=window.setTimeout(()=>{F.current?.()},700),Te=()=>{window.clearTimeout(Pe),document.removeEventListener("click",Ee,!0),F.current=null};F.current=Te,document.addEventListener("click",Ee,!0)},n[16]=I):I=n[16];const v=I;let w,L;n[17]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{F.current?.()},L=[],n[17]=w,n[18]=L):(w=n[17],L=n[18]),he.useEffect(w,L);let E,_;n[19]!==h?(_=()=>{b(h===void 0?"":String(h))},E=[h],n[19]=h,n[20]=E,n[21]=_):(E=n[20],_=n[21]),he.useEffect(_,E);let B;e:{if(h!==void 0){B=h;break e}if(o!==void 0){B=o;break e}if(Number.isFinite(x)){B=x;break e}B=0}const Z=B;let Q;n[22]!==R||n[23]!==x||n[24]!==f||n[25]!==C?(Q=Ee=>{const Pe=Ji(Ee,x,R);f(Qi(Pe,C))},n[22]=R,n[23]=x,n[24]=f,n[25]=C,n[26]=Q):Q=n[26];const M=Q;let X;n[27]!==M||n[28]!==c?(X=Ee=>{const Pe=Ee.target.value;if(b(Pe),Pe.trim()===""){c?.();return}const Te=Number(Pe);Number.isFinite(Te)&&M(Te)},n[27]=M,n[28]=c,n[29]=X):X=n[29];const ee=X;let K;n[30]!==j||n[31]!==R||n[32]!==x||n[33]!==d||n[34]!==c||n[35]!==f||n[36]!==C||n[37]!==h?(K=Ee=>{if(j.trim()===""){c||b(h===void 0?"":String(h)),d?.(Ee);return}const Pe=Number(j);if(!Number.isFinite(Pe))b(h===void 0?"":String(h));else{const Te=Ji(Pe,x,R),Le=Qi(Te,C);Le!==h&&f(Le),b(String(Le))}d?.(Ee)},n[30]=j,n[31]=R,n[32]=x,n[33]=d,n[34]=c,n[35]=f,n[36]=C,n[37]=h,n[38]=K):K=n[38];const O=K,Y=!!(i||Z>=R),U=!!(i||Z<=x);let ne;n[39]!==Z||n[40]!==M||n[41]!==U||n[42]!==C?(ne=()=>{U||M(Z-C)},n[39]=Z,n[40]=M,n[41]=U,n[42]=C,n[43]=ne):ne=n[43];const re=ne;let V;n[44]!==Z||n[45]!==M||n[46]!==Y||n[47]!==C?(V=()=>{Y||M(Z+C)},n[44]=Z,n[45]=M,n[46]=Y,n[47]=C,n[48]=V):V=n[48];const oe=V;let fe;if(n[49]!==a||n[50]!==r||n[51]!==U||n[52]!==j||n[53]!==N||n[54]!==re||n[55]!==oe||n[56]!==Y||n[57]!==A||n[58]!==T||n[59]!==h){fe=Symbol.for("react.early_return_sentinel");e:{const Ee=Te=>Le=>{Le.preventDefault(),Le.stopPropagation(),$.current=!0,v(),Te()},Pe=Te=>Le=>{if($.current){$.current=!1,Le.preventDefault(),Le.stopPropagation();return}Te()};if(A){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 Le;n[63]!==T?(Le=T("numberInput.actions.decreaseAria"),n[63]=T,n[64]=Le):Le=n[64];const Be=Ee(re),He=Pe(re),Ue=!U&&"active:bg-interactive-hover";let Je;n[65]!==Ue?(Je=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",Ue),n[65]=Ue,n[66]=Je):Je=n[66];let de;n[67]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsx(D,{name:"subtract",className:"block h-4 w-4"}),n[67]=de):de=n[67];const q=t.jsx("button",{type:"button","aria-label":Le,disabled:U,onTouchStart:Be,onClick:He,className:Je,children:de});let ue;n[68]!==a?(ue=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]=ue):ue=n[69];const je=h===void 0?N:j;let Re;n[70]!==ue||n[71]!==je?(Re=t.jsx("div",{className:ue,"aria-live":"polite",children:je}),n[70]=ue,n[71]=je,n[72]=Re):Re=n[72];let Ce;n[73]!==T?(Ce=T("numberInput.actions.increaseAria"),n[73]=T,n[74]=Ce):Ce=n[74];const _e=Ee(oe),J=Pe(oe),y=!Y&&"active:bg-interactive-hover";let pe;n[75]!==y?(pe=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",y),n[75]=y,n[76]=pe):pe=n[76];let Ae;n[77]===Symbol.for("react.memo_cache_sentinel")?(Ae=t.jsx(D,{name:"add",className:"block h-4 w-4"}),n[77]=Ae):Ae=n[77];const Oe=t.jsx("button",{type:"button","aria-label":Ce,disabled:Y,onTouchStart:_e,onClick:J,className:pe,children:Ae});let qe;n[78]!==Te||n[79]!==q||n[80]!==Re||n[81]!==Oe?(qe=t.jsxs("div",{className:Te,children:[q,Re,Oe]}),n[78]=Te,n[79]=q,n[80]=Re,n[81]=Oe,n[82]=qe):qe=n[82],fe=qe;break e}}n[49]=a,n[50]=r,n[51]=U,n[52]=j,n[53]=N,n[54]=re,n[55]=oe,n[56]=Y,n[57]=A,n[58]=T,n[59]=h,n[60]=fe}else fe=n[60];if(fe!==Symbol.for("react.early_return_sentinel"))return fe;let xe;n[83]!==r?(xe=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]=xe):xe=n[84];let Ie;n[85]!==T?(Ie=T("numberInput.actions.decreaseAria"),n[85]=T,n[86]=Ie):Ie=n[86];let ve;n[87]!==Z||n[88]!==M||n[89]!==C?(ve=()=>M(Z-C),n[87]=Z,n[88]=M,n[89]=C,n[90]=ve):ve=n[90];let we,be;n[91]===Symbol.for("react.memo_cache_sentinel")?(we=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"),be=t.jsx(D,{name:"subtract",className:"block h-3.5 w-3.5"}),n[91]=we,n[92]=be):(we=n[91],be=n[92]);let se;n[93]!==U||n[94]!==Ie||n[95]!==ve?(se=t.jsx("button",{type:"button","aria-label":Ie,disabled:U,onClick:ve,className:we,children:be}),n[93]=U,n[94]=Ie,n[95]=ve,n[96]=se):se=n[96];const le=u.inputMode??"numeric";let ye;n[97]!==a?(ye=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]=ye):ye=n[98];let H;n[99]!==i||n[100]!==j||n[101]!==O||n[102]!==ee||n[103]!==u||n[104]!==e||n[105]!==le||n[106]!==ye?(H=t.jsx("input",{...u,ref:e,type:"text",inputMode:le,value:j,onChange:ee,onBlur:O,disabled:i,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:ye}),n[99]=i,n[100]=j,n[101]=O,n[102]=ee,n[103]=u,n[104]=e,n[105]=le,n[106]=ye,n[107]=H):H=n[107];let te;n[108]!==T?(te=T("numberInput.actions.increaseAria"),n[108]=T,n[109]=te):te=n[109];let ae;n[110]!==Z||n[111]!==M||n[112]!==C?(ae=()=>M(Z+C),n[110]=Z,n[111]=M,n[112]=C,n[113]=ae):ae=n[113];let me,Me;n[114]===Symbol.for("react.memo_cache_sentinel")?(me=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(D,{name:"add",className:"block h-3.5 w-3.5"}),n[114]=me,n[115]=Me):(me=n[114],Me=n[115]);let Ne;n[116]!==Y||n[117]!==te||n[118]!==ae?(Ne=t.jsx("button",{type:"button","aria-label":te,disabled:Y,onClick:ae,className:me,children:Me}),n[116]=Y,n[117]=te,n[118]=ae,n[119]=Ne):Ne=n[119];let De;return n[120]!==xe||n[121]!==se||n[122]!==H||n[123]!==Ne?(De=t.jsxs("div",{className:xe,children:[se,H,Ne]}),n[120]=xe,n[121]=se,n[122]=H,n[123]=Ne,n[124]=De):De=n[124],De});vs.displayName="NumberInput";const Yi=["*","read","edit","glob","grep","list","bash","task","skill","lsp","todoread","todowrite","webfetch","websearch","codesearch","external_directory","doom_loop","question","plan_enter","plan_exit"],Ca=s=>s==="allow"||s==="ask"||s==="deny",pn=(s,e)=>`${s}::${e}`,rn=s=>{const e=new Map;for(const n of s)!n.permission||n.permission==="invalid"||n.pattern&&Ca(n.action)&&e.set(pn(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 rn(s))e.set(pn(n.permission,n.pattern),n);return e},Xi=s=>[...s].sort((e,n)=>{const a=e.permission.localeCompare(n.permission);return a!==0?a:e.pattern.localeCompare(n.pattern)}),ip=(s,e)=>{const n=Xi(rn(s)),a=Xi(rn(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})},op=s=>s.find(n=>n.permission==="*"&&n.pattern==="*")?.action??"allow",lp=(s,e)=>rn(s).filter(n=>!(n.permission==="*"&&n.pattern==="*")).filter(n=>n.pattern!=="*"||n.action!==e),nr=s=>{if(Array.isArray(s))return rn(s);if(Ca(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(Ca(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))Ca(i)&&e.push({permission:n,pattern:r,action:i})}return e},cp=(s,e)=>{const n=rn(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)},dp=(s,e)=>{const n=fn(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):[]},mp=()=>{const{t:s}=it(),{isMobile:e}=Cs(),n=lt(q=>q.providers),{selectedAgentName:a,getAgentByName:r,createAgent:i,updateAgent:o,agents:d,agentDraft:c,setAgentDraft:f}=Ka(Ss(q=>({selectedAgentName:q.selectedAgentName,getAgentByName:q.getAgentByName,createAgent:q.createAgent,updateAgent:q.updateAgent,agents:q.agents,agentDraft:q.agentDraft,setAgentDraft:q.setAgentDraft}))),u=a?r(a):null,p=!!(c&&c.name===a&&!u),[m,P]=l.useState(""),[g,h]=l.useState("user"),[x,R]=l.useState(""),[C,N]=l.useState("subagent"),[T,k]=l.useState(""),[j,b]=l.useState(""),[A,$]=l.useState(void 0),[F,I]=l.useState(void 0),[v,w]=l.useState(""),[L,E]=l.useState("allow"),[_,B]=l.useState([]),[Z,Q]=l.useState([]),[M,X]=l.useState(""),[ee,K]=l.useState("*"),[O,Y]=l.useState(!1),[U,ne]=l.useState(!1),re=l.useRef(null),V=bs(q=>q.currentDirectory??null),[oe,fe]=l.useState([]),xe=l.useMemo(()=>dp(n,T),[T,n]),Ie=xe.length>0,ve=l.useMemo(()=>!j||!xe.includes(j)?"__default":j,[j,xe]),we=Ie&&(!j||xe.includes(j)),be=Ed(q=>q.permission);l.useEffect(()=>{let q=!1;return(async()=>{const je=await ys.listToolIds({directory:V});if(q)return;const Re=new Set(["write","patch","multiedit"]),Ce=je.map(_e=>typeof _e=="string"?_e.trim():"").filter(Boolean).filter(_e=>_e!=="*").filter(_e=>_e!=="invalid").filter(_e=>!Re.has(_e));fe(Array.from(new Set(Ce)).sort((_e,J)=>_e.localeCompare(J)))})(),()=>{q=!0}},[V]);const se=l.useMemo(()=>{const q=new Set;for(const ue of d){const je=rn(nr(ue.permission));for(const Re of je)Re.permission&&Re.permission!=="*"&&Re.permission!=="invalid"&&q.add(Re.permission)}for(const ue of Object.values(be))for(const je of ue){const Re=je.permission?.trim();Re&&Re!=="invalid"&&q.add(Re)}for(const ue of oe)q.add(ue);return Array.from(q).sort((ue,je)=>ue.localeCompare(je))},[d,be,oe]),le=l.useMemo(()=>da(_),[_]),ye=l.useMemo(()=>da(Z),[Z]),H=l.useCallback(q=>ye.get(pn(q,"*"))?.action,[ye]),te=l.useCallback(q=>Z.filter(ue=>ue.permission===q&&ue.pattern!=="*").sort((ue,je)=>ue.pattern.localeCompare(je.pattern)),[Z]),ae=l.useMemo(()=>{const q=new Set;for(const ue of Yi)q.add(ue);for(const ue of se)q.add(ue);return Array.from(q).sort((ue,je)=>ue.localeCompare(je))},[se]),me=l.useCallback(q=>{const ue=q==="*"?L:H(q)??L,je=te(q),Re=!1,Ce=je.reduce((J,y)=>(J[y.action]=(J[y.action]??0)+1,J),{allow:0,ask:0,deny:0}),_e=["allow","ask","deny"].filter(J=>Ce[J]>0).map(J=>`${Ce[J]} ${J}`).join(", ");return{defaultAction:ue,patternRulesCount:je.length,patternSummary:_e,hasDefaultHint:Re}},[te,H,L]),Me=l.useCallback(q=>s(q==="allow"?"settings.common.permission.allow":q==="deny"?"settings.common.permission.deny":"settings.common.permission.ask"),[s]),Ne=l.useCallback(q=>q==="global"?s("settings.common.scope.global"):Me(q),[Me,s]),De=l.useMemo(()=>{const q=new Set;for(const ue of Yi)q.add(ue);for(const ue of se)q.add(ue);return Array.from(q).sort((ue,je)=>ue.localeCompare(je))},[se]),Ee=l.useCallback((q,ue,je)=>{Q(Re=>{const Ce=da(Re);return Ce.set(pn(q,ue),{permission:q,pattern:ue,action:je}),Array.from(Ce.values())})},[]),Pe=l.useCallback((q,ue)=>{Q(je=>{const Re=da(je);return Re.delete(pn(q,ue)),Array.from(Re.values())})},[]),Te=l.useCallback((q,ue)=>{const je=le.get(pn(q,ue));if(je){Ee(q,ue,je.action);return}Pe(q,ue)},[le,Pe,Ee]),Le=l.useCallback((q,ue,je)=>{Ee(q,ue,je)},[Ee]),Be=l.useCallback(q=>{E(q),Q(ue=>ue.filter(je=>!(je.pattern==="*"&&je.action===q)))},[]),He=l.useCallback(q=>{const ue=M.trim();if(!ue){W.error(s("settings.agents.page.toast.permissionNameRequired"));return}const je=ee.trim()||"*";if(ue==="*"&&je==="*"){Be(q),X(""),K("*");return}je==="*"&&ue!=="*"&&q===L?Pe(ue,"*"):Ee(ue,je,q),X(""),K("*")},[L,M,ee,Pe,Be,s,Ee]),Ue=l.useCallback(q=>q==="*"?s("settings.agents.page.permissions.defaultLabel"):q==="webfetch"?"WebFetch":q==="websearch"?"WebSearch":q==="codesearch"?"CodeSearch":q==="doom_loop"?"Doom Loop":q==="external_directory"?"External Directory":q==="todowrite"?"TodoWrite":q==="todoread"?"TodoRead":q.split(/[_-]+/g).filter(Boolean).map(ue=>ue.charAt(0).toUpperCase()+ue.slice(1)).join(" "),[s]);l.useEffect(()=>{X(""),K("*");const q=ue=>{const je=rn(ue),Re=op(je),Ce=lp(je,Re);return E(Re),B(Ce),Q(Ce),{global:Re,rules:Ce}};if(p&&c){const ue=c.name||"",je=c.scope||"user",Re=c.description||"",Ce=c.mode||"subagent",_e=c.model||"",J=c.variant||"",y=c.temperature??void 0,pe=c.top_p??void 0,Ae=c.prompt||"";P(ue),h(je),R(Re),N(Ce),k(_e),b(J),$(y),I(pe),w(Ae);const Oe=nr(c.permission),qe=q(Oe);re.current={draftName:ue,draftScope:je,description:Re,mode:Ce,model:_e,variant:J,temperature:y,topP:pe,prompt:Ae,globalPermission:qe.global,permissionRules:qe.rules};return}if(u&&a===u.name){const ue=u.description||"",je=u.mode||"subagent",Re=u.model?.providerID&&u.model?.modelID?`${u.model.providerID}/${u.model.modelID}`:"",Ce=u.variant||"",_e=u.temperature,J=u.topP,y=u.prompt||"";R(ue),N(je),k(Re),b(Ce),$(_e),I(J),w(y);const pe=q(nr(u.permission));re.current={draftName:"",draftScope:"user",description:ue,mode:je,model:Re,variant:Ce,temperature:_e,topP:J,prompt:y,globalPermission:pe.global,permissionRules:pe.rules}}},[c,p,u,a]);const Je=l.useMemo(()=>{const q=re.current;return q?!!(p&&(m!==q.draftName||g!==q.draftScope)||x!==q.description||C!==q.mode||T!==q.model||j!==q.variant||A!==q.temperature||F!==q.topP||v!==q.prompt||L!==q.globalPermission||!ip(Z,q.permissionRules)):!1},[x,m,g,L,p,C,T,Z,v,A,F,j]),de=async()=>{const q=p?m.trim().replace(/\s+/g,"-"):a?.trim();if(!q){W.error(s("settings.agents.sidebar.toast.agentNameRequired"));return}if(p&&d.some(ue=>ue.name===q)){W.error(s("settings.agents.sidebar.toast.agentExists"));return}ne(!0);try{const ue=T.trim(),je=j.trim(),Re=v.trim(),Ce=cp(L,Z),_e={name:q,description:x.trim()||void 0,mode:C,model:ue===""?null:ue,variant:je===""?null:je||void 0,temperature:A??null,top_p:F??null,prompt:Re||(p?void 0:null),permission:Ce,scope:p?g:void 0};let J;p?(J=await i(_e),J.ok&&f(null)):J=await o(q,_e),J.ok?J.requiresManualRestart?W.warning(s("settings.agents.page.toast.savedManualRestart")):W.success(s(p?"settings.agents.page.toast.created":"settings.agents.page.toast.updated")):W.error(s(p?"settings.agents.page.toast.createFailed":"settings.agents.page.toast.updateFailed"))}catch(ue){console.error("Error saving agent:",ue);const je=ue instanceof Error&&ue.message?ue.message:s("settings.agents.page.toast.saveUnexpectedError");W.error(je)}finally{ne(!1)}};return a?t.jsx(Wt,{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(Ze,{value:m,onChange:q=>P(q.target.value),placeholder:s("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),t.jsxs(Rt,{value:g,onValueChange:q=>h(q),children:[t.jsx(Tt,{className:"w-fit min-w-[100px]",children:t.jsx(Lt,{placeholder:s("settings.agents.page.field.scopePlaceholder")})}),t.jsxs(Ft,{align:"end",children:[t.jsx(gt,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{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(D,{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:x,onChange:q=>R(q.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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(G,{variant:"chip",size:"xs","aria-pressed":C==="primary",onClick:()=>N("primary"),className:"!font-normal",children:s("settings.agents.page.mode.primary")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":C==="subagent",onClick:()=>N("subagent"),className:"!font-normal",children:s("settings.agents.page.mode.subagent")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":C==="all",onClick:()=>N("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(Jr,{providerId:fn(T)?.providerId??"",modelId:fn(T)?.modelId??"",onChange:(q,ue)=>{k(q&&ue?`${q}/${ue}`:""),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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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:we?t.jsxs(Rt,{value:ve,onValueChange:q=>b(q==="__default"?"":q),children:[t.jsx(Tt,{className:ce("max-w-full",e?"w-full":"w-fit min-w-[10rem]"),children:t.jsx(Lt,{placeholder:s("settings.agents.page.field.variantPlaceholder"),children:q=>q==="__default"?s("chat.modelControls.default"):q})}),t.jsxs(Ft,{children:[t.jsx(gt,{value:"__default",children:s("chat.modelControls.default")}),xe.map(q=>t.jsx(gt,{value:q,children:q},q))]})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ze,{value:j,onChange:q=>b(q.target.value),placeholder:s("settings.agents.page.field.variantPlaceholder"),disabled:!T&&!j,className:ce("h-7 w-40",e&&"w-full")}),j&&t.jsx(G,{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(D,{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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(vs,{value:A,fallbackValue:.7,onValueChange:$,onClear:()=>$(void 0),min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),A!==void 0&&t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>$(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(D,{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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(vs,{value:F,fallbackValue:.9,onValueChange:I,onClear:()=>I(void 0),min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),F!==void 0&&t.jsx(G,{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(D,{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:q=>w(q.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(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Y(q=>!q),children:s(O?"settings.agents.page.permissions.hideEditor":"settings.agents.page.permissions.advancedEditor")})]}),O?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(Rt,{value:L,onValueChange:q=>Be(q),children:[t.jsx(Tt,{className:"w-[100px]",children:t.jsx(Lt,{children:Me(L)})}),t.jsxs(Ft,{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:ae.filter(q=>q!=="*").map(q=>{const ue=Ue(q),{defaultAction:je,patternRulesCount:Re}=me(q),Ce=H(q),_e=Ce??"global",J=te(q),y=["allow","ask","deny"].filter(pe=>pe!==L);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:ue}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono",children:q})]}),t.jsx("div",{className:"typography-micro text-muted-foreground",children:Re>0?s("settings.agents.page.permissions.globalSummary",{summary:je}):je})]}),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(G,{size:"sm",variant:"ghost",onClick:()=>Te(q,"*"),className:"px-1.5 py-0 h-5",children:t.jsx(D,{name:"subtract",className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]}),t.jsxs(Rt,{value:_e,onValueChange:pe=>{if(pe==="global"){Pe(q,"*");return}Ee(q,"*",pe)},children:[t.jsx(Tt,{className:"w-[90px]",children:t.jsx(Lt,{children:Ne(_e)})}),t.jsxs(Ft,{children:[t.jsx(gt,{value:"global",children:s("settings.common.scope.global")}),y.map(pe=>t.jsx(gt,{value:pe,className:"capitalize",children:Me(pe)},pe))]})]})]}),J.map(pe=>{const Ae=pn(pe.permission,pe.pattern),Oe=le.get(Ae),qe=!Oe,at=!!(Oe&&Oe.action!==pe.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:pe.pattern}),qe&&t.jsx("span",{className:"typography-micro text-[var(--status-success)]",children:s("settings.common.badge.new")}),at&&t.jsx("span",{className:"typography-micro text-[var(--status-warning)]",children:s("settings.common.badge.modified")}),(qe||at)&&t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>qe?Pe(pe.permission,pe.pattern):Te(pe.permission,pe.pattern),className:"px-1.5 py-0 h-5",children:t.jsx(D,{name:"subtract",className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]}),t.jsxs(Rt,{value:pe.action,onValueChange:rt=>Le(pe.permission,pe.pattern,rt),children:[t.jsx(Tt,{className:"w-[90px]",children:t.jsx(Lt,{children:Me(pe.action)})}),t.jsxs(Ft,{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")})]})]})]},Ae)})]})]},q)})}),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(Rt,{value:M,onValueChange:X,children:[t.jsx(Tt,{className:"w-full sm:w-[160px]",children:M?t.jsx("span",{className:"truncate",children:Ue(M)}):t.jsx("span",{className:"text-muted-foreground",children:s("settings.agents.page.permissions.permissionPlaceholder")})}),t.jsx(Ft,{children:De.map(q=>t.jsx(gt,{value:q,children:t.jsx("div",{className:"flex items-center justify-between gap-2 w-full",children:t.jsx("span",{children:Ue(q)})})},q))})]}),t.jsx(Ze,{value:ee,onChange:q=>K(q.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(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>He("allow"),children:s("settings.common.permission.allow")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>He("ask"),children:s("settings.common.permission.ask")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>He("deny"),children:s("settings.common.permission.deny")})]})]})]})]}):t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-0",children:ae.map((q,ue)=>{const{defaultAction:je,patternRulesCount:Re,patternSummary:Ce,hasDefaultHint:_e}=me(q),J=Ue(q),y=_e?`${je} (env blocked)`:je;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",ue>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:J}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block",children:q})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[Re>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:y})}):t.jsx("span",{className:ce("typography-micro capitalize px-1.5 py-0.5 rounded",y==="allow"?"text-[var(--status-success)] bg-[var(--status-success)]/10":y==="deny"?"text-[var(--status-error)] bg-[var(--status-error)]/10":"text-[var(--status-warning)] bg-[var(--status-warning)]/10"),children:y}),Re>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})})]})]},q)})})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(G,{onClick:de,disabled:U||!Je,size:"xs",className:"!font-normal",children:s(U?"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(D,{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")})]})})},up="~/.config/opencode/AGENTS.md",Kl=async(s,e)=>{const n=await s.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},pp=s=>s.length>0&&!s.endsWith(`
|
|
2
|
-
`)?`${s}
|
|
3
|
-
`:s,ma={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},gp=(s,e)=>s==="custom"?e:Rd(s),hp=s=>s==="custom"?"custom":Nl(s)?s:"concise",Zi={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"},eo=async(s,e)=>{const n=await ht("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(await Kl(n,e))},fp=()=>{const{t:s}=it(),[e,n]=l.useState(""),[a,r]=l.useState(ma.responseStyleEnabled),[i,o]=l.useState(ma.responseStylePreset),[d,c]=l.useState(ma.responseStyleCustomInstructions),[f,u]=l.useState(!0),[p,m]=l.useState(!1),[P,g]=l.useState(""),h=l.useRef(null);l.useEffect(()=>{const N=new AbortController;return(async()=>{try{const[k,j]=await Promise.all([ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},signal:N.signal}),ht("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:N.signal})]);let b=ma;if(k.ok){const A=await k.json();b={...b,responseStyleEnabled:A.responseStyleEnabled===!0,responseStylePreset:hp(A.responseStylePreset),responseStyleCustomInstructions:typeof A.responseStyleCustomInstructions=="string"?A.responseStyleCustomInstructions:""},typeof A.globalBehaviorPrompt=="string"&&(b={...b,prompt:A.globalBehaviorPrompt})}if(!b.prompt.trim()&&j.ok){const A=await j.json();typeof A.content=="string"&&(b={...b,prompt:A.content})}n(b.prompt),r(b.responseStyleEnabled),o(b.responseStylePreset),c(b.responseStyleCustomInstructions),g(b.prompt),h.current={enabled:b.responseStyleEnabled,preset:b.responseStylePreset,custom:b.responseStyleCustomInstructions}}catch(k){k.name!=="AbortError"&&console.warn("Failed to load behavior settings:",k)}finally{u(!1)}})(),()=>N.abort()},[]),l.useEffect(()=>{if(f)return;const N=h.current;if(N&&N.enabled===a&&N.preset===i&&N.custom===d)return;const T={enabled:a,preset:i,custom:d},k=setTimeout(async()=>{try{await eo({responseStyleEnabled:T.enabled,responseStylePreset:T.preset,responseStyleCustomInstructions:T.custom},s("settings.behavior.page.toast.saveFailed")),h.current=T}catch(j){const b=j instanceof Error?j.message:s("settings.behavior.page.toast.saveFailed");W.error(b)}},400);return()=>clearTimeout(k)},[a,i,d,f,s]);const x=gp(i,d),R=e!==P,C=async()=>{m(!0);try{const N=pp(e),T=await ht("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:N})});if(!T.ok)throw new Error(await Kl(T,s("settings.behavior.page.toast.saveFailed")));await eo({globalBehaviorPrompt:N},s("settings.behavior.page.toast.saveFailed")),n(N),g(N),W.success(s("settings.behavior.page.toast.saved"))}catch(N){console.error("Failed to save behavior:",N);const T=N instanceof Error?N.message:s("settings.behavior.page.toast.saveFailed");W.error(T)}finally{m(!1)}};return t.jsx(Wt,{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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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:up})})]})})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsx(hs,{value:e,onChange:N=>n(N.target.value),placeholder:s("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:f,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"}),t.jsx(G,{onClick:C,disabled:p||!R||f,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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(kt,{checked:a,onChange:r,disabled:f,ariaLabel:s("settings.behavior.page.responseStyle.enableAria")}),s("settings.behavior.page.responseStyle.enable")]}),t.jsxs(Rt,{value:i,onValueChange:N=>o(N),disabled:f||!a,children:[t.jsx(Tt,{className:"w-full sm:w-56",size:"lg",children:t.jsx(Lt,{children:N=>N==="custom"?s("settings.behavior.page.responseStyle.option.custom"):Nl(N)?s(Zi[N]):null})}),t.jsxs(Ft,{children:[Md.map(N=>t.jsx(gt,{value:N,children:s(Zi[N])},N)),t.jsx(gt,{value:"custom",children:s("settings.behavior.page.responseStyle.option.custom")})]})]}),t.jsx(hs,{value:x,onChange:N=>c(N.target.value),placeholder:s("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:f||!a||i!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})]})})},xp=s=>{const e=nt.c(169),{onItemSelect:n}=s,{t:a}=it(),[r,i]=l.useState(null),[o,d]=l.useState(""),[c,f]=l.useState(null),[u,p]=l.useState(null),[m,P]=l.useState(!1),[g,h]=l.useState(null),{selectedCommandName:x,commands:R,setSelectedCommand:C,setCommandDraft:N,createCommand:T,deleteCommand:k,loadCommands:j}=$a(Ss(bp)),b=Hs(yp),A=Hs(vp);let $,F;e[0]!==j||e[1]!==A?($=()=>{j(),A()},F=[j,A],e[0]=j,e[1]=A,e[2]=$,e[3]=F):($=e[2],F=e[3]),l.useEffect($,F);let I;e[4]!==b?(I=new Set(b.map(jp)),e[4]=b,e[5]=I):I=e[5];const v=I;let w;if(e[6]!==R||e[7]!==v){let ge;e[9]!==v?(ge=et=>!v.has(et.name),e[9]=v,e[10]=ge):ge=e[10],w=R.filter(ge),e[6]=R,e[7]=v,e[8]=w}else w=e[8];const L=w;let E,_;e[11]!==x||e[12]!==C||e[13]!==v?(E=()=>{x&&v.has(x)&&C(null)},_=[x,C,v],e[11]=x,e[12]=C,e[13]=v,e[14]=E,e[15]=_):(E=e[14],_=e[15]),l.useEffect(E,_);let B;e[16]!==R||e[17]!==n||e[18]!==N||e[19]!==C?(B=()=>{let ge="new-command",et=1;for(;R.some(tt=>tt.name===ge);)ge=`new-command-${et}`,et++;N({name:ge,scope:"user"}),C(ge),n?.()},e[16]=R,e[17]=n,e[18]=N,e[19]=C,e[20]=B):B=e[20];const Z=B;let Q;e[21]!==a?(Q=async ge=>{if(Rn(ge)){W.error(a("settings.commands.sidebar.toast.builtInCannotDelete"));return}f(ge),p("delete")},e[21]=a,e[22]=Q):Q=e[22];const M=Q;let X;e[23]===Symbol.for("react.memo_cache_sentinel")?(X=async ge=>{Rn(ge)&&(f(ge),p("reset"))},e[23]=X):X=e[23];const ee=X;let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{f(null),p(null)},e[24]=K):K=e[24];const O=K;let Y;e[25]!==c||e[26]!==u||e[27]!==k||e[28]!==a?(Y=async()=>{if(!c||!u)return;P(!0),await k(c.name)?(u==="delete"?W.success(a("settings.commands.sidebar.toast.commandDeleted",{name:c.name})):W.success(a("settings.commands.sidebar.toast.commandReset",{name:c.name})),O()):u==="delete"?W.error(a("settings.commands.sidebar.toast.deleteFailed")):W.error(a("settings.commands.sidebar.toast.resetFailed")),P(!1)},e[25]=c,e[26]=u,e[27]=k,e[28]=a,e[29]=Y):Y=e[29];const U=Y;let ne;e[30]!==R||e[31]!==N||e[32]!==C?(ne=ge=>{const et=ge.name;let tt=1,We=`${et}-copy`;for(;R.some(xt=>xt.name===We);)tt++,We=`${et}-copy-${tt}`;N({name:We,scope:ge.scope||"user",description:ge.description,template:ge.template,agent:ge.agent,model:ge.model}),C(We)},e[30]=R,e[31]=N,e[32]=C,e[33]=ne):ne=e[33];const re=ne;let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V=ge=>{d(ge.name),i(ge)},e[34]=V):V=e[34];const oe=V;let fe;e[35]!==R||e[36]!==T||e[37]!==k||e[38]!==r||e[39]!==o||e[40]!==C||e[41]!==a?(fe=async()=>{if(!r)return;const ge=o.trim().replace(/\s+/g,"-");if(!ge){W.error(a("settings.commands.sidebar.toast.commandNameRequired"));return}if(ge===r.name){i(null);return}if(R.some(tt=>tt.name===ge)){W.error(a("settings.commands.sidebar.toast.commandExists"));return}await T({name:ge,description:r.description,template:r.template,agent:r.agent,model:r.model})?await k(r.name)?(W.success(`Command renamed to "${ge}"`),C(ge)):W.error(a("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):W.error(a("settings.commands.sidebar.toast.renameFailed")),i(null)},e[35]=R,e[36]=T,e[37]=k,e[38]=r,e[39]=o,e[40]=C,e[41]=a,e[42]=fe):fe=e[42];const xe=fe;let Ie,ve,we,be,se,le;if(e[43]!==L||e[44]!==Z||e[45]!==M||e[46]!==re||e[47]!==n||e[48]!==g||e[49]!==x||e[50]!==C||e[51]!==a){const ge=L.filter(Rn),et=L.filter(wp);e[58]===Symbol.for("react.memo_cache_sentinel")?(se=ce("flex h-full flex-col","bg-background"),e[58]=se):se=e[58];let tt;e[59]!==a?(tt=a("settings.commands.sidebar.title"),e[59]=a,e[60]=tt):tt=e[60];let We;e[61]!==tt?(We=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:tt}),e[61]=tt,e[62]=We):We=e[62];let xt;e[63]===Symbol.for("react.memo_cache_sentinel")?(xt=t.jsx(sa,{className:"mb-3"}),e[63]=xt):xt=e[63];let wt;e[64]!==L.length||e[65]!==a?(wt=a("settings.commands.sidebar.total",{count:L.length}),e[64]=L.length,e[65]=a,e[66]=wt):wt=e[66];let St;e[67]!==wt?(St=t.jsx("span",{className:"typography-meta text-muted-foreground",children:wt}),e[67]=wt,e[68]=St):St=e[68];let ie;e[69]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),e[69]=ie):ie=e[69];let Ve;e[70]!==Z?(Ve=t.jsx(G,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:Z,children:ie}),e[70]=Z,e[71]=Ve):Ve=e[71];let Qe;e[72]!==St||e[73]!==Ve?(Qe=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[St,Ve]}),e[72]=St,e[73]=Ve,e[74]=Qe):Qe=e[74],e[75]!==We||e[76]!==Qe?(le=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[We,xt,Qe]}),e[75]=We,e[76]=Qe,e[77]=le):le=e[77],Ie=Wt,ve="flex-1 min-h-0",we="space-y-1 px-3 py-2",be=L.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(D,{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:[ge.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")}),[...ge].sort(Np).map(Ge=>t.jsx(to,{command:Ge,isSelected:x===Ge.name,onSelect:()=>{C(Ge.name),n?.()},onReset:()=>ee(Ge),onDuplicate:()=>re(Ge),isMenuOpen:g===Ge.name,onMenuOpenChange:ut=>h(ut?Ge.name:null)},Ge.name))]}),et.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")}),[...et].sort(kp).map(Ge=>t.jsx(to,{command:Ge,isSelected:x===Ge.name,onSelect:()=>{C(Ge.name),n?.()},onRename:()=>oe(Ge),onDelete:()=>M(Ge),onDuplicate:()=>re(Ge),isMenuOpen:g===Ge.name,onMenuOpenChange:ut=>h(ut?Ge.name:null)},Ge.name))]})]}),e[43]=L,e[44]=Z,e[45]=M,e[46]=re,e[47]=n,e[48]=g,e[49]=x,e[50]=C,e[51]=a,e[52]=Ie,e[53]=ve,e[54]=we,e[55]=be,e[56]=se,e[57]=le}else Ie=e[52],ve=e[53],we=e[54],be=e[55],se=e[56],le=e[57];let ye;e[78]!==Ie||e[79]!==ve||e[80]!==we||e[81]!==be?(ye=t.jsx(Ie,{outerClassName:ve,className:we,children:be}),e[78]=Ie,e[79]=ve,e[80]=we,e[81]=be,e[82]=ye):ye=e[82];const H=c!==null&&u!==null;let te;e[83]!==m?(te=ge=>{!ge&&!m&&O()},e[83]=m,e[84]=te):te=e[84];let ae;e[85]!==u||e[86]!==a?(ae=a(u==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[85]=u,e[86]=a,e[87]=ae):ae=e[87];let me;e[88]!==ae?(me=t.jsx(Kt,{children:ae}),e[88]=ae,e[89]=me):me=e[89];let Me;e[90]!==c?.name||e[91]!==u||e[92]!==a?(Me=u==="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]=u,e[92]=a,e[93]=Me):Me=e[93];let Ne;e[94]!==Me?(Ne=t.jsx(Bt,{children:Me}),e[94]=Me,e[95]=Ne):Ne=e[95];let De;e[96]!==me||e[97]!==Ne?(De=t.jsxs($t,{children:[me,Ne]}),e[96]=me,e[97]=Ne,e[98]=De):De=e[98];let Ee;e[99]!==a?(Ee=a("settings.common.actions.cancel"),e[99]=a,e[100]=Ee):Ee=e[100];let Pe;e[101]!==m||e[102]!==Ee?(Pe=t.jsx(G,{size:"sm",variant:"ghost",onClick:O,disabled:m,children:Ee}),e[101]=m,e[102]=Ee,e[103]=Pe):Pe=e[103];let Te;e[104]!==u||e[105]!==a?(Te=a(u==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[104]=u,e[105]=a,e[106]=Te):Te=e[106];let Le;e[107]!==U||e[108]!==m||e[109]!==Te?(Le=t.jsx(G,{size:"sm",onClick:U,disabled:m,children:Te}),e[107]=U,e[108]=m,e[109]=Te,e[110]=Le):Le=e[110];let Be;e[111]!==Pe||e[112]!==Le?(Be=t.jsxs(Jt,{children:[Pe,Le]}),e[111]=Pe,e[112]=Le,e[113]=Be):Be=e[113];let He;e[114]!==De||e[115]!==Be?(He=t.jsxs(zt,{className:"max-w-md",children:[De,Be]}),e[114]=De,e[115]=Be,e[116]=He):He=e[116];let Ue;e[117]!==H||e[118]!==te||e[119]!==He?(Ue=t.jsx(Ot,{open:H,onOpenChange:te,children:He}),e[117]=H,e[118]=te,e[119]=He,e[120]=Ue):Ue=e[120];const Je=r!==null;let de;e[121]===Symbol.for("react.memo_cache_sentinel")?(de=ge=>!ge&&i(null),e[121]=de):de=e[121];let q;e[122]!==a?(q=a("settings.commands.sidebar.renameDialog.title"),e[122]=a,e[123]=q):q=e[123];let ue;e[124]!==q?(ue=t.jsx(Kt,{children:q}),e[124]=q,e[125]=ue):ue=e[125];const je=r?.name??"";let Re;e[126]!==a||e[127]!==je?(Re=a("settings.commands.sidebar.renameDialog.description",{name:je}),e[126]=a,e[127]=je,e[128]=Re):Re=e[128];let Ce;e[129]!==Re?(Ce=t.jsx(Bt,{children:Re}),e[129]=Re,e[130]=Ce):Ce=e[130];let _e;e[131]!==ue||e[132]!==Ce?(_e=t.jsxs($t,{children:[ue,Ce]}),e[131]=ue,e[132]=Ce,e[133]=_e):_e=e[133];let J;e[134]===Symbol.for("react.memo_cache_sentinel")?(J=ge=>d(ge.target.value),e[134]=J):J=e[134];let y;e[135]!==a?(y=a("settings.commands.sidebar.renameDialog.placeholder"),e[135]=a,e[136]=y):y=e[136];let pe;e[137]!==xe?(pe=ge=>{ge.key==="Enter"&&xe()},e[137]=xe,e[138]=pe):pe=e[138];let Ae;e[139]!==o||e[140]!==y||e[141]!==pe?(Ae=t.jsx(Ze,{value:o,onChange:J,placeholder:y,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:pe}),e[139]=o,e[140]=y,e[141]=pe,e[142]=Ae):Ae=e[142];let Oe;e[143]===Symbol.for("react.memo_cache_sentinel")?(Oe=()=>i(null),e[143]=Oe):Oe=e[143];let qe;e[144]!==a?(qe=a("settings.common.actions.cancel"),e[144]=a,e[145]=qe):qe=e[145];let at;e[146]!==qe?(at=t.jsx(G,{size:"sm",variant:"ghost",onClick:Oe,children:qe}),e[146]=qe,e[147]=at):at=e[147];let rt;e[148]!==a?(rt=a("settings.common.actions.rename"),e[148]=a,e[149]=rt):rt=e[149];let st;e[150]!==xe||e[151]!==rt?(st=t.jsx(G,{size:"sm",onClick:xe,children:rt}),e[150]=xe,e[151]=rt,e[152]=st):st=e[152];let dt;e[153]!==at||e[154]!==st?(dt=t.jsxs(Jt,{children:[at,st]}),e[153]=at,e[154]=st,e[155]=dt):dt=e[155];let Ye;e[156]!==_e||e[157]!==Ae||e[158]!==dt?(Ye=t.jsxs(zt,{children:[_e,Ae,dt]}),e[156]=_e,e[157]=Ae,e[158]=dt,e[159]=Ye):Ye=e[159];let $e;e[160]!==Je||e[161]!==Ye?($e=t.jsx(Ot,{open:Je,onOpenChange:de,children:Ye}),e[160]=Je,e[161]=Ye,e[162]=$e):$e=e[162];let mt;return e[163]!==se||e[164]!==le||e[165]!==ye||e[166]!==Ue||e[167]!==$e?(mt=t.jsxs("div",{className:se,children:[le,ye,Ue,$e]}),e[163]=se,e[164]=le,e[165]=ye,e[166]=Ue,e[167]=$e,e[168]=mt):mt=e[168],mt},to=s=>{const e=nt.c(47),{command:n,isSelected:a,onSelect:r,onDelete:i,onReset:o,onRename:d,onDuplicate:c,isMenuOpen:f,onMenuOpenChange:u}=s,{t:p}=it();let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ea(),e[0]=m):m=e[0];const P=m,[g,h]=l.useState(!1);let x;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==o||e[5]!==p?(x=Q=>t.jsxs(t.Fragment,{children:[d&&t.jsxs(Q,{onClick:M=>{M.stopPropagation(),d()},children:[t.jsx(D,{name:"edit",className:"h-4 w-4 mr-px"}),p("settings.common.actions.rename")]}),t.jsxs(Q,{onClick:M=>{M.stopPropagation(),c()},children:[t.jsx(D,{name:"file-copy",className:"h-4 w-4 mr-px"}),p("settings.common.actions.duplicate")]}),o&&t.jsxs(Q,{onClick:M=>{M.stopPropagation(),o()},children:[t.jsx(D,{name:"restart",className:"h-4 w-4 mr-px"}),p("settings.common.actions.reset")]}),i&&t.jsxs(Q,{onClick:M=>{M.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{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]=x):x=e[6];const R=x,C=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==C?(N=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",C),e[7]=C,e[8]=N):N=e[8];let T;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=P?void 0:Q=>{Q.preventDefault(),h(!0)},e[9]=T):T=e[9];let k;e[10]!==N?(k=t.jsx("div",{className:N,onContextMenu:T}),e[10]=N,e[11]=k):k=e[11];let j;e[12]!==n.name?(j=t.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",n.name]}),e[12]=n.name,e[13]=j):j=e[13];let b;e[14]!==n||e[15]!==p?(b=(n.scope||Rn(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:Rn(n)?p("settings.agents.sidebar.badge.system"):n.scope}),e[14]=n,e[15]=p,e[16]=b):b=e[16];let A;e[17]!==j||e[18]!==b?(A=t.jsxs("div",{className:"flex items-center gap-2",children:[j,b]}),e[17]=j,e[18]=b,e[19]=A):A=e[19];let $;e[20]!==n.description?($=n.description&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n.description}),e[20]=n.description,e[21]=$):$=e[21];let F;e[22]!==r||e[23]!==$||e[24]!==A?(F=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:[A,$]}),e[22]=r,e[23]=$,e[24]=A,e[25]=F):F=e[25];let I;e[26]!==u?(I=Q=>{Q&&h(!1),u(Q)},e[26]=u,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(G,{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(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=v):v=e[28];let w;e[29]!==R?(w=t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:R(js)}),e[29]=R,e[30]=w):w=e[30];let L;e[31]!==f||e[32]!==I||e[33]!==w?(L=t.jsxs(gs,{open:f,onOpenChange:I,children:[v,w]}),e[31]=f,e[32]=I,e[33]=w,e[34]=L):L=e[34];let E;e[35]!==F||e[36]!==L?(E=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[F,L]}),e[35]=F,e[36]=L,e[37]=E):E=e[37];let _;e[38]!==E||e[39]!==k?(_=t.jsx(nn,{render:k,children:E}),e[38]=E,e[39]=k,e[40]=_):_=e[40];let B;e[41]!==R?(B=t.jsx(an,{className:"w-fit min-w-20",children:R(qs)}),e[41]=R,e[42]=B):B=e[42];let Z;return e[43]!==g||e[44]!==_||e[45]!==B?(Z=t.jsxs(sn,{open:g,onOpenChange:h,children:[_,B]}),e[43]=g,e[44]=_,e[45]=B,e[46]=Z):Z=e[46],Z};function bp(s){return{selectedCommandName:s.selectedCommandName,commands:s.commands,setSelectedCommand:s.setSelectedCommand,setCommandDraft:s.setCommandDraft,createCommand:s.createCommand,deleteCommand:s.deleteCommand,loadCommands:s.loadCommands}}function yp(s){return s.skills}function vp(s){return s.loadSkills}function jp(s){return s.name}function wp(s){return!Rn(s)}function Np(s,e){return s.name.localeCompare(e.name)}function kp(s,e){return s.name.localeCompare(e.name)}const Sp=()=>{const{t:s}=it(),{selectedCommandName:e,getCommandByName:n,createCommand:a,updateCommand:r,commands:i,commandDraft:o,setCommandDraft:d}=$a(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,f=!!(o&&o.name===e&&!c),[u,p]=l.useState(""),[m,P]=l.useState("user"),[g,h]=l.useState(""),[x,R]=l.useState(""),[C,N]=l.useState(""),[T,k]=l.useState(""),[j,b]=l.useState(!1),A=l.useRef(null);l.useEffect(()=>{if(f&&o){const I=o.name||"",v=o.scope||"user",w=o.description||"",L=o.agent||"",E=o.model||"",_=o.template||"";p(I),P(v),h(w),R(L),N(E),k(_),A.current={draftName:I,draftScope:v,description:w,agent:L,model:E,template:_}}else if(c){const I=c.description||"",v=c.agent||"",w=c.model||"",L=c.template||"";h(I),R(v),N(w),k(L),A.current={draftName:"",draftScope:"user",description:I,agent:v,model:w,template:L}}},[c,f,e,i,o]);const $=l.useMemo(()=>{const I=A.current;return I?!!(f&&(u!==I.draftName||m!==I.draftScope)||g!==I.description||x!==I.agent||C!==I.model||T!==I.template):!1},[x,g,u,m,f,C,T]),F=async()=>{const I=f?u.trim().replace(/\s+/g,"-"):e?.trim();if(!I){W.error(s("settings.commands.sidebar.toast.commandNameRequired"));return}if(!T.trim()){W.error(s("settings.commands.page.toast.templateRequired"));return}if(f&&i.some(v=>v.name===I)){W.error(s("settings.commands.sidebar.toast.commandExists"));return}b(!0);try{const v=x.trim(),w=C.trim(),L=T.trim(),E={name:I,description:g.trim()||void 0,agent:v===""?null:v,model:w===""?null:w,template:L,scope:f?m:void 0};let _;f?(_=await a(E),_&&d(null)):_=await r(I,E),_?W.success(s(f?"settings.commands.page.toast.created":"settings.commands.page.toast.updated")):W.error(s(f?"settings.commands.page.toast.createFailed":"settings.commands.page.toast.updateFailed"))}catch(v){console.error("Error saving command:",v),W.error(s("settings.commands.page.toast.saveUnexpectedError"))}finally{b(!1)}};return e?t.jsx(Wt,{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:f?s("settings.commands.page.title.new"):`/${e}`}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:s(f?"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:[f&&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(Ze,{value:u,onChange:I=>p(I.target.value),placeholder:s("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),t.jsxs(Rt,{value:m,onValueChange:I=>P(I),children:[t.jsx(Tt,{className:"w-fit min-w-[100px]",children:t.jsx(Lt,{placeholder:s("settings.agents.page.field.scopePlaceholder")})}),t.jsxs(Ft,{align:"end",children:[t.jsx(gt,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{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(D,{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:g,onChange:I=>h(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(kl,{agentName:x,onChange:I=>R(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(Jr,{providerId:fn(C)?.providerId??"",modelId:fn(C)?.modelId??"",onChange:(I,v)=>{N(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:T,onChange:I=>k(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(G,{onClick:F,disabled:j||!$,size:"xs",className:"!font-normal",children:s(j?"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(D,{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")})]})})},so=s=>{switch(s){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"idle"}},no=s=>{const e=nt.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},Cp=s=>{const e=nt.c(120),{onItemSelect:n}=s,{t:a}=it(),{mcpServers:r,selectedMcpName:i,setSelectedMcp:o,setMcpDraft:d,loadMcpConfigs:c,deleteMcp:f}=Ln(Ss(Pp)),u=bs(Ip);let p;e[0]!==u?(p=Ce=>Ce.getStatusForDirectory(u??null),e[0]=u,e[1]=p):p=e[1];const m=os(p),P=os(Ap),g=os(Dp),[h,x]=l.useState(null),[R,C]=l.useState(!1),[N,T]=l.useState(null),[k,j]=l.useState(null),[b,A]=l.useState(!1);let $;e[2]!==r?($=r.filter(Ep),e[2]=r,e[3]=$):$=e[3];const F=$;let I;e[4]!==r?(I=r.filter(Mp),e[4]=r,e[5]=I):I=e[5];const v=I;let w,L;e[6]!==c?(w=()=>{c()},L=[c],e[6]=c,e[7]=w,e[8]=L):(w=e[7],L=e[8]),l.useEffect(w,L);let E;e[9]!==u||e[10]!==g||e[11]!==b||e[12]!==P?(E=()=>{if(b)return;A(!0);const Ce=new Promise(Rp);Promise.all([P({directory:u,silent:!0}),Ce]).then(()=>{const _e=g(u);_e&&W.error(_e)}).finally(()=>{A(!1)})},e[9]=u,e[10]=g,e[11]=b,e[12]=P,e[13]=E):E=e[13];const _=E;let B;e[14]!==r||e[15]!==n||e[16]!==d||e[17]!==o?(B=()=>{let Ce="new-mcp-server",_e=1;for(;r.some(y=>y.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]=B):B=e[18];const Z=B;let Q;e[19]!==f||e[20]!==h||e[21]!==a?(Q=async()=>{if(!h)return;C(!0);const Ce=await f(h.name);Ce.ok?Ce.reloadFailed?W.warning(Ce.message||`MCP server "${h.name}" deleted, but OpenCode reload failed`,{description:Ce.warning||a("settings.mcp.sidebar.toast.refreshListIfStale")}):W.success(Ce.message||a("settings.mcp.sidebar.toast.serverDeleted",{name:h.name})):W.error(a("settings.mcp.sidebar.toast.deleteFailed")),x(null),C(!1)},e[19]=f,e[20]=h,e[21]=a,e[22]=Q):Q=e[22];const M=Q;let X;e[23]!==a?(X=(Ce,_e)=>t.jsxs(_e,{onClick:J=>{J.stopPropagation(),x(Ce)},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]}),e[23]=a,e[24]=X):X=e[24];const ee=X;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=ce("flex h-full flex-col","bg-background"),e[25]=K):K=e[25];let O;e[26]!==a?(O=a("settings.mcp.sidebar.title"),e[26]=a,e[27]=O):O=e[27];let Y;e[28]!==O?(Y=t.jsx("h2",{className:"text-base font-semibold text-foreground",children:O}),e[28]=O,e[29]=Y):Y=e[29];let U;e[30]!==a?(U=a("settings.mcp.sidebar.actions.refreshStatusAria"),e[30]=a,e[31]=U):U=e[31];let ne;e[32]!==a?(ne=a("settings.mcp.sidebar.actions.refreshStatusTitle"),e[32]=a,e[33]=ne):ne=e[33];const re=b&&"animate-spin";let V;e[34]!==re?(V=ce("h-4 w-4",re),e[34]=re,e[35]=V):V=e[35];let oe;e[36]!==V?(oe=t.jsx(D,{name:"refresh",className:V}),e[36]=V,e[37]=oe):oe=e[37];let fe;e[38]!==_||e[39]!==b||e[40]!==U||e[41]!==ne||e[42]!==oe?(fe=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:_,"aria-label":U,title:ne,children:oe}),e[38]=_,e[39]=b,e[40]=U,e[41]=ne,e[42]=oe,e[43]=fe):fe=e[43];let xe;e[44]!==Y||e[45]!==fe?(xe=t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[Y,fe]}),e[44]=Y,e[45]=fe,e[46]=xe):xe=e[46];let Ie;e[47]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx(sa,{className:"mb-3"}),e[47]=Ie):Ie=e[47];let ve;e[48]!==r.length||e[49]!==a?(ve=a("settings.mcp.sidebar.total",{count:r.length}),e[48]=r.length,e[49]=a,e[50]=ve):ve=e[50];let we;e[51]!==ve?(we=t.jsx("span",{className:"typography-meta text-muted-foreground",children:ve}),e[51]=ve,e[52]=we):we=e[52];let be;e[53]!==a?(be=a("settings.mcp.sidebar.actions.addServerTitle"),e[53]=a,e[54]=be):be=e[54];let se;e[55]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),e[55]=se):se=e[55];let le;e[56]!==Z||e[57]!==be?(le=t.jsx(G,{size:"sm","data-settings-item":"mcp.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:Z,title:be,children:se}),e[56]=Z,e[57]=be,e[58]=le):le=e[58];let ye;e[59]!==we||e[60]!==le?(ye=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[we,le]}),e[59]=we,e[60]=le,e[61]=ye):ye=e[61];let H;e[62]!==xe||e[63]!==ye?(H=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[xe,Ie,ye]}),e[62]=xe,e[63]=ye,e[64]=H):H=e[64];let te;e[65]!==r.length||e[66]!==m||e[67]!==n||e[68]!==N||e[69]!==F||e[70]!==ee||e[71]!==k||e[72]!==i||e[73]!==d||e[74]!==o||e[75]!==a||e[76]!==v?(te=t.jsx(Wt,{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(D,{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:[F.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")}),F.map(Ce=>{const _e=m[Ce.name],J=so(_e?.status),y=i===Ce.name,pe=ea();return t.jsxs(sn,{open:k===Ce.name,onOpenChange:Ae=>j(Ae?Ce.name:null),children:[t.jsxs(nn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:pe?void 0:Ae=>{Ae.preventDefault(),j(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(no,{tone:J,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(D,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):t.jsx(D,{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:N===Ce.name,onOpenChange:Ae=>{Ae&&j(null),T(Ae?Ce.name:null)},children:[t.jsx(us,{asChild:!0,children:t.jsx(G,{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(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:ee(Ce,js)})]})]}),t.jsx(an,{className:"w-fit min-w-20",children:ee(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=m[Ce.name],J=so(_e?.status),y=i===Ce.name,pe=ea();return t.jsxs(sn,{open:k===Ce.name,onOpenChange:Ae=>j(Ae?Ce.name:null),children:[t.jsxs(nn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:pe?void 0:Ae=>{Ae.preventDefault(),j(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(no,{tone:J,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(D,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):t.jsx(D,{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:N===Ce.name,onOpenChange:Ae=>{Ae&&j(null),T(Ae?Ce.name:null)},children:[t.jsx(us,{asChild:!0,children:t.jsx(G,{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(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:ee(Ce,js)})]})]}),t.jsx(an,{className:"w-fit min-w-20",children:ee(Ce,qs)})]},Ce.name)})]})]})}),e[65]=r.length,e[66]=m,e[67]=n,e[68]=N,e[69]=F,e[70]=ee,e[71]=k,e[72]=i,e[73]=d,e[74]=o,e[75]=a,e[76]=v,e[77]=te):te=e[77];const ae=h!==null;let me;e[78]!==R?(me=Ce=>{!Ce&&!R&&x(null)},e[78]=R,e[79]=me):me=e[79];let Me;e[80]!==a?(Me=a("settings.mcp.sidebar.deleteDialog.title"),e[80]=a,e[81]=Me):Me=e[81];let Ne;e[82]!==Me?(Ne=t.jsx(Kt,{children:Me}),e[82]=Me,e[83]=Ne):Ne=e[83];const De=h?.name||"";let Ee;e[84]!==a||e[85]!==De?(Ee=a("settings.mcp.sidebar.deleteDialog.descriptionPrefix",{name:De}),e[84]=a,e[85]=De,e[86]=Ee):Ee=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]!==Ee?(Te=t.jsxs(Bt,{children:[Ee," ",Pe,"."]}),e[88]=Ee,e[89]=Te):Te=e[89];let Le;e[90]!==Ne||e[91]!==Te?(Le=t.jsxs($t,{children:[Ne,Te]}),e[90]=Ne,e[91]=Te,e[92]=Le):Le=e[92];let Be;e[93]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>x(null),e[93]=Be):Be=e[93];let He;e[94]!==a?(He=a("settings.common.actions.cancel"),e[94]=a,e[95]=He):He=e[95];let Ue;e[96]!==R||e[97]!==He?(Ue=t.jsx(G,{size:"sm",variant:"ghost",onClick:Be,disabled:R,children:He}),e[96]=R,e[97]=He,e[98]=Ue):Ue=e[98];let Je;e[99]!==R||e[100]!==a?(Je=a(R?"settings.mcp.sidebar.actions.deleting":"settings.common.actions.delete"),e[99]=R,e[100]=a,e[101]=Je):Je=e[101];let de;e[102]!==M||e[103]!==R||e[104]!==Je?(de=t.jsx(G,{size:"sm",onClick:M,disabled:R,children:Je}),e[102]=M,e[103]=R,e[104]=Je,e[105]=de):de=e[105];let q;e[106]!==Ue||e[107]!==de?(q=t.jsxs(Jt,{children:[Ue,de]}),e[106]=Ue,e[107]=de,e[108]=q):q=e[108];let ue;e[109]!==Le||e[110]!==q?(ue=t.jsxs(zt,{className:"max-w-md",children:[Le,q]}),e[109]=Le,e[110]=q,e[111]=ue):ue=e[111];let je;e[112]!==ae||e[113]!==me||e[114]!==ue?(je=t.jsx(Ot,{open:ae,onOpenChange:me,children:ue}),e[112]=ae,e[113]=me,e[114]=ue,e[115]=je):je=e[115];let Re;return e[116]!==H||e[117]!==te||e[118]!==je?(Re=t.jsxs("div",{className:K,children:[H,te,je]}),e[116]=H,e[117]=te,e[118]=je,e[119]=Re):Re=e[119],Re};function Pp(s){return{mcpServers:s.mcpServers,selectedMcpName:s.selectedMcpName,setSelectedMcp:s.setSelectedMcp,setMcpDraft:s.setMcpDraft,loadMcpConfigs:s.loadMcpConfigs,deleteMcp:s.deleteMcp}}function Ip(s){return s.currentDirectory}function Ap(s){return s.refresh}function Dp(s){return s.getErrorForDirectory}function Ep(s){return s.scope==="project"}function Mp(s){return s.scope!=="project"}function Rp(s){return setTimeout(s,500)}function Ls(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function Hn(s){return Array.isArray(s)&&s.every(e=>typeof e=="string")}function Ts(s,e){return e!==void 0?{ok:!1,error:s,parsed:e}:{ok:!1,error:s}}function ua(s,e,n){const a=Tp(n),r=typeof n.url=="string"?n.url.trim():"",i=ao(n,"env","environment"),o=ao(n,"headers"),d=Fp(n),c=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.clientId??"").trim():"",f=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.clientSecret??"").trim():"",u=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():"",m=Lp(n),P=Op(n);return{ok:!0,name:s,type:e,command:a,url:r,environment:i,headers:o,oauthEnabled:d,oauthClientId:c,oauthClientSecret:f,oauthScope:u,oauthRedirectUri:p,timeout:m,enabled:P}}function Tp(s){const e=s.command,n=s.args;if(Hn(e)&&Hn(n))return[...e,...n];if(Hn(e))return e;if(typeof e=="string"&&e.trim()){const a=e.trim().split(/\s+/);return Hn(n)?[...a,...n]:a}return Hn(n)?n:[]}function ao(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 Fp(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 Lp(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 Op(s){return"disabled"in s&&s.disabled===!0?!1:"enabled"in s?!!s.enabled:!0}function zp(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($l(r))return{name:a,entry:r}}return null}function $l(s){return s.type==="local"||s.type==="remote"||Array.isArray(s.command)||typeof s.url=="string"||Array.isArray(s.args)}function Kp(s,e){let n;try{const d=s.trim();if(!d)return Ts("No JSON content provided");n=JSON.parse(d)}catch(d){return Ts(d instanceof Error?`Invalid JSON: ${d.message}`:"Invalid JSON")}if(!Ls(n))return Ts("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 Ts("mcpServers object is empty",n);if(d.length>1)return Ts("Paste one server at a time. Found "+d.length+" servers in mcpServers",n);const c=d[0],f=r[c];return Ls(f)?ua(c,pa(f),f):Ts("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 Ts("mcp object is empty",n);if(d.length>1)return Ts("Paste one server at a time. Found "+d.length+" servers in mcp",n);const c=d[0],f=i[c];return Ls(f)?ua(c,pa(f),f):Ts("Server entry in mcp is not a valid object",n)}const o=zp(a);if(o)return ua(o.name,pa(o.entry),o.entry);if($l(a)){const d=pa(a),c=typeof a.name=="string"&&a.name.trim()?a.name.trim():e?.fallbackName;return ua(c,d,a)}return Ts("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 $p(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 Up="/mcp/oauth/callback",Bp=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}},Vp=s=>{const e=_p(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}},Ul=s=>{const e=s.get("state");return typeof e!="string"?null:e.trim()||null},_p=s=>{if(typeof s!="string"||!s.trim())return null;const e=Bp(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}},xn=Tc,bn=s=>{const e=nt.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&&he.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 f;return e[10]!==i||e[11]!==d||e[12]!==c?(f=t.jsx(Rc,{className:c,...i,...d}),e[10]=i,e[11]=d,e[12]=c,e[13]=f):f=e[13],f},yn=s=>{const e=nt.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(Fc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i};function Hp(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 Wp(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:Vp(n.searchParams),stateKey:Ul(n.searchParams)}}catch{}return{code:e,context:null,stateKey:null}}const qp=({value:s,onChange:e,pasteCommandTitle:n,pasteCommandLabel:a,pasteSuccess:r,clipboardReadFailed:i,preview:o})=>{const[d,c]=l.useState(()=>s.join(`
|
|
4
|
-
`)),f=l.useRef(s);l.useEffect(()=>{JSON.stringify(f.current)!==JSON.stringify(s)&&(f.current=s,c(s.join(`
|
|
5
|
-
`)))},[s]);const u=m=>{const P=m.split(`
|
|
6
|
-
`).filter(g=>g.trim().length>0);e(P)},p=async()=>{try{const P=(await navigator.clipboard.readText()).trim(),g=P.includes(`
|
|
7
|
-
`)?P.split(`
|
|
8
|
-
`).filter(h=>h.trim()):Hp(P);c(g.join(`
|
|
9
|
-
`)),e(g),W.success(r(g.length))}catch{W.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(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:p,type:"button",title:n,children:[t.jsx(D,{name:"clipboard",className:"h-3 w-3"}),a]})}),t.jsx(hs,{value:d,onChange:m=>{c(m.target.value),u(m.target.value)},onBlur:()=>{const m=d.split(`
|
|
10
|
-
`).map(P=>P.trimEnd()).join(`
|
|
11
|
-
`);c(m),u(m)},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((m,P)=>t.jsxs("span",{className:"block",children:[t.jsxs("span",{className:"text-muted-foreground select-none mr-2",children:["[",P,"]"]}),m]},P))})})]})]})},Gp=s=>s.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),ro=({value:s,onChange:e,keyTransform:n=Gp,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:f,keyLabel:u,valueLabel:p,valuePlaceholder:m,hideValueTitle:P,showValueTitle:g,addVariable:h,plainTextWarning:x,removeVariableAria:R})=>{const[C,N]=l.useState(new Set),T=()=>e([...s,{key:"",value:""}]),k=F=>{e(s.filter((I,v)=>v!==F)),N(I=>{const v=new Set(I);return v.delete(F),v})},j=(F,I,v)=>{const w=[...s];w[F]={...w[F],[I]:v},e(w)},b=F=>{N(I=>{const v=new Set(I);return v.has(F)?v.delete(F):v.add(F),v})},A=async()=>{try{const F=await navigator.clipboard.readText(),I=[];for(const w of F.split(`
|
|
15
|
-
`)){const L=w.trim();if(!L||L.startsWith("#"))continue;const E=L.indexOf("=");if(E===-1)continue;const _=L.slice(0,E).trim();let B=L.slice(E+1).trim();(B.startsWith('"')&&B.endsWith('"')||B.startsWith("'")&&B.endsWith("'"))&&(B=B.slice(1,-1)),_&&I.push({key:_,value:B})}if(I.length===0){W.error(d);return}const v=[...s];for(const w of I){const L=v.findIndex(E=>E.key===w.key);L!==-1?v[L]=w:v.push(w)}e(v),W.success(c(I.length))}catch{W.error(f)}},$=s.some(F=>F.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:u}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:p})]}),t.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:A,type:"button",title:o,children:[t.jsx(D,{name:"clipboard",className:"h-3 w-3"}),i]})]}),t.jsx("div",{className:"space-y-1.5",children:s.map((F,I)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ze,{value:F.key,onChange:v=>j(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(Ze,{type:C.has(I)?"text":"password",value:F.value,onChange:v=>j(I,"value",v.target.value),placeholder:m,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:C.has(I)?P:g,children:C.has(I)?t.jsx(D,{name:"eye-off",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"eye",className:"h-3.5 w-3.5"})})]}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>k(I),"aria-label":R,children:t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},I))}),t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:T,type:"button",children:[t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),h]}),$&&t.jsx("p",{className:"typography-micro text-muted-foreground/60",children:x})]})},io=s=>{const e=nt.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 m={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 P=ce("typography-micro font-medium rounded-full px-2 py-0.5",m.text,m.bg);let g;e[5]!==r||e[6]!==n?(g=r(n),e[5]=r,e[6]=n,e[7]=g):g=e[7],c=t.jsxs("span",{className:P,children:["● ",g]});break e}d=ce("typography-micro font-medium",m.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 f;e[8]!==r||e[9]!==n?(f=r(n),e[8]=r,e[9]=n,e[10]=f):f=e[10];let u;return e[11]!==d||e[12]!==f?(u=t.jsxs("span",{className:d,children:["● ",f]}),e[11]=d,e[12]=f,e[13]=u):u=e[13],u},Jp=(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")}},Qp=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)]"}},Yp=(s,e,n,a)=>!!(s==="failed"||s==="needs_auth"||s==="needs_client_registration"||e||n||a),oo=(s,e)=>{if(typeof window>"u")return null;const n=new URL(Up,Kn()||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()},Xp=async s=>{const e=await ht("/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")}},Zp=async s=>{const e=await ht(`/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},Wn=async s=>{typeof s!="string"||!s.trim()||await ht(`/api/mcp/auth/pending?state=${encodeURIComponent(s.trim())}`,{method:"DELETE"}).catch(()=>{})},ar=(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},eg=(s,e)=>{const n=typeof e=="string"&&e.trim()?e.trim():"__global__";return`${s??"__none__"}::${n}`},tg=()=>{const{t:s}=it(),e=l.useCallback((Se,yt)=>s(Se,yt),[s]),{selectedMcpName:n,mcpServers:a,mcpDraft:r,setMcpDraft:i,setSelectedMcp:o,getMcpByName:d,createMcp:c,updateMcp:f,deleteMcp:u}=Ln(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=bs(Se=>Se.currentDirectory),m=l.useMemo(()=>fs(),[]),P=os(Se=>Se.getStatusForDirectory(p??null)),g=os(Se=>Se.getDiagnosticForDirectory(p??null)),h=os(Se=>Se.refresh),x=os(Se=>Se.connect),R=os(Se=>Se.disconnect),C=os(Se=>Se.startAuth),N=os(Se=>Se.completeAuth),T=os(Se=>Se.clearAuth),k=os(Se=>Se.testConnection),j=n?d(n):null,b=!!(r&&r.name===n&&!j),[A,$]=l.useState(""),[F,I]=l.useState("user"),[v,w]=l.useState("local"),[L,E]=l.useState([]),[_,B]=l.useState(""),[Z,Q]=l.useState([]),[M,X]=l.useState([]),[ee,K]=l.useState(!0),[O,Y]=l.useState(""),[U,ne]=l.useState(""),[re,V]=l.useState(""),[oe,fe]=l.useState(""),[xe,Ie]=l.useState(""),[ve,we]=l.useState(!0),[be,se]=l.useState(!1),[le,ye]=l.useState(!1),[H,te]=l.useState(!1),[ae,me]=l.useState(!1),[Me,Ne]=l.useState(!1),[De,Ee]=l.useState(!1),[Pe,Te]=l.useState(!1),[Le,Be]=l.useState(!1),[He,Ue]=l.useState(null),[Je,de]=l.useState(null),[q,ue]=l.useState(""),[je,Re]=l.useState(!1),Ce=l.useRef(0),_e=l.useRef(!1),[J,y]=l.useState(!1),[pe,Ae]=l.useState(!1),[Oe,qe]=l.useState(""),[at,rt]=l.useState(null),st=l.useMemo(()=>eg(n,p),[p,n]),dt=l.useRef(st),Ye=l.useRef(null),$e=l.useCallback(()=>{Ue(null),de(null),ue(""),Re(!1),Ce.current=0,Be(!1),Ne(!1),Ee(!1),_e.current=!1},[]),mt=l.useCallback(()=>{qe(""),rt(null),Ae(!0)},[]),ge=l.useCallback(async()=>{try{const Se=await navigator.clipboard.readText();qe(Se),rt(null)}catch{W.error(s("settings.mcp.page.toast.clipboardReadFailed"))}},[s]),et=l.useCallback(()=>{const Se=Kp(Oe,{fallbackName:A});if(!Se.ok){rt(Se.error);return}const jt=$p(Se,{name:A,scope:F,type:v,command:L,url:_,environment:Z,headers:M,oauthEnabled:ee,oauthClientId:O,oauthClientSecret:U,oauthScope:re,oauthRedirectUri:oe,timeout:xe,enabled:ve},{isNewServer:b});$(jt.name),w(jt.type),E(jt.command??[]),B(jt.url??""),Q(jt.environment??[]),X(jt.headers??[]),K(jt.oauthEnabled??!1),Y(jt.oauthClientId??""),ne(jt.oauthClientSecret??""),V(jt.oauthScope??""),fe(jt.oauthRedirectUri??""),Ie(jt.timeout??""),we(jt.enabled??!0),Ae(!1),qe(""),rt(null),W.success(s("settings.mcp.page.toast.configImported"))},[Oe,A,F,v,L,_,Z,M,ee,O,U,re,oe,xe,ve,b,s]);l.useEffect(()=>{if(b&&r){$(r.name),I(r.scope||"user"),w(r.type),E(r.command),B(r.url),Q(r.environment),X(r.headers),K(r.oauthEnabled),Y(r.oauthClientId),ne(r.oauthClientSecret),V(r.oauthScope),fe(r.oauthRedirectUri),Ie(r.timeout),we(r.enabled),y(!1),Ye.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(j){I(j.scope==="project"?"project":"user");const Se=Li(j.environment),yt=j.type==="remote"?j:null,jt=Li(yt?.headers),Xe=yt?.oauth,Nt=Xe&&typeof Xe=="object"?Xe:null,Vt=Xe!==!1,Qt=j.type,rs=Qt==="local"?j.command??[]:[],Rs=Qt==="remote"?j.url??"":"",cs=typeof yt?.timeout=="number"&&Number.isFinite(yt.timeout)?String(yt.timeout):"";w(Qt),E(rs),B(Rs),Q(Se),X(jt),K(Vt),Y(Vt?Nt?.clientId??"":""),ne(Vt?Nt?.clientSecret??"":""),V(Vt?Nt?.scope??"":""),fe(Vt?Nt?.redirectUri??"":""),Ie(cs),we(j.enabled),y(!1),Ye.current={mcpType:Qt,command:rs,url:Rs,envEntries:Se,headerEntries:jt,oauthEnabled:Vt,oauthClientId:Vt?Nt?.clientId??"":"",oauthClientSecret:Vt?Nt?.clientSecret??"":"",oauthScope:Vt?Nt?.scope??"":"",oauthRedirectUri:Vt?Nt?.redirectUri??"":"",timeout:cs,enabled:j.enabled}}},[j,b,r]);const tt=l.useMemo(()=>{const Se=Ye.current;return Se?v!==Se.mcpType||ve!==Se.enabled||JSON.stringify(L)!==JSON.stringify(Se.command)||_!==Se.url||JSON.stringify(Z)!==JSON.stringify(Se.envEntries)||JSON.stringify(M)!==JSON.stringify(Se.headerEntries)||ee!==Se.oauthEnabled||O!==Se.oauthClientId||U!==Se.oauthClientSecret||re!==Se.oauthScope||oe!==Se.oauthRedirectUri||xe!==Se.timeout:!1},[v,L,_,Z,M,ee,O,U,re,oe,xe,ve]),We=async()=>{const Se=b?A.trim():n??"";if(!Se){W.error(s("settings.mcp.page.toast.nameRequired"));return}if(b&&a.some(jt=>jt.name===Se)){W.error(s("settings.mcp.page.toast.serverNameExists"));return}if(v==="local"&&L.filter(Boolean).length===0){W.error(s("settings.mcp.page.toast.localCommandRequired"));return}if(v==="remote"&&!_.trim()){W.error(s("settings.mcp.page.toast.remoteUrlRequired"));return}const yt={name:Se,scope:F,type:v,command:L,url:_,environment:Z,headers:M,oauthEnabled:ee,oauthClientId:O,oauthClientSecret:U,oauthScope:re,oauthRedirectUri:oe,timeout:xe,enabled:ve};se(!0);try{const jt=b?await c(yt):await f(Se,yt);jt.ok?(await Wn(Je),$e(),b&&(i(null),o(Se)),await h({directory:p,silent:!0}),jt.reloadFailed?W.warning(jt.message||s(b?"settings.mcp.page.toast.serverCreatedReloadFailed":"settings.mcp.page.toast.savedReloadFailed"),{description:jt.warning||s("settings.mcp.page.toast.retryRefreshHint")}):W.success(jt.message||s(b?"settings.mcp.page.toast.serverCreatedReloading":"settings.mcp.page.toast.savedReloading"))):W.error(s("settings.mcp.page.toast.saveFailed"))}catch(jt){W.error(jt instanceof Error?jt.message:s("settings.mcp.page.toast.unexpectedError"))}finally{se(!1)}},xt=async()=>{if(!n)return;te(!0);const Se=await u(n);Se.ok?(await Wn(Je),$e(),Se.reloadFailed?W.warning(Se.message||s("settings.mcp.page.toast.serverDeletedReloadFailed",{name:n}),{description:Se.warning||s("settings.mcp.page.toast.refreshListIfStale")}):W.success(Se.message||s("settings.mcp.page.toast.serverDeleted",{name:n})),ye(!1)):W.error(s("settings.mcp.page.toast.deleteFailed")),te(!1)},wt=async()=>{if(n){me(!0);try{if(P[n]?.status==="connected")await R(n,p),W.success(s("settings.mcp.page.toast.disconnected"));else{await x(n,p),await h({directory:p,silent:!0});const yt=os.getState().getStatusForDirectory(p??null)[n];yt?.status==="connected"?W.success(s("settings.mcp.page.toast.connected")):yt?.status==="needs_auth"?W.message(s("settings.mcp.page.toast.connectionNeedsAuthorization")):yt?.status==="needs_client_registration"?W.message(s("settings.mcp.page.toast.connectionNeedsClientRegistration")):yt?.status==="failed"?W.error(yt.error||s("settings.mcp.page.toast.connectionFailed")):W.message(s("settings.mcp.page.toast.connectionAttemptFinished"));return}await h({directory:p,silent:!0})}catch(Se){W.error(Se instanceof Error?Se.message:s("settings.mcp.page.toast.connectionFailed"))}finally{me(!1)}}},St=l.useCallback(()=>b?(W.error(s("settings.mcp.page.toast.createServerBeforeLiveActions")),!1):tt?(W.error(s("settings.mcp.page.toast.saveBeforeLiveActions")),!1):!0,[tt,b,s]),ie=l.useCallback(async(Se=!1)=>{try{await h({directory:p,silent:Se})}catch(yt){Se||W.error(yt instanceof Error?yt.message:s("settings.mcp.page.toast.refreshStatusFailed"))}},[p,h,s]);l.useEffect(()=>{ie(!0)},[ie]),l.useEffect(()=>{dt.current=st,me(!1),Te(!1),$e()},[$e,st]);const Ve=l.useCallback(async()=>{if(!n||v!=="remote"||!St())return;Ne(!0);const Se=st;let yt=null;try{const jt=os.getState().getStatusForDirectory(p??null)[n]?.status;_e.current=jt==="needs_auth"||jt==="needs_client_registration";const Xe=oo(n,p);if(!Xe)throw new Error(s("settings.mcp.page.toast.oauthRedirectUrlBuildFailed"));if(!oe.trim()&&!m){const rs=await f(n,{oauthEnabled:ee,oauthClientId:O,oauthClientSecret:U,oauthScope:re,oauthRedirectUri:Xe});if(!rs.ok)throw new Error(s("settings.mcp.page.toast.oauthBrowserCallbackSaveFailed"));if(rs.reloadFailed)throw new Error(rs.warning||rs.message||s("settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave"));if(dt.current!==Se)return;fe(Xe),Ye.current=Ye.current?{...Ye.current,oauthRedirectUri:Xe}:Ye.current}const Nt=await C(n,p),Vt=Ul(new URL(Nt).searchParams);if(Vt&&(yt=Vt,await Xp({state:Vt,name:n,directory:p})),dt.current!==Se)return;Ue(Nt),de(Vt??null),Re(!0),Ce.current=0;const Qt=await Ws(Nt);if(dt.current!==Se)return;Qt?W.message(s(m?"settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste":"settings.mcp.page.toast.completeAuthorizationInBrowser")):W.error(s("settings.mcp.page.toast.openAuthorizationUrlFailed"))}catch(jt){await Wn(yt),dt.current===Se&&W.error(ar(jt,s("settings.mcp.page.toast.authorizationStartFailed"),e))}finally{dt.current===Se&&Ne(!1)}},[p,m,v,O,U,ee,oe,re,St,st,n,C,s,e,f]),Qe=l.useCallback(async()=>{if(!n||!St())return;Ee(!0);const Se=st;try{if(await T(n,p),dt.current!==Se)return;Ue(null),de(null),ue(""),Re(!1),Ce.current=0,await Wn(Je),W.success(s("settings.mcp.page.toast.savedAuthorizationRemoved"))}catch(yt){dt.current===Se&&W.error(ar(yt,s("settings.mcp.page.toast.clearAuthorizationFailed"),e))}finally{dt.current===Se&&Ee(!1)}},[Je,T,p,St,st,n,s,e]),Ge=l.useCallback(async()=>{if(!He)return;if((await hn(He)).ok){W.success(s("settings.mcp.page.toast.authorizationUrlCopied"));return}W.error(s("settings.mcp.page.toast.authorizationUrlCopyFailed"))},[He,s]),ut=l.useCallback(async()=>{const Se=Wp(q);if(!Se.code){W.error(s("settings.mcp.page.toast.pasteCallbackOrCodeFirst"));return}const yt=Se.stateKey?await Zp(Se.stateKey):null,jt=Se.context??yt,Xe=jt?.name??n,Nt=jt?.directory??p;if(!Xe){W.error(s("settings.mcp.page.toast.missingServerDetails"));return}if(!jt&&!St())return;Be(!0);const Vt=st;try{if(await N(Xe,Se.code,Nt),await Wn(Se.stateKey??Je),dt.current!==Vt)return;ue(""),Ue(null),de(null),Re(!1),Ce.current=0,W.success(Xe===n?s("settings.mcp.page.toast.authorizationCompleted"):s("settings.mcp.page.toast.authorizationCompletedFor",{name:Xe}))}catch(Qt){dt.current===Vt&&W.error(ar(Qt,s("settings.mcp.page.toast.authorizationCompleteFailed"),e))}finally{dt.current===Vt&&Be(!1)}},[q,Je,N,p,St,st,n,s,e]),bt=l.useCallback(async()=>{if(!(!n||!St())){if(!ve){W.error(s("settings.mcp.page.toast.enableServerBeforeTest"));return}Te(!0);try{const Se=await k(n,p),yt=Se.status?.status;Se.warning?W.warning(Se.warning):yt==="connected"?W.success(s("settings.mcp.page.toast.connectionTestSucceeded")):yt==="needs_auth"?W.message(s("settings.mcp.page.toast.connectionNeedsAuthorization")):yt==="needs_client_registration"?W.message(s("settings.mcp.page.toast.connectionNeedsClientRegistration")):yt==="failed"?W.error(Se.status?.error||Se.error||s("settings.mcp.page.toast.connectionTestFailed")):Se.error?W.error(Se.error):W.message(s("settings.mcp.page.toast.connectionTestFinished"))}catch(Se){W.error(Se instanceof Error?Se.message:s("settings.mcp.page.toast.connectionTestFailed"))}finally{Te(!1)}}},[p,ve,St,n,s,k]);if(l.useEffect(()=>{if(!je||!n)return;const Se=window.setInterval(()=>{(async()=>{Ce.current+=1,await h({directory:p,silent:!0});const yt=os.getState().getStatusForDirectory(p??null)[n];if(yt){if(_e.current&&yt.status!=="needs_auth"&&yt.status!=="needs_client_registration"){Re(!1),Ce.current=0,_e.current=!1,Ue(null),ue(""),yt.status==="connected"&&W.success(s("settings.mcp.page.toast.authorizationCompleted"));return}if(!_e.current&&yt.status==="failed"){Re(!1),Ce.current=0,_e.current=!1,W.error(yt.error||s("settings.mcp.page.toast.authorizationFailed"));return}Ce.current>=30&&(Re(!1),Ce.current=0,_e.current=!1,W.message(s("settings.mcp.page.toast.authorizationStillInProgress")))}})()},2e3);return()=>{window.clearInterval(Se)}},[p,je,h,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(D,{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 pt=P[n],Dt=n?g[n]:void 0,qt=pt??Dt,Yt=pt?.status==="connected",Zt=pt?.status==="needs_auth"||pt?.status==="needs_client_registration",as=m?null:oo(n,p),Ht=Jp(qt?.status,e,qt&&"error"in qt?qt.error:void 0),es=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(Wt,{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(io,{status:qt?.status,enabled:ve,getStatusLabel:es,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(G,{variant:Yt?"outline":"default",size:"xs",className:"!font-normal",onClick:wt,disabled:ae||!ve,children:s(ae?"settings.mcp.page.actions.working":Yt?"settings.mcp.page.actions.disconnect":"settings.mcp.page.actions.connect")}),v==="remote"&&t.jsxs(t.Fragment,{children:[t.jsx(G,{variant:Zt?"default":"outline",size:"xs",className:"!font-normal",onClick:()=>{Ve()},disabled:Me||!ve,children:s(Me?"settings.mcp.page.actions.starting":Zt?"settings.mcp.page.actions.authorize":"settings.mcp.page.actions.reauthorize")}),t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{Qe()},disabled:De||!ve,children:s(De?"settings.mcp.page.actions.clearing":"settings.mcp.page.actions.clearAuth")})]}),Yt&&t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{bt()},disabled:Pe||!ve,children:s(Pe?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.test")})]})]})]})}),!b&&Yp(qt?.status,He,Zt,je)&&t.jsx("div",{className:"mb-6 px-2",children:t.jsxs("div",{className:ce("rounded-lg border p-3",Qp(qt?.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(io,{status:qt?.status,enabled:ve,getStatusLabel:es})]}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ht}),t.jsx("p",{className:"typography-micro text-muted-foreground/80",children:F==="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:!Yt&&t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{bt()},disabled:Pe||!ve,children:s(Pe?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.testConnection")})}),He&&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:He}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ws(He)},children:[t.jsx(D,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.mcp.page.actions.openInBrowser")]}),t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ge()},children:[t.jsx(D,{name:"clipboard",className:"h-3.5 w-3.5"}),s("settings.mcp.page.actions.copyLink")]})]})]})}),v==="remote"&&(Zt||je||He)&&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:q,onChange:Se=>ue(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(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{ut()},disabled:Le,children:s(Le?"settings.mcp.page.actions.completing":"settings.mcp.page.actions.completeAuthorization")})})]})})]}),je&&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(Ze,{value:A,onChange:Se=>$(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(Rt,{value:F,onValueChange:Se=>I(Se),children:[t.jsx(Tt,{className:"!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden",title:s(F==="user"?"settings.common.scope.global":"settings.common.scope.project"),children:F==="user"?t.jsx(D,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"folder",className:"h-3.5 w-3.5"})}),t.jsxs(Ft,{align:"end",children:[t.jsx(gt,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{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(D,{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(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:mt,type:"button",title:s("settings.mcp.page.server.importJsonTitle"),children:[t.jsx(D,{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":ve,onClick:()=>we(!ve),onKeyDown:Se=>{(Se.key===" "||Se.key==="Enter")&&(Se.preventDefault(),we(!ve))},children:[t.jsx(kt,{checked:ve,onChange:we,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(G,{variant:"chip",size:"xs","aria-pressed":v==="local",onClick:()=>w("local"),className:"!font-normal",children:s("settings.mcp.page.transport.local")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":v==="remote",onClick:()=>w("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(qp,{value:L,onChange:E,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(Ze,{value:_,onChange:Se=>B(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(xn,{open:J,onOpenChange:y,children:[t.jsxs(bn,{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(ee?"settings.mcp.page.advanced.autoDetect":"settings.mcp.page.advanced.custom")," · ",M.length," ",s("settings.mcp.page.advanced.headers"),xe?` · ${xe}ms`:"",")"]})]}),J?t.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(D,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(yn,{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(Ze,{type:"number",min:"1",step:"1",value:xe,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"),M.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",M.length,")"]})]}),t.jsx(ro,{value:M,onChange:X,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":ee,onClick:()=>K(!ee),onKeyDown:Se=>{(Se.key===" "||Se.key==="Enter")&&(Se.preventDefault(),K(!ee))},children:[t.jsx(kt,{checked:ee,onChange:K,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(Ze,{value:O,onChange:Se=>Y(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthClientIdPlaceholder"),className:"font-mono typography-meta",disabled:!ee,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(Ze,{value:U,onChange:Se=>ne(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthClientSecretPlaceholder"),className:"font-mono typography-meta",disabled:!ee,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(Ze,{value:re,onChange:Se=>V(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthScopesPlaceholder"),className:"font-mono typography-meta",disabled:!ee,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(Ze,{value:oe,onChange:Se=>fe(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthRedirectUriPlaceholder"),className:"font-mono typography-meta",disabled:!ee,"data-bwignore":"true","data-1p-ignore":"true"})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:s("settings.mcp.page.advanced.oauthHint")}),as&&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:as})]})]})]})})]})})]}),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"),Z.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",Z.length,")"]})]})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:Z.length===0?t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:()=>Q([{key:"",value:""}]),children:[t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),s("settings.mcp.page.env.addEnvironmentVariable")]}):t.jsx(ro,{value:Z,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(G,{onClick:We,disabled:be||!tt&&!b,size:"xs",className:"!font-normal",children:s(be?"settings.common.actions.saving":b?"settings.common.actions.create":"settings.common.actions.saveChanges")}),!b&&t.jsx(G,{variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>ye(!0),children:s("settings.common.actions.delete")})]})]}),t.jsx(Ot,{open:pe,onOpenChange:Se=>{Se||(Ae(!1),qe(""),rt(null))},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.mcp.page.importDialog.title")}),t.jsx(Bt,{children:s("settings.mcp.page.importDialog.description")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(hs,{value:Oe,onChange:Se=>{qe(Se.target.value),rt(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"}),at&&t.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:at}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:ge,type:"button",children:[t.jsx(D,{name:"clipboard",className:"h-3.5 w-3.5"}),s("settings.mcp.page.importDialog.pasteFromClipboard")]})})]}),t.jsxs(Jt,{children:[t.jsx(G,{variant:"outline",onClick:()=>{Ae(!1),qe(""),rt(null)},className:"text-foreground",children:s("settings.common.actions.cancel")}),t.jsx(G,{onClick:et,disabled:!Oe.trim(),size:"sm",children:s("settings.common.actions.import")})]})]})}),t.jsx(Ot,{open:le,onOpenChange:Se=>{!Se&&!H&&ye(!1)},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.mcp.page.deleteDialog.title",{name:n??""})}),t.jsxs(Bt,{children:[s("settings.mcp.page.deleteDialog.descriptionPrefix")," ",t.jsx("code",{className:"text-foreground",children:"opencode.json"}),"."," ",s("settings.mcp.page.deleteDialog.descriptionSuffix")]})]}),t.jsxs(Jt,{children:[t.jsx(G,{variant:"outline",onClick:()=>ye(!1),disabled:H,className:"text-foreground",children:s("settings.common.actions.cancel")}),t.jsx(G,{variant:"destructive",size:"sm",onClick:xt,disabled:H,children:s(H?"settings.mcp.page.actions.deleting":"settings.common.actions.delete")})]})]})})]})},sg=({transform:s})=>({...s,y:0}),ng=s=>{const e=nt.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:f,transition:u,isDragging:p}=Kc(i);let m;e[2]!==f?(m=$c.Transform.toString(f),e[2]=f,e[3]=m):m=e[3];let P;e[4]!==m||e[5]!==u?(P={transform:m,transition:u},e[4]=m,e[5]=u,e[6]=P):P=e[6];const g=p&&"opacity-50";let h;e[7]!==r||e[8]!==g?(h=ce("h-full rounded-md",r,g),e[7]=r,e[8]=g,e[9]=h):h=e[9];let x;return e[10]!==o||e[11]!==a||e[12]!==n||e[13]!==d||e[14]!==c||e[15]!==P||e[16]!==h?(x=t.jsx("div",{ref:c,"data-sortable-tab-id":n,style:P,className:h,...o,...d,children:a}),e[10]=o,e[11]=a,e[12]=n,e[13]=d,e[14]=c,e[15]=P,e[16]=h,e[17]=x):x=e[17],x},ag=s=>{const e=nt.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},vn=s=>{const e=nt.c(121),{items:n,activeId:a,onSelect:r,onClose:i,onReorder:o,layoutMode:d,variant:c,activePillInsetClassName:f,activePillButtonClassName:u,inactiveTabsIconOnly:p,iconOnlyActiveTab:m,animateActivePill:P,activePillLowercase:g,className:h}=s,x=d===void 0?"scrollable":d,R=c===void 0?"default":c,C=p===void 0?!1:p,N=m===void 0?!1:m,T=g===void 0?!0:g,{t:k}=it(),j=ze(rg),{isTablet:b}=Cs(),A=j||b,$=l.useRef(null);let F;e[0]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[0]=F):F=e[0];const[I,v]=l.useState(F);let w;e[1]!==n?(w=n.map(ig),e[1]=n,e[2]=w):w=e[2];const L=w,E=x==="scrollable",_=R==="default",B=R==="active-pill",Z=R==="animated",Q=B||Z,M=_,X=Q||M,ee=B&&E,K=Q,O=P??Z,Y=typeof o=="function",U=Y?ng:ag;let ne;e[3]===Symbol.for("react.memo_cache_sentinel")?(ne=new Map,e[3]=ne):ne=e[3];const re=l.useRef(ne),[V,oe]=l.useState(null);let fe;e[4]===Symbol.for("react.memo_cache_sentinel")?(fe={activationConstraint:{distance:8}},e[4]=fe):fe=e[4];const xe=Lc(Oc(zc,fe)),Ie=og;let ve;e[5]===Symbol.for("react.memo_cache_sentinel")?(ve=(Ye,$e)=>{if($e){re.current.set(Ye,$e);return}re.current.delete(Ye)},e[5]=ve):ve=e[5];const we=ve;let be;e[6]!==a||e[7]!==X?(be=()=>{if(!X||!a){oe(lg);return}const Ye=$.current,$e=re.current.get(a);if(!Ye||!$e){oe(cg);return}let mt=0,ge=0,et=$e;for(;et&&et!==Ye;)mt=mt+et.offsetLeft,ge=ge+et.offsetTop,et=et.offsetParent;const tt={left:mt,top:ge,width:$e.offsetWidth,height:$e.offsetHeight};oe(We=>Ie(We,tt)?We:tt)},e[6]=a,e[7]=X,e[8]=be):be=e[8];const se=be;let le;e[9]!==E?(le=()=>{if(!E){v({left:!1,right:!1});return}const Ye=$.current;if(!Ye){v({left:!1,right:!1});return}v({left:Ye.scrollLeft>2,right:Ye.scrollLeft+Ye.clientWidth<Ye.scrollWidth-2})},e[9]=E,e[10]=le):le=e[10];const ye=le;let H;e[11]!==E||e[12]!==ye?(H=()=>{if(!E){v({left:!1,right:!1});return}const Ye=$.current;if(!Ye)return;ye(),Ye.addEventListener("scroll",ye,{passive:!0});const $e=new ResizeObserver(ye);return $e.observe(Ye),()=>{Ye.removeEventListener("scroll",ye),$e.disconnect()}},e[11]=E,e[12]=ye,e[13]=H):H=e[13];let te;e[14]!==E||e[15]!==n.length||e[16]!==ye?(te=[E,n.length,ye],e[14]=E,e[15]=n.length,e[16]=ye,e[17]=te):te=e[17],l.useEffect(H,te);let ae;e[18]!==a||e[19]!==se||e[20]!==X?(ae=()=>{if(!X){oe(null);return}se();const Ye=$.current;if(!Ye)return;const $e=new ResizeObserver(se);if($e.observe(Ye),a){const mt=re.current.get(a);mt&&$e.observe(mt)}return()=>{$e.disconnect()}},e[18]=a,e[19]=se,e[20]=X,e[21]=ae):ae=e[21];let me;e[22]!==a||e[23]!==n.length||e[24]!==se||e[25]!==X?(me=[a,n.length,se,X],e[22]=a,e[23]=n.length,e[24]=se,e[25]=X,e[26]=me):me=e[26],l.useEffect(ae,me);let Me;e[27]!==se?(Me=()=>{se()},e[27]=se,e[28]=Me):Me=e[28],l.useLayoutEffect(Me);let Ne;e[29]!==a||e[30]!==E||e[31]!==ye?(Ne=()=>{if(!E||!a)return;const Ye=$.current;if(!Ye)return;const $e=window.requestAnimationFrame(()=>{const mt=typeof window.CSS?.escape=="function"?window.CSS.escape(a):a.replace(/"/g,'\\"'),ge=Ye.querySelector(`[data-sortable-tab-id="${mt}"]`);ge&&(ge.scrollIntoView({block:"nearest",inline:"nearest"}),ye())});return()=>{window.cancelAnimationFrame($e)}},e[29]=a,e[30]=E,e[31]=ye,e[32]=Ne):Ne=e[32];let De;e[33]!==a||e[34]!==E||e[35]!==n.length||e[36]!==ye?(De=[a,E,n.length,ye],e[33]=a,e[34]=E,e[35]=n.length,e[36]=ye,e[37]=De):De=e[37],l.useEffect(Ne,De);let Ee;e[38]!==o?(Ee=Ye=>{if(!o)return;const{active:$e,over:mt}=Ye;!mt||$e.id===mt.id||o(String($e.id),String(mt.id))},e[38]=o,e[39]=Ee):Ee=e[39];const Pe=Ee;let Te;e[40]!==h?(Te=ce("relative flex h-full min-w-0 flex-1",h),e[40]=h,e[41]=Te):Te=e[41];let Le;e[42]!==E||e[43]!==I||e[44]!==Q?(Le=E&&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]=E,e[43]=I,e[44]=Q,e[45]=Le):Le=e[45];let Be;e[46]!==E||e[47]!==I||e[48]!==Q?(Be=E&&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]=E,e[47]=I,e[48]=Q,e[49]=Be):Be=e[49];const He=Q?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Ue=Q&&"@container/pill-tabs",Je=Q&&"pill-tabs__track",de=Q&&(f??"gap-0.5 py-0.5"),q=M&&"items-center overflow-y-hidden",ue=K&&"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",je=E?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Re;e[50]!==He||e[51]!==Ue||e[52]!==Je||e[53]!==de||e[54]!==q||e[55]!==ue||e[56]!==je?(Re=ce("relative flex h-full min-w-0 flex-1",He,Ue,Je,de,q,ue,je),e[50]=He,e[51]=Ue,e[52]=Je,e[53]=de,e[54]=q,e[55]=ue,e[56]=je,e[57]=Re):Re=e[57];let Ce;e[58]!==E?(Ce=E?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[58]=E,e[59]=Ce):Ce=e[59];let _e;e[60]!==k?(_e=k("sortableTabsStrip.aria.tabs"),e[60]=k,e[61]=_e):_e=e[61];let J;e[62]!==V||e[63]!==O||e[64]!==Q?(J=Q&&V?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(${V.left}px, ${V.top}px, 0)`,width:`${V.width}px`,height:`${V.height}px`,transition:O?"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]=V,e[63]=O,e[64]=Q,e[65]=J):J=e[65];let y;e[66]!==V||e[67]!==M?(y=M&&V?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(${V.left}px, 0, 0)`,width:`${V.width}px`},"aria-hidden":!0}):null,e[66]=V,e[67]=M,e[68]=y):y=e[68];let pe;if(e[69]!==U||e[70]!==a||e[71]!==u||e[72]!==T||e[73]!==A||e[74]!==N||e[75]!==C||e[76]!==B||e[77]!==j||e[78]!==E||e[79]!==n||e[80]!==i||e[81]!==r||e[82]!==ee||e[83]!==Q){let Ye;e[85]!==U||e[86]!==a||e[87]!==u||e[88]!==T||e[89]!==A||e[90]!==N||e[91]!==C||e[92]!==B||e[93]!==j||e[94]!==E||e[95]!==i||e[96]!==r||e[97]!==ee||e[98]!==Q?(Ye=$e=>{const mt=$e.id===a,ge=C&&Q&&!mt&&!!$e.icon,et=!ge,tt=!!$e.icon&&(!N||mt),We=C&&Q&&mt&&!E&&!ee,xt=$e.closable!==!1&&!!i,wt=xt&&!!$e.icon,St=E||ee?void 0:Q?We?"flex-none basis-auto":j?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",ie=xt?Qe=>{Qe.button===1&&(Qe.preventDefault(),Qe.stopPropagation(),i?.($e.id))}:void 0,Ve=xt?dg:void 0;return t.jsx(U,{id:$e.id,className:St,children:t.jsxs("div",{ref:Qe=>we($e.id,Qe),onAuxClick:ie,onMouseDown:Ve,className:ce("group flex h-full min-w-0 flex-nowrap items-center",E||ee?"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":ge?$e.title??$e.label:void 0,onClick:()=>r($e.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&&T?"lowercase":null,Q&&(ge?"gap-0":"gap-1.5"),Q?ee?"shrink-0 whitespace-nowrap px-3 text-center":E?"max-w-56 shrink-0 px-3 text-center":ge?"px-2 !min-w-0 text-center":We?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":E?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",Q?u??(B?j?"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:$e.title??$e.label,children:Q?t.jsxs(t.Fragment,{children:[tt?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&&(A?"opacity-0":"group-hover:opacity-0")),children:$e.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",A?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:mg,onClick:Qe=>{Qe.stopPropagation(),i?.($e.id)},"aria-label":$e.closeLabel??`Close ${$e.label} tab`,title:$e.closeLabel??`Close ${$e.label} tab`,children:t.jsx(D,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,et?t.jsx("span",{className:"animated-tabs__label truncate",children:$e.label}):null]}):t.jsxs("span",{className:ce("flex min-w-0 flex-nowrap items-center gap-1.5",!E&&"justify-center"),children:[tt?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&&(A?"opacity-0":"group-hover:opacity-0")),children:$e.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",A?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:ug,onClick:Qe=>{Qe.stopPropagation(),i?.($e.id)},"aria-label":$e.closeLabel??`Close ${$e.label} tab`,title:$e.closeLabel??`Close ${$e.label} tab`,children:t.jsx(D,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:$e.label})]})}),xt&&!wt?t.jsx("button",{type:"button",onPointerDown:pg,onClick:Qe=>{Qe.stopPropagation(),i?.($e.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":$e.closeLabel??`Close ${$e.label} tab`,title:$e.closeLabel??`Close ${$e.label} tab`,children:t.jsx(D,{name:"close",className:"h-3 w-3"})}):null]})},$e.id)},e[85]=U,e[86]=a,e[87]=u,e[88]=T,e[89]=A,e[90]=N,e[91]=C,e[92]=B,e[93]=j,e[94]=E,e[95]=i,e[96]=r,e[97]=ee,e[98]=Q,e[99]=Ye):Ye=e[99],pe=n.map(Ye),e[69]=U,e[70]=a,e[71]=u,e[72]=T,e[73]=A,e[74]=N,e[75]=C,e[76]=B,e[77]=j,e[78]=E,e[79]=n,e[80]=i,e[81]=r,e[82]=ee,e[83]=Q,e[84]=pe}else pe=e[84];let Ae;e[100]!==Re||e[101]!==Ce||e[102]!==_e||e[103]!==J||e[104]!==y||e[105]!==pe?(Ae=t.jsxs("div",{ref:$,className:Re,style:Ce,role:"tablist","aria-label":_e,children:[J,y,pe]}),e[100]=Re,e[101]=Ce,e[102]=_e,e[103]=J,e[104]=y,e[105]=pe,e[106]=Ae):Ae=e[106];let Oe;e[107]!==Te||e[108]!==Le||e[109]!==Be||e[110]!==Ae?(Oe=t.jsxs("div",{className:Te,children:[Le,Be,Ae]}),e[107]=Te,e[108]=Le,e[109]=Be,e[110]=Ae,e[111]=Oe):Oe=e[111];const qe=Oe;if(!Y)return qe;let at;e[112]===Symbol.for("react.memo_cache_sentinel")?(at=[sg],e[112]=at):at=e[112];let rt;e[113]!==L||e[114]!==qe?(rt=t.jsx(Uc,{items:L,strategy:Bc,children:qe}),e[113]=L,e[114]=qe,e[115]=rt):rt=e[115];let st;e[116]===Symbol.for("react.memo_cache_sentinel")?(st=t.jsx(Vc,{dropAnimation:null}),e[116]=st):st=e[116];let dt;return e[117]!==Pe||e[118]!==xe||e[119]!==rt?(dt=t.jsxs(_c,{sensors:xe,collisionDetection:Hc,onDragEnd:Pe,modifiers:at,children:[rt,st]}),e[117]=Pe,e[118]=xe,e[119]=rt,e[120]=dt):dt=e[120],dt};function rg(s){return s.isMobile}function ig(s){return s.id}function og(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 lg(s){return s===null?s:null}function cg(s){return s===null?s:null}function dg(s){s.button===1&&s.preventDefault()}function mg(s){s.stopPropagation()}function ug(s){s.stopPropagation()}function pg(s){s.stopPropagation()}const Pa=()=>{try{const e=ns.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();const n=ys.getDirectory();if(n?.trim())return n.trim()}catch(s){console.warn("[PluginsStore] Error resolving config directory:",s)}return null},gg=800,hg=5e3,fg="__default__",Lr=new Map,rr=new Map,xg=1500,Bl=s=>s?.trim()||fg,bg=s=>{Lr.delete(Bl(s))},ls=ln()(ta(Wr((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=Pa(),r=Bl(a),i=Date.now(),o=Lr.get(r)??0,d=e().entries.length>0||e().files.length>0;if(!n?.force&&d&&i-o<hg)return!0;const c=rr.get(r);if(!n?.force&&c)return c;const f=(async()=>{s({isLoading:!0});try{const u=await ht(Zs("/api/config/plugins",a),{headers:qn(a)});if(!u.ok)throw new Error("Failed to load plugins");const p=await Ia(u);return s({entries:p.entries??[],files:p.files??[],isLoading:!1}),Lr.set(r,Date.now()),n?.force||e().loadRegistryInfo(),!0}catch(u){return console.error("[PluginsStore] Failed to load plugins:",u),s({isLoading:!1}),!1}})();rr.set(r,f);try{return await f}finally{rr.delete(r)}},loadRegistryInfo:async n=>{const a=vg(n?.specs??e().entries.map(r=>r.spec));if(a.length===0){s({isLoadingRegistry:!1});return}s({isLoadingRegistry:!0});try{const r=Pa(),i={...e().registryInfo};for(const o of jg(a)){const d=await ht(yg(o,n?.force===!0,r),{headers:qn(r)});if(!d.ok)throw new Error("Failed to load plugin registry info");const c=await Ia(d);for(const f of c.results??[])i[f.spec]=f}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 Cn("Creating plugin entry…",async r=>await ht(Zs("/api/config/plugins/entry",r),{method:"POST",headers:ga(r),body:JSON.stringify(lo(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 Cn("Updating plugin entry…",async d=>await ht(Zs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,d),{method:"PATCH",headers:ga(d),body:JSON.stringify(lo(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 Cn("Deleting plugin entry…",async i=>await ht(Zs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,i),{method:"DELETE",headers:qn(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=Pa(),r=await ht(Zs(`/api/config/plugins/file/${encodeURIComponent(n)}`,a),{headers:qn(a)});if(!r.ok)throw new Error("Failed to read plugin file");return await Ia(r)}catch(a){return console.error("[PluginsStore] Failed to read plugin file:",a),null}},createFile:async n=>Cn("Creating plugin file…",async a=>await ht(Zs("/api/config/plugins/file",a),{method:"POST",headers:ga(a),body:JSON.stringify(n)}),e),updateFile:async(n,a)=>Cn("Updating plugin file…",async r=>await ht(Zs(`/api/config/plugins/file/${encodeURIComponent(n)}`,r),{method:"PUT",headers:ga(r),body:JSON.stringify(a)}),e),deleteFile:async n=>{const a=await Cn("Deleting plugin file…",async r=>await ht(Zs(`/api/config/plugins/file/${encodeURIComponent(n)}`,r),{method:"DELETE",headers:qn(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:Yr(),partialize:s=>({selectedId:s.selectedId})}),{name:"plugins-store"}));function Zs(s,e){const n=e?`?directory=${encodeURIComponent(e)}`:"";return`${s}${n}`}function yg(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 vg(s){return Array.from(new Set(s.map(e=>e.trim()).filter(Boolean)))}function jg(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>xg?(e.push(n),n=[r],a=i.length):(n.push(r),a=o)}return n.length>0&&e.push(n),e}function qn(s){return s?{"x-opencode-directory":s}:void 0}function ga(s){return{"Content-Type":"application/json",...s?{"x-opencode-directory":s}:{}}}function lo(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 Cn(s,e,n){Na(s);let a=!1;try{const r=Pa(),i=await e(r),o=await Ia(i).catch(()=>null);if(!i.ok)throw new Error(o?.error||"Failed to update plugin configuration");return bg(r),o?.requiresReload&&(a=!0,await ka({message:o.message,delayMs:o.reloadDelayMs??gg,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||Sa()}}async function Ia(s){return await s.json()}const wg=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function Ng(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 kg=({open:s,onOpenChange:e,defaultScope:n="user"})=>{const{t:a}=it(),r=ls(E=>E.createEntry),i=ls(E=>E.createFile),[o,d]=l.useState("npm"),[c,f]=l.useState(""),[u,p]=l.useState(""),[m,P]=l.useState(""),[g,h]=l.useState(""),[x,R]=l.useState(n),[C,N]=l.useState(!1),T=l.useCallback(()=>{f(""),p(""),P(""),h(""),R(n)},[n]);l.useEffect(()=>{s&&(d("npm"),T())},[s,T]);const k=E=>{E!==o&&(d(E),T())},j=l.useMemo(()=>Ng(u),[u]),b=!j.ok,A=o==="file"&&m.trim()!==""&&!wg.test(m.trim()),$=(o==="npm"||o==="path")&&c.trim()==="",F=o==="file"&&g.trim()==="",I=o==="file"&&m.trim()==="",v=C||b||o==="npm"&&$||o==="path"&&$||o==="file"&&(I||A||F),w=async()=>{if(!v){N(!0);try{let E;o==="file"?E=await i({fileName:m.trim(),content:g,scope:x}):E=await r({spec:c.trim(),options:j.ok?j.value:void 0,scope:x}),E.ok?(W.success(E.message||a("settings.plugins.toast.created")),E.reloadFailed&&W.warning(a("settings.plugins.toast.reloadFailed")),e(!1)):W.error(E.message||a("settings.plugins.sidebar.toast.deleteFailed"))}finally{N(!1)}}},L=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(Ot,{open:s,onOpenChange:E=>{!E&&C||e(E)},children:t.jsxs(zt,{className:"max-w-xl",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:a("settings.plugins.dialog.add.title")}),t.jsx(Bt,{children:a("settings.plugins.sidebar.empty.description")})]}),t.jsx(vn,{items:L,activeId:o,onSelect:E=>k(E),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(Ze,{id:"plugin-spec",value:c,onChange:E=>f(E.target.value),placeholder:a("settings.plugins.page.field.spec.placeholder"),"aria-invalid":$?!1:void 0,disabled:C}),$&&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:u,onChange:E=>p(E.target.value),rows:5,className:"font-mono",hasError:b,disabled:C}),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(Ze,{id:"plugin-filename",value:m,onChange:E=>P(E.target.value),placeholder:"my-plugin.ts","aria-invalid":A||void 0,disabled:C}),A&&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:g,onChange:E=>h(E.target.value),rows:16,className:"font-mono",disabled:C})]})]}),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(E=>{const _=x===E,B=a(E==="user"?"settings.plugins.scope.user":"settings.plugins.scope.project");return t.jsxs("button",{type:"button",onClick:()=>R(E),disabled:C,className:"flex items-center gap-2 py-1 text-left disabled:opacity-50",children:[t.jsx(tn,{checked:_,onChange:()=>R(E),ariaLabel:B}),t.jsx("span",{className:ce("typography-ui-label font-normal",_?"text-foreground":"text-foreground/60"),children:B})]},E)})})]})]}),t.jsxs(Jt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>e(!1),disabled:C,children:a("settings.plugins.dialog.add.action.cancel")}),t.jsxs(G,{size:"sm",onClick:()=>{w()},disabled:v,children:[C?t.jsx(D,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):null,a("settings.plugins.dialog.add.action.submit")]})]})]})})},Sg=s=>{const e=nt.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=ls(a),{t:i}=it();if(!r)return null;const o=Cg;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(D,{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 f;return e[5]!==r.currentVersion||e[6]!==r.latestVersion||e[7]!==i||e[8]!==c?(f=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]=f):f=e[9],f}case"npm-missing-version":{let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(D,{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(D,{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(D,{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(D,{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(D,{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(D,{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 Cg(s,e){return t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-xs",children:s})}),t.jsx(Et,{children:e})]})}const Vl=s=>{const e=nt.c(26),{header:n,footer:a,children:r,className:i,variant:o}=s,d=o===void 0?"sidebar":o,c=fs(),f=l.useRef(null),[u,p]=l.useState(!1),[m,P]=l.useState(!1),g=d==="background"||c?"bg-background":"bg-sidebar",h=g==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const v=f.current;if(!v){p(!1),P(!1);return}if(!(v.scrollHeight>v.clientHeight+1)){p(!1),P(!1);return}p(v.scrollTop>1),P(v.scrollTop+v.clientHeight<v.scrollHeight-1)},e[0]=x):x=e[0];const R=x;let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{R()},e[1]=C):C=e[1];let N;e[2]!==r?(N=[r,R],e[2]=r,e[3]=N):N=e[3],l.useEffect(C,N);let T,k;e[4]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const v=f.current;if(!v)return;const w=()=>R();return v.addEventListener("scroll",w,{passive:!0}),()=>v.removeEventListener("scroll",w)},k=[R],e[4]=T,e[5]=k):(T=e[4],k=e[5]),l.useEffect(T,k);let j;e[6]!==g||e[7]!==i?(j=ce("flex h-full flex-col",g,i),e[6]=g,e[7]=i,e[8]=j):j=e[8];let b;e[9]!==r?(b=t.jsx(Wt,{ref:f,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 A;e[11]!==h||e[12]!==u?(A=u&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${h} 0%, transparent 100%)`}}),e[11]=h,e[12]=u,e[13]=A):A=e[13];let $;e[14]!==h||e[15]!==m?($=m&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${h} 0%, transparent 100%)`}}),e[14]=h,e[15]=m,e[16]=$):$=e[16];let F;e[17]!==$||e[18]!==b||e[19]!==A?(F=t.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[b,A,$]}),e[17]=$,e[18]=b,e[19]=A,e[20]=F):F=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==F||e[24]!==j?(I=t.jsxs("div",{className:j,children:[n,F,a]}),e[21]=a,e[22]=n,e[23]=F,e[24]=j,e[25]=I):I=e[25],I},Or=s=>{const e=nt.c(23),{title:n,metadata:a,selected:r,onSelect:i,icon:o,actions:d,className:c}=s,f=r===void 0?!1:r,u=d&&d.length>0,p=f?"bg-interactive-selection":"hover:bg-interactive-hover";let m;e[0]!==c||e[1]!==p?(m=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]=m):m=e[2];let P;e[3]!==n?(P=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n}),e[3]=n,e[4]=P):P=e[4];let g;e[5]!==o||e[6]!==P?(g=t.jsxs("div",{className:"flex items-center gap-1.5",children:[o,P]}),e[5]=o,e[6]=P,e[7]=g):g=e[7];let h;e[8]!==a?(h=a&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a}),e[8]=a,e[9]=h):h=e[9];let x;e[10]!==i||e[11]!==g||e[12]!==h?(x=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:[g,h]}),e[10]=i,e[11]=g,e[12]=h,e[13]=x):x=e[13];let R;e[14]!==d||e[15]!==u?(R=u&&t.jsxs(gs,{children:[t.jsx(us,{asChild:!0,children:t.jsx(G,{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(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:d.map(Pg)})]}),e[14]=d,e[15]=u,e[16]=R):R=e[16];let C;e[17]!==x||e[18]!==R?(C=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[x,R]}),e[17]=x,e[18]=R,e[19]=C):C=e[19];let N;return e[20]!==m||e[21]!==C?(N=t.jsx("div",{className:m,children:C}),e[20]=m,e[21]=C,e[22]=N):N=e[22],N};function Pg(s){const e=s.icon;return t.jsxs(js,{onClick:n=>{n.stopPropagation(),s.onClick()},className:ce(s.destructive&&"text-destructive focus:text-destructive"),children:[e&&t.jsx(D,{name:e,className:"h-4 w-4 mr-px"}),s.label]},s.label)}const Ig=s=>s.parsedKind==="npm"?"code-box":"folder",Ag=s=>{const e=nt.c(144),{onItemSelect:n,onAddClick:a}=s,{t:r}=it(),{entries:i,files:o,selectedId:d,setSelected:c,deleteEntry:f,deleteFile:u,loadPlugins:p}=ls(Ss(Dg)),m=ls(Eg),P=ls(Mg),g=ls(Rg),h=ls(Tg),[x,R]=l.useState(null),[C,N]=l.useState(!1),[T,k]=l.useState(!1);let j,b;e[0]!==p?(j=()=>{p()},b=[p],e[0]=p,e[1]=j,e[2]=b):(j=e[1],b=e[2]),l.useEffect(j,b);let A,$;e[3]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const ge=()=>k(!0);return window.addEventListener("openchamber:settings-open-plugin-add",ge),()=>window.removeEventListener("openchamber:settings-open-plugin-add",ge)},$=[],e[3]=A,e[4]=$):(A=e[3],$=e[4]),l.useEffect(A,$);let F;if(e[5]!==i||e[6]!==m){F={userEntries:0,projectEntries:0};for(const ge of i){const et=m[ge.spec];et?.kind==="npm-ok"&&et.hasUpdate&&(ge.scope==="user"?F.userEntries=F.userEntries+1:ge.scope==="project"&&(F.projectEntries=F.projectEntries+1))}e[5]=i,e[6]=m,e[7]=F}else F=e[7];const I=F;let v;e[8]!==i?(v=i.filter(Fg),e[8]=i,e[9]=v):v=e[9];const w=v;let L;e[10]!==i?(L=i.filter(Lg),e[10]=i,e[11]=L):L=e[11];const E=L;let _;e[12]!==o?(_=o.filter(Og),e[12]=o,e[13]=_):_=e[13];const B=_;let Z;e[14]!==o?(Z=o.filter(zg),e[14]=o,e[15]=Z):Z=e[15];const Q=Z,M=i.length+o.length,X=M===0;let ee;e[16]!==a?(ee=()=>{a?a():k(!0)},e[16]=a,e[17]=ee):ee=e[17];const K=ee;let O;e[18]!==n||e[19]!==c?(O=ge=>{c(ge),n?.()},e[18]=n,e[19]=c,e[20]=O):O=e[20];const Y=O;let U;e[21]!==i||e[22]!==m||e[23]!==r||e[24]!==h?(U=async ge=>{const et=i.find(wt=>wt.id===ge);if(!et)return;const tt=m[et.spec];if(!tt||tt.kind!=="npm-ok"||!tt.hasUpdate||!tt.latestVersion)return;const We=tt.latestVersion;(await h(ge)).ok?W.success(r("settings.plugins.toast.updatedToLatest",{version:We})):W.error(r("settings.plugins.toast.refreshFailed"))},e[21]=i,e[22]=m,e[23]=r,e[24]=h,e[25]=U):U=e[25];const ne=U;let re;e[26]!==g||e[27]!==r?(re=async()=>{W.info(r("settings.plugins.toast.refreshing"));try{await g({force:!0})}catch{W.error(r("settings.plugins.toast.refreshFailed"))}},e[26]=g,e[27]=r,e[28]=re):re=e[28];const V=re;let oe;e[29]!==f||e[30]!==u||e[31]!==x||e[32]!==r?(oe=async()=>{if(!x)return;N(!0);const ge=x.kind==="entry"?await f(x.id):await u(x.id);ge.ok?W.success(ge.message||r("settings.plugins.sidebar.toast.deleted",{name:x.label})):W.error(r("settings.plugins.sidebar.toast.deleteFailed")),R(null),N(!1)},e[29]=f,e[30]=u,e[31]=x,e[32]=r,e[33]=oe):oe=e[33];const fe=oe;let xe;e[34]!==Y||e[35]!==ne||e[36]!==m||e[37]!==d||e[38]!==r?(xe=ge=>{const et=m[ge.spec],tt=et?.kind==="npm-ok"&&et.hasUpdate&&!!et.latestVersion,We=[];return tt&&We.push({label:r("settings.plugins.sidebar.actions.updateToLatest"),icon:"arrow-up-s",onClick:()=>{ne(ge.id)}}),We.push({label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>R({kind:"entry",id:ge.id,label:ge.spec})}),t.jsx(Or,{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:ge.spec}),t.jsx(Sg,{spec:ge.spec})]}),metadata:ge.parsedKind==="npm"?r("settings.plugins.sidebar.kind.npm"):r("settings.plugins.sidebar.kind.path"),selected:d===ge.id,onSelect:()=>Y(ge.id),icon:t.jsx(D,{name:Ig(ge),className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:We},ge.id)},e[34]=Y,e[35]=ne,e[36]=m,e[37]=d,e[38]=r,e[39]=xe):xe=e[39];const Ie=xe;let ve;e[40]!==Y||e[41]!==d||e[42]!==r?(ve=ge=>t.jsx(Or,{title:ge.fileName,metadata:r("settings.plugins.sidebar.kind.file"),selected:d===ge.id,onSelect:()=>Y(ge.id),icon:t.jsx(D,{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:()=>R({kind:"file",id:ge.id,label:ge.fileName})}]},ge.id),e[40]=Y,e[41]=d,e[42]=r,e[43]=ve):ve=e[43];const we=ve;let be;e[44]!==r?(be=(ge,et,tt)=>{const We=tt===void 0?0:tt;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:[ge,We>0&&t.jsx("span",{className:"ml-2 normal-case font-normal text-[var(--status-success)]",children:r(We===1?"settings.plugins.sidebar.group.updatesAvailable_one":"settings.plugins.sidebar.group.updatesAvailable_other",{count:We})})]}),et]})},e[44]=r,e[45]=be):be=e[45];const se=be;let le;e[46]!==r?(le=r("settings.plugins.sidebar.title"),e[46]=r,e[47]=le):le=e[47];let ye;e[48]!==le?(ye=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:le})}),e[48]=le,e[49]=ye):ye=e[49];let H;e[50]!==r||e[51]!==M?(H=r("settings.plugins.sidebar.total",{count:M}),e[50]=r,e[51]=M,e[52]=H):H=e[52];let te;e[53]!==H?(te=t.jsx("span",{className:"typography-meta text-muted-foreground",children:H}),e[53]=H,e[54]=te):te=e[54];let ae;e[55]!==V?(ae=()=>{V()},e[55]=V,e[56]=ae):ae=e[56];let me;e[57]!==r?(me=r("settings.plugins.sidebar.actions.refresh"),e[57]=r,e[58]=me):me=e[58];let Me;e[59]!==r?(Me=r("settings.plugins.sidebar.actions.refresh"),e[59]=r,e[60]=Me):Me=e[60];const Ne=P?"size-4 animate-spin":"size-4";let De;e[61]!==Ne?(De=t.jsx(D,{name:"refresh",className:Ne}),e[61]=Ne,e[62]=De):De=e[62];let Ee;e[63]!==P||e[64]!==ae||e[65]!==me||e[66]!==Me||e[67]!==De?(Ee=t.jsx(G,{type:"button","data-settings-item":"plugins.create",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:ae,disabled:P,"aria-label":me,title:Me,children:De}),e[63]=P,e[64]=ae,e[65]=me,e[66]=Me,e[67]=De,e[68]=Ee):Ee=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 Le;e[73]===Symbol.for("react.memo_cache_sentinel")?(Le=t.jsx(D,{name:"add",className:"size-4"}),e[73]=Le):Le=e[73];let Be;e[74]!==K||e[75]!==Pe||e[76]!==Te?(Be=t.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:K,"aria-label":Pe,title:Te,children:Le}),e[74]=K,e[75]=Pe,e[76]=Te,e[77]=Be):Be=e[77];let He;e[78]!==Ee||e[79]!==Be?(He=t.jsxs("div",{className:"flex items-center gap-1",children:[Ee,Be]}),e[78]=Ee,e[79]=Be,e[80]=He):He=e[80];let Ue;e[81]!==te||e[82]!==He?(Ue=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[te,He]}),e[81]=te,e[82]=He,e[83]=Ue):Ue=e[83];let Je;e[84]!==ye||e[85]!==Ue?(Je=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ye,Ue]}),e[84]=ye,e[85]=Ue,e[86]=Je):Je=e[86];let de;e[87]!==X||e[88]!==E||e[89]!==Q||e[90]!==Ie||e[91]!==we||e[92]!==se||e[93]!==r||e[94]!==I||e[95]!==w||e[96]!==B?(de=X?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(D,{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:[w.length>0&&se(r("settings.plugins.sidebar.group.userEntries"),w.map(Ie),I.userEntries),B.length>0&&se(r("settings.plugins.sidebar.group.userFiles"),B.map(we)),E.length>0&&se(r("settings.plugins.sidebar.group.projectEntries"),E.map(Ie),I.projectEntries),Q.length>0&&se(r("settings.plugins.sidebar.group.projectFiles"),Q.map(we))]}),e[87]=X,e[88]=E,e[89]=Q,e[90]=Ie,e[91]=we,e[92]=se,e[93]=r,e[94]=I,e[95]=w,e[96]=B,e[97]=de):de=e[97];let q;e[98]!==Je||e[99]!==de?(q=t.jsx(Vl,{variant:"background",header:Je,children:de}),e[98]=Je,e[99]=de,e[100]=q):q=e[100];let ue;e[101]!==T?(ue=t.jsx(kg,{open:T,onOpenChange:k}),e[101]=T,e[102]=ue):ue=e[102];const je=x!==null;let Re;e[103]!==C?(Re=ge=>{!ge&&!C&&R(null)},e[103]=C,e[104]=Re):Re=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(Kt,{children:Ce}),e[107]=Ce,e[108]=_e):_e=e[108];const J=x?.label??"";let y;e[109]!==r||e[110]!==J?(y=r("settings.plugins.sidebar.deleteDialog.description",{name:J}),e[109]=r,e[110]=J,e[111]=y):y=e[111];let pe;e[112]!==y?(pe=t.jsx(Bt,{children:y}),e[112]=y,e[113]=pe):pe=e[113];let Ae;e[114]!==_e||e[115]!==pe?(Ae=t.jsxs($t,{children:[_e,pe]}),e[114]=_e,e[115]=pe,e[116]=Ae):Ae=e[116];let Oe;e[117]===Symbol.for("react.memo_cache_sentinel")?(Oe=()=>R(null),e[117]=Oe):Oe=e[117];let qe;e[118]!==r?(qe=r("settings.common.actions.cancel"),e[118]=r,e[119]=qe):qe=e[119];let at;e[120]!==C||e[121]!==qe?(at=t.jsx(G,{size:"sm",variant:"ghost",onClick:Oe,disabled:C,children:qe}),e[120]=C,e[121]=qe,e[122]=at):at=e[122];let rt;e[123]!==C||e[124]!==r?(rt=r(C?"settings.plugins.sidebar.actions.deleting":"settings.common.actions.delete"),e[123]=C,e[124]=r,e[125]=rt):rt=e[125];let st;e[126]!==fe||e[127]!==C||e[128]!==rt?(st=t.jsx(G,{size:"sm",variant:"destructive",onClick:fe,disabled:C,children:rt}),e[126]=fe,e[127]=C,e[128]=rt,e[129]=st):st=e[129];let dt;e[130]!==at||e[131]!==st?(dt=t.jsxs(Jt,{children:[at,st]}),e[130]=at,e[131]=st,e[132]=dt):dt=e[132];let Ye;e[133]!==Ae||e[134]!==dt?(Ye=t.jsxs(zt,{className:"max-w-md",children:[Ae,dt]}),e[133]=Ae,e[134]=dt,e[135]=Ye):Ye=e[135];let $e;e[136]!==je||e[137]!==Re||e[138]!==Ye?($e=t.jsx(Ot,{open:je,onOpenChange:Re,children:Ye}),e[136]=je,e[137]=Re,e[138]=Ye,e[139]=$e):$e=e[139];let mt;return e[140]!==q||e[141]!==ue||e[142]!==$e?(mt=t.jsxs(t.Fragment,{children:[q,ue,$e]}),e[140]=q,e[141]=ue,e[142]=$e,e[143]=mt):mt=e[143],mt};function Dg(s){return{entries:s.entries,files:s.files,selectedId:s.selectedId,setSelected:s.setSelected,deleteEntry:s.deleteEntry,deleteFile:s.deleteFile,loadPlugins:s.loadPlugins}}function Eg(s){return s.registryInfo}function Mg(s){return s.isLoadingRegistry}function Rg(s){return s.loadRegistryInfo}function Tg(s){return s.updateToLatest}function Fg(s){return s.scope==="user"}function Lg(s){return s.scope==="project"}function Og(s){return s.scope==="user"}function zg(s){return s.scope==="project"}const zr=s=>{const e=nt.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(Wt,{outerClassName:i,className:"w-full",children:d}),e[7]=i,e[8]=d,e[9]=c):c=e[9],c},Kg=({entryId:s,spec:e})=>{const{t:n}=it(),a=ls(p=>p.registryInfo[e]),r=ls(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,m=a.currentVersion??"",P=async()=>{o(!0);try{(await r(s)).ok?W.success(n("settings.plugins.toast.updatedToLatest",{version:p})):W.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(D,{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:m,latest:p})})]}),t.jsx(G,{variant:"default",size:"sm",onClick:()=>{P()},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(D,{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)",f=d?"alert":"error-warning",u=(()=>{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(D,{name:f,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:u})]})]})};function $g(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 _l(s){return!s||Object.keys(s).length===0?"":JSON.stringify(s,null,2)}function co(s){return{mode:"entry",scope:s.scope,spec:s.spec,optionsJson:_l(s.options),fileName:"",content:""}}function mo(s,e){return{mode:"file",scope:s.scope,spec:"",optionsJson:"",fileName:s.fileName,content:e}}const uo=s=>{const e=nt.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},Ug=()=>{const{t:s}=it(),e=ls(x=>x.selectedId),n=ls(x=>x.entries),a=ls(x=>x.files),r=ls(x=>x.draft),i=ls(x=>x.setDraft),o=ls(x=>x.updateEntry),d=ls(x=>x.updateFile),c=ls(x=>x.readFile),f=l.useMemo(()=>e?n.find(x=>x.id===e)??null:null,[n,e]),u=l.useMemo(()=>e?a.find(x=>x.id===e)??null:null,[a,e]),[p,m]=l.useState(!1),[P,g]=l.useState(!1),h=l.useRef(new Map);if(l.useEffect(()=>{let x=!1;return f?(i(co(f)),()=>{x=!0}):u?(g(!0),(async()=>{const R=await c(u.id);if(x)return;g(!1);const C=R?.content??"";h.current.set(u.id,C),i(mo(u,C))})(),()=>{x=!0}):(i(null),()=>{x=!0})},[f,u,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(D,{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(f&&r&&r.mode==="entry"){const x=$g(r.optionsJson),R=x.ok,C=r.spec!==f.spec||r.optionsJson!==_l(f.options),N=()=>{i(co(f))},T=async()=>{if(!R)return;const k=r.spec.trim();if(!k){W.error(s("settings.plugins.validation.specRequired"));return}m(!0);try{const j=await o(f.id,{spec:k,options:x.value});j.ok?j.reloadFailed?W.warning(j.message||s("settings.plugins.toast.reloadFailed"),{description:j.warning}):W.success(j.message||s("settings.plugins.toast.updated")):W.error(j.message||s("settings.plugins.toast.reloadFailed"))}finally{m(!1)}};return t.jsxs(zr,{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(uo,{scope:f.scope,label:f.scope==="project"?s("settings.plugins.sidebar.group.projectEntries"):s("settings.plugins.sidebar.group.userEntries")})]})}),t.jsx(Kg,{entryId:f.id,spec:f.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(Ze,{value:r.spec,onChange:k=>i({...r,spec:k.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:k=>i({...r,optionsJson:k.target.value}),rows:10,className:ce("font-mono typography-meta min-h-[200px]",!R&&"border-[var(--status-error-border)]"),spellCheck:!1,placeholder:"{ }"}),!R&&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(G,{variant:"default",size:"sm",onClick:()=>{T()},disabled:!C||!R||p,children:s("settings.plugins.page.action.save")}),t.jsx(G,{variant:"outline",size:"sm",onClick:N,disabled:!C||p,children:s("settings.plugins.page.action.discard")})]})]})}if(u&&r&&r.mode==="file"){const x=h.current.get(u.id)??"",R=r.content!==x||r.fileName!==u.fileName,C=()=>{(async()=>{g(!0);const k=(await c(u.id))?.content??"";g(!1),h.current.set(u.id,k),i(mo(u,k))})()},N=async()=>{m(!0);try{const T=await d(u.id,{content:r.content});T.ok?(h.current.set(u.id,r.content),T.reloadFailed?W.warning(T.message||s("settings.plugins.toast.reloadFailed"),{description:T.warning}):W.success(T.message||s("settings.plugins.toast.updated"))):W.error(T.message||s("settings.plugins.toast.reloadFailed"))}finally{m(!1)}};return t.jsxs(zr,{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(uo,{scope:u.scope,label:u.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:u.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:T=>i({...r,content:T.target.value}),rows:16,className:"font-mono typography-meta min-h-[320px]",spellCheck:!1,disabled:P})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"default",size:"sm",onClick:()=>{N()},disabled:!R||p||P,children:s("settings.plugins.page.action.save")}),t.jsx(G,{variant:"outline",size:"sm",onClick:C,disabled:p||P,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(D,{name:"loader-4",className:"mx-auto mb-3 h-6 w-6 animate-spin opacity-50"})})})},Bg="<built-in>",In=s=>s?.path===Bg,Vg=s=>{const e=nt.c(150),{onItemSelect:n}=s,{t:a}=it(),[r,i]=l.useState(null),[o,d]=l.useState(""),[c,f]=l.useState(null),[u,p]=l.useState(!1),[m,P]=l.useState(null),{selectedSkillName:g,skills:h,setSelectedSkill:x,setSkillDraft:R,createSkill:C,deleteSkill:N,getSkillDetail:T}=Hs(Ss(_g));let k;e[0]!==n||e[1]!==x||e[2]!==R||e[3]!==h?(k=()=>{let ge="new-skill",et=1;for(;h.some(tt=>tt.name===ge);)ge=`new-skill-${et}`,et++;R({name:ge,scope:"user",source:"opencode",description:""}),x(ge),n?.()},e[0]=n,e[1]=x,e[2]=R,e[3]=h,e[4]=k):k=e[4];const j=k;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=async ge=>{In(ge)||f(ge)},e[5]=b):b=e[5];const A=b;let $;e[6]!==c||e[7]!==N||e[8]!==a?($=async()=>{if(!c)return;if(In(c)){f(null);return}p(!0),await N(c.name)?(W.success(a("settings.skills.sidebar.toast.skillDeleted",{name:c.name})),f(null)):W.error(a("settings.skills.sidebar.toast.deleteSkillFailed")),p(!1)},e[6]=c,e[7]=N,e[8]=a,e[9]=$):$=e[9];const F=$;let I;e[10]!==T||e[11]!==x||e[12]!==R||e[13]!==h||e[14]!==a?(I=async ge=>{if(In(ge))return;const et=ge.name;let tt=1,We=`${et}-copy`;for(;h.some(wt=>wt.name===We);)tt++,We=`${et}-copy-${tt}`;const xt=await T(ge.name);if(!xt){W.error(a("settings.skills.sidebar.toast.duplicateLoadFailed"));return}R({name:We,scope:ge.scope||"user",source:ge.source||"opencode",description:(xt.sources.md.fields.includes("description"),""),instructions:""}),x(We)},e[10]=T,e[11]=x,e[12]=R,e[13]=h,e[14]=a,e[15]=I):I=e[15];const v=I;let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=ge=>{In(ge)||(d(ge.name),i(ge))},e[16]=w):w=e[16];const L=w;let E;e[17]!==C||e[18]!==N||e[19]!==T||e[20]!==r||e[21]!==o||e[22]!==x||e[23]!==h||e[24]!==a?(E=async()=>{if(!r)return;if(In(r)){i(null);return}const ge=o.trim().replace(/\s+/g,"-").toLowerCase();if(!ge){W.error(a("settings.skills.page.toast.skillNameRequired"));return}if(ge===r.name){i(null);return}if(h.some(We=>We.name===ge)){W.error(a("settings.skills.page.toast.skillExists"));return}if(!await T(r.name)){W.error(a("settings.skills.sidebar.toast.renameLoadFailed")),i(null);return}await C({name:ge,description:"Renamed skill",scope:r.scope,source:r.source})?await N(r.name)?(W.success(`Skill renamed to "${ge}"`),x(ge)):W.error(a("settings.skills.sidebar.toast.removeOldAfterRenameFailed")):W.error(a("settings.skills.sidebar.toast.renameFailed")),i(null)},e[17]=C,e[18]=N,e[19]=T,e[20]=r,e[21]=o,e[22]=x,e[23]=h,e[24]=a,e[25]=E):E=e[25];const _=E;let B;e[26]!==h?(B=h.filter(Hg),e[26]=h,e[27]=B):B=e[27];const Z=B;let Q;e[28]!==h?(Q=h.filter(Wg),e[28]=h,e[29]=Q):Q=e[29];const M=Q;let X;e[30]===Symbol.for("react.memo_cache_sentinel")?(X=function(et){const tt={},We=[];for(const wt of et)wt.group?(tt[wt.group]||(tt[wt.group]=[]),tt[wt.group].push(wt)):We.push(wt);const xt=Object.keys(tt).sort(qg).map(wt=>({name:wt,skills:[...tt[wt]].sort(Gg)}));return We.sort(Jg),{sortedGroups:xt,ungrouped:We}},e[30]=X):X=e[30];const ee=X;let K;e[31]!==Z?(K=ee(Z),e[31]=Z,e[32]=K):K=e[32];const O=K;let Y;e[33]!==M?(Y=ee(M),e[33]=M,e[34]=Y):Y=e[34];const U=Y;let ne;e[35]===Symbol.for("react.memo_cache_sentinel")?(ne=ce("flex h-full flex-col","bg-background"),e[35]=ne):ne=e[35];let re;e[36]!==a?(re=a("settings.skills.sidebar.title"),e[36]=a,e[37]=re):re=e[37];let V;e[38]!==re?(V=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:re}),e[38]=re,e[39]=V):V=e[39];let oe;e[40]===Symbol.for("react.memo_cache_sentinel")?(oe=t.jsx(sa,{className:"mb-3"}),e[40]=oe):oe=e[40];let fe;e[41]!==h.length||e[42]!==a?(fe=a("settings.skills.sidebar.total",{count:h.length}),e[41]=h.length,e[42]=a,e[43]=fe):fe=e[43];let xe;e[44]!==fe?(xe=t.jsx("span",{className:"typography-meta text-muted-foreground",children:fe}),e[44]=fe,e[45]=xe):xe=e[45];let Ie;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),e[46]=Ie):Ie=e[46];let ve;e[47]!==j?(ve=t.jsx(G,{size:"sm","data-settings-item":"skills.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:j,children:Ie}),e[47]=j,e[48]=ve):ve=e[48];let we;e[49]!==xe||e[50]!==ve?(we=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[xe,ve]}),e[49]=xe,e[50]=ve,e[51]=we):we=e[51];let be;e[52]!==V||e[53]!==we?(be=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[V,oe,we]}),e[52]=V,e[53]=we,e[54]=be):be=e[54];let se;e[55]!==O||e[56]!==U||e[57]!==v||e[58]!==n||e[59]!==m||e[60]!==Z||e[61]!==g||e[62]!==x||e[63]!==h.length||e[64]!==a||e[65]!==M?(se=t.jsx(Wt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:h.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(D,{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:[Z.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")}),O.sortedGroups.map(ge=>{const{name:et,skills:tt}=ge;return t.jsx(Fr,{label:et,count:tt.length,storageKey:"project-skills",children:tt.map(We=>t.jsx(ha,{skill:We,isSelected:g===We.name,onSelect:()=>{x(We.name),n?.()},onRename:()=>L(We),onDelete:()=>A(We),onDuplicate:()=>v(We),isMenuOpen:m===We.name,onMenuOpenChange:xt=>P(xt?We.name:null)},We.name))},et)}),O.ungrouped.map(ge=>t.jsx(ha,{skill:ge,isSelected:g===ge.name,onSelect:()=>{x(ge.name),n?.()},onRename:()=>L(ge),onDelete:()=>A(ge),onDuplicate:()=>v(ge),isMenuOpen:m===ge.name,onMenuOpenChange:et=>P(et?ge.name:null)},ge.name))]}),M.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")}),U.sortedGroups.map(ge=>{const{name:et,skills:tt}=ge;return t.jsx(Fr,{label:et,count:tt.length,storageKey:"user-skills",children:tt.map(We=>t.jsx(ha,{skill:We,isSelected:g===We.name,onSelect:()=>{x(We.name),n?.()},onRename:()=>L(We),onDelete:()=>A(We),onDuplicate:()=>v(We),isMenuOpen:m===We.name,onMenuOpenChange:xt=>P(xt?We.name:null)},We.name))},et)}),U.ungrouped.map(ge=>t.jsx(ha,{skill:ge,isSelected:g===ge.name,onSelect:()=>{x(ge.name),n?.()},onRename:()=>L(ge),onDelete:()=>A(ge),onDuplicate:()=>v(ge),isMenuOpen:m===ge.name,onMenuOpenChange:et=>P(et?ge.name:null)},ge.name))]})]})}),e[55]=O,e[56]=U,e[57]=v,e[58]=n,e[59]=m,e[60]=Z,e[61]=g,e[62]=x,e[63]=h.length,e[64]=a,e[65]=M,e[66]=se):se=e[66];const le=c!==null;let ye;e[67]!==u?(ye=ge=>{!ge&&!u&&f(null)},e[67]=u,e[68]=ye):ye=e[68];let H;e[69]!==a?(H=a("settings.skills.sidebar.deleteDialog.title"),e[69]=a,e[70]=H):H=e[70];let te;e[71]!==H?(te=t.jsx(Kt,{children:H}),e[71]=H,e[72]=te):te=e[72];const ae=c?.name??"";let me;e[73]!==a||e[74]!==ae?(me=a("settings.skills.sidebar.deleteDialog.description",{name:ae}),e[73]=a,e[74]=ae,e[75]=me):me=e[75];let Me;e[76]!==me?(Me=t.jsx(Bt,{children:me}),e[76]=me,e[77]=Me):Me=e[77];let Ne;e[78]!==te||e[79]!==Me?(Ne=t.jsxs($t,{children:[te,Me]}),e[78]=te,e[79]=Me,e[80]=Ne):Ne=e[80];let De;e[81]===Symbol.for("react.memo_cache_sentinel")?(De=()=>f(null),e[81]=De):De=e[81];let Ee;e[82]!==a?(Ee=a("settings.common.actions.cancel"),e[82]=a,e[83]=Ee):Ee=e[83];let Pe;e[84]!==u||e[85]!==Ee?(Pe=t.jsx(G,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:De,disabled:u,children:Ee}),e[84]=u,e[85]=Ee,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 Le;e[89]!==F||e[90]!==u||e[91]!==Te?(Le=t.jsx(G,{size:"sm",onClick:F,disabled:u,children:Te}),e[89]=F,e[90]=u,e[91]=Te,e[92]=Le):Le=e[92];let Be;e[93]!==Pe||e[94]!==Le?(Be=t.jsxs(Jt,{children:[Pe,Le]}),e[93]=Pe,e[94]=Le,e[95]=Be):Be=e[95];let He;e[96]!==Ne||e[97]!==Be?(He=t.jsxs(zt,{className:"max-w-md",children:[Ne,Be]}),e[96]=Ne,e[97]=Be,e[98]=He):He=e[98];let Ue;e[99]!==le||e[100]!==ye||e[101]!==He?(Ue=t.jsx(Ot,{open:le,onOpenChange:ye,children:He}),e[99]=le,e[100]=ye,e[101]=He,e[102]=Ue):Ue=e[102];const Je=r!==null;let de;e[103]===Symbol.for("react.memo_cache_sentinel")?(de=ge=>!ge&&i(null),e[103]=de):de=e[103];let q;e[104]!==a?(q=a("settings.skills.sidebar.renameDialog.title"),e[104]=a,e[105]=q):q=e[105];let ue;e[106]!==q?(ue=t.jsx(Kt,{children:q}),e[106]=q,e[107]=ue):ue=e[107];const je=r?.name??"";let Re;e[108]!==a||e[109]!==je?(Re=a("settings.skills.sidebar.renameDialog.description",{name:je}),e[108]=a,e[109]=je,e[110]=Re):Re=e[110];let Ce;e[111]!==Re?(Ce=t.jsx(Bt,{children:Re}),e[111]=Re,e[112]=Ce):Ce=e[112];let _e;e[113]!==ue||e[114]!==Ce?(_e=t.jsxs($t,{children:[ue,Ce]}),e[113]=ue,e[114]=Ce,e[115]=_e):_e=e[115];let J;e[116]===Symbol.for("react.memo_cache_sentinel")?(J=ge=>d(ge.target.value),e[116]=J):J=e[116];let y;e[117]!==a?(y=a("settings.skills.sidebar.renameDialog.placeholder"),e[117]=a,e[118]=y):y=e[118];let pe;e[119]!==_?(pe=ge=>{ge.key==="Enter"&&_()},e[119]=_,e[120]=pe):pe=e[120];let Ae;e[121]!==o||e[122]!==y||e[123]!==pe?(Ae=t.jsx(Ze,{value:o,onChange:J,placeholder:y,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:pe}),e[121]=o,e[122]=y,e[123]=pe,e[124]=Ae):Ae=e[124];let Oe;e[125]===Symbol.for("react.memo_cache_sentinel")?(Oe=()=>i(null),e[125]=Oe):Oe=e[125];let qe;e[126]!==a?(qe=a("settings.common.actions.cancel"),e[126]=a,e[127]=qe):qe=e[127];let at;e[128]!==qe?(at=t.jsx(G,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:Oe,children:qe}),e[128]=qe,e[129]=at):at=e[129];let rt;e[130]!==a?(rt=a("settings.common.actions.rename"),e[130]=a,e[131]=rt):rt=e[131];let st;e[132]!==_||e[133]!==rt?(st=t.jsx(G,{size:"sm",onClick:_,children:rt}),e[132]=_,e[133]=rt,e[134]=st):st=e[134];let dt;e[135]!==at||e[136]!==st?(dt=t.jsxs(Jt,{children:[at,st]}),e[135]=at,e[136]=st,e[137]=dt):dt=e[137];let Ye;e[138]!==_e||e[139]!==Ae||e[140]!==dt?(Ye=t.jsxs(zt,{children:[_e,Ae,dt]}),e[138]=_e,e[139]=Ae,e[140]=dt,e[141]=Ye):Ye=e[141];let $e;e[142]!==Je||e[143]!==Ye?($e=t.jsx(Ot,{open:Je,onOpenChange:de,children:Ye}),e[142]=Je,e[143]=Ye,e[144]=$e):$e=e[144];let mt;return e[145]!==be||e[146]!==se||e[147]!==Ue||e[148]!==$e?(mt=t.jsxs("div",{className:ne,children:[be,se,Ue,$e]}),e[145]=be,e[146]=se,e[147]=Ue,e[148]=$e,e[149]=mt):mt=e[149],mt},ha=s=>{const e=nt.c(49),{skill:n,isSelected:a,onSelect:r,onDelete:i,onRename:o,onDuplicate:d,isMenuOpen:c,onMenuOpenChange:f}=s,{t:u}=it();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ea(),e[0]=p):p=e[0];const m=p;let P;e[1]!==n.source||e[2]!==u?(P=n.source==="claude"?u("settings.skills.sidebar.badge.claude"):n.source==="agents"?u("settings.skills.sidebar.badge.agents"):u("settings.skills.sidebar.badge.opencode"),e[1]=n.source,e[2]=u,e[3]=P):P=e[3];const g=P;let h;e[4]!==n?(h=In(n),e[4]=n,e[5]=h):h=e[5];const x=h,[R,C]=l.useState(!1);let N;e[6]!==i||e[7]!==d||e[8]!==o||e[9]!==u?(N=M=>t.jsxs(t.Fragment,{children:[t.jsxs(M,{onClick:X=>{X.stopPropagation(),o()},children:[t.jsx(D,{name:"edit",className:"h-4 w-4 mr-px"}),u("settings.common.actions.rename")]}),t.jsxs(M,{onClick:X=>{X.stopPropagation(),d()},children:[t.jsx(D,{name:"file-copy",className:"h-4 w-4 mr-px"}),u("settings.common.actions.duplicate")]}),t.jsxs(M,{onClick:X=>{X.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{name:"delete-bin",className:"h-4 w-4 mr-px"}),u("settings.common.actions.delete")]})]}),e[6]=i,e[7]=d,e[8]=o,e[9]=u,e[10]=N):N=e[10];const T=N,k=!x&&R,j=a?"bg-interactive-selection":"hover:bg-interactive-hover";let b;e[11]!==j?(b=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",j),e[11]=j,e[12]=b):b=e[12];let A;e[13]!==x?(A=!m&&!x?M=>{M.preventDefault(),C(!0)}:void 0,e[13]=x,e[14]=A):A=e[14];let $;e[15]!==b||e[16]!==A?($=t.jsx("div",{className:b,onContextMenu:A}),e[15]=b,e[16]=A,e[17]=$):$=e[17];let F;e[18]!==n.name?(F=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[18]=n.name,e[19]=F):F=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]!==g?(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:g}),e[22]=g,e[23]=v):v=e[23];let w;e[24]!==F||e[25]!==I||e[26]!==v?(w=t.jsxs("div",{className:"flex items-center gap-1.5",children:[F,I,v]}),e[24]=F,e[25]=I,e[26]=v,e[27]=w):w=e[27];let L;e[28]!==r||e[29]!==w?(L=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:w}),e[28]=r,e[29]=w,e[30]=L):L=e[30];let E;e[31]!==x||e[32]!==c||e[33]!==f||e[34]!==T?(E=x?null:t.jsxs(gs,{open:c,onOpenChange:M=>{M&&C(!1),f(M)},children:[t.jsx(us,{asChild:!0,children:t.jsx(G,{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(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:T(js)})]}),e[31]=x,e[32]=c,e[33]=f,e[34]=T,e[35]=E):E=e[35];let _;e[36]!==L||e[37]!==E?(_=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[L,E]}),e[36]=L,e[37]=E,e[38]=_):_=e[38];let B;e[39]!==_||e[40]!==$?(B=t.jsx(nn,{render:$,children:_}),e[39]=_,e[40]=$,e[41]=B):B=e[41];let Z;e[42]!==x||e[43]!==T?(Z=x?null:t.jsx(an,{className:"w-fit min-w-20",children:T(qs)}),e[42]=x,e[43]=T,e[44]=Z):Z=e[44];let Q;return e[45]!==B||e[46]!==Z||e[47]!==k?(Q=t.jsxs(sn,{open:k,onOpenChange:C,children:[B,Z]}),e[45]=B,e[46]=Z,e[47]=k,e[48]=Q):Q=e[48],Q};function _g(s){return{selectedSkillName:s.selectedSkillName,skills:s.skills,setSelectedSkill:s.setSelectedSkill,setSkillDraft:s.setSkillDraft,createSkill:s.createSkill,deleteSkill:s.deleteSkill,getSkillDetail:s.getSkillDetail}}function Hg(s){return s.scope==="project"}function Wg(s){return s.scope==="user"}function qg(s,e){return s.localeCompare(e)}function Gg(s,e){return s.name.localeCompare(e.name)}function Jg(s,e){return s.name.localeCompare(e.name)}const Qg=s=>s!==null&&typeof s=="object"&&"updateStatus"in s&&typeof s.updateStatus=="function",Yg=s=>{const e=document.createElement("div");e.className="cm-vim-panel";const n=Jc(s);if(!n)return{top:!1,dom:e};n.state.statusbar=e;const a=n.state.vimPlugin;return Qg(a)&&a.updateStatus(),{top:!1,dom:e,destroy(){n.state.statusbar===e&&(n.state.statusbar=null)}}};function po(s){return s?[Wc(),qc.of(Yg),Gc()]:[]}const Xg={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Zg={case:"Match case",re:"Regular expression",word:"Match whole word"};function eh(s){const e=s.querySelector(".cm-search");if(e){for(const[n,a]of Object.entries(Xg)){const r=e.querySelector(`button[name="${n}"]`);r&&!r.title&&(r.title=a)}for(const[n,a]of Object.entries(Zg)){const i=e.querySelector(`input[name="${n}"]`)?.parentElement;i&&!i.title&&(i.title=a)}}}const ir=new WeakMap;function th(s,e){const n=Ma(s.state);if(!n.valid)return ir.delete(s),0;const a=ir.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 ir.set(s,{query:n,doc:s.state.doc,total:i}),i}function sh(s){const e=Ma(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 go(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=th(e,n),o=i===0?0:sh(e);r.textContent=i===0?"":`${o}/${i}`}const ho=new jn,fo=new jn,xo=new jn,bo=new jn,yo=new jn,vo=new jn,jo=new jn,wo=s=>s,or=nd,nh=ad,ah=rd;class rh extends id{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 No=(s,e)=>!s||s.length===0?[]:vl.define({create(n){const a=new qr,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,Oa.widget({widget:new rh(i.id,e),block:!0,side:1}))}return a.finish()},update(n,a){return n.map(a.changes)},provide:n=>Fs.decorations.from(n)}),ko=s=>{if(!s)return[];const e=Math.max(1,s.start),n=Math.max(e,s.end);return yl.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 qr;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,Oa.line({class:"oc-cm-selected-line"}))}return r.finish()}},{decorations:a=>a.decorations})};function So({value:s,onChange:e,extensions:n,className:a,readOnly:r,lineNumbersConfig:i,highlightLines:o,onViewReady:d,onViewDestroy:c,blockWidgets:f,enableSearch:u,searchOpen:p,onSearchOpenChange:m,vimMode:P}){const g=l.useRef(null),h=l.useRef(null),x=l.useRef(s),R=l.useRef(e),C=l.useRef(d),N=l.useRef(c),T=l.useRef(m),k=l.useRef(f),j=l.useRef(P),b=l.useRef(new Map),[A,$]=l.useState([]),F=l.useCallback(v=>{const w=(v??[]).map(L=>{const E=b.current.get(L.id);return E?{id:L.id,content:L.content,container:E}:null}).filter(L=>L!==null);$(L=>L.length===w.length&&L.every((E,_)=>{const B=w[_];return E.id===B.id&&E.content===B.content&&E.container===B.container})?L:w)},[]),I=l.useCallback(v=>{const w=g.current,L=v??h.current;if(!w||!L)return;const E=L.dom.querySelector(".cm-gutters"),_=E instanceof HTMLElement?E.getBoundingClientRect().width:0;w.style.setProperty("--oc-editor-gutter-width",`${_}px`)},[]);return l.useEffect(()=>{x.current=s},[s]),l.useEffect(()=>{R.current=e},[e]),l.useEffect(()=>{C.current=d,N.current=c},[d,c]),l.useEffect(()=>{T.current=m},[m]),l.useEffect(()=>{k.current=f,F(f)},[f,F]),l.useEffect(()=>{if(!g.current)return;const v=(()=>{if(typeof document>"u")return null;const L=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(L)return L;const E=window.__OPENCHAMBER_CSP_NONCE__;return typeof E=="string"&&E.length>0?E:null})(),w=Qc.create({doc:x.current,extensions:[...v?[Fs.cspNonce.of(v)]:[],Yc({fixed:!0}),ho.of(ri(i)),Xc(),Zc.of(" "),jo.of(po(P)),Wa.of([ed,...td,...sd]),Fs.updateListener.of(L=>{I(L.view),(L.viewportChanged||L.geometryChanged)&&F(k.current);const E=ii(L.startState),_=ii(L.state);E!==_&&T.current?.(_);const B=!Ma(L.startState).eq(Ma(L.state));if(_&&(E!==_||B||L.docChanged||L.selectionSet)&&go(L.view.dom,L.view,E!==_||B||L.docChanged),!L.docChanged)return;const Z=L.state.doc.toString();x.current=Z,R.current(Z),F(k.current)}),fo.of(Fs.editable.of(!r)),xo.of(n??[]),bo.of(ko(o)),yo.of(No(f,b.current)),vo.of(u?[oi({top:!0}),Wa.of(wo(li))]:[])]});return h.current=new Fs({state:w,parent:g.current}),or(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{I(h.current),F(k.current)}),h.current&&C.current?.(h.current),()=>{N.current?.(),h.current?.destroy(),h.current=null,$([])}},[k,I,F]),l.useEffect(()=>{const v=h.current;v&&(v.dispatch({effects:[ho.reconfigure(ri(i)),fo.reconfigure(Fs.editable.of(!r)),xo.reconfigure(n??[]),bo.reconfigure(ko(o)),yo.reconfigure(No(f,b.current)),vo.reconfigure(u?[oi({top:!0}),Wa.of(wo(li))]:[])]}),or(v,v.state.doc.length,200),v.requestMeasure(),requestAnimationFrame(()=>{I(v),F(k.current)}))},[n,o,i,r,f,u,I,F]),l.useEffect(()=>{const v=h.current;if(!v){j.current=P;return}j.current!==P&&(j.current=P,v.dispatch({effects:jo.reconfigure(po(P))}))},[P]),l.useEffect(()=>{const v=h.current;!v||u===!1||(p?(nh(v),requestAnimationFrame(()=>{eh(v.dom),go(v.dom,v,!0)})):ah(v))},[p,u]),l.useEffect(()=>{const v=h.current;if(!v)return;const w=v.state.doc.toString();w!==s&&(v.dispatch({changes:{from:0,to:w.length,insert:s}}),or(v,v.state.doc.length,300),v.requestMeasure(),requestAnimationFrame(()=>I(v)))},[s,I]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:g,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)}),A.map(v=>wa.createPortal(v.content,v.container,v.id))]})}const ih=s=>{const e=nt.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(D,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(D,{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(At,{asChild:!0,children:t.jsx(G,{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 f;e[6]!==o?(f=t.jsx(Et,{sideOffset:8,children:o}),e[6]=o,e[7]=f):f=e[7];let u;return e[8]!==c||e[9]!==f?(u=t.jsxs(It,{children:[c,f]}),e[8]=c,e[9]=f,e[10]=u):u=e[10],u},ks=ln()(ta(Wr((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 Kd();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 zd();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 Od();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=Os()?.settings;if(r)try{const o=(await r.load())?.settings||{};a=n(o.defaultGitIdentityId)}catch{}}if(a===null)try{const r=await ht("/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 Pt({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 Ld(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 Fd(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 Td(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:Yr(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=ks);const oh=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,lh=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},ch=async()=>{try{const s=Os()?.settings;if(s)return(await s.load())?.settings||{};const e=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});return e.ok?await e.json().catch(()=>null):null}catch{return null}},dh=s=>{const e=nt.c(160),{open:n,onOpenChange:a}=s,{t:r}=it(),i=Vs(mh),o=Vs(uh),d=Vs(ph),c=Vs(gh),f=Vs(hh),u=ks(fh),p=ks(xh),[m,P]=l.useState(""),[g,h]=l.useState(""),[x,R]=l.useState("");let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[0]=C):C=e[0];const[N,T]=l.useState(C),[k,j]=l.useState(null),[b,A]=l.useState(!1);let $;e[1]===Symbol.for("react.memo_cache_sentinel")?($=[],e[1]=$):$=e[1];const[F,I]=l.useState($),[v,w]=l.useState(null),L=l.useRef(0);let E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=ge=>{L.current=L.current+1,A(!1),j(null),ge?.clearIdentity&&(I([]),w(null))},e[2]=E):E=e[2];const _=E;let B,Z;e[3]!==p||e[4]!==n?(B=()=>{n&&(L.current=L.current+1,P(""),h(""),R(""),j(null),A(!1),I([]),w(null),p(),(async()=>{const ge=await ch(),et=Array.isArray(ge?.skillCatalogs)?ge?.skillCatalogs:[];T(et||[])})())},Z=[n,p],e[3]=p,e[4]=n,e[5]=B,e[6]=Z):(B=e[5],Z=e[6]),l.useEffect(B,Z);let Q;e[7]!==g?(Q=g.trim(),e[7]=g,e[8]=Q):Q=e[8];const M=Q;let X;e[9]!==x?(X=x.trim(),e[9]=x,e[10]=X):X=e[10];const ee=X;let K;if(e[11]!==N||e[12]!==M||e[13]!==ee){let ge;e[15]!==M||e[16]!==ee?(ge=et=>{const tt=(et.source||"").trim(),We=(et.subpath||"").trim();return tt===M&&We===ee},e[15]=M,e[16]=ee,e[17]=ge):ge=e[17],K=N.some(ge),e[11]=N,e[12]=M,e[13]=ee,e[14]=K}else K=e[14];const O=K;let Y;e[18]!==u||e[19]!==v||e[20]!==m||e[21]!==i||e[22]!==g||e[23]!==x||e[24]!==r?(Y=async()=>{const ge=g.trim();if(!ge){W.error(r("settings.skills.catalog.add.toast.repositoryRequired"));return}m.trim()||P(lh(ge)),A(!1),j(null);const et=L.current+1;L.current=et;const tt=await i({source:ge,subpath:x.trim()||void 0,gitIdentityId:v||void 0});if(L.current!==et)return;if(!tt.ok){if(tt.error?.kind==="authRequired"){if(fs()){W.error(r("settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode"));return}const xt=tt.error.identities||[];if(I(xt),!v&&xt.length>0){const wt=u&&u!=="global"&&xt.some(St=>St.id===u)?u:xt[0].id;w(wt)}W.error(r("settings.skills.catalog.add.toast.authenticationRequiredScan"));return}W.error(tt.error?.message||r("settings.skills.catalog.add.toast.scanFailed"));return}const We=tt.items?.length||0;if(j(We),We===0){W.error(r("settings.skills.catalog.add.toast.noSkillsFound")),A(!1);return}I([]),A(!0),W.success(r("settings.skills.catalog.shared.toast.foundSkills",{count:We}))},e[18]=u,e[19]=v,e[20]=m,e[21]=i,e[22]=g,e[23]=x,e[24]=r,e[25]=Y):Y=e[25];const U=Y;let ne;e[26]!==N||e[27]!==v||e[28]!==O||e[29]!==m||e[30]!==o||e[31]!==d||e[32]!==a||e[33]!==b||e[34]!==c||e[35]!==g||e[36]!==x||e[37]!==r?(ne=async()=>{const ge=m.trim(),et=g.trim(),tt=x.trim();if(!ge){W.error(r("settings.skills.catalog.add.toast.catalogNameRequired"));return}if(!et){W.error(r("settings.skills.catalog.add.toast.repositoryRequired"));return}if(!b){W.error(r("settings.skills.catalog.add.toast.scanBeforeAdd"));return}if(O){W.error(r("settings.skills.catalog.add.toast.catalogAlreadyExists"));return}const We={id:oh(),label:ge,source:et,...tt?{subpath:tt}:{},...v?{gitIdentityId:v}:{}},xt=[...N,We];try{await Pt({skillCatalogs:xt}),T(xt),W.success(r("settings.skills.catalog.add.toast.catalogAdded")),await o({refresh:!0}),await d(We.id,{refresh:!0}),c(We.id),a(!1)}catch(wt){const St=wt;W.error(St instanceof Error?St.message:r("settings.skills.catalog.add.toast.saveFailed"))}},e[26]=N,e[27]=v,e[28]=O,e[29]=m,e[30]=o,e[31]=d,e[32]=a,e[33]=b,e[34]=c,e[35]=g,e[36]=x,e[37]=r,e[38]=ne):ne=e[38];const re=ne;let V;e[39]!==r?(V=r("settings.skills.catalog.add.title"),e[39]=r,e[40]=V):V=e[40];let oe;e[41]!==V?(oe=t.jsx(Kt,{children:V}),e[41]=V,e[42]=oe):oe=e[42];let fe;e[43]!==r?(fe=r("settings.skills.catalog.add.descriptionPrefix"),e[43]=r,e[44]=fe):fe=e[44];let xe;e[45]===Symbol.for("react.memo_cache_sentinel")?(xe=t.jsx("code",{className:"font-mono",children:"SKILL.md"}),e[45]=xe):xe=e[45];let Ie;e[46]!==r?(Ie=r("settings.skills.catalog.add.descriptionSuffix"),e[46]=r,e[47]=Ie):Ie=e[47];let ve;e[48]!==fe||e[49]!==Ie?(ve=t.jsxs(Bt,{children:[fe," ",xe,Ie]}),e[48]=fe,e[49]=Ie,e[50]=ve):ve=e[50];let we;e[51]!==oe||e[52]!==ve?(we=t.jsxs($t,{children:[oe,ve]}),e[51]=oe,e[52]=ve,e[53]=we):we=e[53];let be;e[54]!==r?(be=r("settings.skills.catalog.add.field.catalogName"),e[54]=r,e[55]=be):be=e[55];let se;e[56]!==be?(se=t.jsx("label",{className:"typography-ui-label text-foreground",children:be}),e[56]=be,e[57]=se):se=e[57];let le;e[58]===Symbol.for("react.memo_cache_sentinel")?(le=ge=>P(ge.target.value),e[58]=le):le=e[58];let ye;e[59]!==r?(ye=r("settings.skills.catalog.add.field.catalogNamePlaceholder"),e[59]=r,e[60]=ye):ye=e[60];let H;e[61]!==m||e[62]!==ye?(H=t.jsx(Ze,{value:m,onChange:le,placeholder:ye}),e[61]=m,e[62]=ye,e[63]=H):H=e[63];let te;e[64]!==se||e[65]!==H?(te=t.jsxs("div",{className:"space-y-2",children:[se,H]}),e[64]=se,e[65]=H,e[66]=te):te=e[66];let ae;e[67]!==r?(ae=r("settings.skills.catalog.add.field.repository"),e[67]=r,e[68]=ae):ae=e[68];let me;e[69]!==ae?(me=t.jsx("label",{className:"typography-ui-label text-foreground",children:ae}),e[69]=ae,e[70]=me):me=e[70];let Me;e[71]===Symbol.for("react.memo_cache_sentinel")?(Me=ge=>{h(ge.target.value),_({clearIdentity:!0})},e[71]=Me):Me=e[71];let Ne;e[72]!==r?(Ne=r("settings.skills.catalog.shared.field.repositoryPlaceholder"),e[72]=r,e[73]=Ne):Ne=e[73];let De;e[74]!==g||e[75]!==Ne?(De=t.jsx(Ze,{value:g,onChange:Me,placeholder:Ne}),e[74]=g,e[75]=Ne,e[76]=De):De=e[76];let Ee;e[77]!==r?(Ee=r("settings.skills.catalog.add.field.repositoryHint"),e[77]=r,e[78]=Ee):Ee=e[78];let Pe;e[79]!==Ee?(Pe=t.jsx("p",{className:"typography-micro text-muted-foreground",children:Ee}),e[79]=Ee,e[80]=Pe):Pe=e[80];let Te;e[81]!==me||e[82]!==De||e[83]!==Pe?(Te=t.jsxs("div",{className:"space-y-2",children:[me,De,Pe]}),e[81]=me,e[82]=De,e[83]=Pe,e[84]=Te):Te=e[84];let Le;e[85]!==r?(Le=r("settings.skills.catalog.add.field.optionalSubpath"),e[85]=r,e[86]=Le):Le=e[86];let Be;e[87]!==Le?(Be=t.jsx("label",{className:"typography-ui-label text-foreground",children:Le}),e[87]=Le,e[88]=Be):Be=e[88];let He;e[89]===Symbol.for("react.memo_cache_sentinel")?(He=ge=>{R(ge.target.value),_({clearIdentity:!0})},e[89]=He):He=e[89];let Ue;e[90]!==r?(Ue=r("settings.skills.catalog.shared.field.subpathPlaceholder"),e[90]=r,e[91]=Ue):Ue=e[91];let Je;e[92]!==x||e[93]!==Ue?(Je=t.jsx(Ze,{value:x,onChange:He,placeholder:Ue}),e[92]=x,e[93]=Ue,e[94]=Je):Je=e[94];let de;e[95]!==Be||e[96]!==Je?(de=t.jsxs("div",{className:"space-y-2",children:[Be,Je]}),e[95]=Be,e[96]=Je,e[97]=de):de=e[97];let q;e[98]!==v||e[99]!==F||e[100]!==r?(q=F.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(Rt,{value:v||"",onValueChange:ge=>{w(ge),_()},children:[t.jsx(Tt,{className:"w-fit",children:t.jsx("span",{children:F.find(ge=>ge.id===v)?.name||r("settings.skills.catalog.shared.auth.chooseIdentity")})}),t.jsx(Ft,{align:"start",children:F.map(bh)})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:r("settings.skills.catalog.shared.auth.footerHint")})]}):null,e[98]=v,e[99]=F,e[100]=r,e[101]=q):q=e[101];let ue;e[102]!==k||e[103]!==r?(ue=k!==null?t.jsx("div",{className:"typography-meta text-muted-foreground",children:r("settings.skills.catalog.add.scanResult",{count:k})}):null,e[102]=k,e[103]=r,e[104]=ue):ue=e[104];let je;e[105]!==O||e[106]!==r?(je=O?t.jsx("div",{className:"typography-meta text-muted-foreground",children:r("settings.skills.catalog.add.duplicateMessage")}):null,e[105]=O,e[106]=r,e[107]=je):je=e[107];let Re;e[108]!==te||e[109]!==Te||e[110]!==de||e[111]!==q||e[112]!==ue||e[113]!==je?(Re=t.jsxs("div",{className:"space-y-4",children:[te,Te,de,q,ue,je]}),e[108]=te,e[109]=Te,e[110]=de,e[111]=q,e[112]=ue,e[113]=je,e[114]=Re):Re=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 J;e[119]!==Ce||e[120]!==_e?(J=t.jsx(G,{size:"sm",variant:"ghost",onClick:Ce,children:_e}),e[119]=Ce,e[120]=_e,e[121]=J):J=e[121];let y;e[122]!==U?(y=()=>{U()},e[122]=U,e[123]=y):y=e[123];let pe;e[124]!==f||e[125]!==g?(pe=f||!g.trim(),e[124]=f,e[125]=g,e[126]=pe):pe=e[126];let Ae;e[127]===Symbol.for("react.memo_cache_sentinel")?(Ae=t.jsx(D,{name:"git-repository",className:"h-4 w-4"}),e[127]=Ae):Ae=e[127];let Oe;e[128]!==f||e[129]!==r?(Oe=r(f?"settings.skills.catalog.shared.actions.scanning":"settings.skills.catalog.shared.actions.scan"),e[128]=f,e[129]=r,e[130]=Oe):Oe=e[130];let qe;e[131]!==y||e[132]!==pe||e[133]!==Oe?(qe=t.jsxs(G,{size:"sm",className:"gap-2",variant:"ghost",onClick:y,disabled:pe,children:[Ae,Oe]}),e[131]=y,e[132]=pe,e[133]=Oe,e[134]=qe):qe=e[134];let at;e[135]!==re?(at=()=>{re()},e[135]=re,e[136]=at):at=e[136];let rt;e[137]!==O||e[138]!==m||e[139]!==b||e[140]!==g?(rt=!b||O||!m.trim()||!g.trim(),e[137]=O,e[138]=m,e[139]=b,e[140]=g,e[141]=rt):rt=e[141];let st;e[142]!==r?(st=r("settings.skills.catalog.add.actions.addCatalog"),e[142]=r,e[143]=st):st=e[143];let dt;e[144]!==at||e[145]!==rt||e[146]!==st?(dt=t.jsx(G,{size:"sm",onClick:at,disabled:rt,children:st}),e[144]=at,e[145]=rt,e[146]=st,e[147]=dt):dt=e[147];let Ye;e[148]!==J||e[149]!==qe||e[150]!==dt?(Ye=t.jsxs(Jt,{children:[J,qe,dt]}),e[148]=J,e[149]=qe,e[150]=dt,e[151]=Ye):Ye=e[151];let $e;e[152]!==we||e[153]!==Re||e[154]!==Ye?($e=t.jsxs(zt,{className:"max-w-xl",children:[we,Re,Ye]}),e[152]=we,e[153]=Re,e[154]=Ye,e[155]=$e):$e=e[155];let mt;return e[156]!==a||e[157]!==n||e[158]!==$e?(mt=t.jsx(Ot,{open:n,onOpenChange:a,children:$e}),e[156]=a,e[157]=n,e[158]=$e,e[159]=mt):mt=e[159],mt};function mh(s){return s.scanRepo}function uh(s){return s.loadCatalog}function ph(s){return s.loadSource}function gh(s){return s.setSelectedSource}function hh(s){return s.isScanning}function fh(s){return s.defaultGitIdentityId}function xh(s){return s.loadDefaultGitIdentityId}function bh(s){return t.jsx(gt,{value:s.id,children:s.name},s.id)}const yh=s=>{const e=nt.c(85),{open:n,onOpenChange:a,conflicts:r,onConfirm:i}=s,{t:o}=it();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const[c,f]=l.useState(d);let u,p;e[1]!==r||e[2]!==n?(u=()=>{if(!n)return;const re={};for(const V of r)re[V.skillName]="skip";f(re)},p=[n,r],e[1]=r,e[2]=n,e[3]=u,e[4]=p):(u=e[3],p=e[4]),l.useEffect(u,p);let m;e[5]!==r?(m=re=>{const V={};for(const oe of r)V[oe.skillName]=re;f(V)},e[5]=r,e[6]=m):m=e[6];const P=m;let g;e[7]!==r||e[8]!==c?(g=r.length>0&&r.every(re=>c[re.skillName]),e[7]=r,e[8]=c,e[9]=g):g=e[9];const h=g;let x;e[10]!==o?(x=o("settings.skills.catalog.conflicts.title"),e[10]=o,e[11]=x):x=e[11];let R;e[12]!==x?(R=t.jsx(Kt,{children:x}),e[12]=x,e[13]=R):R=e[13];let C;e[14]!==o?(C=o("settings.skills.catalog.conflicts.description"),e[14]=o,e[15]=C):C=e[15];let N;e[16]!==C?(N=t.jsx(Bt,{children:C}),e[16]=C,e[17]=N):N=e[17];let T;e[18]!==R||e[19]!==N?(T=t.jsxs($t,{children:[R,N]}),e[18]=R,e[19]=N,e[20]=T):T=e[20];let k;e[21]!==r.length||e[22]!==o?(k=o("settings.skills.catalog.conflicts.count",{count:r.length}),e[21]=r.length,e[22]=o,e[23]=k):k=e[23];let j;e[24]!==k?(j=t.jsx("span",{className:"typography-meta text-muted-foreground",children:k}),e[24]=k,e[25]=j):j=e[25];let b;e[26]!==P?(b=()=>P("skip"),e[26]=P,e[27]=b):b=e[27];let A;e[28]!==o?(A=o("settings.skills.catalog.conflicts.actions.skipAll"),e[28]=o,e[29]=A):A=e[29];let $;e[30]!==b||e[31]!==A?($=t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:b,children:A}),e[30]=b,e[31]=A,e[32]=$):$=e[32];let F;e[33]!==P?(F=()=>P("overwrite"),e[33]=P,e[34]=F):F=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]!==F||e[38]!==I?(v=t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:F,children:I}),e[37]=F,e[38]=I,e[39]=v):v=e[39];let w;e[40]!==$||e[41]!==v?(w=t.jsxs("div",{className:"flex items-center gap-2",children:[$,v]}),e[40]=$,e[41]=v,e[42]=w):w=e[42];let L;e[43]!==j||e[44]!==w?(L=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[j,w]}),e[43]=j,e[44]=w,e[45]=L):L=e[45];let E;if(e[46]!==r||e[47]!==c||e[48]!==o){let re;e[50]!==c||e[51]!==o?(re=V=>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:V.skillName}),t.jsx("div",{className:"typography-micro text-muted-foreground",children:o("settings.skills.catalog.conflicts.installedIn",{scope:V.scope==="project"?o("settings.skills.catalog.conflicts.scope.project"):o("settings.skills.catalog.conflicts.scope.user"),source:V.source==="agents"?o("settings.skills.catalog.conflicts.source.agents"):o("settings.skills.catalog.conflicts.source.opencode")})})]}),t.jsxs(Rt,{value:c[V.skillName]||"skip",onValueChange:oe=>f(fe=>({...fe,[V.skillName]:oe})),children:[t.jsx(Tt,{className:"w-fit",children:t.jsx("span",{className:"capitalize",children:(c[V.skillName]||"skip")==="overwrite"?o("settings.skills.catalog.conflicts.decision.overwrite"):o("settings.skills.catalog.conflicts.decision.skip")})}),t.jsxs(Ft,{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")})]})]})]},V.skillName),e[50]=c,e[51]=o,e[52]=re):re=e[52],E=r.map(re),e[46]=r,e[47]=c,e[48]=o,e[49]=E}else E=e[49];let _;e[53]!==E?(_=t.jsx("div",{className:"space-y-2",children:E}),e[53]=E,e[54]=_):_=e[54];let B;e[55]!==L||e[56]!==_?(B=t.jsxs("div",{className:"space-y-3",children:[L,_]}),e[55]=L,e[56]=_,e[57]=B):B=e[57];let Z;e[58]!==a?(Z=()=>a(!1),e[58]=a,e[59]=Z):Z=e[59];let Q;e[60]!==o?(Q=o("settings.common.actions.cancel"),e[60]=o,e[61]=Q):Q=e[61];let M;e[62]!==Z||e[63]!==Q?(M=t.jsx(G,{size:"sm",variant:"ghost",onClick:Z,children:Q}),e[62]=Z,e[63]=Q,e[64]=M):M=e[64];let X;e[65]!==c||e[66]!==i?(X=()=>i(c),e[65]=c,e[66]=i,e[67]=X):X=e[67];const ee=!h;let K;e[68]!==o?(K=o("settings.skills.catalog.conflicts.actions.continue"),e[68]=o,e[69]=K):K=e[69];let O;e[70]!==X||e[71]!==ee||e[72]!==K?(O=t.jsx(G,{size:"sm",onClick:X,disabled:ee,children:K}),e[70]=X,e[71]=ee,e[72]=K,e[73]=O):O=e[73];let Y;e[74]!==M||e[75]!==O?(Y=t.jsxs(Jt,{children:[M,O]}),e[74]=M,e[75]=O,e[76]=Y):Y=e[76];let U;e[77]!==T||e[78]!==B||e[79]!==Y?(U=t.jsxs(zt,{className:"max-w-2xl",children:[T,B,Y]}),e[77]=T,e[78]=B,e[79]=Y,e[80]=U):U=e[80];let ne;return e[81]!==a||e[82]!==n||e[83]!==U?(ne=t.jsx(Ot,{open:n,onOpenChange:a,children:U}),e[81]=a,e[82]=n,e[83]=U,e[84]=ne):ne=e[84],ne},Xr=[{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 Zn(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 Hl(s){if(s==="user-claude")return{scope:"user",source:"claude"};if(s==="project-claude")return{scope:"project",source:"claude"};const e=Xr.find(n=>n.value===s);return e?{scope:e.scope,source:e.source}:{scope:"user",source:"opencode"}}const vh=s=>{const e=nt.c(124),{open:n,onOpenChange:a,item:r}=s,{t:i}=it(),o=Vs(jh),d=Vs(wh),[c,f]=l.useState("user"),[u,p]=l.useState("opencode"),m=ns(Nh),P=ns(kh),[g,h]=l.useState(null),[x,R]=l.useState(!1);let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[0]=C):C=e[0];const[N,T]=l.useState(C),[k,j]=l.useState(null);let b,A;e[1]!==P||e[2]!==n?(b=()=>{n&&(f("user"),p("opencode"),h(P),R(!1),T([]),j(null))},A=[n,P],e[1]=P,e[2]=n,e[3]=b,e[4]=A):(b=e[3],A=e[4]),l.useEffect(b,A);let $;e[5]!==i?($=de=>{switch(de){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]=$):$=e[6];const F=$;let I;e[7]!==i?(I=de=>{switch(de){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 w;e:{if(m.length===0){w=null;break e}if(g&&m.some(de=>de.id===g)){w=g;break e}if(P&&m.some(de=>de.id===P)){w=P;break e}w=m[0]?.id??null}const L=w;let E;e:{if(c!=="project"){E=null;break e}const de=L;if(!de){E=null;break e}let q;if(e[9]!==de||e[10]!==m){let je;e[12]!==de?(je=Re=>Re.id===de,e[12]=de,e[13]=je):je=e[13],q=m.find(je),e[9]=de,e[10]=m,e[11]=q}else q=e[11];E=q?.path??null}const _=E;let B;e[14]!==o||e[15]!==r||e[16]!==a||e[17]!==i?(B=async de=>{const q={skillDir:de.skillDir};r?.clawdhub&&(q.clawdhub={slug:r.clawdhub.slug,version:r.clawdhub.version});const ue=await o({source:de.source,subpath:de.subpath,gitIdentityId:r?.gitIdentityId,scope:de.scope,targetSource:de.targetSource,selections:[q],conflictPolicy:"prompt",conflictDecisions:de.conflictDecisions},{directory:de.directoryOverride??null});if(ue.ok){W.success(i("settings.skills.catalog.installSkill.toast.installed")),a(!1);return}if(ue.error?.kind==="conflicts"){j({source:de.source,subpath:de.subpath,scope:de.scope,targetSource:de.targetSource,skillDir:de.skillDir,directoryOverride:de.directoryOverride??null}),T(ue.error.conflicts),R(!0);return}if(ue.error?.kind==="authRequired"){W.error(ue.error.message||i("settings.skills.catalog.installSkill.toast.authRequired"));return}W.error(ue.error?.message||i("settings.skills.catalog.installSkill.toast.installFailed"))},e[14]=o,e[15]=r,e[16]=a,e[17]=i,e[18]=B):B=e[18];const Z=B;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 M;e[21]!==Q?(M=t.jsx(Kt,{children:Q}),e[21]=Q,e[22]=M):M=e[22];let X;e[23]!==i?(X=i("settings.skills.catalog.installSkill.descriptionPrefix"),e[23]=i,e[24]=X):X=e[24];let ee;e[25]!==r.skillName?(ee=t.jsx("span",{className:"font-semibold text-foreground",children:r.skillName}),e[25]=r.skillName,e[26]=ee):ee=e[26];let K;e[27]!==i?(K=i("settings.skills.catalog.installSkill.descriptionSuffix"),e[27]=i,e[28]=K):K=e[28];let O;e[29]!==X||e[30]!==ee||e[31]!==K?(O=t.jsxs(Bt,{children:[X," ",ee," ",K]}),e[29]=X,e[30]=ee,e[31]=K,e[32]=O):O=e[32];let Y;e[33]!==M||e[34]!==O?(Y=t.jsxs($t,{children:[M,O]}),e[33]=M,e[34]=O,e[35]=Y):Y=e[35];let U;e[36]!==i?(U=i("settings.skills.catalog.installSkill.field.destination"),e[36]=i,e[37]=U):U=e[37];let ne;e[38]!==U?(ne=t.jsx("span",{className:"typography-ui-label text-foreground",children:U}),e[38]=U,e[39]=ne):ne=e[39];let re;e[40]!==c||e[41]!==u?(re=Zn(c,u),e[40]=c,e[41]=u,e[42]=re):re=e[42];let V;e[43]===Symbol.for("react.memo_cache_sentinel")?(V=de=>{const q=Hl(de);f(q.scope),p(q.source==="agents"?"agents":"opencode")},e[43]=V):V=e[43];let oe;e[44]!==c?(oe=c==="user"?t.jsx(D,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"folder",className:"h-3.5 w-3.5"}),e[44]=c,e[45]=oe):oe=e[45];let fe;e[46]!==u?(fe=u==="agents"?t.jsx(D,{name:"robot-2",className:"h-3.5 w-3.5"}):null,e[46]=u,e[47]=fe):fe=e[47];let xe;e[48]!==F||e[49]!==c||e[50]!==u?(xe=F(Zn(c,u)),e[48]=F,e[49]=c,e[50]=u,e[51]=xe):xe=e[51];let Ie;e[52]!==xe?(Ie=t.jsx("span",{children:xe}),e[52]=xe,e[53]=Ie):Ie=e[53];let ve;e[54]!==oe||e[55]!==fe||e[56]!==Ie?(ve=t.jsxs(Tt,{className:"w-fit gap-1.5",children:[oe,fe,Ie]}),e[54]=oe,e[55]=fe,e[56]=Ie,e[57]=ve):ve=e[57];let we;e[58]!==v||e[59]!==F?(we=Xr.map(de=>t.jsx(gt,{value:de.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:[de.scope==="user"?t.jsx(D,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"folder",className:"h-3.5 w-3.5"}),de.source==="agents"?t.jsx(D,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:F(de.value)})]}),t.jsx("span",{className:"typography-micro text-muted-foreground ml-5",children:v(de.value)})]})},de.value)),e[58]=v,e[59]=F,e[60]=we):we=e[60];let be;e[61]!==we?(be=t.jsx(Ft,{align:"start",children:we}),e[61]=we,e[62]=be):be=e[62];let se;e[63]!==re||e[64]!==ve||e[65]!==be?(se=t.jsxs(Rt,{value:re,onValueChange:V,children:[ve,be]}),e[63]=re,e[64]=ve,e[65]=be,e[66]=se):se=e[66];let le;e[67]!==ne||e[68]!==se?(le=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ne,se]}),e[67]=ne,e[68]=se,e[69]=le):le=e[69];let ye;e[70]!==m||e[71]!==L||e[72]!==c||e[73]!==i?(ye=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")}),m.length===0?t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.skills.catalog.installSkill.field.noProjects")}):t.jsxs(Rt,{value:L??"",onValueChange:de=>h(de),disabled:m.length===1,children:[t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:i("settings.skills.catalog.installSkill.field.chooseProjectPlaceholder")})}),t.jsx(Ft,{align:"start",children:m.map(Sh)})]})]}),e[70]=m,e[71]=L,e[72]=c,e[73]=i,e[74]=ye):ye=e[74];let H;e[75]!==r.warnings?(H=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]=H):H=e[76];let te;e[77]!==le||e[78]!==ye||e[79]!==H?(te=t.jsxs("div",{className:"mt-2 space-y-3",children:[le,ye,H]}),e[77]=le,e[78]=ye,e[79]=H,e[80]=te):te=e[80];let ae;e[81]!==a?(ae=()=>a(!1),e[81]=a,e[82]=ae):ae=e[82];let me;e[83]!==i?(me=i("settings.common.actions.cancel"),e[83]=i,e[84]=me):me=e[84];let Me;e[85]!==ae||e[86]!==me?(Me=t.jsx(G,{size:"sm",variant:"ghost",onClick:ae,children:me}),e[85]=ae,e[86]=me,e[87]=Me):Me=e[87];const Ne=d||!r.installable||c==="project"&&!_;let De;e[88]!==_||e[89]!==Z||e[90]!==r.repoSource||e[91]!==r.repoSubpath||e[92]!==r.skillDir||e[93]!==c||e[94]!==u?(De=()=>{Z({source:r.repoSource,subpath:r.repoSubpath,scope:c,targetSource:u,skillDir:r.skillDir,directoryOverride:_})},e[88]=_,e[89]=Z,e[90]=r.repoSource,e[91]=r.repoSubpath,e[92]=r.skillDir,e[93]=c,e[94]=u,e[95]=De):De=e[95];let Ee;e[96]!==d||e[97]!==i?(Ee=i(d?"settings.skills.catalog.installSkill.actions.installing":"settings.skills.catalog.installSkill.actions.install"),e[96]=d,e[97]=i,e[98]=Ee):Ee=e[98];let Pe;e[99]!==Ne||e[100]!==De||e[101]!==Ee?(Pe=t.jsx(G,{size:"sm",disabled:Ne,onClick:De,children:Ee}),e[99]=Ne,e[100]=De,e[101]=Ee,e[102]=Pe):Pe=e[102];let Te;e[103]!==Me||e[104]!==Pe?(Te=t.jsxs(Jt,{children:[Me,Pe]}),e[103]=Me,e[104]=Pe,e[105]=Te):Te=e[105];let Le;e[106]!==Y||e[107]!==te||e[108]!==Te?(Le=t.jsxs(zt,{className:"max-w-md",children:[Y,te,Te]}),e[106]=Y,e[107]=te,e[108]=Te,e[109]=Le):Le=e[109];let Be;e[110]!==a||e[111]!==n||e[112]!==Le?(Be=t.jsx(Ot,{open:n,onOpenChange:a,children:Le}),e[110]=a,e[111]=n,e[112]=Le,e[113]=Be):Be=e[113];let He;e[114]!==k||e[115]!==Z?(He=de=>{k&&(Z({source:k.source,subpath:k.subpath,scope:k.scope,targetSource:k.targetSource,skillDir:k.skillDir,conflictDecisions:de,directoryOverride:k.directoryOverride??null}),R(!1))},e[114]=k,e[115]=Z,e[116]=He):He=e[116];let Ue;e[117]!==N||e[118]!==x||e[119]!==He?(Ue=t.jsx(yh,{open:x,onOpenChange:R,conflicts:N,onConfirm:He}),e[117]=N,e[118]=x,e[119]=He,e[120]=Ue):Ue=e[120];let Je;return e[121]!==Be||e[122]!==Ue?(Je=t.jsxs(t.Fragment,{children:[Be,Ue]}),e[121]=Be,e[122]=Ue,e[123]=Je):Je=e[123],Je};function jh(s){return s.installSkills}function wh(s){return s.isInstalling}function Nh(s){return s.projects}function kh(s){return s.activeProjectId}function Sh(s){return t.jsx(gt,{value:s.id,children:s.label||s.path},s.id)}const Ch=async()=>{try{const s=Os()?.settings;if(s)return(await s.load())?.settings||{};const e=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});return e.ok?await e.json().catch(()=>null):null}catch{return null}},Ph=({mode:s,onModeChange:e,showModeTabs:n=!0})=>{const{t:a}=it(),{sources:r,itemsBySource:i,selectedSourceId:o,setSelectedSource:d,loadCatalog:c,loadSource:f,loadMoreClawdHub:u,isLoadingCatalog:p,isLoadingSource:m,isLoadingMore:P,loadedSourceIds:g,clawdhubHasMoreBySource:h,lastCatalogError:x}=Vs(Ss(M=>({sources:M.sources,itemsBySource:M.itemsBySource,selectedSourceId:M.selectedSourceId,setSelectedSource:M.setSelectedSource,loadCatalog:M.loadCatalog,loadSource:M.loadSource,loadMoreClawdHub:M.loadMoreClawdHub,isLoadingCatalog:M.isLoadingCatalog,isLoadingSource:M.isLoadingSource,isLoadingMore:M.isLoadingMore,loadedSourceIds:M.loadedSourceIds,clawdhubHasMoreBySource:M.clawdhubHasMoreBySource,lastCatalogError:M.lastCatalogError}))),[R,C]=l.useState(""),[N,T]=l.useState(!1),[k,j]=l.useState(!1),[b,A]=l.useState(null),[$,F]=l.useState(!1),[I,v]=l.useState(!1);l.useEffect(()=>{c()},[c]),l.useEffect(()=>{o&&(g[o]||f(o))},[o,g,f]);const w=l.useMemo(()=>o?i[o]||[]:[],[i,o]),L=l.useMemo(()=>{const M=R.trim().toLowerCase();return M?w.filter(X=>{const ee=X.skillName.toLowerCase(),K=(X.description||"").toLowerCase(),O=(X.frontmatterName||"").toLowerCase();return ee.includes(M)||K.includes(M)||O.includes(M)}):w},[w,R]),E=l.useMemo(()=>r.find(M=>M.id===o)||null,[r,o]),_=!!(o&&o.startsWith("custom:")),B=E?.source==="clawdhub:registry"||E?.sourceType==="clawdhub",Z=!!(o&&(h[o]??!0)),Q=async()=>{if(!(!o||!_)){F(!0);try{const M=await Ch(),ee=(Array.isArray(M?.skillCatalogs)?M?.skillCatalogs:[]).filter(K=>K.id!==o);await Pt({skillCatalogs:ee}),await c({refresh:!0}),v(!1)}finally{F(!1)}}};return t.jsx(Wt,{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(vn,{items:[{id:"manual",label:a("settings.skills.catalog.page.mode.manual")},{id:"external",label:a("settings.skills.catalog.page.mode.external")}],activeId:s,onSelect:M=>e(M),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(Rt,{value:o||"",onValueChange:M=>d(M),children:[t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:a("settings.skills.catalog.page.field.selectSourcePlaceholder"),children:E?.label})}),t.jsx(Ft,{align:"start",children:r.map(M=>t.jsx(gt,{value:M.id,children:M.label},M.id))})]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{o?f(o,{refresh:!0}):c({refresh:!0})},disabled:p||m,title:a("settings.skills.catalog.page.actions.refreshTitle"),children:t.jsx(D,{name:"refresh",className:ce("h-3.5 w-3.5",(p||m)&&"animate-spin")})}),_&&t.jsx(G,{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:$,title:a("settings.skills.catalog.page.actions.removeCatalogTitle"),children:t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(G,{"data-settings-item":"skills.catalog.add-catalog",size:"xs",className:"!font-normal gap-1",onClick:()=>T(!0),children:[t.jsx(D,{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(D,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),t.jsx(Ze,{value:R,onChange:M=>C(M.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:L.length})})]})]})]}),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("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:x.message})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("section",{className:"px-2 pb-2 pt-0",children:L.length===0&&!m?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")})]}):m?t.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[t.jsx(D,{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:L.map(M=>{const X=M.installed?.isInstalled,ee=M.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:M.skillName}),X&&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:ee||a("settings.skills.catalog.page.badge.unknown")})}),!M.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")})]}),M.description?t.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 line-clamp-2",children:M.description}):t.jsx("div",{className:"typography-meta text-muted-foreground/50 mt-0.5 italic",children:a("settings.skills.catalog.shared.noDescription")}),M.clawdhub&&t.jsxs("div",{className:"typography-micro text-muted-foreground mt-1.5 flex items-center gap-3",children:[M.clawdhub.owner&&t.jsxs("span",{children:[a("settings.skills.catalog.page.byOwnerPrefix")," ",t.jsx("span",{className:"font-medium text-foreground/80",children:M.clawdhub.owner})]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(D,{name:"download",className:"h-3 w-3"}),M.clawdhub.downloads?.toLocaleString()??0]}),(M.clawdhub.stars??0)>0&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(D,{name:"star",className:"h-3 w-3"}),M.clawdhub.stars]}),t.jsxs("span",{className:"bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:["v",M.clawdhub.version]})]}),M.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:M.warnings.join(" · ")}):null]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal shrink-0",disabled:!M.installable,onClick:()=>{A(M),j(!0)},children:a("settings.skills.catalog.shared.actions.install")})]})},`${M.sourceId}:${M.skillDir}`)})})}),B&&Z&&!m&&L.length>0&&t.jsx("div",{className:"flex justify-center mt-2 px-2",children:t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{u()},disabled:P,children:a(P?"settings.skills.catalog.page.loading.more":"settings.skills.catalog.page.actions.loadMoreSkills")})})]}),t.jsx(dh,{open:N,onOpenChange:T}),t.jsx(vh,{open:k,onOpenChange:j,item:b}),t.jsx(Ot,{open:I,onOpenChange:M=>{$||v(M)},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:a("settings.skills.catalog.page.removeDialog.title")}),t.jsx(Bt,{children:a("settings.skills.catalog.page.removeDialog.description")})]}),t.jsxs(Jt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>v(!1),disabled:$,children:a("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",variant:"destructive",onClick:()=>{Q()},disabled:$,children:a("settings.skills.catalog.page.actions.removeCatalog")})]})]})})]})})};function Co(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=Fs.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=ci.define([{tag:[Fe.comment,Fe.docComment,Fe.meta,Fe.documentMeta],class:"cm-comment"},{tag:[Fe.keyword,Fe.controlKeyword,Fe.moduleKeyword,Fe.definitionKeyword,Fe.modifier],class:"cm-keyword"},{tag:[Fe.operatorKeyword,Fe.operator,Fe.derefOperator,Fe.updateOperator,Fe.definitionOperator,Fe.typeOperator,Fe.controlOperator,Fe.logicOperator,Fe.bitwiseOperator,Fe.arithmeticOperator,Fe.compareOperator],class:"cm-operator"},{tag:[Fe.punctuation,Fe.separator,Fe.bracket,Fe.paren,Fe.brace,Fe.squareBracket,Fe.angleBracket],class:"cm-punctuation"},{tag:[Fe.string,Fe.regexp,Fe.attributeValue,Fe.special(Fe.string),Fe.monospace],class:"cm-string"},{tag:Fe.escape,class:"cm-string-2"},{tag:[Fe.number,Fe.bool,Fe.atom,Fe.null,Fe.self],class:"cm-number"},{tag:[Fe.function(Fe.variableName),Fe.function(Fe.definition(Fe.variableName)),Fe.function(Fe.propertyName),Fe.standard(Fe.variableName),Fe.special(Fe.variableName)],class:"cm-builtin"},{tag:Fe.definition(Fe.variableName),class:"cm-def"},{tag:[Fe.variableName,Fe.local(Fe.variableName),Fe.constant(Fe.variableName),Fe.literal],class:"cm-variable"},{tag:Fe.propertyName,class:"cm-property"},{tag:Fe.attributeName,class:"cm-attribute"},{tag:[Fe.className,Fe.typeName,Fe.namespace],class:"cm-variable-3"},{tag:[Fe.tagName,Fe.labelName,Fe.annotation,Fe.macroName],class:"cm-tag"},{tag:Fe.link,class:"cm-link"},{tag:[Fe.heading,Fe.heading1,Fe.heading2,Fe.heading3,Fe.heading4,Fe.heading5,Fe.heading6],class:"cm-keyword"}]),c=ci.define([{tag:[Fe.comment,Fe.docComment,Fe.meta,Fe.documentMeta],color:s.colors.syntax.base.comment},{tag:[Fe.keyword,Fe.controlKeyword,Fe.moduleKeyword,Fe.definitionKeyword,Fe.modifier],color:s.colors.syntax.base.keyword},{tag:[Fe.operatorKeyword,Fe.operator,Fe.derefOperator,Fe.updateOperator,Fe.definitionOperator,Fe.typeOperator,Fe.controlOperator,Fe.logicOperator,Fe.bitwiseOperator,Fe.arithmeticOperator,Fe.compareOperator],color:s.colors.syntax.base.operator},{tag:[Fe.string,Fe.regexp,Fe.attributeValue,Fe.special(Fe.string),Fe.monospace],color:s.colors.syntax.base.string},{tag:Fe.escape,color:i.stringEscape||s.colors.syntax.base.string},{tag:[Fe.number,Fe.bool,Fe.atom,Fe.null,Fe.self],color:s.colors.syntax.base.number},{tag:[Fe.function(Fe.variableName),Fe.function(Fe.definition(Fe.variableName)),Fe.function(Fe.propertyName),Fe.standard(Fe.variableName),Fe.special(Fe.variableName)],color:s.colors.syntax.base.function},{tag:Fe.definition(Fe.variableName),color:i.variableGlobal||s.colors.syntax.base.variable},{tag:[Fe.variableName,Fe.local(Fe.variableName),Fe.constant(Fe.variableName),Fe.literal],color:s.colors.syntax.base.variable},{tag:Fe.propertyName,color:i.variableProperty||s.colors.syntax.base.variable},{tag:Fe.attributeName,color:i.variableOther||s.colors.syntax.base.variable},{tag:[Fe.className,Fe.typeName,Fe.namespace],color:s.colors.syntax.base.type},{tag:[Fe.tagName,Fe.labelName,Fe.annotation,Fe.macroName],color:i.tag||s.colors.syntax.base.keyword},{tag:Fe.link,color:i.url||s.colors.syntax.base.function,textDecoration:"underline"},{tag:[Fe.punctuation,Fe.separator,Fe.bracket,Fe.paren,Fe.brace,Fe.squareBracket,Fe.angleBracket],color:i.punctuation||s.colors.syntax.base.comment}]);return e?.syntaxColors===!1?[o]:[o,aa(od,{fallback:!0}),aa(ld),aa(d),aa(c)]}const Ih=180,Wl=cd.define(),Ah=1,Dh=2,Eh=4,Po=new Map,Mh=(s,e)=>{const n=`${s}|${e}`,a=Po.get(n);if(a)return a;let r="";s&&(r+=`color:${s};`),e&Ah&&(r+="font-style:italic;"),e&Dh&&(r+="font-weight:bold;"),e&Eh&&(r+="text-decoration:underline;");const i=Oa.mark({attributes:{style:r}});return Po.set(n,i),i},Rh=(s,e)=>{const n=new qr,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[f,u,p]of o){if(f<=0)continue;const m=c,P=Math.min(c+f,d.to);c+=f,!(P<=m)&&(!u&&!p||n.add(m,P,Mh(u,p)))}}return n.finish()},Th=vl.define({create(){return Oa.none},update(s,e){let n=s.map(e.changes);for(const a of e.effects)a.is(Wl)&&(n=a.value);return n},provide:s=>Fs.decorations.from(s)}),Fh=s=>yl.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)},Ih)}async tokenize(e){const n=++this.generation,a=e.state.doc.toString(),r=await $d(a,s.language,s.themeName,s.theme);r&&n===this.generation&&e.state.doc.length===a.length&&e.dispatch({effects:Wl.of(Rh(e,r))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Lh=s=>[Th,Fh(s)],Oh=()=>{const s=nt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ph,{mode:"external",onModeChange:Vh,showModeTabs:!1}),s[0]=e):e=s[0],e},zh="SKILL.md",Kh="h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]",Aa=(s,e)=>{const n=dd({description:s}).trimEnd(),a=e.trimStart();return`---
|
|
23
|
-
${n}
|
|
24
|
-
---${a?`
|
|
25
|
-
|
|
26
|
-
${a}`:`
|
|
27
|
-
`}`},$h=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),ql=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=md(e[1]);if($h(a)){const r=a.description;typeof r=="string"&&(n=r)}}catch{n=null}return{description:n,instructions:e[2].replace(/^\r?\n/,"")}},Uh=(s,e)=>{const n=ql(s);return Aa(e,n.instructions)},Bh=()=>{const{t:s}=it(),{currentTheme:e}=Ua(),{selectedSkillName:n,getSkillByName:a,getSkillDetail:r,createSkill:i,updateSkill:o,skills:d,skillDraft:c,setSkillDraft:f,setSelectedSkill:u}=Hs(Ss(de=>({selectedSkillName:de.selectedSkillName,getSkillByName:de.getSkillByName,getSkillDetail:de.getSkillDetail,createSkill:de.createSkill,updateSkill:de.updateSkill,skills:de.skills,skillDraft:de.skillDraft,setSkillDraft:de.setSkillDraft,setSelectedSkill:de.setSelectedSkill}))),p=n?a(n):null,m=!!(c&&c.name===n&&!p),P=!!(n&&!p&&!c),g=p?.path==="<built-in>";l.useEffect(()=>{P&&u(null)},[P,u]);const[h,x]=l.useState(""),[R,C]=l.useState("user"),[N,T]=l.useState("opencode"),[k,j]=l.useState(""),[b,A]=l.useState(""),[$,F]=l.useState(()=>Aa("","")),[I,v]=l.useState("edit"),[w,L]=l.useState([]),[E,_]=l.useState([]),[B,Z]=l.useState(!1),[Q,M]=l.useState(!1),[X,ee]=l.useState(""),[K,O]=l.useState(""),[Y,U]=l.useState(!1),[ne,re]=l.useState(""),[V,oe]=l.useState(""),[fe,xe]=l.useState(null),[Ie,ve]=l.useState(!1),[we,be]=l.useState(""),[se,le]=l.useState(null),[ye,H]=l.useState(!1),te=m?h.trim()!==""||k.trim()!==""||b.trim()!==""||E.length>0:k!==X||b!==K,ae=fe?V!==we:ne.trim()!=="",me=l.useCallback(de=>{switch(de){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(de=>{switch(de){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(m&&c){const q=c.description||"",ue=c.instructions||"";x(c.name||""),C(c.scope||"user"),T(c.source==="agents"?"agents":"opencode"),j(q),A(ue),F(Aa(q,ue)),ee(""),O(""),L([]),_(c.pendingFiles||[])}else if(n&&p){M(!0);try{const q=await r(n);if(q){const ue=q.sources.md,je=ue.description||"",Re=ue.instructions||"";j(je),A(Re),F(Aa(je,Re)),ee(je),O(Re),L(ue.supportingFiles||[])}}catch(q){console.error("Failed to load skill details:",q)}finally{M(!1)}}})()},[p,m,n,d,c,r]);const Ne=l.useMemo(()=>{const de=[Co(e)],q=mi(zh);return q&&de.push(q),de.push(Fs.lineWrapping),de},[e]),De=l.useMemo(()=>{const de=ne.trim()||"supporting-file.md",q=Ud(de),ue=!!q&&q!=="markdown",je=[Co(e,ue?{syntaxColors:!1}:void 0)],Re=mi(de);return Re&&je.push(Re),ue&&q&&je.push(Lh({language:q,themeName:e.metadata.id,theme:Sr(e)})),je.push(Fs.lineWrapping),je},[e,ne]),Ee=l.useCallback(de=>{j(de),F(q=>Uh(q,de))},[]),Pe=l.useCallback(de=>{F(de);const q=ql(de);j(q.description??""),A(q.instructions)},[]),Te=async()=>{const de=m?h.trim().replace(/\s+/g,"-").toLowerCase():n?.trim();if(!de){W.error(s("settings.skills.page.toast.skillNameRequired"));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(de)||de.length>64){W.error(s("settings.skills.page.toast.invalidSkillName"));return}if(!k.trim()){W.error(s("settings.skills.page.toast.descriptionRequired"));return}if(m&&d.some(q=>q.name===de)){W.error(s("settings.skills.page.toast.skillExists"));return}Z(!0);try{const q={name:de,description:k.trim(),instructions:b.trim()||void 0,scope:m?R:void 0,source:m?N:void 0,targetPath:m?void 0:p?.path,supportingFiles:m&&E.length>0?E:void 0};let ue;m?(ue=await i(q),ue&&(f(null),_([]),u(de))):(ue=await o(de,q),ue&&(ee(k.trim()),O(b.trim()))),ue?W.success(s(m?"settings.skills.page.toast.skillCreated":"settings.skills.page.toast.skillUpdated")):W.error(s(m?"settings.skills.page.toast.createSkillFailed":"settings.skills.page.toast.updateSkillFailed"))}catch(q){console.error("Error saving skill:",q),W.error(s("settings.skills.page.toast.saveUnexpectedError"))}finally{Z(!1)}},Le=()=>{xe(null),re(""),oe(""),be(""),U(!0)},Be=async de=>{if(xe(de),re(de),m){const ue=E.find(je=>je.path===de)?.content||"";oe(ue),be(ue),U(!0);return}if(n){ve(!0),U(!0);try{const{readSupportingFile:q}=Hs.getState(),ue=await q(n,de);oe(ue||""),be(ue||"")}catch{W.error(s("settings.skills.page.toast.loadFileContentFailed")),oe(""),be("")}finally{ve(!1)}}},He=async()=>{if(!ne.trim()){W.error(s("settings.skills.page.toast.fileNameRequired"));return}const de=ne.trim(),q=fe!==null;if(m){if(q)_(Re=>Re.map(Ce=>Ce.path===fe?{path:de,content:V}:Ce)),W.success(s("settings.skills.page.toast.fileUpdated",{path:de}));else{if(E.some(Re=>Re.path===de)){W.error(s("settings.skills.page.toast.fileExists"));return}_(Re=>[...Re,{path:de,content:V}]),W.success(s("settings.skills.page.toast.fileAdded",{path:de}))}U(!1),xe(null);return}if(!n){W.error(s("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:ue}=Hs.getState();if(await ue(n,de,V)){W.success(q?s("settings.skills.page.toast.fileUpdated",{path:de}):s("settings.skills.page.toast.fileCreated",{path:de})),U(!1),xe(null);const Re=await r(n);Re&&L(Re.sources.md.supportingFiles||[])}else W.error(s(q?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},Ue=de=>{if(m){_(q=>q.filter(ue=>ue.path!==de)),W.success(s("settings.skills.page.toast.fileRemoved",{path:de}));return}n&&le(de)},Je=async()=>{if(!se||!n)return;H(!0);const{deleteSupportingFile:de}=Hs.getState();if(await de(n,se)){W.success(s("settings.skills.page.toast.fileDeleted",{path:se}));const ue=await r(n);ue&&L(ue.sources.md.supportingFiles||[]),le(null)}else W.error(s("settings.skills.page.toast.deleteFileFailed"));H(!1)};return!n&&!c||P?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(D,{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(Wt,{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:m?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:me(Zn(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:[m&&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(Ze,{value:h,onChange:de=>x(de.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:s("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),t.jsxs(Rt,{value:Zn(R,N),onValueChange:de=>{const q=Hl(de);C(q.scope),T(q.source==="agents"?"agents":"opencode")},children:[t.jsxs(Tt,{className:"w-fit gap-1.5",children:[R==="user"?t.jsx(D,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"folder",className:"h-3.5 w-3.5"}),N==="agents"?t.jsx(D,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:me(Zn(R,N))})]}),t.jsx(Ft,{align:"start",children:Xr.map(de=>t.jsx(gt,{value:de.value,children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[de.scope==="user"?t.jsx(D,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"folder",className:"h-3.5 w-3.5"}),de.source==="agents"?t.jsx(D,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:me(de.value)})]}),t.jsx("span",{className:"typography-micro text-muted-foreground ml-6",children:Me(de.value)})]})},de.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:k,onChange:de=>Ee(de.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:g})})]})]})]}),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(ih,{currentMode:I==="preview"?"preview":"edit",onToggle:()=>v(de=>de==="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",Kh),children:I==="preview"?t.jsx(Wt,{outerClassName:"h-full",className:"h-full",children:t.jsx("div",{className:"min-h-full px-4 py-3",children:t.jsx(kr,{content:$,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})}):t.jsx(So,{value:$,onChange:Pe,readOnly:g,extensions:Ne,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(G,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:Le,disabled:g,children:[t.jsx(D,{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 de=m?E:w;return de.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:de.map(q=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>Be(q.path),children:[t.jsx(D,{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:q.path}),m&&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")}),!g&&t.jsx(G,{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:ue=>{ue.stopPropagation(),Ue(q.path)},children:t.jsx(D,{name:"delete-bin",className:"h-3 w-3"})})]},q.path))})})()})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(G,{onClick:Te,disabled:g||B||!te,size:"xs",className:"!font-normal",children:s(B?"settings.common.actions.saving":m?"settings.skills.page.actions.createSkill":"settings.common.actions.saveChanges")})})]}),t.jsx(Ot,{open:se!==null,onOpenChange:de=>{!de&&!ye&&le(null)},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.skills.page.deleteFileDialog.title")}),t.jsx(Bt,{children:s("settings.skills.page.deleteFileDialog.description",{path:se??""})})]}),t.jsxs(Jt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>le(null),disabled:ye,children:s("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",variant:"destructive",onClick:Je,disabled:ye,children:s("settings.common.actions.delete")})]})]})}),t.jsx(Ot,{open:Y,onOpenChange:de=>{U(de),de||xe(null)},children:t.jsxs(zt,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[t.jsxs($t,{className:"flex-shrink-0",children:[t.jsx(Kt,{children:s(fe?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),t.jsx(Bt,{children:s(fe?"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(Ze,{value:ne,onChange:de=>re(de.target.value),placeholder:s("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]",disabled:fe!==null}),!fe&&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(So,{value:V,onChange:oe,extensions:De,className:"h-full",enableSearch:!0})})]})]}),t.jsxs(Jt,{className:"mt-4",children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{U(!1),xe(null)},children:s("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",onClick:He,disabled:Ie||!ae,children:s(fe?"settings.common.actions.saveChanges":"settings.skills.page.actions.createFile")})]})]})})]})},Io=s=>{const e=nt.c(2),{view:n}=s,a=n===void 0?"installed":n;let r;return e[0]!==a?(r=a==="catalog"?t.jsx(Oh,{}):t.jsx(Bh,{}),e[0]=a,e[1]=r):r=e[1],r};function Vh(){}const _h=s=>{const e=nt.c(38),{onItemSelect:n}=s,{t:a}=it(),r=ns(Hh),i=ze(Wh),o=ze(qh),{currentTheme:d}=Ua();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=fs(),e[0]=c):c=e[0];const f=c,u=Gh;let p,m;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)},m=[r,i,o],e[1]=r,e[2]=i,e[3]=o,e[4]=p,e[5]=m):(p=e[4],m=e[5]),l.useEffect(p,m);let P;e[6]===Symbol.for("react.memo_cache_sentinel")?(P=ce("border-b px-3","pt-4 pb-3"),e[6]=P):P=e[6];let g;e[7]!==a?(g=a("settings.page.projects.title"),e[7]=a,e[8]=g):g=e[8];let h;e[9]!==g?(h=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:g}),e[9]=g,e[10]=h):h=e[10];let x;e[11]!==r.length||e[12]!==a?(x=a("settings.projects.sidebar.total",{count:r.length}),e[11]=r.length,e[12]=a,e[13]=x):x=e[13];let R;e[14]!==x?(R=t.jsx("span",{className:"typography-meta text-muted-foreground",children:x}),e[14]=x,e[15]=R):R=e[15];let C;e[16]!==a?(C=!f&&t.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:u,"aria-label":a("settings.projects.sidebar.actions.addProject"),children:t.jsx(D,{name:"add",className:"size-4"})}),e[16]=a,e[17]=C):C=e[17];let N;e[18]!==R||e[19]!==C?(N=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[R,C]}),e[18]=R,e[19]=C,e[20]=N):N=e[20];let T;e[21]!==N||e[22]!==h?(T=t.jsxs("div",{className:P,children:[h,N]}),e[21]=N,e[22]=h,e[23]=T):T=e[23];let k;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=A=>{const $=A.id===i,F=A.icon?Bd[A.icon]:null,I=A.color?Cl[A.color]??null:null,v=F?t.jsx(D,{name:F,className:ce("h-4 w-4",$?"text-foreground":"text-muted-foreground/70"),style:I?{color:I}:void 0}):t.jsx(D,{name:"folder",className:ce("h-4 w-4",$?"text-foreground":"text-muted-foreground/70"),style:I?{color:I}:void 0}),w=A.iconImage?t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:A.iconBackground?{backgroundColor:A.iconBackground}:void 0,children:t.jsx(Pl,{project:A,options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:v})}):v;return t.jsx(Or,{title:A.label||A.path,icon:w,selected:$,onSelect:()=>{o(A.id),n?.()}},A.id)},e[30]=d,e[31]=n,e[32]=i,e[33]=o,e[34]=b):b=e[34],k=r.map(b),e[24]=d,e[25]=n,e[26]=r,e[27]=i,e[28]=o,e[29]=k}else k=e[29];let j;return e[35]!==T||e[36]!==k?(j=t.jsx(Vl,{variant:"background",header:T,children:k}),e[35]=T,e[36]=k,e[37]=j):j=e[37],j};function Hh(s){return s.projects}function Wh(s){return s.settingsProjectsSelectedId}function qh(s){return s.setSettingsProjectsSelectedId}function Gh(){Sl.requestDirectoryDialog()}const Jh=({projectRef:s=null})=>{const{t:e}=it(),{isMobile:n,isTablet:a}=Cs(),r=n||a,i=ns(_=>_.getActiveProject()),o=s?.path??i?.path??null,d=Ns(_=>_.getWorktreeMetadata),c=Vd(),f=bs(_=>_.homeDirectory),[u,p]=l.useState([]),[m,P]=l.useState(!1),[g,h]=l.useState(!1),[x,R]=l.useState(null),[C,N]=l.useState([]),[T,k]=l.useState(!1),j=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(!(!j||x===!1))try{const _=await ui(j);N(_)}catch{}},[j,x]);l.useEffect(()=>{if(!o)return;let _=!1;return R(null),(async()=>{try{const B=await _d(o);if(_)return;R(B)}catch{}})(),()=>{_=!0}},[o]),l.useEffect(()=>{if(!j){N([]),k(!1);return}if(x===!1){N([]),k(!1);return}let _=!1;return k(!0),N([]),(async()=>{try{const B=await ui(j);if(_)return;N(B)}catch{}finally{_||k(!1)}})(),()=>{_=!0}},[j,x]),l.useEffect(()=>{if(!j)return;let _=!1;return h(!0),(async()=>{try{const[B,Z]=await Promise.all([Il(j),Al(j)]);_||(p(B.length>0?B:[""]),P(Z))}catch{_||(p([""]),P(!1))}finally{_||h(!1)}})(),()=>{_=!0}},[j]);const A=l.useCallback((_,B)=>{p(Z=>{const Q=[...Z];return Q[_]=B,Q})},[]),$=l.useCallback(()=>{p(_=>[..._,""])},[]),F=l.useCallback(async _=>{if(!j)return;const B=_.filter(Z=>Z.trim().length>0);await Hd(j,B)},[j]),I=l.useCallback(_=>{p(B=>{const Z=B.filter((Q,M)=>M!==_);return F(Z),Z.length>0?Z:[""]})},[F]),v=l.useCallback(()=>{F(u)},[F,u]),w=l.useCallback(_=>{P(_),j&&Wd(j,_)},[j]),L=l.useCallback(_=>{const B=U=>U.replace(/\\/g,"/").replace(/\/+$/,""),Z=B(_.path),Q=c.filter(U=>{const ne=d(U.id);if(ne?.path&&B(ne.path)===Z)return!0;const re=U.directory;return!!(re&&B(re)===Z)}),M=new Set(Q.map(U=>U.id)),X=[...Cr.getState().activeSessions,...Cr.getState().archivedSessions],ee=U=>{const ne=X.filter(V=>{const oe=V.parentID;return oe&&U.has(oe)});if(ne.length===0)return[];const re=new Set(ne.map(V=>V.id));return[...ne,...ee(re)]},K=ee(M),O=new Set,Y=[...Q,...K].filter(U=>O.has(U.id)?!1:(O.add(U.id),!0));Sl.requestDelete({sessions:Y,mode:"worktree",worktree:_})},[c,d]),E=l.useMemo(()=>c.map(_=>_.id).join(","),[c]);return l.useEffect(()=>{x&&o&&b()},[E,x,o,b]),o?x===!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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsxs(Et,{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")]})]})]})}),g?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:[u.map((_,B)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(Ze,{value:_,onChange:Z=>A(B,Z.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(B)},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(D,{name:"close",className:"h-4 w-4"})})]},B)),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:$,children:[t.jsx(D,{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(kt,{checked:m,onChange:w,ariaLabel:e("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:ce("typography-ui-label font-normal",m?"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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:e("settings.openchamber.worktrees.list.tooltip")})]})]})}),T?t.jsx("p",{className:"typography-meta text-muted-foreground px-1",children:e("settings.openchamber.worktrees.list.loading")}):C.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:C.map(_=>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:_.label||_.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:qd(_.path,f)})]}),t.jsx("button",{type:"button",onClick:()=>L(_),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:_.branch||_.label||_.path}),children:t.jsx(D,{name:"delete-bin",className:"h-4 w-4"})})]},_.path))})]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.worktrees.state.selectProject")})},Ao=(s,e)=>e.updatedAtMs-s.updatedAtMs,ms=ln((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([Yd(),gi()]),r={};for(const i of a.sort(Ao))r[i.id]=i;e().listenerReady||await Xd(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 Qd();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await gi(),a={};for(const r of n.sort(Ao))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 Jd({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=Zd(n,a);r&&r.trim()&&(i.nickname=r.trim()),await e().upsertInstance(i)},removeInstance:async n=>{await pi(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 Gd(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 pi(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})})),Gl=[{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"}],Qh=Object.fromEntries(Gl.map(s=>[s.key,s.Icon])),Yh="openchamber:project-actions-updated",Xh=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},qv=(s,e)=>`${Xh(s)}::${e}`,Zh=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},Do=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},ef=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=Do(e.localPort),a=Do(e.remotePort);if(!n||!a)return null;const r=Zh(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}`}},Jl=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const a of n.portForwards){const r=ef(n,a);r&&e.push(r)}return e},Gv=(s,e)=>{const n=(s||"").trim();return n&&Jl(e).find(i=>i.id===n)?.url||null},tf=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,sf=()=>({id:tf(),name:"",command:"",icon:"play"}),nf=({projectRef:s})=>{const{t:e}=it(),n=l.useMemo(()=>is(),[]),a=ms(b=>b.instances),r=ms(b=>b.load),[i,o]=l.useState([]),[d,c]=l.useState(!1),[f,u]=l.useState(!1),[p,m]=l.useState(null),[P,g]=l.useState({});l.useEffect(()=>{n&&r().catch(()=>{})},[n,r]),l.useEffect(()=>{let b=!1;return c(!0),(async()=>{try{const A=await em(s);if(b)return;o(A.actions),m(JSON.stringify({actions:A.actions}))}catch{if(b)return;o([]),m(JSON.stringify({actions:[]}))}finally{b||c(!1)}})(),()=>{b=!0}},[s]);const h=l.useMemo(()=>n?Jl(a):[],[a,n]),x=l.useMemo(()=>i.some(A=>A.name.trim().length===0||A.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[i,e]),R=l.useMemo(()=>p===null?!1:p!==JSON.stringify({actions:i}),[i,p]),C=l.useCallback(()=>{const b=sf();o(A=>[...A,b]),g(A=>({...A,[b.id]:!0}))},[]),N=l.useCallback(b=>{o(A=>A.filter($=>$.id!==b)),g(A=>{const $={...A};return delete $[b],$})},[]),T=l.useCallback((b,A)=>{o($=>$.map(F=>F.id===b?A(F):F))},[]),k=l.useCallback(async()=>{if(x){W.error(x);return}u(!0);try{if(!await tm(s,{actions:i,primaryActionId:null})){W.error(e("settings.projects.actions.toast.saveFailed"));return}m(JSON.stringify({actions:i})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Yh,{detail:{projectId:s.id}})),W.success(e("settings.projects.actions.toast.saved"))}catch{W.error(e("settings.projects.actions.toast.saveFailed"))}finally{u(!1)}},[i,s,e,x]),j=!f&&!d&&R&&!x;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(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:C,children:[t.jsx(D,{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 A=b.icon||"play",$=Qh[A]||"play",F=P[b.id]??!1,I=b.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(xn,{open:F,onOpenChange:v=>{g(w=>({...w,[b.id]:v}))},className:ce("py-1.5"),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(bn,{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:[F?t.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(D,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(D,{name:$,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(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>N(b.id),children:t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(yn,{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(D,{name:$,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:Gl.map(v=>{const w=v.Icon,L=(b.icon||"play")===v.key;return t.jsx("button",{type:"button",onClick:()=>T(b.id,E=>({...E,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)]",L&&"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(D,{name:w,className:"h-4 w-4"})},v.key)})})})]}),t.jsx(Ze,{value:b.name,onChange:v=>T(b.id,w=>({...w,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=>T(b.id,w=>({...w,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:()=>T(b.id,v=>({...v,...v.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:v=>{(v.key===" "||v.key==="Enter")&&(v.preventDefault(),T(b.id,w=>({...w,...w.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(kt,{checked:b.autoOpenUrl===!0,onChange:v=>T(b.id,w=>({...w,...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(Ze,{value:b.openUrl||"",onChange:v=>T(b.id,w=>({...w,openUrl:v.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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")}),h.length>0?t.jsxs(Rt,{value:b.desktopOpenSshForward&&h.some(v=>v.id===b.desktopOpenSshForward)?b.desktopOpenSshForward:"__none__",onValueChange:v=>{T(b.id,w=>({...w,...v==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:v}}))},children:[t.jsx(Tt,{className:"h-7 w-full max-w-[30rem]",children:t.jsx(Lt,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Ft,{children:[t.jsx(gt,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),h.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:[x?t.jsx("p",{className:"typography-meta mb-2 text-[var(--status-warning)]",children:x}):null,t.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:k,disabled:!j,children:e(f?"settings.common.actions.saving":"settings.projects.actions.actions.save")})]})]})]})},af=()=>{const s=nt.c(197),{t:e}=it(),n=ns(rf),a=ns(of),r=ns(lf),i=ns(cf),o=ns(df),d=ze(mf),c=ze(uf),{currentTheme:f}=Ua();let u;e:{if(!d){u=null;break e}let Xe;s[0]!==n||s[1]!==d?(Xe=n.find(Nt=>Nt.id===d)??null,s[0]=n,s[1]=d,s[2]=Xe):Xe=s[2],u=Xe}const p=u;let m,P;s[3]!==n||s[4]!==d||s[5]!==c?(m=()=>{if(n.length===0){c(null);return}d&&n.some(Xe=>Xe.id===d)||c(n[0].id)},P=[n,d,c],s[3]=n,s[4]=d,s[5]=c,s[6]=m,s[7]=P):(m=s[6],P=s[7]),l.useEffect(m,P);const[g,h]=l.useState(""),[x,R]=l.useState(null),[C,N]=l.useState(null),[T,k]=l.useState(null),[j,b]=l.useState(!1),[A,$]=l.useState(!1),[F,I]=l.useState(!1),[v,w]=l.useState(!1),[L,E]=l.useState(null),[_,B]=l.useState(null),[Z,Q]=l.useState(!1),M=l.useRef(null);let X;s[8]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{E(null),B(pf)},s[8]=X):X=s[8];const ee=X;let K;e:{if(!p){K=null;break e}let Xe;s[9]!==p.id||s[10]!==p.path?(Xe={id:p.id,path:p.path},s[9]=p.id,s[10]=p.path,s[11]=Xe):Xe=s[11],K=Xe}const O=K;let Y,U;s[12]!==p?(Y=()=>{if(!p){h(""),R(null),N(null),k(null);return}h(p.label??""),R(p.icon??null),N(p.color??null),k(p.iconBackground??null),w(!1),ee(),Q(!1)},U=[p,ee],s[12]=p,s[13]=Y,s[14]=U):(Y=s[13],U=s[14]),l.useEffect(Y,U);let ne,re;s[15]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>()=>{ee()},re=[ee],s[15]=ne,s[16]=re):(ne=s[15],re=s[16]),l.useEffect(ne,re);let V;s[17]!==C||s[18]!==x||s[19]!==T||s[20]!==g||s[21]!==v||s[22]!==L||s[23]!==p?(V=!!p&&(g.trim()!==(p?.label??"").trim()||x!==(p?.icon??null)||C!==(p?.color??null)||T!==(p?.iconBackground??null)||v||!!L),s[17]=C,s[18]=x,s[19]=T,s[20]=g,s[21]=v,s[22]=L,s[23]=p,s[24]=V):V=s[24];const oe=V;let fe;s[25]!==C||s[26]!==x||s[27]!==T||s[28]!==g||s[29]!==v||s[30]!==L||s[31]!==i||s[32]!==p||s[33]!==e||s[34]!==a||s[35]!==r?(fe=async()=>{if(!p)return;if(L){b(!0);const Nt=await r(p.id,L);if(b(!1),!Nt.ok){W.error(Nt.error||e("settings.projects.page.toast.uploadIconFailed"));return}W.success(e("settings.projects.page.toast.iconUpdated")),ee(),w(!1)}const Xe=v&&!!p.iconImage;if(Xe){$(!0);const Nt=await i(p.id);if($(!1),!Nt.ok){W.error(Nt.error||e("settings.projects.page.toast.removeIconFailed"));return}W.success(e("settings.projects.page.toast.iconRemoved")),w(!1),k(null)}a(p.id,{label:g.trim(),icon:x,color:C,iconBackground:Xe?null:T})},s[25]=C,s[26]=x,s[27]=T,s[28]=g,s[29]=v,s[30]=L,s[31]=i,s[32]=p,s[33]=e,s[34]=a,s[35]=r,s[36]=fe):fe=s[36];const xe=fe,Ie=C?Cl[C]??null:null,ve=!!p?.iconImage,we=!!(L&&_),be=p?.iconImage?.source==="custom",se=ve&&!v||we,le=se,H=!Z&&(we||!!(p&&ve&&!v));let te;s[37]!==j||s[38]!==p?(te=Xe=>{!p||!Xe||j||(w(!1),Q(!1),E(Xe),B(Nt=>(Nt&&URL.revokeObjectURL(Nt),URL.createObjectURL(Xe))))},s[37]=j,s[38]=p,s[39]=te):te=s[39];const ae=te;let me;s[40]!==we||s[41]!==le||s[42]!==ve||s[43]!==A||s[44]!==p?(me=()=>{!p||!le||A||(we&&ee(),w(!!ve),Q(!1))},s[40]=we,s[41]=le,s[42]=ve,s[43]=A,s[44]=p,s[45]=me):me=s[45];const Me=me;let Ne;s[46]!==o||s[47]!==F||s[48]!==p||s[49]!==e?(Ne=async()=>{!p||F||(ee(),w(!1),Q(!1),I(!0),o(p.id).then(Xe=>{if(!Xe.ok){W.error(Xe.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(Xe.skipped){W.success(e("settings.projects.page.toast.customIconAlreadySet"));return}W.success(e("settings.projects.page.toast.iconDiscovered"))}).finally(()=>{I(!1)}))},s[46]=o,s[47]=F,s[48]=p,s[49]=e,s[50]=Ne):Ne=s[50];const De=Ne;if(!p){let Xe;s[51]!==e?(Xe=e("settings.projects.page.empty.noProjects"),s[51]=e,s[52]=Xe):Xe=s[52];let Nt;return s[53]!==Xe?(Nt=t.jsx(Wt,{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:Xe})})}),s[53]=Xe,s[54]=Nt):Nt=s[54],Nt}let Ee;s[55]!==p.label||s[56]!==e?(Ee=p.label??e("settings.projects.page.title.default"),s[55]=p.label,s[56]=e,s[57]=Ee):Ee=s[57];let Pe;s[58]!==Ee?(Pe=t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:Ee}),s[58]=Ee,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 Le;s[62]!==Pe||s[63]!==Te?(Le=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]=Le):Le=s[64];let Be;s[65]!==e?(Be=e("settings.projects.page.field.projectName"),s[65]=e,s[66]=Be):Be=s[66];let He;s[67]!==Be?(He=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]=He):He=s[68];let Ue;s[69]===Symbol.for("react.memo_cache_sentinel")?(Ue=Xe=>h(Xe.target.value),s[69]=Ue):Ue=s[69];let Je;s[70]!==e?(Je=e("settings.projects.page.field.projectNamePlaceholder"),s[70]=e,s[71]=Je):Je=s[71];let de;s[72]!==g||s[73]!==Je?(de=t.jsx("div",{className:"mt-1.5 flex min-w-0 items-center gap-2",children:t.jsx(Ze,{value:g,onChange:Ue,placeholder:Je,className:"h-7 min-w-0 w-full sm:max-w-[19rem]"})}),s[72]=g,s[73]=Je,s[74]=de):de=s[74];let q;s[75]!==He||s[76]!==de?(q=t.jsxs("div",{"data-settings-item":"projects.name",className:"py-1.5",children:[He,de]}),s[75]=He,s[76]=de,s[77]=q):q=s[77];let ue;s[78]!==e?(ue=e("settings.projects.page.field.accentColor"),s[78]=e,s[79]=ue):ue=s[79];let je;s[80]!==ue?(je=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:ue})}),s[80]=ue,s[81]=je):je=s[81];let Re;s[82]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>N(null),s[82]=Re):Re=s[82];const Ce=C===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 J;s[85]!==e?(J=e("settings.projects.page.field.none"),s[85]=e,s[86]=J):J=s[86];let y;s[87]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(D,{name:"close",className:"h-4 w-4 text-muted-foreground"}),s[87]=y):y=s[87];let pe;s[88]!==_e||s[89]!==J?(pe=t.jsx("button",{type:"button",onClick:Re,className:_e,title:J,children:y}),s[88]=_e,s[89]=J,s[90]=pe):pe=s[90];let Ae;s[91]!==C?(Ae=sm.map(Xe=>t.jsx("button",{type:"button",onClick:()=>N(Xe.key),className:ce("h-7 w-7 rounded-md border transition-colors",C===Xe.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:Xe.cssVar},title:Xe.label},Xe.key)),s[91]=C,s[92]=Ae):Ae=s[92];let Oe;s[93]!==pe||s[94]!==Ae?(Oe=t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[pe,Ae]}),s[93]=pe,s[94]=Ae,s[95]=Oe):Oe=s[95];let qe;s[96]!==je||s[97]!==Oe?(qe=t.jsxs("div",{"data-settings-item":"projects.accent-color",className:"py-1.5",children:[je,Oe]}),s[96]=je,s[97]=Oe,s[98]=qe):qe=s[98];let at;s[99]!==e?(at=e("settings.projects.page.field.projectIcon"),s[99]=e,s[100]=at):at=s[100];let rt;s[101]!==at?(rt=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:at})}),s[101]=at,s[102]=rt):rt=s[102];let st;s[103]!==ae?(st=t.jsx("input",{ref:M,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Xe=>{const Nt=Xe.target.files?.[0]??null;ae(Nt),Xe.currentTarget.value=""}}),s[103]=ae,s[104]=st):st=s[104];let dt;s[105]===Symbol.for("react.memo_cache_sentinel")?(dt=()=>R(null),s[105]=dt):dt=s[105];const Ye=x===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let $e;s[106]!==Ye?($e=ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ye),s[106]=Ye,s[107]=$e):$e=s[107];let mt;s[108]!==e?(mt=e("settings.projects.page.field.none"),s[108]=e,s[109]=mt):mt=s[109];let ge;s[110]===Symbol.for("react.memo_cache_sentinel")?(ge=t.jsx(D,{name:"close",className:"h-4 w-4 text-muted-foreground"}),s[110]=ge):ge=s[110];let et;s[111]!==$e||s[112]!==mt?(et=t.jsx("button",{type:"button",onClick:dt,className:$e,title:mt,children:ge}),s[111]=$e,s[112]=mt,s[113]=et):et=s[113];let tt;s[114]!==Ie||s[115]!==x?(tt=nm.map(Xe=>{const Nt=Xe.Icon;return t.jsx("button",{type:"button",onClick:()=>R(Xe.key),className:ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",x===Xe.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:Xe.label,children:t.jsx(D,{name:Nt,className:"w-4 h-4",style:Ie&&x===Xe.key?{color:Ie}:void 0})},Xe.key)}),s[114]=Ie,s[115]=x,s[116]=tt):tt=s[116];let We;s[117]!==et||s[118]!==tt?(We=t.jsxs("div",{className:"mt-1.5 flex max-w-[22rem] flex-wrap items-center gap-2",children:[et,tt]}),s[117]=et,s[118]=tt,s[119]=We):We=s[119];let xt;s[120]!==f||s[121]!==se||s[122]!==we||s[123]!==T||s[124]!==_||s[125]!==p||s[126]!==H||s[127]!==e?(xt=se&&H&&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:T?{backgroundColor:T}:void 0,children:we&&_?t.jsx("img",{src:_,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>Q(!0)}):p?t.jsx(Pl,{project:p,options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>Q(!0)}):null})})]}),s[120]=f,s[121]=se,s[122]=we,s[123]=T,s[124]=_,s[125]=p,s[126]=H,s[127]=e,s[128]=xt):xt=s[128];let wt;s[129]!==se||s[130]!==T||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:T??"#000000",onChange:Xe=>k(Xe.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(Ze,{value:T??"",onChange:Xe=>k(Xe.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(G,{type:"button",size:"xs",variant:"outline",onClick:()=>k(null),className:"h-7 w-7 p-0","aria-label":e("settings.projects.page.field.clearIconBackgroundAria"),title:e("settings.projects.page.field.clearBackground"),disabled:!T,children:t.jsx(D,{name:"close",className:"h-3.5 w-3.5"})})]}),s[129]=se,s[130]=T,s[131]=e,s[132]=wt):wt=s[132];let St;s[133]!==De||s[134]!==be||s[135]!==F||s[136]!==j||s[137]!==e?(St=!be&&t.jsxs(t.Fragment,{children:[t.jsx(G,{size:"xs",className:"h-6 !font-normal",onClick:()=>M.current?.click(),disabled:j,children:e(j?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(G,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{De()},disabled:F,children:e(F?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),s[133]=De,s[134]=be,s[135]=F,s[136]=j,s[137]=e,s[138]=St):St=s[138];let ie;s[139]!==Me||s[140]!==le||s[141]!==A||s[142]!==e?(ie=le&&t.jsx(G,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{Me()},disabled:A,children:e(A?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),s[139]=Me,s[140]=le,s[141]=A,s[142]=e,s[143]=ie):ie=s[143];let Ve;s[144]!==A||s[145]!==v||s[146]!==e?(Ve=v&&t.jsx(G,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>w(!1),disabled:A,children:e("settings.projects.page.actions.undoRemove")}),s[144]=A,s[145]=v,s[146]=e,s[147]=Ve):Ve=s[147];let Qe;s[148]!==St||s[149]!==ie||s[150]!==Ve?(Qe=t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[St,ie,Ve]}),s[148]=St,s[149]=ie,s[150]=Ve,s[151]=Qe):Qe=s[151];let Ge;s[152]!==rt||s[153]!==st||s[154]!==We||s[155]!==xt||s[156]!==wt||s[157]!==Qe?(Ge=t.jsxs("div",{"data-settings-item":"projects.icon",className:"py-1.5",children:[rt,st,We,xt,wt,Qe]}),s[152]=rt,s[153]=st,s[154]=We,s[155]=xt,s[156]=wt,s[157]=Qe,s[158]=Ge):Ge=s[158];let ut;s[159]!==q||s[160]!==qe||s[161]!==Ge?(ut=t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[q,qe,Ge]}),s[159]=q,s[160]=qe,s[161]=Ge,s[162]=ut):ut=s[162];let bt;s[163]!==oe||s[164]!==A||s[165]!==j||s[166]!==g?(bt=!oe||g.trim().length===0||j||A,s[163]=oe,s[164]=A,s[165]=j,s[166]=g,s[167]=bt):bt=s[167];let pt;s[168]!==e?(pt=e("settings.common.actions.saveChanges"),s[168]=e,s[169]=pt):pt=s[169];let Dt;s[170]!==xe||s[171]!==bt||s[172]!==pt?(Dt=t.jsx("div",{className:"mt-0.5 px-2 py-1",children:t.jsx(G,{onClick:xe,disabled:bt,size:"xs",className:"!font-normal",children:pt})}),s[170]=xe,s[171]=bt,s[172]=pt,s[173]=Dt):Dt=s[173];let qt;s[174]!==ut||s[175]!==Dt?(qt=t.jsxs("div",{className:"mb-8",children:[ut,Dt]}),s[174]=ut,s[175]=Dt,s[176]=qt):qt=s[176];let Yt;s[177]!==O?(Yt=O&&t.jsx(nf,{projectRef:O}),s[177]=O,s[178]=Yt):Yt=s[178];let Zt;s[179]!==Yt?(Zt=t.jsx("div",{"data-settings-item":"projects.worktree",className:"mb-8",children:t.jsx("section",{className:"px-2 pb-2 pt-0",children:Yt})}),s[179]=Yt,s[180]=Zt):Zt=s[180];let as;s[181]!==e?(as=e("settings.projects.page.section.worktree"),s[181]=e,s[182]=as):as=s[182];let Ht;s[183]!==as?(Ht=t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:as})}),s[183]=as,s[184]=Ht):Ht=s[184];let es;s[185]!==O?(es=O&&t.jsx(Jh,{projectRef:O}),s[185]=O,s[186]=es):es=s[186];let Se;s[187]!==es?(Se=t.jsx("section",{className:"px-2 pb-2 pt-0",children:es}),s[187]=es,s[188]=Se):Se=s[188];let yt;s[189]!==Ht||s[190]!==Se?(yt=t.jsxs("div",{className:"mb-8",children:[Ht,Se]}),s[189]=Ht,s[190]=Se,s[191]=yt):yt=s[191];let jt;return s[192]!==Le||s[193]!==qt||s[194]!==Zt||s[195]!==yt?(jt=t.jsx(Wt,{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:[Le,qt,Zt,yt]})}),s[192]=Le,s[193]=qt,s[194]=Zt,s[195]=yt,s[196]=jt):jt=s[196],jt};function rf(s){return s.projects}function of(s){return s.updateProjectMeta}function lf(s){return s.uploadProjectIcon}function cf(s){return s.removeProjectIcon}function df(s){return s.discoverProjectIcon}function mf(s){return s.settingsProjectsSelectedId}function uf(s){return s.setSettingsProjectsSelectedId}function pf(s){return s&&URL.revokeObjectURL(s),null}const Ql=s=>({v:1,serverUrl:s.serverUrl.trim().replace(/\/+$/,""),token:s.token.trim(),...s.label?.trim()?{label:s.label.trim()}:{}}),gf=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()}`},hf=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 Ql({serverUrl:r,token:i,label:o})}catch{return null}},Kr=()=>Math.floor(2e4+Math.random()*3e4),ff=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")},Eo=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"}},xf=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),Yl=s=>!!(s&&xf.has(s)),Mo=s=>s==="ready"?"bg-[var(--status-success)] animate-pulse":s==="error"?"bg-[var(--status-error)] animate-pulse":s==="degraded"||Yl(s)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",bf=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}`,yf=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:Kr(),remoteHost:"127.0.0.1",remotePort:80}),vf=s=>s.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",$s=s=>{const e=nt.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(At,{asChild:!0,children:t.jsx(D,{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(It,{children:[i,t.jsx(Et,{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},jf=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"}},Ro=(s,e)=>{const n=(s||"").trim();return`${!n||n==="127.0.0.1"||n==="::1"?"localhost":n}:${e||0}`},wf=s=>{const e=(s||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},Nf=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}`},$r=(s="",e="")=>({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`header-${Date.now()}-${Math.random().toString(16).slice(2)}`,name:s,value:e}),kf=s=>s.trim().toLowerCase()==="authorization",lr=s=>{const e={};for(const n of s){const a=n.name.trim(),r=n.value.trim();a&&r&&!kf(a)&&(e[a]=r)}return Object.keys(e).length>0?e:void 0},Sf=s=>Object.entries(s||{}).map(([e,n])=>$r(e,n)),Cf=()=>{if(typeof window>"u")return null;const e=Kn()||window.location.href;try{const n=Number(new URL(e).port||window.location.port);return Number.isFinite(n)&&n>0?n:null}catch{const n=Number(window.location.port);return Number.isFinite(n)&&n>0?n:null}},Pf=async()=>{const s=Pr(Kn())||window.location.origin;if(!is()||!zn())return s;let e;try{e=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}})}catch{return s}if(!e.ok||(await e.json().catch(()=>null))?.desktopLanAccessActive!==!0)return s;const a=await Rl(),r=Cf();return!a||!r?s:`http://${a}:${r}`},cr=s=>{const e=s.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},If=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}},Af=()=>{const{t:s}=it(),{clientAuth:e}=Qr(),n=is(),a=ms(z=>z.instances),r=ms(z=>z.statusesById),i=ms(z=>z.importCandidates),o=ms(z=>z.isLoading),d=ms(z=>z.isImportsLoading),c=ms(z=>z.isSaving),f=ms(z=>z.error),u=ms(z=>z.load),p=ms(z=>z.loadImports),m=ms(z=>z.refreshStatuses),P=ms(z=>z.upsertInstance),g=ms(z=>z.createFromCommand),h=ms(z=>z.removeInstance),x=ms(z=>z.connect),R=ms(z=>z.disconnect),C=ms(z=>z.retry),N=ze(z=>z.settingsRemoteInstancesSelectedId),T=ze(z=>z.setSettingsRemoteInstancesSelectedId),k=l.useMemo(()=>N&&a.find(z=>z.id===N)||null,[a,N]),[j,b]=l.useState(null),[A,$]=l.useState(!1),[F,I]=l.useState(!1),[v,w]=l.useState(null),[L,E]=l.useState([]),[_,B]=l.useState(null),[Z,Q]=l.useState(""),[M,X]=l.useState(!1),[ee,K]=l.useState({}),[O,Y]=l.useState(!1),[U,ne]=l.useState(!1),[re,V]=l.useState(()=>Date.now()),[oe,fe]=l.useState([]),[xe,Ie]=l.useState("local"),[ve,we]=l.useState(!1),[be,se]=l.useState(!1),[le,ye]=l.useState(""),[H,te]=l.useState(""),[ae,me]=l.useState(""),[Me,Ne]=l.useState([]),[De,Ee]=l.useState(""),[Pe,Te]=l.useState(null),[Le,Be]=l.useState(!1),[He,Ue]=l.useState(!1),[Je,de]=l.useState(null),[q,ue]=l.useState(""),[je,Re]=l.useState(""),[Ce,_e]=l.useState(""),[J,y]=l.useState([]),[pe,Ae]=l.useState([]),[Oe,qe]=l.useState(!1),[at,rt]=l.useState(""),[st,dt]=l.useState(null),[Ye,$e]=l.useState(null),[mt,ge]=l.useState(null),[et,tt]=l.useState(null),We=l.useMemo(()=>pe.filter(z=>!!z.revokedAt).length,[pe]),[xt,wt]=l.useState(!1),[St,ie]=l.useState("ssh user@example.com"),[Ve,Qe]=l.useState("");l.useEffect(()=>{u(),p()},[u,p]);const Ge=l.useCallback(async()=>{we(!0),Te(null);try{const z=await hi();fe(z.hosts||[]),Ie(z.defaultHostId||"local")}catch(z){Te(z instanceof Error?z.message:String(z))}finally{we(!1)}},[]);l.useEffect(()=>{Ge()},[Ge]);const ut=l.useCallback(async(z,Ke=xe)=>{se(!0),Te(null);try{await fi({hosts:z,defaultHostId:Ke,initialHostChoiceCompleted:!0}),fe(z),Ie(Ke)}catch(ft){Te(ft instanceof Error?ft.message:String(ft))}finally{se(!1)}},[xe]),bt=l.useCallback(async()=>{const z=xi(H);if(!z){Te(s("desktopHostSwitcher.error.invalidUrl"));return}const Ke=z.persistedUrl,vt={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:le.trim()||Vn(Ke),url:Ke,apiUrl:Ke,...ae.trim()?{clientToken:ae.trim()}:{},...lr(Me)?{requestHeaders:lr(Me)}:{}};await ut([vt,...oe],xe),ye(""),te(""),me(""),Ne([]),Be(!1),z.redeemUrl&&cr(z.redeemUrl)},[xe,Me,oe,le,ae,H,ut,s]),pt=l.useCallback(async()=>{const z=hf(De);if(!z){Te(s("settings.remoteInstances.direct.error.invalidConnectLink"));return}const Ke=Pr(z.serverUrl);if(!Ke){Te(s("desktopHostSwitcher.error.invalidUrl"));return}const ft=oe.find(vt=>Pr(vt.apiUrl||vt.url)===Ke);if(ft){const vt=oe.map(ts=>ts.id===ft.id?{...ts,label:z.label||ts.label,url:Ke,apiUrl:Ke,clientToken:z.token}:ts);await ut(vt,xe)}else{const vt=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`;await ut([{id:vt,label:z.label||Vn(Ke),url:Ke,apiUrl:Ke,clientToken:z.token},...oe],xe)}Ee(""),Te(null),Ue(!1)},[De,xe,oe,ut,s]),Dt=l.useCallback(async z=>{const Ke=oe.filter(vt=>vt.id!==z);await ut(Ke,xe===z?"local":xe),Je===z&&de(null)},[xe,Je,oe,ut]),qt=l.useCallback(z=>{de(z.id),ue(z.label),Re(z.apiUrl||z.url),_e(z.clientToken||""),y(Sf(z.requestHeaders)),Te(null)},[]),Yt=l.useCallback(async()=>{if(!Je)return;const z=xi(je);if(!z){Te(s("desktopHostSwitcher.error.invalidUrl"));return}const Ke=z.persistedUrl,ft=oe.map(vt=>vt.id===Je?{...vt,label:q.trim()||Vn(Ke),url:Ke,apiUrl:Ke,clientToken:Ce.trim()||void 0,requestHeaders:lr(J)}:vt);await ut(ft,xe),de(null),z.redeemUrl&&cr(z.redeemUrl)},[xe,J,q,Ce,je,Je,oe,ut,s]),Zt=l.useCallback(async()=>{const z=St.trim();if(!z){W.error(s("settings.remoteInstances.page.toast.sshCommandRequired"));return}const Ke=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await g(Ke,z,Ve.trim()||s("settings.remoteInstances.sidebar.newSshInstanceName")),T(Ke),wt(!1),ie("ssh user@example.com"),Qe(""),W.success(s("settings.remoteInstances.page.toast.instanceCreated"))}catch(ft){W.error(s("settings.remoteInstances.sidebar.toast.createFailed"),{description:ft instanceof Error?ft.message:String(ft)})}},[g,T,St,Ve,s]),as=l.useCallback(async z=>{await ut(oe,z)},[oe,ut]),Ht=l.useCallback(async()=>{if(e){qe(!0),$e(null);try{Ae(await e.listClients())}catch(z){$e(z instanceof Error?z.message:String(z))}finally{qe(!1)}}},[e]);l.useEffect(()=>{Ht()},[Ht]);const es=l.useCallback(async()=>{if(e){$e(null);try{const z=await e.createClient({label:at.trim()||void 0});dt(z.token),rt(""),await Ht()}catch(z){$e(z instanceof Error?z.message:String(z))}}},[e,Ht,at]),Se=l.useCallback(async()=>{if(e){$e(null);try{const z=await Pf(),Ke=await e.createClient({label:at.trim()||"Paired client"}),ft=Ql({serverUrl:z,token:Ke.token,label:at||"OpenChamber"}),vt=gf(ft);dt(Ke.token),ge(vt),tt(await jl.toDataURL(vt,{width:192,margin:1})),rt(""),await Ht()}catch(z){$e(z instanceof Error?z.message:String(z))}}},[e,Ht,at]),yt=l.useCallback(async z=>{if(!e)return;const Ke=z.clientKind==="desktop-local";$e(null);try{if(await e.revokeClient(z.id),Ke&&is()){const ft=await hi();await fi({hosts:ft.hosts,defaultHostId:ft.defaultHostId,initialHostChoiceCompleted:ft.initialHostChoiceCompleted,localClientToken:null}),Ae(vt=>vt.map(ts=>ts.id===z.id?{...ts,revokedAt:new Date().toISOString()}:ts)),Ym({apiBaseUrl:Kn(),clientToken:null,runtimeKey:"local"});return}await Ht()}catch(ft){$e(ft instanceof Error?ft.message:String(ft))}},[e,Ht]),jt=l.useCallback(async()=>{if(e){$e(null);try{await e.purgeRevokedClients(),await Ht()}catch(z){$e(z instanceof Error?z.message:String(z))}}},[e,Ht]);l.useEffect(()=>{b(k)},[k]),l.useEffect(()=>{if(!N)return;const z=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||m()},2e3);return()=>{window.clearInterval(z)}},[m,N]),l.useEffect(()=>{let z=null,Ke=Date.now();const ft=()=>{const ts=Date.now();ts-Ke>=1e3&&(V(ts),Ke=ts),z=requestAnimationFrame(ft)};(typeof document>"u"||document.visibilityState==="visible")&&(z=requestAnimationFrame(ft));const vt=()=>{document.visibilityState==="visible"&&z===null?z=requestAnimationFrame(ft):document.visibilityState!=="visible"&&z!==null&&(cancelAnimationFrame(z),z=null)};return document.addEventListener("visibilitychange",vt),()=>{document.removeEventListener("visibilitychange",vt),z!==null&&cancelAnimationFrame(z)}},[]);const Xe=N?r[N]:null,Nt=Xe?.phase,Vt=Nt==="ready",Qt=Nt==="degraded",rs=Yl(Nt),cs=Vt||(rs||Qt),Is=Xe?Math.max(0,re-Xe.updatedAtMs):0,Ps=Qt&&Is>12e3,ct=l.useMemo(()=>!j||!k?!1:JSON.stringify(j)!==JSON.stringify(k),[j,k]),ke=l.useCallback(z=>{b(Ke=>Ke&&z(Ke))},[]),Ct=l.useCallback(async()=>{if(!j)return;const z=If(j);if(!z.sshCommand.trim()){W.error(s("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(!(z.localForward.bindHost==="0.0.0.0"&&!window.confirm(s("settings.remoteInstances.page.confirm.bindAllInterfaces")))){if(z.auth.sshPassword?.enabled&&z.auth.sshPassword.value?.trim()&&z.auth.sshPassword.store!=="settings"){const Ke=window.confirm(s("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext"));z.auth.sshPassword.store=Ke?"settings":"never",Ke||(z.auth.sshPassword.value=void 0)}if(z.auth.openchamberPassword?.enabled&&z.auth.openchamberPassword.value?.trim()&&z.auth.openchamberPassword.store!=="settings"){const Ke=window.confirm(s("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext"));z.auth.openchamberPassword.store=Ke?"settings":"never",Ke||(z.auth.openchamberPassword.value=void 0)}try{await P(z),W.success(s("settings.remoteInstances.page.toast.instanceSaved"))}catch(Ke){W.error(s("settings.remoteInstances.page.toast.saveFailed"),{description:Ke instanceof Error?Ke.message:String(Ke)})}}},[j,s,P]),Xt=l.useCallback(async(z,Ke)=>{const ft=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await g(ft,`ssh ${Ke}`,z),T(ft),W.success(s("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(vt){return W.error(s("settings.remoteInstances.sidebar.toast.createFailed"),{description:vt instanceof Error?vt.message:String(vt)}),!1}},[g,T,s]),Gt=l.useCallback(()=>{M||(B(null),Q(""))},[M]),wn=l.useCallback((z,Ke)=>{if(Ke){B(z),Q(vf(z));return}Xt(z,z)},[Xt]),cn=l.useCallback(async()=>{const z=_,Ke=Z.trim();if(z){if(!Ke){W.error(s("settings.remoteInstances.page.toast.destinationRequired"));return}X(!0);try{await Xt(z,Ke)&&(B(null),Q(""))}finally{X(!1)}}},[Xt,Z,_,s]),Gs=l.useCallback(async()=>{if(k)try{await x(k.id);return}catch(z){if(!ff(z)||!window.confirm(s("settings.remoteInstances.sidebar.confirm.localPortInUseRetry")))throw z;const ft={...k,localForward:{...k.localForward,preferredLocalPort:Kr()}};await P(ft),await x(ft.id),W.success(s("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[x,k,s,P]),Nn=l.useCallback(async z=>(await am(z,600)).map(ft=>Nf(ft)),[]),Va=l.useCallback(async()=>{if(j){$(!0),I(!0),w(null);try{const z=await Nn(j.id);E(z)}catch(z){E([]),w(z instanceof Error?z.message:String(z))}finally{I(!1)}}},[j,Nn]);l.useEffect(()=>{if(!A||!j)return;let z=!1;const Ke=async()=>{try{const vt=await Nn(j.id);z||(E(vt),w(null))}catch(vt){z||w(vt instanceof Error?vt.message:String(vt))}};Ke();const ft=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Ke()},1e3);return()=>{z=!0,window.clearInterval(ft)}},[j,A,Nn]);const Es=l.useMemo(()=>L.join(`
|
|
28
|
-
`),[L]),Js=l.useCallback(()=>{if(!Es.trim()){W.error(s("settings.remoteInstances.page.toast.noLogsToCopy"));return}hn(Es).then(z=>{z.ok&&W.success(s("settings.remoteInstances.page.toast.logsCopied"))})},[Es,s]),Qs=l.useCallback(async()=>{if(j)try{await rm(j.id),E([]),W.success(s("settings.remoteInstances.page.toast.logsCleared"))}catch(z){W.error(s("settings.remoteInstances.page.toast.clearLogsFailed"),{description:z instanceof Error?z.message:String(z)})}},[j,s]),$n=l.useCallback(async()=>{if(!Xe?.localUrl){W.error(s("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}const z=Xe.localUrl.trim();if(!z){W.error(s("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}cr(z)},[Xe?.localUrl,s]),_a=l.useCallback(()=>{if(!j)return;Y(!0),(cs?R(j.id):Gs()).catch(Ke=>{const ft=cs?Vt?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";W.error(s(ft),{description:Ke instanceof Error?Ke.message:String(Ke)})}).finally(()=>{Y(!1)})},[cs,Gs,R,j,Vt,s]),Un=l.useCallback(()=>{if(!j||rs)return;ne(!0),(Qt?R(j.id).then(()=>Gs()):C(j.id)).catch(Ke=>{W.error(s("settings.remoteInstances.page.toast.retryFailed"),{description:Ke instanceof Error?Ke.message:String(Ke)})}).finally(()=>{ne(!1)})},[Gs,R,j,rs,Qt,C,s]),zs=s(rs?"settings.remoteInstances.page.actions.connecting":Qt?Ps?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),kn=!O&&!U&&(Nt==="error"||Nt==="idle"||!Nt||Qt&&Ps)&&!rs,Ys=s(Vt?"settings.remoteInstances.sidebar.actions.disconnect":cs?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!j)return t.jsxs(zr,{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(Ze,{className:"h-8",value:at,onChange:z=>rt(z.target.value),placeholder:s("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{es()},children:s("settings.remoteInstances.clientAuth.actions.create")}),t.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Se()},children:s("settings.remoteInstances.clientAuth.actions.pair")})]}),mt?t.jsxs("div",{className:"flex flex-col gap-3 rounded-md border border-[var(--interactive-border)] p-2 sm:flex-row",children:[et?t.jsx("img",{src:et,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:mt}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{hn(mt)},children:[t.jsx(D,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.common.actions.copyAll")]})]})]}):null,st?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:st})]}):null,t.jsxs("div",{className:"space-y-1",children:[We>0?t.jsx("div",{className:"flex justify-end",children:t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{jt()},children:s("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,Oe?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.state.loading")}):pe.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.state.empty")}):pe.map(z=>{const Ke=z.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:z.label}),Ke?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:z.revokedAt?s("settings.remoteInstances.clientAuth.state.revoked"):z.lastUsedAt?s("settings.remoteInstances.clientAuth.lastUsed",{date:z.lastUsedAt}):s("settings.remoteInstances.clientAuth.neverUsed")})]}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{yt(z)},disabled:!!z.revokedAt,children:s("settings.remoteInstances.clientAuth.actions.revoke")})]},z.id)})]}),Ye?t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Ye}):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(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ue(!0),disabled:be,children:s("settings.remoteInstances.direct.import.action")}),t.jsxs(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>Be(!0),disabled:be,children:[t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.direct.actions.add")]})]})]}),t.jsx("div",{className:"space-y-1",children:ve?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.state.loading")}):oe.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.state.empty")}):oe.map(z=>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:Vn(z.label)}),xe===z.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:Vn(z.apiUrl||z.url)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{as(z.id)},disabled:be||xe===z.id,"aria-label":s("desktopHostSwitcher.actions.setAsDefaultAria"),children:xe===z.id?t.jsx(D,{name:"star-fill",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"star",className:"h-3.5 w-3.5"})}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>qt(z),disabled:be,children:[t.jsx(D,{name:"pencil",className:"h-3.5 w-3.5"}),s("desktopHostSwitcher.actions.edit")]}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Dt(z.id)},disabled:be,children:[t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.delete")]})]})]})},z.id))}),Pe?t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Pe}):null]})]}):null,n?t.jsx(Ot,{open:Le,onOpenChange:Be,children:t.jsxs(zt,{className:"sm:max-w-lg",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.remoteInstances.direct.actions.add")}),t.jsx(Bt,{children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:z=>{z.preventDefault(),bt()},children:[t.jsx(Ze,{className:"h-8",value:le,onChange:z=>ye(z.target.value),placeholder:s("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:be}),t.jsx(Ze,{className:"h-8",value:H,onChange:z=>te(z.target.value),placeholder:s("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:be,autoFocus:!0}),t.jsx(Ze,{className:"h-8",value:ae,onChange:z=>me(z.target.value),placeholder:s("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:be}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.remoteInstances.direct.headers.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.headers.description")})]}),Me.map(z=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(Ze,{className:"h-8 font-mono text-xs",value:z.name,onChange:Ke=>Ne(ft=>ft.map(vt=>vt.id===z.id?{...vt,name:Ke.target.value}:vt)),placeholder:s("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:be}),t.jsx(Ze,{className:"h-8 font-mono text-xs",value:z.value,onChange:Ke=>Ne(ft=>ft.map(vt=>vt.id===z.id?{...vt,value:Ke.target.value}:vt)),placeholder:s("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:be}),t.jsx("button",{type:"button",onClick:()=>Ne(Ke=>Ke.filter(ft=>ft.id!==z.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":s("settings.remoteInstances.direct.headers.removeAria"),disabled:be,children:t.jsx(D,{name:"close",className:"h-4 w-4"})})]},z.id)),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Ne(z=>[...z,$r()]),disabled:be,children:[t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.direct.headers.actions.add")]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Be(!1),disabled:be,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:be||!H.trim(),children:s("settings.remoteInstances.direct.actions.add")})]})]})]})}):null,n?t.jsx(Ot,{open:!!Je,onOpenChange:z=>{z||de(null)},children:t.jsxs(zt,{className:"sm:max-w-lg",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("desktopHostSwitcher.actions.edit")}),t.jsx(Bt,{children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:z=>{z.preventDefault(),Yt()},children:[t.jsx(Ze,{className:"h-8",value:q,onChange:z=>ue(z.target.value),placeholder:s("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:be}),t.jsx(Ze,{className:"h-8",value:je,onChange:z=>Re(z.target.value),placeholder:s("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:be,autoFocus:!0}),t.jsx(Ze,{className:"h-8",value:Ce,onChange:z=>_e(z.target.value),placeholder:s("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:be}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.remoteInstances.direct.headers.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.headers.description")})]}),J.map(z=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(Ze,{className:"h-8 font-mono text-xs",value:z.name,onChange:Ke=>y(ft=>ft.map(vt=>vt.id===z.id?{...vt,name:Ke.target.value}:vt)),placeholder:s("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:be}),t.jsx(Ze,{className:"h-8 font-mono text-xs",value:z.value,onChange:Ke=>y(ft=>ft.map(vt=>vt.id===z.id?{...vt,value:Ke.target.value}:vt)),placeholder:s("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:be}),t.jsx("button",{type:"button",onClick:()=>y(Ke=>Ke.filter(ft=>ft.id!==z.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":s("settings.remoteInstances.direct.headers.removeAria"),disabled:be,children:t.jsx(D,{name:"close",className:"h-4 w-4"})})]},z.id)),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>y(z=>[...z,$r()]),disabled:be,children:[t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.direct.headers.actions.add")]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>de(null),disabled:be,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:be,children:s("settings.common.actions.saveChanges")})]})]})]})}):null,n?t.jsx(Ot,{open:He,onOpenChange:Ue,children:t.jsxs(zt,{className:"sm:max-w-lg",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.remoteInstances.direct.import.action")}),t.jsx(Bt,{children:s("settings.remoteInstances.direct.import.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:z=>{z.preventDefault(),pt()},children:[t.jsx(Ze,{className:"h-8",value:De,onChange:z=>Ee(z.target.value),placeholder:s("settings.remoteInstances.direct.import.placeholder"),disabled:be,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ue(!1),disabled:be,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:be||!De.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(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>wt(!0),children:[t.jsx(D,{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(z=>{const Ke=r[z.id],ft=z.nickname?.trim()||z.sshParsed?.destination||z.id,vt=Ke?.phase,ts=vt==="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 ${Mo(vt)}`}),t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:ft})]}),t.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[s(Eo(vt)),Ke?.localUrl?` · ${Ke.localUrl}`:""]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(ts?R(z.id):x(z.id)).catch(ot=>W.error(s(ts?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:ot instanceof Error?ot.message:String(ot)}))},children:[ts?t.jsx(D,{name:"stop",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"plug-2",className:"h-3.5 w-3.5"}),s(ts?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>T(z.id),children:[t.jsx(D,{name:"pencil",className:"h-3.5 w-3.5"}),s("desktopHostSwitcher.actions.edit")]}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(s("settings.remoteInstances.page.confirm.removeInstance"))&&h(z.id).catch(ot=>W.error(s("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:ot instanceof Error?ot.message:String(ot)}))},children:[t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.delete")]})]})]},z.id)})})]}):null,n?t.jsx(Ot,{open:xt,onOpenChange:wt,children:t.jsxs(zt,{className:"sm:max-w-lg",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.remoteInstances.sidebar.actions.addSshInstance")}),t.jsx(Bt,{children:s("settings.remoteInstances.page.section.instanceDescription")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:z=>{z.preventDefault(),Zt()},children:[t.jsx(Ze,{className:"h-8",value:Ve,onChange:z=>Qe(z.target.value),placeholder:s("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:c}),t.jsx(Ze,{className:"h-8",value:St,onChange:z=>ie(z.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(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>wt(!1),disabled:c,children:s("settings.common.actions.cancel")}),t.jsx(G,{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(z=>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:[z.host,z.pattern?` ${s("settings.remoteInstances.page.import.patternSuffix")}`:""]}),t.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:z.sshCommand})]}),t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{wn(z.host,z.pattern)},children:s("settings.common.actions.import")})]},`${z.source}:${z.host}`))})})]}):null,t.jsx(Ot,{open:!!_,onOpenChange:z=>{z||Gt()},children:t.jsxs(zt,{className:"sm:max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.remoteInstances.page.patternDialog.title")}),t.jsx(Bt,{children:_?s("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:_}):s("settings.remoteInstances.page.patternDialog.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:z=>{z.preventDefault(),cn()},children:[t.jsx(Ze,{value:Z,onChange:z=>Q(z.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(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Gt,disabled:M,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:M,children:s("settings.remoteInstances.page.actions.create")})]})]})]})})]});const na=j.remoteOpenchamber.mode==="managed",Ha=j.nickname?.trim()||j.sshParsed?.destination||j.id;return t.jsx(Ot,{open:!!j,onOpenChange:z=>{z||T(null)},children:t.jsxs(zt,{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:Ha}),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 ${Mo(Nt)}`}),t.jsx("span",{children:s(Eo(Nt))}),Xe?.localUrl?t.jsx("span",{className:"font-mono text-foreground/80",children:Xe.localUrl}):null,Ps?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(G,{type:"button",variant:cs?"outline":"default",size:"xs",className:"!font-normal",onClick:_a,disabled:O||U,children:[cs?t.jsx(D,{name:"stop",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"plug-2",className:"h-3.5 w-3.5"}),Ys]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Un,disabled:!kn,children:[t.jsx(D,{name:"refresh",className:`h-3.5 w-3.5 ${rs||Qt&&!Ps?"animate-spin":""}`}),zs]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Va()},children:[t.jsx(D,{name:"terminal-window",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.logs")]}),t.jsxs(G,{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"))&&h(j.id).then(()=>{T(null),W.success(s("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(Ke=>{W.error(s("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:Ke instanceof Error?Ke.message:String(Ke)})})},children:[t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.sidebar.actions.remove")]})]}),Xe?.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:Xe.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(Ze,{className:"h-7 md:max-w-xl",value:j.sshCommand,onChange:z=>ke(Ke=>({...Ke,sshCommand:z.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(Ze,{className:"h-7 md:max-w-sm",value:j.nickname||"",onChange:z=>ke(Ke=>({...Ke,nickname:z.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(vs,{containerClassName:"w-fit",min:5,max:240,step:1,className:"w-16 tabular-nums",value:j.connectionTimeoutSec,onValueChange:z=>{ke(Ke=>({...Ke,connectionTimeoutSec:Number.isFinite(z)?z:Ke.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(Rt,{value:j.remoteOpenchamber.mode,onValueChange:z=>ke(Ke=>({...Ke,remoteOpenchamber:{...Ke.remoteOpenchamber,mode:z==="external"?"external":"managed"}})),children:[t.jsx(Tt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Lt,{placeholder:s("settings.remoteInstances.page.field.modePlaceholder")})}),t.jsxs(Ft,{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(vs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:j.remoteOpenchamber.preferredPort,onValueChange:z=>{ke(Ke=>({...Ke,remoteOpenchamber:{...Ke.remoteOpenchamber,preferredPort:Number.isFinite(z)&&z>0?z:void 0}}))},onClear:()=>{ke(z=>({...z,remoteOpenchamber:{...z.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]}),na?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(Rt,{value:j.remoteOpenchamber.installMethod,onValueChange:z=>ke(Ke=>({...Ke,remoteOpenchamber:{...Ke.remoteOpenchamber,installMethod:z==="npm"||z==="download_release"||z==="upload_bundle"?z:"bun"}})),children:[t.jsx(Tt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Lt,{placeholder:s("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),t.jsxs(Ft,{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,na?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(Fa,{checked:j.remoteOpenchamber.keepRunning,onCheckedChange:z=>ke(Ke=>({...Ke,remoteOpenchamber:{...Ke.remoteOpenchamber,keepRunning:z}}))})})]}):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(Rt,{value:j.localForward.bindHost,onValueChange:z=>{z==="0.0.0.0"&&!window.confirm(s("settings.remoteInstances.page.confirm.bindAllInterfaces"))||ke(Ke=>({...Ke,localForward:{...Ke.localForward,bindHost:z==="localhost"||z==="0.0.0.0"?z:"127.0.0.1"}}))},children:[t.jsx(Tt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Lt,{placeholder:s("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),t.jsxs(Ft,{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(vs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:j.localForward.preferredLocalPort,onValueChange:z=>{ke(Ke=>({...Ke,localForward:{...Ke.localForward,preferredLocalPort:Number.isFinite(z)&&z>0?z:void 0}}))},onClear:()=>{ke(z=>({...z,localForward:{...z.localForward,preferredLocalPort:void 0}}))},emptyLabel:s("settings.remoteInstances.page.field.auto")}),t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:s("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>ke(z=>({...z,localForward:{...z.localForward,preferredLocalPort:Kr()}})),children:t.jsx(D,{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(Ze,{className:"h-7 md:max-w-sm",type:"password",value:j.auth.sshPassword?.value||"",onChange:z=>ke(Ke=>({...Ke,auth:{...Ke.auth,sshPassword:{enabled:z.target.value.trim().length>0,value:z.target.value,store:Ke.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(Ze,{className:"h-7 md:max-w-sm",type:"password",value:j.auth.openchamberPassword?.value||"",onChange:z=>ke(Ke=>({...Ke,auth:{...Ke.auth,openchamberPassword:{enabled:z.target.value.trim().length>0,value:z.target.value,store:Ke.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:[j.portForwards.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground/80",children:s("settings.remoteInstances.page.empty.noExtraForwards")}):null,j.portForwards.map((z,Ke)=>{const ft=_t=>{ke(ds=>({...ds,portForwards:ds.portForwards.map((ai,jc)=>jc===Ke?_t(ai):ai)}))},vt=z.type==="remote"?"Local target":"Local listen",ts=z.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.",S=z.type==="remote"?"Remote listen":"Remote target",ot=z.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",Mt=Ro(z.localHost||"localhost",z.localPort),ss=Ro(z.remoteHost||"localhost",z.remotePort),As=z.type==="local"&&typeof z.localPort=="number"&&z.localPort>0,Ks=As?`http://${wf(z.localHost)}:${z.localPort}`:"",dn=!!ee[z.id],Bn=z.type==="local"?s("settings.remoteInstances.page.forwardType.local"):z.type==="remote"?s("settings.remoteInstances.page.forwardType.remote"):s("settings.remoteInstances.page.forwardType.dynamic");return t.jsxs(xn,{open:dn,onOpenChange:_t=>{K(ds=>({...ds,[z.id]:_t}))},className:`${Ke>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(bn,{className:"flex items-center gap-2 group",children:[t.jsx(D,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${dn?"rotate-180":""}`}),t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:bf(z)}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:Bn})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fa,{checked:z.enabled,onCheckedChange:_t=>ft(ds=>({...ds,enabled:_t})),"aria-label":s("settings.remoteInstances.page.actions.enableForwardAria")}),t.jsx(G,{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:()=>ke(_t=>({..._t,portForwards:_t.portForwards.filter(ds=>ds.id!==z.id)})),children:t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),t.jsx(yn,{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(jf(z.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(Rt,{value:z.type,onValueChange:_t=>ft(ds=>({...ds,type:_t==="dynamic"||_t==="remote"?_t:"local"})),children:[t.jsx(Tt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Lt,{placeholder:s("settings.remoteInstances.page.field.typePlaceholder")})}),t.jsxs(Ft,{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:vt,hint:ts})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ze,{className:"h-7 w-32",value:z.localHost||"127.0.0.1",onChange:_t=>ft(ds=>({...ds,localHost:_t.target.value})),placeholder:s("settings.remoteInstances.page.field.localHostPlaceholder")}),t.jsx("span",{className:"text-muted-foreground",children:":"}),t.jsx(vs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:z.localPort,onValueChange:_t=>{ft(ds=>({...ds,localPort:Number.isFinite(_t)&&_t>0?_t:void 0}))},onClear:()=>{ft(_t=>({..._t,localPort:void 0}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]})]}),z.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:S,hint:ot})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ze,{className:"h-7 w-32",value:z.remoteHost||"",onChange:_t=>ft(ds=>({...ds,remoteHost:_t.target.value})),placeholder:s("settings.remoteInstances.page.field.remoteHostPlaceholder")}),t.jsx("span",{className:"text-muted-foreground",children:":"}),t.jsx(vs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:z.remotePort,onValueChange:_t=>{ft(ds=>({...ds,remotePort:Number.isFinite(_t)&&_t>0?_t:void 0}))},onClear:()=>{ft(_t=>({..._t,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:z.type==="dynamic"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:Mt}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.localSocks5")})]}):z.type==="remote"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"server",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:ss}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.remote")}),t.jsx(D,{name:"arrow-right",className:"h-3.5 w-3.5"}),t.jsx(D,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:Mt}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.local")})]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:Mt}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.local")}),t.jsx(D,{name:"arrow-right",className:"h-3.5 w-3.5"}),t.jsx(D,{name:"server",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:ss}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.remote")})]})}),As?t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ws(Ks).then(_t=>{_t||W.error(s("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[t.jsx(D,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},z.id)}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const z=yf();ke(Ke=>({...Ke,portForwards:[...Ke.portForwards,z]})),K(Ke=>({...Ke,[z.id]:!0}))},children:[t.jsx(D,{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(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Ct()},disabled:!ct||c,children:s("settings.common.actions.saveChanges")}),Xe?.localUrl?t.jsxs(t.Fragment,{children:[t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{hn(Xe.localUrl||"").then(z=>{z.ok&&W.success(s("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[t.jsx(D,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.copyLocalUrl")]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{$n()},children:[t.jsx(D,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.open")]})]}):null,f?t.jsx("div",{className:"ml-auto typography-meta text-[var(--status-error)]",children:f}):null]})}),t.jsx(Ot,{open:A,onOpenChange:$,children:t.jsxs(zt,{className:"sm:max-w-2xl",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.remoteInstances.page.logsDialog.title")}),t.jsx(Bt,{children:j?.nickname?.trim()||j?.sshParsed?.destination||j?.id||s("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Js,disabled:F||!Es.trim(),children:[t.jsx(D,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.common.actions.copyAll")]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Qs()},disabled:F,children:[t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.clear")]})]}),F?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:L.length>0?L.join(`
|
|
29
|
-
`):s("settings.remoteInstances.page.logsDialog.empty")})]})}),t.jsx(Ot,{open:!!_,onOpenChange:z=>{z||Gt()},children:t.jsxs(zt,{className:"sm:max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:s("settings.remoteInstances.page.patternDialog.title")}),t.jsx(Bt,{children:_?s("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:_}):s("settings.remoteInstances.page.patternDialog.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:z=>{z.preventDefault(),cn()},children:[t.jsx(Ze,{value:Z,onChange:z=>Q(z.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(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Gt,disabled:M,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:M,children:s("settings.common.actions.create")})]})]})]})})]})})},Df="__add_provider__",Ef=()=>{const s=ys.getDirectory();return typeof s=="string"&&s.trim().length>0?s.trim():null},Mf=({onItemSelect:s})=>{const{t:e}=it(),n=lt(m=>m.providers),a=lt(m=>m.selectedProviderId),r=lt(m=>m.setSelectedProvider),i=ns(m=>m.activeProjectId),[o,d]=l.useState({}),c=l.useMemo(()=>Ef(),[i]);l.useEffect(()=>{if(n.length===0){d({});return}let m=!1;return(async()=>{const g=n.map(async h=>{try{const x=c?`?directory=${encodeURIComponent(c)}`:"",R=await ht(`/api/provider/${encodeURIComponent(h.id)}/source${x}`,{method:"GET",headers:{Accept:"application/json"}});if(!R.ok)return;const C=await R.json().catch(()=>null),N=C?.sources??C?.data?.sources;if(!N||m)return;d(T=>({...T,[h.id]:N}))}catch{}});await Promise.all(g)})(),()=>{m=!0}},[c,n]);const f="bg-background",u=l.useMemo(()=>n.filter(m=>!!o[m.id]?.project?.exists),[n,o]),p=l.useMemo(()=>n.filter(m=>!o[m.id]?.project?.exists),[n,o]);return t.jsxs("div",{className:ce("flex h-full flex-col",f),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(sa,{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(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:()=>{r(Df),s?.()},"aria-label":e("settings.providers.sidebar.actions.connectProviderAria"),title:e("settings.providers.sidebar.actions.connectProviderTitle"),children:t.jsx(D,{name:"add",className:"h-3.5 w-3.5"})})]})]}),t.jsx(Wt,{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(D,{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(m=>t.jsx(To,{provider:m,selectedProviderId:a,onSelect:()=>{r(m.id),s?.()}},m.id))]}),u.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")}),u.map(m=>t.jsx(To,{provider:m,selectedProviderId:a,onSelect:()=>{r(m.id),s?.()}},m.id))]})]})})]})},To=s=>{const e=nt.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 f;e[0]!==c?(f=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",c),e[0]=c,e[1]=f):f=e[1];let u;e[2]!==n.id?(u=t.jsx(Tn,{providerId:n.id,className:"h-4 w-4 flex-shrink-0"}),e[2]=n.id,e[3]=u):u=e[3];const p=n.name||n.id;let m;e[4]!==p?(m=t.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:p}),e[4]=p,e[5]=m):m=e[5];let P;e[6]!==i?(P=t.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:i}),e[6]=i,e[7]=P):P=e[7];let g;e[8]!==r||e[9]!==u||e[10]!==m||e[11]!==P?(g=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:[u,m,P]}),e[8]=r,e[9]=u,e[10]=m,e[11]=P,e[12]=g):g=e[12];let h;return e[13]!==n.id||e[14]!==f||e[15]!==g?(h=t.jsx("div",{className:f,children:g},d),e[13]=n.id,e[14]=f,e[15]=g,e[16]=h):h=e[16],h},Rf=s=>s,Tf=s=>new Intl.NumberFormat(Gr(),{notation:"compact",compactDisplay:"short",maximumFractionDigits:1,minimumFractionDigits:0}).format(s),Fo=s=>{if(typeof s!="number"||Number.isNaN(s))return null;if(s===0)return"0";const e=Tf(s);return e.endsWith(".0")?e.slice(0,-2):e},fa="__add_provider__",On=s=>typeof s=="object"&&s!==null,Lo=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()},Ff=s=>{if(!On(s))return{};const e={};for(const[n,a]of Object.entries(s))Array.isArray(a)&&(e[n]=a.filter(r=>On(r)));return e},Lf=s=>{if(typeof s=="string")return{id:s};if(!On(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}},Of=s=>{let e=[];Array.isArray(s)?e=s:On(s)&&(Array.isArray(s.all)?e=s.all:Array.isArray(s.providers)&&(e=s.providers));const n=e.map(r=>Lf(r)).filter(r=>!!r),a=new Set;return n.filter(r=>a.has(r.id)?!1:(a.add(r.id),!0))},zf=()=>{const{t:s}=it(),e=lt(H=>H.providers),n=lt(H=>H.selectedProviderId),a=lt(H=>H.setSelectedProvider),r=lt(H=>H.getModelMetadata),i=ze(H=>H.hiddenModels),o=ze(H=>H.toggleHiddenModel),d=ze(H=>H.hideAllModels),c=ze(H=>H.showAllModels),[f,u]=l.useState({}),[p,m]=l.useState(!1),[P,g]=l.useState({}),[h,x]=l.useState(null),[R,C]=l.useState(""),[N,T]=l.useState(null),[k,j]=l.useState({}),[b,A]=l.useState({}),[$,F]=l.useState([]),[I,v]=l.useState(!1),[w,L]=l.useState(null),[E,_]=l.useState(""),[B,Z]=l.useState(""),[Q,M]=l.useState(!1),[X,ee]=l.useState({}),[K,O]=l.useState(!1),Y=n===fa;l.useEffect(()=>{!n&&e.length>0&&a(e[0].id)},[e,n,a]),l.useEffect(()=>{if(!Y)return;let H=!0;return(async()=>{m(!0);try{const ae=await ys.getSdkClient().provider.auth();if(ae.error)throw new Error(`provider.auth failed: ${String(ae.error)}`);if(!H)return;u(Ff(ae.data))}catch(ae){if(!H)return;console.error("Failed to load provider auth methods:",ae),W.error(s("settings.providers.page.toast.authMethodsLoadFailed"))}finally{H&&m(!1)}})(),()=>{H=!1}},[Y,s]),l.useEffect(()=>{if(!Rf(Y))return;let H=!0;return(async()=>{v(!0),L(null);try{const ae=await ys.getSdkClient().provider.list();if(ae.error)throw new Error(`provider.list failed: ${String(ae.error)}`);if(!H)return;F(Of(ae.data))}catch(ae){if(!H)return;console.error("Failed to load available providers:",ae),L(s("settings.providers.page.state.unableToLoadProviderList"))}finally{H&&v(!1)}})(),()=>{H=!1}},[Y,s]);const U=l.useMemo(()=>new Set(e.map(H=>H.id)),[e]),ne=l.useMemo(()=>$.filter(H=>!U.has(H.id)).sort((H,te)=>{const ae=(H.name||H.id).toLowerCase(),me=(te.name||te.id).toLowerCase();return ae.localeCompare(me)}),[$,U]);l.useEffect(()=>{n===fa&&E&&!ne.some(H=>H.id===E)&&_("")},[n,E,ne]),l.useEffect(()=>{if(n===fa){O(!0);return}O(!1)},[n,s]),l.useEffect(()=>{if(!n||n===fa)return;let H=!1;return(async()=>{try{const ae=await ht(`/api/provider/${encodeURIComponent(n)}/source`,{method:"GET",headers:{Accept:"application/json"}}),me=await ae.json().catch(()=>null);if(!ae.ok)throw new Error(me?.error||s("settings.providers.page.toast.providerSourcesLoadFailed"));const Me=me?.sources??me?.data?.sources;!H&&Me&&ee(Ne=>({...Ne,[n]:Me}))}catch(ae){H||console.error("Failed to load provider sources:",ae)}})(),()=>{H=!0}},[n,s]);const re=e.find(H=>H.id===n),V=n?X[n]:void 0,oe=async H=>{const te=P[H]?.trim()??"";if(!te){W.error(s("settings.providers.page.toast.apiKeyRequired"));return}const ae=`api:${H}`;x(ae);try{if((await ys.getSdkClient().auth.set({providerID:H,auth:{type:"api",key:te}})).error)throw new Error(s("settings.providers.page.toast.apiKeySaveFailed"));W.success(s("settings.providers.page.toast.apiKeySaved")),g(Me=>({...Me,[H]:""})),await Mn({scopes:["providers"],mode:"active"}),a(H)}catch(me){console.error("Failed to save API key:",me),W.error(s("settings.providers.page.toast.apiKeySaveFailed"))}finally{x(null)}},fe=async(H,te)=>{const ae=`oauth:${H}:${te}`;x(ae);try{const me=await ys.getSdkClient().provider.oauth.authorize({providerID:H,method:te});if(me.error)throw new Error(s("settings.providers.page.toast.oauthStartFailed"));const Me=On(me.data)?me.data:{},Ne=Me.data,De=On(Ne)?Ne:Me,Ee=typeof De.url=="string"&&De.url||typeof De.verification_uri_complete=="string"&&De.verification_uri_complete||typeof De.verification_uri=="string"&&De.verification_uri||void 0,Pe=typeof De.instructions=="string"&&De.instructions||typeof De.message=="string"&&De.message||void 0,Te=typeof De.user_code=="string"&&De.user_code||typeof De.code=="string"&&De.code||typeof De.userCode=="string"&&De.userCode||void 0;if(!Ee&&!Pe&&!Te)throw new Error(s("settings.providers.page.toast.oauthDetailsMissing"));const Le=`${H}:${te}`;A(Be=>({...Be,[Le]:{url:Ee,instructions:Pe,userCode:Te}})),Ee&&Ws(Ee),T({providerId:H,methodIndex:te}),W.message(s("settings.providers.page.toast.completeOAuthInBrowser"))}catch(me){console.error("Failed to start OAuth flow:",me),W.error(s("settings.providers.page.toast.oauthStartFailed"))}finally{x(null)}},xe=async(H,te)=>{const ae=`${H}:${te}`,me=k[ae]?.trim(),Me=`oauth-complete:${H}:${te}`;x(Me);try{const Ne={method:te};if(me&&(Ne.code=me),(await ys.getSdkClient().provider.oauth.callback({providerID:H,method:Ne.method,code:Ne.code})).error)throw new Error(s("settings.providers.page.toast.oauthCompleteFailed"));W.success(s("settings.providers.page.toast.oauthCompleted")),j(Ee=>({...Ee,[ae]:""})),T(null),await Mn({scopes:["providers"],mode:"active"}),a(H)}catch(Ne){console.error("Failed to complete OAuth flow:",Ne),W.error(s("settings.providers.page.toast.oauthCompleteFailed"))}finally{x(null)}},Ie=async H=>{const te=await hn(H);if(te.ok){W.success(s("settings.providers.page.toast.oauthLinkCopied"));return}console.error("Failed to copy OAuth link:",te.error),W.error(s("settings.providers.page.toast.oauthLinkCopyFailed"))},ve=async H=>{const te=await hn(H);if(te.ok){W.success(s("settings.providers.page.toast.deviceCodeCopied"));return}console.error("Failed to copy device code:",te.error),W.error(s("settings.providers.page.toast.deviceCodeCopyFailed"))},we=async H=>{const te=`disconnect:${H}`;x(te);try{const ae=await ht(`/api/provider/${encodeURIComponent(H)}/auth?scope=all`,{method:"DELETE",headers:{Accept:"application/json"}}),me=await ae.json().catch(()=>null);if(!ae.ok)throw new Error(me?.error||s("settings.providers.page.toast.providerDisconnectFailed"));W.success(s("settings.providers.page.toast.providerDisconnected")),await Mn({scopes:["providers"],mode:"active"})}catch(ae){console.error("Failed to disconnect provider:",ae),W.error(s("settings.providers.page.toast.providerDisconnectFailed"))}finally{x(null)}};if(!Y&&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(D,{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(Y)return t.jsx(Wt,{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")}):w?t.jsx("p",{className:"typography-meta text-muted-foreground",children:w}):ne.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.connect.allProvidersConnected")}):t.jsxs(gs,{open:Q,onOpenChange:H=>{M(H),H||Z("")},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:[E?t.jsx(Tn,{providerId:E,className:"h-3.5 w-3.5 flex-shrink-0"}):null,t.jsx("span",{className:ce("truncate typography-ui-label font-normal",E?"text-foreground":"text-muted-foreground"),children:E?ne.find(H=>H.id===E)?.name||E:s("settings.providers.page.connect.selectProviderPlaceholder")})]}),t.jsx(D,{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:H=>H.preventDefault(),children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2",onKeyDown:H=>H.stopPropagation(),children:[t.jsx(D,{name:"search",className:"h-4 w-4 text-muted-foreground"}),t.jsx("input",{type:"text",value:B,onChange:H=>Z(H.target.value),onKeyDown:H=>H.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(Wt,{outerClassName:"max-h-[240px]",className:"p-1",children:(()=>{const H=ne.filter(te=>{const ae=B.toLowerCase();return(te.name||te.id).toLowerCase().includes(ae)||te.id.toLowerCase().includes(ae)});return H.length===0?t.jsx("p",{className:"py-4 text-center typography-meta text-muted-foreground",children:s("settings.providers.page.connect.noProvidersFound")}):H.map(te=>t.jsxs(js,{onSelect:()=>{_(te.id),M(!1),Z("")},className:"flex items-center justify-between",children:[t.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Tn,{providerId:te.id,className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:te.name||te.id})]}),E===te.id&&t.jsx(D,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},te.id))})()})]})]})]})})]}),E&&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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(Ze,{type:"password",value:P[E]??"",onChange:H=>g(te=>({...te,[E]:H.target.value})),placeholder:s("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>oe(E),disabled:h===`api:${E}`,children:h===`api:${E}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.saveKey")})]})]}),(()=>{const te=(f[E]??[]).filter(ae=>Lo(ae)==="oauth");return te.length===0?null:t.jsx("div",{className:"space-y-4 border-t border-[var(--surface-subtle)] pt-2",children:te.map((ae,me)=>{const Me=ae.label||ae.name||s("settings.providers.page.auth.oauthMethodFallback",{index:String(me+1)}),Ne=`${E}:${me}`,De=N?.providerId===E&&N?.methodIndex===me;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}),(ae.description||ae.help)&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:String(ae.description||ae.help)})]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>fe(E,me),disabled:h===`oauth:${E}:${me}`,children:s("settings.providers.page.actions.connect")})]}),b[Ne]?.instructions&&t.jsx("p",{className:"typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded",children:b[Ne]?.instructions}),b[Ne]?.userCode&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(Ze,{value:b[Ne]?.userCode,readOnly:!0,className:"font-mono text-center tracking-widest"}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ve(b[Ne]?.userCode??""),children:s("settings.providers.page.actions.copyCode")})]}),b[Ne]?.url&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(Ze,{value:b[Ne]?.url,readOnly:!0,className:"text-xs text-muted-foreground"}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ws(b[Ne]?.url??""),children:s("settings.providers.page.actions.open")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(b[Ne]?.url??""),children:s("settings.providers.page.actions.copy")})]})]}),De&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(Ze,{value:k[Ne]??"",onChange:Ee=>j(Pe=>({...Pe,[Ne]:Ee.target.value})),placeholder:s("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal",onClick:()=>xe(E,me),disabled:h===`oauth-complete:${E}:${me}`,children:h===`oauth-complete:${E}:${me}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.complete")})]})]},`${E}-${Me}`)})})})()]})]})]})});if(!re)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(D,{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 be=Array.isArray(re.models)?re.models:[],le=(f[re.id]??[]).filter(H=>Lo(H)==="oauth"),ye=be.filter(H=>{const te=typeof H?.name=="string"?H.name:"",ae=typeof H?.id=="string"?H.id:"",me=R.trim().toLowerCase();return me?te.toLowerCase().includes(me)||ae.toLowerCase().includes(me):!0});return t.jsx(Wt,{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(Tn,{providerId:re.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:re.name||re.id}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:t.jsx("span",{className:"font-mono",children:re.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(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>O(H=>!H),children:s(K?"settings.providers.page.actions.hide":"settings.providers.page.actions.reconnect")})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:K?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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(Ze,{type:"password",value:P[re.id]??"",onChange:H=>g(te=>({...te,[re.id]:H.target.value})),placeholder:s("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>oe(re.id),disabled:h===`api:${re.id}`,children:h===`api:${re.id}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.saveKey")})]})]}),le.length>0&&t.jsx("div",{className:"space-y-4 border-t border-[var(--surface-subtle)] pt-2",children:le.map((H,te)=>{const ae=H.label||H.name||s("settings.providers.page.auth.oauthMethodFallback",{index:String(te+1)}),me=`${re.id}:${te}`,Me=N?.providerId===re.id&&N?.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:ae}),(H.description||H.help)&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:String(H.description||H.help)})]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>fe(re.id,te),disabled:h===`oauth:${re.id}:${te}`,children:s("settings.providers.page.actions.connect")})]}),b[me]?.instructions&&t.jsx("p",{className:"typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded",children:b[me]?.instructions}),b[me]?.userCode&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(Ze,{value:b[me]?.userCode,readOnly:!0,className:"font-mono text-center tracking-widest"}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ve(b[me]?.userCode??""),children:s("settings.providers.page.actions.copyCode")})]}),b[me]?.url&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(Ze,{value:b[me]?.url,readOnly:!0,className:"text-xs text-muted-foreground"}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ws(b[me]?.url??""),children:s("settings.providers.page.actions.open")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(b[me]?.url??""),children:s("settings.providers.page.actions.copy")})]})]}),Me&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(Ze,{value:k[me]??"",onChange:Ne=>j(De=>({...De,[me]:Ne.target.value})),placeholder:s("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal",onClick:()=>xe(re.id,te),disabled:h===`oauth-complete:${re.id}:${te}`,children:h===`oauth-complete:${re.id}:${te}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.complete")})]})]},`${re.id}-${ae}`)})})]}):t.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[t.jsx(D,{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:V&&(V.auth.exists||V.user.exists||V.project.exists||V.custom?.exists)?t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[s("settings.providers.page.connectionDetails.configuredIn")," ",[V.auth.exists?s("settings.providers.page.connectionDetails.source.authCredentials"):null,V.user.exists?s("settings.providers.page.connectionDetails.source.userConfig"):null,V.project.exists?s("settings.providers.page.connectionDetails.source.projectConfig"):null,V.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(G,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>we(re.id),disabled:h===`disconnect:${re.id}`,children:h===`disconnect:${re.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"),be.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",be.length,")"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const H=be.map(te=>typeof te?.id=="string"?te.id:"").filter(te=>te.length>0);d(re.id,H)},children:s("settings.providers.page.actions.hideAll")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>c(re.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(D,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),t.jsx(Ze,{value:R,onChange:H=>C(H.target.value),placeholder:s("settings.providers.page.models.filterPlaceholder"),className:"h-7 pl-8 w-full"})]}),ye.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:ye.map(H=>{const te=typeof H?.id=="string"?H.id:"",ae=typeof H?.name=="string"?H.name:te,me=te?r(re.id,te):void 0,Me=i.some(Pe=>Pe.providerID===re.id&&Pe.modelID===te),Ne=Fo(me?.limit?.context),De=Fo(me?.limit?.output),Ee=[];return me?.tool_call&&Ee.push({key:"tools",icon:"tools",label:s("settings.providers.page.models.capability.toolCalling")}),me?.reasoning&&Ee.push({key:"reasoning",icon:"brain-ai-3",label:s("settings.providers.page.models.capability.reasoning")}),me?.attachment&&Ee.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:ae}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(Ne||De)&&t.jsxs("span",{className:"typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:[Ne?`${Ne} ${s("settings.providers.page.models.tokenBadge.context")}`:"",Ne&&De?" · ":"",De?`${De} ${s("settings.providers.page.models.tokenBadge.output")}`:""]}),Ee.length>0&&t.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:Ee.map(({key:Pe,icon:Te,label:Le})=>t.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]",title:Le,"aria-label":Le,children:t.jsx(D,{name:Te,className:"h-3 w-3"})},Pe))}),t.jsx("button",{type:"button",onClick:()=>o(re.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(D,{name:"eye-off",className:"h-3.5 w-3.5"}):t.jsx(D,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},te)})})]})]})]})})},on=[{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 Oo(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 Kf=[{id:"gemini-auth",label:"Gemini",matcher:s=>s.startsWith("gemini/"),order:1},{id:"antigravity-auth",label:"Antigravity",matcher:s=>s.startsWith("antigravity/"),order:2}],Xl={google:Kf};function Zl(s,e){const n=Xl[e]??[];for(const a of n)if(a.matcher(s))return a;return null}function $f(s){return Xl[s]??[]}function Uf(s){return[...s].sort((e,n)=>e.order-n.order)}function Jv(s,e){const n=new Map;for(const a of Object.keys(s)){const i=Zl(a,e)?.id??null;n.has(i)||n.set(i,[]),n.get(i).push(a)}return n}function Bf(s,e,n){const a=new Map;for(const r of s){const i=e(r),d=Zl(i,n)?.id??null;a.has(d)||a.set(d,[]),a.get(d).push(r)}return a}function Vf(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 Zr=6e4,zo=s=>{const e=on.map(m=>m.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))):Zr,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(m=>typeof m=="string"&&e.includes(m)):e,c={},f=s?.usageSelectedModels;if(f&&typeof f=="object")for(const[m,P]of Object.entries(f))Array.isArray(P)&&(c[m]=P.filter(g=>typeof g=="string"));const u={},p=s?.usageExpandedFamilies;if(p&&typeof p=="object")for(const[m,P]of Object.entries(p))Array.isArray(P)&&(u[m]=P.filter(g=>typeof g=="string"));return{autoRefresh:n,refreshIntervalMs:a,displayMode:r,showPredValues:i,dropdownProviderIds:d,selectedModels:c,expandedFamilies:u}},_f=async()=>{const s=Os()?.settings;if(s)try{const n=(await s.load())?.settings;return zo(n??null)}catch{}if(!fs()){const e=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(e.ok){const n=await e.json().catch(()=>null);return zo(n)}}return{autoRefresh:!1,refreshIntervalMs:Zr,displayMode:"usage",showPredValues:!1,dropdownProviderIds:on.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Ut=ln()(ta((s,e)=>({results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Zr,displayMode:"usage",showPredValues:!1,dropdownProviderIds:on.map(n=>n.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{try{const n=await _f();s(n)}catch(n){console.warn("Failed to load usage settings:",n)}},fetchAllQuotas:async()=>{s({isLoading:!0,error:null});const n=on.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 ht(`/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}})),Pt({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}}}),Pt({usageExpandedFamilies:e().expandedFamilies})},applyDefaultSelections:(n,a)=>{if((e().selectedModels[n]?.length??0)>0)return;const i=Vf(n,a);i.length!==0&&(s(o=>({selectedModels:{...o.selectedModels,[n]:i}})),Pt({usageSelectedModels:e().selectedModels}))}}),{name:"quota-store"})),Hf=()=>{const s=nt.c(5),e=Ut(Wf),n=Ut(qf),a=Ut(Gf);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 Wf(s){return s.autoRefresh}function qf(s){return s.refreshIntervalMs}function Gf(s){return s.fetchAllQuotas}const Jf=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)},Qf=s=>{const e=nt.c(122),{onItemSelect:n}=s,{t:a}=it(),r=Ut(Yf),i=Ut(Xf),o=Ut(Zf),d=Ut(ex),c=Ut(tx),f=Ut(sx),u=Ut(nx),p=Ut(ax),m=Ut(rx),P=Ut(ix),g=Ut(ox),h=Ut(lx),x=Ut(cx),R=Ut(dx);let C,N;e[0]!==R?(C=()=>{R()},N=[R],e[0]=R,e[1]=C,e[2]=N):(C=e[1],N=e[2]),l.useEffect(C,N);const T=mx;let k;e[3]!==m?(k=je=>{m(je),T({usageAutoRefresh:je})},e[3]=m,e[4]=k):k=e[4];const j=k;let b;e[5]!==P?(b=je=>{const Re=Number(je);Number.isFinite(Re)&&(P(Re),T({usageRefreshIntervalMs:Re}))},e[5]=P,e[6]=b):b=e[6];const A=b;let $;e[7]!==g?($=je=>{je!=="usage"&&je!=="remaining"||(g(je),T({usageDisplayMode:je}))},e[7]=g,e[8]=$):$=e[8];const F=$;let I;e[9]!==x?(I=je=>{x(je),T({usageShowPredValues:je})},e[9]=x,e[10]=I):I=e[10];const v=I;let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=ce("flex h-full flex-col","bg-background"),e[11]=w):w=e[11];let L;e[12]!==a?(L=a("settings.usage.sidebar.title"),e[12]=a,e[13]=L):L=e[13];let E;e[14]!==L?(E=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:L}),e[14]=L,e[15]=E):E=e[15];let _;e[16]!==a?(_=a("settings.usage.sidebar.total",{count:on.length}),e[16]=a,e[17]=_):_=e[17];let B;e[18]!==_?(B=t.jsx("span",{className:"typography-meta text-muted-foreground",children:_}),e[18]=_,e[19]=B):B=e[19];let Z;e[20]!==a?(Z=a("settings.usage.sidebar.actions.toggleAutoRefreshAria"),e[20]=a,e[21]=Z):Z=e[21];let Q;e[22]!==j||e[23]!==Z||e[24]!==f?(Q=t.jsx(At,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(kt,{checked:f,onChange:j,ariaLabel:Z})})}),e[22]=j,e[23]=Z,e[24]=f,e[25]=Q):Q=e[25];let M;e[26]!==a?(M=a("settings.usage.sidebar.tooltip.autoRefresh"),e[26]=a,e[27]=M):M=e[27];let X;e[28]!==M?(X=t.jsx(Et,{side:"bottom",children:M}),e[28]=M,e[29]=X):X=e[29];let ee;e[30]!==Q||e[31]!==X?(ee=t.jsxs(It,{children:[Q,X]}),e[30]=Q,e[31]=X,e[32]=ee):ee=e[32];const K=String(u),O=!f;let Y;e[33]!==a?(Y=a("settings.usage.sidebar.field.intervalPlaceholder"),e[33]=a,e[34]=Y):Y=e[34];let U;e[35]!==Y?(U=t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:Y})}),e[35]=Y,e[36]=U):U=e[36];let ne;e[37]===Symbol.for("react.memo_cache_sentinel")?(ne=t.jsxs(Ft,{children:[t.jsx(gt,{value:"30000",children:"30s"}),t.jsx(gt,{value:"60000",children:"1m"}),t.jsx(gt,{value:"300000",children:"5m"})]}),e[37]=ne):ne=e[37];let re;e[38]!==A||e[39]!==K||e[40]!==O||e[41]!==U?(re=t.jsxs(Rt,{value:K,onValueChange:A,disabled:O,children:[U,ne]}),e[38]=A,e[39]=K,e[40]=O,e[41]=U,e[42]=re):re=e[42];let V;e[43]!==d?(V=()=>d(),e[43]=d,e[44]=V):V=e[44];let oe;e[45]!==a?(oe=a("settings.usage.sidebar.actions.refreshAria"),e[45]=a,e[46]=oe):oe=e[46];let fe;e[47]!==a?(fe=a("settings.usage.sidebar.actions.refreshTitle"),e[47]=a,e[48]=fe):fe=e[48];const xe=c&&"animate-spin";let Ie;e[49]!==xe?(Ie=ce("h-3.5 w-3.5",xe),e[49]=xe,e[50]=Ie):Ie=e[50];let ve;e[51]!==Ie?(ve=t.jsx(D,{name:"refresh",className:Ie}),e[51]=Ie,e[52]=ve):ve=e[52];let we;e[53]!==c||e[54]!==V||e[55]!==oe||e[56]!==fe||e[57]!==ve?(we=t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:V,"aria-label":oe,title:fe,disabled:c,children:ve}),e[53]=c,e[54]=V,e[55]=oe,e[56]=fe,e[57]=ve,e[58]=we):we=e[58];let be;e[59]!==ee||e[60]!==re||e[61]!==we?(be=t.jsxs("div",{className:"flex items-center gap-2",children:[ee,re,we]}),e[59]=ee,e[60]=re,e[61]=we,e[62]=be):be=e[62];let se;e[63]!==B||e[64]!==be?(se=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[B,be]}),e[63]=B,e[64]=be,e[65]=se):se=e[65];let le;e[66]!==a?(le=a("settings.usage.sidebar.field.display"),e[66]=a,e[67]=le):le=e[67];let ye;e[68]!==le?(ye=t.jsx("span",{className:"typography-micro text-muted-foreground",children:le}),e[68]=le,e[69]=ye):ye=e[69];let H;e[70]!==a?(H=a("settings.usage.sidebar.field.displayModePlaceholder"),e[70]=a,e[71]=H):H=e[71];let te;e[72]!==H?(te=t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:H})}),e[72]=H,e[73]=te):te=e[73];let ae;e[74]!==a?(ae=a("settings.usage.sidebar.field.displayModeUsage"),e[74]=a,e[75]=ae):ae=e[75];let me;e[76]!==ae?(me=t.jsx(gt,{value:"usage",children:ae}),e[76]=ae,e[77]=me):me=e[77];let Me;e[78]!==a?(Me=a("settings.usage.sidebar.field.displayModeRemaining"),e[78]=a,e[79]=Me):Me=e[79];let Ne;e[80]!==Me?(Ne=t.jsx(gt,{value:"remaining",children:Me}),e[80]=Me,e[81]=Ne):Ne=e[81];let De;e[82]!==me||e[83]!==Ne?(De=t.jsxs(Ft,{children:[me,Ne]}),e[82]=me,e[83]=Ne,e[84]=De):De=e[84];let Ee;e[85]!==F||e[86]!==te||e[87]!==De||e[88]!==p?(Ee=t.jsxs(Rt,{value:p,onValueChange:F,children:[te,De]}),e[85]=F,e[86]=te,e[87]=De,e[88]=p,e[89]=Ee):Ee=e[89];let Pe;e[90]!==ye||e[91]!==Ee?(Pe=t.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[ye,Ee]}),e[90]=ye,e[91]=Ee,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 Le;e[95]!==Te?(Le=t.jsx("span",{className:"typography-micro text-muted-foreground",children:Te}),e[95]=Te,e[96]=Le):Le=e[96];let Be;e[97]!==a?(Be=a("settings.usage.sidebar.field.showPredictions"),e[97]=a,e[98]=Be):Be=e[98];let He;e[99]!==v||e[100]!==h||e[101]!==Be?(He=t.jsx(kt,{checked:h,onChange:v,ariaLabel:Be}),e[99]=v,e[100]=h,e[101]=Be,e[102]=He):He=e[102];let Ue;e[103]!==Le||e[104]!==He?(Ue=t.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[Le,He]}),e[103]=Le,e[104]=He,e[105]=Ue):Ue=e[105];let Je;e[106]!==se||e[107]!==Pe||e[108]!==Ue||e[109]!==E?(Je=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[E,se,Pe,Ue]}),e[106]=se,e[107]=Pe,e[108]=Ue,e[109]=E,e[110]=Je):Je=e[110];let de;e[111]!==n||e[112]!==r||e[113]!==i||e[114]!==o||e[115]!==a?(de=on.map(je=>{const Re=r.find(Ae=>Ae.providerId===je.id),Ce=Jf(Re?.usage),_e=Dl(Ce),J=je.id===i,y=Re?.configured??!1,pe=y?_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",J?"bg-interactive-selection":"hover:bg-interactive-hover"),children:t.jsxs("button",{type:"button",onClick:()=>{o(je.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:pe}),t.jsx(Tn,{providerId:je.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:je.name}),!y&&t.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:a("settings.usage.sidebar.status.notSet")})]})},je.id)}),e[111]=n,e[112]=r,e[113]=i,e[114]=o,e[115]=a,e[116]=de):de=e[116];let q;e[117]!==de?(q=t.jsx(Wt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:de}),e[117]=de,e[118]=q):q=e[118];let ue;return e[119]!==Je||e[120]!==q?(ue=t.jsxs("div",{className:w,children:[Je,q]}),e[119]=Je,e[120]=q,e[121]=ue):ue=e[121],ue};function Yf(s){return s.results}function Xf(s){return s.selectedProviderId}function Zf(s){return s.setSelectedProvider}function ex(s){return s.fetchAllQuotas}function tx(s){return s.isLoading}function sx(s){return s.autoRefresh}function nx(s){return s.refreshIntervalMs}function ax(s){return s.displayMode}function rx(s){return s.setAutoRefresh}function ix(s){return s.setRefreshInterval}function ox(s){return s.setDisplayMode}function lx(s){return s.showPredValues}function cx(s){return s.setShowPredValues}function dx(s){return s.loadSettings}async function mx(s){try{await Pt(s)}catch(e){console.warn("Failed to save usage settings:",e)}}const ux=s=>{const e=nt.c(20),{percent:n,tonePercent:a,className:r,expectedMarkerPercent:i}=s;let o;e[0]!==n?(o=im(n)??0,e[0]=n,e[1]=o):o=e[1];const d=o,c=a??n;let f;e[2]!==c?(f=Dl(c),e[2]=c,e[3]=f):f=e[3];const u=f,p=i!=null?Math.max(0,Math.min(100,i)):null;let m;e[4]!==u?(m=u==="critical"?{backgroundColor:"var(--status-error)"}:u==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=u,e[5]=m):m=e[5];const P=m;let g;e[6]!==r?(g=ce("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",r),e[6]=r,e[7]=g):g=e[7];const h=`${d}%`;let x;e[8]!==P||e[9]!==h?(x={...P,width:h},e[8]=P,e[9]=h,e[10]=x):x=e[10];let R;e[11]!==d||e[12]!==x?(R=t.jsx("div",{className:"h-full transition-all duration-300",style:x,role:"progressbar","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100}),e[11]=d,e[12]=x,e[13]=R):R=e[13];let C;e[14]!==p?(C=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]=C):C=e[15];let N;return e[16]!==g||e[17]!==R||e[18]!==C?(N=t.jsxs("div",{className:g,children:[R,C]}),e[16]=g,e[17]=R,e[18]=C,e[19]=N):N=e[19],N},px=s=>{const e=nt.c(67),{paceInfo:n,className:a,compact:r}=s,i=r===void 0?!1:r,{t:o}=it();let d;e[0]!==n.status?(d=om(n.status),e[0]=n.status,e[1]=d):d=e[1];const c=d;let f;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],f=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],f=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],f=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],f=b;break e}}f=void 0}const u=f;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 m=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 A;e[15]!==c?(A={backgroundColor:c},e[15]=c,e[16]=A):A=e[16];let $;e[17]!==u||e[18]!==A?($=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:A,title:u}),e[17]=u,e[18]=A,e[19]=$):$=e[19];let F;e[20]!==c?(F={color:c},e[20]=c,e[21]=F):F=e[21];const I=n.isExhausted?void 0:m;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:bi(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 w;e[27]!==v||e[28]!==F||e[29]!==I?(w=t.jsx("span",{className:"typography-micro tabular-nums",style:F,title:I,children:v}),e[27]=v,e[28]=F,e[29]=I,e[30]=w):w=e[30];let L;return e[31]!==w||e[32]!==b||e[33]!==$?(L=t.jsxs("div",{className:b,children:[$,w]}),e[31]=w,e[32]=b,e[33]=$,e[34]=L):L=e[34],L}let P;e[35]!==a?(P=ce("flex items-center justify-between gap-2",a),e[35]=a,e[36]=P):P=e[36];let g;e[37]!==n.isExhausted||e[38]!==n.paceRateText||e[39]!==o?(g=!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]=g):g=e[40];let h;e[41]!==g?(h=t.jsx("div",{className:"flex items-center gap-1.5",children:g}),e[41]=g,e[42]=h):h=e[42];let x;e[43]!==c?(x={color:c},e[43]=c,e[44]=x):x=e[44];let R;e[45]!==n.isExhausted||e[46]!==n.predictText||e[47]!==n.remainingSeconds||e[48]!==m||e[49]!==u||e[50]!==o?(R=n.isExhausted?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium",children:u}),t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.waitSeparator")}),t.jsx("span",{className:"font-medium",children:bi(n.remainingSeconds)})]}):t.jsxs("span",{title:m,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]=m,e[49]=u,e[50]=o,e[51]=R):R=e[51];let C;e[52]!==x||e[53]!==R?(C=t.jsx("span",{className:"typography-micro tabular-nums",style:x,children:R}),e[52]=x,e[53]=R,e[54]=C):C=e[54];let N;e[55]!==c?(N={backgroundColor:c},e[55]=c,e[56]=N):N=e[56];let T;e[57]!==u||e[58]!==N?(T=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:N,title:u}),e[57]=u,e[58]=N,e[59]=T):T=e[59];let k;e[60]!==C||e[61]!==T?(k=t.jsxs("div",{className:"flex items-center gap-1.5",children:[C,T]}),e[60]=C,e[61]=T,e[62]=k):k=e[62];let j;return e[63]!==k||e[64]!==P||e[65]!==h?(j=t.jsxs("div",{className:P,children:[h,k]}),e[63]=k,e[64]=P,e[65]=h,e[66]=j):j=e[66],j},dr=s=>{const e=nt.c(54),{title:n,window:a,subtitle:r,showToggle:i,toggleEnabled:o,onToggle:d}=s,c=i===void 0?!1:i,f=o===void 0?!1:o,u=Ut(gx),p=Ut(hx),m=ze(fx),P=u==="remaining"?a.remainingPercent:a.usedPercent,g=u==="remaining"?"remaining":"used";let h;e[0]!==P||e[1]!==a.valueLabel?(h=lm(a.valueLabel,P),e[0]=P,e[1]=a.valueLabel,e[2]=h):h=e[2];const x=h,R=a.resetAfterFormatted??a.resetAtFormatted;let C;e[3]!==R||e[4]!==m||e[5]!==a.resetAt?(C=cm(a.resetAt,R,m),e[3]=R,e[4]=m,e[5]=a.resetAt,e[6]=C):C=e[6];const N=C;let T;e[7]!==n?(T=dm(n),e[7]=n,e[8]=T):T=e[8];const k=T;let j;e[9]!==n||e[10]!==a.resetAt||e[11]!==a.usedPercent||e[12]!==a.windowSeconds?(j=mm(a.usedPercent,a.resetAt,a.windowSeconds,n),e[9]=n,e[10]=a.resetAt,e[11]=a.usedPercent,e[12]=a.windowSeconds,e[13]=j):j=e[13];const b=j;let A;e:{if(!b||b.dailyAllocationPercent===null){A=null;break e}const U=um(b.elapsedRatio);A=u==="remaining"?100-U:U}const $=A;let F;e[14]!==d||e[15]!==c||e[16]!==f?(F=c&&t.jsx(kt,{checked:f,onChange:U=>d?.(U),ariaLabel:"Show in dropdown"}),e[14]=d,e[15]=c,e[16]=f,e[17]=F):F=e[17];let I;e[18]!==k?(I=t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:k}),e[18]=k,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 w;e[22]!==I||e[23]!==v?(w=t.jsxs("div",{className:"min-w-0 flex flex-col",children:[I,v]}),e[22]=I,e[23]=v,e[24]=w):w=e[24];let L;e[25]!==w||e[26]!==F?(L=t.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[F,w]}),e[25]=w,e[26]=F,e[27]=L):L=e[27];const E=x==="-"?"":x;let _;e[28]!==E?(_=t.jsx("div",{className:"typography-ui-label text-foreground tabular-nums flex items-center justify-end",children:E}),e[28]=E,e[29]=_):_=e[29];let B;e[30]!==L||e[31]!==_?(B=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[L,_]}),e[30]=L,e[31]=_,e[32]=B):B=e[32];let Z;e[33]!==P||e[34]!==$||e[35]!==a.usedPercent?(Z=t.jsx(ux,{percent:P,tonePercent:a.usedPercent,expectedMarkerPercent:$,className:"h-1.5"}),e[33]=P,e[34]=$,e[35]=a.usedPercent,e[36]=Z):Z=e[36];const Q=N?`Resets ${N}`:"";let M;e[37]!==Q?(M=t.jsx("span",{className:"typography-micro text-muted-foreground",children:Q}),e[37]=Q,e[38]=M):M=e[38];let X;e[39]!==g?(X=t.jsx("span",{className:"typography-micro text-muted-foreground",children:g}),e[39]=g,e[40]=X):X=e[40];let ee;e[41]!==M||e[42]!==X?(ee=t.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[M,X]}),e[41]=M,e[42]=X,e[43]=ee):ee=e[43];let K;e[44]!==Z||e[45]!==ee?(K=t.jsxs("div",{className:"mt-2.5",children:[Z,ee]}),e[44]=Z,e[45]=ee,e[46]=K):K=e[46];let O;e[47]!==b||e[48]!==p?(O=b&&p&&t.jsx("div",{className:"mt-1.5",children:t.jsx(px,{paceInfo:b})}),e[47]=b,e[48]=p,e[49]=O):O=e[49];let Y;return e[50]!==B||e[51]!==K||e[52]!==O?(Y=t.jsxs("div",{className:"py-3",children:[B,K,O]}),e[50]=B,e[51]=K,e[52]=O,e[53]=Y):Y=e[53],Y};function gx(s){return s.displayMode}function hx(s){return s.showPredValues}function fx(s){return s.timeFormatPreference}const xx=(s,e)=>{if(!s)return"-";try{return El(s,e,{fallback:"-"})}catch{return"-"}},bx=()=>{const{t:s}=it(),e=ze(w=>w.timeFormatPreference),n=Ut(w=>w.results),a=Ut(w=>w.selectedProviderId),r=Ut(w=>w.setSelectedProvider),i=Ut(w=>w.loadSettings),o=Ut(w=>w.fetchAllQuotas),d=Ut(w=>w.isLoading),c=Ut(w=>w.lastUpdated),f=Ut(w=>w.error),u=Ut(w=>w.dropdownProviderIds),p=Ut(w=>w.setDropdownProviderIds),m=Ut(w=>w.selectedModels),P=Ut(w=>w.toggleModelSelected),g=Ut(w=>w.applyDefaultSelections);Hf(),l.useEffect(()=>{i(),o()},[i,o]),l.useEffect(()=>{if(a||n.length===0)return;const w=n.find(L=>L.configured)?.providerId;r(w??on[0]?.id??null)},[n,a,r]);const h=n.find(w=>w.providerId===a)??null,R=on.find(w=>w.id===a)?.name??a??s("settings.usage.sidebar.title"),C=h?.usage,N=a?u.includes(a):!1,T=l.useCallback(w=>{if(!a)return;const L=w?Array.from(new Set([...u,a])):u.filter(E=>E!==a);p(L),Pt({usageDropdownProviders:L})},[u,a,p]),k=l.useMemo(()=>C?.models?Object.entries(C.models).map(([w,L])=>({name:w,windows:L})).filter(w=>Object.keys(w.windows.windows).length>0):[],[C?.models]);l.useEffect(()=>{a&&k.length>0&&g(a,k.map(w=>w.name))},[a,k,g]);const j=l.useMemo(()=>!a||k.length===0?new Map:Bf(k,w=>w.name,a),[k,a]),b=l.useMemo(()=>{if(!a)return[];const w=$f(a);return Uf(w)},[a]),[A,$]=l.useState(()=>({})),F=l.useCallback(w=>{$(L=>({...L,[w]:!L[w]}))},[]),I=l.useCallback(w=>{if(!a)return;P(a,w);const L=m[a]??[],_=L.includes(w)?L.filter(Z=>Z!==w):[...L,w],B={...m,[a]:_};Pt({usageSelectedModels:B})},[a,m,P]),v=a?m[a]??[]:[];return a?t.jsx(Wt,{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(Tn,{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:R})}),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:xx(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":N,onClick:()=>T(!N),onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),T(!N))},children:[t.jsx(kt,{checked:N,onChange:T,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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.usage.page.options.showInHeaderTooltip")})]})]})]})}),!h&&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")})}),f&&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:f})]}),h&&!h.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")})]}),C?.windows&&Object.keys(C.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(C.windows).map(([w,L])=>t.jsx(dr,{title:w,window:L},w))})})}),k.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(w=>{const L=j.get(w.id)??[];if(L.length===0)return null;const E=A[w.id]??!1;return t.jsx("section",{className:"p-2",children:t.jsxs(xn,{open:!E,onOpenChange:()=>F(w.id),children:[t.jsxs(bn,{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:w.label}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",L.length,")"]})]}),E?t.jsx(D,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(yn,{children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:L.map(_=>{const B=Object.entries(_.windows.windows);if(B.length===0)return null;const[Z,Q]=B[0],M=v.includes(_.name);return t.jsx(dr,{title:Z,subtitle:Oo(_.name),window:Q,showToggle:!0,toggleEnabled:M,onToggle:()=>I(_.name)},_.name)})})})]})},w.id)}),(()=>{const w=j.get(null)??[];if(w.length===0)return null;const L=A.other??!1;return t.jsx("section",{className:"p-2",children:t.jsxs(xn,{open:!L,onOpenChange:()=>F("other"),children:[t.jsxs(bn,{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:["(",w.length,")"]})]}),L?t.jsx(D,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(yn,{children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:w.map(E=>{const _=Object.entries(E.windows.windows);if(_.length===0)return null;const[B,Z]=_[0],Q=v.includes(E.name);return t.jsx(dr,{title:B,subtitle:Oo(E.name),window:Z,showToggle:!0,toggleEnabled:Q,onToggle:()=>I(E.name)},E.name)})})})]})})})()]})]}),h?.configured&&C&&Object.keys(C.windows??{}).length===0&&k.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")})})},yx="git.commit.generate",Ur=ln(s=>({selectedPromptId:yx,setSelectedPromptId:e=>{s(n=>n.selectedPromptId===e?n:{selectedPromptId:e})}})),vx=s=>{const e=nt.c(23),{onItemSelect:n}=s,{t:a}=it(),r=Ur(jx),i=Ur(wx);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 f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=[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]=f):f=e[3];const u=f;let p;e[4]!==a?(p=a("settings.magicPrompts.sidebar.title"),e[4]=a,e[5]=p):p=e[5];let m;e[6]!==p?(m=t.jsx("h2",{className:"text-base font-semibold text-foreground",children:p}),e[6]=p,e[7]=m):m=e[7];let P;e[8]!==a?(P=a("settings.magicPrompts.sidebar.description"),e[8]=a,e[9]=P):P=e[9];let g;e[10]!==P?(g=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:P}),e[10]=P,e[11]=g):g=e[11];let h;e[12]!==m||e[13]!==g?(h=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[m,g]}),e[12]=m,e[13]=g,e[14]=h):h=e[14];let x;e[15]!==n||e[16]!==r||e[17]!==i||e[18]!==a?(x=t.jsx(Wt,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:u.map(C=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:a(C.groupKey)}),C.items.map(N=>{const T=r===N.id;return t.jsx("button",{type:"button",onClick:()=>{i(N.id),n?.()},className:ce("flex w-full items-center rounded-md px-2 py-1.5 text-left transition-colors",T?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-ui-label truncate font-normal",children:a(N.titleKey)})},N.id)})]},C.groupKey))}),e[15]=n,e[16]=r,e[17]=i,e[18]=a,e[19]=x):x=e[19];let R;return e[20]!==x||e[21]!==h?(R=t.jsxs("div",{className:"flex h-full flex-col bg-background",children:[h,x]}),e[20]=x,e[21]=h,e[22]=R):R=e[22],R};function jx(s){return s.selectedPromptId}function wx(s){return s.setSelectedPromptId}const Ko={"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"}]}},$o=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),mr=s=>s.endsWith(".visible"),Nx=()=>{const{t:s}=it(),e=l.useCallback(j=>s(j),[s]),n=Ur(j=>j.selectedPromptId),[a,r]=l.useState(!0),[i,o]=l.useState({}),[d,c]=l.useState({}),[f,u]=l.useState({}),[p,m]=l.useState({}),[P,g]=l.useState(!1);l.useEffect(()=>{let j=!0;return(async()=>{r(!0);try{const A=await fm();if(!j)return;o(A)}catch(A){console.warn("Failed to load magic prompts:",A),W.error(s("settings.magicPrompts.page.toast.loadFailed"))}finally{j&&r(!1)}})(),()=>{j=!1}},[s]);const h=Ko[n]??Ko["git.commit.generate"],x=l.useCallback(j=>$o(i,j)?i[j]:qa(j),[i]),R=l.useCallback(j=>d[j]??x(j),[d,x]),C=l.useCallback((j,b)=>{c(A=>A[j]===b?A:{...A,[j]:b})},[]),N=l.useCallback(async j=>{const b=R(j);if(mr(j)&&b.trim().length===0){W.error(s("settings.magicPrompts.page.toast.visiblePromptRequired"));return}u(A=>({...A,[j]:!0}));try{const A=b===qa(j)?await yi(j):await pm(j,b);o(A.overrides),W.success(s("settings.magicPrompts.page.toast.saved"))}catch(A){const $=A instanceof Error?A.message:String(A);W.error(s("settings.magicPrompts.page.toast.saveFailed"),{description:$})}finally{u(A=>({...A,[j]:!1}))}},[R,s]),T=l.useCallback(async j=>{m(b=>({...b,[j]:!0}));try{const b=await yi(j);o(b.overrides),c(A=>({...A,[j]:qa(j)})),W.success(s("settings.magicPrompts.page.toast.resetSuccess"))}catch(b){const A=b instanceof Error?b.message:String(b);W.error(s("settings.magicPrompts.page.toast.resetFailed"),{description:A})}finally{m(b=>({...b,[j]:!1}))}},[s]),k=l.useCallback(async()=>{g(!0);try{const j=await gm();o(j.overrides),c({}),W.success(s("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(j){const b=j instanceof Error?j.message:String(j);W.error(s("settings.magicPrompts.page.toast.resetAllFailed"),{description:b})}finally{g(!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(h.titleKey)}),t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:e(h.descriptionKey)})]})]})}),t.jsx(G,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{k()},disabled:P||Object.keys(i).length===0,children:s(P?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")})]}),h.blocks.map((j,b)=>{const A=hm(j.id),$=x(j.id),F=R(j.id),I=$o(i,j.id),v=F!==$,w=mr(j.id)&&F.trim().length===0,L=f[j.id]===!0,E=p[j.id]===!0;return t.jsxs("section",{"data-settings-item":mr(j.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(j.titleKey)}),t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:A.description})]})]}),A.placeholders&&A.placeholders.length>0&&t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[s("settings.magicPrompts.page.placeholdersLabel")," ",A.placeholders.map(_=>`{{${_.key}}}`).join(", ")]})]}),t.jsx(hs,{value:F,onChange:_=>C(j.id,_.target.value),className:"min-h-[220px] font-mono text-sm"}),w&&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(G,{variant:"outline",size:"sm",onClick:()=>{T(j.id)},disabled:!I||L||E,children:s(E?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),t.jsx(G,{size:"sm",onClick:()=>{N(j.id)},disabled:!v||L||E||w,children:s(L?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},j.id)})]})})},kx=s=>{const e=nt.c(89),{onItemSelect:n}=s,{t:a}=it(),[r,i]=l.useState(null),[o,d]=l.useState(null),[c,f]=l.useState(null),{selectedSnippetName:u,snippets:p,setSelectedSnippet:m,setSnippetDraft:P,deleteSnippet:g,loadSnippets:h}=Ba(Ss(Sx));let x,R;e[0]!==h?(x=()=>{h()},R=[h],e[0]=h,e[1]=x,e[2]=R):(x=e[1],R=e[2]),l.useEffect(x,R);let C;e[3]!==n||e[4]!==m||e[5]!==P||e[6]!==p?(C=async()=>{const se=new Set(p.map(Cx));let le="new-snippet",ye=1;for(;se.has(le);)le=`new-snippet-${ye++}`;P({name:le,scope:"global"}),m(le),n?.()},e[3]=n,e[4]=m,e[5]=P,e[6]=p,e[7]=C):C=e[7];const N=C;let T;e[8]!==r||e[9]!==g||e[10]!==a?(T=async()=>{if(!r)return;await g(r.name)?(W.success(a("settings.snippets.sidebar.toast.deleted")),i(null)):W.error(a("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=r,e[9]=g,e[10]=a,e[11]=T):T=e[11];const k=T;let j;e[12]!==p?(j=[...p].sort(Px),e[12]=p,e[13]=j):j=e[13];const b=j;let A;e[14]===Symbol.for("react.memo_cache_sentinel")?(A=ce("flex h-full flex-col","bg-background"),e[14]=A):A=e[14];let $;e[15]!==a?($=a("settings.snippets.sidebar.title"),e[15]=a,e[16]=$):$=e[16];let F;e[17]!==$?(F=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:$}),e[17]=$,e[18]=F):F=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 w;e[24]!==a?(w=a("settings.snippets.sidebar.actions.create"),e[24]=a,e[25]=w):w=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),e[26]=L):L=e[26];let E;e[27]!==N||e[28]!==w?(E=t.jsx(G,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:N,"aria-label":w,children:L}),e[27]=N,e[28]=w,e[29]=E):E=e[29];let _;e[30]!==v||e[31]!==E?(_=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,E]}),e[30]=v,e[31]=E,e[32]=_):_=e[32];let B;e[33]!==_||e[34]!==F?(B=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[F,_]}),e[33]=_,e[34]=F,e[35]=B):B=e[35];let Z;if(e[36]!==n||e[37]!==o||e[38]!==c||e[39]!==u||e[40]!==m||e[41]!==b||e[42]!==a){let se;e[44]!==n||e[45]!==o||e[46]!==c||e[47]!==u||e[48]!==m||e[49]!==a?(se=le=>t.jsxs(sn,{open:c===le.name,onOpenChange:ye=>f(ye?le.name:null),children:[t.jsxs(nn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",u===le.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:ye=>{ye.preventDefault(),f(le.name)}}),children:[t.jsxs("button",{onClick:()=>{m(le.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:["#",le.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.${le.source}`)})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:le.description||le.content.replace(/\s+/g," ").substring(0,80)})]}),t.jsxs(gs,{open:o===le.name,onOpenChange:ye=>{ye&&f(null),d(ye?le.name:null)},children:[t.jsx(us,{asChild:!0,children:t.jsx(G,{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:le.name}),children:t.jsx(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ps,{align:"end",className:"w-fit min-w-20",children:t.jsxs(js,{onClick:ye=>{ye.stopPropagation(),i(le)},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]})})]})]}),t.jsx(an,{className:"w-fit min-w-20",children:t.jsxs(qs,{onClick:ye=>{ye.stopPropagation(),i(le)},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]})})]},`${le.source}:${le.filePath}`),e[44]=n,e[45]=o,e[46]=c,e[47]=u,e[48]=m,e[49]=a,e[50]=se):se=e[50],Z=b.map(se),e[36]=n,e[37]=o,e[38]=c,e[39]=u,e[40]=m,e[41]=b,e[42]=a,e[43]=Z}else Z=e[43];let Q;e[51]!==Z?(Q=t.jsx(Wt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:Z}),e[51]=Z,e[52]=Q):Q=e[52];const M=r!==null;let X;e[53]===Symbol.for("react.memo_cache_sentinel")?(X=se=>{se||i(null)},e[53]=X):X=e[53];let ee;e[54]!==a?(ee=a("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=a,e[55]=ee):ee=e[55];let K;e[56]!==ee?(K=t.jsx(Kt,{children:ee}),e[56]=ee,e[57]=K):K=e[57];const O=r?.name??"";let Y;e[58]!==a||e[59]!==O?(Y=a("settings.snippets.sidebar.dialog.deleteDescription",{name:O}),e[58]=a,e[59]=O,e[60]=Y):Y=e[60];let U;e[61]!==Y?(U=t.jsx(Bt,{children:Y}),e[61]=Y,e[62]=U):U=e[62];let ne;e[63]!==K||e[64]!==U?(ne=t.jsxs($t,{children:[K,U]}),e[63]=K,e[64]=U,e[65]=ne):ne=e[65];let re;e[66]===Symbol.for("react.memo_cache_sentinel")?(re=()=>i(null),e[66]=re):re=e[66];let V;e[67]!==a?(V=a("settings.common.actions.cancel"),e[67]=a,e[68]=V):V=e[68];let oe;e[69]!==V?(oe=t.jsx(G,{size:"sm",variant:"ghost",onClick:re,children:V}),e[69]=V,e[70]=oe):oe=e[70];let fe;e[71]!==a?(fe=a("settings.common.actions.delete"),e[71]=a,e[72]=fe):fe=e[72];let xe;e[73]!==k||e[74]!==fe?(xe=t.jsx(G,{size:"sm",onClick:k,children:fe}),e[73]=k,e[74]=fe,e[75]=xe):xe=e[75];let Ie;e[76]!==oe||e[77]!==xe?(Ie=t.jsxs(Jt,{children:[oe,xe]}),e[76]=oe,e[77]=xe,e[78]=Ie):Ie=e[78];let ve;e[79]!==ne||e[80]!==Ie?(ve=t.jsxs(zt,{className:"max-w-md",children:[ne,Ie]}),e[79]=ne,e[80]=Ie,e[81]=ve):ve=e[81];let we;e[82]!==M||e[83]!==ve?(we=t.jsx(Ot,{open:M,onOpenChange:X,children:ve}),e[82]=M,e[83]=ve,e[84]=we):we=e[84];let be;return e[85]!==B||e[86]!==Q||e[87]!==we?(be=t.jsxs("div",{className:A,children:[B,Q,we]}),e[85]=B,e[86]=Q,e[87]=we,e[88]=be):be=e[88],be};function Sx(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 Px(s,e){return s.name.localeCompare(e.name)}const Ix=()=>{const{t:s}=it(),{selectedSnippetName:e,snippets:n,snippetDraft:a,setSnippetDraft:r,updateSnippet:i,createSnippet:o}=Ba(Ss(A=>({selectedSnippetName:A.selectedSnippetName,snippets:A.snippets,snippetDraft:A.snippetDraft,setSnippetDraft:A.setSnippetDraft,updateSnippet:A.updateSnippet,createSnippet:A.createSnippet}))),d=l.useMemo(()=>e?n.find(A=>A.name===e||A.aliases.includes(e))??null:null,[e,n]),c=!!(a&&a.name===e&&!d),[f,u]=l.useState(""),[p,m]=l.useState("global"),[P,g]=l.useState(""),[h,x]=l.useState(""),[R,C]=l.useState(""),[N,T]=l.useState(!1),k=l.useRef(null);l.useEffect(()=>{if(c&&a){const A={draftName:a.name||"",draftScope:a.scope||"global",description:a.description||"",aliases:(a.aliases||[]).join(", "),content:a.content||""};u(A.draftName),m(A.draftScope),g(A.description),x(A.aliases),C(A.content),k.current=A}else if(d){const A={draftName:"",draftScope:"global",description:d.description??"",aliases:d.aliases.join(", "),content:d.content};g(A.description),x(A.aliases),C(A.content),k.current=A}},[d,c,e,a]);const j=l.useMemo(()=>{const A=k.current;return A?c&&f!==A.draftName||c&&p!==A.draftScope?!0:P!==A.description||h!==A.aliases||R!==A.content:!1},[h,R,P,f,p,c]),b=async()=>{const A=c?f.trim().replace(/\s+/g,"-"):e?.trim();if(!A){W.error(s("settings.snippets.page.toast.nameRequired"));return}if(!R.trim()){W.error(s("settings.snippets.page.toast.contentRequired"));return}const $=h.split(",").map(F=>F.trim()).filter(Boolean);T(!0);try{if(!(c?await o(A,R,{aliases:$,description:P,scope:p}):await i(A,{content:R,aliases:$,description:P}))){W.error(s("settings.snippets.page.toast.saveFailed"));return}W.success(s("settings.snippets.page.toast.saved")),c&&r(null)}finally{T(!1)}};return e?t.jsx(Wt,{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(Ze,{value:f,onChange:A=>u(A.target.value),placeholder:s("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),t.jsxs(Rt,{value:p,onValueChange:A=>m(A),children:[t.jsx(Tt,{className:"w-fit min-w-[100px]",children:t.jsx(Lt,{})}),t.jsxs(Ft,{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(Ze,{value:P,onChange:A=>g(A.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(Ze,{value:h,onChange:A=>x(A.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:R,onChange:A=>C(A.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(G,{onClick:b,disabled:N||!j,size:"xs",className:"!font-normal",children:s(N?"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(D,{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")})]})})},ec=()=>{const{t:s}=it(),e=lt(p=>p.settingsGitmojiEnabled),n=lt(p=>p.setSettingsGitmojiEnabled),a=Xm(),r=ze(p=>p.gitChangesViewMode),i=ze(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 m=null;if(!m){const P=Os()?.settings;if(P)try{const h=(await P.load())?.settings;h&&(m={gitmojiEnabled:typeof h.gitmojiEnabled=="boolean"?h.gitmojiEnabled:void 0,gitChangesViewMode:h.gitChangesViewMode==="flat"||h.gitChangesViewMode==="tree"?h.gitChangesViewMode:void 0})}catch{}}if(!m){const P=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});P.ok&&(m=await P.json())}m&&(typeof m.gitmojiEnabled=="boolean"&&n(m.gitmojiEnabled),(m.gitChangesViewMode==="flat"||m.gitChangesViewMode==="tree")&&i(m.gitChangesViewMode))}catch(m){console.warn("Failed to load git settings:",m)}finally{d(!1)}})()},[i,n]);const f=l.useCallback(async p=>{n(p);try{await Pt({gitmojiEnabled:p})}catch(m){console.warn("Failed to save gitmoji setting:",m)}},[n]),u=l.useCallback(p=>{p!==r&&(i(p),Pt({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 m=r===p.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":m,onClick:()=>{u(p.id)},onKeyDown:P=>{(P.key===" "||P.key==="Enter")&&(P.preventDefault(),u(p.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(tn,{checked:m,onChange:()=>{u(p.id)},ariaLabel:s("settings.openchamber.git.optionAria",{option:p.label})}),t.jsx("span",{className:m?"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:()=>{f(!e)},onKeyDown:p=>{(p.key===" "||p.key==="Enter")&&(p.preventDefault(),f(!e))},children:[t.jsx(kt,{checked:e,onChange:p=>{f(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:()=>Ya(!a),onKeyDown:p=>{(p.key===" "||p.key==="Enter")&&(p.preventDefault(),Ya(!a))},children:[t.jsx(kt,{checked:a,onChange:Ya,ariaLabel:s("settings.openchamber.git.showGitignoredAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.git.showGitignored")})]})]})]})},tc=()=>{const{t:s}=it(),{isMobile:e}=Cs(),n=Os()?.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)},[]),[f,u]=l.useState(!1),[p,m]=l.useState(null),[P,g]=l.useState(null),h=l.useRef(null),x=l.useCallback(()=>{h.current!=null&&(window.clearInterval(h.current),h.current=null),g(null)},[]);l.useEffect(()=>((async()=>{try{i||await o(n)}catch(v){console.warn("Failed to load GitHub auth status:",v)}})(),()=>{x()}),[i,o,n,x]);const R=l.useCallback(async()=>{u(!0);try{const v=n?await n.authStart():await(async()=>{const L=await ht("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),E=await L.json().catch(()=>null);if(!L.ok||!E||!("deviceCode"in E))throw new Error(E?.error||L.statusText);return E})();m(v),g(Math.max(1,v.interval)*1e3);const w=v.verificationUriComplete||v.verificationUri;c(w)}catch(v){console.error("Failed to start GitHub connect:",v),W.error(s("settings.github.page.toast.startConnectFailed"))}finally{u(!1)}},[c,n,s]),C=l.useCallback(async v=>{if(n)return n.authComplete(v);const w=await ht("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:v})}),L=await w.json().catch(()=>null);if(!w.ok||!L)throw new Error(L?.error||w.statusText);return L},[n]);l.useEffect(()=>{if(!(!p?.deviceCode||!P)&&h.current==null)return h.current=window.setInterval(()=>{(async()=>{try{const v=await C(p.deviceCode);if(v.connected){W.success(s("settings.github.page.toast.connected")),m(null),x(),await o(n,{force:!0});return}v.status==="slow_down"&&g(w=>w?w+5e3:5e3),(v.status==="expired_token"||v.status==="access_denied")&&(W.error(v.error||s("settings.github.page.toast.authorizationFailed")),m(null),x())}catch(v){console.warn("GitHub polling failed:",v)}})()},P),()=>{h.current!=null&&(window.clearInterval(h.current),h.current=null)}},[p,P,C,o,n,x,s]);const N=l.useCallback(async v=>{u(!0);try{if(n)await n.authSetGhCliDisabled(v);else{const w=await ht("/api/github/auth/gh-cli",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({disabled:v})}),L=await w.json().catch(()=>null);if(!w.ok)throw new Error(L?.error||w.statusText)}W.success(s(v?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled")),await o(n,{force:!0})}catch(w){console.error("Failed to update gh CLI setting:",w),W.error(s("settings.github.page.toast.ghCliUpdateFailed"))}finally{u(!1)}},[o,n,s]),T=l.useCallback(async()=>{u(!0);try{if(x(),m(null),n)await n.authDisconnect();else{const v=await ht("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}});if(!v.ok)throw new Error(v.statusText)}W.success(s("settings.github.page.toast.disconnected")),await o(n,{force:!0})}catch(v){console.error("Failed to disconnect GitHub:",v),W.error(s("settings.github.page.toast.disconnectFailed"))}finally{u(!1)}},[o,n,x,s]),k=l.useCallback(async v=>{if(v){u(!0);try{const w=n?await n.authActivate(v):await(async()=>{const L=await ht("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:v})}),E=await L.json().catch(()=>null);if(!L.ok||!E)throw new Error(E?.error||L.statusText);return E})();d(w),W.success(s("settings.github.page.toast.accountSwitched"))}catch(w){console.error("Failed to switch GitHub account:",w),W.error(s("settings.github.page.toast.accountSwitchFailed"))}finally{u(!1)}}},[n,d,s]);if(r)return null;const j=!!a?.connected,b=a?.user,$=(a?.accounts??[]).filter(v=>!v.current),F=a?.ghCli??null,I=F?.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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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:[j?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(D,{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})}),F?.active&&t.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:s("settings.github.page.ghCli.activeDescription")})]})]}),F?.active?t.jsx(G,{size:"sm",variant:"outline",onClick:()=>N(!0),disabled:f,className:ce(e?"w-full":void 0),children:s("settings.github.page.ghCli.actions.disable")}):t.jsx(G,{size:"sm",variant:"outline",onClick:T,disabled:f,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(G,{size:"sm",variant:"default",onClick:R,disabled:f,children:s("settings.github.page.actions.connect")})]}),$.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:$.map(v=>{const w=v.user,L=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:[w?.avatarUrl?t.jsx("img",{src:w.avatarUrl,alt:w.login?s("settings.github.page.avatarAlt.withLogin",{login:w.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(D,{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:w?.name?.trim()||w?.login||"GitHub"}),w?.login&&t.jsxs("span",{className:"typography-micro text-muted-foreground truncate",children:[t.jsx("span",{className:"font-mono",children:w.login}),t.jsx("span",{className:"mx-1 opacity-50",children:"·"}),t.jsx("span",{children:L})]})]})]}),t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>k(v.id),disabled:f,children:s("settings.github.page.actions.switchTo")})]},v.id)})})]})]}),j&&t.jsx("div",{className:"mt-2 px-2 pb-2",children:t.jsx(G,{size:"sm",variant:"outline",onClick:R,disabled:f,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(G,{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(G,{size:"sm",variant:"ghost",disabled:f,onClick:()=>{x(),m(null)},children:s("settings.common.actions.cancel")})]})]}),F?.available&&!F?.active&&(!F.user||F.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:[F.user?.avatarUrl?t.jsx("img",{src:F.user.avatarUrl,alt:F.user.login?s("settings.github.page.avatarAlt.withLogin",{login:F.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(D,{name:"github-fill",className:"h-4 w-4 text-muted-foreground"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[!F.disabled&&F.user&&t.jsx("div",{className:"typography-ui-label text-foreground truncate",children:F.user.name?.trim()||F.user.login||"GitHub"}),!F.disabled&&F.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(D,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"font-mono",children:F.user.login}),F.user.email&&t.jsx("span",{className:"opacity-50",children:"•"}),F.user.email&&t.jsx("span",{children:F.user.email})]}),t.jsx("div",{className:ce("typography-meta text-muted-foreground",F.disabled?"opacity-60":void 0),children:F.disabled?s("settings.github.page.ghCli.disabledDescription"):s("settings.github.page.ghCli.fallbackDescription")})]})]}),t.jsx(G,{size:"sm",variant:"outline",onClick:()=>N(!F.disabled),disabled:f,className:ce(e?"w-full":void 0),children:F.disabled?s("settings.github.page.ghCli.actions.enable"):s("settings.github.page.ghCli.actions.disable")})]})})]})]})},Uo=[{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)"}],Ax=[{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"}],Dx=({open:s,onOpenChange:e,profileId:n,importData:a})=>{const{t:r}=it(),i=ks(U=>U.getProfileById),o=ks(U=>U.createProfile),d=ks(U=>U.updateProfile),c=ks(U=>U.deleteProfile),f=l.useMemo(()=>n&&n!=="new"&&!a?i(n):null,[n,i,a]),u=n==="new"||a!=null,p=n==="global",[m,P]=l.useState(""),[g,h]=l.useState(""),[x,R]=l.useState(""),[C,N]=l.useState("ssh"),[T,k]=l.useState(""),[j,b]=l.useState(!1),[A,$]=l.useState(""),[F,I]=l.useState(""),[v,w]=l.useState("keyword"),[L,E]=l.useState("branch"),[_,B]=l.useState(!1),[Z,Q]=l.useState(!1),[M,X]=l.useState(!1);l.useEffect(()=>{if(s){if(a){const U=a.host.split("/"),ne=U.length>=3?U[U.length-1]:a.host;P(ne),h(a.username),R(""),N("token"),k(""),b(!1),$(""),I(a.host),w("string"),E("code")}else if(u)P(""),h(""),R(""),N("ssh"),k(""),b(!1),$(""),I(""),w("keyword"),E("branch");else if(f)P(f.name),h(f.userName),R(f.userEmail),N(f.authType||"ssh"),k(f.sshKey||""),b(f.signCommits===!0),$(f.signingKey||""),I(f.host||""),w(f.color||"keyword"),E(f.icon||"branch");else if(p){const U=i("global");U&&(P(U.name),h(U.userName),R(U.userEmail),N(U.authType||"ssh"),k(U.sshKey||""),b(!1),$(""),I(U.host||""),w(U.color||"keyword"),E(U.icon||"branch"))}}},[s,n,f,u,a,p,i]);const ee=async()=>{if(!g.trim()||!x.trim()){W.error(r("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(C==="token"&&!F.trim()){W.error(r("settings.gitIdentities.editor.toast.hostRequiredForToken"));return}if(j&&!A.trim()){W.error(r("settings.gitIdentities.editor.toast.signingKeyRequired"));return}B(!0);try{const U={name:m.trim()||g.trim(),userName:g.trim(),userEmail:x.trim(),authType:C,sshKey:C==="ssh"&&T.trim()||null,signCommits:j,signingKey:A.trim()||null,host:C==="token"&&F.trim()||null,color:v,icon:L};let ne;if(u)ne=await o(U);else if(n)ne=await d(n,U);else return;ne?(W.success(r(u?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):W.error(r(u?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(U){console.error("Error saving profile:",U),W.error(r("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{B(!1)}},K=async()=>{if(!(!n||u)){X(!0);try{await c(n)?(W.success(r("settings.gitIdentities.editor.toast.profileDeleted")),Q(!1),e(!1)):W.error(r("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(U){console.error("Error deleting profile:",U),W.error(r("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{X(!1)}}},O=l.useMemo(()=>Uo.find(ne=>ne.key===v)?.cssVar||"var(--syntax-keyword)",[v]),Y=a?r("settings.gitIdentities.editor.title.importCredential"):u?r("settings.gitIdentities.editor.title.newIdentity"):p?r("settings.gitIdentities.editor.title.globalIdentity"):f?.name||r("settings.gitIdentities.editor.title.editIdentity");return t.jsxs(t.Fragment,{children:[t.jsx(Ot,{open:s,onOpenChange:e,children:t.jsxs(zt,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:Y}),t.jsx(Bt,{children:r(p?"settings.gitIdentities.editor.description.globalReadOnly":u?"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(Ze,{value:m,onChange:U=>P(U.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:Uo.map(U=>t.jsx("button",{type:"button",onClick:()=>w(U.key),className:ce("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",v===U.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:U.cssVar},title:U.label},U.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:Ax.map(U=>{const ne=U.Icon;return t.jsx("button",{type:"button",onClick:()=>E(U.key),className:ce("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",L===U.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:U.label,children:t.jsx(D,{name:ne,className:"w-3.5 h-3.5",style:{color:L===U.key?O:"var(--surface-muted-foreground)"}})},U.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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.userNameTooltip")})]})]}),t.jsx(Ze,{value:g,onChange:U=>h(U.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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.emailAddressTooltip")})]})]}),t.jsx(Ze,{type:"email",value:x,onChange:U=>R(U.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(G,{size:"sm",type:"button",variant:"chip","aria-pressed":C==="ssh",onClick:()=>N("ssh"),children:[t.jsx(D,{name:"lock-2",className:"w-3.5 h-3.5 mr-1"})," SSH"]}),t.jsxs(G,{size:"sm",type:"button",variant:"chip","aria-pressed":C==="token",onClick:()=>N("token"),children:[t.jsx(D,{name:"key",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.gitIdentities.editor.field.authToken")]})]})]}),C==="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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.sshKeyPathTooltip")})]})]}),t.jsx(Ze,{value:T,onChange:U=>k(U.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(kt,{checked:j,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(Ze,{value:A,onChange:U=>$(U.target.value),placeholder:r("settings.gitIdentities.editor.field.signingKeyPlaceholder"),disabled:!j,className:"h-8 font-mono text-xs"})]})]}),C==="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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.hostTooltip")})]})]}),t.jsx(Ze,{value:F,onChange:U=>I(U.target.value),placeholder:r("settings.gitIdentities.editor.field.hostPlaceholder"),required:!0,className:"h-8 font-mono text-xs"})]})]})]})]}),t.jsxs(Jt,{className:"gap-2",children:[!p&&!u&&t.jsxs(G,{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(D,{name:"delete-bin",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.common.actions.delete")]}),t.jsx(G,{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(G,{size:"sm",onClick:ee,disabled:_,children:r(_?"settings.common.actions.saving":u?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})}),t.jsx(Ot,{open:Z,onOpenChange:U=>{M||Q(U)},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:r("settings.gitIdentities.page.deleteDialog.title")}),t.jsx(Bt,{children:r("settings.gitIdentities.page.deleteDialog.description",{name:f?.name||m})})]}),t.jsxs(Jt,{children:[t.jsx(G,{variant:"ghost",onClick:()=>Q(!1),disabled:M,children:r("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",variant:"destructive",onClick:()=>{K()},disabled:M,children:r("settings.common.actions.delete")})]})]})})]})},Ex={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart"},Mx={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},Rx=()=>{const s=nt.c(118),{t:e}=it(),{profiles:n,globalIdentity:a,defaultGitIdentityId:r,deleteProfile:i,loadProfiles:o,loadGlobalIdentity:d,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:f,setDefaultGitIdentityId:u,getUnimportedCredentials:p}=ks(Ss(Fx)),[m,P]=l.useState(!1),[g,h]=l.useState(null),[x,R]=l.useState(null),[C,N]=l.useState(null),[T,k]=l.useState(!1);let j,b;s[0]!==f||s[1]!==c||s[2]!==d||s[3]!==o?(j=()=>{o(),d(),c(),f()},b=[o,d,c,f],s[0]=f,s[1]=c,s[2]=d,s[3]=o,s[4]=j,s[5]=b):(j=s[4],b=s[5]),l.useEffect(j,b);let A,$,F,I,v,w,L,E,_,B,Z,Q,M,X;if(s[6]!==r||s[7]!==C||s[8]!==i||s[9]!==p||s[10]!==a||s[11]!==n||s[12]!==u||s[13]!==e){const De=p();let Ee;s[28]===Symbol.for("react.memo_cache_sentinel")?(Ee=(je,Re)=>{h(je),R(Re??null),P(!0)},s[28]=Ee):Ee=s[28];const Pe=Ee;let Te;s[29]!==r||s[30]!==u||s[31]!==e?(Te=async je=>{const Re=r===je?null:je;if(!await u(Re)){W.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}W.success(e(Re?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},s[29]=r,s[30]=u,s[31]=e,s[32]=Te):Te=s[32];const Le=Te;let Be;s[33]!==C||s[34]!==i||s[35]!==e?(Be=async()=>{if(!C)return;k(!0),await i(C.id)?(W.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:C.name})),N(null)):W.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),k(!1)},s[33]=C,s[34]=i,s[35]=e,s[36]=Be):Be=s[36],$=Be,A=Wt,v="h-full",w="w-full bg-background",F="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(tc,{})}),s[37]=I):I=s[37],Q="git.identities",M="border-t border-border/40 pt-6";let He;s[38]!==e?(He=e("settings.gitIdentities.page.section.title"),s[38]=e,s[39]=He):He=s[39];let Ue;s[40]!==He?(Ue=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:He})}),s[40]=He,s[41]=Ue):Ue=s[41];let Je,de;s[42]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>Pe("new"),de=t.jsx(D,{name:"add",className:"w-3.5 h-3.5 mr-1"}),s[42]=Je,s[43]=de):(Je=s[42],de=s[43]);let q;s[44]!==e?(q=e("settings.common.badge.new"),s[44]=e,s[45]=q):q=s[45];let ue;s[46]!==q?(ue=t.jsxs(G,{size:"sm",variant:"outline",onClick:Je,children:[de," ",q]}),s[46]=q,s[47]=ue):ue=s[47],s[48]!==Ue||s[49]!==ue?(X=t.jsxs("div",{className:"mb-3 px-1 flex items-start justify-between gap-4",children:[Ue,ue]}),s[48]=Ue,s[49]=ue,s[50]=X):X=s[50],L="rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",E=a&&t.jsx(Bo,{profile:a,isDefault:r==="global",onEdit:()=>Pe("global"),onToggleDefault:()=>Le("global"),isReadOnly:!0,hasBorder:n.length>0||De.length>0}),_=n.map((je,Re)=>t.jsx(Bo,{profile:je,isDefault:r===je.id,onEdit:()=>Pe(je.id),onToggleDefault:()=>Le(je.id),onDelete:()=>N(je),hasBorder:Re<n.length-1||De.length>0},je.id)),B=!a&&n.length===0&&De.length===0&&t.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[t.jsx(D,{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")})]}),Z=De.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")})}),De.map((je,Re)=>t.jsx(Tx,{credential:je,onImport:()=>Pe("new",{host:je.host,username:je.username}),hasBorder:Re<De.length-1},`${je.host}-${je.username}`))]}),s[6]=r,s[7]=C,s[8]=i,s[9]=p,s[10]=a,s[11]=n,s[12]=u,s[13]=e,s[14]=A,s[15]=$,s[16]=F,s[17]=I,s[18]=v,s[19]=w,s[20]=L,s[21]=E,s[22]=_,s[23]=B,s[24]=Z,s[25]=Q,s[26]=M,s[27]=X}else A=s[14],$=s[15],F=s[16],I=s[17],v=s[18],w=s[19],L=s[20],E=s[21],_=s[22],B=s[23],Z=s[24],Q=s[25],M=s[26],X=s[27];let ee;s[51]!==L||s[52]!==E||s[53]!==_||s[54]!==B||s[55]!==Z?(ee=t.jsxs("div",{className:L,children:[E,_,B,Z]}),s[51]=L,s[52]=E,s[53]=_,s[54]=B,s[55]=Z,s[56]=ee):ee=s[56];let K;s[57]!==ee||s[58]!==Q||s[59]!==M||s[60]!==X?(K=t.jsxs("div",{"data-settings-item":Q,className:M,children:[X,ee]}),s[57]=ee,s[58]=Q,s[59]=M,s[60]=X,s[61]=K):K=s[61];let O;s[62]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(ec,{}),s[62]=O):O=s[62];let Y;s[63]!==F||s[64]!==I||s[65]!==K?(Y=t.jsxs("div",{className:F,children:[I,K,O]}),s[63]=F,s[64]=I,s[65]=K,s[66]=Y):Y=s[66];let U;s[67]!==A||s[68]!==v||s[69]!==w||s[70]!==Y?(U=t.jsx(A,{outerClassName:v,className:w,children:Y}),s[67]=A,s[68]=v,s[69]=w,s[70]=Y,s[71]=U):U=s[71];let ne;s[72]!==x||s[73]!==m||s[74]!==g?(ne=t.jsx(Dx,{open:m,onOpenChange:P,profileId:g,importData:x}),s[72]=x,s[73]=m,s[74]=g,s[75]=ne):ne=s[75];const re=C!==null;let V;s[76]!==T?(V=De=>{T||De||N(null)},s[76]=T,s[77]=V):V=s[77];let oe;s[78]!==e?(oe=e("settings.gitIdentities.page.deleteDialog.title"),s[78]=e,s[79]=oe):oe=s[79];let fe;s[80]!==oe?(fe=t.jsx(Kt,{children:oe}),s[80]=oe,s[81]=fe):fe=s[81];const xe=C?.name??"";let Ie;s[82]!==e||s[83]!==xe?(Ie=e("settings.gitIdentities.page.deleteDialog.description",{name:xe}),s[82]=e,s[83]=xe,s[84]=Ie):Ie=s[84];let ve;s[85]!==Ie?(ve=t.jsx(Bt,{children:Ie}),s[85]=Ie,s[86]=ve):ve=s[86];let we;s[87]!==fe||s[88]!==ve?(we=t.jsxs($t,{children:[fe,ve]}),s[87]=fe,s[88]=ve,s[89]=we):we=s[89];let be;s[90]===Symbol.for("react.memo_cache_sentinel")?(be=()=>N(null),s[90]=be):be=s[90];let se;s[91]!==e?(se=e("settings.common.actions.cancel"),s[91]=e,s[92]=se):se=s[92];let le;s[93]!==T||s[94]!==se?(le=t.jsx(G,{variant:"ghost",onClick:be,disabled:T,children:se}),s[93]=T,s[94]=se,s[95]=le):le=s[95];let ye;s[96]!==$?(ye=()=>{$()},s[96]=$,s[97]=ye):ye=s[97];let H;s[98]!==e?(H=e("settings.common.actions.delete"),s[98]=e,s[99]=H):H=s[99];let te;s[100]!==T||s[101]!==ye||s[102]!==H?(te=t.jsx(G,{size:"sm",variant:"destructive",onClick:ye,disabled:T,children:H}),s[100]=T,s[101]=ye,s[102]=H,s[103]=te):te=s[103];let ae;s[104]!==le||s[105]!==te?(ae=t.jsxs(Jt,{children:[le,te]}),s[104]=le,s[105]=te,s[106]=ae):ae=s[106];let me;s[107]!==we||s[108]!==ae?(me=t.jsxs(zt,{className:"max-w-md",children:[we,ae]}),s[107]=we,s[108]=ae,s[109]=me):me=s[109];let Me;s[110]!==re||s[111]!==V||s[112]!==me?(Me=t.jsx(Ot,{open:re,onOpenChange:V,children:me}),s[110]=re,s[111]=V,s[112]=me,s[113]=Me):Me=s[113];let Ne;return s[114]!==U||s[115]!==ne||s[116]!==Me?(Ne=t.jsxs(t.Fragment,{children:[U,ne,Me]}),s[114]=U,s[115]=ne,s[116]=Me,s[117]=Ne):Ne=s[117],Ne},Bo=s=>{const e=nt.c(56),{profile:n,isDefault:a,onEdit:r,onToggleDefault:i,onDelete:o,isReadOnly:d,hasBorder:c}=s,{t:f}=it(),[u,p]=l.useState(!1),m=Ex[n.icon||"branch"]||"git-branch",P=Mx[n.color||""],g=n.authType||"ssh";let h;e[0]!==r?(h=K=>{K.currentTarget===K.target&&(K.key!=="Enter"&&K.key!==" "||(K.preventDefault(),r()))},e[0]=r,e[1]=h):h=e[1];const x=h;let R;e[2]!==a||e[3]!==d||e[4]!==o||e[5]!==i||e[6]!==f?(R=K=>t.jsxs(t.Fragment,{children:[t.jsx(K,{onClick:O=>{O.stopPropagation(),i()},children:f(a?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!d&&o&&t.jsxs(K,{onClick:O=>{O.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[t.jsx(D,{name:"delete-bin",className:"h-4 w-4 mr-px"}),f("settings.common.actions.delete")]})]}),e[2]=a,e[3]=d,e[4]=o,e[5]=i,e[6]=f,e[7]=R):R=e[7];const C=R,N=c&&"border-b border-[var(--surface-subtle)]";let T;e[8]!==N?(T=ce("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",N),e[8]=N,e[9]=T):T=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=K=>{K.preventDefault(),p(!0)},e[10]=k):k=e[10];let j;e[11]!==x||e[12]!==r||e[13]!==T?(j=t.jsx("div",{className:T,onClick:r,role:"button",tabIndex:0,onKeyDown:x,onContextMenu:k}),e[11]=x,e[12]=r,e[13]=T,e[14]=j):j=e[14];let b;e[15]!==P?(b={color:P},e[15]=P,e[16]=b):b=e[16];let A;e[17]!==m||e[18]!==b?(A=t.jsx(D,{name:m,className:"w-4 h-4 shrink-0",style:b}),e[17]=m,e[18]=b,e[19]=A):A=e[19];let $;e[20]!==n.name?($=t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:n.name}),e[20]=n.name,e[21]=$):$=e[21];let F;e[22]!==g?(F=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:g}),e[22]=g,e[23]=F):F=e[23];let I;e[24]!==a||e[25]!==f?(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:f("settings.gitIdentities.page.badge.default")}),e[24]=a,e[25]=f,e[26]=I):I=e[26];let v;e[27]!==d||e[28]!==f?(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:f("settings.agents.sidebar.badge.system")}),e[27]=d,e[28]=f,e[29]=v):v=e[29];let w;e[30]!==F||e[31]!==I||e[32]!==v||e[33]!==$?(w=t.jsxs("div",{className:"flex items-center gap-1.5",children:[$,F,I,v]}),e[30]=F,e[31]=I,e[32]=v,e[33]=$,e[34]=w):w=e[34];const L=g==="token"&&n.host?n.host:n.userEmail;let E;e[35]!==L?(E=t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:L}),e[35]=L,e[36]=E):E=e[36];let _;e[37]!==w||e[38]!==E?(_=t.jsxs("div",{className:"min-w-0",children:[w,E]}),e[37]=w,e[38]=E,e[39]=_):_=e[39];let B;e[40]!==_||e[41]!==A?(B=t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[A,_]}),e[40]=_,e[41]=A,e[42]=B):B=e[42];let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(us,{asChild:!0,children:t.jsx(G,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:Lx,children:t.jsx(D,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[43]=Z):Z=e[43];let Q;e[44]!==C?(Q=t.jsxs(gs,{children:[Z,t.jsx(ps,{align:"end",className:"w-fit min-w-28",children:C(js)})]}),e[44]=C,e[45]=Q):Q=e[45];let M;e[46]!==B||e[47]!==Q||e[48]!==j?(M=t.jsxs(nn,{render:j,children:[B,Q]}),e[46]=B,e[47]=Q,e[48]=j,e[49]=M):M=e[49];let X;e[50]!==C?(X=t.jsx(an,{className:"w-fit min-w-28",children:C(qs)}),e[50]=C,e[51]=X):X=e[51];let ee;return e[52]!==u||e[53]!==M||e[54]!==X?(ee=t.jsxs(sn,{open:u,onOpenChange:p,children:[M,X]}),e[52]=u,e[53]=M,e[54]=X,e[55]=ee):ee=e[55],ee},Tx=s=>{const e=nt.c(21),{credential:n,onImport:a,hasBorder:r}=s,{t:i}=it();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,f=n.host.includes("/"),u=r&&"border-b border-[var(--surface-subtle)]";let p;e[2]!==u?(p=ce("flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30",u),e[2]=u,e[3]=p):p=e[3];let m;e[4]!==c?(m=t.jsx("span",{className:"typography-ui-label text-foreground truncate block",children:c}),e[4]=c,e[5]=m):m=e[5];const P=f?n.host:n.username;let g;e[6]!==P?(g=t.jsx("span",{className:"typography-micro text-muted-foreground/60 truncate block leading-tight",children:P}),e[6]=P,e[7]=g):g=e[7];let h;e[8]!==m||e[9]!==g?(h=t.jsxs("div",{className:"min-w-0",children:[m,g]}),e[8]=m,e[9]=g,e[10]=h):h=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(D,{name:"download",className:"h-3 w-3"}),e[11]=x):x=e[11];let R;e[12]!==i?(R=i("settings.gitIdentities.page.actions.import"),e[12]=i,e[13]=R):R=e[13];let C;e[14]!==a||e[15]!==R?(C=t.jsxs(G,{size:"sm",variant:"ghost",onClick:a,className:"gap-1 shrink-0",children:[x,R]}),e[14]=a,e[15]=R,e[16]=C):C=e[16];let N;return e[17]!==C||e[18]!==p||e[19]!==h?(N=t.jsxs("div",{className:p,children:[h,C]}),e[17]=C,e[18]=p,e[19]=h,e[20]=N):N=e[20],N};function Fx(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 Lx(s){return s.stopPropagation()}const sc=()=>{const s=xm();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},Ox=()=>{const s=nt.c(2),[e,n]=l.useState(zx);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(sc())};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 zx(){return sc()}const Kx=[{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"}],$x=[{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"}],Ux=[{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"}],Gn="OpenChamber - AI Coding Assistant",Vo=[{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"}],_o=[{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"}],Bx=[{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",Vx=[{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"}],_x=[{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"}],Ho=[{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"}],Hx=[{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"}],Wo=[{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"}],qo=[{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"}],Wx=[{id:"steer",labelKey:"settings.openchamber.visual.option.followUpBehavior.steer.label"},{id:"queue",labelKey:"settings.openchamber.visual.option.followUpBehavior.queue.label"}],qx=s=>s==="markdown"?"markdown":"plain",ei=({visibleSettings:s})=>{const{locale:e,locales:n,setLocale:a,label:r,t:i}=it(),o=l.useCallback(S=>i(S),[i]),{isMobile:d}=Cs(),{browserTab:c}=Ox(),f=Zm(),u=ze(S=>S.showReasoningTraces),p=ze(S=>S.setShowReasoningTraces),m=ze(S=>S.collapsibleThinkingBlocks),P=ze(S=>S.setCollapsibleThinkingBlocks),g=ze(S=>S.mermaidRenderingMode),h=ze(S=>S.setMermaidRenderingMode),x=ze(S=>S.userMessageRenderingMode),R=ze(S=>S.setUserMessageRenderingMode),C=ze(S=>S.collapsibleUserMessages),N=ze(S=>S.setCollapsibleUserMessages),T=ze(S=>S.stickyUserHeader),k=ze(S=>S.setStickyUserHeader),j=ze(S=>S.expandedEditorToolbar),b=ze(S=>S.setExpandedEditorToolbar),A=ze(S=>S.wideChatLayoutEnabled),$=ze(S=>S.setWideChatLayoutEnabled),F=ze(S=>S.chatRenderMode),I=ze(S=>S.setChatRenderMode),v=ze(S=>S.activityRenderMode),w=ze(S=>S.setActivityRenderMode),L=ze(S=>S.fontSize),E=ze(S=>S.setFontSize),_=ze(S=>S.terminalFontSize),B=ze(S=>S.setTerminalFontSize),Z=ze(S=>S.uiFont),Q=ze(S=>S.setUiFont),M=ze(S=>S.monoFont),X=ze(S=>S.setMonoFont),ee=ze(S=>S.padding),K=ze(S=>S.setPadding),O=ze(S=>S.inputBarOffset),Y=ze(S=>S.setInputBarOffset),U=ze(S=>S.mobileKeyboardMode),ne=ze(S=>S.setMobileKeyboardMode),re=ze(S=>S.diffLayoutPreference),V=ze(S=>S.setDiffLayoutPreference),oe=ze(S=>S.showTerminalQuickKeysOnDesktop),fe=ze(S=>S.setShowTerminalQuickKeysOnDesktop),xe=ze(S=>S.fileEditorKeymap),Ie=ze(S=>S.setFileEditorKeymap),ve=Pi(S=>S.followUpBehavior),we=Pi(S=>S.setFollowUpBehavior),be=ze(S=>S.persistChatDraft),se=ze(S=>S.setPersistChatDraft),le=ze(S=>S.inputSpellcheckEnabled),ye=ze(S=>S.setInputSpellcheckEnabled),H=ze(S=>S.showToolFileIcons),te=ze(S=>S.setShowToolFileIcons),ae=ze(S=>S.showTurnChangedFiles),me=ze(S=>S.setShowTurnChangedFiles),Me=ze(S=>S.showExpandedBashTools),Ne=ze(S=>S.setShowExpandedBashTools),De=ze(S=>S.showExpandedEditTools),Ee=ze(S=>S.setShowExpandedEditTools),Pe=ze(S=>S.timeFormatPreference),Te=ze(S=>S.setTimeFormatPreference),Le=ze(S=>S.weekStartPreference),Be=ze(S=>S.setWeekStartPreference),He=ze(S=>S.showSplitAssistantMessageActions),Ue=ze(S=>S.setShowSplitAssistantMessageActions),Je=lt(S=>S.settingsMessageStreamTransport),de=lt(S=>S.setSettingsMessageStreamTransport),q=Je,ue=lt(S=>S.settingsDefaultFileViewerPreview),je=lt(S=>S.setSettingsDefaultFileViewerPreview),Re=ze(S=>S.isSettingsDialogOpen),{themeMode:Ce,setThemeMode:_e,availableThemes:J,customThemesLoading:y,reloadCustomThemes:pe,lightThemeId:Ae,darkThemeId:Oe,setLightThemePreference:qe,setDarkThemePreference:at}=Ua(),[rt,st]=l.useState(!1),dt=l.useMemo(()=>is()&&typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.macVibrancySupported===!0,[]),Ye=typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.macVibrancy===!0,[$e,mt]=l.useState(Ye),[ge,et]=l.useState(!1),tt=l.useMemo(()=>is()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),We=ze(S=>S.dockBadgeEnabled),xt=ze(S=>S.setDockBadgeEnabled),[wt,St]=l.useState(0),ie=ze(S=>S.reportUsage),Ve=ze(S=>S.setReportUsage),Qe=l.useCallback(S=>{Ve(S),Pt({reportUsage:S})},[Ve]),Ge=Re&&(s?s.includes("chatRenderMode"):!0);l.useEffect(()=>{if(!Ge)return;let S=null,ot=Date.now();const Mt=()=>{const As=Date.now();As-ot>=420&&(St(Ks=>(Ks+1)%24),ot=As),S=requestAnimationFrame(Mt)};(typeof document>"u"||document.visibilityState==="visible")&&(S=requestAnimationFrame(Mt));const ss=()=>{document.visibilityState==="visible"&&S===null?S=requestAnimationFrame(Mt):document.visibilityState!=="visible"&&S!==null&&(cancelAnimationFrame(S),S=null)};return document.addEventListener("visibilitychange",ss),()=>{document.removeEventListener("visibilitychange",ss),S!==null&&cancelAnimationFrame(S)}},[Ge]);const ut=l.useCallback(S=>{R(S),Pt({userMessageRenderingMode:S})},[R]),bt=l.useCallback(S=>{k(S),Pt({stickyUserHeader:S})},[k]),pt=l.useCallback(S=>{b(S),Pt({expandedEditorToolbar:S})},[b]),Dt=l.useCallback(S=>{N(S),Pt({collapsibleUserMessages:S})},[N]),qt=l.useCallback(S=>{$(S),Pt({wideChatLayoutEnabled:S})},[$]),Yt=l.useCallback(S=>{Ue(S),Pt({showSplitAssistantMessageActions:S})},[Ue]),Zt=l.useCallback(S=>{ye(S),Pt({inputSpellcheckEnabled:S})},[ye]),as=l.useCallback(S=>{I(S),Pt({chatRenderMode:S})},[I]),Ht=l.useCallback(S=>{de(S),Pt({messageStreamTransport:S})},[de]),es=l.useCallback(S=>{w(S),Pt({activityRenderMode:S})},[w]),Se=l.useCallback(S=>{h(S),Pt({mermaidRenderingMode:S})},[h]),yt=l.useCallback(S=>{te(S),Pt({showToolFileIcons:S})},[te]),jt=l.useCallback(S=>{me(S),Pt({showTurnChangedFiles:S})},[me]),Xe=l.useCallback(S=>{je(S),Pt({defaultFileViewerPreview:S}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:S}}))},[je]),Nt=l.useCallback(S=>{Ne(S),Pt({showExpandedBashTools:S})},[Ne]),Vt=l.useCallback(S=>{Ee(S),Pt({showExpandedEditTools:S})},[Ee]),Qt=l.useCallback(S=>{Te(S),Pt({timeFormatPreference:S})},[Te]),rs=l.useCallback(S=>{Be(S),Pt({weekStartPreference:S})},[Be]),Rs=l.useMemo(()=>J.filter(S=>S.metadata.variant==="light").sort((S,ot)=>S.metadata.name.localeCompare(ot.metadata.name)),[J]),cs=l.useMemo(()=>J.filter(S=>S.metadata.variant==="dark").sort((S,ot)=>S.metadata.name.localeCompare(ot.metadata.name)),[J]),Is=l.useMemo(()=>Rs.find(S=>S.metadata.id===Ae)??Rs[0],[Rs,Ae]),Ps=l.useMemo(()=>cs.find(S=>S.metadata.id===Oe)??cs[0],[cs,Oe]),ct=l.useCallback((S,ot)=>{const Mt=ot==="dark"?" Dark":" Light";return S.endsWith(Mt)?S.slice(0,-Mt.length):S},[]),ke=S=>s?s.includes(S):!0,Ct=fs(),Xt=ke("theme")&&!Ct,Gt=ke("theme")||ke("timeFormat")||ke("weekStart"),wn=d&&gn()&&!is()&&!Ct,cn=Ct?Gt:ke("theme")||wn||ke("pwaInstallName")||ke("pwaOrientation")||ke("timeFormat")||ke("weekStart"),Gs=ke("fontSize")||ke("terminalFontSize")||ke("spacing")||ke("inputBarOffset"),Nn=ke("terminalQuickKeys")&&!d||ke("fileEditorKeymap")||ke("expandedEditorToolbar"),Va=ke("mermaidRendering")||ke("userMessageRendering")||ke("chatRenderMode")||ke("messageTransport")||ke("activityRenderMode")&&F==="sorted"||ke("collapsibleUserMessages")||ke("stickyUserHeader")||ke("wideChatLayout")||ke("splitAssistantMessageActions")||ke("diffLayout")||ke("dotfiles")||ke("fileViewerPreview")||ke("reasoning")||ke("followUpBehavior")||ke("persistDraft")||ke("showToolFileIcons")||ke("expandedTools")||!d&&ke("inputSpellcheck"),Es=ke("pwaInstallName")&&gn()&&c&&!is()&&!Ct,Js=ke("pwaOrientation")&&gn()&&!is()&&!Ct,Qs=ke("mobileKeyboardMode")&&gn()&&!is()&&!Ct&&eu(),[$n,_a]=l.useState(()=>uu()),[Un,zs]=l.useState(""),[kn,Ys]=l.useState("system"),na=l.useMemo(()=>{const S=Wo.find(ot=>ot.id===Pe);return o(S?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[Pe,o]),Ha=l.useMemo(()=>{const S=qo.find(ot=>ot.id===Le);return o(S?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[Le,o]),z=l.useMemo(()=>{const S=Vo.find(ot=>ot.id===kn);return S?o(S.labelKey):void 0},[kn,o]),Ke=l.useMemo(()=>{const S=_o.find(ot=>ot.id===U);return S?o(S.labelKey):void 0},[U,o]),ft=l.useCallback(S=>{S!==$n&&(_a(S),pu(S),window.location.reload())},[$n]),vt=l.useCallback(async S=>{if(typeof window>"u")return;const ot=window,ss=S.trim().replace(/\s+/g," ").slice(0,64);if(await Pt({pwaAppName:ss}),typeof ot.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const As=ot.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(ss);zs(As);return}zs(ss||Gn),ot.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),ts=l.useCallback(async S=>{if(typeof window>"u")return;const ot=window,Mt=ur(S);if(await Pt({pwaOrientation:Mt}),typeof ot.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const ss=ot.__OPENCHAMBER_SET_PWA_ORIENTATION__(Mt);Ys(ss);return}Ys(Mt),ot.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return l.useEffect(()=>{if(typeof window>"u"||!Es&&!Js&&!Qs)return;let S=!1;return(async()=>{try{const Mt=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!Mt.ok){S||zs(Gn);return}const ss=await Mt.json().catch(()=>({})),Ks=(typeof ss?.pwaAppName=="string"?ss.pwaAppName:"").trim().replace(/\s+/g," ").slice(0,64),dn=ur(ss?.pwaOrientation),Bn=Mi(ss?.mobileKeyboardMode);S||(Es&&zs(Ks||Gn),Js&&Ys(dn),Qs&&ne(Bn))}catch{S||(Es&&zs(Gn),Js&&Ys("system"),Qs&&ne("native"))}})(),()=>{S=!0}},[ne,Qs,Es,Js]),t.jsxs("div",{className:"space-y-8",children:[cn&&t.jsxs("div",{className:"mb-8 space-y-6",children:[Xt&&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:Kx.map(S=>t.jsx(G,{variant:"chip",size:"xs","aria-pressed":Ce===S.value,className:"!font-normal",onClick:()=>_e(S.value),children:o(S.labelKey)},S.value))})]}),wn&&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:Bx.map(S=>t.jsx(G,{variant:"chip",size:"xs","aria-pressed":$n===S.value,className:"!font-normal",onClick:()=>ft(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(Rt,{value:Is?.metadata.id??"",onValueChange:qe,children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.selectLightThemeAria"),className:"w-fit",children:t.jsx(Lt,{placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),children:Is?ct(Is.metadata.name,"light"):void 0})}),t.jsx(Ft,{children:Rs.map(S=>t.jsx(gt,{value:S.metadata.id,children:ct(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(Rt,{value:Ps?.metadata.id??"",onValueChange:at,children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.selectDarkThemeAria"),className:"w-fit",children:t.jsx(Lt,{placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),children:Ps?ct(Ps.metadata.name,"dark"):void 0})}),t.jsx(Ft,{children:cs.map(S=>t.jsx(gt,{value:S.metadata.id,children:ct(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:y||rt,onClick:()=>{const S=Date.now();st(!0),pe().finally(()=>{const ot=Date.now()-S;if(ot<500){window.setTimeout(()=>{st(!1)},500-ot);return}st(!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(rt?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")}),t.jsxs(It,{children:[t.jsx(At,{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(D,{name:"information",className:"h-3.5 w-3.5"})})}),t.jsx(Et,{sideOffset:8,children:i("settings.openchamber.visual.field.themeImportInfoTooltip")})]})]}),dt&&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":$e,onClick:()=>{ge||mt(!$e)},onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),ge||mt(!$e))},children:[t.jsx(kt,{checked:$e,onChange:mt,disabled:ge,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")})]})]}),$e!==Ye&&t.jsx("div",{className:"pl-6",children:t.jsx(G,{variant:"outline",size:"sm",disabled:ge,onClick:()=>{et(!0),tu("desktop_set_vibrancy",{enabled:$e})},children:i(ge?"settings.openchamber.visual.actions.restarting":"settings.openchamber.visual.actions.saveAndRestart")})})]}),tt&&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":We,onClick:()=>xt(!We),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),xt(!We))},children:[t.jsx(kt,{checked:We,onChange:xt,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")})]})]})})]}),Gt&&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(Rt,{value:e,onValueChange:S=>a(S),children:[t.jsx(Tt,{"aria-label":i("settings.appearance.language.select"),className:"w-fit",children:t.jsx(Lt,{children:r(e)})}),t.jsx(Ft,{children:n.map(S=>t.jsx(gt,{value:S,children:r(S)},S))})]})]}),(ke("timeFormat")||ke("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:[ke("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(Rt,{value:Pe,onValueChange:S=>Qt(S),children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.selectTimeFormatAria"),className:"w-fit",children:t.jsx(Lt,{children:na})}),t.jsx(Ft,{children:Wo.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]})]}),ke("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(Rt,{value:Le,onValueChange:S=>rs(S),children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.selectWeekStartAria"),className:"w-fit",children:t.jsx(Lt,{children:Ha})}),t.jsx(Ft,{children:qo.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]})]})]})]}),(Es||Js||Qs)&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[Es&&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(Ze,{value:Un,onChange:S=>{zs(S.target.value)},onBlur:()=>{vt(Un)},onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),vt(Un))},className:"h-7",maxLength:64,"aria-label":i("settings.openchamber.visual.field.pwaInstallAppNameAria")}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{zs(Gn),vt("")},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(D,{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(Rt,{value:kn,onValueChange:S=>{const ot=ur(S);Ys(ot),ts(ot)},children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.pwaInstallOrientationAria"),className:"w-full",children:t.jsx(Lt,{placeholder:i("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:z})}),t.jsx(Ft,{children:Vo.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Ys("system"),ts("system")},disabled:kn==="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(D,{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(Rt,{value:U,onValueChange:S=>{const ot=Mi(S);ne(ot),Pt({mobileKeyboardMode:ot})},children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.mobileKeyboardModeAria"),className:"w-full",children:t.jsx(Lt,{placeholder:i("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:Ke})}),t.jsx(Ft,{children:_o.map(S=>t.jsx(gt,{value:S.id,children:o(S.labelKey)},S.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{ne("native"),Pt({mobileKeyboardMode:"native"})},disabled:U==="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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]})]}),Gs&&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:[ke("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(Rt,{value:Z,onValueChange:S=>Q(S),children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.selectInterfaceFontAria"),className:"w-[13rem]",children:t.jsx(Lt,{children:Ii.find(S=>S.id===Z)?.label})}),t.jsx(Ft,{children:Ii.map(S=>t.jsx(gt,{value:S.id,children:t.jsx("span",{style:{fontFamily:S.stack},children:S.label})},S.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>Q(Ai),disabled:Z===Ai,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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),ke("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(Rt,{value:M,onValueChange:S=>X(S),children:[t.jsx(Tt,{"aria-label":i("settings.openchamber.visual.field.selectCodeFontAria"),className:"w-[13rem]",children:t.jsx(Lt,{children:Di.find(S=>S.id===M)?.label})}),t.jsx(Ft,{children:Di.map(S=>t.jsx(gt,{value:S.id,children:t.jsx("span",{style:{fontFamily:S.stack},children:S.label})},S.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>X(Ei),disabled:M===Ei,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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),ke("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(vs,{value:L,onValueChange:E,min:50,max:200,step:5,"aria-label":i("settings.openchamber.visual.field.fontSizePercentageAria"),className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>E(100),disabled:L===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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),ke("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(vs,{value:_,onValueChange:B,min:9,max:52,step:1,className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>B(13),disabled:_===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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),ke("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(vs,{value:ee,onValueChange:K,min:50,max:200,step:5,className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>K(100),disabled:ee===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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),ke("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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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(vs,{value:O,onValueChange:Y,min:0,max:100,step:5,className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>Y(0),disabled:O===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(D,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]})]})}),Nn&&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")}),ke("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 ot=xe===S,Mt=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":ot,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",ot?"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",!ot&&"opacity-0")})}),t.jsx("span",{className:ce("typography-ui-label font-normal",ot?"text-foreground":"text-foreground/50"),children:Mt})]},S)})})]}),ke("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":j,onClick:()=>pt(!j),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),pt(!j))},children:[t.jsx(kt,{checked:j,onChange:pt,ariaLabel:i("settings.openchamber.visual.field.expandedEditorToolbarAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.expandedEditorToolbar")})]}),ke("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":oe,onClick:()=>fe(!oe),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),fe(!oe))},children:[t.jsx(kt,{checked:oe,onChange:fe,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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.terminalQuickKeysTooltip")})]})]})]})]})}),Va&&t.jsxs("div",{className:"space-y-3",children:[(ke("userMessageRendering")||ke("mermaidRendering")||ke("chatRenderMode")||ke("messageTransport")||ke("activityRenderMode")&&F==="sorted"||ke("diffLayout")&&!Ct||ke("followUpBehavior"))&&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:[ke("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:_x.map(S=>{const ot=F===S.id,Mt=wt%12;return t.jsxs("button",{type:"button",onClick:()=>as(S.id),"aria-pressed":ot,className:ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",ot?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsx("span",{className:ce("typography-ui-label",ot?"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(ss=>{const As=ss*3+1,Ks=Mt-As+1,dn=Ks<=0?0:Ks===1?42:Ks===2?68:92,Bn=dn>0;return t.jsxs("div",{className:ce("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",Bn?"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:`${dn}%`}})]},ss)})}):t.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(ss=>{const As=Mt>=(ss+1)*3;return t.jsxs("div",{className:ce("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",As?"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%"}})]},ss)})})})]},S.id)})})]}),ke("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:Ho.map(S=>t.jsx(G,{variant:"chip",size:"xs","aria-pressed":q===S.id,className:"!font-normal",onClick:()=>Ht(S.id),children:o(S.labelKey)},S.id))}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:(()=>{const S=Ho.find(ot=>ot.id===q);return S?.descriptionKey?o(S.descriptionKey):""})()})]})]}),ke("activityRenderMode")&&F==="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:Hx.map(S=>{const ot=v===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":ot,onClick:()=>es(S.id),onKeyDown:Mt=>{(Mt.key===" "||Mt.key==="Enter")&&(Mt.preventDefault(),es(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(tn,{checked:ot,onChange:()=>es(S.id),ariaLabel:i("settings.openchamber.visual.field.activityDefaultModeAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",ot?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),ke("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:()=>Nt(!Me),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Nt(!Me))},children:[t.jsx(kt,{checked:Me,onChange:Nt,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":De,onClick:()=>Vt(!De),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Vt(!De))},children:[t.jsx(kt,{checked:De,onChange:Vt,ariaLabel:i("settings.openchamber.visual.field.showExpandedEditToolsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.editTools")})]})]}),ke("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:Vx.map(S=>{const ot=qx(x)===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":ot,onClick:()=>ut(S.id),onKeyDown:Mt=>{(Mt.key===" "||Mt.key==="Enter")&&(Mt.preventDefault(),ut(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(tn,{checked:ot,onChange:()=>ut(S.id),ariaLabel:i("settings.openchamber.visual.field.userMessageRenderingAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",ot?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),ke("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:Ux.map(S=>{const ot=g===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":ot,onClick:()=>Se(S.id),onKeyDown:Mt=>{(Mt.key===" "||Mt.key==="Enter")&&(Mt.preventDefault(),Se(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(tn,{checked:ot,onChange:()=>Se(S.id),ariaLabel:i("settings.openchamber.visual.field.mermaidRenderingAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",ot?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),ke("diffLayout")&&!Ct&&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:$x.map(S=>{const ot=re===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":ot,onClick:()=>V(S.id),onKeyDown:Mt=>{(Mt.key===" "||Mt.key==="Enter")&&(Mt.preventDefault(),V(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(tn,{checked:ot,onChange:()=>V(S.id),ariaLabel:i("settings.openchamber.visual.field.diffLayoutAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",ot?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]}),ke("followUpBehavior")&&t.jsxs("section",{"data-settings-item":"chat.follow-up-behavior",className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.followUpBehavior")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.followUpBehaviorAria"),className:"mt-0.5 space-y-0",children:Wx.map(S=>{const ot=ve===S.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":ot,onClick:()=>we(S.id),onKeyDown:Mt=>{(Mt.key===" "||Mt.key==="Enter")&&(Mt.preventDefault(),we(S.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(tn,{checked:ot,onChange:()=>we(S.id),ariaLabel:i("settings.openchamber.visual.field.followUpBehaviorAria",{option:o(S.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",ot?"text-foreground":"text-foreground/50"),children:o(S.labelKey)})]},S.id)})})]})]}),(ke("collapsibleUserMessages")||ke("stickyUserHeader")||ke("wideChatLayout")||ke("splitAssistantMessageActions")||ke("dotfiles")||ke("fileViewerPreview")||ke("persistDraft")||ke("showToolFileIcons")||ke("showTurnChangedFiles")||!d&&ke("inputSpellcheck")||ke("reasoning"))&&t.jsxs("section",{className:"p-2 space-y-0.5",children:[ke("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":u,onClick:()=>p(!u),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),p(!u))},children:[t.jsx(kt,{checked:u,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")})]}),ke("reasoning")&&u&&t.jsxs("div",{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(kt,{checked:m,onChange:P,ariaLabel:i("settings.openchamber.visual.field.collapsibleThinkingBlocksAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.collapsibleThinkingBlocks")})]}),ke("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":C,onClick:()=>Dt(!C),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Dt(!C))},children:[t.jsx(kt,{checked:C,onChange:Dt,ariaLabel:i("settings.openchamber.visual.field.collapsibleUserMessagesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.collapsibleUserMessages")})]}),ke("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":T,onClick:()=>bt(!T),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),bt(!T))},children:[t.jsx(kt,{checked:T,onChange:bt,ariaLabel:i("settings.openchamber.visual.field.stickyUserHeaderAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.stickyUserHeader")})]}),ke("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":A,onClick:()=>qt(!A),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),qt(!A))},children:[t.jsx(kt,{checked:A,onChange:qt,ariaLabel:i("settings.openchamber.visual.field.wideChatLayoutAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.wideChatLayout")})]}),ke("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":He,onClick:()=>Yt(!He),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Yt(!He))},children:[t.jsx(kt,{checked:He,onChange:Yt,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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 cursor-help text-muted-foreground/60"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip")})]})]})]}),ke("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":H,onClick:()=>yt(!H),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),yt(!H))},children:[t.jsx(kt,{checked:H,onChange:yt,ariaLabel:i("settings.openchamber.visual.field.showToolFileIconsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showToolFileIcons")})]}),ke("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":ae,onClick:()=>jt(!ae),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),jt(!ae))},children:[t.jsx(kt,{checked:ae,onChange:jt,ariaLabel:i("settings.openchamber.visual.field.showTurnChangedFilesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showTurnChangedFiles")})]}),ke("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":f,onClick:()=>Xa(!f),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Xa(!f))},children:[t.jsx(kt,{checked:f,onChange:Xa,ariaLabel:i("settings.openchamber.visual.field.showDotfilesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showDotfiles")})]}),ke("fileViewerPreview")&&t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":ue,onClick:()=>Xe(!ue),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Xe(!ue))},children:[t.jsx("span",{onClick:S=>S.stopPropagation(),children:t.jsx(kt,{checked:ue,onChange:Xe,ariaLabel:i("settings.openchamber.defaults.field.openFilesPreviewAria")})}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.defaults.field.openFilesPreview")})]}),ke("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":be,onClick:()=>se(!be),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),se(!be))},children:[t.jsx(kt,{checked:be,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&&ke("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":le,onClick:()=>Zt(!le),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Zt(!le))},children:[t.jsx(kt,{checked:le,onChange:Zt,ariaLabel:i("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.enableSpellcheckInTextInputs")})]})]})]}),ke("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(kt,{checked:ie,onChange:Qe,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":ie,onClick:()=>Qe(!ie),onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),Qe(!ie))},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")})]})]})]})})]})},Gx=1,Jx=365,Go=30,Qx=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],nc=()=>{const s=nt.c(113),{t:e}=it(),n=ze(Yx),a=ze(Xx),r=ze(Zx),i=ze(eb),o=ze(tb),d=ze(sb);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={autoRun:!1},s[0]=c):c=s[0];const{candidates:f,isRunning:u,runCleanup:p,action:m}=bm(c),P=f.length;let g;s[1]!==p||s[2]!==e?(g=async()=>{const ae=await p({force:!0});if(ae.completedIds.length===0&&ae.failedIds.length===0){W.message(ae.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}ae.completedIds.length>0&&W.success(ae.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:ae.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:ae.completedIds.length})),ae.failedIds.length>0&&W.error(ae.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:ae.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:ae.failedIds.length}))},s[1]=p,s[2]=e,s[3]=g):g=s[3];const h=g;let x;s[4]!==e?(x=e("settings.openchamber.sessionRetention.title"),s[4]=e,s[5]=x):x=s[5];let R;s[6]!==x?(R=t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:x}),s[6]=x,s[7]=R):R=s[7];let C;s[8]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),s[8]=C):C=s[8];let N;s[9]!==e?(N=e("settings.openchamber.sessionRetention.tooltip"),s[9]=e,s[10]=N):N=s[10];let T;s[11]!==N?(T=t.jsxs(It,{children:[C,t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:N})]}),s[11]=N,s[12]=T):T=s[12];let k;s[13]!==R||s[14]!==T?(k=t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[R,T]})}),s[13]=R,s[14]=T,s[15]=k):k=s[15];let j,b;s[16]!==n||s[17]!==i?(j=()=>i(!n),b=ae=>{(ae.key===" "||ae.key==="Enter")&&(ae.preventDefault(),i(!n))},s[16]=n,s[17]=i,s[18]=j,s[19]=b):(j=s[18],b=s[19]);let A;s[20]!==e?(A=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),s[20]=e,s[21]=A):A=s[21];let $;s[22]!==n||s[23]!==i||s[24]!==A?($=t.jsx(kt,{checked:n,onChange:i,ariaLabel:A}),s[22]=n,s[23]=i,s[24]=A,s[25]=$):$=s[25];let F;s[26]!==e?(F=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),s[26]=e,s[27]=F):F=s[27];let I;s[28]!==F?(I=t.jsx("span",{className:"typography-ui-label text-foreground",children:F}),s[28]=F,s[29]=I):I=s[29];let v;s[30]!==n||s[31]!==$||s[32]!==I||s[33]!==j||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:j,onKeyDown:b,children:[$,I]}),s[30]=n,s[31]=$,s[32]=I,s[33]=j,s[34]=b,s[35]=v):v=s[35];let w;s[36]!==e?(w=e("settings.openchamber.sessionRetention.field.retentionPeriod"),s[36]=e,s[37]=w):w=s[37];let L;s[38]!==w?(L=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:w})}),s[38]=w,s[39]=L):L=s[39];let E;s[40]!==e?(E=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),s[40]=e,s[41]=E):E=s[41];let _;s[42]!==a||s[43]!==o||s[44]!==E?(_=t.jsx(vs,{value:a,onValueChange:o,min:Gx,max:Jx,step:1,"aria-label":E,className:"w-20 tabular-nums"}),s[42]=a,s[43]=o,s[44]=E,s[45]=_):_=s[45];let B;s[46]!==e?(B=e("settings.openchamber.sessionRetention.field.days"),s[46]=e,s[47]=B):B=s[47];let Z;s[48]!==B?(Z=t.jsx("span",{className:"typography-ui-label text-muted-foreground",children:B}),s[48]=B,s[49]=Z):Z=s[49];let Q;s[50]!==o?(Q=()=>o(Go),s[50]=o,s[51]=Q):Q=s[51];const M=a===Go;let X;s[52]!==e?(X=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),s[52]=e,s[53]=X):X=s[53];let ee;s[54]!==e?(ee=e("settings.common.actions.reset"),s[54]=e,s[55]=ee):ee=s[55];let K;s[56]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(D,{name:"restart",className:"h-3.5 w-3.5"}),s[56]=K):K=s[56];let O;s[57]!==Q||s[58]!==M||s[59]!==X||s[60]!==ee?(O=t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:Q,disabled:M,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":X,title:ee,children:K}),s[57]=Q,s[58]=M,s[59]=X,s[60]=ee,s[61]=O):O=s[61];let Y;s[62]!==_||s[63]!==Z||s[64]!==O?(Y=t.jsxs("div",{className:"flex items-center gap-2 sm:w-fit",children:[_,Z,O]}),s[62]=_,s[63]=Z,s[64]=O,s[65]=Y):Y=s[65];let U;s[66]!==L||s[67]!==Y?(U=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:[L,Y]}),s[66]=L,s[67]=Y,s[68]=U):U=s[68];let ne;s[69]!==e?(ne=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),s[69]=e,s[70]=ne):ne=s[70];let re;s[71]!==ne?(re=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:ne})}),s[71]=ne,s[72]=re):re=s[72];let V;s[73]!==r||s[74]!==d||s[75]!==e?(V=Qx.map(ae=>t.jsx(G,{type:"button",variant:"chip",size:"xs","aria-pressed":r===ae.value,className:"!font-normal",onClick:()=>d(ae.value),children:e(ae.labelKey)},ae.value)),s[73]=r,s[74]=d,s[75]=e,s[76]=V):V=s[76];let oe;s[77]!==V?(oe=t.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:w-fit",children:V}),s[77]=V,s[78]=oe):oe=s[78];let fe;s[79]!==re||s[80]!==oe?(fe=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:[re,oe]}),s[79]=re,s[80]=oe,s[81]=fe):fe=s[81];let xe;s[82]!==v||s[83]!==U||s[84]!==fe?(xe=t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[v,U,fe]}),s[82]=v,s[83]=U,s[84]=fe,s[85]=xe):xe=s[85];let Ie;s[86]!==e?(Ie=e("settings.openchamber.sessionRetention.manualCleanup.title"),s[86]=e,s[87]=Ie):Ie=s[87];let ve;s[88]!==Ie?(ve=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]=ve):ve=s[89];let we;s[90]!==u||s[91]!==e?(we=e(u?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),s[90]=u,s[91]=e,s[92]=we):we=s[92];let be;s[93]!==h||s[94]!==u||s[95]!==we?(be=t.jsx("div",{className:"flex items-center gap-2 sm:w-fit",children:t.jsx(G,{type:"button",variant:"outline",size:"xs",onClick:h,disabled:u,className:"!font-normal",children:we})}),s[93]=h,s[94]=u,s[95]=we,s[96]=be):be=s[96];let se;s[97]!==ve||s[98]!==be?(se=t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8",children:[ve,be]}),s[97]=ve,s[98]=be,s[99]=se):se=s[99];let le;s[100]!==m||s[101]!==P||s[102]!==e?(le=m==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:P}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:P}),s[100]=m,s[101]=P,s[102]=e,s[103]=le):le=s[103];let ye;s[104]!==le?(ye=t.jsx("p",{className:"typography-meta text-muted-foreground",children:le}),s[104]=le,s[105]=ye):ye=s[105];let H;s[106]!==se||s[107]!==ye?(H=t.jsxs("div",{className:"mt-1 px-2 py-1.5 space-y-1",children:[se,ye]}),s[106]=se,s[107]=ye,s[108]=H):H=s[108];let te;return s[109]!==xe||s[110]!==H||s[111]!==k?(te=t.jsxs("div",{className:"mb-8",children:[k,xe,H]}),s[109]=xe,s[110]=H,s[111]=k,s[112]=te):te=s[112],te};function Yx(s){return s.autoDeleteEnabled}function Xx(s){return s.autoDeleteAfterDays}function Zx(s){return s.sessionRetentionAction}function eb(s){return s.setAutoDeleteEnabled}function tb(s){return s.setAutoDeleteAfterDays}function sb(s){return s.setSessionRetentionAction}const Jo=(s,e,n)=>!s||!Number.isFinite(s)?e:new Intl.DateTimeFormat(Gr(),{dateStyle:"medium",timeStyle:"short",hour12:n==="auto"?void 0:n==="12h"}).format(s),ac=()=>{const{t:s}=it(),e=ze(b=>b.timeFormatPreference),[n,a]=l.useState(!1),[r,i]=l.useState(!0),[o,d]=l.useState(!1),[c,f]=l.useState(null),[u,p]=l.useState(!1),[m,P]=l.useState([]),[g,h]=l.useState(ym),[x,R]=l.useState(""),C=l.useMemo(()=>vm(),[]),N=l.useCallback(async()=>{i(!0),R("");try{const b=await jm();P(b)}catch(b){const A=b instanceof Error?b.message:s("settings.openchamber.passkeys.toast.loadFailed");R(A)}finally{i(!1)}},[s]);l.useEffect(()=>{let b=!1;return(async()=>{try{if(!C.supported){b||(a(!1),i(!1));return}b||a(!0)}catch{b||a(!1)}if(!b){const A=await Ga();if(h(A),!A.enabled){P([]),i(!1);return}await N()}})(),()=>{b=!0,vi()}},[N,C.supported]);const T=l.useCallback(async()=>{if(!g.enabled){const b=s("settings.openchamber.passkeys.toast.enableUiPasswordFirst");R(b),W.message(b);return}if(!n){R(C.reason),W.message(C.reason);return}if(o){vi(),d(!1);return}R(""),d(!0);try{await wm(),h(await Ga()),await N(),W.success(s("settings.openchamber.passkeys.toast.added"))}catch(b){if(Nm(b)){W.message(s("settings.openchamber.passkeys.toast.setupCanceled"));return}const A=b instanceof Error?b.message:s("settings.openchamber.passkeys.toast.addFailed");R(A),W.error(A)}finally{d(!1)}},[o,N,g.enabled,C.reason,n,s]),k=l.useCallback(async b=>{f(b),R("");try{await km(b),h(await Ga()),await N(),W.success(s("settings.openchamber.passkeys.toast.removed"))}catch(A){const $=A instanceof Error?A.message:s("settings.openchamber.passkeys.toast.removeFailed");R($),W.error($)}finally{f(null)}},[N,s]),j=l.useCallback(async()=>{p(!0),R("");try{await Sm(),window.location.reload()}catch(b){const A=b instanceof Error?b.message:s("settings.openchamber.passkeys.toast.clearAuthFailed");R(A),W.error(A),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(G,{type:"button",variant:o?"secondary":"outline",size:"xs",onClick:()=>{T()},disabled:r||u,className:"!font-normal",children:s(o?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>{j()},disabled:r||o||u,className:"!font-normal text-muted-foreground hover:text-foreground",children:s(u?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]})]}),!g.enabled&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.uiPasswordRequired")}),g.enabled&&!n&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:C.reason}),r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.loading")}):m.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:m.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:Jo(b.lastUsedAt,s("settings.openchamber.passkeys.time.neverUsed"),e)}):s("settings.openchamber.passkeys.item.added",{time:Jo(b.createdAt,s("settings.openchamber.passkeys.time.neverUsed"),e)})}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k(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))})]}),x&&t.jsx("div",{className:"mt-1 px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:x})})]})},nb=s=>{const e=fn(s);return e||{providerId:"",modelId:""}},rc=()=>{const{t:s}=it(),e=lt(I=>I.setProvider),n=lt(I=>I.setModel),a=lt(I=>I.setAgent),r=lt(I=>I.setCurrentVariant),i=lt(I=>I.setSettingsDefaultModel),o=lt(I=>I.setSettingsDefaultVariant),d=lt(I=>I.setSettingsDefaultAgent),c=ze(I=>I.showDeletionDialog),f=ze(I=>I.setShowDeletionDialog),u=lt(I=>I.providers),[p,m]=l.useState(),[P,g]=l.useState(),[h,x]=l.useState(),[R,C]=l.useState(!0),N=l.useMemo(()=>nb(p),[p]);l.useEffect(()=>{(async()=>{try{let v=null;if(!v){const w=Os()?.settings;if(w)try{const E=(await w.load())?.settings;E&&(v={defaultModel:typeof E.defaultModel=="string"?E.defaultModel:void 0,defaultVariant:typeof E.defaultVariant=="string"?E.defaultVariant:void 0,defaultAgent:typeof E.defaultAgent=="string"?E.defaultAgent:void 0})}catch{}}if(!v){const w=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});w.ok&&(v=await w.json())}if(v){const w=typeof v.defaultModel=="string"&&v.defaultModel.trim().length>0?v.defaultModel.trim():void 0,L=typeof v.defaultVariant=="string"&&v.defaultVariant.trim().length>0?v.defaultVariant.trim():void 0,E=typeof v.defaultAgent=="string"&&v.defaultAgent.trim().length>0?v.defaultAgent.trim():void 0;w!==void 0&&m(w),L!==void 0&&g(L),E!==void 0&&x(E)}}catch(v){console.warn("Failed to load defaults settings:",v)}finally{C(!1)}})()},[]);const T=l.useCallback(async(I,v)=>{const w=I&&v?`${I}/${v}`:void 0;m(w),g(void 0),o(void 0),r(void 0),i(w),I&&v&&u.find(E=>E.id===I)&&(e(I),n(v));try{await Pt({defaultModel:w??"",defaultVariant:""});const L=await ht("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultModel:w})});L.ok||console.warn("Failed to save default model to server:",L.status,L.statusText)}catch(L){console.warn("Failed to save default model:",L)}},[u,r,n,e,i,o]),k="__default__",j=l.useCallback(I=>I===k?s("settings.openchamber.defaults.option.default"):I.charAt(0).toUpperCase()+I.slice(1),[s]),b=l.useCallback(async I=>{const v=I===k?void 0:I||void 0;g(v),o(v),r(v);try{await Pt({defaultVariant:v??""})}catch(w){console.warn("Failed to save default variant:",w)}},[r,o]),A=l.useCallback(async I=>{const v=I||void 0;x(v),d(v),I&&a(I);try{await Pt({defaultAgent:v??""})}catch(w){console.warn("Failed to save default agent:",w)}},[a,d]),$=l.useMemo(()=>{if(!N.providerId||!N.modelId)return[];const w=u.find(L=>L.id===N.providerId)?.models.find(L=>L.id===N.modelId)?.variants;return w?Object.keys(w):[]},[N.modelId,N.providerId,u]),F=$.length>0;return l.useEffect(()=>{!F&&P&&(g(void 0),o(void 0),r(void 0),Pt({defaultVariant:""}).catch(()=>{}))},[P,r,o,F]),R?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")," ",N.providerId?t.jsxs("span",{className:"text-foreground",children:[N.providerId,"/",N.modelId,F?` (${P??s("settings.openchamber.defaults.option.defaultLowercase")})`:""]}):t.jsx("span",{className:"text-foreground",children:s("settings.openchamber.defaults.summaryOpenCodeDefault")}),h&&t.jsxs(t.Fragment,{children:[" / ",t.jsx("span",{className:"text-foreground",children:h})]})]}),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(Jr,{providerId:N.providerId,modelId:N.modelId,onChange:T})})]}),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(Rt,{value:P??k,onValueChange:b,disabled:!F,children:[t.jsx(Tt,{className:"w-fit min-w-[120px]",children:t.jsx(Lt,{placeholder:s("settings.openchamber.defaults.field.thinkingPlaceholder"),children:j(P??k)})}),t.jsxs(Ft,{children:[t.jsx(gt,{value:k,children:s("settings.openchamber.defaults.option.default")}),$.map(I=>t.jsx(gt,{value:I,children:j(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(kl,{agentName:h||"",onChange:A})})]}),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:()=>f(!c),onKeyDown:I=>{(I.key===" "||I.key==="Enter")&&(I.preventDefault(),f(!c))},children:[t.jsx(kt,{checked:c,onChange:f,ariaLabel:s("settings.openchamber.defaults.field.showDeletionDialogAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.showDeletionDialog")})]})]})]})},Qo={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"}},ab={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"},rb=()=>{const{t:s}=it(),e=l.useMemo(()=>is(),[]),n=l.useMemo(()=>fs(),[]),a=l.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),r=!e&&!n&&!a,i=ze(K=>K.nativeNotificationsEnabled),o=ze(K=>K.setNativeNotificationsEnabled),d=ze(K=>K.notificationMode),c=ze(K=>K.setNotificationMode),f=ze(K=>K.notifyOnSubtasks),u=ze(K=>K.setNotifyOnSubtasks),p=ze(K=>K.notifyOnCompletion),m=ze(K=>K.setNotifyOnCompletion),P=ze(K=>K.notifyOnError),g=ze(K=>K.setNotifyOnError),h=ze(K=>K.notifyOnQuestion),x=ze(K=>K.setNotifyOnQuestion),R=ze(K=>K.notificationTemplates),C=ze(K=>K.setNotificationTemplates),[N,T]=l.useState("default"),[k,j]=l.useState(!1),[b,A]=l.useState(!1),[$,F]=l.useState(!1);l.useEffect(()=>{if(!r){j(!1),A(!1);return}typeof Notification<"u"&&T(Notification.permission);const K=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;j(K),(async()=>{if(!K){A(!1);return}try{const Y=await navigator.serviceWorker.getRegistration();if(!Y){A(!1);return}const U=await Y.pushManager.getSubscription();A(!!U)}catch{A(!1)}})()},[r]);const I=async K=>{if(e){o(K);return}if(!r){o(K);return}if(K&&typeof Notification<"u"&&Notification.permission==="default")try{const O=await Notification.requestPermission();T(O),O==="granted"?o(!0):W.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.description")})}catch(O){console.error("Failed to request notification permission:",O),W.error(s("settings.notifications.page.toast.requestPermissionFailed"))}else o(!!(K&&N==="granted"))},v=e||n||a||r&&typeof Notification<"u"&&Notification.permission==="granted",w=(K,O,Y)=>{C({...R,[K]:{...R[K],[O]:Y}})},L=K=>{const O="=".repeat((4-K.length%4)%4),Y=(K+O).replace(/-/g,"+").replace(/_/g,"/"),U=atob(Y),ne=new Uint8Array(U.length);for(let re=0;re<U.length;re+=1)ne[re]=U.charCodeAt(re);return ne},E=async(K,O,Y)=>{let U=null;const ne=new Promise((re,V)=>{U=setTimeout(()=>{V(new Error(Y))},O)});try{return await Promise.race([K,ne])}finally{U&&clearTimeout(U)}},_=async K=>{if(K.active)return;const O=K.installing||K.waiting;O&&O.state!=="activated"&&await E(new Promise(Y=>{const U=()=>{O.state==="activated"&&(O.removeEventListener("statechange",U),Y())};O.addEventListener("statechange",U),U()}),15e3,"Service worker activation timed out")},B=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const K=[{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 O=null;for(const Y of K)try{const U=Y.opts?navigator.serviceWorker.register("/sw.js",Y.opts):navigator.serviceWorker.register("/sw.js");return await E(U,1e4,`Service worker registration timed out (${Y.label})`)}catch(U){O=U}throw O instanceof Error?O:new Error("Service worker registration failed")},Z=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const K=await navigator.serviceWorker.getRegistration();if(K)return K;const O=await B();try{await O.update()}catch{}return await _(O),O},Q=K=>{const O=K,Y=[`type=${typeof K}`,`toString=${String(K)}`,`name=${String(O?.name??"")}`,`message=${String(O?.message??"")}`];let U="";try{U=JSON.stringify(K)}catch{}return{summary:Y.filter(Boolean).join(" | "),json:U,stack:typeof O?.stack=="string"?O.stack:""}},M=async()=>{const K=Os();if(!K?.notifications){W.error(s("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await K.notifications.notifyAgentCompletion({title:s("settings.notifications.page.testNotification.title"),body:s("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?W.success(s("settings.notifications.page.toast.testNotificationSent")):W.error(s("settings.notifications.page.toast.testNotificationFailed"))}catch(O){console.error("Test notification failed:",O),W.error(s("settings.notifications.page.toast.testNotificationFailed"))}},X=async()=>{if(!k){W.error(s("settings.notifications.page.toast.pushUnsupported"));return}const K=Os();if(!K?.push){W.error(s("settings.notifications.page.toast.pushApiUnavailable"));return}F(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const fe=await Notification.requestPermission();if(T(fe),fe!=="granted"){W.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){W.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const O=await K.push.getVapidPublicKey();if(!O?.publicKey){W.error(s("settings.notifications.page.toast.pushKeyLoadFailed"));return}const Y=await Z();await _(Y);const U=await Y.pushManager.getSubscription();if(!("pushManager"in Y)||!Y.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const re=(U??await E(Y.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:L(O.publicKey)}),15e3,"Push subscription timed out")).toJSON(),V=re.keys;if(!re.endpoint||!V?.p256dh||!V.auth)throw new Error("Push subscription missing keys");if(!(await E(K.push.subscribe({endpoint:re.endpoint,keys:{p256dh:V.p256dh,auth:V.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:Cm()}),15e3,"Push subscribe request timed out"))?.ok){W.error(s("settings.notifications.page.toast.enableBackgroundFailed"));return}A(!0),W.success(s("settings.notifications.page.toast.backgroundEnabled"))}catch(O){console.error("[Push] Enable failed:",O);const Y=Q(O);W.error(s("settings.notifications.page.toast.enableBackgroundFailed"),{description:Y.summary})}finally{F(!1)}},ee=async()=>{if(!k){A(!1);return}const K=Os();if(!K?.push){W.error(s("settings.notifications.page.toast.pushApiUnavailable"));return}F(!0);try{const Y=await(await Z()).pushManager.getSubscription();if(!Y){A(!1);return}const U=Y.endpoint;await Y.unsubscribe(),await K.push.unsubscribe({endpoint:U}),A(!1),W.success(s("settings.notifications.page.toast.backgroundDisabled"))}finally{F(!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":i&&v,onClick:()=>{I(!(i&&v))},onKeyDown:K=>{(K.key===" "||K.key==="Enter")&&(K.preventDefault(),I(!(i&&v)))},children:[t.jsx(kt,{checked:i&&v,onChange:K=>{I(K)},ariaLabel:s("settings.notifications.page.delivery.enableAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.delivery.enableLabel")})]}),i&&v&&!a&&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":d==="always",onClick:()=>c(d==="always"?"hidden-only":"always"),onKeyDown:K=>{(K.key===" "||K.key==="Enter")&&(K.preventDefault(),c(d==="always"?"hidden-only":"always"))},children:[t.jsx(kt,{checked:d==="always",onChange:K=>c(K?"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(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{M()},children:s("settings.notifications.page.delivery.testAction")})})]})]}),r&&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")}),N==="denied"&&t.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:s("settings.notifications.page.delivery.permissionDenied")}),N==="granted"&&!i&&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")})})]}),i&&v&&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":p,onClick:()=>m(!p),onKeyDown:K=>{(K.key===" "||K.key==="Enter")&&(K.preventDefault(),m(!p))},children:[t.jsx(kt,{checked:p,onChange:m,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":f,onClick:()=>u(!f),onKeyDown:K=>{(K.key===" "||K.key==="Enter")&&(K.preventDefault(),u(!f))},children:[t.jsx(kt,{checked:f,onChange:u,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":P,onClick:()=>g(!P),onKeyDown:K=>{(K.key===" "||K.key==="Enter")&&(K.preventDefault(),g(!P))},children:[t.jsx(kt,{checked:P,onChange:g,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":h,onClick:()=>x(!h),onKeyDown:K=>{(K.key===" "||K.key==="Enter")&&(K.preventDefault(),x(!h))},children:[t.jsx(kt,{checked:h,onChange:x,ariaLabel:s("settings.notifications.page.events.questionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.questionLabel")})]})]})]}),!a&&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(K=>t.jsxs("section",{className:"p-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground font-normal capitalize block",children:s(ab[K])}),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(Ze,{value:R[K].title,onChange:O=>w(K,"title",O.target.value),className:"h-7",placeholder:s(Qo[K].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(Ze,{value:R[K].message,onChange:O=>w(K,"message",O.target.value),className:"h-7",placeholder:s(Qo[K].messageKey)})]})]})]},K))})]})]}),r&&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(kt,{checked:k?b:!1,disabled:!k||$,onChange:K=>{K?X():ee()},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",k?"text-foreground":"text-muted-foreground"),children:s("settings.notifications.page.push.enableLabel")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s(k?"settings.notifications.page.push.supportedHint":"settings.notifications.page.push.unsupportedHint")})]}),$&&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")})})]})})]})]})},ws=s=>{if(!s)return;s.pause();const{src:e}=s;e.startsWith("blob:")&&URL.revokeObjectURL(e),s.removeAttribute("src"),s.load()},ib=[{id:"parakeet-tdt-0.6b-v2-int8",labelKey:"settings.voice.page.stt.model.parakeetV2",badgeKey:"settings.voice.page.stt.badge.bestForEnglish",accuracy:5,speed:5,size:"460 MB"},{id:"parakeet-tdt-0.6b-v3-int8",labelKey:"settings.voice.page.stt.model.parakeetV3",badgeKey:"settings.voice.page.stt.badge.bestForMultilingual",accuracy:5,speed:4,size:"465 MB"},{id:"whisper-base-int8",labelKey:"settings.voice.page.stt.model.whisperBase",badgeKey:null,accuracy:3,speed:3,size:"200 MB"},{id:"whisper-tiny-int8",labelKey:"settings.voice.page.stt.model.whisperTiny",badgeKey:null,accuracy:2,speed:4,size:"115 MB"}],Yo=s=>{const e=nt.c(8),{value:n,label:a}=s,r=`${a}: ${n}/5`,i=`${n/5*100}%`;let o;e[0]!==i?(o=t.jsx("span",{className:"h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]","aria-hidden":"true",children:t.jsx("span",{className:"block h-full rounded-full bg-[var(--primary-base)]",style:{width:i}})}),e[0]=i,e[1]=o):o=e[1];let d;e[2]!==a?(d=t.jsx("span",{className:"typography-ui-compact text-muted-foreground",children:a}),e[2]=a,e[3]=d):d=e[3];let c;return e[4]!==r||e[5]!==o||e[6]!==d?(c=t.jsxs("span",{className:"flex items-center gap-1.5",title:r,children:[o,d]}),e[4]=r,e[5]=o,e[6]=d,e[7]=c):c=e[7],c},ob=({selectedModelId:s,onSelect:e})=>{const{t:n}=it(),a=he.useCallback(m=>n(m),[n]),[r,i]=he.useState(new Map),[o,d]=he.useState(null),c=he.useCallback(async()=>{try{const m=await ht("/api/dictation/status",{query:{provider:"local"}});if(!m.ok)return;const P=await m.json();Array.isArray(P?.models)&&i(new Map(P.models.map(g=>[g.id,g])))}catch{}},[]);he.useEffect(()=>{c()},[c]);const f=Array.from(r.values()).some(m=>m.downloading);he.useEffect(()=>{if(!f)return;const m=setInterval(()=>{c()},2e3);return()=>clearInterval(m)},[f,c]);const u=async m=>{d(m);try{await ht(`/api/dictation/models/${encodeURIComponent(m)}/download`,{method:"POST"}),await c()}catch{}finally{d(null)}},p=async m=>{d(m);try{await ht(`/api/dictation/models/${encodeURIComponent(m)}`,{method:"DELETE"}),await c()}catch{}finally{d(null)}};return t.jsx("div",{role:"radiogroup","aria-label":n("settings.voice.page.field.model"),className:"mt-1 space-y-0",children:ib.map(m=>{const P=s===m.id,g=r.get(m.id)??null;return t.jsxs("div",{className:"flex w-full items-start gap-2 py-1.5",children:[t.jsx("div",{className:"pt-0.5",children:t.jsx(tn,{checked:P,onChange:()=>e(m.id),ariaLabel:a(m.labelKey)})}),t.jsxs("div",{className:"min-w-0 flex-1 cursor-pointer",role:"button",tabIndex:0,onClick:()=>e(m.id),onKeyDown:h=>{(h.key===" "||h.key==="Enter")&&(h.preventDefault(),e(m.id))},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[t.jsx("span",{className:ce("typography-ui-label font-normal",P?"text-foreground":"text-foreground/50"),children:a(m.labelKey)}),m.badgeKey?t.jsx("span",{className:"rounded px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide",style:{backgroundColor:"var(--status-success-background)",color:"var(--status-success)",border:"1px solid var(--status-success-border)"},children:a(m.badgeKey)}):null]}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-4 gap-y-0.5",children:[t.jsx(Yo,{value:m.accuracy,label:n("settings.voice.page.stt.meta.accuracy")}),t.jsx(Yo,{value:m.speed,label:n("settings.voice.page.stt.meta.speed")}),t.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:m.size})]}),g?.downloadError?t.jsx("p",{className:"mt-0.5 typography-meta text-[var(--status-error)]",children:g.downloadError}):null]}),t.jsx("div",{className:"flex w-14 flex-shrink-0 items-center justify-end gap-1 pt-0.5",children:g?.installed?t.jsxs(t.Fragment,{children:[t.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:o===m.id,onClick:()=>{p(m.id)},title:n("settings.voice.page.stt.modelDelete"),"aria-label":n("settings.voice.page.stt.modelDelete"),children:t.jsx(D,{name:"delete-bin",className:"h-4 w-4"})}),t.jsx(D,{name:"checkbox-circle",className:"h-4 w-4 flex-shrink-0 text-[var(--status-success)]","aria-label":n("settings.voice.page.stt.modelInstalled")})]}):g?.downloading?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(D,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof g.downloadProgress=="number"?`${g.downloadProgress}%`:""})]}):t.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:o===m.id,onClick:()=>{u(m.id)},title:n("settings.voice.page.stt.modelDownload"),"aria-label":n("settings.voice.page.stt.modelDownload"),children:t.jsx(D,{name:"download",className:"h-4 w-4"})})})]},m.id)})})},pr=[{id:0,label:"Alloy (af)"},{id:1,label:"Bella (af)"},{id:2,label:"Nicole (af)"},{id:3,label:"Sarah (af)"},{id:4,label:"Sky (af)"},{id:5,label:"Adam (am)"},{id:6,label:"Michael (am)"},{id:7,label:"Emma (bf)"},{id:8,label:"Isabella (bf)"},{id:9,label:"George (bm)"},{id:10,label:"Lewis (bm)"}],gr="kokoro-en-v0_19",lb=()=>{const{t:s}=it(),[e,n]=he.useState(null),[a,r]=he.useState(!1),i=he.useCallback(async()=>{try{const d=await ht("/api/dictation/status",{query:{provider:"local"}});if(!d.ok)return;const c=await d.json(),f=Array.isArray(c?.ttsModels)?c.ttsModels.find(u=>u.id===gr):null;f&&n(f)}catch{}},[]);he.useEffect(()=>{i()},[i]),he.useEffect(()=>{if(!e?.downloading)return;const d=setInterval(()=>{i()},2e3);return()=>clearInterval(d)},[e?.downloading,i]);const o=async d=>{r(!0);try{const c=d==="POST"?`/api/dictation/models/${gr}/download`:`/api/dictation/models/${gr}`;await ht(c,{method:d}),await i()}catch{}finally{r(!1)}};return e?t.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"Kokoro"}),t.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:"305 MB"}),e.installed?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]","aria-label":s("settings.voice.page.stt.modelInstalled")}),t.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:a,onClick:()=>{o("DELETE")},title:s("settings.voice.page.stt.modelDelete"),"aria-label":s("settings.voice.page.stt.modelDelete"),children:t.jsx(D,{name:"delete-bin",className:"h-4 w-4"})})]}):e.downloading?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(D,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof e.downloadProgress=="number"?`${e.downloadProgress}%`:""})]}):t.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:a,onClick:()=>{o("POST")},title:s("settings.voice.page.stt.modelDownload"),"aria-label":s("settings.voice.page.stt.modelDownload"),children:t.jsx(D,{name:"download",className:"h-4 w-4"})}),e.downloadError?t.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:e.downloadError}):null]}):null},cb=[{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"}],db=()=>{const{t:s}=it(),{isMobile:e}=Cs(),n=lt(y=>y.voiceProvider),a=lt(y=>y.setVoiceProvider),r=lt(y=>y.speechRate),i=lt(y=>y.setSpeechRate),o=lt(y=>y.speechPitch),d=lt(y=>y.setSpeechPitch),c=lt(y=>y.speechVolume),f=lt(y=>y.setSpeechVolume),u=lt(y=>y.sayVoice),p=lt(y=>y.setSayVoice),m=lt(y=>y.localTtsVoiceId),P=lt(y=>y.setLocalTtsVoiceId),{speak:g,stop:h,isPlaying:x,error:R}=Pm(),C=he.useCallback(()=>{if(x){h();return}const y=pr.find(pe=>pe.id===m)?.label??String(m);g(s("settings.voice.page.preview.voiceLine",{voiceName:y}),{speakerId:m,speed:lt.getState().speechRate})},[x,m,g,h,s]),N=lt(y=>y.browserVoice),T=lt(y=>y.setBrowserVoice),k=lt(y=>y.openaiVoice),j=lt(y=>y.setOpenaiVoice),b=lt(y=>y.openaiApiKey),A=lt(y=>y.setOpenaiApiKey),$=lt(y=>y.openaiCompatibleUrl),F=lt(y=>y.setOpenaiCompatibleUrl),I=lt(y=>y.openaiCompatibleApiKey),v=lt(y=>y.setOpenaiCompatibleApiKey),w=lt(y=>y.openaiCompatibleVoice),L=lt(y=>y.setOpenaiCompatibleVoice),E=lt(y=>y.openaiCompatibleTtsModel),_=lt(y=>y.setOpenaiCompatibleTtsModel),B=lt(y=>y.showMessageTTSButtons),Z=lt(y=>y.ttsInputMode),Q=lt(y=>y.setTtsInputMode),M=lt(y=>y.sttProvider),X=lt(y=>y.setSttProvider),ee=lt(y=>y.sttServerUrl),K=lt(y=>y.setSttServerUrl),O=lt(y=>y.sttApiKey),Y=lt(y=>y.setSttApiKey),U=lt(y=>y.sttModel),ne=lt(y=>y.setSttModel),re=lt(y=>y.sttLocalModel),V=lt(y=>y.setSttLocalModel),oe=lt(y=>y.sttLanguage),fe=lt(y=>y.setSttLanguage),xe=lt(y=>y.setShowMessageTTSButtons),Ie=lt(y=>y.dictationEnabled),ve=lt(y=>y.setDictationEnabled),[we,be]=he.useState(!1),[se,le]=he.useState([]),[ye,H]=he.useState(!1),[te,ae]=he.useState(null),[me,Me]=he.useState(!1),[Ne,De]=he.useState(!1),[Ee,Pe]=he.useState(null),[Te,Le]=he.useState(!1),[Be,He]=he.useState(null),[Ue,Je]=he.useState([]),[de,q]=he.useState(!1);he.useEffect(()=>((async()=>{const pe=await Ja.waitForVoices();Je(pe)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{Je(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const ue=he.useMemo(()=>Ue.filter(y=>y.lang).sort((y,pe)=>{const Ae=y.lang.startsWith("en"),Oe=pe.lang.startsWith("en");if(Ae&&!Oe)return-1;if(!Ae&&Oe)return 1;const qe=y.lang.localeCompare(pe.lang);return qe!==0?qe:y.name.localeCompare(pe.name)}),[Ue]),je=he.useCallback(()=>{if(de){Ja.cancelSpeech(),q(!1);return}const y=Ue.find(qe=>qe.name===N),pe=y?.name??s("settings.voice.page.preview.browserVoiceFallback"),Ae=s("settings.voice.page.preview.voiceLine",{voiceName:pe});q(!0);const Oe=new SpeechSynthesisUtterance(Ae);Oe.rate=r,Oe.pitch=o,Oe.volume=c,y&&(Oe.voice=y,Oe.lang=y.lang),Oe.onend=()=>q(!1),Oe.onerror=()=>q(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(Oe)},[N,Ue,r,o,c,de,s]);he.useEffect(()=>()=>{de&&Ja.cancelSpeech()},[de]),he.useEffect(()=>{if(!B||n!=="openai"&&n!=="openai-compatible"){Me(b.trim().length>0);return}(async()=>{try{const Oe=(await(await ht("/api/tts/status")).json()).available,qe=b.trim().length>0;Me(Oe||qe)}catch{Me(b.trim().length>0)}})()},[b,B,n]),he.useEffect(()=>{if(!B){be(!1),le([]);return}ht("/api/tts/say/status").then(y=>y.json()).then(y=>{if(be(y.available),y.voices){const pe=y.voices.filter((Ae,Oe,qe)=>qe.findIndex(at=>at.name===Ae.name)===Oe).sort((Ae,Oe)=>Ae.name.localeCompare(Oe.name));le(pe)}}).catch(()=>{be(!1)})},[B]);const Re=he.useCallback(async()=>{if(te){ws(te),ae(null),H(!1);return}H(!0);let y=null;try{const pe=await ht("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.voiceLine",{voiceName:u}),voice:u,rate:Math.round(100+(r-.5)*200)})});if(!pe.ok)throw new Error("Preview failed");const Ae=await pe.blob(),Oe=URL.createObjectURL(Ae);y=new Audio(Oe),y.onended=()=>{ws(y),ae(null),H(!1)},y.onerror=()=>{ws(y),ae(null),H(!1)},ae(y),await y.play()}catch{ws(y),ae(null),H(!1)}},[u,r,te,s]);he.useEffect(()=>()=>{ws(te)},[te]);const Ce=he.useCallback(async()=>{if(Ee){ws(Ee),Pe(null),De(!1);return}De(!0);let y=null;try{const pe=await ht("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.voiceLine",{voiceName:k}),voice:k,speed:r,apiKey:b||void 0})});if(!pe.ok){const qe=await pe.json().catch(()=>({error:"Unknown error"}));throw new Error(qe.error||`HTTP ${pe.status}`)}const Ae=await pe.blob(),Oe=URL.createObjectURL(Ae);y=new Audio(Oe),y.onended=()=>{ws(y),Pe(null),De(!1)},y.onerror=()=>{ws(y),Pe(null),De(!1)},Pe(y),await y.play()}catch{ws(y),Pe(null),De(!1)}},[k,r,Ee,b,s]);he.useEffect(()=>()=>{ws(Ee)},[Ee]);const _e=he.useCallback(async()=>{if(Be){ws(Be),He(null),Le(!1);return}if(!$.trim())return;Le(!0);let y=null;try{const pe=await ht("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.customServerLine"),voice:w,model:E||void 0,speed:r,baseURL:$,apiKey:I||void 0})});if(!pe.ok){const qe=await pe.json().catch(()=>({error:"Unknown error"}));throw new Error(qe.error||`HTTP ${pe.status}`)}const Ae=await pe.blob(),Oe=URL.createObjectURL(Ae);y=new Audio(Oe),y.onended=()=>{ws(y),He(null),Le(!1)},y.onerror=()=>{ws(y),He(null),Le(!1)},He(y),await y.play()}catch{ws(y),He(null),Le(!1)}},[$,w,E,I,r,Be,s]);he.useEffect(()=>()=>{ws(Be)},[Be]);const J="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.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":B,onClick:()=>xe(!B),onKeyDown:y=>{(y.key===" "||y.key==="Enter")&&(y.preventDefault(),xe(!B))},children:[t.jsx(kt,{checked:B,onChange:xe,ariaLabel:s("settings.voice.page.field.messageReadAloudButtonAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.messageReadAloudButton")})]}),B&&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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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:s("settings.voice.page.provider.local")})," ",s("settings.voice.page.tooltip.localTts")]}),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(G,{variant:"chip",size:"xs","aria-pressed":n==="browser",onClick:()=>a("browser"),className:"!font-normal",children:s("settings.voice.page.provider.browser")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":n==="local",onClick:()=>a("local"),className:"!font-normal",children:s("settings.voice.page.provider.local")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":n==="openai",onClick:()=>a("openai"),className:"!font-normal",children:"OpenAI"}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":n==="openai-compatible",onClick:()=>a("openai-compatible"),className:"!font-normal",children:s("settings.voice.page.provider.custom")}),we&&t.jsxs(G,{variant:"chip",size:"xs","aria-pressed":n==="say",onClick:()=>a("say"),className:"!font-normal",children:[t.jsx(D,{name:"apple",className:"w-3.5 h-3.5 mr-0.5"}),s("settings.voice.page.provider.say")]})]})]})}),n==="openai"&&t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!me&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.apiKey")}),t.jsx("span",{className:ce("typography-meta ml-2",me?"text-muted-foreground":"text-[var(--status-error)]/80"),children:s(me&&!b?"settings.voice.page.field.apiKeyHintUsingConfig":me?"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:b,onChange:y=>A(y.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:()=>A(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(D,{name:"close",className:"w-3.5 h-3.5"})})]})]}),n==="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",!$.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:$,onChange:y=>F(y.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"}),$&&t.jsx("button",{type:"button",onClick:()=>F(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(D,{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:I,onChange:y=>v(y.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"}),I&&t.jsx("button",{type:"button",onClick:()=>v(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(D,{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:E,onChange:y=>_(y.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:w,onChange:y=>L(y.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(G,{size:"xs",variant:"ghost",onClick:_e,title:s("settings.voice.page.actions.preview"),disabled:!$.trim(),children:Te?t.jsx(D,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(D,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),n==="local"&&t.jsx(lb,{}),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:[n==="local"&&t.jsxs(t.Fragment,{children:[t.jsxs(Rt,{value:String(m),onValueChange:y=>P(Number.parseInt(y,10)||0),children:[t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder"),children:y=>pr.find(pe=>String(pe.id)===y)?.label??y})}),t.jsx(Ft,{children:pr.map(y=>t.jsx(gt,{value:String(y.id),children:y.label},y.id))})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:C,title:s("settings.voice.page.actions.preview"),children:x?t.jsx(D,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(D,{name:"play",className:"w-3.5 h-3.5"})}),R?t.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:R}):null]}),n==="openai"&&me&&t.jsxs(t.Fragment,{children:[t.jsxs(Rt,{value:k,onValueChange:j,children:[t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder")})}),t.jsx(Ft,{children:cb.map(y=>t.jsx(gt,{value:y.value,children:y.label},y.value))})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:Ce,title:s("settings.voice.page.actions.preview"),children:Ne?t.jsx(D,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(D,{name:"play",className:"w-3.5 h-3.5"})})]}),n==="openai-compatible"&&t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.voice.page.field.configuredAbove")}),n==="say"&&we&&se.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs(Rt,{value:u,onValueChange:p,children:[t.jsx(Tt,{className:"w-fit",children:t.jsx(Lt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder")})}),t.jsx(Ft,{children:se.map(y=>t.jsx(gt,{value:y.name,children:y.name},y.name))})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:Re,title:s("settings.voice.page.actions.preview"),children:ye?t.jsx(D,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(D,{name:"play",className:"w-3.5 h-3.5"})})]}),n==="browser"&&ue.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs(Rt,{value:N||"$auto",onValueChange:y=>T(y==="$auto"?"":y),children:[t.jsx(Tt,{className:"w-fit max-w-[200px]",children:t.jsx(Lt,{placeholder:s("settings.voice.page.field.auto")})}),t.jsxs(Ft,{children:[t.jsx(gt,{value:"$auto",children:s("settings.voice.page.field.auto")}),ue.map(y=>t.jsxs(gt,{value:y.name,children:[y.name," (",y.lang,")"]},y.name))]})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:je,title:s("settings.voice.page.actions.preview"),children:de?t.jsx(D,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(D,{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:r,onChange:y=>i(Number(y.target.value)),className:J}),t.jsx(vs,{value:r,onValueChange:i,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:o,onChange:y=>d(Number(y.target.value)),className:J}),t.jsx(vs,{value:o,onValueChange:d,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:c,onChange:y=>f(Number(y.target.value)),className:J}),e?t.jsx(vs,{value:Math.round(c*100),onValueChange:y=>f(y/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(c*100),"%"]})]})]}),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(G,{variant:"chip",size:"xs","aria-pressed":Z==="sanitized",onClick:()=>Q("sanitized"),className:"!font-normal",children:s("settings.voice.page.field.ttsInputModeSanitized")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":Z==="raw",onClick:()=>Q("raw"),className:"!font-normal",children:s("settings.voice.page.field.ttsInputModeRaw")})]})]})})]})]})]}),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.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":Ie,onClick:()=>ve(!Ie),onKeyDown:y=>{(y.key===" "||y.key==="Enter")&&(y.preventDefault(),ve(!Ie))},children:[t.jsx(kt,{checked:Ie,onChange:ve,ariaLabel:s("settings.voice.page.field.enableVoiceInputAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.enableVoiceInput")})]}),Ie&&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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{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.local")})," ",s("settings.voice.page.tooltip.sttLocal")]}),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(G,{variant:"chip",size:"xs","aria-pressed":M==="local",onClick:()=>X("local"),className:"!font-normal",children:s("settings.voice.page.provider.local")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":M==="openai-compatible",onClick:()=>X("openai-compatible"),className:"!font-normal",children:s("settings.voice.page.provider.server")})]})]})}),M==="local"&&t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.model")}),t.jsx(ob,{selectedModelId:re,onSelect:V})]}),M==="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",!ee.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:ee,onChange:y=>K(y.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"}),ee&&t.jsx("button",{type:"button",onClick:()=>K(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(D,{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:O,onChange:y=>Y(y.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"}),O&&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(D,{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:U,onChange:y=>ne(y.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:oe,onChange:y=>fe(y.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"})})]})]})]})]})]})]})},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}],mb="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",ub="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",hr=[{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"}],pb=[".yml",".yaml",".json"],gb="settings.openchamber.tunnel.error.invalidConfigExtension",Jn=s=>{const e=s.trim().toLowerCase();return pb.some(n=>e.endsWith(n))},hb=s=>s==="ngrok"?"ngrok":"cloudflared",ic=()=>{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"},fb=(s,e=ic())=>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/",fr=(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():hb(n),r=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():ic(),i=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():fb(n,r);return{provider:n,dependency:a,installCommand:i}},oc=s=>s==="cloudflare"?"Cloudflare":s==="ngrok"?"Ngrok":s,Xo=s=>{const e=nt.c(11),{provider:n}=s;let a;e[0]!==n?(a=oc(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 f;e[4]!==c?(f=t.jsx(D,{name:"cloud",className:c}),e[4]=c,e[5]=f):f=e[5];let u;e[6]!==r?(u=t.jsx("span",{children:r}),e[6]=r,e[7]=u):u=e[7];let p;return e[8]!==f||e[9]!==u?(p=t.jsxs("span",{className:"flex items-center gap-2",children:[f,u]}),e[8]=f,e[9]=u,e[10]=p):p=e[10],p},en=s=>s==="quick"?"quick":s==="managed-remote"?"managed-remote":s==="managed-local"?"managed-local":"quick",Br=(s,e,n)=>s.find(r=>r.ms===e)?.value||n,Zo=(s,e,n)=>{const a=Br(s,e,n);return s.find(r=>r.value===a)?.label||a},el=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`},xb=(s,e)=>El(s,e,{hour:"2-digit",precision:"second"}),Da=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()}},bb=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=Da(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},yb=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,vb=()=>{const{t:s}=it(),e=ze(ie=>ie.timeFormatPreference),n=l.useCallback(ie=>s(ie),[s]),[a,r]=l.useState("checking"),[i,o]=l.useState(null),[d,c]=l.useState(null),[f,u]=l.useState(null),[p,m]=l.useState(null),[P,g]=l.useState(null),[h,x]=l.useState(!1),[R,C]=l.useState(!1),[N,T]=l.useState(!1),[k,j]=l.useState("cloudflare"),[b,A]=l.useState(()=>fr("cloudflare")),[$,F]=l.useState([]),[I,v]=l.useState("quick"),[w,L]=l.useState(null),[E,_]=l.useState([]),[B,Z]=l.useState({}),[Q,M]=l.useState(""),[X,ee]=l.useState({}),[K,O]=l.useState(new Set),[Y,U]=l.useState(!1),[ne,re]=l.useState(""),[V,oe]=l.useState(""),[fe,xe]=l.useState(""),[Ie,ve]=l.useState(1800*1e3),[we,be]=l.useState(480*60*1e3),[se,le]=l.useState(""),[ye,H]=l.useState([]),[te,ae]=l.useState(()=>Date.now()),[me,Me]=l.useState(null),Ne=s(gb),De=l.useRef(null),Ee=l.useMemo(()=>w?!Jn(w):!1,[w]),Pe=l.useMemo(()=>E.find(ie=>ie.id===Q)||E[0]||null,[E,Q]),Te=l.useMemo(()=>ye.map(ie=>{const Ve=ie.expiresAt<=te,Qe=ie.status==="active"&&!Ve,Ge=Qe?el(ie.expiresAt-te):ie.inactiveReason==="expired"||Ve?"expired":"inactive",ut=Ge==="expired"?s("settings.openchamber.tunnel.state.expired"):ie.inactiveReason==="tunnel-revoked"?s("settings.openchamber.tunnel.state.revoked"):s("settings.openchamber.tunnel.state.inactive"),bt=en(ie.mode);return{...ie,isActive:Qe,mode:bt,remainingTextForSession:Ge,inactiveLabel:ut}}),[te,ye,s]),Le=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]),He=l.useMemo(()=>!i||a!=="active"||!d?!1:d!==I,[d,a,i,I]),Ue=l.useMemo(()=>{if(typeof me=="number"&&Number.isFinite(me)&&me>0)return me;if(typeof window>"u")return null;const Ve=Kn()||window.location.href;let Qe=0;try{Qe=Number(new URL(Ve).port)}catch{Qe=Number(window.location.port)}return Number.isFinite(Qe)&&Qe>0?Qe:null},[me]),Je=l.useMemo(()=>$.find(ie=>ie.provider===k)??null,[$,k]),de=l.useMemo(()=>{const ie=new Set(Je?.modes?.map(Ve=>Ve.key).filter(Ve=>Ve==="quick"||Ve==="managed-remote"||Ve==="managed-local"));return ie.size===0?hr:hr.filter(Ve=>ie.has(Ve.value))},[Je]),q=l.useMemo(()=>de.some(ie=>ie.value==="managed-remote"||ie.value==="managed-local"),[de]),ue=l.useMemo(()=>b.provider===k?b:fr(k),[b,k]),je=l.useCallback(async ie=>{await Ws(ie)},[]),Re=l.useCallback((ie,Ve)=>(A(fr(Ve,ie)),ie.available===!0),[]),Ce=l.useCallback(async(ie,Ve)=>{try{const Qe=await ht("/api/openchamber/tunnel/check",{query:{provider:ie},...Ve?{signal:Ve}:{}});if(!Qe.ok)return null;const Ge=await Qe.json();if(Ve?.aborted)return null;const ut=Re(Ge,ie);return r(bt=>bt==="checking"||bt==="starting"||bt==="active"||bt==="stopping"?bt:ut?"idle":"not-available"),ut}catch{return null}},[Re]),_e=l.useCallback(async ie=>{try{const[Ve,Qe,Ge,ut]=await Promise.all([ht("/api/openchamber/tunnel/check",{signal:ie}),ht("/api/openchamber/tunnel/status",{signal:ie}),ht("/api/config/settings",{signal:ie,headers:{Accept:"application/json"}}),ht("/api/openchamber/tunnel/providers",{signal:ie})]),bt=await Ve.json(),pt=await Qe.json(),Dt=Ge.ok?await Ge.json():{},qt=ut.ok?await ut.json():{},Yt=pt.ttlConfig?.bootstrapTtlMs??(Dt?.tunnelBootstrapTtlMs===null?null:typeof Dt?.tunnelBootstrapTtlMs=="number"?Dt.tunnelBootstrapTtlMs:1800*1e3),Zt=typeof pt.ttlConfig?.sessionTtlMs=="number"?pt.ttlConfig.sessionTtlMs:typeof Dt?.tunnelSessionTtlMs=="number"?Dt.tunnelSessionTtlMs:480*60*1e3,as=en(pt.mode??Dt?.tunnelMode),Ht=typeof Dt?.tunnelProvider=="string"&&Dt.tunnelProvider.trim().length>0?Dt.tunnelProvider.trim().toLowerCase():"cloudflare",es=typeof Dt?.managedLocalTunnelConfigPath=="string"&&Dt.managedLocalTunnelConfigPath.trim()||null,Se=Re(bt,Ht),yt=bb(pt?.managedRemoteTunnelPresets),jt=typeof pt.managedRemoteTunnelHostname=="string"?pt.managedRemoteTunnelHostname:"",Xe=yt.length>0?yt:jt?[{id:`legacy-${Da(jt)}`,name:jt,hostname:Da(jt)}]:[],Nt=Xe[0]?.id||"";if(ve(Yt),be(Zt),j(Ht),F(Array.isArray(qt?.providers)?qt.providers:[]),v(as),L(es),_(Xe),M(Nt),H(Array.isArray(pt.activeSessions)?pt.activeSessions:[]),c(pt.activeTunnelMode?en(pt.activeTunnelMode):pt.active&&pt.mode?en(pt.mode):null),O(new Set(Array.isArray(pt.managedRemoteTunnelTokenPresetIds)?pt.managedRemoteTunnelTokenPresetIds:[])),Me(typeof pt.localPort=="number"?pt.localPort:null),pt.active&&pt.url){o({url:pt.url,connectUrl:null,bootstrapExpiresAt:typeof pt.bootstrapExpiresAt=="number"?pt.bootstrapExpiresAt:null}),r("active");return}r(Se?"idle":"not-available")}catch{ie.aborted||(r("error"),m(s("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[Re,s]);l.useEffect(()=>{const ie=new AbortController;return _e(ie.signal),()=>ie.abort()},[_e]),l.useEffect(()=>{if(!i?.connectUrl){u(null);return}let ie=!1;return jl.toDataURL(i.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(Ve=>{ie||u(Ve)}).catch(()=>{ie||u(null)}),()=>{ie=!0}},[i?.connectUrl]),l.useEffect(()=>{if(!i?.bootstrapExpiresAt){le(s("settings.openchamber.tunnel.state.noExpiry"));return}let ie=null,Ve=Date.now();const Qe=()=>{const bt=i.bootstrapExpiresAt?i.bootstrapExpiresAt-Date.now():0;bt<=0?le(s("settings.openchamber.tunnel.state.expired")):le(el(bt))},Ge=()=>{const bt=Date.now();bt-Ve>=1e3&&(Qe(),Ve=bt),ie=requestAnimationFrame(Ge)};Qe(),(typeof document>"u"||document.visibilityState==="visible")&&(ie=requestAnimationFrame(Ge));const ut=()=>{document.visibilityState==="visible"&&ie===null?ie=requestAnimationFrame(Ge):document.visibilityState!=="visible"&&ie!==null&&(cancelAnimationFrame(ie),ie=null)};return document.addEventListener("visibilitychange",ut),()=>{document.removeEventListener("visibilitychange",ut),ie!==null&&cancelAnimationFrame(ie)}},[s,i?.bootstrapExpiresAt]),l.useEffect(()=>{let ie=null,Ve=Date.now();const Qe=()=>{const ut=Date.now();ut-Ve>=1e3&&(ae(ut),Ve=ut),ie=requestAnimationFrame(Qe)};(typeof document>"u"||document.visibilityState==="visible")&&(ie=requestAnimationFrame(Qe));const Ge=()=>{document.visibilityState==="visible"&&ie===null?ie=requestAnimationFrame(Qe):document.visibilityState!=="visible"&&ie!==null&&(cancelAnimationFrame(ie),ie=null)};return document.addEventListener("visibilitychange",Ge),()=>{document.removeEventListener("visibilitychange",Ge),ie!==null&&cancelAnimationFrame(ie)}},[]),l.useEffect(()=>{if(a==="starting"||a==="stopping"||a==="checking")return;let ie=!1;const Ve=async()=>{try{const Ge=await ht("/api/openchamber/tunnel/status");if(!Ge.ok||ie)return;const ut=await Ge.json();if(ie)return;H(Array.isArray(ut.activeSessions)?ut.activeSessions:[]),O(new Set(Array.isArray(ut.managedRemoteTunnelTokenPresetIds)?ut.managedRemoteTunnelTokenPresetIds:[])),Me(typeof ut.localPort=="number"?ut.localPort:null)}catch{}},Qe=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Ve()},5e3);return()=>{ie=!0,window.clearInterval(Qe)}},[a]);const J=l.useCallback(async ie=>{T(!0);try{await Pt(ie),Object.prototype.hasOwnProperty.call(ie,"tunnelMode")&&ie.tunnelMode&&v(ie.tunnelMode),Object.prototype.hasOwnProperty.call(ie,"tunnelProvider")&&typeof ie.tunnelProvider=="string"&&j(ie.tunnelProvider),Object.prototype.hasOwnProperty.call(ie,"managedLocalTunnelConfigPath")&&L(ie.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(ie,"managedRemoteTunnelPresets")&&ie.managedRemoteTunnelPresets&&_(ie.managedRemoteTunnelPresets)}catch{W.error(s("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{T(!1)}},[s]),y=l.useCallback(async(ie,Ve)=>{C(!0);try{await Pt({tunnelBootstrapTtlMs:ie,tunnelSessionTtlMs:Ve})}catch{W.error(s("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{C(!1)}},[s]),pe=l.useCallback(async ie=>{const Ve=ie.token.trim();if(Ve)try{const Qe={...X,[ie.presetId]:Ve};await Pt({managedRemoteTunnelPresetTokens:Qe}),O(Ge=>{const ut=new Set(Ge);return ut.add(ie.presetId),ut})}catch{W.error(s("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[X,s]),Ae=l.useCallback(async ie=>{g(null),m(null);const Ve=$.find(Ge=>Ge.provider===ie),Qe=Ve?.modes?.some(Ge=>Ge.key===I)?I:en(Ve?.modes?.[0]?.key);await J({tunnelProvider:ie,tunnelMode:Qe}),Ce(ie)},[$,Ce,J,I]),Oe=l.useCallback(async()=>{const ie=await Tl({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(ie.success&&typeof ie.path=="string"&&ie.path.trim().length>0){const Ve=ie.path.trim();if(!Jn(Ve)){W.error(Ne);return}L(Ve),await J({managedLocalTunnelConfigPath:Ve});return}De.current?.click()},[Ne,J]),qe=l.useCallback(ie=>{const Ve=ie.trim();L(Ve.length>0?Ve:null)},[]),at=l.useCallback(async()=>{if(w&&!Jn(w)){W.error(Ne);return}await J({managedLocalTunnelConfigPath:w})},[Ne,w,J]),rt=l.useCallback(async()=>{L(null),await J({managedLocalTunnelConfigPath:null})},[J]),st=l.useCallback(async ie=>{const Ve=ie.target.files?.[0];if(!Ve)return;const Qe=Ve.name.trim();if(Qe.length!==0){if(!Jn(Qe)){W.error(Ne);return}L(Qe),await J({managedLocalTunnelConfigPath:Qe}),ie.target.value=""}},[Ne,J]),dt=l.useCallback(async()=>{if(m(null),g(null),I==="managed-local"&&w&&!Jn(w)){m(Ne),W.error(Ne);return}r("starting");try{let ie="",Ve="";if(I==="managed-remote"){if(!Pe){r("idle"),g(s("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),W.error(s("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}ie=Pe.hostname,Ve=(X[Pe.id]||"").trim(),await J({tunnelMode:"managed-remote",managedRemoteTunnelPresets:E})}const Qe=await ht("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:k,mode:I,...I==="managed-remote"&&Pe?{managedRemoteTunnelPresetId:Pe.id,managedRemoteTunnelPresetName:Pe.name}:{},...I==="managed-remote"&&ie?{managedRemoteTunnelHostname:ie}:{},...I==="managed-remote"&&Ve?{managedRemoteTunnelToken:Ve}:{},...I==="managed-local"&&w?{configPath:w}:{}})}),Ge=await Qe.json();if(!Qe.ok||!Ge.ok){if(I==="managed-remote"&&typeof Ge.error=="string"&&Ge.error.includes("Managed remote tunnel token is required")){r("idle"),g(s("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),W.error(s("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}r("error"),m(Ge.error||s("settings.openchamber.tunnel.toast.startFailed")),W.error(Ge.error||s("settings.openchamber.tunnel.toast.startFailed"));return}const ut=typeof Ge.url=="string"?Ge.url:"";if(!ut){r("error"),m(s("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),W.error(s("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(o({url:ut,connectUrl:typeof Ge.connectUrl=="string"?Ge.connectUrl:null,bootstrapExpiresAt:typeof Ge.bootstrapExpiresAt=="number"?Ge.bootstrapExpiresAt:null}),c(Ge.activeTunnelMode?en(Ge.activeTunnelMode):Ge.mode?en(Ge.mode):I),H(Array.isArray(Ge.activeSessions)?Ge.activeSessions:[]),Array.isArray(Ge.managedRemoteTunnelTokenPresetIds)&&O(new Set(Ge.managedRemoteTunnelTokenPresetIds)),typeof Ge.localPort=="number"&&Me(Ge.localPort),typeof Ge.mode=="string"&&v(en(Ge.mode)),r("active"),Ge.replacedTunnel){const bt=typeof Ge.revokedBootstrapCount=="number"?Ge.revokedBootstrapCount:0,pt=typeof Ge.invalidatedSessionCount=="number"?Ge.invalidatedSessionCount:0;bt===1&&pt===1?W.warning(s("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):bt===1?W.warning(s("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:pt})):pt===1?W.warning(s("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:bt})):W.warning(s("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:bt,invalidatedSessionCount:pt}))}else W.success(s("settings.openchamber.tunnel.toast.linkReady"))}catch{r("error"),m(s("settings.openchamber.tunnel.toast.startFailed")),W.error(s("settings.openchamber.tunnel.toast.startFailed"))}},[Ne,E,J,Pe,X,s,k,I,w]),Ye=l.useCallback(async()=>{r("stopping");try{await ht("/api/openchamber/tunnel/stop",{method:"POST"});const ie=await ht("/api/openchamber/tunnel/status");if(ie.ok){const Ve=await ie.json();H(Array.isArray(Ve.activeSessions)?Ve.activeSessions:[]),O(new Set(Array.isArray(Ve.managedRemoteTunnelTokenPresetIds)?Ve.managedRemoteTunnelTokenPresetIds:[])),Me(typeof Ve.localPort=="number"?Ve.localPort:null)}o(null),c(null),u(null),r("idle"),W.success(s("settings.openchamber.tunnel.toast.stopped"))}catch{r("error"),m(s("settings.openchamber.tunnel.toast.stopFailed")),W.error(s("settings.openchamber.tunnel.toast.stopFailed"))}},[s]),$e=l.useCallback(async()=>{if(i?.connectUrl)try{await navigator.clipboard.writeText(i.connectUrl),x(!0),W.success(s("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>x(!1),2e3)}catch{W.error(s("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[s,i?.connectUrl]),mt=l.useCallback(async ie=>{const Ve=xa.find(Qe=>Qe.value===ie);Ve&&(ve(Ve.ms),await y(Ve.ms,we))},[y,we]),ge=l.useCallback(async ie=>{const Ve=ba.find(Qe=>Qe.value===ie);!Ve||Ve.ms===null||(be(Ve.ms),await y(Ie,Ve.ms))},[Ie,y]),et=l.useCallback(async ie=>{g(null),m(null),a!=="active"&&a!=="stopping"&&a!=="starting"&&r("idle"),await J({tunnelMode:ie,managedRemoteTunnelPresets:E})},[E,J,a]),tt=l.useCallback(async(ie,Ve)=>{try{await Pt({managedRemoteTunnelPresets:Ve})}catch{W.error(s("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[s]),We=l.useCallback(ie=>{const Ve=E.find(Qe=>Qe.id===ie);Ve&&(M(Ve.id),g(null),tt(Ve,E))},[E,tt]),xt=l.useCallback(async()=>{const ie=ne.trim(),Ve=Da(V),Qe=fe.trim();if(!ie){W.error(s("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!Ve){W.error(s("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!Qe){W.error(s("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(E.some(bt=>bt.hostname===Ve)){W.error(s("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Ge={id:yb(),name:ie,hostname:Ve},ut=[...E,Ge];_(ut),M(Ge.id),Z(bt=>({...bt,[Ge.id]:!0})),ee(bt=>({...bt,[Ge.id]:Qe})),g(null),U(!1),re(""),oe(""),xe(""),await J({tunnelMode:"managed-remote",managedRemoteTunnelPresets:ut,managedRemoteTunnelPresetTokens:{...X,[Ge.id]:Qe}}),await pe({presetId:Ge.id,presetName:Ge.name,hostname:Ge.hostname,token:Qe}),W.success(s("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[E,V,ne,fe,pe,J,X,s]),wt=l.useCallback(async ie=>{const Ve=E.find(pt=>pt.id===ie);if(!Ve)return;const Qe=E.filter(pt=>pt.id!==Ve.id),Ge=Qe[0]?.id||"",ut=Q===Ve.id?Ge:Q,bt=Object.fromEntries(Object.entries(X).filter(([pt,Dt])=>pt!==Ve.id&&Dt.trim().length>0));_(Qe),M(ut),Z(pt=>{const Dt={...pt};return delete Dt[Ve.id],Dt}),ee(pt=>{const Dt={...pt};return delete Dt[Ve.id],Dt}),O(pt=>{const Dt=new Set(pt);return Dt.delete(Ve.id),Dt}),g(null),await J({managedRemoteTunnelPresets:Qe,managedRemoteTunnelPresetTokens:bt}),W.success(s("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[E,J,Q,X,s]),St="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(D,{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(ie=>{const Ve=ie.mode==="quick",Qe=ie.mode==="managed-remote",Ge=Ve?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":Qe?"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)]",ut=ie.isActive?Ve?"text-[var(--status-warning)]":Qe?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",bt=s(Ve?"settings.openchamber.tunnel.badge.quick":Qe?"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(D,{name:"checkbox-blank-circle-fill",className:ce("size-2.5 shrink-0",ut)}),t.jsx("span",{className:ce("typography-micro rounded border px-1.5 py-0.5 uppercase",Ge),children:bt}),t.jsx("span",{className:"typography-meta text-muted-foreground/80",children:s("settings.openchamber.tunnel.session.redeemedAt",{time:xb(ie.createdAt,e)})}),t.jsx("span",{className:"typography-meta text-foreground",children:ie.isActive?s("settings.openchamber.tunnel.session.expiresIn",{remaining:ie.remainingTextForSession}):ie.inactiveLabel===s("settings.openchamber.tunnel.state.inactive")?s("settings.openchamber.tunnel.state.inactive"):s("settings.openchamber.tunnel.session.inactiveWithReason",{reason:ie.inactiveLabel})})]},ie.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(D,{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:ue.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:ue.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(Rt,{value:k,onValueChange:ie=>{Ae(ie)},disabled:N||a==="starting"||a==="stopping",children:[t.jsx(Tt,{className:"max-w-[16rem]",children:t.jsx(Lt,{placeholder:s("settings.openchamber.tunnel.field.providerPlaceholder"),children:oc(k)})}),t.jsxs(Ft,{children:[$.length>0?$.map(ie=>t.jsx(gt,{value:ie.provider,children:t.jsx(Xo,{provider:ie.provider})},ie.provider)):t.jsx(gt,{value:"cloudflare",children:t.jsx(Xo,{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:de.map(ie=>t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"chip",size:"xs","aria-pressed":I===ie.value,className:"!font-normal",onClick:()=>{et(ie.value)},disabled:N||a==="starting"||a==="stopping",children:n(ie.labelKey)})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:n(ie.tooltipKey)})]},ie.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(Rt,{value:Br(xa,Ie,"1800000"),onValueChange:ie=>{mt(ie)},disabled:R||N||a==="starting"||a==="stopping",children:[t.jsx(Tt,{className:"max-w-[11rem] min-w-0",children:t.jsx(Lt,{className:"truncate",children:Zo(xa,Ie,"1800000")})}),t.jsx(Ft,{children:xa.map(ie=>t.jsx(gt,{value:ie.value,children:ie.label},ie.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(Rt,{value:Br(ba,we,"28800000"),onValueChange:ie=>{ge(ie)},disabled:R||N||a==="starting"||a==="stopping",children:[t.jsx(Tt,{className:"max-w-[11rem] min-w-0",children:t.jsx(Lt,{className:"truncate",children:Zo(ba,we,"28800000")})}),t.jsx(Ft,{children:ba.map(ie=>t.jsx(gt,{value:ie.value,children:ie.label},ie.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(D,{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")}),q&&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 Ue=="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:",Ue]})]})}),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(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>U(ie=>!ie),disabled:a==="starting"||a==="stopping"||N,children:[t.jsx(D,{name:"add",className:"h-3.5 w-3.5"}),s("settings.common.actions.create")]})]}),E.length>0?t.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:E.map((ie,Ve)=>{const Qe=X[ie.id]||"",Ge=K.has(ie.id),ut=B[ie.id]??!1;return t.jsx("div",{className:ce(Ve<E.length-1&&"border-b border-[var(--surface-subtle)]"),children:t.jsxs(xn,{open:ut,onOpenChange:bt=>{Z(pt=>({...pt,[ie.id]:bt})),bt&&We(ie.id)},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2 px-3",children:[t.jsxs(bn,{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"||N,children:[ut?t.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(D,{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:ie.name})]}),t.jsx(G,{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:ie.name}),onClick:()=>{wt(ie.id)},disabled:a==="starting"||a==="stopping"||N,children:t.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(yn,{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:ie.hostname})]}),t.jsx(Ze,{type:"password",value:Qe,onChange:bt=>{const pt=bt.target.value;g(null),ee(Dt=>({...Dt,[ie.id]:pt}))},onBlur:bt=>{const pt=bt.currentTarget.value.trim();pt&&pe({presetId:ie.id,presetName:ie.name,hostname:ie.hostname,token:pt})},placeholder:s(Ge?"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(G,{variant:"ghost",size:"xs",className:"!font-normal",disabled:a==="starting"||a==="stopping"||Qe.trim().length===0,onClick:()=>{pe({presetId:ie.id,presetName:ie.name,hostname:ie.hostname,token:Qe})},children:s("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},ie.id)})}):t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),Y&&t.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[t.jsx(Ze,{value:ne,onChange:ie=>re(ie.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:N||a==="starting"||a==="stopping"}),t.jsx(Ze,{value:V,onChange:ie=>oe(ie.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:N||a==="starting"||a==="stopping"}),t.jsx(Ze,{type:"password",value:fe,onChange:ie=>xe(ie.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:N||a==="starting"||a==="stopping"}),typeof Ue=="number"&&t.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[s("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",t.jsxs("code",{children:["http://localhost:",Ue]}),"."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{xt()},disabled:N||a==="starting"||a==="stopping",children:s("settings.common.actions.saveChanges")}),t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{U(!1),re(""),oe(""),xe("")},disabled:N||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(It,{children:[t.jsx(At,{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(D,{name:"information",className:"h-3.5 w-3.5"})})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]})]}),!Pe&&P&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:P})]}),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:De,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:ie=>{st(ie)}}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ze,{value:w||"",onChange:ie=>{qe(ie.target.value)},onBlur:()=>{at()},placeholder:s("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:a==="starting"||a==="stopping"||N}),t.jsx(G,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Oe()},disabled:a==="starting"||a==="stopping"||N,children:t.jsx(D,{name:"folder",className:"size-3.5"})}),w&&t.jsx(G,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{rt()},disabled:a==="starting"||a==="stopping"||N,children:t.jsx(D,{name:"close",className:"size-3.5"})})]}),t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s(w?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),Ee&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Ne})]})}),!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(D,{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:()=>{je(mb)},children:[s("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),t.jsx(D,{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:()=>{je(ub)},children:[s("settings.openchamber.tunnel.actions.openManagedLocalDocs"),t.jsx(D,{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(hr.find(ie=>ie.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(Rt,{value:Q||(E[0]?.id??""),onValueChange:ie=>{We(ie)},disabled:N||a==="starting"||a==="stopping"||E.length<=1,children:[t.jsx(Tt,{children:t.jsx(Lt,{placeholder:s("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:Pe?.name})}),t.jsx(Ft,{fitContent:!0,children:E.map(ie=>t.jsx(gt,{value:ie.id,children:ie.name},ie.id))})]})]}),He&&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(D,{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(G,{size:"sm",variant:"outline",onClick:dt,disabled:a==="starting"||N||I==="managed-remote"&&!Pe||I==="managed-local"&&Ee,className:ce(St,a==="starting"&&"opacity-70"),children:a==="starting"?t.jsxs(t.Fragment,{children:[t.jsx(D,{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})]}),Le&&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(G,{size:"sm",variant:"ghost",onClick:$e,className:"shrink-0 gap-1.5",children:[h?t.jsx(D,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):t.jsx(D,{name:"file-copy",className:"size-3.5"}),s(h?"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:[f?t.jsx("img",{src:f,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(G,{size:"sm",variant:"outline",onClick:dt,disabled:a==="stopping"||N||I==="managed-local"&&Ee,className:St,children:[t.jsx(D,{name:"restart",className:"size-3.5"}),s("settings.openchamber.tunnel.actions.newConnectLink")]}),t.jsx(G,{size:"sm",variant:"ghost",onClick:Ye,disabled:a==="stopping"||N,className:"gap-2 text-[var(--status-error)]",children:a==="stopping"?t.jsxs(t.Fragment,{children:[t.jsx(D,{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(G,{size:"sm",variant:"ghost",onClick:dt,children:s("settings.openchamber.tunnel.actions.retry")})]})]})},lc=()=>{const{t:s}=it(),[e,n]=he.useState(""),[a,r]=he.useState(!0),[i,o]=he.useState(!1),d=ze(m=>m.showOpenCodeUpdateNotifications),c=ze(m=>m.setShowOpenCodeUpdateNotifications);he.useEffect(()=>{let m=!1;return(async()=>{try{const P=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!P.ok)return;const g=await P.json().catch(()=>null);if(m||!g)return;const h=typeof g.opencodeBinary=="string"?g.opencodeBinary.trim():"";n(h)}catch{}finally{m||r(!1)}})(),()=>{m=!0}},[]);const f=he.useCallback(async()=>{if(!(typeof window>"u")&&is())try{const m=await Tl();m.success&&m.path&&m.path.trim().length>0&&n(m.path.trim())}catch{}},[]),u=he.useCallback(async()=>{o(!0);try{const m=e.trim(),P=m.length>=2&&(m.startsWith('"')&&m.endsWith('"')||m.startsWith("'")&&m.endsWith("'"))?m.slice(1,-1).trim():m;await Pt({opencodeBinary:P}),await Mn({message:s("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}finally{o(!1)}},[s,e]),p=he.useCallback(m=>{c(m),Pt({showOpenCodeUpdateNotifications:m})},[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(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsxs(Et,{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(Ze,{value:e,onChange:m=>n(m.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(G,{type:"button",variant:"outline",size:"xs",onClick:f,disabled:a||i||!is(),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(D,{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(kt,{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(G,{type:"button",size:"xs",onClick:u,disabled:a||i,className:"shrink-0 !font-normal",children:s(i?"settings.common.actions.saving":"settings.openchamber.opencodeCli.actions.saveAndReload")})})]})]})},cc=()=>{const{t:s}=it(),e=is()&&zn(),[n,a]=he.useState(!1),[r,i]=he.useState(!1),[o,d]=he.useState(""),[c,f]=he.useState(""),[u,p]=he.useState(!1),[m,P]=he.useState(null),[g,h]=he.useState(!0),[x,R]=he.useState(!1),[C,N]=he.useState(!1),[T,k]=he.useState(!1),[j,b]=he.useState(!1),[A,$]=he.useState(!1),[F,I]=he.useState(!1),[v,w]=he.useState(!1),[L,E]=he.useState(null),[_,B]=he.useState(null);he.useEffect(()=>{if(!e){h(!1);return}let V=!1;return(async()=>{try{const oe=await ht("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!oe.ok)throw new Error(s("settings.openchamber.desktopNetwork.error.loadFailed"));const fe=await oe.json().catch(()=>null);if(V)return;const xe=fe?.desktopLanAccessEnabled===!0,Ie=typeof fe?.desktopUiPassword=="string"?fe.desktopUiPassword:"";a(xe),i(xe),d(Ie),f(Ie),p(fe?.desktopLanAccessActive===!0),P(typeof fe?.desktopLanAccessBlockedReason=="string"?fe.desktopLanAccessBlockedReason:null),E(null)}catch(oe){V||E(oe instanceof Error?oe.message:s("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{V||h(!1)}})(),()=>{V=!0}},[e,s]),he.useEffect(()=>{if(!e){N(!1);return}let V=!1;return(async()=>{const oe=await su();V||(N(oe?.supported===!0),k(oe?.enabled===!0))})(),()=>{V=!0}},[e]),he.useEffect(()=>{if(!e){$(!1);return}let V=!1;return(async()=>{const oe=await nu();V||($(oe?.supported===!0),I(oe?.enabled===!0))})(),()=>{V=!0}},[e]),he.useEffect(()=>{if(!e||!r){B(null);return}let V=!1;return(async()=>{const oe=await Rl();V||B(oe)})(),()=>{V=!0}},[r,e]);const Z=r!==n||c!==o,Q=he.useMemo(()=>{if(typeof window>"u")return null;const oe=Kn()||window.location.href;let fe=0;try{fe=Number(new URL(oe).port)}catch{fe=Number(window.location.port)}return Number.isFinite(fe)&&fe>0?fe:null},[]),M=r&&u&&_&&Q?`http://${_}:${Q}`:null,X=r&&!c.trim(),ee=n&&!u&&m==="missing-password",K=g||x||!Z||X,O=he.useCallback(()=>{i(V=>!V)},[]),Y=he.useCallback(V=>{f(V),V.trim()||i(!1)},[]),U=he.useCallback(async()=>{if(!C||j)return;const V=!T;k(V),b(!0),E(null);try{const oe=await au(V);if(!oe?.supported)throw new Error(s("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));k(oe.enabled)}catch(oe){k(!V),E(oe instanceof Error?oe.message:s("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{b(!1)}},[j,T,C,s]),ne=he.useCallback(async()=>{if(!A||v)return;const V=!F;I(V),w(!0),E(null);try{const oe=await ru(V);if(!oe?.supported)throw new Error(s("settings.openchamber.desktopNetwork.error.keepAwakeUnsupported"));I(oe.enabled)}catch(oe){I(!V),E(oe instanceof Error?oe.message:s("settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed"))}finally{w(!1)}},[v,F,A,s]),re=he.useCallback(async()=>{if(Z){R(!0),E(null);try{if(!(await ht("/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 iu())throw new Error(s("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(V){E(V instanceof Error?V.message:s("settings.openchamber.desktopNetwork.error.saveFailed")),R(!1)}}},[c,r,Z,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:[C?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:U,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),U())},children:[t.jsx(kt,{checked:T,onChange:U,ariaLabel:s("settings.openchamber.desktopNetwork.field.launchAtLoginAria"),disabled:j}),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,A?t.jsxs("div",{"data-settings-item":"sessions.desktop-keep-awake",className:"group flex cursor-pointer items-start gap-2 py-1.5",role:"button",tabIndex:0,onClick:ne,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),ne())},children:[t.jsx(kt,{checked:F,onChange:ne,ariaLabel:s("settings.openchamber.desktopNetwork.field.keepAwakeAria"),disabled:v}),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.keepAwake")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopNetwork.field.keepAwakeDescription")})]})]}):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(Ze,{id:"desktop-ui-password",type:"password",className:"h-7 max-w-sm",value:c,onChange:V=>Y(V.target.value),placeholder:s("settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:g||x,required:r,"aria-invalid":X}),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:O,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),O())},children:[t.jsx(kt,{checked:r,onChange:O,ariaLabel:s("settings.openchamber.desktopNetwork.field.allowLanAccessAria"),disabled:g||x}),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")}),X||ee?t.jsx("div",{className:"typography-micro text-[var(--status-warning)]/85",children:s("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]})]}),L?t.jsx("div",{className:"px-2 typography-micro text-[var(--status-error)]",children:L}):null,M?t.jsxs("div",{className:"px-2 typography-micro text-muted-foreground/80",children:[s(Z&&!n?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),t.jsx("span",{className:"font-mono text-foreground",children:M})]}):null,t.jsx("div",{className:"flex justify-start py-1.5",children:t.jsx(G,{type:"button",size:"xs",onClick:re,disabled:K,className:"shrink-0 !font-normal",children:s(x?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})})]})]}):null},jb=new Set(["shift","control","alt","meta"]),wb=s=>{if(jb.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=Dm(s.key);return n?(e.push(n),Pn(e.join("+"))):null},Nb=()=>{const s=nt.c(61),{t:e}=it();let n;s[0]!==e?(n=V=>e(V),s[0]=e,s[1]=n):n=s[1];const a=n,r=ze(kb),i=ze(Sb),o=ze(Cb),d=ze(Pb);let c;s[2]===Symbol.for("react.memo_cache_sentinel")?(c=Im(),s[2]=c):c=s[2];const f=c;let u;s[3]!==a?(u=(V,oe)=>{const fe=`settings.openchamber.keyboardShortcuts.action.${V}.label`,xe=a(fe);return xe===fe?oe:xe},s[3]=a,s[4]=u):u=s[4];const p=u,[m,P]=l.useState(null);let g;s[5]===Symbol.for("react.memo_cache_sentinel")?(g={},s[5]=g):g=s[5];const[h,x]=l.useState(g),[R,C]=l.useState(""),[N,T]=l.useState(""),[k,j]=l.useState(null),b=Ib;let A;s[6]!==r?(A=(V,oe)=>{const fe=Pn(oe);for(const xe of f){if(xe.id===V)continue;const Ie=ji(xe.id,r);if(Pn(Ie)===fe)return xe.id}return null},s[6]=r,s[7]=A):A=s[7];const $=A;let F;s[8]!==$||s[9]!==i||s[10]!==r||s[11]!==e?(F=(V,oe)=>{const fe=Pn(oe),xe=$(V,fe);if(xe){j({actionId:V,combo:fe,conflictActionId:xe}),C("");return}const Ie={...r,[V]:fe};i(V,fe),b(Ie),j(null),C(""),T(wi(fe)?e("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut"):""),x(ve=>{const we={...ve};return delete we[V],we})},s[8]=$,s[9]=i,s[10]=r,s[11]=e,s[12]=F):F=s[12];const I=F;let v;s[13]!==k||s[14]!==i||s[15]!==r||s[16]!==e?(v=()=>{if(!k)return;const V={...r,[k.conflictActionId]:Ni,[k.actionId]:k.combo};i(k.conflictActionId,Ni),i(k.actionId,k.combo),b(V),j(null),C(""),T(wi(k.combo)?e("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut"):""),x(oe=>{const fe={...oe};return delete fe[k.actionId],fe})},s[13]=k,s[14]=i,s[15]=r,s[16]=e,s[17]=v):v=s[17];const w=v;let L;s[18]!==o||s[19]!==r?(L=V=>{const oe={...r};delete oe[V],o(V),b(oe),x(fe=>{const xe={...fe};return delete xe[V],xe}),j(null),C(""),T("")},s[18]=o,s[19]=r,s[20]=L):L=s[20];const E=L;let _;s[21]!==e?(_=e("settings.openchamber.keyboardShortcuts.title"),s[21]=e,s[22]=_):_=s[22];let B;s[23]!==_?(B=t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:_}),s[23]=_,s[24]=B):B=s[24];let Z;s[25]!==d?(Z=()=>{d(),b({}),x({}),j(null),C(""),T("")},s[25]=d,s[26]=Z):Z=s[26];let Q;s[27]!==e?(Q=e("settings.openchamber.keyboardShortcuts.actions.resetAll"),s[27]=e,s[28]=Q):Q=s[28];let M;s[29]!==Z||s[30]!==Q?(M=t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Z,children:Q}),s[29]=Z,s[30]=Q,s[31]=M):M=s[31];let X;s[32]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(At,{asChild:!0,children:t.jsx(D,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),s[32]=X):X=s[32];let ee;s[33]!==e?(ee=e("settings.openchamber.keyboardShortcuts.tooltip"),s[33]=e,s[34]=ee):ee=s[34];let K;s[35]!==ee?(K=t.jsxs(It,{children:[X,t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:ee})]}),s[35]=ee,s[36]=K):K=s[36];let O;s[37]!==M||s[38]!==K||s[39]!==B?(O=t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[B,M,K]})}),s[37]=M,s[38]=K,s[39]=B,s[40]=O):O=s[40];let Y;s[41]!==w||s[42]!==R||s[43]!==k||s[44]!==e||s[45]!==N?(Y=(R||N||k)&&t.jsxs("div",{className:"mb-2 space-y-2 px-1",children:[k&&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(G,{type:"button",size:"xs",className:"!font-normal",onClick:w,children:e("settings.openchamber.keyboardShortcuts.actions.overwrite")}),t.jsx(G,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>j(null),children:e("settings.common.actions.cancel")})]})]}),R&&t.jsx("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground",children:R}),N&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground",children:N})]}),s[41]=w,s[42]=R,s[43]=k,s[44]=e,s[45]=N,s[46]=Y):Y=s[46];let U;s[47]!==p||s[48]!==m||s[49]!==h||s[50]!==E||s[51]!==I||s[52]!==r||s[53]!==e?(U=f.map((V,oe)=>{const fe=ji(V.id,r),xe=h[V.id],Ie=xe??fe,ve=typeof xe=="string"&&Pn(xe)!==Pn(fe);return t.jsxs("div",{className:ce("flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",oe>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(V.id,V.label)})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsx(Ze,{readOnly:!0,value:m===V.id?e("settings.openchamber.keyboardShortcuts.field.pressKeys"):Am(Ie),onFocus:()=>{P(V.id),C("")},onBlur:()=>{m===V.id&&P(null)},onKeyDown:we=>{if(we.preventDefault(),we.stopPropagation(),we.key==="Escape"){P(null);return}const be=wb(we);be&&(x(se=>({...se,[V.id]:be})),P(null),j(null),C(""))},className:"h-7 w-40 min-w-0 typography-ui-label text-center"}),t.jsx(G,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{const we=h[V.id];if(!we){C(e("settings.openchamber.keyboardShortcuts.error.captureFirst"));return}I(V.id,we)},disabled:!ve,children:e("settings.common.actions.saveChanges")}),t.jsx(G,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>E(V.id),children:e("settings.common.actions.reset")})]})]},V.id)}),s[47]=p,s[48]=m,s[49]=h,s[50]=E,s[51]=I,s[52]=r,s[53]=e,s[54]=U):U=s[54];let ne;s[55]!==U?(ne=t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:U}),s[55]=U,s[56]=ne):ne=s[56];let re;return s[57]!==O||s[58]!==Y||s[59]!==ne?(re=t.jsxs("div",{"data-settings-item":"shortcuts.keyboard-shortcuts",className:"mb-8",children:[O,Y,ne]}),s[57]=O,s[58]=Y,s[59]=ne,s[60]=re):re=s[60],re};function kb(s){return s.shortcutOverrides}function Sb(s){return s.setShortcutOverride}function Cb(s){return s.clearShortcutOverride}function Pb(s){return s.resetAllShortcutOverrides}function Ib(s){Pt({shortcutOverrides:s})}const dc=()=>{const s=nt.c(2),[e,n]=l.useState(0);let a,r;return s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>ou(()=>n(Kb)),r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),l.useEffect(a,r),e},Ab=s=>{const e=nt.c(20),{section:n}=s,{isMobile:a}=Cs();dc();let r;e[0]!==a?(r=a&&gn(),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=is()&&zn(),e[3]=c):c=e[3];const f=c;if(!n){let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(ei,{}),e[4]=g):g=e[4];let h,x,R;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(rc,{})}),x=f&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(cc,{})}),R=!d&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(lc,{})}),e[5]=h,e[6]=x,e[7]=R):(h=e[5],x=e[6],R=e[7]);let C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(nc,{})}),e[8]=C):C=e[8];let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(ac,{})}),e[9]=N):N=e[9];let T;e[10]!==i?(T=i&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Ol,{})}),e[10]=i,e[11]=T):T=e[11];let k;return e[12]!==T?(k=t.jsx(Wt,{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:[g,h,x,R,C,N,T]})}),e[12]=T,e[13]=k):k=e[13],k}let u;e[14]!==n?(u=()=>{switch(n){case"visual":return t.jsx(Eb,{});case"chat":return t.jsx(Mb,{});case"sessions":return t.jsx(Rb,{});case"shortcuts":return t.jsx(Db,{});case"git":return t.jsx(Tb,{});case"github":return t.jsx(Fb,{});case"notifications":return t.jsx(Lb,{});case"voice":return t.jsx(Ob,{});case"tunnel":return t.jsx(zb,{});default:return null}},e[14]=n,e[15]=u):u=e[15];const p=u;let m;e[16]!==p?(m=p(),e[16]=p,e[17]=m):m=e[17];let P;return e[18]!==m?(P=t.jsx(Wt,{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:m})}),e[18]=m,e[19]=P):P=e[19],P},Db=()=>{const s=nt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Nb,{}),s[0]=e):e=s[0],e},Eb=()=>{const s=nt.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(ei,{visibleSettings:["theme","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a,"fontSize","terminalFontSize","fileEditorKeymap","spacing","inputBarOffset","expandedEditorToolbar",...n?[]:["terminalQuickKeys"],"reportUsage"]}),s[2]=r):r=s[2],r},Mb=()=>{const s=nt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(ei,{visibleSettings:["chatRenderMode","messageTransport","activityRenderMode","userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","expandedTools","collapsibleUserMessages","stickyUserHeader","wideChatLayout","splitAssistantMessageActions","diffLayout","dotfiles","fileViewerPreview","followUpBehavior","persistDraft","inputSpellcheck"]}),s[0]=e):e=s[0],e},Rb=()=>{const s=nt.c(7);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs(),s[0]=e):e=s[0];const n=e;dc();let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=is()&&zn(),s[1]=a):a=s[1];const r=a;let i,o,d;s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(rc,{}),o=r&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(cc,{})}),d=!n&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(lc,{})}),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(nc,{})}),s[5]=c):c=s[5];let f;return s[6]===Symbol.for("react.memo_cache_sentinel")?(f=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(ac,{})})]}),s[6]=f):f=s[6],f},Tb=()=>{const s=nt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"space-y-6",children:t.jsx(ec,{})}),s[0]=e):e=s[0],e},Fb=()=>{const s=nt.c(1);if(fs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(tc,{}),s[0]=e):e=s[0],e},Lb=()=>{const s=nt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(rb,{}),s[0]=e):e=s[0],e},Ob=()=>{const s=nt.c(1);if(fs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(db,{}),s[0]=e):e=s[0],e},zb=()=>{const s=nt.c(1);if(fs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(vb,{}),s[0]=e):e=s[0],e};function Kb(s){return s+1}const mc=[{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}],$b={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function En(s){const e=s.trim().toLowerCase();return mc.find(n=>n.slug===e)??null}function ti(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=$b[e];if(n)return n;const a=En(e);return a?a.slug:"home"}const Ub=[{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.follow-up-behavior",page:"chat",titleKey:"settings.openchamber.visual.section.followUpBehavior",descriptionKey:"settings.openchamber.visual.field.followUpBehaviorDescription",keywords:["follow up","queue","steer","send immediately"]},{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-keep-awake",page:"sessions",titleKey:"settings.openchamber.desktopNetwork.field.keepAwake",descriptionKey:"settings.openchamber.desktopNetwork.field.keepAwakeDescription",keywords:["desktop","sleep","awake","server","mobile","phone"],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","additional headers","request headers","cloudflare access","service token"],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.playback",page:"voice",titleKey:"settings.voice.page.section.playbackAndSummary",keywords:["tts","read aloud","voice","provider","speech rate","speech pitch","speech volume","tts input mode","markdown"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","dictation","voice input","transcribe","whisper","parakeet","microphone"]},{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 tl(s){return s.trim().toLocaleLowerCase()}function Bb({query:s,runtimeCtx:e,visiblePageSlugs:n,t:a,getPageTitle:r}){const i=tl(s);if(!i)return[];const o=n?new Set(n):null,d=i.split(/\s+/).filter(Boolean);return Ub.flatMap(c=>{if(o&&!o.has(c.page))return[];const f=En(c.page);if(!f||f.isAvailable&&!f.isAvailable(e)||c.isAvailable&&!c.isAvailable(e))return[];const u=a(c.titleKey),p=c.descriptionKey?a(c.descriptionKey):null,m=tl([u,p,r(c.page),...c.keywords??[]].filter(Boolean).join(" "));return d.every(P=>m.includes(P))?[{...c,title:u,description:p,pageTitle:r(c.page)}]:[]})}const Vr=176,_r=280,sl=8,uc="__openchamberSettingsDetail";function xr(s){return Math.min(_r,Math.max(Vr,s))}const Vb=["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"],_b={icon:"chat-thread"},Hb="__add_provider__";function Wb(s,e){const n=fs(),a=!s&&gn();return{isVSCode:n,isWeb:a,isDesktop:s,isMobile:e}}function nl(s,e){return s.isAvailable?s.isAvailable(e):!0}function Hr(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 br(s){if(!Hr(s))return null;const e=s[uc];if(!Hr(e))return null;const n=e.page,a=e.stage;return typeof n!="string"||a!=="page-content"?null:{page:ti(n),stage:a}}function qb(){return typeof window>"u"||!Hr(window.history.state)?{}:window.history.state}function pc(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 _b.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 yr=s=>{const e=nt.c(95),{onOpen:n}=s,{t:a}=it();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 f;e[11]!==n?(f=()=>n("providers"),e[11]=n,e[12]=f):f=e[12];let u;e[13]===Symbol.for("react.memo_cache_sentinel")?(u=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[13]=u):u=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 m;e[16]!==p?(m=t.jsx("div",{className:"typography-ui-label text-foreground",children:p}),e[16]=p,e[17]=m):m=e[17];let P;e[18]!==a?(P=a("settings.view.home.cards.providers.description"),e[18]=a,e[19]=P):P=e[19];let g;e[20]!==P?(g=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:P}),e[20]=P,e[21]=g):g=e[21];let h;e[22]!==g||e[23]!==f||e[24]!==m?(h=t.jsxs("button",{type:"button",onClick:f,className:u,children:[m,g]}),e[22]=g,e[23]=f,e[24]=m,e[25]=h):h=e[25];let x;e[26]!==n?(x=()=>n("agents"),e[26]=n,e[27]=x):x=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[28]=R):R=e[28];let C;e[29]!==a?(C=a("settings.view.home.cards.agents.title"),e[29]=a,e[30]=C):C=e[30];let N;e[31]!==C?(N=t.jsx("div",{className:"typography-ui-label text-foreground",children:C}),e[31]=C,e[32]=N):N=e[32];let T;e[33]!==a?(T=a("settings.view.home.cards.agents.description"),e[33]=a,e[34]=T):T=e[34];let k;e[35]!==T?(k=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:T}),e[35]=T,e[36]=k):k=e[36];let j;e[37]!==x||e[38]!==N||e[39]!==k?(j=t.jsxs("button",{type:"button",onClick:x,className:R,children:[N,k]}),e[37]=x,e[38]=N,e[39]=k,e[40]=j):j=e[40];let b;e[41]!==n?(b=()=>n("skills.catalog"),e[41]=n,e[42]=b):b=e[42];let A;e[43]===Symbol.for("react.memo_cache_sentinel")?(A=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[43]=A):A=e[43];let $;e[44]!==a?($=a("settings.view.home.cards.skillsCatalog.title"),e[44]=a,e[45]=$):$=e[45];let F;e[46]!==$?(F=t.jsx("div",{className:"typography-ui-label text-foreground",children:$}),e[46]=$,e[47]=F):F=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 w;e[52]!==b||e[53]!==F||e[54]!==v?(w=t.jsxs("button",{type:"button",onClick:b,className:A,children:[F,v]}),e[52]=b,e[53]=F,e[54]=v,e[55]=w):w=e[55];let L;e[56]!==n?(L=()=>n("mcp"),e[56]=n,e[57]=L):L=e[57];let E;e[58]===Symbol.for("react.memo_cache_sentinel")?(E=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[58]=E):E=e[58];let _;e[59]!==a?(_=a("settings.view.home.cards.mcp.title"),e[59]=a,e[60]=_):_=e[60];let B;e[61]!==_?(B=t.jsx("div",{className:"typography-ui-label text-foreground",children:_}),e[61]=_,e[62]=B):B=e[62];let Z;e[63]!==a?(Z=a("settings.view.home.cards.mcp.description"),e[63]=a,e[64]=Z):Z=e[64];let Q;e[65]!==Z?(Q=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:Z}),e[65]=Z,e[66]=Q):Q=e[66];let M;e[67]!==L||e[68]!==B||e[69]!==Q?(M=t.jsxs("button",{type:"button",onClick:L,className:E,children:[B,Q]}),e[67]=L,e[68]=B,e[69]=Q,e[70]=M):M=e[70];let X;e[71]!==n?(X=()=>n("usage"),e[71]=n,e[72]=X):X=e[72];let ee;e[73]===Symbol.for("react.memo_cache_sentinel")?(ee=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[73]=ee):ee=e[73];let K;e[74]!==a?(K=a("settings.view.home.cards.usage.title"),e[74]=a,e[75]=K):K=e[75];let O;e[76]!==K?(O=t.jsx("div",{className:"typography-ui-label text-foreground",children:K}),e[76]=K,e[77]=O):O=e[77];let Y;e[78]!==a?(Y=a("settings.view.home.cards.usage.description"),e[78]=a,e[79]=Y):Y=e[79];let U;e[80]!==Y?(U=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:Y}),e[80]=Y,e[81]=U):U=e[81];let ne;e[82]!==X||e[83]!==O||e[84]!==U?(ne=t.jsxs("button",{type:"button",onClick:X,className:ee,children:[O,U]}),e[82]=X,e[83]=O,e[84]=U,e[85]=ne):ne=e[85];let re;e[86]!==h||e[87]!==j||e[88]!==w||e[89]!==M||e[90]!==ne?(re=t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[h,j,w,M,ne]}),e[86]=h,e[87]=j,e[88]=w,e[89]=M,e[90]=ne,e[91]=re):re=e[91];let V;return e[92]!==re||e[93]!==c?(V=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,re]})}),e[92]=re,e[93]=c,e[94]=V):V=e[94],V},Gb=s=>{const e=nt.c(127),{onClose:n,forceMobile:a,isWindowed:r,visiblePageSlugs:i,initialMobileStage:o}=s,d=o===void 0?"nav":o,{t:c}=it(),f=Cs(),u=a??f.isMobile,p=ze(Jb),m=ze(Qb),P=ze(Yb);let g;e[0]!==p?(g=ti(p),e[0]=p,e[1]=g):g=e[1];const h=g,[x,R]=l.useState(d),C=l.useRef(null),[N,T]=l.useState(216),[k,j]=l.useState(""),[b,A]=l.useState(null),[$,F]=l.useState(0),[I,v]=l.useState(!1),[w,L]=l.useState(!1),E=l.useRef(0),_=l.useRef(N),B=l.useRef(null);let Z;e[2]===Symbol.for("react.memo_cache_sentinel")?(Z=[],e[2]=Z):Z=e[2];const Q=l.useRef(Z),M=l.useRef(0),X=l.useRef(!1);let ee;e[3]===Symbol.for("react.memo_cache_sentinel")?(ee=is(),e[3]=ee):ee=e[3];const K=ee;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=is()&&zn(),e[4]=O):O=e[4];const Y=O;let U;e[5]===Symbol.for("react.memo_cache_sentinel")?(U=is()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",e[5]=U):U=e[5];const ne=U;let re;e[6]!==u?(re=Wb(K,u),e[6]=u,e[7]=re):re=e[7];const V=re;let oe;if(e[8]!==u||e[9]!==V||e[10]!==i){const ct=i?new Set(i):null;let ke;e[12]!==V?(ke=Gt=>nl(Gt,V),e[12]=V,e[13]=ke):ke=e[13];let Ct;e[14]!==V.isVSCode?(Ct=Gt=>!(V.isVSCode&&Gt.slug==="projects"),e[14]=V.isVSCode,e[15]=Ct):Ct=e[15];let Xt;e[16]!==u?(Xt=Gt=>!(u&&Gt.slug==="shortcuts"),e[16]=u,e[17]=Xt):Xt=e[17],oe=mc.filter(Xb).filter(Gt=>!ct||ct.has(Gt.slug)).filter(ke).filter(Ct).filter(Xt),e[8]=u,e[9]=V,e[10]=i,e[11]=oe}else oe=e[11];const fe=oe;let xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=new Map(Vb.map(Zb)),e[18]=xe):xe=e[18];const Ie=xe;let ve;if(e[19]!==fe){let ct;e[21]===Symbol.for("react.memo_cache_sentinel")?(ct=(ke,Ct)=>(Ie.get(ke.slug)??999)-(Ie.get(Ct.slug)??999),e[21]=ct):ct=e[21],ve=fe.slice().sort(ct),e[19]=fe,e[20]=ve}else ve=e[20];const we=ve,be=ns(ey);let se,le;e[22]!==I?(se=()=>{if(typeof window>"u")return;const ct=()=>{if(!I){const ke=xr(Math.floor(window.innerWidth*.12));T(ke)}};return window.addEventListener("resize",ct),()=>window.removeEventListener("resize",ct)},le=[I],e[22]=I,e[23]=se,e[24]=le):(se=e[23],le=e[24]),l.useEffect(se,le);let ye,H;e[25]!==w?(ye=()=>{if(!w)return;const ct=Ct=>{const Xt=Ct.clientX-E.current,Gt=xr(_.current+Xt);T(Gt),v(!0)},ke=()=>L(!1);return window.addEventListener("pointermove",ct),window.addEventListener("pointerup",ke,{once:!0}),()=>{window.removeEventListener("pointermove",ct),window.removeEventListener("pointerup",ke)}},H=[w],e[25]=w,e[26]=ye,e[27]=H):(ye=e[26],H=e[27]),l.useEffect(ye,H);let te;e[28]!==N?(te=ct=>{L(!0),E.current=ct.clientX,_.current=N,ct.preventDefault()},e[28]=N,e[29]=te):te=e[29];const ae=te;let me;e[30]!==N?(me=ct=>{const ke=ct.shiftKey?sl*4:sl;let Ct;e:switch(ct.key){case"ArrowLeft":{Ct=N-ke;break e}case"ArrowRight":{Ct=N+ke;break e}case"Home":{Ct=Vr;break e}case"End":{Ct=_r;break e}default:return}ct.preventDefault(),T(xr(Ct)),v(!0)},e[30]=N,e[31]=me):me=e[31];const Me=me;let Ne;e[32]!==m||e[33]!==r||e[34]!==V.isVSCode||e[35]!==h?(Ne=()=>{if(!(!m&&!V.isVSCode&&!r)){if(h==="agents"){Ka.getState().loadAgents();return}if(h==="commands"){$a.getState().loadCommands();return}if(h==="mcp"){Ln.getState().loadMcpConfigs();return}if(h==="plugins"){ls.getState().loadPlugins();return}(h==="skills.installed"||h==="skills.catalog")&&(Hs.getState().loadSkills(),Vs.getState().loadCatalog()),h==="snippets"&&Ba.getState().loadSnippets()}},e[32]=m,e[33]=r,e[34]=V.isVSCode,e[35]=h,e[36]=Ne):Ne=e[36];let De;e[37]!==be||e[38]!==m||e[39]!==r||e[40]!==V.isVSCode||e[41]!==h?(De=[be,m,r,V.isVSCode,h],e[37]=be,e[38]=m,e[39]=r,e[40]=V.isVSCode,e[41]=h,e[42]=De):De=e[42],l.useEffect(Ne,De);let Ee;e[43]!==u||e[44]!==P?(Ee=ct=>{if(P(ct),C.current=ct,!u)return;const ke=En(ct);if(!ke||ke.slug==="home"){R("nav");return}R(ke.kind==="split"?"page-sidebar":"page-content")},e[43]=u,e[44]=P,e[45]=Ee):Ee=e[45];const Pe=Ee;let Te;e[46]!==h?(Te=En(h),e[46]=h,e[47]=Te):Te=e[47];const Le=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 He=Be;let Ue;e[49]!==c?(Ue=ct=>{switch(ct){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]=Ue):Ue=e[50];const Je=Ue;let de;e[51]!==Je||e[52]!==V||e[53]!==k||e[54]!==c||e[55]!==i?(de=Bb({query:k,runtimeCtx:{...V,isDesktopLocalOrigin:Y,isMac:ne},visiblePageSlugs:i,t:c,getPageTitle:Je}),e[51]=Je,e[52]=V,e[53]=k,e[54]=c,e[55]=i,e[56]=de):de=e[56];const q=de,ue=iy;let je;if(e[57]!==q){je=[];const ct=new Map;for(const ke of q){let Ct=ct.get(ke.page);Ct||(Ct={page:ke.page,pageTitle:ke.pageTitle,results:[]},ct.set(ke.page,Ct),je.push(Ct)),Ct.results.push(ke)}e[57]=q,e[58]=je}else je=e[58];const Re=je;let Ce;e[59]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>{F(0),M.current=0,X.current=!1},e[59]=Ce):Ce=e[59];let _e;e[60]!==k?(_e=[k],e[60]=k,e[61]=_e):_e=e[61],l.useEffect(Ce,_e);let J,y;e[62]!==$?(J=()=>{M.current=$},y=[$],e[62]=$,e[63]=J,e[64]=y):(J=e[63],y=e[64]),l.useEffect(J,y);let pe,Ae;e[65]!==$?(pe=()=>{Q.current[$]?.scrollIntoView({block:"nearest"})},Ae=[$],e[65]=$,e[66]=pe,e[67]=Ae):(pe=e[66],Ae=e[67]),l.useEffect(pe,Ae);let Oe,qe;e[68]!==$||e[69]!==q.length?(Oe=()=>{$>=q.length&&F(Math.max(0,q.length-1)),Q.current.length=q.length},qe=[$,q.length],e[68]=$,e[69]=q.length,e[70]=Oe,e[71]=qe):(Oe=e[70],qe=e[71]),l.useEffect(Oe,qe);let at;e[72]!==u||e[73]!==Pe?(at=ct=>{const ke=ue(ct);A(ke),Pe(ct.page),u&&R("page-content"),ct.id==="plugins.create"&&typeof window<"u"&&window.setTimeout(oy,50)},e[72]=u,e[73]=Pe,e[74]=at):at=e[74];const rt=at;let st;e[75]!==rt||e[76]!==k||e[77]!==q?(st=ct=>{if(k.trim()){if(ct.key==="Escape"){ct.preventDefault(),j("");return}if(q.length!==0){if(ct.key==="ArrowDown"){ct.preventDefault(),X.current=!0,F(ke=>(ke+1)%q.length);return}if(ct.key==="ArrowUp"){ct.preventDefault(),X.current=!0,F(ke=>(ke-1+q.length)%q.length);return}if(ct.key==="Enter"){ct.preventDefault();const ke=(M.current%q.length+q.length)%q.length,Ct=q[ke]??q[0];Ct&&rt(Ct)}}}},e[75]=rt,e[76]=k,e[77]=q,e[78]=st):st=e[78];const dt=st;let Ye;e[79]!==b?(Ye=()=>{const ct=b;if(!ct)return;let ke=!1;const Ct=window.requestAnimationFrame(()=>{if(ke)return;const Xt=typeof CSS<"u"&&CSS.escape?CSS.escape(ct):ct.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Gt=B.current?.querySelector(`[data-settings-item="${Xt}"]`);Gt&&(A(null),Gt.scrollIntoView({block:"center",behavior:"smooth"}),Gt.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Gt.removeAttribute("data-settings-search-highlight")},1600))});return()=>{ke=!0,window.cancelAnimationFrame(Ct)}},e[79]=b,e[80]=Ye):Ye=e[80];let $e;e[81]!==b||e[82]!==h?($e=[b,h],e[81]=b,e[82]=h,e[83]=$e):$e=e[83],l.useEffect(Ye,$e);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 ge=mt,et=ly;let tt;e[86]!==Pe||e[87]!==ge||e[88]!==V?(tt=ct=>{const ke=En(ct);if(ke&&!nl(ke,V))return ge();switch(ct){case"home":return t.jsx(yr,{onOpen:Pe});case"projects":return t.jsx(af,{});case"remote-instances":return t.jsx(Af,{});case"agents":return t.jsx(mp,{});case"behavior":return t.jsx(fp,{});case"commands":return t.jsx(Sp,{});case"mcp":return t.jsx(tg,{});case"plugins":return t.jsx(Ug,{});case"skills.installed":return t.jsx(Io,{view:"installed"});case"skills.catalog":return t.jsx(Io,{view:"catalog"});case"providers":return t.jsx(zf,{});case"usage":return t.jsx(bx,{});case"about":return t.jsx("div",{className:"h-full overflow-auto px-5 py-6",children:t.jsx(Ol,{})});case"magic-prompts":return t.jsx(Nx,{});case"snippets":return t.jsx(Ix,{});case"git":return t.jsx(Rx,{});case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":{const Ct=He[ct]??"visual";return t.jsx(Ab,{section:Ct})}default:return t.jsx(yr,{onOpen:Pe})}},e[86]=Pe,e[87]=ge,e[88]=V,e[89]=tt):tt=e[89];const We=tt;let xt,wt;e[90]!==u||e[91]!==x||e[92]!==h?(xt=()=>{if(!u||x!=="nav"||h==="home"||C.current===h)return;const ct=En(h);!ct||ct.slug==="home"||(C.current=h,R(ct.kind==="split"?"page-sidebar":"page-content"))},wt=[u,x,h],e[90]=u,e[91]=x,e[92]=h,e[93]=xt,e[94]=wt):(xt=e[93],wt=e[94]),l.useEffect(xt,wt);const St=u&&x!=="nav",ie=u&&x==="page-content"&&h==="skills.installed",Ve=x==="page-content"&&Le?.kind==="split"&&!ie;let Qe;e[95]!==ie||e[96]!==St||e[97]!==c?(Qe=c(ie?"settings.view.actions.back":St?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),e[95]=ie,e[96]=St,e[97]=c,e[98]=Qe):Qe=e[98];const Ge=Qe,ut=Em();let bt;e[99]!==V.isVSCode?(bt=ct=>{if(typeof window>"u"||V.isVSCode)return;const ke=br(window.history.state);ke?.page===ct&&ke.stage==="page-content"||window.history.pushState({...qb(),[uc]:{page:ct,stage:"page-content"}},"",window.location.href)},e[99]=V.isVSCode,e[100]=bt):bt=e[100];const pt=bt;let Dt;e[101]!==pt||e[102]!==h?(Dt=()=>{R("page-content"),h==="skills.installed"&&pt(h)},e[101]=pt,e[102]=h,e[103]=Dt):Dt=e[103];const qt=Dt;let Yt;e[104]!==ie||e[105]!==V.isVSCode||e[106]!==h?(Yt=()=>{if(ie){if((typeof window<"u"?br(window.history.state):null)?.page===h&&!V.isVSCode){window.history.back();return}R("page-sidebar");return}R("nav")},e[104]=ie,e[105]=V.isVSCode,e[106]=h,e[107]=Yt):Yt=e[107];const Zt=Yt;let as,Ht;e[108]!==u||e[109]!==V.isVSCode||e[110]!==h?(as=()=>{if(!u||V.isVSCode)return;const ct=ke=>{if(h!=="skills.installed")return;if(br(ke.state)?.page==="skills.installed"){R("page-content");return}R(cy)};return window.addEventListener("popstate",ct),()=>{window.removeEventListener("popstate",ct)}},Ht=[u,V.isVSCode,h],e[108]=u,e[109]=V.isVSCode,e[110]=h,e[111]=as,e[112]=Ht):(as=e[111],Ht=e[112]),l.useEffect(as,Ht);let es;e[113]===Symbol.for("react.memo_cache_sentinel")?(es=()=>{R("page-sidebar")},e[113]=es):es=e[113];const Se=es,yt=()=>{const ct=k.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(D,{name:"search",className:"h-4 w-4 shrink-0"}),t.jsx("input",{value:k,onChange:ke=>j(ke.target.value),onKeyDown:dt,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"}),ct&&t.jsx("button",{type:"button",onClick:()=>j(""),"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(D,{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:ct?q.length>0?(()=>{let ke=0;return Re.map(Ct=>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:Ct.pageTitle}),Ct.results.map(Xt=>{const Gt=ke;ke=ke+1;const wn=Gt===$,cn=!!Xt.description;return t.jsxs("button",{type:"button",ref:Gs=>{Q.current[Gt]=Gs},onMouseMove:()=>{X.current=!1,F(Gt)},onClick:()=>rt(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",cn?"min-h-11 py-1.5":"py-2",wn?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Xt.title}),cn&&t.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:Xt.description})]},Xt.id)})]},Ct.page))})():t.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:c("settings.view.search.noResults")}):we.map(ke=>{const Ct=h===ke.slug,Xt=pc(ke.slug);return!Xt&&ke.slug!=="mcp"?null:t.jsx(It,{children:t.jsx(At,{asChild:!0,children:t.jsxs("button",{type:"button",onClick:()=>Pe(ke.slug),"aria-current":Ct?"page":void 0,className:ce("flex h-8 items-center gap-2 rounded-md px-2 overflow-hidden",Ct?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[ke.slug==="mcp"?t.jsx(bu,{className:"h-4 w-4 shrink-0"}):t.jsx(D,{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:Je(ke.slug)}),ke.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")})]})]})})},ke.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:!V.isVSCode&&t.jsxs(It,{children:[t.jsx(At,{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:my,children:[t.jsx(D,{name:"restart",className:"h-4 w-4 shrink-0"}),t.jsx("span",{children:c("settings.view.actions.reloadOpenCode")})]})}),t.jsx(Et,{children:c("settings.view.actions.reloadOpenCodeTooltip")})]})})})]})},jt=()=>{if(x==="nav")return t.jsx("div",{className:ce("flex-1 min-h-0 overflow-hidden",V.isVSCode?"bg-background":"bg-sidebar"),children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(Xs,{children:yt()})})});if(!Le)return t.jsx("div",{className:"flex-1 bg-background"});if(x==="page-sidebar"){if(Le.kind!=="split"){const ke=We(h);return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Xs,{children:ke})})}return t.jsx("div",{className:ce("flex-1 min-h-0 overflow-hidden",V.isVSCode?"bg-background":"bg-sidebar"),children:t.jsx(Xs,{children:et(h,{onItemSelect:qt})})})}const ct=We(h);return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Xs,{children:ct})})};let Xe;e[114]!==Le||e[115]!==Pe||e[116]!==We||e[117]!==V.isVSCode||e[118]!==h?(Xe=()=>!Le||h==="home"?t.jsx(yr,{onOpen:Pe}):Le.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",V.isVSCode?"bg-background":"bg-sidebar"),style:{borderColor:"var(--interactive-border)"},children:t.jsx(Xs,{children:et(h,{})})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Xs,{children:We(h)})})]}):t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(Xs,{children:We(h)})}),e[114]=Le,e[115]=Pe,e[116]=We,e[117]=V.isVSCode,e[118]=h,e[119]=Xe):Xe=e[119];const Nt=Xe,Vt="true";let Qt;e[120]===Symbol.for("react.memo_cache_sentinel")?(Qt=ce("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),e[120]=Qt):Qt=e[120];const rs=u?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:[St||n?t.jsx("button",{type:"button",onClick:St?Zt:n,"aria-label":Ge,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(D,{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:x==="nav"?c("settings.view.home.title"):Le?Je(Le.slug):c("settings.view.home.title")}),Ve&&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(D,{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:ut}),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(D,{name:"close",className:"h-5 w-5"})})]}):t.jsxs(t.Fragment,{children:[St&&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(D,{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:ut}),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(D,{name:"close",className:"h-5 w-5"})})})]}),Rs="flex flex-1 min-h-0 overflow-hidden",cs=u?jt():t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ce("relative flex h-full min-h-0 flex-col overflow-hidden border-r",K?"bg-sidebar":V.isVSCode?"bg-background":"bg-sidebar",w?"":"transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]"),style:{width:`${N}px`,minWidth:`${N}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)]",w?"bg-primary/30":"bg-transparent hover:bg-primary/20"),tabIndex:0,onPointerDown:ae,onKeyDown:Me,role:"separator","aria-orientation":"vertical","aria-valuemin":Vr,"aria-valuemax":_r,"aria-valuenow":N,"aria-label":c("settings.view.actions.resizeNavigation")}),t.jsx(Xs,{children:yt()})]}),t.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Nt()})]});let Is;e[121]!==cs?(Is=t.jsx("div",{className:Rs,children:cs}),e[121]=cs,e[122]=Is):Is=e[122];let Ps;return e[123]!==Qt||e[124]!==rs||e[125]!==Is?(Ps=t.jsxs("div",{ref:B,"data-settings-view":Vt,className:Qt,children:[rs,Is]}),e[123]=Qt,e[124]=rs,e[125]=Is,e[126]=Ps):Ps=e[126],Ps};function Jb(s){return s.settingsPage}function Qb(s){return s.isSettingsDialogOpen}function Yb(s){return s.setSettingsPage}function Xb(s){return s.slug!=="home"}function Zb(s,e){return[s,e]}function ey(s){return s.activeProjectId}function ty(s){return s.name}function sy(s){return s.name}function ny(s){return s.name}function ay(s){return s.name}function ry(s){return s.name}function iy(s){if(s.id.startsWith("agents.")){const e=Ka.getState(),n=Qn("new-agent",e.agents.map(ty));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=$a.getState(),n=Qn("new-command",e.commands.map(sy));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=Ln.getState(),n=Qn("new-mcp-server",e.mcpServers.map(ny));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=Ba.getState(),n=Qn("new-snippet",e.snippets.map(ay));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(ry));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"&<.getState().setSelectedProvider(Hb),s.id==="plugins.create"?"plugins.spec":s.id}function oy(){window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))}function ly(s,e){switch(s){case"projects":return t.jsx(_h,{onItemSelect:e.onItemSelect});case"agents":return t.jsx(ap,{onItemSelect:e.onItemSelect});case"commands":return t.jsx(xp,{onItemSelect:e.onItemSelect});case"mcp":return t.jsx(Cp,{onItemSelect:e.onItemSelect});case"plugins":return t.jsx(Ag,{onItemSelect:e.onItemSelect});case"skills.installed":return t.jsx(Vg,{onItemSelect:e.onItemSelect});case"providers":return t.jsx(Mf,{onItemSelect:e.onItemSelect});case"usage":return t.jsx(Qf,{onItemSelect:e.onItemSelect});case"magic-prompts":return t.jsx(vx,{onItemSelect:e.onItemSelect});case"snippets":return t.jsx(kx,{onItemSelect:e.onItemSelect});default:return null}}function cy(s){return s==="page-content"?"page-sidebar":s}function dy(){}function my(){Mn({message:"Restarting OpenCode…",mode:"projects",scopes:["all"]}).catch(dy)}const Qv=Object.freeze(Object.defineProperty({__proto__:null,SettingsView:Gb,getSettingsNavIcon:pc},Symbol.toStringTag,{value:"Module"})),uy=["chat","git","diff","terminal","files","diagram"],py=["settings","agents","commands","skills","providers","usage","git-identities"],Ds={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function al(s){const e=gy();return{sessionId:hy(e),tab:fy(e),settingsPath:xy(e),diffFile:by(e)}}function gy(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function hy(s){const e=s.get(Ds.SESSION);return!e||e.trim().length===0?null:e.trim()}function fy(s){const e=s.get(Ds.TAB);if(!e)return null;const n=e.toLowerCase().trim();return uy.includes(n)?n:null}function xy(s){const e=s.get(Ds.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(py.includes(n),n)}function by(s){const e=s.get(Ds.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function rl(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(Ds.SESSION)||s.has(Ds.TAB)||s.has(Ds.SETTINGS)||s.has(Ds.FILE)}catch{return!1}}const yy="chat";function gc(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Ds.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Ds.SETTINGS,n),e}return s.tab!==yy&&e.set(Ds.TAB,s.tab),s.tab==="diff"&&s.diffFile&&s.diffFile.trim().length>0&&e.set(Ds.FILE,s.diffFile),e}function vy(s,e){const n=typeof window<"u"?window.location.pathname:"/",a=s.toString();return a?`${n}?${a}`:n}function jy(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=gc(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 wy(s,e={}){if(!(typeof window>"u")&&!Ny()&&!(!e.force&&jy(s)))try{const n=gc(s),a=vy(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",a):window.history.pushState({route:s},"",a)}catch{}}function Ny(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function ky(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Yv(){const s=l.useMemo(()=>ky(),[]),e=l.useRef(!1),n=l.useRef(!1),a=Ns(p=>p.setCurrentSession),r=ze(p=>p.setActiveMainTab),i=ze(p=>p.setSettingsDialogOpen),o=ze(p=>p.setSettingsPage),d=ze(p=>p.navigateToDiff),c=l.useCallback(async p=>{if(!n.current){n.current=!0;try{if(p.sessionId){const m=Ns.getState().currentSessionId;p.sessionId!==m&&await a(p.sessionId)}if(p.settingsPath){o(ti(p.settingsPath)),i(!0);return}ze.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]),f=l.useCallback(()=>{const p=Ns.getState(),m=ze.getState();return{sessionId:p.currentSessionId,tab:m.activeMainTab,isSettingsOpen:m.isSettingsDialogOpen,settingsPath:m.settingsPage,diffFile:m.pendingDiffFile}},[]),u=l.useCallback((p={})=>{if(s||n.current)return;const m=f();wy(m,p)},[s,f]);l.useEffect(()=>{if(e.current||(e.current=!0,!rl()))return;const p=al();(async()=>(await c(p),s||u({replace:!0})))()},[c,s,u]),l.useEffect(()=>{if(s)return;let p=Ns.getState().currentSessionId;return Ns.subscribe(P=>{const g=P.currentSessionId;g===p||n.current||(p=g,u())})},[s,u]),l.useEffect(()=>{if(s)return;let p=ze.getState().activeMainTab,m=ze.getState().isSettingsDialogOpen,P=ze.getState().settingsPage,g=ze.getState().pendingDiffFile;return ze.subscribe(x=>{if(n.current)return;const R=x.activeMainTab!==p,C=x.isSettingsDialogOpen!==m,N=x.settingsPage!==P,T=x.pendingDiffFile!==g&&x.activeMainTab==="diff";p=x.activeMainTab,m=x.isSettingsDialogOpen,P=x.settingsPage,g=x.pendingDiffFile,(R||C||N||T)&&u()})},[s,u]),l.useEffect(()=>{if(typeof window>"u"||s)return;const p=()=>{const m=al();if(rl())c(m);else{const P=ze.getState();P.isSettingsDialogOpen&&i(!1),P.activeMainTab!=="chat"&&r("chat")}};return window.addEventListener("popstate",p),()=>{window.removeEventListener("popstate",p)}},[c,s,r,i])}function Xv(){const s=nt.c(5),e=Ll(Cy),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 f=Sy,u=p=>{d||(c=window.setTimeout(async()=>{const m=await n.current(),P=typeof m=="number"&&Number.isFinite(m)?f(m):36e5;u(P)},p))};return u(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 Sy(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function Cy(s){return s.checkForUpdates}const hc={"?":{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"}},Py=hc.M;function Iy(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 Ay(s){const e=Iy(s);return hc[e]??Py}const Dy=l.memo(function(e){const n=nt.c(58),{file:a,actionLabel:r,actionSymbol:i,onAction:o,onViewDiff:d,onRevert:c,isReverting:f,stats:u,rowPaddingClassName:p,indentPx:m,actionAtStart:P,showRevert:g}=e,h=m===void 0?0:m,x=P===void 0?!1:P,R=g===void 0?!0:g;let C;n[0]!==a?(C=Ay(a),n[0]=a,n[1]=C):C=n[1];const N=C,{t:T}=it(),k=N.description,j=u?.insertions??0,b=u?.deletions??0;let A;n[2]!==o||n[3]!==d?(A=xe=>{xe.key===" "?(xe.preventDefault(),o()):xe.key==="Enter"&&(xe.preventDefault(),d())},n[2]=o,n[3]=d,n[4]=A):A=n[4];const $=A;let F;n[5]!==o?(F=xe=>{xe.preventDefault(),xe.stopPropagation(),o()},n[5]=o,n[6]=F):F=n[6];const I=F;let v;n[7]!==c?(v=xe=>{xe.preventDefault(),xe.stopPropagation(),c()},n[7]=c,n[8]=v):v=n[8];const w=v;let L;n[9]!==r||n[10]!==i||n[11]!==I?(L=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]=L):L=n[12];const E=L,_=`group flex items-center gap-2 py-1.5 cursor-pointer ${p??"px-3"}`;let B;n[13]!==h?(B=h>0?{paddingLeft:`${h}px`}:void 0,n[13]=h,n[14]=B):B=n[14];const Z=x?E:null;let Q;n[15]!==N.color?(Q={color:N.color},n[15]=N.color,n[16]=Q):Q=n[16];let M;n[17]!==N.code||n[18]!==k||n[19]!==Q?(M=t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:Q,title:k,"aria-label":k,children:N.code}),n[17]=N.code,n[18]=k,n[19]=Q,n[20]=M):M=n[20];let X;n[21]!==a.path?(X=t.jsx(Mm,{filePath:a.path,className:"h-3.5 w-3.5 shrink-0"}),n[21]=a.path,n[22]=X):X=n[22];let ee;if(n[23]!==a.path){e:{const xe=a.path.lastIndexOf("/");if(xe===-1){let ye;n[25]===Symbol.for("react.memo_cache_sentinel")?(ye={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},n[25]=ye):ye=n[25],ee=t.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ye,title:a.path,children:a.path});break e}const Ie=a.path.slice(0,xe),ve=a.path.slice(xe);let we;n[26]===Symbol.for("react.memo_cache_sentinel")?(we={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},n[26]=we):we=n[26];let be;n[27]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsx("span",{className:"text-muted-foreground",children:"/"}),n[27]=be):be=n[27];const se=t.jsx("span",{className:"text-foreground",children:ve.slice(1)});let le;n[28]!==se?(le=t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[be,se]}),n[28]=se,n[29]=le):le=n[29],ee=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:we,children:Ie}),le]})}n[23]=a.path,n[24]=ee}else ee=n[24];let K;n[30]===Symbol.for("react.memo_cache_sentinel")?(K={color:"var(--status-success)"},n[30]=K):K=n[30];let O;n[31]!==j?(O=t.jsxs("span",{style:K,children:["+",j]}),n[31]=j,n[32]=O):O=n[32];let Y,U;n[33]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),U={color:"var(--status-error)"},n[33]=Y,n[34]=U):(Y=n[33],U=n[34]);let ne;n[35]!==b?(ne=t.jsxs("span",{style:U,children:["-",b]}),n[35]=b,n[36]=ne):ne=n[36];let re;n[37]!==O||n[38]!==ne?(re=t.jsxs("span",{className:"shrink-0 typography-micro",children:[O,Y,ne]}),n[37]=O,n[38]=ne,n[39]=re):re=n[39];let V;n[40]!==a.path||n[41]!==w||n[42]!==f||n[43]!==R||n[44]!==T?(V=R?t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx("button",{type:"button",onClick:w,disabled:f,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":T("gitView.changes.revertFileAria",{path:a.path}),children:f?t.jsx(D,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(D,{name:"arrow-go-back",className:"size-3.5"})})}),t.jsx(Et,{sideOffset:8,children:T("gitView.changes.revertFileTooltip")})]}):null,n[40]=a.path,n[41]=w,n[42]=f,n[43]=R,n[44]=T,n[45]=V):V=n[45];const oe=x?null:E;let fe;return n[46]!==$||n[47]!==d||n[48]!==B||n[49]!==Z||n[50]!==M||n[51]!==X||n[52]!==ee||n[53]!==re||n[54]!==V||n[55]!==oe||n[56]!==_?(fe=t.jsxs("div",{className:_,role:"button",tabIndex:0,onClick:d,onKeyDown:$,style:B,children:[Z,M,X,ee,re,V,oe]}),n[46]=$,n[47]=d,n[48]=B,n[49]=Z,n[50]=M,n[51]=X,n[52]=ee,n[53]=re,n[54]=V,n[55]=oe,n[56]=_,n[57]=fe):fe=n[57],fe}),il=14,fc=s=>s.replace(/\\/g,"/").replace(/^\/+/,"").trim(),ol=(s,e)=>({id:`dir:${s}`,path:s,name:e,children:new Map,directFiles:[],files:[]}),Ey=s=>{const e=ol("","");for(const n of s){const a=fc(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 f=o.children.get(c);if(f){f.files.push(n),o=f;continue}const u=ol(d,c);u.files.push(n),o.children.set(c,u),o=u}}o.directFiles.push(n)}return e},My=(s,e)=>{const n=[],a=(r,i)=>{const o=Array.from(r.children.values()).sort((c,f)=>c.path.localeCompare(f.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,f)=>c.path.localeCompare(f.path));for(const c of d)n.push({key:`file:${fc(c.path)}`,kind:"file",depth:i,file:c})};return a(s,0),n},Ry=1e3,ll=34,vr=30,ya="pl-0 pr-2",jr=(s,e)=>`${s} ${e}`,Zv=({groups:s,diffStats:e,revertingPaths:n,isRevertingAll:a=!1,headerBackgroundClassName:r="bg-sidebar",onVisiblePathsChange:i,onRevertAll:o,onRevertDirectory:d})=>{const{t:c}=it(),f=l.useRef(null),p=ze(O=>O.gitChangesViewMode)==="tree",m=l.useMemo(()=>s.filter(O=>O.entries.length>0),[s]),[P,g]=l.useState(new Set),[h,x]=l.useState(new Set),[R,C]=l.useState(!1),[N,T]=l.useState(null),k=l.useMemo(()=>m.map(O=>Ey(O.entries)),[m]),j=l.useMemo(()=>{const O=[];return m.forEach((Y,U)=>{Array.from(k[U]?.children.values()??[]).forEach(ne=>{O.push(jr(Y.id,ne.path))})}),O},[k,m]);l.useEffect(()=>{p&&x(O=>{const Y=new Set,U=new Set(j);return O.forEach(ne=>{(ne.slice(ne.indexOf(" ")+1).includes("/")||U.has(ne))&&Y.add(ne)}),j.forEach(ne=>Y.add(ne)),Y})},[p,j]);const b=l.useMemo(()=>{const O=[];return m.forEach((Y,U)=>{if(O.push({type:"header",key:`header:${Y.id}`,groupIndex:U}),!P.has(Y.id)){if(p){const ne=new Set;h.forEach(V=>{V.startsWith(`${Y.id} `)&&ne.add(V.slice(Y.id.length+1))}),My(k[U],ne).forEach(V=>{V.kind==="file"?O.push({type:"file",key:`${Y.id}:${V.key}`,groupIndex:U,file:V.file,depth:V.depth}):O.push({type:"directory",key:`${Y.id}:${V.key}`,groupIndex:U,directory:V.directory,depth:V.depth})});return}Y.entries.forEach(ne=>{O.push({type:"file",key:`${Y.id}:file:${ne.path}`,groupIndex:U,file:ne,depth:0})})}}),o&&m.length>0&&O.push({type:"revert-all",key:"revert-all"}),O},[P,h,p,o,k,m]),A=b.length,$=A>=Ry,F=ud({count:A,enabled:$,getScrollElement:()=>f.current,estimateSize:()=>ll,overscan:12,getItemKey:O=>b[O]?.key??O}),I=F.getVirtualItems(),v=l.useMemo(()=>{if(!$)return 0;const O=f.current?.scrollTop??0;return I.find(U=>U.end>O)?.index??0},[$,I,f]);l.useEffect(()=>{if(!i)return;const O=Y=>Y&&Y.type==="file"?Y.file.path:null;if(A===0){i([]);return}if(!$){const Y=[];for(const U of b)if(U.type==="file"&&(Y.push(U.file.path),Y.length>=vr))break;i(Y);return}i(b.slice(v,v+Math.ceil((f.current?.clientHeight??0)/ll)+vr).map(Y=>O(Y)).filter(Y=>!!Y).slice(0,vr))},[i,A,b,$,v]);const w=l.useCallback(O=>{g(Y=>{const U=new Set(Y);return U.has(O)?U.delete(O):U.add(O),U})},[]),L=l.useCallback((O,Y)=>{x(U=>{const ne=new Set(U),re=jr(O,Y);return ne.has(re)?ne.delete(re):ne.add(re),ne})},[]),E=l.useMemo(()=>{const O=new Set;return m.forEach(Y=>Y.entries.forEach(U=>O.add(U.path))),Array.from(O)},[m]),_=E.length,B=N?a||N.paths.some(O=>n.has(O)):!1,Z=l.useCallback(async()=>{!o||a||E.length===0||(await o(E),C(!1))},[E,a,o]),Q=l.useCallback(async()=>{!d||!N||B||(await d(N.paths),T(null))},[B,d,N]),M=l.useCallback((O,Y)=>{const U=P.has(O.id),ne=O.entries.length;return t.jsxs("div",{className:ce("sticky top-0 z-10 flex items-center gap-2 py-2",r,ya,!Y&&"mt-1 border-t border-border/40"),children:[t.jsx("button",{type:"button",onClick:()=>O.onActionAll(O.entries.map(re=>re.path)),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":O.actionAllLabel,title:O.actionAllLabel,children:O.actionSymbol}),t.jsxs("button",{type:"button",onClick:()=>w(O.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":!U,children:[t.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:O.title}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:ne}),t.jsx(D,{name:"arrow-down-s",className:ce("size-3.5 shrink-0 text-muted-foreground transition-transform",U&&"-rotate-90")})]})]})},[P,r,w]),X=l.useCallback((O,Y,U)=>{const ne=h.has(jr(O.id,Y.path)),re=Y.files.map(oe=>oe.path),V=a||re.some(oe=>n.has(oe));return t.jsxs("div",{className:ce("group flex items-center gap-2 py-1.5",ya),style:{paddingLeft:`${U*il}px`},children:[t.jsxs("button",{type:"button",onClick:()=>L(O.id,Y.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":ne?c("gitView.changes.collapseDirectoryAria",{path:Y.path}):c("gitView.changes.expandDirectoryAria",{path:Y.path}),children:[ne?t.jsx(D,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):t.jsx(D,{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:Y.path,children:Y.name}),t.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:Y.files.length})]}),O.showRevertActions!==!1&&d?t.jsx("button",{type:"button",onClick:()=>T({path:Y.path,paths:re,count:re.length}),disabled:V,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":c("gitView.changes.revertDirectoryAria",{path:Y.path}),title:c("gitView.changes.revertDirectoryTooltip"),children:V?t.jsx(D,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(D,{name:"arrow-go-back",className:"size-3.5"})}):null,t.jsx("button",{type:"button",onClick:()=>O.onActionAll(Y.files.map(oe=>oe.path)),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":c(O.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:Y.path}),title:c(O.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:Y.path}),children:O.actionSymbol})]})},[h,a,d,n,c,L]),ee=l.useCallback((O,Y)=>{if(O.type==="revert-all")return t.jsx("div",{className:ce("flex justify-end py-2",ya),children:t.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>C(!0),disabled:a,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[t.jsx(D,{name:"arrow-go-back",className:"size-3.5"}),c("gitView.changes.revertAll")]})});const U=m[O.groupIndex];if(!U)return null;if(O.type==="header")return M(U,Y);if(O.type==="directory")return X(U,O.directory,O.depth);const ne=O.file;return t.jsx(Dy,{file:ne,actionLabel:U.getActionLabel(ne.path),actionSymbol:U.actionSymbol,onAction:()=>U.onActionFile(ne.path),stats:e?.[ne.path],onViewDiff:()=>U.onViewDiff(ne.path),onRevert:()=>U.onRevertFile(ne.path),isReverting:n.has(ne.path)||a,rowPaddingClassName:ya,indentPx:O.depth*il,actionAtStart:!p,showRevert:U.showRevertActions!==!1})},[e,a,p,X,M,n,c,m]),K=l.useCallback(O=>{const Y=b[O],U=b[O-1];return!Y||!U||Y.type!=="file"&&Y.type!=="directory"||U.type!=="file"&&U.type!=="directory"?!1:U.groupIndex===Y.groupIndex},[b]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[t.jsx(Rm,{ref:f,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:$?t.jsx("div",{style:{height:F.getTotalSize(),position:"relative"},children:I.map(O=>{const Y=b[O.index];return Y?t.jsx("div",{"data-index":O.index,ref:F.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${O.start}px)`},className:ce(K(O.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:ee(Y,O.index===0)},Y.key):null})}):t.jsx("div",{role:"list","aria-label":c("gitView.changes.changedFilesAria"),children:b.map((O,Y)=>t.jsx("div",{className:ce("relative",K(Y)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:ee(O,Y===0)},O.key))})}),t.jsx(Tm,{containerRef:f,disableHorizontal:!0})]}),t.jsx(Ot,{open:R,onOpenChange:O=>{!a&&!O&&C(!1)},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:c("gitView.changes.revertAllDialogTitle")}),t.jsx(Bt,{children:_===1?c("gitView.changes.revertAllDescriptionSingle",{count:_}):c("gitView.changes.revertAllDescriptionPlural",{count:_})})]}),t.jsxs(Jt,{children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>C(!1),disabled:a,children:c("gitView.common.cancel")}),t.jsx(G,{variant:"destructive",size:"sm",onClick:()=>{Z()},disabled:a,children:c(a?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),t.jsx(Ot,{open:!!N,onOpenChange:O=>{!B&&!O&&T(null)},children:t.jsxs(zt,{className:"max-w-md",children:[t.jsxs($t,{children:[t.jsx(Kt,{children:c("gitView.changes.revertDirectoryDialogTitle")}),t.jsx(Bt,{children:N?N.count===1?c("gitView.changes.revertDirectoryDescriptionSingle",{count:N.count,path:N.path}):c("gitView.changes.revertDirectoryDescriptionPlural",{count:N.count,path:N.path}):null})]}),t.jsxs(Jt,{children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>T(null),disabled:B,children:c("gitView.common.cancel")}),t.jsx(G,{variant:"destructive",size:"sm",onClick:()=>{Q()},disabled:B||!N,children:c(B?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},wr=38,va=200,Ty=s=>{const e=nt.c(20),{value:n,onChange:a,placeholder:r,disabled:i,hasTouchInput:o,isMobile:d}=s,c=i===void 0?!1:i,f=o===void 0?!1:o,u=d===void 0?!1:d,{t:p}=it(),m=l.useRef(null),P=ze(Fy);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const $=m.current;if(!$)return;const F=document.activeElement===$,I=()=>{$.style.height=`${wr}px`;const w=$.scrollHeight,L=Math.min(Math.max(w,wr),va);$.style.height=`${L}px`,$.style.overflowY=w>va?"auto":"hidden",w>va&&!F&&($.scrollTop=$.scrollHeight)};I();const v=window.requestAnimationFrame(I);return()=>{window.cancelAnimationFrame(v)}},e[0]=g):g=e[0];let h;e[1]!==n?(h=[n],e[1]=n,e[2]=h):h=e[2],l.useLayoutEffect(g,h);let x;e[3]!==a?(x=$=>a($.target.value),e[3]=a,e[4]=x):x=e[4];let R;e[5]!==r||e[6]!==p?(R=r??p("gitView.commit.messagePlaceholder"),e[5]=r,e[6]=p,e[7]=R):R=e[7];const C=f?"on":"off",N=f?"sentences":"off",T=u||P,k=c&&"opacity-50";let j;e[8]!==k?(j=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)]",k),e[8]=k,e[9]=j):j=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b={minHeight:wr,maxHeight:va},e[10]=b):b=e[10];let A;return e[11]!==c||e[12]!==T||e[13]!==j||e[14]!==x||e[15]!==R||e[16]!==C||e[17]!==N||e[18]!==n?(A=t.jsx("textarea",{ref:m,value:n,onChange:x,placeholder:R,rows:1,disabled:c,autoCorrect:C,autoCapitalize:N,spellCheck:T,className:j,style:b}),e[11]=c,e[12]=T,e[13]=j,e[14]=x,e[15]=R,e[16]=C,e[17]=N,e[18]=n,e[19]=A):A=e[19],A};function Fy(s){return s.inputSpellcheckEnabled}const Ly=s=>{const e=nt.c(30),{highlights:n,onInsert:a}=s,{t:r}=it();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 f;e[7]!==r?(f=r("gitView.commit.aiHighlights.insertAria"),e[7]=r,e[8]=f):f=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(D,{name:"arrow-down",className:"size-4"}),e[9]=u):u=e[9];let p;e[10]!==o||e[11]!==f?(p=t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon",className:"size-6",onClick:o,"aria-label":f,children:u})}),e[10]=o,e[11]=f,e[12]=p):p=e[12];let m;e[13]!==r?(m=r("gitView.commit.aiHighlights.insertTooltip"),e[13]=r,e[14]=m):m=e[14];let P;e[15]!==m?(P=t.jsx(Et,{sideOffset:8,children:m}),e[15]=m,e[16]=P):P=e[16];let g;e[17]!==p||e[18]!==P?(g=t.jsxs(It,{children:[p,P]}),e[17]=p,e[18]=P,e[19]=g):g=e[19];let h;e[20]!==c||e[21]!==g?(h=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c,g]}),e[20]=c,e[21]=g,e[22]=h):h=e[22];let x;e[23]!==n?(x=n.map(Oy),e[23]=n,e[24]=x):x=e[24];let R;e[25]!==x?(R=t.jsx("ul",{className:"space-y-1",children:x}),e[25]=x,e[26]=R):R=e[26];let C;return e[27]!==h||e[28]!==R?(C=t.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[h,R]}),e[27]=h,e[28]=R,e[29]=C):C=e[29],C};function Oy(s,e){return t.jsx("li",{className:"typography-meta text-foreground",children:s},`${s}-${e}`)}const ej=s=>{const e=nt.c(75),{stagedCount:n,commitMessage:a,onCommitMessageChange:r,generatedHighlights:i,onInsertHighlights:o,onGenerateMessage:d,isGeneratingMessage:c,onCommit:f,onCommitAndPush:u,commitAction:p,hasPendingIndexMutation:m,gitmojiEnabled:P,onOpenGitmojiPicker:g}=s,h=m===void 0?!1:m,{t:x}=it(),R=n>0;let C;e[0]!==p||e[1]!==a||e[2]!==h||e[3]!==R?(C=a.trim()&&R&&p===null&&!h,e[0]=p,e[1]=a,e[2]=h,e[3]=R,e[4]=C):C=e[4];const N=C,{isMobile:T,hasTouchInput:k}=Cs();let j;e[5]!==x?(j=x("gitView.commit.title"),e[5]=x,e[6]=j):j=e[6];let b;e[7]!==j?(b=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:j}),e[7]=j,e[8]=b):b=e[8];let A;e[9]!==R||e[10]!==x?(A=R?null:t.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:x("gitView.commit.stageFilesHint")}),e[9]=R,e[10]=x,e[11]=A):A=e[11];let $;e[12]!==b||e[13]!==A?($=t.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[b,A]}),e[12]=b,e[13]=A,e[14]=$):$=e[14];let F;e[15]!==i||e[16]!==o?(F=t.jsx(Ly,{highlights:i,onInsert:o}),e[15]=i,e[16]=o,e[17]=F):F=e[17];let I;e[18]!==x?(I=x("gitView.commit.messagePlaceholder"),e[18]=x,e[19]=I):I=e[19];const v=p!==null;let w;e[20]!==a||e[21]!==k||e[22]!==T||e[23]!==r||e[24]!==I||e[25]!==v?(w=t.jsx(Ty,{value:a,onChange:r,placeholder:I,disabled:v,hasTouchInput:k,isMobile:T}),e[20]=a,e[21]=k,e[22]=T,e[23]=r,e[24]=I,e[25]=v,e[26]=w):w=e[26];let L;e[27]!==P||e[28]!==g||e[29]!==x?(L=P&&t.jsxs(G,{variant:"outline",size:"sm",onClick:g,className:"w-fit",type:"button",children:[t.jsx(D,{name:"emotion-happy",className:"size-4"}),x("gitView.commit.addGitmoji")]}),e[27]=P,e[28]=g,e[29]=x,e[30]=L):L=e[30];const E=c||p!==null||h||n===0;let _;e[31]!==x?(_=x("gitView.commit.generateAria"),e[31]=x,e[32]=_):_=e[32];let B;e[33]!==c?(B=c?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=c,e[34]=B):B=e[34];let Z;e[35]!==x?(Z=x("gitView.commit.generate"),e[35]=x,e[36]=Z):Z=e[36];let Q;e[37]!==Z?(Q=t.jsx("span",{className:"commit-actions__label",children:Z}),e[37]=Z,e[38]=Q):Q=e[38];let M;e[39]!==d||e[40]!==E||e[41]!==_||e[42]!==B||e[43]!==Q?(M=t.jsxs(G,{variant:"outline",size:"sm",onClick:d,disabled:E,type:"button","aria-label":_,className:"commit-actions__btn",children:[B,Q]}),e[39]=d,e[40]=E,e[41]=_,e[42]=B,e[43]=Q,e[44]=M):M=e[44];let X;e[45]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx("div",{className:"flex-1"}),e[45]=X):X=e[45];const ee=!N||c;let K;e[46]!==x?(K=x("gitView.commit.commitAria"),e[46]=x,e[47]=K):K=e[47];let O;e[48]!==p||e[49]!==x?(O=p==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label",children:x("gitView.commit.committing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-commit",className:"size-4"}),t.jsx("span",{className:"commit-actions__label",children:x("gitView.commit.commit")})]}),e[48]=p,e[49]=x,e[50]=O):O=e[50];let Y;e[51]!==f||e[52]!==ee||e[53]!==K||e[54]!==O?(Y=t.jsx(G,{size:"sm",variant:"outline",onClick:f,disabled:ee,className:"commit-actions__btn whitespace-nowrap","aria-label":K,children:O}),e[51]=f,e[52]=ee,e[53]=K,e[54]=O,e[55]=Y):Y=e[55];let U;e[56]!==N||e[57]!==p||e[58]!==c||e[59]!==T||e[60]!==u||e[61]!==x?(U=T?t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"default",size:"sm",onClick:()=>u(),disabled:!N||c,className:"h-7 w-7 p-0","aria-label":x("gitView.commit.pushAria"),children:p==="commitAndPush"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"arrow-up",className:"size-3.5"})})}),t.jsx(Et,{side:"top",children:t.jsx("p",{children:x("gitView.commit.push")})})]}):t.jsx(G,{size:"sm",variant:"default",onClick:()=>u(),disabled:!N||c,className:"commit-actions__btn","aria-label":x("gitView.commit.pushAria"),children:p==="commitAndPush"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:x("gitView.commit.pushing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"arrow-up",className:"size-3.5"}),t.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:x("gitView.commit.push")})]})}),e[56]=N,e[57]=p,e[58]=c,e[59]=T,e[60]=u,e[61]=x,e[62]=U):U=e[62];let ne;e[63]!==M||e[64]!==Y||e[65]!==U?(ne=t.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[M,X,Y,U]}),e[63]=M,e[64]=Y,e[65]=U,e[66]=ne):ne=e[66];let re;e[67]!==w||e[68]!==L||e[69]!==ne||e[70]!==F?(re=t.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[F,w,L,ne]}),e[67]=w,e[68]=L,e[69]=ne,e[70]=F,e[71]=re):re=e[71];let V;return e[72]!==re||e[73]!==$?(V=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[$,re]}),e[72]=re,e[73]=$,e[74]=V):V=e[74],V},zy=s=>{const e=nt.c(41),{syncAction:n,remotes:a,onFetch:r,onSync:i,onRemoveRemote:o,disabled:d,removingRemoteName:c,aheadCount:f,behindCount:u,trackingRemoteName:p,hasUncommittedChanges:m}=s,P=a===void 0?[]:a,g=c===void 0?null:c,h=f===void 0?0:f,x=u===void 0?0:u,R=m===void 0?!1:m,{t:C}=it(),N=l.useRef(!1),T=!!g,k=P.find(le=>le.name===p)??P[0],j=x>0&&R,b=d||n!==null||T||!k||j,A=d||n!==null||T||P.length===0,$=h>0||x>0;let F;e[0]!==C?(F=C("gitView.sync.sync"),e[0]=C,e[1]=F):F=e[1];const I=x>0?`↓${x}`:null,v=h>0?`↑${h}`:null;let w;e[2]!==F||e[3]!==I||e[4]!==v?(w=[F,I,v].filter(Boolean),e[2]=F,e[3]=I,e[4]=v,e[5]=w):w=e[5];const L=w.join(" "),E=j?C("gitView.sync.commitOrStashTooltip"):k?$?C("gitView.sync.syncChangesTooltip",{ahead:h,behind:x}):C("gitView.sync.syncChanges"):C("gitView.sync.noRemoteTooltip"),_=()=>{k&&i(k)},B="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 Z;e[6]===Symbol.for("react.memo_cache_sentinel")?(Z=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]=Z):Z=e[6];let Q;e[7]!==C?(Q=C("gitView.sync.syncChanges"),e[7]=C,e[8]=Q):Q=e[8];let M;e[9]!==n?(M=n==="sync"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=M):M=e[10];let X;e[11]!==L?(X=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:L}),e[11]=L,e[12]=X):X=e[12];let ee;e[13]!==_||e[14]!==b||e[15]!==Q||e[16]!==M||e[17]!==X?(ee=t.jsx(At,{asChild:!0,children:t.jsxs("button",{type:"button",onClick:_,disabled:b,className:Z,"aria-label":Q,children:[M,X]})}),e[13]=_,e[14]=b,e[15]=Q,e[16]=M,e[17]=X,e[18]=ee):ee=e[18];let K;e[19]!==E?(K=t.jsx(Et,{sideOffset:8,children:E}),e[19]=E,e[20]=K):K=e[20];let O;e[21]!==ee||e[22]!==K?(O=t.jsxs(It,{children:[ee,K]}),e[21]=ee,e[22]=K,e[23]=O):O=e[23];const Y=gs;let U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=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]=U):U=e[24];let ne;e[25]!==C?(ne=C("gitView.sync.moreActionsAria"),e[25]=C,e[26]=ne):ne=e[26];let re;e[27]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx(D,{name:"arrow-down-s",className:"size-4"}),e[27]=re):re=e[27];let V;e[28]!==A||e[29]!==ne?(V=t.jsx(us,{asChild:!0,children:t.jsx("button",{type:"button",className:U,disabled:A,"aria-label":ne,children:re})}),e[28]=A,e[29]=ne,e[30]=V):V=e[30];const oe=ps,fe="start",xe=-40,Ie="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",ve=P.map(le=>t.jsx(js,{onSelect:ye=>{if(N.current){ye.preventDefault(),N.current=!1;return}r(le)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(D,{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:C("gitView.sync.fetchFromRemote",{name:le.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:le.fetchUrl})]})}),o&&le.name!==p?t.jsx(G,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||T,onPointerDown:ye=>{N.current=!0,ye.preventDefault(),ye.stopPropagation()},onClick:ye=>{N.current=!0,ye.preventDefault(),ye.stopPropagation(),o(le)},"aria-label":C("gitView.header.removeRemoteAria",{name:le.name}),title:C("gitView.header.removeRemoteTitle",{name:le.name}),children:g===le.name?t.jsx(D,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(D,{name:"close",className:"size-3.5"})}):null]})},le.name));let we;e[31]!==oe||e[32]!==ve?(we=t.jsx(oe,{align:fe,alignOffset:xe,className:Ie,children:ve}),e[31]=oe,e[32]=ve,e[33]=we):we=e[33];let be;e[34]!==Y||e[35]!==V||e[36]!==we?(be=t.jsxs(Y,{children:[V,we]}),e[34]=Y,e[35]=V,e[36]=we,e[37]=be):be=e[37];let se;return e[38]!==O||e[39]!==be?(se=t.jsxs("div",{className:B,children:[O,be]}),e[38]=O,e[39]=be,e[40]=se):se=e[40],se};function Ky(s){const e=nt.c(85),{draft:n,onEdit:a,onDelete:r,className:i,maxWidth:o}=s,{t:d}=it(),f=za()?.currentTheme,[u,p]=he.useState(!1),[m,P]=he.useState(!1),g=typeof n.text=="string"?n.text:"";let h;e[0]!==g?(h=g.length>150||g.split(`
|
|
30
|
-
`).length>3,e[0]=g,e[1]=h):h=e[1];const x=h;let R;e[2]!==i?(R=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]=R):R=e[3];const C=f?.colors?.surface?.elevated,N=f?.colors?.interactive?.border,T=o?`${Math.max(200,Math.floor(o))}px`:void 0;let k;e[4]!==C||e[5]!==N||e[6]!==T?(k={backgroundColor:C,borderColor:N,maxWidth:T},e[4]=C,e[5]=N,e[6]=T,e[7]=k):k=e[7];let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=H=>{H.preventDefault(),P(!0)},e[8]=j):j=e[8];let b;e[9]!==R||e[10]!==k?(b=t.jsx("div",{className:R,style:k,"data-comment-card":"true",onContextMenu:j}),e[9]=R,e[10]=k,e[11]=b):b=e[11];let A;e[12]!==n.fileLabel?(A=t.jsx("span",{className:"truncate max-w-[200px]",title:n.fileLabel,children:n.fileLabel}),e[12]=n.fileLabel,e[13]=A):A=e[13];let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("span",{children:"•"}),e[14]=$):$=e[14];let F;e[15]!==n.endLine||e[16]!==n.startLine||e[17]!==d?(F=d("inlineComment.range.lines",{start:n.startLine,end:n.endLine}),e[15]=n.endLine,e[16]=n.startLine,e[17]=d,e[18]=F):F=e[18];let I;e[19]!==F?(I=t.jsx("span",{children:F}),e[19]=F,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 w;e[23]!==I||e[24]!==v||e[25]!==A?(w=t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5",children:[A,$,I,v]}),e[23]=I,e[24]=v,e[25]=A,e[26]=w):w=e[26];const L=u||!x,E=!u&&x&&"line-clamp-3";let _;e[27]!==E?(_=ce("text-sm whitespace-pre-wrap break-words leading-relaxed",E),e[27]=E,e[28]=_):_=e[28];let B;e[29]!==g||e[30]!==_?(B=t.jsx("div",{className:_,children:g}),e[29]=g,e[30]=_,e[31]=B):B=e[31];let Z;e[32]!==x||e[33]!==u||e[34]!==d?(Z=x&&t.jsx(bn,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start",children:u?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"arrow-up-s",className:"size-3 mr-1"}),d("inlineComment.actions.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"arrow-down-s",className:"size-3 mr-1"}),d("inlineComment.actions.showMore")]})})}),e[32]=x,e[33]=u,e[34]=d,e[35]=Z):Z=e[35];let Q;e[36]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsx(yn,{}),e[36]=Q):Q=e[36];let M;e[37]!==L||e[38]!==B||e[39]!==Z?(M=t.jsxs(xn,{open:L,onOpenChange:p,children:[B,Z,Q]}),e[37]=L,e[38]=B,e[39]=Z,e[40]=M):M=e[40];let X;e[41]!==w||e[42]!==M?(X=t.jsxs("div",{className:"flex-1 min-w-0",children:[w,M]}),e[41]=w,e[42]=M,e[43]=X):X=e[43];let ee;e[44]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(us,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground",children:t.jsx(D,{name:"more",className:"size-4"})})}),e[44]=ee):ee=e[44];let K;e[45]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(D,{name:"edit",className:"size-4 mr-2"}),e[45]=K):K=e[45];let O;e[46]!==d?(O=d("inlineComment.actions.editComment"),e[46]=d,e[47]=O):O=e[47];let Y;e[48]!==a||e[49]!==O?(Y=t.jsxs(js,{onClick:a,children:[K,O]}),e[48]=a,e[49]=O,e[50]=Y):Y=e[50];let U;e[51]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx(D,{name:"delete-bin",className:"size-4 mr-2"}),e[51]=U):U=e[51];let ne;e[52]!==d?(ne=d("inlineComment.actions.deleteComment"),e[52]=d,e[53]=ne):ne=e[53];let re;e[54]!==r||e[55]!==ne?(re=t.jsxs(js,{onClick:r,className:"text-destructive",children:[U,ne]}),e[54]=r,e[55]=ne,e[56]=re):re=e[56];let V;e[57]!==Y||e[58]!==re?(V=t.jsxs(gs,{children:[ee,t.jsxs(ps,{align:"end",children:[Y,re]})]}),e[57]=Y,e[58]=re,e[59]=V):V=e[59];let oe;e[60]!==X||e[61]!==V?(oe=t.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[X,V]}),e[60]=X,e[61]=V,e[62]=oe):oe=e[62];let fe;e[63]!==oe||e[64]!==b?(fe=t.jsx(nn,{render:b,children:oe}),e[63]=oe,e[64]=b,e[65]=fe):fe=e[65];let xe;e[66]===Symbol.for("react.memo_cache_sentinel")?(xe=t.jsx(D,{name:"edit",className:"size-4 mr-2"}),e[66]=xe):xe=e[66];let Ie;e[67]!==d?(Ie=d("inlineComment.actions.editComment"),e[67]=d,e[68]=Ie):Ie=e[68];let ve;e[69]!==a||e[70]!==Ie?(ve=t.jsxs(qs,{onClick:a,children:[xe,Ie]}),e[69]=a,e[70]=Ie,e[71]=ve):ve=e[71];let we;e[72]===Symbol.for("react.memo_cache_sentinel")?(we=t.jsx(D,{name:"delete-bin",className:"size-4 mr-2"}),e[72]=we):we=e[72];let be;e[73]!==d?(be=d("inlineComment.actions.deleteComment"),e[73]=d,e[74]=be):be=e[74];let se;e[75]!==r||e[76]!==be?(se=t.jsxs(qs,{onClick:r,className:"text-destructive focus:text-destructive",children:[we,be]}),e[75]=r,e[76]=be,e[77]=se):se=e[77];let le;e[78]!==ve||e[79]!==se?(le=t.jsxs(an,{children:[ve,se]}),e[78]=ve,e[79]=se,e[80]=le):le=e[80];let ye;return e[81]!==m||e[82]!==fe||e[83]!==le?(ye=t.jsxs(sn,{open:m,onOpenChange:P,children:[fe,le]}),e[81]=m,e[82]=fe,e[83]=le,e[84]=ye):ye=e[84],ye}function cl(s){const e=nt.c(62),{initialText:n,onTextChange:a,onSave:r,onCancel:i,fileLabel:o,lineRange:d,isEditing:c,className:f,maxWidth:u}=s,p=n===void 0?"":n,m=c===void 0?!1:c,{t:P}=it(),h=za()?.currentTheme,{isMobile:x}=Cs(),[R,C]=l.useState(p),N=he.useRef(null);let T;e[0]!==a?(T=ae=>{C(ae),a?.(ae)},e[0]=a,e[1]=T):T=e[1];const k=T,j=he.useRef(d);let b,A;e[2]!==d?(b=()=>{d&&(j.current=d)},A=[d],e[2]=d,e[3]=b,e[4]=A):(b=e[3],A=e[4]),he.useEffect(b,A);const $=Wy,F=$(d);let I,v;e[5]!==x?(I=()=>{const ae=N.current;if(!ae)return;const me=ae.closest(".overlay-scrollbar-container"),Me=me?.scrollTop??window.scrollY,Ne=me?.scrollLeft??window.scrollX;if(x){ae.scrollIntoView({behavior:"auto",block:"nearest"});try{ae.focus({preventScroll:!0})}catch{ae.focus()}return}try{ae.focus({preventScroll:!0})}catch{ae.focus()}const De=ae.value.length;try{ae.setSelectionRange(De,De)}catch{}requestAnimationFrame(()=>{me?(me.scrollTop=Me,me.scrollLeft=Ne):window.scrollTo({top:Me,left:Ne})})},v=[x],e[5]=x,e[6]=I,e[7]=v):(I=e[6],v=e[7]),he.useEffect(I,v);let w;e[8]!==i||e[9]!==r||e[10]!==R?(w=ae=>{(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"?(ae.preventDefault(),R.trim()&&r(R,$(j.current))):ae.key==="Escape"&&(ae.preventDefault(),i())},e[8]=i,e[9]=r,e[10]=R,e[11]=w):w=e[11];const L=w;let E;e[12]!==r||e[13]!==R?(E=ae=>{ae.stopPropagation(),R.trim()&&r(R,$(j.current))},e[12]=r,e[13]=R,e[14]=E):E=e[14];const _=E;let B;e[15]!==f?(B=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",f),e[15]=f,e[16]=B):B=e[16];const Z=h?.colors?.surface?.elevated,Q=h?.colors?.interactive?.border,M=u?`${Math.max(200,Math.floor(u))}px`:void 0;let X;e[17]!==Z||e[18]!==Q||e[19]!==M?(X={backgroundColor:Z,borderColor:Q,maxWidth:M},e[17]=Z,e[18]=Q,e[19]=M,e[20]=X):X=e[20];const ee="true",K=Hy,O=_y,Y="p-3",U=(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:"•"}),F&&t.jsx("span",{children:P("inlineComment.range.lines",{start:F.start,end:F.end})})]});let ne;e[21]!==k?(ne=ae=>k(ae.target.value),e[21]=k,e[22]=ne):ne=e[22];let re;e[23]!==x||e[24]!==P?(re=P(x?"inlineComment.input.placeholderShort":"inlineComment.input.placeholder"),e[23]=x,e[24]=P,e[25]=re):re=e[25];let V;e[26]!==L||e[27]!==ne||e[28]!==re||e[29]!==R?(V=t.jsx(hs,{simple:!0,ref:N,value:R,onChange:ne,onKeyDown:L,placeholder:re,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]=L,e[27]=ne,e[28]=re,e[29]=R,e[30]=V):V=e[30];let oe;e[31]!==P?(oe=P("inlineComment.actions.cancel"),e[31]=P,e[32]=oe):oe=e[32];let fe;e[33]!==i||e[34]!==oe?(fe=t.jsx(G,{variant:"ghost",size:"sm",onClick:i,onPointerDown:Vy,onTouchStart:By,className:"h-8 text-muted-foreground hover:text-foreground",children:oe}),e[33]=i,e[34]=oe,e[35]=fe):fe=e[35];let xe;e[36]!==R?(xe=R.trim(),e[36]=R,e[37]=xe):xe=e[37];const Ie=!xe,ve=h?.colors?.status?.success,we=h?.colors?.status?.successForeground;let be;e[38]!==ve||e[39]!==we?(be={backgroundColor:ve,color:we},e[38]=ve,e[39]=we,e[40]=be):be=e[40];let se;e[41]!==m||e[42]!==P?(se=P(m?"inlineComment.actions.save":"inlineComment.actions.comment"),e[41]=m,e[42]=P,e[43]=se):se=e[43];let le;e[44]!==_||e[45]!==Ie||e[46]!==be||e[47]!==se?(le=t.jsx(G,{size:"sm",onClick:_,onPointerDown:Uy,onTouchStart:$y,disabled:Ie,className:"h-8 min-w-[80px]",style:be,children:se}),e[44]=_,e[45]=Ie,e[46]=be,e[47]=se,e[48]=le):le=e[48];let ye;e[49]!==fe||e[50]!==le?(ye=t.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[fe,le]}),e[49]=fe,e[50]=le,e[51]=ye):ye=e[51];let H;e[52]!==U||e[53]!==V||e[54]!==ye?(H=t.jsxs("div",{className:Y,children:[U,V,ye]}),e[52]=U,e[53]=V,e[54]=ye,e[55]=H):H=e[55];let te;return e[56]!==B||e[57]!==X||e[58]!==K||e[59]!==O||e[60]!==H?(te=t.jsx("div",{className:B,style:X,"data-comment-input":ee,onPointerDown:K,onTouchStart:O,children:H}),e[56]=B,e[57]=X,e[58]=K,e[59]=O,e[60]=H,e[61]=te):te=e[61],te}function $y(s){return s.stopPropagation()}function Uy(s){return s.stopPropagation()}function By(s){return s.stopPropagation()}function Vy(s){return s.stopPropagation()}function _y(s){return s.stopPropagation()}function Hy(s){return s.stopPropagation()}function Wy(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 qy=s=>{const e=Math.min(s.startLine,s.endLine),n=Math.max(s.startLine,s.endLine);return{...s,startLine:e,endLine:n}},dl=s=>{const e=Math.min(s.start,s.end),n=Math.max(s.start,s.end);return{...s,start:e,end:n}};function Gy(s){const e=nt.c(40),{t:n}=it(),{source:a,fileLabel:r,language:i,getCodeForRange:o,toStoreRange:d,fromDraftRange:c}=s,f=Ns(ev),u=Ns(Zy),p=ra(Xy),m=ra(Yy),P=ra(Qy),g=ra(Jy),[h,x]=l.useState(null),[R,C]=l.useState(""),[N,T]=l.useState(null),k=f??(u?"draft":null);let j;e:{if(!k||!r){let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee=[],e[0]=ee):ee=e[0],j=ee;break e}let Q;e[1]!==g||e[2]!==k?(Q=g[k]??[],e[1]=g,e[2]=k,e[3]=Q):Q=e[3];const M=Q;let X;if(e[4]!==r||e[5]!==M||e[6]!==a){let ee;e[8]!==r||e[9]!==a?(ee=K=>K.source===a&&K.fileLabel===r,e[8]=r,e[9]=a,e[10]=ee):ee=e[10],X=M.filter(ee),e[4]=r,e[5]=M,e[6]=a,e[7]=X}else X=e[7];j=X}const b=j;let A;e[11]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{x(null),C(""),T(null)},e[11]=A):A=e[11];const $=A;let F;e[12]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{$()},e[12]=F):F=e[12];const I=F;let v;e[13]!==c?(v=Q=>{const M=dl(c(Q));x(M),C(Q.text),T(Q.id)},e[13]=c,e[14]=v):v=e[14];const w=v;let L;e[15]!==N||e[16]!==P?(L=Q=>{P(Q.sessionKey,Q.id),N===Q.id&&$()},e[15]=N,e[16]=P,e[17]=L):L=e[17];const E=L;let _;e[18]!==p||e[19]!==N||e[20]!==r||e[21]!==o||e[22]!==i||e[23]!==h||e[24]!==k||e[25]!==a||e[26]!==n||e[27]!==d||e[28]!==m?(_=(Q,M)=>{const X=M??h,ee=Q.trim();if(!X||!ee||!r)return;if(!k){W.error(n("inlineComment.toast.selectSessionToSave"));return}const K=dl(X),O=qy(d(K)),Y=o(K);N?m(k,N,{fileLabel:r,startLine:O.startLine,endLine:O.endLine,side:O.side,code:Y,language:i,text:ee}):p({sessionKey:k,source:a,fileLabel:r,startLine:O.startLine,endLine:O.endLine,side:O.side,code:Y,language:i,text:ee}),$()},e[18]=p,e[19]=N,e[20]=r,e[21]=o,e[22]=i,e[23]=h,e[24]=k,e[25]=a,e[26]=n,e[27]=d,e[28]=m,e[29]=_):_=e[29];const B=_;let Z;return e[30]!==R||e[31]!==E||e[32]!==b||e[33]!==N||e[34]!==c||e[35]!==B||e[36]!==h||e[37]!==k||e[38]!==w?(Z={sessionKey:k,drafts:b,selection:h,setSelection:x,commentText:R,setCommentText:C,editingDraftId:N,setEditingDraftId:T,reset:$,cancel:I,startEdit:w,deleteDraft:E,saveComment:B,fromDraftRange:c},e[30]=R,e[31]=E,e[32]=b,e[33]=N,e[34]=c,e[35]=B,e[36]=h,e[37]=k,e[38]=w,e[39]=Z):Z=e[39],Z}function Jy(s){return s.drafts}function Qy(s){return s.removeDraft}function Yy(s){return s.updateDraft}function Xy(s){return s.addDraft}function Zy(s){return s.newSessionDraft?.open}function ev(s){return s.currentSessionId}const Ea=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}`},tv=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 sv(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 ml(s){if(!(!s||s<=0))return Math.max(200,Math.floor(s))}function nv(s){const{diffRootRef:e,drafts:n,selection:a,editingDraftId:r,commentText:i,onTextChange:o,fileLabel:d,onSave:c,onCancel:f,onEdit:u,onDelete:p}=s,[m,P]=l.useState(0),[g,h]=l.useState(null),x=l.useMemo(()=>!a||r?null:Ea({type:"new",selection:a}),[r,a]),R=l.useMemo(()=>{const T=n.map(k=>Ea({type:k.id===r?"edit":"saved",draft:k}));return x&&T.push(x),T},[n,r,x]),C=l.useCallback(T=>{const k=e.current;if(!k)return null;const j=k.querySelector("diffs-container");if(!(j instanceof HTMLElement))return null;const b=j.querySelector(`[data-annotation-id="${T}"]`);if(b instanceof HTMLElement)return b;const A=j.shadowRoot;return A?A.querySelector(`[data-annotation-id="${T}"]`):null},[e]);l.useEffect(()=>{if(R.length===0)return;let T=!1,k=0;const j=12,b=()=>{T||R.every($=>!!C($))||k>=j||(k+=1,requestAnimationFrame(()=>{T||(P($=>$+1),b())}))};return b(),()=>{T=!0}},[R,C]),l.useEffect(()=>{const T=e.current;if(!T)return;const k=()=>{const b=getComputedStyle(T),A=sv(b.getPropertyValue("--oc-context-panel-width")),$=T.getBoundingClientRect(),F=A??$.width;h(F>0?F:null)};k();const j=new ResizeObserver(()=>{k()});return j.observe(T),window.addEventListener("resize",k),()=>{j.disconnect(),window.removeEventListener("resize",k)}},[e]);const N=l.useCallback(T=>{const j=e.current?.getBoundingClientRect(),b=T.closest("[data-annotation-content]"),A=b instanceof HTMLElement?b.getBoundingClientRect():T.getBoundingClientRect(),$=[A.width];j&&$.push(j.right-A.left);const F=$.filter(I=>Number.isFinite(I)&&I>0);return F.length>0?ml(Math.min(...F)):ml(g)},[e,g]);return t.jsxs(t.Fragment,{children:[n.map(T=>{const k=Ea({type:T.id===r?"edit":"saved",draft:T}),j=C(k);if(!j)return null;const b=N(j);return T.id===r?wa.createPortal(t.jsx(cl,{initialText:i,onTextChange:o,fileLabel:d,lineRange:{start:T.startLine,end:T.endLine,side:T.side==="original"?"deletions":"additions"},isEditing:!0,onSave:c,onCancel:f,maxWidth:b}),j,`draft-edit-${T.id}`):wa.createPortal(t.jsx(Ky,{draft:T,onEdit:()=>u(T),onDelete:()=>p(T),maxWidth:b}),j,`draft-card-${T.id}`)}),a&&!r&&x&&(()=>{const T=C(x);if(!T)return null;const k=N(T);return wa.createPortal(t.jsx(cl,{initialText:i,onTextChange:o,fileLabel:d,lineRange:a,isEditing:!1,onSave:c,onCancel:f,maxWidth:k}),T,x)})()]})}const ul=5e5,av=`
|
|
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
|
-
`,rv=`
|
|
53
|
-
${av}
|
|
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 iv(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 pl(s){const e=s.length>400?`${s.slice(0,200)}${s.slice(-200)}`:s;return`${s.length}:${iv(e)}`}const ov=(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),f=Math.max(1,d),u=Math.min(o.length,c);return f>u?"":o.slice(f-1,u).join(`
|
|
165
|
-
`)},lv=(s,e)=>s===e?!0:!s||!e?!1:s.start===e.start&&s.end===e.end&&s.side===e.side,cv=s=>s==="auto"||s==="scroll"||s==="overlay",dv=s=>{let e=s?.parentElement??null;for(;e;){const n=window.getComputedStyle(e);if(cv(n.overflowY))return e;e=e.parentElement}return null},mv=(s,e)=>{if(!s||!e||typeof window>"u")return()=>{};const n=dv(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)}},uv=(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)}},ja=new WeakMap,pv={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function gv(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 hv(s){if(typeof document>"u")return null;const e=gv(s);let n=ja.get(e.key);if(!n){const r=new fd;r.setup(e.root,e.content),n={virtualizer:r,refs:0},ja.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=ja.get(e.key);r&&(r.refs-=1,!(r.refs>0)&&(r.virtualizer.cleanUp(),ja.delete(e.key)))}}}const fv=(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)}},tj=({original:s,modified:e,fileDiff:n,language:a,fileName:r,renderSideBySide:i,wrapLines:o,layout:d="fill",enableComments:c=!0})=>{const f=za(),u=f?.currentTheme.metadata.variant==="dark",p=f?.availableThemes.find(H=>H.metadata.id===f.lightThemeId)??Ra(!1),m=f?.availableThemes.find(H=>H.metadata.id===f.darkThemeId)??Ra(!0),{isMobile:P}=Cs(),g=Gy({source:"diff",fileLabel:r||"unknown",language:a,getCodeForRange:H=>ov(s,e,n,H),toStoreRange:H=>({startLine:H.start,endLine:H.end,side:H.side==="deletions"?"original":"modified"}),fromDraftRange:H=>({start:H.startLine,end:H.endLine,side:H.side==="original"?"deletions":"additions"})}),{drafts:h,selection:x,setSelection:R,commentText:C,setCommentText:N,editingDraftId:T,saveComment:k,cancel:j,startEdit:b,deleteDraft:A}=g,$=he.useRef(null),F=he.useRef(null),I=he.useRef(""),v=he.useRef(!1),w=he.useRef(null);he.useEffect(()=>{$.current=x},[x]),he.useEffect(()=>{F.current=T},[T]),he.useEffect(()=>{I.current=C},[C]);const L=he.useCallback(H=>{if(!c||v.current)return;const te=$.current;if(!(!H&&te&&I.current.trim())){if(P&&te&&H&&H.side===te.side){const ae=Math.min(te.start,H.start),me=Math.max(te.end,H.end);R({...H,start:ae,end:me})}else R(H);H&&(F.current||N(""))}},[c,P,N,R]),E=he.useCallback(()=>{j()},[j]),_=he.useCallback(H=>{const te=document.createElement("div");te.style.position="relative";const ae=Ea(H.metadata);return te.dataset.annotationId=ae,te.dataset.annotationSide=H.side,te.dataset.annotationLine=String(H.lineNumber),te},[]),B=he.useCallback((H,te)=>{k(H,te??x??void 0)},[k,x]),Z=he.useCallback(H=>{R(H);const te=O.current;if(te)try{v.current=!0,te.setSelectedLines(H),w.current=H}catch{}finally{v.current=!1}},[R]),Q=he.useCallback(H=>{const te=H.closest("[data-line-type]")?.getAttribute("data-line-type")??H.getAttribute("data-line-type");if(te==="change-deletion")return"deletions";if(te==="change-addition")return"additions";const ae=H.getAttribute("data-column-side")??H.getAttribute("data-side")??H.closest("[data-column-side]")?.getAttribute("data-column-side");if(ae==="deletions"||ae==="left"||ae==="original")return"deletions";if(ae==="additions"||ae==="right"||ae==="modified")return"additions";const me=H.closest("[data-line-type]");if(me instanceof HTMLElement){const Me=me.getBoundingClientRect(),Ne=H.getBoundingClientRect(),De=Me.left+Me.width/2;return Ne.left+Ne.width/2<De?"deletions":"additions"}return"additions"},[]);Ta(p),Ta(m);const M=`${p.metadata.id}:${m.metadata.id}:${u?"dark":"light"}`,X=he.useMemo(()=>{if(n){const H=n.deletionLines.reduce((ae,me)=>ae+me.length,0),te=n.additionLines.reduce((ae,me)=>ae+me.length,0);return Math.max(H,te)>ul}return Math.max(s.length,e.length)>ul},[n,e.length,s.length]),ee=he.useRef(null),K=he.useRef(null),O=he.useRef(null),Y=he.useRef(null),U=he.useRef(null),ne=he.useRef(null),re=he.useRef(void 0),V=he.useRef(void 0),oe=he.useRef(void 0),fe=he.useRef(void 0),[,xe]=l.useReducer(H=>H+1,0),Ie=Rr(X?"unified":i?"split":"unified"),ve=he.useMemo(()=>Sr(p),[p]),we=he.useMemo(()=>Sr(m),[m]);l.useLayoutEffect(()=>{const H=ee.current;if(!H)return;const te=H.querySelector("diffs-container");if(!te)return;const ae=u?we:ve,me=(Je,de)=>Je.colors?.[de],Me=me(ve,"terminal.ansiGreen"),Ne=me(ve,"terminal.ansiRed"),De=me(ve,"terminal.ansiBlue"),Ee=me(we,"terminal.ansiGreen"),Pe=me(we,"terminal.ansiRed"),Te=me(we,"terminal.ansiBlue");te.style.setProperty("--shiki-light",ve.fg),te.style.setProperty("--shiki-light-bg",ve.bg),Me&&te.style.setProperty("--shiki-light-addition-color",Me),Ne&&te.style.setProperty("--shiki-light-deletion-color",Ne),De&&te.style.setProperty("--shiki-light-modified-color",De),te.style.setProperty("--shiki-dark",we.fg),te.style.setProperty("--shiki-dark-bg",we.bg),Ee&&te.style.setProperty("--shiki-dark-addition-color",Ee),Pe&&te.style.setProperty("--shiki-dark-deletion-color",Pe),Te&&te.style.setProperty("--shiki-dark-modified-color",Te),te.style.setProperty("--diffs-bg",ae.bg),te.style.setProperty("--diffs-fg",ae.fg);const Le=u?Ee:Me,Be=u?Pe:Ne,He=u?Te:De;Le&&te.style.setProperty("--diffs-addition-color-override",Le),Be&&te.style.setProperty("--diffs-deletion-color-override",Be),He&&te.style.setProperty("--diffs-modified-color-override",He);const Ue=te.shadowRoot?.querySelector("pre");Ue&&(Ue.style.setProperty("--shiki-light",ve.fg),Ue.style.setProperty("--shiki-light-bg",ve.bg),Me&&Ue.style.setProperty("--shiki-light-addition-color",Me),Ne&&Ue.style.setProperty("--shiki-light-deletion-color",Ne),De&&Ue.style.setProperty("--shiki-light-modified-color",De),Ue.style.setProperty("--shiki-dark",we.fg),Ue.style.setProperty("--shiki-dark-bg",we.bg),Ee&&Ue.style.setProperty("--shiki-dark-addition-color",Ee),Pe&&Ue.style.setProperty("--shiki-dark-deletion-color",Pe),Te&&Ue.style.setProperty("--shiki-dark-modified-color",Te),Ue.style.setProperty("--diffs-bg",ae.bg),Ue.style.setProperty("--diffs-fg",ae.fg),Le&&Ue.style.setProperty("--diffs-addition-color-override",Le),Be&&Ue.style.setProperty("--diffs-deletion-color-override",Be),He&&Ue.style.setProperty("--diffs-modified-color-override",He))},[we,M,u,ve]);const be=he.useMemo(()=>({theme:{dark:m.metadata.id,light:p.metadata.id},themeType:u?"dark":"light",diffStyle:i?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:X?0:1e3,maxLineLengthForHighlighting:X?1:1e3,tokenizeMaxLineLength:X?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:o?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:c,enableHoverUtility:!1,onLineSelected:c?L:void 0,unsafeCSS:rv,renderAnnotation:c?_:void 0}),[m.metadata.id,c,u,X,p.metadata.id,i,o,L,_]),se=he.useMemo(()=>c?tv({drafts:h,editingDraftId:T,selection:x}):[],[T,c,h,x]),le=he.useRef(se);if(he.useEffect(()=>{le.current=se},[se]),he.useEffect(()=>{const H=K.current;return()=>{O.current?.cleanUp(),O.current=null,Y.current?.release(),Y.current=null,U.current=null,ne.current=null,re.current=void 0,V.current=void 0,oe.current=void 0,fe.current=void 0,H&&(H.innerHTML="")}},[]),he.useEffect(()=>{if(typeof window>"u")return;const H=K.current,te=ee.current;if(!H||!Ie)return;const ae=mv(te,H);let me=Y.current;me||(me=hv(H),Y.current=me),Y.current=me;const Me=me?.virtualizer??null,Ne=n?void 0:{name:r||"",contents:s,lang:a,cacheKey:`old:${M}:${r}:${pl(s)}`},De=n?void 0:{name:r||"",contents:e,lang:a,cacheKey:`new:${M}:${r}:${pl(e)}`},Ee=n?V.current!==n:V.current!==void 0||!Ne||!De||!oe.current||!fe.current||!di(oe.current,Ne)||!di(fe.current,De),Pe=O.current,Te=!!(Pe&&(U.current!==Me||ne.current!==Ie||Me&&(re.current!==be.hunkSeparators||Ee)));Te&&(Pe?.cleanUp(),O.current=null,H.innerHTML="");let Le=O.current;const Be=!Te&&Pe?!pd(Pe.options,be):!1;if(Le?Le.setOptions(be):(Le=me?new gd(be,me.virtualizer,pv,Ie):new hd(be,Ie),O.current=Le,w.current=null),U.current=Me,ne.current=Ie,re.current=Me?be.hunkSeparators:void 0,V.current=n,oe.current=Ne,fe.current=De,n)Le.render({fileDiff:n,forceRender:Be,lineAnnotations:le.current,containerWrapper:H});else{if(!Ne||!De)return;Le.render({oldFile:Ne,newFile:De,forceRender:Be,lineAnnotations:le.current,containerWrapper:H})}const He=uv(H,()=>{ae(),fv(Le,me,xe)});return()=>{He(),ae()}},[M,n,r,a,e,be,s,Ie]),he.useEffect(()=>{const H=O.current;if(H){try{H.setLineAnnotations(se)}catch(te){console.error("Failed to apply diff line annotations",te);try{H.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(O.current===H){try{H.rerender()}catch{}xe()}})}},[se]),he.useEffect(()=>{const H=O.current;if(!H||x!==null)return;const te=w.current;if(!lv(x,te))try{v.current=!0,H.setSelectedLines(x),w.current=x}catch{}finally{v.current=!1}},[x]),he.useEffect(()=>{if(!c)return;const H=K.current;if(!H)return;let te=null,ae=()=>{};const me=()=>{const Ne=H.querySelector("diffs-container")?.shadowRoot;if(!Ne){te=requestAnimationFrame(me);return}const De=Ee=>{if(!(Ee instanceof MouseEvent)||Ee.button!==0||!(Ee.target instanceof Element))return;const Pe=Ee.target.closest("[data-column-number]");if(!(Pe instanceof HTMLElement))return;const Te=Pe.getAttribute("data-column-number"),Le=Te?parseInt(Te,10):NaN;if(Number.isNaN(Le))return;const Be=Q(Pe);L({start:Le,end:Le,side:Be}),Ee.preventDefault(),Ee.stopPropagation()};Ne.addEventListener("click",De,!0),ae=()=>{Ne.removeEventListener("click",De,!0)}};return me(),()=>{te!==null&&cancelAnimationFrame(te),ae()}},[M,c,r,L,Q]),he.useEffect(()=>{const H=K.current;if(!H)return;let te=null,ae=null;const Me=setTimeout(()=>{const Ne=H.querySelector("diffs-container");if(!(Ne instanceof HTMLElement))return;const De=Ne.shadowRoot;te=new MutationObserver(()=>{ae&&cancelAnimationFrame(ae),ae=requestAnimationFrame(()=>{xe(),ae=null})}),te.observe(Ne,{childList:!0,subtree:!0}),De&&te.observe(De,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(Me),ae&&cancelAnimationFrame(ae),te?.disconnect()}},[M,r]),typeof window>"u")return null;const ye=c?t.jsx(nv,{diffRootRef:ee,drafts:h,selection:x,editingDraftId:T,commentText:C,onTextChange:N,fileLabel:r?.split("/").pop()??"",onSave:B,onCancel:E,onEdit:H=>{Z({start:H.startLine,end:H.endLine,side:H.side==="original"?"deletions":"additions"}),b(H)},onDelete:A}):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(Wt,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:t.jsx("div",{ref:ee,className:"size-full relative",children:t.jsx("div",{ref:K,className:"size-full"})})}),ye]})}):t.jsxs("div",{className:ce("relative","w-full"),children:[t.jsx("div",{ref:ee,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative",children:t.jsx("div",{ref:K,className:"w-full"})}),ye]})},xv=()=>{const s=nt.c(13),[e,n]=he.useState(!1);let a,r;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(is())},r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),he.useEffect(a,r);let i;s[2]!==e?(i=async m=>e?await lu(m):{success:!0,path:m},s[2]=e,s[3]=i):i=s[3];const o=i;let d;s[4]!==e?(d=async m=>e?await cu():{success:!0},s[4]=e,s[5]=d):d=s[5];const c=d;let f;s[6]!==e?(f=async m=>e?await du():{success:!0},s[6]=e,s[7]=f):f=s[7];const u=f;let p;return s[8]!==e||s[9]!==o||s[10]!==c||s[11]!==u?(p={isDesktop:e,requestAccess:o,startAccessing:c,stopAccessing:u},s[8]=e,s[9]=o,s[10]=c,s[11]=u,s[12]=p):p=s[12],p},bv=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),yv=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:a,onCheckout:r,onCreate:i,remotes:o=[],disabled:d=!1})=>{const{t:c}=it(),[f,u]=l.useState(!1),[p,m]=l.useState(""),[P,g]=l.useState(!1),[h,x]=l.useState(!1),[R,C]=l.useState(""),[N,T]=l.useState(!1),k=l.useRef(null),j=l.useCallback(B=>{B.stopPropagation()},[]),b=o.length>1,A=l.useMemo(()=>bv(R),[R]),$=l.useMemo(()=>{const B=p.toLowerCase();return B?e.filter(Z=>Z.toLowerCase().includes(B)):e},[p,e]),F=l.useMemo(()=>{const B=p.toLowerCase();return B?n.filter(Z=>Z.toLowerCase().includes(B)):n},[p,n]),I=B=>{if(B===s){u(!1);return}r(B),u(!1),m("")},v=()=>{g(!0),setTimeout(()=>k.current?.focus(),50)},w=async()=>{if(!(!A||N)){if(b){x(!0);return}T(!0);try{await i(A,o[0]),C(""),g(!1),u(!1)}finally{T(!1)}}},L=async B=>{if(!(!A||N)){T(!0);try{await i(A,B),C(""),g(!1),x(!1),u(!1)}finally{T(!1)}}},E=()=>{x(!1)},_=()=>{C(""),g(!1),x(!1)};return l.useEffect(()=>{f||(m(""),g(!1),x(!1),C(""))},[f]),t.jsxs(gs,{open:f,onOpenChange:u,children:[t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(us,{asChild:!0,children:t.jsxs(G,{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(D,{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(D,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(Et,{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(Ir,{className:"h-full min-h-0",children:[t.jsx(Ar,{placeholder:c("gitView.branch.searchPlaceholder"),value:p,onValueChange:m,onKeyDown:j}),t.jsxs(Dr,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Er,{children:c("gitView.branch.empty")}),t.jsx(Bs,{children:h?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:E,disabled:N,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(D,{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:A})," ",c("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:o.map(B=>t.jsxs("button",{type:"button",onClick:()=>L(B),disabled:N,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:[N?t.jsx(D,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,B.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:B.pushUrl})]},B.name))})]}):P?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:k,placeholder:c("gitView.branch.newBranchPlaceholder"),value:R,onChange:B=>C(B.target.value),onClick:B=>B.stopPropagation(),onKeyDown:B=>{j(B),B.key==="Enter"?(B.preventDefault(),w()):B.key==="Escape"&&(B.preventDefault(),_())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:w,disabled:!A||N,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:N?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:_,disabled:N,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(D,{name:"close",className:"size-4"})})]}):t.jsxs(Ms,{onSelect:v,children:[t.jsx(D,{name:"add",className:"size-4"}),t.jsx("span",{children:c("gitView.branch.create")})]})}),t.jsx(Dn,{}),t.jsxs(Bs,{heading:c("gitView.branch.localBranches"),children:[$.map(B=>t.jsxs(Ms,{onSelect:()=>I(B),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:B}),(a?.[B]?.ahead||a?.[B]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[a[B].ahead||0," ahead ·"," ",a[B].behind||0," behind"]})]}),s===B&&t.jsx("span",{className:"typography-micro text-primary",children:c("gitView.branch.currentBadge")})]},`local-${B}`)),$.length===0&&t.jsx(Ms,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noLocalBranches")})})]}),t.jsx(Dn,{}),t.jsxs(Bs,{heading:c("gitView.branch.remoteBranches"),children:[F.map(B=>t.jsx(Ms,{onSelect:()=>I(B),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:B})},`remote-${B}`)),F.length===0&&t.jsx(Ms,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noRemoteBranches")})})]})]})]})})]})},vv=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),jv=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:a}=it(),[r,i]=l.useState(!1),[o,d]=l.useState(s||""),[c,f]=l.useState(!1),u=l.useRef(null),p=()=>{!s||!e||(d(s),i(!0),setTimeout(()=>u.current?.focus(),0))},m=async()=>{if(!s||!e||!o.trim())return;const h=vv(o);if(h===s){i(!1);return}f(!0);try{await e(s,h),i(!1),d("")}finally{f(!1)}},P=()=>{i(!1),d("")},g=h=>{h.key==="Enter"?(h.preventDefault(),m()):h.key==="Escape"&&(h.preventDefault(),P())};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:h=>{h.preventDefault(),m()},children:[t.jsx(D,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:u,value:o,onChange:h=>d(h.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:g,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(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:P,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(D,{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(D,{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(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:p,title:a("gitView.branch.renameTitle"),children:t.jsx(D,{name:"edit",className:"size-4"})})]})]})},wv={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3"},Nv={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 xc(s){return s&&Nv[s]||"var(--primary)"}const gl=s=>{const e=nt.c(8),{icon:n,className:a,colorToken:r}=s,i=wv[n??"branch"]??"user-3";let o;e[0]!==r?(o=xc(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(D,{name:i,className:a,style:d}),e[4]=a,e[5]=i,e[6]=d,e[7]=c):c=e[7],c},bc=s=>{const e=nt.c(35),{activeProfile:n,identities:a,onSelect:r,isApplying:i,iconOnly:o}=s,d=o===void 0?!1:o,{t:c}=it(),f=i||a.length===0,u=n?.color;let p;e[0]!==u?(p=xc(u),e[0]=u,e[1]=p):p=e[1];let m;e[2]!==p?(m={color:p},e[2]=p,e[3]=m):m=e[3];let P;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==i?(P=i?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(gl,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=i,e[7]=P):P=e[7];let g;e[8]!==n?.name||e[9]!==d||e[10]!==c?(g=!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]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=h):h=e[12];let x;e[13]!==f||e[14]!==m||e[15]!==P||e[16]!==g?(x=t.jsx(At,{asChild:!0,children:t.jsx(us,{asChild:!0,children:t.jsxs(G,{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:m,disabled:f,children:[P,g,h]})})}),e[13]=f,e[14]=m,e[15]=P,e[16]=g,e[17]=x):x=e[17];let R;e[18]!==c?(R=c("gitView.header.identityTooltip"),e[18]=c,e[19]=R):R=e[19];let C;e[20]!==R?(C=t.jsx(Et,{sideOffset:8,children:R}),e[20]=R,e[21]=C):C=e[21];let N;e[22]!==C||e[23]!==x?(N=t.jsxs(It,{children:[x,C]}),e[22]=C,e[23]=x,e[24]=N):N=e[24];let T;e[25]!==n?.id||e[26]!==a||e[27]!==r||e[28]!==c?(T=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 A=n?.id===b.id;return t.jsx(js,{onSelect:()=>r(b),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(gl,{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})]}),A?t.jsx(D,{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]=T):T=e[29];let k;e[30]!==T?(k=t.jsx(ps,{align:"end",className:"w-64",children:T}),e[30]=T,e[31]=k):k=e[31];let j;return e[32]!==N||e[33]!==k?(j=t.jsxs(gs,{children:[N,k]}),e[32]=N,e[33]=k,e[34]=j):j=e[34],j},kv=s=>{const e=nt.c(21),{comparison:n,trackingBranch:a,tooltipDelayMs:r}=s,i=r===void 0?1e3:r,{t:o}=it(),d=`${n.remote}/${n.branch}`,c=n.ahead===0&&n.behind===0;let f;e[0]!==o||e[1]!==d||e[2]!==a?(f=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]=f):f=e[3];const u=f;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(D,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=p):p=e[4];let m;e[5]!==d?(m=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:d}),e[5]=d,e[6]=m):m=e[6];let P;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==c||e[10]!==o?(P=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]=P):P=e[11];let g;e[12]!==m||e[13]!==P?(g=t.jsx(At,{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,m,P]})}),e[12]=m,e[13]=P,e[14]=g):g=e[14];let h;e[15]!==u?(h=t.jsx(Et,{sideOffset:8,children:u}),e[15]=u,e[16]=h):h=e[16];let x;return e[17]!==g||e[18]!==h||e[19]!==i?(x=t.jsxs(It,{delayDuration:i,children:[g,h]}),e[17]=g,e[18]=h,e[19]=i,e[20]=x):x=e[20],x},sj=s=>{const e=nt.c(54),{status:n,localBranches:a,remoteBranches:r,branchInfo:i,syncAction:o,remotes:d,onFetch:c,onSync:f,onRemoveRemote:u,removingRemoteName:p,onCheckoutBranch:m,onCreateBranch:P,onRenameBranch:g,activeIdentityProfile:h,availableIdentities:x,onSelectIdentity:R,isApplyingIdentity:C,isWorktreeMode:N,onOpenHistory:T,onOpenGraph:k,onOpenStashes:j,actionTabItems:b,activeActionTab:A,onSelectActionTab:$}=s,{t:F}=it();if(!n)return null;let I;e[0]!==k||e[1]!==T||e[2]!==j||e[3]!==F?(I=T||k||j?t.jsxs(gs,{children:[t.jsxs(It,{children:[t.jsx(At,{asChild:!0,children:t.jsx(us,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":F("gitView.header.repositoryViews"),children:t.jsx(D,{name:"git-repository",className:"size-4"})})})}),t.jsx(Et,{sideOffset:8,children:F("gitView.header.repositoryViews")})]}),t.jsxs(ps,{align:"end",children:[T?t.jsxs(js,{onSelect:T,children:[t.jsx(D,{name:"history",className:"size-4"}),F("gitView.history.title")]}):null,k?t.jsxs(js,{onSelect:k,children:[t.jsx(D,{name:"git-merge",className:"size-4"}),F("gitView.graph.title")]}):null,j?t.jsxs(js,{onSelect:j,children:[t.jsx(D,{name:"archive-stack",className:"size-4"}),F("gitView.stashes.title")]}):null]})]}):null,e[0]=k,e[1]=T,e[2]=j,e[3]=F,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 w=v,L=!n;let E;e[7]!==n.tracking?(E=n.tracking?.split("/")[0],e[7]=n.tracking,e[8]=E):E=e[8];const _=(n.files?.length??0)>0;let B;e[9]!==c||e[10]!==u||e[11]!==f||e[12]!==d||e[13]!==p||e[14]!==n.ahead||e[15]!==n.behind||e[16]!==o||e[17]!==L||e[18]!==E||e[19]!==_?(B=t.jsx(zy,{syncAction:o,remotes:d,onFetch:c,onSync:f,onRemoveRemote:u,removingRemoteName:p,disabled:L,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:E,hasUncommittedChanges:_}),e[9]=c,e[10]=u,e[11]=f,e[12]=d,e[13]=p,e[14]=n.ahead,e[15]=n.behind,e[16]=o,e[17]=L,e[18]=E,e[19]=_,e[20]=B):B=e[20];const Z=B;let Q;e[21]!==n.tracking||e[22]!==n.upstreamComparison?(Q=n.upstreamComparison?t.jsx(kv,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[21]=n.tracking,e[22]=n.upstreamComparison,e[23]=Q):Q=e[23];const M=Q;let X;e[24]!==h||e[25]!==x||e[26]!==C||e[27]!==R?(X=t.jsx(bc,{activeProfile:h,identities:x,onSelect:R,isApplying:C,iconOnly:!0}),e[24]=h,e[25]=x,e[26]=C,e[27]=R,e[28]=X):X=e[28];const ee=X;let K;e[29]!==i||e[30]!==N||e[31]!==a||e[32]!==m||e[33]!==P||e[34]!==g||e[35]!==r||e[36]!==d||e[37]!==n.current?(K=t.jsx("div",{className:"min-w-0 flex-1",children:N?t.jsx(jv,{currentBranch:n.current,onRename:g}):t.jsx(yv,{currentBranch:n.current,localBranches:a,remoteBranches:r,branchInfo:i,onCheckout:m,onCreate:P,remotes:d})}),e[29]=i,e[30]=N,e[31]=a,e[32]=m,e[33]=P,e[34]=g,e[35]=r,e[36]=d,e[37]=n.current,e[38]=K):K=e[38];let O;e[39]!==ee||e[40]!==w?(O=t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[w,ee]}),e[39]=ee,e[40]=w,e[41]=O):O=e[41];let Y;e[42]!==O||e[43]!==K?(Y=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[K,O]}),e[42]=O,e[43]=K,e[44]=Y):Y=e[44];let U;e[45]!==b||e[46]!==A||e[47]!==$||e[48]!==Z||e[49]!==M?(U=b&&A&&$?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(vn,{items:b,activeId:A,onSelect:$,layoutMode:"fit",variant:"active-pill",iconOnlyActiveTab:!0,activePillButtonClassName:"h-7",className:"h-full"})}),M?t.jsx("div",{className:"min-w-0 shrink",children:M}):null,t.jsx("div",{className:"shrink-0",children:Z})]}):null,e[45]=b,e[46]=A,e[47]=$,e[48]=Z,e[49]=M,e[50]=U):U=e[50];let ne;return e[51]!==Y||e[52]!==U?(ne=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[Y,U]}),e[51]=Y,e[52]=U,e[53]=ne):ne=e[53],ne},Sv=s=>s==="/",La=s=>s.replace(/\\/g,"/"),si=s=>{if(!s||Sv(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Fn=s=>s.endsWith("/"),Cv=s=>{const e=s.trim();return!e||Fn(e)?e:`${e}/`},ni=s=>s.lastIndexOf("/"),yc=s=>{if(Fn(s))return s;const e=ni(s);return e<0?s:s.slice(0,e+1)},Pv=s=>{const e=ni(s);return s.slice(e+1)},vc=s=>{const e=si(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=ni(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},Iv=s=>Fn(s)&&vc(s)!==null,Av=(s,e)=>`${yc(s)}${e}/`,un=s=>{if(!s)return null;const e=si(La(s.trim()));return e?e.toLowerCase():null},hl=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},Dv=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,Nr=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},Ev=async()=>{try{const s=await ht("/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 ys.getFilesystemHome().catch(()=>null)},nj=({open:s,onOpenChange:e})=>{const{t:n}=it(),a=bs(y=>y.homeDirectory),r=ns(y=>y.projects),i=ns(y=>y.addProject),o=ks(y=>y.profiles),d=ks(y=>y.globalIdentity),c=ks(y=>y.defaultGitIdentityId),f=ks(y=>y.loadProfiles),u=ks(y=>y.loadGlobalIdentity),p=ks(y=>y.loadDefaultGitIdentityId),{isDesktop:m,requestAccess:P,startAccessing:g}=xv(),{isMobile:h}=Cs(),x=l.useRef(null),R=l.useRef(null),C=l.useRef(new Map),[N,T]=l.useState(""),[k,j]=l.useState("~/"),[b,A]=l.useState([]),[$,F]=l.useState(!1),[I,v]=l.useState(!1),[w,L]=l.useState(0),[E,_]=l.useState(!1),[B,Z]=l.useState(!1),[Q,M]=l.useState(0),[X,ee]=l.useState(!1),[K,O]=l.useState(""),[Y,U]=l.useState(null),[ne,re]=l.useState(!1),V=N||a,oe=l.useMemo(()=>new Set(r.map(y=>un(y.path)).filter(y=>!!y)),[r]);l.useEffect(()=>{if(!s)return;j("~/"),A([]),L(0),_(!1),Z(!1),ee(!1),O(""),U(null),re(!1),requestAnimationFrame(()=>Nr(x.current));let y=!1;return(async()=>{const Ae=await Ev();y||(T(Ae||a||""),requestAnimationFrame(()=>Nr(x.current)))})(),()=>{y=!0}},[a,s]),l.useEffect(()=>{s&&(f(),u(),p())},[p,f,u,s]);const fe=l.useMemo(()=>{const y=new Map;d&&y.set(d.id,d);for(const pe of o)y.set(pe.id,pe);return Array.from(y.values())},[o,d]);l.useEffect(()=>{if(!s||!X||Y!==null)return;const y=typeof c=="string"?c.trim():"";if(y&&fe.some(Ae=>Ae.id===y)){U(y);return}const pe=fe.find(Ae=>Ae.authType==="ssh"||Ae.sshKey);pe&&U(pe.id)},[fe,c,X,s,Y]);const xe=l.useMemo(()=>fe.find(y=>y.id===Y)??null,[fe,Y]),Ie=l.useMemo(()=>yc(k),[k]),ve=l.useMemo(()=>Fn(k)?"":Pv(k),[k]),we=l.useMemo(()=>V?hl(Ie,V):"",[Ie,V]);l.useEffect(()=>{if(!s||!we){A([]);return}let y=!1;return F(!0),v(!1),ys.listLocalDirectory(we).then(pe=>{if(y)return;v(!1);const Ae=pe.filter(Oe=>Oe.isDirectory).map(Oe=>({name:Oe.name,path:La(Oe.path)})).sort((Oe,qe)=>Oe.name.localeCompare(qe.name));A(Ae)}).catch(()=>{y||(A([]),v(!0))}).finally(()=>{y||F(!1)}),()=>{y=!0}},[we,s]);const be=l.useMemo(()=>{const y=ve.toLowerCase(),pe=ne||ve.startsWith(".");return b.filter(Ae=>Ae.name.toLowerCase().startsWith(y)&&(pe||!Ae.name.startsWith(".")))},[ve,b,ne]),se=l.useMemo(()=>{const y=[];Iv(k)&&y.push({type:"up",value:"browse:up",name:"..",path:vc(k)});for(const pe of be){const Ae=un(pe.path);y.push({type:"directory",value:`browse:${pe.path}`,name:pe.name,path:pe.path,disabled:!!(Ae&&oe.has(Ae))})}return y},[oe,be,k]);l.useEffect(()=>{L(0)},[k,se.length]);const le=l.useMemo(()=>V?si(hl(k,V)):"",[V,k]),ye=un(le),H=!!(ye&&oe.has(ye)),te=l.useMemo(()=>ve?be.find(y=>y.name===ve)??null:null,[ve,be]),ae=!!(le&&!H&&(Fn(k)&&I||!Fn(k)&&ve.trim().length>0&&te===null)),me=!E&&!B&&!H&&!!le,Me=me&&K.trim().length>0,Ne=se[w]??null,De=!!(Ne&&(Ne.type==="up"||Ne.type==="directory"&&!Ne.disabled)),Ee=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",Pe=n(H?"directoryExplorerDialog.actions.alreadyAdded":X?E?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":E?"directoryExplorerDialog.actions.adding":ae?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");l.useLayoutEffect(()=>{const y=R.current;if(!y)return;const pe=()=>M(Math.ceil(y.getBoundingClientRect().width));if(pe(),typeof ResizeObserver>"u")return;const Ae=new ResizeObserver(pe);return Ae.observe(y),()=>Ae.disconnect()},[Pe]),l.useLayoutEffect(()=>{const y=x.current;y&&(y.scrollLeft=y.scrollWidth)},[Q,k]),l.useLayoutEffect(()=>{s&&Nr(x.current)},[s]),l.useLayoutEffect(()=>{const y=se[w];y&&C.current.get(y.value)?.scrollIntoView({block:"nearest"})},[w,se]);const Te=l.useCallback(()=>{e(!1)},[e]),Le=l.useCallback((y,pe)=>{y.stopPropagation();const Ae=un(pe);if(Ae&&oe.has(Ae))return;i(pe)||W.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")})},[i,oe,n]),Be=l.useCallback(async y=>{if(!y||E)return;const pe=un(y);if(pe&&oe.has(pe))return;let Ae=y;_(!0);try{const Oe=!X&&ae&&un(y)===un(le);if(X){const at=K.trim();if(!at){W.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Ae=(await ys.cloneRepository({remoteUrl:at,destinationPath:y,gitIdentityId:xe?.id??null})).path}else Oe&&await ys.createDirectory(y);if(!i(Ae)){W.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Te()}catch(Oe){W.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Oe instanceof Error?Oe.message:n("directoryExplorerDialog.toast.unknownError")})}finally{_(!1)}},[i,oe,K,Te,X,E,xe?.id,ae,le,n]),He=l.useCallback(y=>{j(Cv(y))},[]),Ue=l.useCallback(y=>{j(Av(k,y.name))},[k]),Je=l.useCallback(y=>{if(y){if(y.type==="up"){y.path&&He(y.path);return}y.disabled||Ue(y)}},[He,Ue]),de=l.useCallback(async()=>{if(!(!m||B)){Z(!0);try{const y=await P(le);if(!y.success||!y.path){y.error&&y.error!=="Directory selection cancelled"&&W.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:y.error});return}const pe=await g(y.path);if(!pe.success){W.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:pe.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await Be(y.path)}catch(y){W.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:y instanceof Error?y.message:n("directoryExplorerDialog.toast.unknownError")})}finally{Z(!1)}}},[Be,m,B,P,g,n,le]),q=l.useCallback(y=>{if(y.key==="ArrowDown"){y.preventDefault(),L(pe=>Math.min(se.length-1,pe+1));return}if(y.key==="ArrowUp"){y.preventDefault(),L(pe=>Math.max(0,pe-1));return}if(y.key==="Enter"){if(y.preventDefault(),Dv(y)){Be(le);return}De&&Je(Ne);return}y.key==="Backspace"&&k===""&&(y.preventDefault(),Te())},[Je,Be,Te,De,Ne,k,se.length,le]),ue=t.jsxs("button",{type:"button",onClick:()=>re(y=>!y),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:[ne?t.jsx(D,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(D,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),je=t.jsxs("div",{className:"px-2.5 py-1.5",children:[X?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(Ze,{value:K,onChange:y=>O(y.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(bc,{activeProfile:xe,identities:fe,onSelect:y=>U(y.id),isApplying:E,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(D,{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(Ze,{ref:x,value:k,onChange:y=>j(La(y.target.value)),onKeyDown:q,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!h&&Q>0?{paddingRight:`${Q+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),h?null:t.jsx(G,{ref:R,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:X?!Me:!me,onMouseDown:y=>y.preventDefault(),onClick:()=>{Be(le)},title:Pe,children:Pe})]})]}),Re=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")}),$?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((y,pe)=>{const Ae=pe===w;return t.jsxs("button",{ref:Oe=>{Oe?C.current.set(y.value,Oe):C.current.delete(y.value)},type:"button",disabled:y.type==="directory"&&y.disabled,onMouseEnter:()=>L(pe),onMouseDown:Oe=>Oe.preventDefault(),onClick:()=>Je(y),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",Ae&&"bg-interactive-selection text-interactive-selection-foreground",!Ae&&"hover:bg-interactive-hover/50",y.type==="directory"&&y.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[y.type==="up"?t.jsx(D,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(D,{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:y.name})}),y.type==="directory"&&y.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")}):y.type==="directory"?t.jsx("button",{type:"button",onMouseDown:Oe=>Oe.stopPropagation(),onClick:Oe=>Le(Oe,y.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(D,{name:"add",className:"h-3.5 w-3.5"})}):null]},y.value)})})]})}),Ce=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[je,Re]}),_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(D,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(D,{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(D,{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:Ee}),t.jsx(D,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),J=()=>t.jsxs(t.Fragment,{children:[h?null:_e,t.jsxs("div",{className:ce("flex w-full flex-row justify-end gap-2 sm:w-auto",h&&"justify-stretch"),children:[m?t.jsx(G,{variant:"ghost",size:"xs",onClick:de,disabled:E||B||X,children:n(B?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(G,{variant:"ghost",size:"xs",onClick:()=>ee(y=>!y),disabled:E||B,className:ce(h&&"flex-1"),children:n(X?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),h?t.jsx(G,{size:"xs",onClick:()=>{Be(le)},disabled:X?!Me:!me,className:"flex-1",children:Pe}):null]})]});return h?t.jsx(Xn,{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:J()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:ue}),Ce]})}):t.jsx(Ot,{open:s,onOpenChange:e,children:t.jsxs(zt,{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(Kt,{children:n("directoryExplorerDialog.title")}),t.jsx(Bt,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),ue]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:Ce}),t.jsx(Jt,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:J()})]})})};function fl(s){const{localBranches:e,remoteBranches:n,query:a}=s,r=a.trim();if(!r)return{matching:[],otherLocal:e,otherRemote:n};const i=ki(e,r,u=>u),o=ki(n,r,u=>u),d=[],c=i.other,f=o.other;for(const u of i.matching)d.push({label:u,value:u,source:"local"});for(const u of o.matching)d.push({label:u,value:`remotes/${u}`,source:"remote"});return d.sort((u,p)=>{const m=u.label.localeCompare(p.label,void 0,{sensitivity:"accent"});return m!==0?m:u.source!==p.source?u.source.localeCompare(p.source):u.value.localeCompare(p.value)}),{matching:d,otherLocal:c,otherRemote:f}}function Mv({open:s,onOpenChange:e,onSelect:n}){const{t:a}=it(),r=ze(se=>se.isMobile),{github:i}=Qr(),o=_s(se=>se.status),d=_s(se=>se.hasChecked),c=ze(se=>se.setSettingsDialogOpen),f=ze(se=>se.setSettingsPage),u=ns(se=>se.getActiveProject()),p=u?.path??null,m=he.useMemo(()=>p&&u?{id:u.id,path:p}:null,[u,p]),[P,g]=he.useState("issues"),[h,x]=he.useState(""),[R,C]=he.useState([]),[N,T]=he.useState([]),[k,j]=he.useState(!1),[b,A]=he.useState(!1),[$,F]=he.useState(null),[I,v]=he.useState(null),[w,L]=he.useState(null),[E,_]=he.useState(!1),[B,Z]=he.useState(new Map),[Q,M]=he.useState(1),[X,ee]=he.useState(!1),K=Fm(h,350),O=he.useCallback(async se=>{if(!(!p||!i)&&!(d&&o?.connected===!1)){j(!0),F(null),M(1),ee(!1);try{if(P==="issues"&&i.issuesList){const le=await i.issuesList(p,{page:1,query:se});le.connected===!1?(F(a("session.githubIntegration.error.notConnected")),C([])):(C(le.issues??[]),M(le.page??1),ee(!!le.hasMore))}else if(P==="prs"&&i.prsList){const le=await i.prsList(p,{page:1,query:se});le.connected===!1?(F(a("session.githubIntegration.error.notConnected")),T([])):(T(le.prs??[]),M(le.page??1),ee(!!le.hasMore))}}catch(le){F(le instanceof Error?le.message:a("session.githubIntegration.error.loadDataFailed"))}finally{j(!1)}}},[p,i,d,o,P,a]);he.useEffect(()=>{if(!s||!p||d&&o?.connected===!1||!i)return;if(!K.trim()){O();return}const se=new AbortController;j(!0),F(null),M(1),ee(!1);const le=P==="issues"&&i.issuesList?i.issuesList(p,{page:1,query:K.trim()}):P==="prs"&&i.prsList?i.prsList(p,{page:1,query:K.trim()}):null;if(!le){j(!1);return}return le.then(ye=>{se.signal.aborted||("issues"in ye?ye.connected===!1?(F(a("session.githubIntegration.error.notConnected")),C([])):(C(ye.issues??[]),M(ye.page??1),ee(!!ye.hasMore)):"prs"in ye&&(ye.connected===!1?(F(a("session.githubIntegration.error.notConnected")),T([])):(T(ye.prs??[]),M(ye.page??1),ee(!!ye.hasMore))))}).catch(ye=>{se.signal.aborted||F(ye instanceof Error?ye.message:a("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{se.signal.aborted||j(!1)}),()=>se.abort()},[s,p,i,d,o,P,K,O,a]);const Y=he.useCallback(async()=>{if(!(!p||!i)&&!(k||b)&&X){A(!0);try{const se=Q+1;if(P==="issues"&&i.issuesList){const le=K.trim()?await i.issuesList(p,{page:se,query:K.trim()}):await i.issuesList(p,{page:se});le.connected!==!1&&(C(ye=>[...ye,...le.issues??[]]),M(le.page??se),ee(!!le.hasMore))}else if(P==="prs"&&i.prsList){const le=K.trim()?await i.prsList(p,{page:se,query:K.trim()}):await i.prsList(p,{page:se});le.connected!==!1&&(T(ye=>[...ye,...le.prs??[]]),M(le.page??se),ee(!!le.hasMore))}}catch{}finally{A(!1)}}},[p,i,P,Q,X,k,b,K]);he.useEffect(()=>{if(!s){g("issues"),x(""),C([]),T([]),v(null),L(null),_(!1),F(null),Z(new Map),M(1),ee(!1);return}O()},[s,O]);const U=he.useCallback(async se=>{if(!(!m||!se)&&!B.has(se))try{const ye=(await Ml(m,{mode:"new",branchName:se,worktreeName:se})).errors.find(H=>H.code==="branch_in_use");Z(H=>new Map(H).set(se,{isValid:!ye,error:ye?a(ye.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{Z(le=>new Map(le).set(se,{isValid:!1,error:a("session.githubIntegration.validation.failed")}))}},[m,B,a]);he.useEffect(()=>{!s||P!=="prs"||N.forEach(se=>{se.head&&U(se.head)})},[s,P,N,U]);const ne=d&&o?.connected===!0,re=()=>{f("github"),c(!0)},V=se=>{v(se),L(null)},oe=se=>{L(se),v(null)},fe=()=>{I?n({type:"issue",item:I}):w&&n({type:"pr",item:w,includeDiff:E}),e(!1)},xe=()=>{v(null),L(null),_(!1)},Ie=I||w&&B.get(w.head??"")?.isValid!==!1,ve=se=>se.head?B.get(se.head)?.isValid===!1:!0,we=t.jsx(t.Fragment,{children:ne?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(D,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Ze,{value:h,onChange:se=>x(se.target.value),placeholder:a(P==="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:[k&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(D,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),$&&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(D,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:$})]})}),!k&&!$&&P==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[R.length>0?R.map(se=>t.jsx("button",{onClick:()=>V(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")}),X&&!b&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{Y()},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(D,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!k&&!$&&P==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[N.length>0?N.map(se=>{const le=ve(se),ye=se.head?B.get(se.head):void 0;return t.jsx("button",{onClick:()=>!le&&oe(se),disabled:le,className:ce("w-full text-left px-2 py-1.5 rounded transition-colors",w?.number===se.number?"bg-interactive-selection text-interactive-selection-foreground":le?"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,le&&ye?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:ye.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")}),X&&!b&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{Y()},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(D,{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(D,{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(G,{onClick:re,size:"sm",children:a("session.githubIntegration.connect.action")})]})}),be=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||w)&&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(D,{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:w?.number??""})}),t.jsx("button",{onClick:xe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(D,{name:"close",className:"h-3.5 w-3.5"})})]}),P==="prs"&&w&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(kt,{checked:E,onChange:se=>_(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(G,{variant:"outline",size:"sm",onClick:()=>e(!1),className:ce(r&&"flex-1"),children:a("session.githubIntegration.actions.cancel")}),t.jsx(G,{size:"sm",onClick:fe,disabled:!Ie,className:ce(r&&"flex-1"),children:a("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:r?t.jsx(Xn,{open:s,title:a("session.githubIntegration.title"),onClose:()=>e(!1),footer:ne?be: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(vn,{items:[{id:"issues",label:a("session.githubIntegration.tabs.issues"),icon:t.jsx(D,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:a("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(D,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:P,onSelect:le=>{g(le),x("")},variant:"active-pill",layoutMode:"fit"})}),(I||w)&&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(D,{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:w?.number??""})}),t.jsx("button",{onClick:xe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(D,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:we}):t.jsx(Ot,{open:s,onOpenChange:e,children:t.jsxs(zt,{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(Kt,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(D,{name:"github",className:"h-5 w-5"}),a("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(vn,{items:[{id:"issues",label:a("session.githubIntegration.tabs.issues"),icon:t.jsx(D,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:a("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(D,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:P,onSelect:se=>{g(se),x("")},variant:"active-pill",layoutMode:"fit"})})]})}),we,t.jsx(Jt,{className:"mt-1",children:be})]})})})}const Yn=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),xl="oc:lastWorktreeSourceBranch",Rv=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",bl=(s,e,n)=>{const a=Yn(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(f=>{const u=f.indexOf("/");return u<=0||u>=f.length-1?!1:f.slice(u+1)===a});if(r){const f=r.indexOf("/"),u=r.slice(0,f);return{existingBranch:`remotes/${r}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:a,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${u}/${a}`}}const i=String(s.headLabel||"").split(":")[0]?.trim(),o=s.headRepo?.owner||i||"pr-head",d=`pr-${Rv(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}`}},Tv=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
166
|
-
${JSON.stringify(e,null,2)}`},Fv=s=>`GitHub pull request context (JSON)
|
|
167
|
-
${JSON.stringify(s,null,2)}`;function aj({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:a}=it(),{github:r,git:i}=Qr(),o=ze(J=>J.isMobile),d=_s(J=>J.status),c=_s(J=>J.hasChecked),f=ns(J=>J.getActiveProject()),u=f?.path??null,p=he.useMemo(()=>u&&f?{id:f.id,path:u}:null,[f,u]),[m,P]=he.useState("new-branch"),[g,h]=he.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,R]=he.useState({selectedBranch:"",worktreeName:""}),C=Lm(u),N=Om(u),T=zm(J=>J.fetchBranches),k=he.useMemo(()=>C?.all?C.all.filter(J=>!J.startsWith("remotes/")).sort():[],[C]),j=he.useMemo(()=>C?.all?C.all.filter(J=>J.startsWith("remotes/")).map(J=>J.replace(/^remotes\//,"")).sort():[],[C]),b=Ns(J=>J.availableWorktreesByProject),A=he.useMemo(()=>{if(!u)return new Set;const J=b.get(u)??[];return new Set(J.map(y=>y.name))},[b,u]),$=he.useCallback((J=10)=>{for(let y=0;y<J;y++){const pe=Qa();if(!A.has(pe))return pe}return`${Qa()}-${Date.now().toString(36).slice(-4)}`},[A]),[F,I]=he.useState(!1),[v,w]=he.useState(!1),[L,E]=he.useState(!1),[_,B]=he.useState(!1),[Z,Q]=he.useState(!1),[M,X]=he.useState(""),[ee,K]=he.useState(""),O=he.useRef(null),Y=he.useRef(null),U=he.useRef(null),ne=he.useRef(null),re=he.useCallback(J=>{J.stopPropagation()},[]),V=he.useCallback(J=>{let y=J;for(;y&&y!==document.body;){const{overflowY:pe}=window.getComputedStyle(y);if((pe==="auto"||pe==="scroll")&&y.scrollHeight>y.clientHeight)return y;y=y.parentElement}return null},[]),oe=he.useCallback(J=>{J&&(J.scrollTop=0)},[]),fe=he.useCallback(J=>{const y=J.current?.querySelector('[data-slot="command-list"]')??null;oe(y)},[oe]),xe=he.useCallback(J=>{const y=V(J.current);oe(y)},[V,oe]),Ie=he.useMemo(()=>fl({localBranches:k,remoteBranches:j,query:M}),[k,j,M]),ve=he.useMemo(()=>fl({localBranches:k,remoteBranches:j,query:ee}),[k,j,ee]),we=M.trim().length>0,be=ee.trim().length>0,se=Ie.matching.length>0,le=ve.matching.length>0,ye=!!(u&&i),H=he.useCallback(()=>{!u||!i||T(u,i)},[u,i,T]);he.useEffect(()=>{!s||!u||!i||C?.all||T(u,i)},[s,u,i,C?.all,T]),he.useEffect(()=>{!v&&!_&&X("")},[v,_]),he.useEffect(()=>{!L&&!Z&&K("")},[L,Z]),he.useEffect(()=>{v&&fe(O),_&&xe(U)},[v,_,M,fe,xe]),he.useEffect(()=>{L&&fe(Y),Z&&xe(ne)},[L,Z,ee,fe,xe]);const[te,ae]=he.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[me,Me]=he.useState(!1),[Ne,De]=he.useState(null),Ee=he.useCallback(()=>{const J=lt.getState(),y=J.getVisibleAgents();if(J.settingsDefaultAgent){const pe=y.find(Ae=>Ae.name===J.settingsDefaultAgent);if(pe)return pe.name}return y.find(pe=>pe.name==="build")?.name||y[0]?.name},[]),Pe=he.useCallback(()=>{const J=lt.getState(),y=J.settingsDefaultModel;if(!y)return null;const pe=fn(y);if(!pe)return null;const{providerId:Ae,modelId:Oe}=pe;return J.getModelMetadata(Ae,Oe)?{providerID:Ae,modelID:Oe}:null},[]),Te=he.useCallback((J,y)=>{const pe=lt.getState(),Ae=pe.settingsDefaultVariant,Oe=pe.currentProviderId===J&&pe.currentModelId===y?pe.currentVariant:void 0,rt=pe.providers.find(st=>st.id===J)?.models.find(st=>st.id===y)?.variants;if(!rt)return Ae||Oe||void 0;if(Ae&&Object.prototype.hasOwnProperty.call(rt,Ae))return Ae;if(Oe&&Object.prototype.hasOwnProperty.call(rt,Oe))return Oe},[]),Le=he.useCallback(async J=>{if(!u||!r)return;const y=lt.getState(),pe=Km.getState().lastUsedProvider,Ae=Pe(),Oe=Ae?.providerID||y.currentProviderId||pe?.providerID,qe=Ae?.modelID||y.currentModelId||pe?.modelID,at=Ee()||y.currentAgentName||void 0;if(!Oe||!qe){W.error(a("session.newWorktree.error.noModelSelected"));return}const rt=Te(Oe,qe);if(J.issue){if(!r.issueGet||!r.issueComments)return;const st=await r.issueGet(u,J.issue.number);if(st.connected===!1||!st.repo||!st.issue)throw new Error("Failed to load issue context");const dt=await r.issueComments(u,J.issue.number);if(dt.connected===!1)throw new Error("Failed to load issue comments");const Ye=await ia("github.issue.review.visible",{issue_number:String(J.issue.number)}),$e=await ia("github.issue.review.instructions"),mt=Tv({repo:st.repo,issue:st.issue,comments:dt.comments??[]});await Ns.getState().sendMessage(Ye,Oe,qe,at,void 0,void 0,[{text:$e,synthetic:!0},{text:mt,synthetic:!0}],rt,void 0,{sessionId:J.sessionId}),W.success(a("session.newWorktree.toast.sessionFromIssue"));return}if(J.pr){if(!r.prContext)return;const st=await r.prContext(u,J.pr.number,{includeDiff:J.includeDiff,includeCheckDetails:!1});if(st.connected===!1||!st.repo||!st.pr)throw new Error("Failed to load PR context");const dt=await ia("github.pr.review.visible",{pr_number:String(J.pr.number)}),Ye=await ia("github.pr.review.instructions"),$e=Fv(st);await Ns.getState().sendMessage(dt,Oe,qe,at,void 0,void 0,[{text:Ye,synthetic:!0},{text:$e,synthetic:!0}],rt,void 0,{sessionId:J.sessionId}),W.success(a("session.newWorktree.toast.sessionFromPr"))}},[r,u,Ee,Pe,Te,a]),Be=m==="new-branch"?g:x;he.useEffect(()=>{if(!C?.all||!u||g.sourceBranch)return;(async()=>{try{const y=await $m(u).catch(()=>null),pe=localStorage.getItem(xl),Ae=pe&&C.all?.includes(pe)?pe:y&&C.all?.includes(y)?y:C.all?.includes("main")?"main":C.all?.includes("master")?"master":C.all?.[0]||"";Ae&&h(Oe=>({...Oe,sourceBranch:Ae}))}catch{}})()},[C,u,g.sourceBranch]),he.useEffect(()=>{if(!s)return;P("new-branch"),R({selectedBranch:"",worktreeName:""}),w(!1),E(!1),B(!1),Q(!1),X(""),K(""),ae({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const J=$();h({branchName:J,worktreeName:J,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,$]),he.useEffect(()=>{if(m!=="new-branch"||!g.isSyncingWorktreeName)return;const J=Yn(g.branchName),y=xs(J);h(pe=>({...pe,worktreeName:y}))},[m,g.branchName,g.isSyncingWorktreeName]);const He=he.useCallback(async()=>{if(!p||!te.touched||me)return;Ne&&Ne.abort();const J=new AbortController;De(J),ae(y=>({...y,isValidating:!0}));try{const y=m==="new-branch"?g.branchName:x.selectedBranch,pe=Be.worktreeName,Ae=Yn(y),Oe=xs(pe);let qe=null,at=null;if(Ae||(qe=a("session.newWorktree.error.branchNameRequired")),Oe||(at=a("session.newWorktree.error.worktreeDirectoryRequired")),Ae&&Oe){const rt=m==="new-branch"?g.linkedPr:null,st=rt?bl(rt,k,j):null,dt=await Ml(p,{mode:m==="existing-branch"||st?"existing":"new",branchName:Ae,worktreeName:Oe,existingBranch:st?.existingBranch??(m==="existing-branch"?Ae:void 0),...st?.ensureRemoteName?{ensureRemoteName:st.ensureRemoteName}:{},...st?.ensureRemoteUrl?{ensureRemoteUrl:st.ensureRemoteUrl}:{}});if(J.signal.aborted)return;dt.ok||dt.errors.forEach(Ye=>{if(Ye.code==="worktree_exists"){at=at??Ye.message;return}Ye.code.startsWith("branch_")&&(qe=qe??Ye.message)})}J.signal.aborted||ae(rt=>({...rt,isValidating:!1,branchError:qe,worktreeError:at}))}catch{J.signal.aborted||ae(y=>({...y,isValidating:!1}))}},[p,m,g.branchName,g.linkedPr,x.selectedBranch,Be.worktreeName,k,j,te.touched,Ne,me,a]),Ue=m==="new-branch"?g.branchName:x.selectedBranch;he.useEffect(()=>{if(!s||!p||!te.touched||me)return;const J=setTimeout(()=>{He()},300);return()=>clearTimeout(J)},[Be.worktreeName,Ue,s,p,He,te.touched,me]);const Je=async()=>{if(!p||!u){W.error(a("session.newWorktree.error.noActiveProject"));return}ae(Oe=>({...Oe,touched:!0}));const J=m==="new-branch"?g.branchName:x.selectedBranch,y=Be.worktreeName,pe=Yn(J),Ae=xs(y);if(!pe){W.error(a("session.newWorktree.error.branchNameRequired"));return}if(!Ae){W.error(a("session.newWorktree.error.worktreeDirectoryRequired"));return}Ne&&(Ne.abort(),De(null)),ae(Oe=>({...Oe,isValidating:!1,branchError:null,worktreeError:null})),Me(!0);try{const Oe=m==="new-branch"?g.linkedPr:null,qe=m==="new-branch"?g.linkedIssue:null,at=m==="new-branch"?g.linkedPr:null,rt=m==="new-branch"?g.includePrDiff:!1,st=!!(qe||at),dt=await Il(p),Ye=g.sourceBranch;let $e="";const mt=(()=>{if(Oe){const We=bl(Oe,k,j);return $e=We.sourceLabel,{preferredName:pe||Ae,mode:"existing",branchName:pe,worktreeName:Ae,existingBranch:We.existingBranch,setupCommands:dt,setUpstream:We.setUpstream,upstreamRemote:We.upstreamRemote,upstreamBranch:We.upstreamBranch,returnAfterDirectoryCreated:!0,...We.ensureRemoteName?{ensureRemoteName:We.ensureRemoteName}:{},...We.ensureRemoteUrl?{ensureRemoteUrl:We.ensureRemoteUrl}:{}}}return $e=m==="new-branch"?Ye:"",{preferredName:pe||Ae,mode:m==="existing-branch"?"existing":"new",branchName:m==="existing-branch"?void 0:pe,worktreeName:Ae,existingBranch:m==="existing-branch"?pe:void 0,setupCommands:dt,returnAfterDirectoryCreated:!0,...Ye&&m==="new-branch"?{startRef:Ye}:{}}})(),ge=await Um(u,mt),et=await Bm(p,ge);let tt=null;if(st){await Al(p)&&await Vm(et.path);const We=qe?`#${qe.number} ${qe.title}`.trim():at?`#${at.number} ${at.title}`.trim():a("session.newWorktree.newSessionTitle"),xt=await _m(We,et.path,null);if(!xt?.id)throw new Error("Failed to create session");tt=xt.id,n?.(et.path,{sessionId:tt}),e(!1),Me(!1),Hm(xt.id,We).catch(()=>{});try{Ns.getState().initializeNewOpenChamberSession(xt.id,lt.getState().agents)}catch{}}else e(!1),Me(!1);g.sourceBranch&&m==="new-branch"&&!g.linkedPr&&localStorage.setItem(xl,g.sourceBranch),W.success(a("session.newWorktree.toast.worktreeCreated"),{description:a("session.newWorktree.toast.worktreeCreatedDescription",{target:`${et.branch||et.name}${$e?` ${a("session.newWorktree.fromSource",{source:$e})}`:""}`})}),tt?Le({sessionId:tt,directory:et.path,issue:qe,pr:at,includeDiff:rt}).catch(We=>{const xt=We instanceof Error?We.message:a("session.newWorktree.error.sendGitHubContextFailed");W.error(a("session.newWorktree.error.sendGitHubContextFailed"),{description:xt})}):n?.(et.path)}catch(Oe){const qe=Oe instanceof Error?Oe.message:a("session.newWorktree.error.createWorktreeFailed");W.error(a("session.newWorktree.error.createWorktreeFailed"),{description:qe})}finally{Me(!1)}},de=J=>{P(J),ae(y=>({...y,touched:!1,branchError:null,worktreeError:null}))},q=J=>{if(!J){h(y=>({...y,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(J.type==="issue"){const y=J.item,pe=`issue-${y.number}-${Qa()}`;h(Ae=>({...Ae,linkedIssue:y,linkedPr:null,includePrDiff:!1,branchName:pe,worktreeName:xs(pe),isSyncingWorktreeName:!0}))}else if(J.type==="pr"){const y=J.item;h(pe=>({...pe,linkedPr:y,linkedIssue:null,includePrDiff:J.includeDiff??!1,branchName:y.head,worktreeName:xs(y.head),isSyncingWorktreeName:!0}))}},ue=c&&d?.connected===!0,Re=(m==="existing-branch"?!!x.selectedBranch&&!!x.worktreeName&&!te.branchError&&!te.worktreeError:!!Yn(g.branchName)&&!!g.worktreeName&&!te.branchError&&!te.worktreeError)&&!me,Ce=()=>{h(J=>({...J,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(D,{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(G,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:me,className:ce(o&&"flex-1"),children:a("session.newWorktree.actions.cancel")}),t.jsxs(G,{size:"sm",onClick:Je,disabled:!Re||me,className:ce("gap-1.5",o&&"flex-1"),children:[me&&t.jsx(D,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),a(me?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[o?t.jsxs(Xn,{open:s,title:a("session.newWorktree.title"),onClose:()=>e(!1),footer:_e,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(vn,{items:[{id:"new-branch",label:a("session.newWorktree.mode.newBranch"),icon:t.jsx(D,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:a("session.newWorktree.mode.existingBranch"),icon:t.jsx(D,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:m,onSelect:J=>de(J),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[m==="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(G,{variant:"outline",size:"sm",onClick:()=>B(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:x.selectedBranch?"text-foreground":"text-muted-foreground",children:x.selectedBranch||a("session.newWorktree.chooseBranch")}),t.jsx(D,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:H,disabled:!ye||N,title:a("session.newWorktree.fetchBranches"),children:N?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"refresh",className:"size-4"})})]}),t.jsx(Xn,{open:_,title:a("session.newWorktree.selectBranch"),onClose:()=>B(!1),children:t.jsxs("div",{className:"space-y-4",ref:U,children:[t.jsx(Ze,{value:M,onChange:J=>X(J.target.value),placeholder:a("session.newWorktree.searchBranches"),className:"h-8"}),N?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.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:[we&&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(J=>t.jsx("button",{onClick:()=>{R(y=>({...y,selectedBranch:J.value,worktreeName:xs(J.label)})),ae(y=>({...y,touched:!0})),B(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",x.selectedBranch===J.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:J.label})},`${J.source}-${J.value}`))})]}),we&&!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(we?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.otherLocal.map(J=>t.jsx("button",{onClick:()=>{R(y=>({...y,selectedBranch:J,worktreeName:xs(J)})),ae(y=>({...y,touched:!0})),B(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",x.selectedBranch===J?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:J})},J))})]}),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(we?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.otherRemote.map(J=>t.jsx("button",{onClick:()=>{R(y=>({...y,selectedBranch:`remotes/${J}`,worktreeName:xs(J)})),ae(y=>({...y,touched:!0})),B(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",x.selectedBranch===`remotes/${J}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:J})},`remotes/${J}`))})]})]})]})})]}):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")}),m==="new-branch"&&ue&&t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1.5 h-7",children:[t.jsx(D,{name:"github",className:"size-4 text-status-success"}),g.linkedIssue||g.linkedPr?a("session.newWorktree.actions.change"):a("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(Ze,{value:g.branchName,onChange:J=>{h(y=>({...y,branchName:J.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ae(J=>({...J,touched:!0})),placeholder:a("session.newWorktree.branchNamePlaceholder"),disabled:!!g.linkedPr,className:ce("h-8",te.touched&&te.branchError&&"border-destructive",g.linkedPr&&"bg-muted text-muted-foreground")}),g.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(D,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.usingPrBranch",{branch:g.linkedPr.head})})]}),g.linkedIssue&&!g.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(D,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.fromIssue",{number:g.linkedIssue.number,title:g.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")}),m!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const J=xs(m==="new-branch"?g.branchName:"");h(y=>({...y,worktreeName:J,isSyncingWorktreeName:!0}))},disabled:!g.branchName||g.worktreeName===xs(g.branchName),className:ce("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",g.worktreeName===xs(g.branchName)||!g.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(D,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:a("session.newWorktree.actions.reset")})]})]}),t.jsx(Ze,{value:Be.worktreeName,onChange:J=>{m==="new-branch"?h(y=>({...y,worktreeName:J.target.value,isSyncingWorktreeName:!1})):R(y=>({...y,worktreeName:J.target.value}))},onBlur:()=>ae(J=>({...J,touched:!0})),placeholder:a("session.newWorktree.worktreeDirectoryPlaceholder"),className:ce("h-8",te.touched&&te.worktreeError&&"border-destructive")})]}),m==="new-branch"&&!g.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(G,{variant:"outline",size:"sm",onClick:()=>Q(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:g.sourceBranch?"text-foreground":"text-muted-foreground",children:g.sourceBranch||a("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(D,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),g.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("session.newWorktree.newBranchFromSource",{source:g.sourceBranch})}),t.jsx(Xn,{open:Z,title:a("session.newWorktree.selectSourceBranch"),onClose:()=>Q(!1),children:t.jsxs("div",{className:"space-y-4",ref:ne,children:[t.jsx(Ze,{value:ee,onChange:J=>K(J.target.value),placeholder:a("session.newWorktree.searchBranches"),className:"h-8"}),N?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.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:[be&&le&&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:ve.matching.map(J=>t.jsx("button",{onClick:()=>{h(y=>({...y,sourceBranch:J.value})),Q(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",g.sourceBranch===J.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:J.label})},`${J.source}-${J.value}`))})]}),be&&!le&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),ve.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(be?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:ve.otherLocal.map(J=>t.jsx("button",{onClick:()=>{h(y=>({...y,sourceBranch:J})),Q(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",g.sourceBranch===J?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:J})},J))})]}),ve.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(be?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:ve.otherRemote.map(J=>t.jsx("button",{onClick:()=>{h(y=>({...y,sourceBranch:`remotes/${J}`})),Q(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",g.sourceBranch===`remotes/${J}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:J})},`remotes/${J}`))})]})]})]})})]}),(g.linkedIssue||g.linkedPr)&&m==="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(D,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),g.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.issueNumber",{number:g.linkedIssue.number})}),g.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.prNumber",{number:g.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:g.linkedIssue?.title||g.linkedPr?.title}),t.jsx("a",{href:g.linkedIssue?.url||g.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:J=>J.stopPropagation(),children:t.jsx(D,{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(D,{name:"close",className:"h-3.5 w-3.5"})})]}),g.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:[g.linkedPr.head," → ",g.linkedPr.base]}),g.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(Ot,{open:s,onOpenChange:e,children:t.jsxs(zt,{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(Kt,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(D,{name:"git-branch",className:"h-5 w-5"}),a("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(vn,{items:[{id:"new-branch",label:a("session.newWorktree.mode.newBranch"),icon:t.jsx(D,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:a("session.newWorktree.mode.existingBranch"),icon:t.jsx(D,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:m,onSelect:J=>de(J),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[m==="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:w,children:[t.jsx(us,{asChild:!0,children:t.jsxs(G,{variant:"outline",size:"sm",className:"h-9 min-w-[220px] max-w-full justify-between gap-2",children:[t.jsx("span",{className:ce("truncate",x.selectedBranch?"text-foreground":"text-muted-foreground"),children:x.selectedBranch||a("session.newWorktree.chooseBranch")}),t.jsx(D,{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:O,children:t.jsxs(Ir,{shouldFilter:!1,children:[t.jsx(Ar,{placeholder:a("session.newWorktree.searchBranches"),value:M,onValueChange:X,onKeyDown:re}),t.jsx(Dr,{disableHorizontal:!0,children:N?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.length===0?t.jsx(Er,{children:a("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[we&&se&&t.jsx(Bs,{heading:a("session.newWorktree.matchingBranches"),children:Ie.matching.map(J=>t.jsx(Ms,{value:J.value,onSelect:()=>{R(y=>({...y,selectedBranch:J.value,worktreeName:xs(J.label)})),ae(y=>({...y,touched:!0})),w(!1)},children:t.jsx("span",{className:"typography-small break-all",children:J.label})},`${J.source}-${J.value}`))}),we&&!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:[we&&t.jsx(Dn,{}),t.jsx(Bs,{heading:a(we?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:Ie.otherLocal.map(J=>t.jsx(Ms,{value:J,onSelect:()=>{R(y=>({...y,selectedBranch:J,worktreeName:xs(J)})),ae(y=>({...y,touched:!0})),w(!1)},children:t.jsx("span",{className:"typography-small break-all",children:J})},`local-${J}`))})]}),Ie.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(Ie.otherLocal.length>0||we)&&t.jsx(Dn,{}),t.jsx(Bs,{heading:a(we?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:Ie.otherRemote.map(J=>t.jsx(Ms,{value:`remotes/${J}`,onSelect:()=>{R(y=>({...y,selectedBranch:`remotes/${J}`,worktreeName:xs(J)})),ae(y=>({...y,touched:!0})),w(!1)},children:t.jsx("span",{className:"typography-small break-all",children:J})},`remote-${J}`))})]})]})})]})})]}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:H,disabled:!ye||N,title:a("session.newWorktree.fetchBranches"),children:N?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{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")}),m==="new-branch"&&ue&&t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1.5 h-7",children:[t.jsx(D,{name:"github",className:"size-4 text-status-success"}),g.linkedIssue||g.linkedPr?a("session.newWorktree.actions.change"):a("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(Ze,{value:g.branchName,onChange:J=>{h(y=>({...y,branchName:J.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ae(J=>({...J,touched:!0})),placeholder:a("session.newWorktree.branchNamePlaceholder"),disabled:!!g.linkedPr,className:ce("h-8",te.touched&&te.branchError&&"border-destructive",g.linkedPr&&"bg-muted text-muted-foreground")}),g.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(D,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.usingPrBranch",{branch:g.linkedPr.head})})]}),g.linkedIssue&&!g.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(D,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.fromIssue",{number:g.linkedIssue.number,title:g.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")}),m!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const J=xs(m==="new-branch"?g.branchName:"");h(y=>({...y,worktreeName:J,isSyncingWorktreeName:!0}))},disabled:!g.branchName||g.worktreeName===xs(g.branchName),className:ce("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",g.worktreeName===xs(g.branchName)||!g.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(D,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:a("session.newWorktree.actions.reset")})]})]}),t.jsx(Ze,{value:Be.worktreeName,onChange:J=>{m==="new-branch"?h(y=>({...y,worktreeName:J.target.value,isSyncingWorktreeName:!1})):R(y=>({...y,worktreeName:J.target.value}))},onBlur:()=>ae(J=>({...J,touched:!0})),placeholder:a("session.newWorktree.worktreeDirectoryPlaceholder"),className:ce("h-8",te.touched&&te.worktreeError&&"border-destructive")})]}),m==="new-branch"&&!g.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:L,onOpenChange:E,children:[t.jsx(us,{asChild:!0,children:t.jsxs(G,{variant:"outline",size:"sm",className:"h-9 min-w-[220px] max-w-full justify-between gap-2",children:[t.jsx("span",{className:ce("truncate",g.sourceBranch?"text-foreground":"text-muted-foreground"),children:g.sourceBranch||a("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(D,{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:Y,children:t.jsxs(Ir,{shouldFilter:!1,children:[t.jsx(Ar,{placeholder:a("session.newWorktree.searchBranches"),value:ee,onValueChange:K,onKeyDown:re}),t.jsx(Dr,{disableHorizontal:!0,children:N?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.length===0?t.jsx(Er,{children:a("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[be&&le&&t.jsx(Bs,{heading:a("session.newWorktree.matchingBranches"),children:ve.matching.map(J=>t.jsx(Ms,{value:J.value,onSelect:()=>{h(y=>({...y,sourceBranch:J.value})),E(!1)},children:t.jsx("span",{className:"typography-small break-all",children:J.label})},`${J.source}-${J.value}`))}),be&&!le&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),ve.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[be&&t.jsx(Dn,{}),t.jsx(Bs,{heading:a(be?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:ve.otherLocal.map(J=>t.jsx(Ms,{value:J,onSelect:()=>{h(y=>({...y,sourceBranch:J})),E(!1)},children:t.jsx("span",{className:"typography-small break-all",children:J})},`local-${J}`))})]}),ve.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(ve.otherLocal.length>0||be)&&t.jsx(Dn,{}),t.jsx(Bs,{heading:a(be?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:ve.otherRemote.map(J=>t.jsx(Ms,{value:`remotes/${J}`,onSelect:()=>{h(y=>({...y,sourceBranch:`remotes/${J}`})),E(!1)},children:t.jsx("span",{className:"typography-small break-all",children:J})},`remote-${J}`))})]})]})})]})})]}),g.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("session.newWorktree.newBranchFromSource",{source:g.sourceBranch})})]}),(g.linkedIssue||g.linkedPr)&&m==="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(D,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),g.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.issueNumber",{number:g.linkedIssue.number})}),g.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.prNumber",{number:g.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:g.linkedIssue?.title||g.linkedPr?.title}),t.jsx("a",{href:g.linkedIssue?.url||g.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:J=>J.stopPropagation(),children:t.jsx(D,{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(D,{name:"close",className:"h-3.5 w-3.5"})})]}),g.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:[g.linkedPr.head," → ",g.linkedPr.base]}),g.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(Jt,{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(D,{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(G,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:me,children:a("session.newWorktree.actions.cancel")}),t.jsxs(G,{size:"sm",onClick:Je,disabled:!Re||me,className:"gap-1.5",children:[me&&t.jsx(D,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),a(me?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(Mv,{open:F,onOpenChange:I,onSelect:q})]})}const rj=s=>{Ns.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),ze.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&Wm.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),mu(),ys.reconnectToRuntimeBaseUrl(),lt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),ns.getState().resetForRuntimeSwitch(),Cr.getState().resetForRuntimeSwitch(),Ns.getState().restoreForRuntimeSwitch(s.runtimeKey),ze.getState().restoreForRuntimeSwitch(s.runtimeKey),qm()};export{Lh as $,Ol as A,bn as B,Zv as C,nj as D,yn as E,Jv as F,$f as G,Uf as H,cl as I,_i as J,ks as K,sj as L,Uv as M,aj as N,Vv as O,tj as P,on as Q,an as R,zy as S,Wv as T,ux as U,qs as V,nn as W,sn as X,Gy as Y,dl as Z,Co as _,ej as a,So as a0,ih as a1,mc as a2,pc as a3,Ox as a4,Bv as a5,Vp as a6,Ul as a7,Up as a8,Qv as a9,av as b,Yv as c,_v as d,Ll as e,Ln as f,os as g,Gb as h,Ut as i,Hf as j,Oo as k,bu as l,Hv as m,$v as n,Ky as o,ms as p,Xh as q,rj as r,Yh as s,qv as t,Xv as u,Gv as v,Qh as w,vn as x,px as y,xn as z};
|